gdb: how to debug an executable file with a few command line papameters


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Programming gdb: how to debug an executable file with a few command line papameters
# 1  
gdb: how to debug an executable file with a few command line papameters

If an executalbe file has several parameters, gdb can not pass parameters correctly. Let us see:

run:
./executablefile1 agr1 arg2 arg3

debug:
gdb executablefile1
run executalbefile1 arg1 arg2 arg3

then argv[0] : executablefile1
argv[1] : executablefile
argv[2] : arg1
argv[3] : arg2
argv[4] : arg3

When we use argv[x] many times, it is unconvenient to change each to argv[x+1].

May we fix it in a tricky way?

Thanks
# 2  
Quote:
Originally Posted by cdbug
If an executalbe file has several parameters, gdb can not pass parameters correctly. Let us see:

run:
./executablefile1 agr1 arg2 arg3

debug:
gdb executablefile1
run executalbefile1 arg1 arg2 arg3

then argv[0] : executablefile1
argv[1] : executablefile
argv[2] : arg1
argv[3] : arg2
argv[4] : arg3

When we use argv[x] many times, it is unconvenient to change each to argv[x+1].

May we fix it in a tricky way?

Thanks
Run it as
Code:
gdb executablefile
run arg1 arg2 arg3

# 3  
I tried and it can work well.

Thanks
# 4  
Let me ask a related question.

If an exe file has several commands without argument, such as 'source', 'compile', 'run', it would be a trouble in gdb.

How to debug the exe with gdb? I tried and it shows that 'run source', 'source' , 'run compile' ..., can not work correctly
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #848
Difficulty: Medium
The IEEE standardized Bluetooth as IEEE 802.15.1, but IEEE no longer maintains the Bluetooth standard.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

Odd behavior from GDB while trying to cross-debug an embedded Linux application.

Some background: The application normally runs on an embedded platform. Currently, for development purposes, I have the rootfs located @ /exports and the target is communicating over NFS. That way I can make a change on my local system, save the application @ /exports, and run the altered... (4 Replies)
Discussion started by: Circuits
4 Replies

2. AIX

Gdb on a 64 bit executable - cannot access memory

Hi, Can anyone explain this please..... A simple test program... ### snip #include <stdio.h> main() { static int n; n = 6; printf("hello %d\n", n); n=7; } ### snip 64 bit compile/link.... (2 Replies)
Discussion started by: bagpussnz
2 Replies

3. UNIX for Dummies Questions & Answers

GDB not showing line details

I have bunch of source code which I compiled using -ggdb3 flag. I have copied the source code and executable to an another machine. When I run the exe in gdb it does not show the statments at the line numbers when it breaks. This is what I see Breakpoint 1, TestCode (handler=0x806e110,... (1 Reply)
Discussion started by: rupeshkp728
1 Replies

4. Programming

Can't debug: assert error with gdb (no problem without)

I'm sorry if the title is really criptic, but I don't know how to phrase my problem. I know I can't really ask for a solution, and I normally wouldn't but this is really escaping my abilities. Antefacts. I developed a program using the zeromq messaging library. I got to a point where the... (11 Replies)
Discussion started by: erupter
11 Replies

5. Programming

GDB No line in file error

Hi, I have a c program i compile with gcc4.5. This elf, if I use gdb and put a breakpoint on main, instead has a breakpoint in a function other than main or says no line in file. I verified the elf is 1 to 1 with source, have all debug symbols for compilation etc. The problem I think is the... (2 Replies)
Discussion started by: dragonpoint
2 Replies

6. Shell Programming and Scripting

How to compile or debug line by line in shell script?

I know about bash -x, set -x and -v but disappears from Command Line Interface in fraction of second ...... I am looking for a command or script ..complies each line and shows the output after executing each line ....( similar what we have in C ) Thanks in Advance (2 Replies)
Discussion started by: frintocf
2 Replies

7. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

8. Programming

Debug two process Using GDB

Hi All I know How to attach a process to beubg it .But for my application I am using client as well server.Both are two separate process .Suppose I need to debug both .How to attach both of them together .Or I have to attach them separetly . Suppose client process id is 1325 and server is... (2 Replies)
Discussion started by: mr_deb
2 Replies

9. UNIX for Advanced & Expert Users

a question about debug using gdb(/lib32/libc.so.6: No such file or directory)

Hi all, (gdb) target remote 192.168.185.196:1389 Remote debugging using 192.168.185.196:1389 warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. 0x2fbd0800 in ?? () (gdb) l 1 ... (0 Replies)
Discussion started by: yanglei_fage
0 Replies

10. Programming

gdb: problem while debug an executable file

I created one file (test.cpp)and complied it and get the executable file(test) and run it.It is giving the out put but when I am trying to debug that executable.I am getting the error -- please tell me the solutions?? Thanks in advance ..... (2 Replies)
Discussion started by: smartgupta
2 Replies

Featured Tech Videos