Find the answer to your Linux question:
Results 1 to 7 of 7
how do i trace a program in gcc????...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    70

    tracing in gcc

    how do i trace a program in gcc????

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Hi,

    You can use gdb, install it with your Synaptic Package Manager or with apt-get.
    Here you can find documentation about it:

    GDB: The GNU Project Debugger

    Regards

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    70

    Exclamation

    hey franklin when i inserted the Ubuntu cd it showed new packages but its not showin again and i didnt install any new packages at tat time....and am not able to install GDB.....i tried apt-get install GDB it says no packages found....plz help....its urgent

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Don't use capital letters, it's gdb not GDB.

    Regards

  5. #5
    Just Joined!
    Join Date
    Sep 2007
    Posts
    70
    hey thanks franklin i actually recognised tat mistake of mine...it was already installed....apt-cache policy gdb.....can u jus help me how to use it???please....

  6. #6
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Googling for "gdb tutorial" brings up some good hits. I suggest you check them out.

    The basic usage is that you compile your program with the '-g' flag to gcc, and then you run "gdb < EXECUTABLE NAME >". You can now set breakpoints, step through the code line by line, print out variables as you go, etc.

    The other main usage is to run the command "ulimit -c unlimited". This will cause programs that crash to produce coredumps. So you run your program (again, compiled with '-g'), let it crash, then run "gdb < EXECUTABLE NAME > <COREDUMP>", and you can do a backtrace on the coredump, and check the status of the program at various points.

    For the record, the '-g' flag to gcc causes gcc to put in "debugging symbols". These symbols help gdb integrate with the program a bit better, and give you more information on the status of the program.
    DISTRO=Arch
    Registered Linux User #388732

  7. #7
    Just Joined!
    Join Date
    Sep 2007
    Posts
    70
    thanks..will try out.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...