backtrace/2001: list command displays wrong source after a backtrace or where command

andrew.stubbs@st.com andrew.stubbs@st.com
Sun Sep 4 00:28:00 GMT 2005


>Number:         2001
>Category:       backtrace
>Synopsis:       list command displays wrong source after a backtrace or where command
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 30 16:58:00 UTC 2005
>Closed-Date:
>Last-Modified:
>Originator:     andrew.stubbs@st.com
>Release:        gdb 6.3
>Organization:
>Environment:

>Description:
The (first) list command is supposed to show the code position in the current context, isn't it?

However, immediately following a backtrace or where command
it actually shows the position in frame #0. This is despite the frame command (with no parameters) reporting the correct frame.

I have observed this in both my i686 host system GDB (RHELWS3) and my sh-elf cross debugger.
>How-To-Repeat:
Compile a program:
---8<--------------------->8---
#include <stdio.h>

void c (void) {
        printf ("In C\n");
}

void b (void) {
        printf ("In B\n");
        c();
        printf ("In B\n");
}

int main (void) {
        printf ("In Main\n");
        b();
        printf ("In Main\n");
        return 0;
}
---8<--------------------->8---

Debug it as follows:
(gdb) b c
Breakpoint 1 at 0x804834a: file a.c, line 4.
(gdb) run
Starting program: /view/stubbsa-sh4bare/vob/insight.cmp/a.out 
In Main
In B

Breakpoint 1, c () at a.c:4
4               printf ("In C\n");
(gdb) l
1       #include <stdio.h>
2
3       void c (void) {
4               printf ("In C\n");
5       }
6
7       void b (void) {
8               printf ("In B\n");
9               c();
10              printf ("In B\n");
(gdb) bt
#0  c () at a.c:4
#1  0x08048377 in b () at a.c:9
#2  0x080483ae in main () at a.c:15
(gdb) l
15              b();
16              printf ("In Main\n");
17              return 0;
18      }
(gdb) frame
#0  c () at a.c:4
4               printf ("In C\n");
(gdb) frame 1
#1  0x08048377 in b () at a.c:9
9               c();
(gdb) l
4               printf ("In C\n");
5       }
6
7       void b (void) {
8               printf ("In B\n");
9               c();
10              printf ("In B\n");
11      }
12
13      int main (void) {
(gdb) bt
#0  c () at a.c:4
#1  0x08048377 in b () at a.c:9
#2  0x080483ae in main () at a.c:15
(gdb) l
15              b();
16              printf ("In Main\n");
17              return 0;
18      }
(gdb) frame
#1  0x08048377 in b () at a.c:9
9               c();


The problem can clearly be seen in the list following each backtrace.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gdb-prs mailing list