Thread: Debugging in Win32 Enivornment

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    17

    Question Debugging in Win32 Enivornment

    Hi all, Lonnie here.

    I can trying to figure out how to write a simple debugger for windows. The goal would be to execute a program using CreateProcess() (or if there is something better please let me know), if the program has any bugs which allow us to make it crash (don't all applications have bugs, hence we need debuggers haha) then it would catch the crash and output debugging info such as first chance/second chance, all extended registers values (ebx=, esi for pointers, etc), and if the crash was an access violation, stack overflow, things of that nature. Then, for a bonus, kill the process.

    Understand?

    I have been scouring the internet for a simple example of a this FOREVER and haven't found anything that would get me running and working code.. I found this but I can't seem to put it together and make it do all that I would like.

    Anybody got any shiny, bright ideas?

    Thanks!!!

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    How about reading the GDB source?

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    17
    Assuming there is a windows port of GDB... cause from what I see its mainly a GNU/Linux application.

    Besides that, anything?

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by lonnieh View Post
    Assuming there is a windows port of GDB...
    Of course there is! You are going to have to use your mind and fingers with a little more enthusiasm if you want to pull this off.

    It only took me ONE google to get this:

    GDB on Windows

    Altho I doubt this works quite the way you are hoping!

    Anyway, keep in mind that this

    if the program has any bugs which allow us to make it crash (don't all applications have bugs, hence we need debuggers haha) then it would catch the crash
    is not quite possible; it could only catch bugs which actually cause a crash during execution, not all the ones that could.

    Unless you do some interesting and unique work
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    17
    I was rather asking of an example of a simple debugger, rather than trying to decipher through GDB's source code and piecing it together from there. But I am looking at it as we speak, but if anyone knows of any simpler codes I can see or how the achieve the aforementioned a goals, please let me know.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    But I am looking at it as we speak, but if anyone knows of any simpler codes I can see or how the achieve the aforementioned a goals, please let me know.
    Your task is not all that simple. If you are looking for simple perhaps a different project is in order. Writing a fully functional fully featured debugger for Windows is something that requires a development team with a significant amount of low-level Windows experience. It is definitely not for the faint of heart.

  7. #7
    Registered User
    Join Date
    Aug 2009
    Posts
    17
    I am not looking into writing a fully featured debugger. As stated previously, my goals are:

    1) Create a process
    2) Catch any faults or crashes it may encounter during runtime
    2.1) If It encounters a fault or crash, output debugging info
    2.2) If operations are normal, goto 3
    3) Kill the process

    One would think that may be simpler than a fully featured debugger. Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 10:48 AM
  2. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  3. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 03:26 PM
  4. tools for debugging win32
    By underthesun in forum Windows Programming
    Replies: 4
    Last Post: 02-03-2005, 06:52 AM
  5. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 05:57 PM

Tags for this Thread