From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7957 invoked by alias); 25 Jul 2002 21:38:18 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 7881 invoked from network); 25 Jul 2002 21:38:10 -0000 Received: from unknown (HELO mta5.snfc21.pbi.net) (206.13.28.241) by sources.redhat.com with SMTP; 25 Jul 2002 21:38:10 -0000 Received: from modrick ([66.120.11.181]) by mta5.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with SMTP id <0GZT00272QRLJ8@mta5.snfc21.pbi.net> for gdb-patches@sources.redhat.com; Thu, 25 Jul 2002 14:38:10 -0700 (PDT) Date: Thu, 25 Jul 2002 15:10:00 -0000 From: Mo DeJong Subject: [Patch] add implementation of stack-info-frame MI command To: gdb-patches@sources.redhat.com Message-id: <20020725143758.3cbf44d1.supermo@bayarea.net> Organization: House of Mirth MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-SW-Source: 2002-07/txt/msg00519.txt.bz2 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 * 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 * 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;