![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help Required: Command to find IP address and command executed of a user | loggedout | Security | 2 | 08-06-2008 05:12 PM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 03:06 PM |
| inconsistent ls command display at the command prompt & running as a cron job | rajranibl | Linux | 5 | 07-30-2007 05:26 AM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | HP-UX | 1 | 10-16-2006 01:16 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | Shell Programming and Scripting | 0 | 09-19-2006 06:44 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I'm having problem understanding the how to use gdb command to debug my program. Can anyone give me some suggestion how to start, and examples. I read the manual in unix...I'm still confuse.
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Well ... I don't usually read the GDB manual because its command line help is already quite good. To use GDB properly you should compile your C program with the -g switch. Then simply
gdb ./executable Then you will be asked to enter the commands. I usually just type 'help' then you will see Quote:
To run the program, enter 'run'. Usually you may want to insert some breakpoints before starting the program. I forgot the command to use. You may type 'help breakpoints' for a list of commands that you will find useful. |
|
#3
|
|||
|
|||
|
this is what i did to get an executable file before i use gdb command
i type : gcc -g text2.c it did not work. |
|
#4
|
|||
|
|||
|
Then it's your text2.c that does not work. If your program is correct, it should be compilable. It is possible for some special conditions that a program compiled with -g may cause it not functioning as expected but that only affects runtime.
Can you specify what do you mean by "it did not work"? Any error messages? |
|
#5
|
|||
|
|||
|
my program(text2.c) did compile and run. I tested my code. It did give me the right output and so on.
but i couldn't find any executable file in my directory. This is what i did..and what happened : [confuse@enlnxs ~]$ gcc -g text2.c [confuse@enlnxs ~]$ ls a.out file33.c file4new.c mail text2.c text3.c file2.c file4.c file.c test.c text2.out [confuse@enlnxs ~]$ gdb text2.c GNU gdb Red Hat Linux (5.2-2) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"..."/ennfs/csc/cscund/confuse/text2.c": not in executable format: File format not recognized (gdb) |
|
#6
|
|||
|
|||
|
Oh dear. When you use gcc/g++ to compile a program and if you don't specify the -o switch, the output is written to the file named "a.out".
Either you gcc text2.c -o text2 -g gdb ./text2 or gcc text2.c -g gdb ./a.out |
|
#7
|
|||
|
|||
|
thank you. : )
|
|||
| Google The UNIX and Linux Forums |