GDB Monitor Commands in CLion

I am trying to debug an embedded project using remote gdb. My system:

  • Target: ARM Cortex M0.
  • SEGGER J-Link GDB V6.10 Command Line Version
  • arm-none-eabi-gdb 10/7/201160616-cvs
  • CLion 2016.2.2, Build # CL-162.1967.7
  • Ubuntu 16.04

My .gdbinit file has the following:

target remote localhost:2331 #(I remove this line when debugging with CLion)
set verbose on
file "/path_to_output_file/blinky.elf"
monitor reset
break main

What bothered me for several days is that it works fine if I debug gdb directly from the terminal, but not when I use the debugger in CLion. In CLion, I get an error:

"monitor" is not supported for this purpose.

, "monitor reset" ( , ). CLION, , , , , , reset. , CLion, main().

CLion ? , ?

, CPP-7322 CPP-7256.

+4
1

CLion - .gdbinit . , , . , monitor reset , .

:

  • , GDB :

    # commands from .gdbinit
    target remote localhost:2331
    set verbose on
    file "/path_to_output_file/blinky.elf"
    monitor reset
    break main
    
  • , GDB CLion .gdbinit :

    # commands from .gdbinit
    target remote localhost:2331
    set verbose on
    file "/path_to_output_file/blinky.elf"
    monitor reset
    break main
    
    # commands executed by CLion to attach
    target remote localhost:2331  # <- ERROR (A program is being debugged already)
    
  • GDB CLion attach:

    # commands from .gdbinit
    set verbose on
    file "/path_to_output_file/blinky.elf"
    monitor reset  # <- ERROR not attached to remote gdbserver => unknown command
    
    # ... not executed due to the error above
    break main
    # commands executed by CLion to attach
    target remote localhost:2331
    

, , , , ( : CLion). , , .

:

, CLION, . GDB hooks .

.gdbinit :

define target hookpost-remote
file "/path_to_output_file/blinky.elf"
monitor reset
break main
end

, , , GDB , , , , CLion, .

+5

Source: https://habr.com/ru/post/1656471/


All Articles