[Mono-dev] Compiling Mono with debug symbols to diagnose an issue with embedded Mono 4.0.2.5
Jonathan Mitchell
jonathan at mugginsoft.com
Thu Aug 6 14:44:32 UTC 2015
> On 6 Aug 2015, at 15:34, Howard Rubin <howard.rubin at hl.konicaminolta.us> wrote:
>
> You have to create the generic method. That can be done in C#, which it
> sounds like you're already doing.
> If you'd like to do that in the calling C++/mono (my preferred solution),
> have a look at
> https://gist.github.com/gedim21/8d86ba8e59ac5d8ed0ee
Thanks for the link.
This is more or less what I am doing - will need to review the code again.
For most of my unit test signatures what I have works fine - only some more complex ones are causing trouble
Jonathan
>
> Howard Rubin
>
> -----Original Message-----
> From: Jonathan Mitchell [mailto:jonathan at mugginsoft.com]
> Sent: Thursday, August 06, 2015 3:03 AM
> To: Howard Rubin <howard.rubin at hl.konicaminolta.us>
> Subject: Re: [Mono-dev] Compiling Mono with debug symbols to diagnose an
> issue with embedded Mono 4.0.2.5
>
>> On 5 Aug 2015, at 21:55, Howard Rubin <howard.rubin at hl.konicaminolta.us>
> wrote:
>>
>> Did the problem situation have to do with generics?
>
> IIRC one of the problem signatures was
>
> public void SendTelemetry(string url, string productCode, params
> KeyValuePair<string, object>[] additionalData)
>
> I use a code generator (which can handle moderate range of signatures
> without issue) to parse
>
> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/dotNET/UnitTests/
> Dubrovnik.UnitTests/ReferenceObject.cs
>
> into
>
> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/dotNET/UnitTests/
> GeneratedObjC/Dubrovnik_UnitTests_ReferenceObject.m
>
> For the problem signature I had to resort to using a managed helper function
> with a simpler signature.
>
>>
>> -----Original Message-----
>> From: Jonathan Mitchell [mailto:jonathan at mugginsoft.com]
>> Sent: Wednesday, August 05, 2015 1:19 PM
>> To: Howard Rubin <howard.rubin at hl.konicaminolta.us>
>> Subject: Re: [Mono-dev] Compiling Mono with debug symbols to diagnose
>> an issue with embedded Mono 4.0.2.5
>>
>> Hi Howard
>>
>> Thanks for that.
>> I have some code that does something similar but I am still running
>> into situations where I just cannot get the signature figured out.
>> IIRC the signature I used agreed with mono_method_full_name() but the
>> method lookup still failed.
>> I will take another crack at it and hopefully inspiration will strike.
>>
>> Thanks again
>>
>> Jonathan
>>
>>
>>> On 5 Aug 2015, at 20:09, Howard Rubin
>>> <howard.rubin at hl.konicaminolta.us>
>> wrote:
>>>
>>> Hi Jonathan,
>>> At the risk of defeating my purpose of debugging mono, here’s what I
>>> use to “figure out what the correct embedded API function signatures”.
>>> Hope this helps, Howard Rubin
>>>
>>> static void ListMethods(MonoClass* theClass) {
>>> void* iterM = NULL;
>>> MonoMethod* mm;
>>> while ((mm = mono_class_get_methods(theClass, &iterM)) != NULL) {
>>> const char* name = mono_method_get_name(mm);
>>> printf("mono_method_get_name returned %s \"%s\"\n", name,
>> mono_method_full_name(mm, true));
>>> }
>>> }
>>>
>>> From: mono-devel-list-bounces at lists.ximian.com
>>> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of
>>> Alexander Köplinger
>>> Sent: Wednesday, August 05, 2015 11:19 AM
>>> To: Mono-devel-list at lists.ximian.com
>>> Subject: Re: [Mono-dev] Compiling Mono with debug symbols to diagnose
>>> an issue with embedded Mono 4.0.2.5
>>>
>>> You can build the MDK with
>> https://github.com/mono/bockbuild#the-mono-mac-distribution, but I'm
>> not sure if that includes debug symbols (I think it does).
>>>
>>> -- Alex
>>>
>>>> From: jonathan at mugginsoft.com
>>>> Date: Wed, 5 Aug 2015 18:06:37 +0100
>>>> To: Mono-devel-list at lists.ximian.com
>>>> Subject: Re: [Mono-dev] Compiling Mono with debug symbols to
>>>> diagnose an issue with embedded Mono 4.0.2.5
>>>>
>>>>
>>>>> On 5 Aug 2015, at 02:12, Jean-Michel.Perraud at csiro.au wrote:
>>>>>
>>>>> I am trying to debug C code, mostly to step through the mono
>>>>> runtime
>> itself.
>>>> I too would like to debug the Mono runtime itself and so would
>>>> really,
>> really, really like to able to build an MDK with debug symbols and
>> source code references.
>>>>
>>>> Why do I need to debug the runtime?
>>>> I have written an Obj-C > C# bridge utilising the runtime and in
>>>> some
>> situations I cannot figure out what the correct embedded API function
>> signatures are for more complex generic managed methods. Being able to
>> debug the runtime would give me some insight into what is going on in
>> the method signature search process.
>>>>
>>>>> That said, I would not at all refuse a howto guide for mixed mode
>>>>> (C
>> and C#) debugging on Linux (not possible so far as I know). I may try
>> to give a try on Windows with Visual Studio, but as a fallback option
>> as this issue may not be reproducible on it anyway.
>>>>
>>>> Here is my take on debugging Mono based on working on OS X.
>>>>
>>>> C
>>>> ==
>>>>
>>>> On the Obj-C side (Obj-C is a strict superset of C) I should be able
>>>> to
>> step into the Mono runtime code via the Xcode side if my Mono runtime
>> build supported debug symbols and their source code references. I
>> reckon that most C IDEs should be fit to do the same.
>>>>
>>>>
>>>> C#
>>>> ==
>>>>
>>>> I don’t know of a way to seamlessly debug both C and C# via the same
>>>> IDE
>> on OS X (perhaps VS can so this on windows).
>>>> To debug the managed code in my OS X app I do roughly the following
>> (more detail follows in the notes below).
>>>>
>>>> 1. Configure the OS X app embedded Mono code to use the Mono soft
>> debugger (this is a remote capable software debugger that runs over
>> TCP-IP see
> http://www.mono-project.com/docs/advanced/runtime/docs/soft-debugger/).
>>>> 2. Run my OS X outside of my Xcode IDE. If I don’t do this then the
>> signals generated by the debugee tend to get caught by the IDE
>> debugger rather than the Mono soft debugger.
>>>> 3. Fire up Xamarin Studio (XS) on a Windows machine (in my case a
>> Windows VM on the same physical machine but a networked base PC should
>> work just fine too).
>>>> 4. In XS connect to the remote debugger, set breakpoints etc.
>>>> 5. Exercise the OS X app and trigger breakpoints in XS.
>>>>
>>>> Getting the soft debugger/Xamarin setup correctly can be fiddly but
>>>> it
>> does work.
>>>> It may be possible to debug the managed code by Using Xamarin Studio
>>>> on
>> OS X or Linux but in my case (as I was building the Managed code
>> assemblies on the Windows VM anyway) it was easiest to run XS on Windows.
>>>>
>>>> Debugging Mono Embedded API
>>>> ===========================
>>>>
>>>> The embedded managed code can be debugged (including breakpoints and
>> single stepping) using Xamarin Studio.
>>>>
>>>> 1. Config OS X app to attach to Mono soft Debugger.
>>>>
>>>> Xamarin Studio must be running on machine with IP 192.168.1.72 (in
>>>> this case my windows VM) [DBManagedEnvironment
>>>> setRuntimeOptions:@{@"address" : @"192.168.1.72", @"port" :
>>>> @"10000", @"loglevel" : @"0"}];
>>>>
>>>> 2. Call DBManagedEnvironment +setRuntimeOptions: with IP address and
>> port of Windows VM running the Xamarin Studio debugger.
>>>>
>>>> + (void)setRuntimeOptions:(NSDictionary *)options
>>>> {
>>>> // NOTE: be sure to call this before -initWithDomainName
>>>>
>>>> // for info on these options see man mono // the debugger can be
>>>> configured either as a client or a server NSString *address =
>>>> options[@"address"]?:@"127.0.0.1";
>>>> NSString *port = options[@"port"]?:@"10000"; NSString *server =
>>>> options[@"server"]?:@"n"; NSString *suspend =
>>>> options[@"suspend"]?:@"y"; NSString *loglevel =
>>>> options[@"loglevel"]?:@"1"; NSString *timeout =
>>>> options[@"timeout"]?:@"10";
>>>>
>>>> NSString *agent = [NSString
>>>> stringWithFormat:@"--debugger-agent=transport=dt_socket,address=%@:%
>>>> @,server=%@,suspend=%@,loglevel=%@,timeout=%@", address, port,
>>>> server, suspend, loglevel,timeout]; const char* jit_options[] = {
>>>> "--soft-breakpoints", [agent UTF8String] };
>>>>
>>>> mono_jit_parse_options(2, (char**)jit_options);
>>>>
>>>> mono_debug_init(MONO_DEBUG_FORMAT_MONO);
>>>> }
>>>>
>>>> see
>>>> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework
>>>> /XCode/DBManagedEnvironment.m#L167
>>>>
>>>>
>>>> 3. Run app outside of Xcode. The app will pause if the remote
>>>> debugger
>> is not responding.
>>>> 4. Run Xamarin Studio (preconfigure env var to enable the soft debug
>> menu if it is not visible) on the VM and load the solution being
>> debugged on OS X.
>>>> 5. Set start up project as appropriate (May be better to have a
>>>> dummy
>> exe project rather than rebuild this all the time).
>>>> 6. Select Run - Run with - Custom command Mono soft debugger.
>>>> 7. Enter IP address and port.
>>>> 8. Click Listen.
>>>> 9. Set breakpoints as normal.
>>>>
>>>> Notes on Use of the Mono Soft Debugger
>>>> ======================================
>>>>
>>>> See http://www.jeffongames.com/2012/03/debugging-embedded-mono/
>>>> http://mono.1490590.n4.nabble.com/remote-debugging-a-hello-world-app
>>>> lication-td4591791.html
>>>>
>>>> The debugee should connect to the debugger on the configured
>>>> listener IP
>> and port.
>>>> The Windows firewall will need to allow the incoming connection.
>>>> To check if the connection is up and running;
>>>>
>>>> // manual check if connection to debugger listener can be
>>>> established teqlnet 192.168.1.72 10000
>>>>
>>>> // check state of established network connections netstat -n -f inet
>>>>
>>>> For the soft debugger signal handler to work correctly the app must
>>>> be
>> executed outside of Xcode.
>>>> Other signal handlers, such as those installed by HockeyApp, must be
>> disabled while the soft debugger is in use.
>>>> Remember to use a debug build of the managed code!
>>>>
>>>> http://www.mono-project.com/docs/advanced/runtime/docs/soft-debugger
>>>> /
>>>>
>>>> HTH
>>>>
>>>> Jonathan
>>>> _______________________________________________
>>>> Mono-devel-list mailing list
>>>> Mono-devel-list at lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>> <Untitled attachment 00299.txt>
>
>
>
More information about the Mono-devel-list
mailing list