User forums > Using Code::Blocks

[GDB] How to pass a dynamically defined parameter to the debugger?

<< < (2/2)

J.:
@Ollydbg:

On the GDB shell the pid can be determined by
--- Code: ---(gdb) shell ps -W | gawk "/APP\.EXE/{ print $1 }"
--- End code ---
where the -W flag retrieves the windows processes as well.  Outside GDB, i.e. using cmd, the same works with 'tasklist' instead of 'ps -W'.

What could be an easy and quick solution is a canned sequence of commands loaded at gdb start (.gdbinit?). But up to now I could not manage to define the local gdb variable $PID using 'set $PID=...' and then passing that to 'attach'. Any ideas?


Ultimately I want to debug a .dll compiled by MinGW which is called by the host excel.exe.

Sorry for the pure formatting, I am travelling right now.

oBFusCATed:

--- Quote from: J. on December 04, 2016, 01:18:48 pm ---What could be an easy and quick solution is a canned sequence of commands loaded at gdb start (.gdbinit?). But up to now I could not manage to define the local gdb variable $PID using 'set $PID=...' and then passing that to 'attach'. Any ideas?

--- End quote ---

Adding stuff to .gdbinit won't help, because C::B is the one that starts gdb and it won't ever start it if you don't use the debug->start or debug->attach menu items.
Without gdb starting .gdbinit does nothing.

ollydbg:

--- Quote from: J. on December 04, 2016, 01:18:48 pm ---Ultimately I want to debug a .dll compiled by MinGW which is called by the host excel.exe.

--- End quote ---
What is the method to get the pid of excel.exe? You want to get this pid in C::B, and then let C::B to call the gdb to attach the excel.exe?

Navigation

[0] Message Index

[*] Previous page

Go to full version