Sponsored Content
Top Forums Programming gdb: how to debug an executable file with a few command line papameters Post 302245749 by cdbug on Friday 10th of October 2008 11:42:52 PM
Old 10-11-2008
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
KTR(9)							   BSD Kernel Developer's Manual						    KTR(9)

NAME
CTR0, CTR1, CTR2, CTR3, CTR4, CTR5 -- kernel tracing facility SYNOPSIS
#include <sys/param.h> #include <sys/ktr.h> extern int ktr_cpumask; extern int ktr_entries; extern int ktr_extend; extern int ktr_mask; extern int ktr_verbose; extern struct ktr_entry ktr_buf[]; void CTR0(u_int mask, char *format); void CTR1(u_int mask, char *format, arg1); void CTR2(u_int mask, char *format, arg1, arg2); void CTR3(u_int mask, char *format, arg1, arg2, arg3); void CTR4(u_int mask, char *format, arg1, arg2, arg3, arg4); void CTR5(u_int mask, char *format, arg1, arg2, arg3, arg4, arg5); void CTR6(u_int mask, char *format, arg1, arg2, arg3, arg4, arg5, arg6); DESCRIPTION
KTR provides a circular buffer of events that can be logged in a printf(9) style fashion. These events can then be dumped with ddb(4), gdb(1) or ktrdump(8). Events are created and logged in the kernel via the CTRx macros. The first parameter is a mask of event types (KTR_*) defined in <sys/ktr.h>. The event will be logged only if any of the event types specified in mask are enabled in the global event mask stored in ktr_mask. The format argument is a printf(9) style format string used to build the text of the event log message. Following the format string are zero to five arguments referenced by format. Each event is logged with a file name and source line number of the originating CTR call, and a timestamp in addition to the log message. The event is stored in the circular buffer with supplied arguments as is, and formatting is done at the dump time. Do not use pointers to the objects with limited lifetime, for instance, strings, because the pointer may become invalid when buffer is printed. Note that the different macros differ only in the number of arguments each one takes, as indicated by its name. The ktr_entries variable contains the number of entries in the ktr_buf array. These variables are mostly useful for post-mortem crash dump tools to locate the base of the circular trace buffer and its length. The ktr_mask variable contains the run time mask of events to log. The CPU event mask is stored in the ktr_cpumask variable. The ktr_verbose variable stores the verbose flag that controls whether events are logged to the console in addition to the event buffer. EXAMPLES
This example demonstrates the use of tracepoints at the KTR_PROC logging level. void mi_switch() { ... /* * Pick a new current process and record its start time. */ ... CTR3(KTR_PROC, "mi_switch: old proc %p (pid %d)", p, p->p_pid); ... cpu_switch(); ... CTR3(KTR_PROC, "mi_switch: new proc %p (pid %d)", p, p->p_pid); ... } SEE ALSO
ktr(4), ktrdump(8) HISTORY
The KTR kernel tracing facility first appeared in BSD/OS 3.0 and was imported into FreeBSD 5.0. BUGS
Currently there is one global buffer shared among all CPUs. It might be profitable at some point in time to use per-CPU buffers instead so that if one CPU halts or starts spinning, then the log messages it emitted just prior to halting or spinning will not be drowned out by events from the other CPUs. The arguments given in CTRx() macros are stored as u_long, so do not pass arguments larger than size of an u_long type. For example passing 64bit arguments on 32bit architectures will give incorrect results. BSD
November 30, 2008 BSD
All times are GMT -4. The time now is 08:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy