gdb/2202: display command does not work under certain condition.

ching@coware.com ching@coware.com
Sat Nov 18 00:18:00 GMT 2006


>Number:         2202
>Category:       gdb
>Synopsis:       display command does not work under certain condition.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 18 00:18:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     ching@coware.com
>Release:        unknown-1.0
>Organization:
>Environment:
Linux garfield 2.4.21-27.EL #1 Wed Dec 1 22:08:15 EST 2004 i686 i686 i386 GNU/Linux
>Description:
The display command does not work understand certain condition. For example, First time it display correctly, after I call "print snooze(100)" which should just sleep for 100 million seconds and try display number again. 
It fails.

Here is the snap shot of gdb output.

====================================================

There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b simple.cpp:63
print snooze(100)
display num_elements
print snooze(100)
display num_elements
Breakpoint 1 at 0x83dbd47: file simple.cpp, line 63.
(gdb) r
Starting program: /tmp/simple 
[Thread debugging using libthread_db enabled]
[New Thread 1075258784 (LWP 11920)]
[New Thread 1077627824 (LWP 11923)]

           Copyright (c) 1996-2005  CoWare, Inc.
       1732 N. First St., San Jose, CA, 95112, U.S.A.

             Copyright (c) 2004  Cadence, Inc.
       2655 Seely Avenue, San Jose, CA, 95134, U.S.A.

             SystemC 2.1.v1 --- Nov  5 2006 18:03:59
        Copyright (c) 1996-2005 by all Contributors
                    ALL RIGHTS RESERVED
[Switching to Thread 1075258784 (LWP 11920)]

Breakpoint 1, fifo::write (this=0x8b96870, c=86 'V') at simple.cpp:63
warning: Source file is more recent than executable.

63             if (num_elements == max)
(gdb) print snooze(100)
$1 = void
(gdb) display num_elements
1: this->num_elements = 0
(gdb) print snooze(100)
$2 = void
(gdb) display num_elements
(gdb) 

=================================================

It is happened on gdb 6.2. After debug the problem. I think there is a bug in value_of_local() routine in valops.c file, which supposed to set "block_found" global correct. But it did not.

If you stop at display_command and print "block_found"  variable, you will see that it is not set correct after you call "print snooze(100)". If you stop after line 1386 in printcmd.c file of parse_expression(exp) call.

 1385       innermost_block = 0;
   1386       expr = parse_expression (exp);
It will set innermost_block to block_found which is wrong. Because the value_of_local with "this" should set it, but it did not. According to the documentation on lookup_symbol in symtab.c. It

   979    NAME is a field of the current implied argument `this'.  If so set
    980    *IS_A_FIELD_OF_THIS to 1, otherwise set it to zero.
    981    BLOCK_FOUND is set to the block in which NAME is found (in the case of
    982    a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */




I did a patch on valops.c and it seems to fix the problem.

===================================================================
RCS file: /sceng/cvsroot/gdb-6.2.1/gdb/valops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 valops.c
--- valops.c    7 Oct 2004 22:35:11 -0000       1.1.1.1
+++ valops.c    18 Nov 2006 00:01:31 -0000
@@ -43,6 +43,7 @@
 #include "gdb_assert.h"
 #include "cp-support.h"
 #include "observer.h"
+#include "parser-defs.h" // for block_found
 
 extern int overload_debug;
 /* Local functions.  */
@@ -2709,7 +2710,9 @@
       else
        return NULL;
     }
-
+  // need to set block_found to the correct value, otherwise we will not be able to
+  // display the correct value.
+  block_found = b;
   ret = read_var_value (sym, deprecated_selected_frame);
   if (ret == 0 && complain)
     error ("`%s' argument unreadable", name);


>How-To-Repeat:
To reproduce the problem:
unzip/untar the attached test case.
1. cd display_bug
2. invoke
gdb simple
3. do the followings

b simple.cpp:63
r
print snooze(100)
display num_elements
print snooze(100)
display num_elements



>Fix:

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



More information about the Gdb-prs mailing list