how to print struct in GDB

hi,

i hav array of following struct which contains 50 elements. I want to
print only first feild of the struct ie name field in GDB debuggure.

  struct node \{

        char name[17] ;
        int    age;
         char  sex;
         int location
 \}   SS[50]

after running 50 loops if i m using (gdb) print SS
command it will show the all element and field of the array SS[50]
but how to get first ie name field of array SS

print SS.name

As i told u that SS[50] is an array of 50 elements and ss[].name is its first field so
i wanted to show only the first field of the struct array which itself would be the
char array of name of 50 elements. but ur comand is display only the name field
of first elment.Kindly suggest me .....

You mean dumping the "name" field of all 50 structs? I guess that is not possible with debugger because that is not a contiguous piece of address. You will need to do it manually, or simply insert debug statements in the program and get it in a loop.

No it is possible i got it now....
for that u have to write one simple script and
put that script in user defined function.......
this script will run the for loop 50 times and
print the element one by one just have a look

1 define ram
2 set $pk = 50
3 while $pk!=0
4 print ss1[$pk].name
5 set $pk = $pk-1
6 end
7 end

u put as userdefine fun in GDB and use it...