Hi,
When i debug the program using gdb , the gdb is entering the definations of std lib functions (ex: printf, strcpy ect) and other internal functions.
Initially the debuger was working fine, i dont have clue when it got changed.I guess some of the flags of gdb might have changed.

Please let me know how to bring it back to normal state.
Please find the attachment for reference.
below is the code i am using for gdb test.

int main( void )
{
    int i;
    for (i =0;i<5;i++)
        printf("Helloo\n);

    return 0;
}

Recommended Answers

It's supposed to do that. It's how the debugger works. You step through functions like that.

Jump to Post

(gdb) help s
Step program until it reaches a different source line.
Argument N means do this N times (or till program stops for another reason).
(gdb) help n
Step program, proceeding through subroutine calls.
Like the "step" command as long as subroutine calls do not happen;
when they do, the …

Jump to Post

Also, up will take you upwards through the call stack, function by function. Stop typing up when you are at the function you're interested in.

This is basically a case of RTFM.

Jump to Post

All 10 Replies

It's supposed to do that. It's how the debugger works. You step through functions like that.

But iam not able to debug my original program, because the program goes very deep into std definations.
The orinigal behaviour of Debugger is to skip the std function( i mean dont go to definations , but yeild the result) and continue with user code.

This is really irritating, and i am not able to debug .

(gdb) help s
Step program until it reaches a different source line.
Argument N means do this N times (or till program stops for another reason).
(gdb) help n
Step program, proceeding through subroutine calls.
Like the "step" command as long as subroutine calls do not happen;
when they do, the call is treated as one instruction.
Argument N means do this N times (or till program stops for another reason).

Also, up will take you upwards through the call stack, function by function. Stop typing up when you are at the function you're interested in.

This is basically a case of RTFM.

I guess the shared library symbol table is getting loaded.
Try the below command in gdb, before running the program.

show auto-solib-add -- this will indicate the current status. Incase if this mode is ON, turn it OFF using the command set auto-solib-add mode off

Hope it helps :)

I guess the shared library symbol table is getting loaded.
Try the below command in gdb, before running the program.

show auto-solib-add -- this will indicate the current status. Incase if this mode is ON, turn it OFF using the command set auto-solib-add mode off

Hope it helps :)

That did the trick but i am getting all the std functions out put at the same time no matter how many.
Well that is not what is expected, normal behaviour is , it should process line by line and give out put if any printf or any likes and wait for the next action.

(gdb) set auto-solib-add off
(gdb) b main
Breakpoint 1 at 0x804843e: file f1.c, line 5.
(gdb) r
Starting program: /home/slb/a.out 

Breakpoint 1, main () at f1.c:5
5   {
(gdb) s
6       char str[] = "Hello";
(gdb) s
8       printf("len = %d\n",strlen("Hello"));
(gdb) list
3   
4   int main( void)
5   {
6       char str[] = "Hello";
7       int len,size;
8       printf("len = %d\n",strlen("Hello"));
9       len = strlen(str);
10      printf("len = %d\n",len);
11      size = sizeof("Hello");
12      printf("size = %d\n", size);
(gdb) s
len = 5
len = 5
size = 6
0xb7e60113 in ?? () from /lib/i386-linux-gnu/libc.so.6
(gdb) set auto-solib-add off
(gdb) b main
Breakpoint 1 at 0x804843e: file f1.c, line 5.
(gdb) r
Starting program: /home/slb/a.out 

Breakpoint 1, main () at f1.c:5
5   {
(gdb) s
6       char str[] = "Hello";
(gdb) s
8       printf("len = %d\n",strlen("Hello"));
(gdb) list
3   
4   int main( void)
5   {
6       char str[] = "Hello";
7       int len,size;
8       printf("len = %d\n",strlen("Hello"));
9       len = strlen(str);
10      printf("len = %d\n",len);
11      size = sizeof("Hello");
12      printf("size = %d\n", size);
(gdb) s
len = 5
len = 5
size = 6
0xb7e60113 in ?? () from /lib/i386-linux-gnu/libc.so.6
(gdb) s
Cannot find bounds of current function

Also, up will take you upwards through the call stack, function by function. Stop typing up when you are at the function you're interested in.

This is basically a case of RTFM.

I guess this takes a long time until we get out of the unwanted code.

(gdb) help s
Step program until it reaches a different source line.
Argument N means do this N times (or till program stops for another reason).
(gdb) help n
Step program, proceeding through subroutine calls.
Like the "step" command as long as subroutine calls do not happen;
when they do, the call is treated as one instruction.
Argument N means do this N times (or till program stops for another reason).

Sorry , I dont understand what you are trying to say here , if i knew how many lines i have to skip in advance, its easy, but i cannot always.

L7Sqr , your suggesin seeenm to work, i post the response later, schduled power cuts , need run..

Gaiety: That is expected when auto-solib-add mode is off. The step command in gdb will stop at the next function where the symbols are found.

Warning: If you use the step command while control is within a function that was compiled without debugging information, execution proceeds until control reaches a function that does have debugging information. Likewise, it will not step into a function which is compiled without debugging information.

Can you try with next command and let us know, what is that you are getting.

I guess the problem is that, the standard library is compiled with debug flags. Otherwise, this problem wouldn't have come in the first place. :)

please show the next command

please show the next command

Just press the 'n' in gdb session.

rustysynate
with next command its not entering any inetrnal code of lib functions, it works fine.

Thanks All.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.