-
Notifications
You must be signed in to change notification settings - Fork 564
[C++ification] Continue converting code to "proper" C++ #3759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Mono.Android_TestsAppBundle crashed: |
Huh... This is exactly the same code as in master, don't see a reason why it would fail. We'll see if re-run helps. |
|
The weird and one our recent favorite failure: Neither of those appear to be related to this PR. |
src/monodroid/jni/debug.cc
Outdated
| } | ||
|
|
||
| bool use_fd = false; | ||
| if (strncmp (cmd, "start debugger: ", 16) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: stylistically would it be better if we removed the hardcoded length and instead went with string constants & sizeof()?
static constexpr char COMMAND_START_DEBUGGER[] = "start debugger: ";
if (strncmp (cmd, COMMAND_START_DEBUGGER, sizeof (COMMAND_START_DEBUGGER)-1) == 0) {
...
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would be better (even better with constexpr size_t COMMAND_START_DEBUGGER_LEN = sizeof(COMMAND_START_DEBUGGER)-1 but it would blow out the source code size...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but if you don't mind the visual bloat, I'm ok with it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "visual bloat" would be a good idea, considering that all of these lines are changing anyway..,.
Next commit in the series of making our native code use "proper" C++ constructs,
take advantage of the language's features etc. Changes:
* Fix more compilation warnings arising from differences between platforms
* Compare pointers against `nullptr` instead of the traditional `!p` C-style
check
* Use the `simple_pointer_guard` class in more places
* Use references to pointers instead of pointers to pointers in a handful of
places to decrease the number of null checks
* Switch nested namespace declarations to C++17 style
* Make `Util::ends_with` slightly faster when used with literal strings,
taking advantage of C++ templates
* Move variable declarations closer to places where they are actually used
* Move a number of extern "C" functions to `external-api.cc`
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@grendello Why? I think or It means "if valid", not "if not 0". |
Context: dotnet#3759 Context: dotnet@6d85759#diff-e99739c16155208685952aa52870d4cdL33-L39 When switching from C-style `xcalloc` to C++-style `new` I failed to use the proper type to allocate array which holds directories where Android placed the APK files of the application. This mistake manifested itself only when using AppBundles, which is where we allocate more than one entry of the array. The resulting error was the following runtime exception: 11-04 12:27:55.722 3339 3339 E mono : Unhandled Exception: 11-04 12:27:55.722 3339 3339 E mono : System.DllNotFoundException: __Internal assembly:<unknown assembly> type:<unknown type> member:(null) 11-04 12:27:55.722 3339 3339 E mono : at (wrapper managed-to-native) Android.Runtime.JNIEnv.monodroid_timing_start(string) Which occurred because Xamarin.Android runtime failed to load `libmonodroid.so` from one of the directories that should have been stored in the array mentioned above - usually found in the *last* entry of the array. When iterating over the array, the XA runtime would end up with a null pointer after the end of the array instead of a pointer to the last entry. This commit uses the proper type when allocating the array.
Context: dotnet#3759 Context: dotnet@6d85759#diff-e99739c16155208685952aa52870d4cdL33-L39 When switching from C-style `xcalloc` to C++-style `new` I failed to use the proper type to allocate array which holds directories where Android placed the APK files of the application. This mistake manifested itself only when using AppBundles, which is where we allocate more than one entry of the array. The resulting error was the following runtime exception: 11-04 12:27:55.722 3339 3339 E mono : Unhandled Exception: 11-04 12:27:55.722 3339 3339 E mono : System.DllNotFoundException: __Internal assembly:<unknown assembly> type:<unknown type> member:(null) 11-04 12:27:55.722 3339 3339 E mono : at (wrapper managed-to-native) Android.Runtime.JNIEnv.monodroid_timing_start(string) Which occurred because Xamarin.Android runtime failed to load `libmonodroid.so` from one of the directories that should have been stored in the array mentioned above - usually found in the *last* entry of the array. When iterating over the array, the XA runtime would end up with a null pointer after the end of the array instead of a pointer to the last entry. This commit uses the proper type when allocating the array.
Next commit in the series of making our native code use "proper" C++ constructs,
take advantage of the language's features etc. Changes:
nullptrinstead of the traditional!pC-style checksimple_pointer_guardclass in more placesplaces to decrease the number of null checks
Util::ends_withslightly faster when used with literal strings,taking advantage of C++ templates
external-api.cc