bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gdb] Strange behaviour when displaying static var


From: Serge De Marre
Subject: [Bug-gdb] Strange behaviour when displaying static var
Date: Thu, 21 Sep 2000 09:06:01 GMT

Hello all.
I have some strange behaviour when trying to display a static variable
which exists in several files.

Imagine the following situation: a project with 3 files:
-------------- test.c --------------
void f();
void g();
void h()
{
}
int main() 
{
  while (1) {           
    f();        
    g();
    h();
  }
  return 0;
}
-------------- test1.c --------------
static int a;
void f()
{
  ++a;
}
-------------- test2.c --------------
static int a;
void g()
{
  --a;
}
---------------------------------------

notice the "static int a" in both test1.c and test2.c
When running gdb (4.17, 4.18 or 5.0), I am doing the following:

(gdb) b h
(gdb) list test1.c:1
(gdb) disp a
(gdb) list test2.c:1
(gdb) disp a
(gdb) run
Breakpoint 1, h ()
2: a = -1
1: a = 1
(gdb) list test1.c:1
(gdb) disp a
(gdb) list test2.c:2
(gdb) disp a
(gdb) disp
4: a = -1
3: a = -1
2: a = -1
1: a = 1


Now my question is: why does the disp command figure out correctly what
"int a" I want to display before running the program, and why doesn't it
figure out after hitting a breakpoint ? Any ideas ?



-- 
========================================================================
Serge De Marre                                      Development Engineer
CoWare, Inc.                                      Tel: +32 (0)16 396 320
Interleuvenlaan 15a                               Fax: +32 (0)16 396 329
B-3001 Leuven                                    Email: address@hidden
Belgium                                      WWW: http://www.CoWare.com/
========================================================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]