* [Patch] add implementation of stack-info-frame MI command
@ 2002-07-25 15:10 Mo DeJong
2002-07-25 17:04 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Mo DeJong @ 2002-07-25 15:10 UTC (permalink / raw)
To: gdb-patches
Hello.
While using the MI, I noticed that there is a real problem trying to find
the current stack level. One could get the stack and look at the level
value of the first frame or parse the results of a cli frame command,
but these both seem ugly. What is needed is a stack-info-frame that
returns the current stack level to complement the stack-select-frame
which selects a stack level.
Here is what I propose:
-stack-info-frame
^done,level="0"
(gdb)
-stack-select-frame 5
^done
(gdb)
-stack-info-frame
^done,level="5"
(gdb)
The stack-info-frame command is currently unimplemented
even though it appears in the documentation, so there is
no way this patch could break anything. The only objection
I could think of was that folks might want the command
to return all the info about the current frame, like the
stack-list-frames method. That is actually not needed since
one could always run stack-list-frames and then select
a stack level out of the returned frames. In real code,
it is better to query the whole stack as opposed to changing
the stack, doing a query of the current frame, changing the
stack, then doing a query, and so on.
I forgot to mention in my last patch that I sent in my FSF
copyright paperwork, so that should not stand in the way
of incorporating my patches any longer.
cheers
Mo
2002-07-25 Mo DeJong <supermo@bayarea.net>
* mi-stack.exp: Add test for stack-info-frame
command that returns the current stack level.
Index: mi-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stack.exp,v
retrieving revision 1.8
diff -u -r1.8 mi-stack.exp
--- mi-stack.exp 19 Aug 2001 01:23:43 -0000 1.8
+++ mi-stack.exp 25 Jul 2002 21:06:38 -0000
@@ -192,6 +192,10 @@
"232\\^done" \
"stack select frame 1"
+ mi_gdb_test "232-stack-info-frame" \
+ "232\\^done,level=\"1\"" \
+ "stack info frame"
+
mi_gdb_test "232-stack-list-locals 1" \
"232\\^done,locals=\\\[\\\]" \
"stack locals listing for new frame"
2002-07-25 Mo DeJong <supermo@bayarea.net>
* gdbmi.texinfo (stack-info-frame): Document
return of current stack level by stack-info-frame.
* mi-cmd-stack.c (mi_cmd_stack_info_frame):
Implement stack-info-frame command.
* mi-cmds.c: Add mi_cmd_stack_info_frame to
mi command lookup table.
* mi-cmds.h: Add mi_cmd_stack_info_frame decl.
Index: gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.26
diff -u -r1.26 gdbmi.texinfo
--- gdbmi.texinfo 25 Feb 2002 02:13:09 -0000 1.26
+++ gdbmi.texinfo 25 Jul 2002 21:11:34 -0000
@@ -2558,12 +2558,18 @@
-stack-info-frame
@end example
-Get info on the current frame.
+Get the stack level of the current frame.
+
+@smallexample
+(@value{GDBP})
+-stack-info-frame
+^done,level="0"
+(@value{GDBP})
+@end smallexample
@subsubheading @value{GDBN} Command
-The corresponding @value{GDBN} command is @samp{info frame} or @samp{frame}
-(without arguments).
+There's no equivalent @value{GDBN} command.
@subsubheading Example
N.A.
Index: mi-cmd-stack.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-stack.c,v
retrieving revision 1.10
diff -u -r1.10 mi-cmd-stack.c
--- mi-cmd-stack.c 5 Feb 2002 19:28:36 -0000 1.10
+++ mi-cmd-stack.c 25 Jul 2002 21:11:35 -0000
@@ -307,3 +307,16 @@
select_frame_command_wrapper (argv[0], 1 /* not used */ );
return MI_CMD_DONE;
}
+
+enum mi_cmd_result
+mi_cmd_stack_info_frame (char *command, char **argv, int argc)
+{
+ if (!target_has_stack)
+ error ("mi_cmd_stack_info_frame: No stack.");
+
+ if (argc > 0)
+ error ("mi_cmd_stack_info_frame: Command accepts no arguments");
+
+ ui_out_field_fmt (uiout, "level", "%d", selected_frame_level);
+ return MI_CMD_DONE;
+}
Index: mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.8
diff -u -r1.8 mi-cmds.c
--- mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
+++ mi-cmds.c 25 Jul 2002 21:11:35 -0000
@@ -103,7 +103,7 @@
{"signal-list-handle-actions", 0, 0},
{"signal-list-signal-types", 0, 0},
{"stack-info-depth", 0, 0, mi_cmd_stack_info_depth},
- {"stack-info-frame", 0, 0},
+ {"stack-info-frame", 0, 0, mi_cmd_stack_info_frame},
{"stack-list-arguments", 0, 0, mi_cmd_stack_list_args},
{"stack-list-exception-handlers", 0, 0},
{"stack-list-frames", 0, 0, mi_cmd_stack_list_frames},
Index: mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.5
diff -u -r1.5 mi-cmds.h
--- mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
+++ mi-cmds.h 25 Jul 2002 21:11:35 -0000
@@ -76,6 +76,7 @@
extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
+extern mi_cmd_argv_ftype mi_cmd_stack_info_frame;
extern mi_cmd_argv_ftype mi_cmd_stack_list_args;
extern mi_cmd_argv_ftype mi_cmd_stack_list_frames;
extern mi_cmd_argv_ftype mi_cmd_stack_list_locals;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] add implementation of stack-info-frame MI command
2002-07-25 15:10 [Patch] add implementation of stack-info-frame MI command Mo DeJong
@ 2002-07-25 17:04 ` Andrew Cagney
2002-07-25 17:05 ` Keith Seitz
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-07-25 17:04 UTC (permalink / raw)
To: Mo DeJong; +Cc: gdb-patches
See my post to GDB@. I think this should be handled as an event and not
as a command.
The user entering a command like ``up'' needs to trigger the event
notification anyway.
enjoy,
Andrew
> While using the MI, I noticed that there is a real problem trying to find
> the current stack level. One could get the stack and look at the level
> value of the first frame or parse the results of a cli frame command,
> but these both seem ugly. What is needed is a stack-info-frame that
> returns the current stack level to complement the stack-select-frame
> which selects a stack level.
>
> Here is what I propose:
>
> -stack-info-frame
> ^done,level="0"
> (gdb)
> -stack-select-frame 5
> ^done
> (gdb)
> -stack-info-frame
> ^done,level="5"
> (gdb)
>
> The stack-info-frame command is currently unimplemented
> even though it appears in the documentation, so there is
> no way this patch could break anything. The only objection
> I could think of was that folks might want the command
> to return all the info about the current frame, like the
> stack-list-frames method. That is actually not needed since
> one could always run stack-list-frames and then select
> a stack level out of the returned frames. In real code,
> it is better to query the whole stack as opposed to changing
> the stack, doing a query of the current frame, changing the
> stack, then doing a query, and so on.
>
> I forgot to mention in my last patch that I sent in my FSF
> copyright paperwork, so that should not stand in the way
> of incorporating my patches any longer.
>
> cheers
> Mo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] add implementation of stack-info-frame MI command
2002-07-25 17:04 ` Andrew Cagney
@ 2002-07-25 17:05 ` Keith Seitz
2002-07-25 20:11 ` Mo DeJong
0 siblings, 1 reply; 5+ messages in thread
From: Keith Seitz @ 2002-07-25 17:05 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Mo DeJong, gdb-patches
On Thu, 25 Jul 2002, Andrew Cagney wrote:
> See my post to GDB@. I think this should be handled as an event and not
> as a command.
As Mo has implemented, -stack-info-frame would return the very same
information as -stack-info-depth. I always thought that -stack-info-frame
would give information about the current (or given) frame, i.e., saved pc,
saved registers, etc.
> The user entering a command like ``up'' needs to trigger the event
> notification anyway.
As for "up"/"down"/"frame" commands to the console, I have already
implemented a notification event on the "mi branch".
Keith
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] add implementation of stack-info-frame MI command
2002-07-25 17:05 ` Keith Seitz
@ 2002-07-25 20:11 ` Mo DeJong
2002-07-25 22:33 ` Keith Seitz
0 siblings, 1 reply; 5+ messages in thread
From: Mo DeJong @ 2002-07-25 20:11 UTC (permalink / raw)
To: gdb-patches; +Cc: ac131313
On Thu, 25 Jul 2002 17:03:57 -0700 (PDT)
Keith Seitz <keiths@redhat.com> wrote:
> On Thu, 25 Jul 2002, Andrew Cagney wrote:
>
> > See my post to GDB. I think this should be handled as an event and not
> > as a command.
>
> As Mo has implemented, -stack-info-frame would return the very same
> information as -stack-info-depth.
It would? I was under the impression that -stack-info-depth would return
the number of frames on the stack without taking what the current frame
is into account.
-stack-info-depth
^done,depth="3"
(gdb)
^done depth 3
-stack-info-frame
^done,level="0"
(gdb)
^done level 0
up
^done,frame={level="1 ",addr="0x080484a8",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff5c4"}],file="resources.c",line="38"},line="38",file="resources.c"
-stack-info-depth
^done,depth="3"
(gdb)
-stack-info-frame
^done,level="1"
(gdb)
> I always thought that -stack-info-frame
> would give information about the current (or given) frame, i.e., saved pc,
> saved registers, etc.
I can't speak as to the original design goals. The existing documentation
for the command is not very clear about what it should do. I just
thought -stack-info-frame would work like -stack-select-frame in
that it would deal with an integer stack level. How is one meant to
query the stack level?
Mo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] add implementation of stack-info-frame MI command
2002-07-25 20:11 ` Mo DeJong
@ 2002-07-25 22:33 ` Keith Seitz
0 siblings, 0 replies; 5+ messages in thread
From: Keith Seitz @ 2002-07-25 22:33 UTC (permalink / raw)
To: Mo DeJong; +Cc: gdb-patches, ac131313
On Thu, 25 Jul 2002, Mo DeJong wrote:
> It would? I was under the impression that -stack-info-depth would return
> the number of frames on the stack without taking what the current frame
> is into account.
Ah, fooey. Brain fart. You're right. My bad...
Keith
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-07-26 3:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 15:10 [Patch] add implementation of stack-info-frame MI command Mo DeJong
2002-07-25 17:04 ` Andrew Cagney
2002-07-25 17:05 ` Keith Seitz
2002-07-25 20:11 ` Mo DeJong
2002-07-25 22:33 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox