Author Topic: How do you load a GDB command file into SlickEdit debug session?  (Read 3942 times)

jasons

  • New Community Member
  • Posts: 1
  • Hero Points: 0
How do you load a GDB command file into SlickEdit debug session?
« on: September 19, 2011, 03:49:26 pm »
I want to load a GDB command file into a SlickEdit debug session.  I've trying adding it as a command line argument to the debug configuration, but that doesn't seem to work.  Can I do this and if so, how?  TIA

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2091
  • Hero Points: 259
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #1 on: September 21, 2011, 07:49:58 pm »
You are on the right track, pass the command file to GDB using -x <gdbinit>.  You might want to try passing it in using an absolute path.  You can turn on the def_debug_logging option (Macro > Set Variable...) in order to see what is going on with the debugger.  The logging information will be in vs.log in your configuration directory.

Note that when you give GDB a command file for it to run at startup, there is a limited number of things you can do, because certain commands are not enabled in GDB/MI mode, and also some commands, such as setting breakpoints, running, stepping, etc, will leave GDB in a state which is out of sync with SlickEdit.

You can also send individual commands to GDB after starting your debug session by using the SlickEdit command "debug_send_command".

Nox Metus

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #2 on: February 10, 2012, 01:20:14 am »
You can also send individual commands to GDB after starting your debug session by using the SlickEdit command "debug_send_command".
Sorry for a newbie question, but how to use  "debug_send_command"? Write a script? Can I instead send commands interactively during a debug session? I need it to load shared libraries symbols when connected to a gdbserver.

lambertia

  • Senior Community Member
  • Posts: 382
  • Hero Points: 14
  • I have nothing sufficiently witty to say.
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #3 on: February 10, 2012, 05:06:12 am »
You can also send individual commands to GDB after starting your debug session by using the SlickEdit command "debug_send_command".
Sorry for a newbie question, but how to use  "debug_send_command"? Write a script? Can I instead send commands interactively during a debug session? I need it to load shared libraries symbols when connected to a gdbserver.

If you do this a lot you can specify a configuration file to load in the Debugging|Configurations|Arguments:--command=~/etc/my-gdb-commands-ls.txt

To enter commands interactively, try clicking on the status bar at the bottom of the editor (to the left of the line number display)

Nox Metus

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #4 on: February 10, 2012, 08:20:35 pm »
If you do this a lot you can specify a configuration file to load in the Debugging|Configurations|Arguments:--command=~/etc/my-gdb-commands-ls.txt
This won't do. I need to load symbols for shared libraries. To do it I need first check where in memory the libraries were loaded on the target system (where gdbserver is running), and then issue a command to gdb in the middle of the debugging session, not during invocation of gdb.

To enter commands interactively, try clicking on the status bar at the bottom of the editor (to the left of the line number display)
Thanks! Will try it.

PogusMagnus

  • Community Member
  • Posts: 16
  • Hero Points: 1
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #5 on: May 08, 2012, 02:55:48 pm »
You are on the right track, pass the command file to GDB using -x <gdbinit>.  You might want to try passing it in using an absolute path.

