The previous post was closed, but relevant to the subject.
Previous post: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653
I am using WindowsXP, and my dev platform is MingW32.
GDB version is 6.3 native to MingW32.
I recently decided to try and use said program to find out why my program was crashing with no useful information (turned out to be bad char* management).
GDB barfs on the winsock listen function returning a SIGSEGV. This makes debugging absolutely impossible. Or not so I later found out (after much superlative frustration).
The 'attach' command comes to the rescue!
Step 1: Run the target program as normal.
Step 2: Run GDB in a separate command prompt window.
Step 3: Using the task manager (CTRL-Shift-Esc), find the process ID (PID) of the target program.
Step 4: in GDB type 'attach <name> <pid>' to attach GDB to the already running process.
Name is the executable name relative to the path that GDB was run from excluding '.exe'
Step 5: in GDB type 'continue', this allows the attached program to run as normal again.
Now when the bugs fly free, GDB comes to the rescue and outputs some useful information about the problem. As for exiting GDB as well as your program, I just hit (CTRL-C) several times in both command windows.
I hope this will be helpful to anyone having the same problems as I did. As usual however, Your Mileage May Vary.
Previous post: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653
I am using WindowsXP, and my dev platform is MingW32.
GDB version is 6.3 native to MingW32.
I recently decided to try and use said program to find out why my program was crashing with no useful information (turned out to be bad char* management).
GDB barfs on the winsock listen function returning a SIGSEGV. This makes debugging absolutely impossible. Or not so I later found out (after much superlative frustration).
The 'attach' command comes to the rescue!
Step 1: Run the target program as normal.
Step 2: Run GDB in a separate command prompt window.
Step 3: Using the task manager (CTRL-Shift-Esc), find the process ID (PID) of the target program.
Step 4: in GDB type 'attach <name> <pid>' to attach GDB to the already running process.
Name is the executable name relative to the path that GDB was run from excluding '.exe'
Step 5: in GDB type 'continue', this allows the attached program to run as normal again.
Now when the bugs fly free, GDB comes to the rescue and outputs some useful information about the problem. As for exiting GDB as well as your program, I just hit (CTRL-C) several times in both command windows.
I hope this will be helpful to anyone having the same problems as I did. As usual however, Your Mileage May Vary.