|
Debugging with GDB and winsock
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
ThomasWatts
USA (66 posts) bio
|
| Date |
Wed 14 Nov 2007 10:35 AM (UTC) [ quote
] |
| Message |
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. | top |
|
| Posted by |
Nick Gammon
Australia (18,770 posts) bio
Forum Administrator |
| Date |
Reply #1 on Thu 15 Nov 2007 07:29 PM (UTC) [ quote
] |
| Message |
Thanks for the tip. I mentioned on that page you should be able to attach to a running process in a single step like this:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,670 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )