This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Backtrace oddity with verbose on


If a stack backtrace triggers one of the "corrupt stack" errors like
the following:

    Previous frame identical to this frame (corrupt stack?)

the backtrace command will print nothing except this message the first
time a backtrace is done, if verbose is on.  For example, without
verbose on, you get:

    (gdb) bt
    #0  0x04013d04 in cpu_peek_memory_location (present=0x42153a0, addr=0x0, size=2) at ../ukern/cpu-r7k/r7k_cpu.c:428
    #1  0x0400c708 in probe_peekmemory (config=0x2, results=0x4110000, magic=2) at ../ukern/common/probe.c:191
    #2  0x0403c274 in parser_sub_parse_end_of_line (word=0x2 "", node=0x40c86e8, config=0x4215770, result=0x4215468, reason=0x42156b0)
        at ../common/toolkits/parser/parser_subs.c:661
    #3  0x0403acbc in parser_parse_words (config=0x4215770, check_only=FALSE, stop_at_index=68222976) at ../common/toolkits/parser/parser.c:298
    #4  0x0403e508 in editor_read_and_parse (p_config=0x4215770, e_config=0x42159d8) at ../common/toolkits/parser/editor.c:1731
    #5  0x040657bc in system_console_create (tty=0x413c098) at ../common/applications/system/system.c:449
    #6  0x04065ad0 in system_console_thread () at ../common/applications/system/system.c:548
    #7  0x0400ba00 in thread_debug () at ../ukern/common/thread.c:893
    #8  0x0400ba00 in thread_debug () at ../ukern/common/thread.c:893
    Previous frame identical to this frame (corrupt stack?)

With verbose, you get:

    (gdb) set verbose on
    (gdb) bt
    Reading in symbols for ../ukern/common/probe.c...done.
    Reading in symbols for ../common/toolkits/parser/parser_subs.c...done.
    Reading in symbols for ../common/toolkits/parser/parser.c...done.
    Reading in symbols for ../common/toolkits/parser/editor.c...done.
    Reading in symbols for ../common/applications/system/system.c...done.
    Reading in symbols for ../ukern/common/thread.c...done.
    Previous frame identical to this frame (corrupt stack?)

and a second bt command will then print the actual backtrace.

The cause is some code in backtrace_command_1 that is only run when
verbose is on, that attempts to do a "silent" backtrace to seed the
frame cache and pull in relevant symbols, so that the real backtrace
output does not have "Reading in symbols for XXX" messages
interspersed with the backtrace output.  For example, if you remove
that code with the attached patch, you get:

    (gdb) set verbose on
    (gdb) bt
    #0  0x04013d04 in cpu_peek_memory_location (present=0x42153a0, addr=0x0, size=2) at ../ukern/cpu-r7k/r7k_cpu.c:428
    Reading in symbols for ../ukern/common/probe.c...done.
    #1  0x0400c708 in probe_peekmemory (config=0x2, results=0x4110000, magic=2) at ../ukern/common/probe.c:191
    Reading in symbols for ../common/toolkits/parser/parser_subs.c...done.
    #2  0x0403c274 in parser_sub_parse_end_of_line (word=0x2 "", node=0x40c86e8, config=0x4215770, result=0x4215468, reason=0x42156b0)
        at ../common/toolkits/parser/parser_subs.c:661
    Reading in symbols for ../common/toolkits/parser/parser.c...done.
    #3  0x0403acbc in parser_parse_words (config=0x4215770, check_only=FALSE, stop_at_index=68222976) at ../common/toolkits/parser/parser.c:298
    Reading in symbols for ../common/toolkits/parser/editor.c...done.
    #4  0x0403e508 in editor_read_and_parse (p_config=0x4215770, e_config=0x42159d8) at ../common/toolkits/parser/editor.c:1731
    Reading in symbols for ../common/applications/system/system.c...done.
    #5  0x040657bc in system_console_create (tty=Reading in symbols for ../common/applications/vty/vty_telnet.c...done.
    0x413c098) at ../common/applications/system/system.c:449
    #6  0x04065ad0 in system_console_thread () at ../common/applications/system/system.c:548
    Reading in symbols for ../ukern/common/thread.c...done.
    #7  0x0400ba00 in thread_debug () at ../ukern/common/thread.c:893
    #8  0x0400ba00 in thread_debug () at ../ukern/common/thread.c:893
    Previous frame identical to this frame (corrupt stack?)
    (gdb) bt

I wonder if perhaps this attempt to prevent this sort of output is
misguided.  With verbose on, we typically expect to see additional
verbose output interspersed with other output.  So perhaps the best
solution is also the simplest, just delete that code.

Comments?

-Fred

Index: stack.c
===================================================================
RCS file: /services/cvs/cvsroot/gnusense/gdb/gdb/stack.c,v
retrieving revision 1.1.1.6.4.1
diff -u -p -r1.1.1.6.4.1 stack.c
--- stack.c     9 Oct 2006 22:17:40 -0000       1.1.1.6.4.1
+++ stack.c     30 Jan 2007 21:14:08 -0000
@@ -1133,25 +1133,6 @@ backtrace_command_1 (char *count_exp, in
   else
     count = -1;
 
-  if (info_verbose)
-    {
-      struct partial_symtab *ps;
-
-      /* Read in symbols for all of the frames.  Need to do this in a
-         separate pass so that "Reading in symbols for xxx" messages
-         don't screw up the appearance of the backtrace.  Also if
-         people have strong opinions against reading symbols for
-         backtrace this may have to be an option.  */
-      i = count;
-      for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi))
-       {
-         QUIT;
-         ps = find_pc_psymtab (get_frame_address_in_block (fi));
-         if (ps)
-           PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in.  */
-       }
-    }
-
   for (i = 0, fi = trailing; fi && count--; i++, fi = get_prev_frame (fi))
     {
       struct symtab_and_line savesal;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]