6 years, 5 months ago.

How to debug the mbed library ?

Hi everyone,

I would like to study the inner working of the mbed API. Yes, I have looked at https://developer.mbed.org/handbook/mbed-library-internals

What I would like to do is be able to debug step by step the mbed library itself.

I have downloaded gdb, configured it to launch arm-based elf images. I am using the simulator built-in with gdb (target sim) as I don't really know if it is possible to debug code on my LPC2368.

I am able to debug my application, but when a call to an mbed API function is done, it seems like the debugger is unable to step into it.

I have tried recompiling the mbed library from the git repository with "python workspace_tools/build.py -m LPC2368 -t GCC_ARM -o debug-info" and then copy is from build/ to my actual project (exported from the IDE to use ARMgcc). Still doesn't work.

Do you know where I can get those symbols and how to load them into gdb ?

Regards

1 Answer

6 years, 5 months ago.

Hi,

You need to put "debug-info" build option in your private_setting.py in your workspace_tools.

BUILD_OPTIONS = ["debug-info"]

Please see my private_settings.py for your reference.

https://gist.github.com/toyowata/21980034211515794b7e

I hope this helps.

Thanks.

I have managed to step into the constructor of DigitalOut but I still seem to be blocked : I can't go into gpio_init_out()

I have a message saying "Single stepping until exit from function gpio_init_out, which has no line number information."

Is there something else to put to get access to the inner working of those gpio functions ?

posted by Nathan O. 19 Apr 2015

I'm not sure why you cannot step into the function gpio_init_out since I usually using MDK-ARM, not gcc.

The gpio_init_out() calls _gpio_init_out() function which is static inlined in the gpio.c. It's worth trying to put -fno-inline command option in gcc.py script.

        if "debug-info" in self.options:
            common_flags.append("-g")
            common_flags.append("-O0")
            common_flags.append("-fno-inline") # and may be -fno-eliminate-unused-debug-types
        else:
            common_flags.append("-O2")
posted by Toyomasa Watarai 20 Apr 2015