Thread: How do i use the debugger in unix?

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    21

    How do i use the debugger in unix?

    Hello all,

    I am using c on unix but I'm not sure how to kick off a debugger?
    I tried compiling as follows:

    cc -g test22.c -o test22_deb

    and then tried running the exe :

    test22_deb

    in the hope that it would be in debug so i could step through it. But no joy.

    Please advise,

    Manny

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    What version of UNIX are you using? Which compiler?

  3. #3
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    and what tools?
    most unix debuggers work on core files, such as when an app crashed and had debug hooks in the binary.
    using one of the ide tools you can step through execution using a debugger, though those are all gui based and it looks like you are using cli to do this.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    21
    Hi,

    Previously I have only used C and the debugger on a VMS platform. Unix is totally new to me. The operating system is SunOS 5.6.
    I don't know how to find out which compiler we're using.

    Cheers,

    Manny

    Quote Originally Posted by kermit
    What version of UNIX are you using? Which compiler?

  5. #5
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    manny,
    Code:
     cc -v
    should give you the version of the compiler.
    or else -h or --help after the cc
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  6. #6
    Registered User
    Join Date
    Jun 2006
    Posts
    21
    Hi,

    I tried the commands as below, but they do not give the compiler version.

    Any other ideas?

    Manny

    Quote Originally Posted by Jaqui
    manny,
    Code:
     cc -v
    should give you the version of the compiler.
    or else -h or --help after the cc

  7. #7
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    odd it does with linux / gcc

    you could try doing a listing of /usr/bin for *cc*

    ls /usr/bin/*cc*

    would give a directory listing of everything with cc in the name of the file.

    ahh, found it on the Sun Solaris site.
    it's Sun WorkShop C.
    I bet you will find documentation for all your software there

    Sun Workshop C is K&R C, with support for ANSI/ISO C

    http://docs.sun.com/source/806-3567/preface.html this is for version 6, which is most likely newer than what you have, but it's the sun docs for their c programming tools.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  8. #8
    Registered User
    Join Date
    Jun 2006
    Posts
    21
    Thanks, I'll have a hunt around in the docs.

    Quote Originally Posted by Jaqui
    odd it does with linux / gcc

    you could try doing a listing of /usr/bin for *cc*

    ls /usr/bin/*cc*

    would give a directory listing of everything with cc in the name of the file.

    ahh, found it on the Sun Solaris site.
    it's Sun WorkShop C.
    I bet you will find documentation for all your software there

    Sun Workshop C is K&R C, with support for ANSI/ISO C

    http://docs.sun.com/source/806-3567/preface.html this is for version 6, which is most likely newer than what you have, but it's the sun docs for their c programming tools.

  9. #9
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    If you are running SunOS, I believe you would invoke the debugger in the following manner:

    Code:
    $ dbx progname
    where $ is the command line prompt, and dbx is the name of the debugger.

    This article might be of use to you. If not, Google is your friend. As well, you can read the manual for dbx:

    Code:
    $ man dbx
    When you want to quit the manual page, press <SHIFT + Q>
    Last edited by kermit; 07-13-2006 at 05:42 PM.

  10. #10
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Quote Originally Posted by manny
    Hello all,

    I am using c on unix but I'm not sure how to kick off a debugger?
    I tried compiling as follows:

    cc -g test22.c -o test22_deb

    and then tried running the exe :

    test22_deb

    in the hope that it would be in debug so i could step through it. But no joy.

    Please advise,

    Manny
    the -g option just adds debug symbols to the binary.
    so a debugger (another program!) can interpret the binary.
    without the -g option a debugger could not know which address stands for which variable.

    if youre using an ide (e.g. kdevelop) then there should be debugger built-in.
    or a simple stand alone debugger with an gui would be ddd (which is just a front end for gdb).
    (unfortunately the handling is not as nice as the vc-debugger )
    signature under construction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 10:54 AM
  2. Replies: 3
    Last Post: 07-24-2007, 04:25 PM
  3. Setting up a Unix box
    By @nthony in forum Tech Board
    Replies: 6
    Last Post: 07-22-2007, 10:22 PM
  4. UNIX (Linux, BSD, etc) Programming :: UNIX
    By kuphryn in forum Linux Programming
    Replies: 6
    Last Post: 04-01-2004, 08:44 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM