This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Call function from gdb at breakpoint?

Hi,

Is it possible to call an arbitrary function at a breakpoint in gdb on the nRF52? I know you can with normal gdb, but I haven't been able to make it work with the cross ARM version. Thanks.

SDK13 PCA10040/nRF52832 GNU gdb (GNU Tools for ARM Embedded Processors 6-2017-q1-update) Eclipse OSX

  • Hi,

    I just tested this with gcc-arm-none-eabi-6_2-2016q4 on the blinky example. I added this function which blinks with 1 sec delay instead of 500 ms:

    void test_function(void)
    {
        for (int i = 0; i < LEDS_NUMBER; i++)
        {
            bsp_board_led_invert(i);
            nrf_delay_ms(1000);
        }    
    }
    

    Remember to run this function once before entering while(1) loop to ensure that gcc does not dump it.

    arm-none-eabi-gdb _build/*.out 
    (gdb) target remote :2331 
    (gdb) load 
    (gdb) mon reset 
    (gdb) c 
    <break somewhere in your code once the 500 ms routine starts, using CTRL+C> 
    (gdb) call test_function()
    

    It is very important that you add the parentheses when calling "call func()". Once it is finished calling the function, it will go back to a halted state.

    Happy debugging! Cheers, Håkon

Related