Nope!
This can not work. On starting GDB SlickEdit is secretly passing the option "--nx" which directly contradicts the "-x" option. Both are mutually exclusive and "--nx" has a higher priority. So, on starting GDB no configuration files whatsoever are loaded. (Which, in my particular case, sucks big time  >:( )

@SlickEdit: Is there any way to remove the "--nx" option from the invocation of GDB?
« Last Edit: May 08, 2012, 02:57:22 pm by PogusMagnus »

john.dehelian

  • Community Member
  • Posts: 10
  • Hero Points: 1
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #6 on: May 21, 2015, 07:26:08 pm »
Was there ever an answer to this. Also if I put -ex 'handle SIG32 nopass nostop noprint' in the arguments field it doesn't work. Here is the log:
Code: [Select]
debug[2015-05-21T15:09:49.066676Z]GDB starting gdb: /home/john/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gdbtui
debug[2015-05-21T15:09:49.066887Z]GDB startup arg[0]=/home/john/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gdbtui
debug[2015-05-21T15:09:49.066948Z]GDB startup arg[1]=-nx
debug[2015-05-21T15:09:49.067005Z]GDB startup arg[2]=-interpreter=mi
debug[2015-05-21T15:09:49.067061Z]GDB startup arg[3]=-quiet
debug[2015-05-21T15:09:49.254819Z]======================================
debug[2015-05-21T15:09:50.798968Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.799275Z]GDB handle_event: &"/lib/libsqlite3.so.0: No such file or directory.\n"
debug[2015-05-21T15:09:50.799719Z]GDB handle_event: =library-loaded,id="/lib/libsqlite3.so.0",target-name="/lib/libsqlite3.so.0",host-name="/lib/libsqlite3.so.0",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.800157Z]GDB handle_event: &"warning: .dynamic section for \"/lib/libgpio.so\" is not at the expected address (wrong library or version mismatch?)\n"
debug[2015-05-21T15:09:50.800674Z]GDB handle_event: =library-loaded,id="/lib/libgpio.so",target-name="/lib/libgpio.so",host-name="/lib/libgpio.so",low-address="0x0x400a5a48",high-address="0x0x400a72dc",symbols-loaded="0"
debug[2015-05-21T15:09:50.800967Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.801201Z]GDB handle_event: &"/lib/libdl.so.2: No such file or directory.\n"
debug[2015-05-21T15:09:50.801604Z]GDB handle_event: =library-loaded,id="/lib/libdl.so.2",target-name="/lib/libdl.so.2",host-name="/lib/libdl.so.2",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.801879Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.802101Z]GDB handle_event: &"/lib/librt.so.1: No such file or directory.\n"
debug[2015-05-21T15:09:50.802505Z]GDB handle_event: =library-loaded,id="/lib/librt.so.1",target-name="/lib/librt.so.1",host-name="/lib/librt.so.1",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.802779Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.803008Z]GDB handle_event: &"/lib/libgcc_s.so.1: No such file or directory.\n"
debug[2015-05-21T15:09:50.803423Z]GDB handle_event: =library-loaded,id="/lib/libgcc_s.so.1",target-name="/lib/libgcc_s.so.1",host-name="/lib/libgcc_s.so.1",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.803704Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.803970Z]GDB handle_event: &"/lib/libc.so.6: No such file or directory.\n"
debug[2015-05-21T15:09:50.804368Z]GDB handle_event: =library-loaded,id="/lib/libc.so.6",target-name="/lib/libc.so.6",host-name="/lib/libc.so.6",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.804662Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.804897Z]GDB handle_event: &"/lib/libpthread.so.0: No such file or directory.\n"
debug[2015-05-21T15:09:50.805323Z]GDB handle_event: =library-loaded,id="/lib/libpthread.so.0",target-name="/lib/libpthread.so.0",host-name="/lib/libpthread.so.0",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.805598Z]GDB handle_event: &"Error while mapping shared library sections:\n"
debug[2015-05-21T15:09:50.805835Z]GDB handle_event: &"/lib/ld-linux.so.3: No such file or directory.\n"
debug[2015-05-21T15:09:50.806276Z]GDB handle_event: =library-loaded,id="/lib/ld-linux.so.3",target-name="/lib/ld-linux.so.3",host-name="/lib/ld-linux.so.3",low-address="0x0x0",high-address="0x0x0",symbols-loaded="0"
debug[2015-05-21T15:09:50.856912Z]======================================
debug[2015-05-21T15:09:50.862914Z]      GDB event: empty event packet
debug[2015-05-21T15:09:50.863009Z]GDB command_reply: DONE
debug[2015-05-21T15:10:23.135424Z]GDB handle_event: =thread-created,id="2",group-id="42000"
debug[2015-05-21T15:10:23.135812Z]GDB handle_event: ~"[New Thread 2518]\n"
debug[2015-05-21T15:10:23.136124Z]GDB handle_event: ~"[Switching to Thread 2518]\n"
debug[2015-05-21T15:10:23.136765Z]GDB handle_event: *stopped,reason="signal-received",signal-name="SIG32",signal-meaning="Real-time event 32",frame={addr="0x401a9134",func="??",args=[]},thread-id="2",stopped-threads="all",core="0"
debug[2015-05-21T15:10:23.136964Z]======================================
The command line approach works. But it would be a pain to have to remember to do that every time I start the debugger.
Any resolution on the command file loader?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2091
  • Hero Points: 259
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #7 on: May 21, 2015, 10:11:03 pm »
Two things.  One, the log doesn't show that anything extra was passed to gdb, so I don't think you put that in the arguments correctly, or if you did, you did not put it into the GDB configuration that you were actually using.

Look again at Debug > Debugger Options... > Configurations.

With respect to -nx, in my experience with GDB, the last argument specified wins, so, it does not matter that -nx is specified first.  I've never seen it behave differently.  Try "gdb -nx -ex help" from the unix command line as proof.

john.dehelian

  • Community Member
  • Posts: 10
  • Hero Points: 1
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #8 on: May 22, 2015, 01:17:10 pm »
Thanks Dennis, I ran it again and this is what I got.
Code: [Select]
debug[2015-05-22T08:55:19.510694Z]GDB starting gdb: /home/john/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gdb
debug[2015-05-22T08:55:19.510934Z]GDB startup arg[0]=/home/john/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gdb
debug[2015-05-22T08:55:19.510999Z]GDB startup arg[1]=-nx
debug[2015-05-22T08:55:19.511060Z]GDB startup arg[2]=-interpreter=mi
debug[2015-05-22T08:55:19.511120Z]GDB startup arg[3]=-quiet
debug[2015-05-22T08:55:19.511179Z]GDB startup arg[4]=-ex
debug[2015-05-22T08:55:19.511237Z]GDB startup arg[5]='handle
debug[2015-05-22T08:55:19.511295Z]GDB startup arg[6]=SIG32
debug[2015-05-22T08:55:19.511354Z]GDB startup arg[7]=nopass
debug[2015-05-22T08:55:19.511414Z]GDB startup arg[8]=nostop
debug[2015-05-22T08:55:19.511472Z]GDB startup arg[9]=noprint'
After typing debug_send_command info signals I get
debug[2015-05-22T09:00:07.504702Z]      GDB event: ~"SIG32         Yes\tYes\tYes\t\tReal-time event 32\n"
Which means it didn't work.
It looks like the arguments are getting separated. Perhaps I need to quote the whole command?

john.dehelian

  • Community Member
  • Posts: 10
  • Hero Points: 1
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #9 on: May 22, 2015, 01:57:07 pm »
OK found something interesting. The --command does work. But the arguments parameter doesn't take effect until the second time you run it.
I put this on the arguments line:
--command=~/.slickedit/19.0.1/gdb_init.ini
And filled the file with:
handle SIG32 pass nostop noprint
Then my program is not interrupted with the pthread_cancel function.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2091
  • Hero Points: 259
Re: How do you load a GDB command file into SlickEdit debug session?
« Reply #10 on: May 22, 2015, 04:03:54 pm »
Glad that is working for you now.  The -ex option should have worked also, but you needed to use double-quotes rather than single quotes to quote the argument.