This is the mail archive of the gdb@sources.redhat.com 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]

Problem with MI -stack-list-frames command.


Hello.

While writing up a little library to script interaction with gdb via
the MI, I ran into a small incompatibility between the -stack-list-frames
and -stack-list-arguments commands.

-stack-list-frames
^done,stack=[frame={level="0 ",addr="0x080483b0",func="main",file="example.c",line="4"},frame={level="1 ",addr="0x400339cb",func="__libc_start_main",file="../sysdeps/generic/libc-start.c",line="92"}]
(gdb) 

-stack-list-arguments 1
^done,stack-args=[frame={level="0",args=[]},frame={level="1",args=[{name="main",value="(int (*)()) 0x80483a0 <main>"},{name="argc",value="1"},{name="argv",value="(char **) 0xbffff5b4"},{name="init",value="(void (*)()) 0x8048274 <_init>"},{name="fini",value="(void (*)()) 0x80483fc <_fini>"},{name="rtld_fini",value="(void (*)()) 0x4000ae60 <_dl_fini>"},{name="stack_end",value="(void *) 0x4010c098"}]}]
(gdb)

Note how the stack level is printed as level="0 " for the frames
and as level="0" for the arguments. From "the outside" there does
not appear to be any reason for this difference. It is only a minor
bother to special case this in my parser, but I figured it
would be better to fix this then leave it for the next person to
run into.

After some quick poking around, I found that the problem could
be "fixed" by making this little change:

Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.29
diff -u -r1.29 stack.c
--- stack.c	14 Feb 2002 07:24:54 -0000	1.29
+++ stack.c	16 Jul 2002 06:22:02 -0000
@@ -533,7 +533,7 @@
   if (level >= 0)
     {
       ui_out_text (uiout, "#");
-      ui_out_field_fmt (uiout, "level", "%-2d", level);
+      ui_out_field_int (uiout, "level", level);
       ui_out_spaces (uiout, 1);
     }
   if (addressprint)


Now, that worked for my MI test case, but it causes tons of
other failures in the existing gdb tests. From that, I am
guessing that this field is too deeply entwined with other
parts of gdb to be changed in this way. So, what is the
right way to go about this? I assume I will need to write
a new MI impl of the print_frame function. Should I copy
the existing print_frame and move it into mi-cmd-stack.c?
I am looking for a bit of guidance up front in the hope
that I can avoid wasting time doing this the wrong way.
If this can't easily be changed and I am wasting my
time, please let me know.

thanks
Mo


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