Hi,
I am trying to see all values in data segment ,stack segment from GDB debugger
in this process,
i am able to see the stack values from GDB command "backtrace full" .
I want to see all values the values in data segment( both initialized and uninitialized vlues) also. I mean mainly i want to see all the global variables list. Because any way i can see constant and static values if i define in main function from "backtrace full"
But i did have any idea to see total variables in data segment(mainly global variable) from GDB commands
any body suggest me to see all those values (global values)?
i know the see the golbal values like "print variablename" in gdb.
but i want to see all the variable stored in data segment from gdb.
please help any one.
please see the below program to see stack values from GDB
Code:
#include<stdio.h>
int g;
int main()
{
int i;
const int c;
static int s;
fun1();
fun2();
fun3();
fun4();
return 0;
}
int fun1()
{
int i=1;
printf ("enter the value of i in function one\n");
scanf ("%d",&i);
printf ("%d\n",i);
return 0;
}
int fun2()
{
int i=2;
return 0;
}
int fun3()
{
int i=3;
return 0;
}
int fun4()
{
int i=4;
return 0;
}
GDB logs
Code:
cc -g 25.c
[root@examples]# gdb a.out
GNU gdb Red Hat Linux (6.3.0.0-1.96rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) break 0
No line 0 in file "25.c".
(gdb) break 1
Breakpoint 1 at 0x804839c: file 25.c, line 1.
(gdb) run
Starting program: /home/koti/examples/c_examples/a.out
Breakpoint 1, main () at 25.c:4
4 {
(gdb) n
8 fun1();
(gdb) backtrace full
#0 main () at 25.c:8
i = 9190560
c = 0
s = 0
(gdb) n
enter the value of i in function one
1
1
9 fun2();
(gdb)