1 /**[txh]********************************************************************
3 Copyright (c) 2004 by Salvador E. Tropea.
4 Covered by the GPL license.
6 Module: Stack manipulation.
8 GDB/MI commands for the "Stack Manipulation" section.@p
11 gdb command: Implemented?
13 -stack-info-frame Yes, implemented as "frame"
15 -stack-list-arguments Yes
16 -stack-list-frames Yes
17 -stack-list-locals Yes
18 -stack-select-frame Yes
21 ***************************************************************************/
25 /* Low level versions. */
27 void mi_stack_list_frames(mi_h *h, int from, int to)
30 mi_send(h,"-stack-list-frames\n");
32 mi_send(h,"-stack-list-frames %d %d\n",from,to);
35 void mi_stack_list_arguments(mi_h *h, int show, int from, int to)
38 mi_send(h,"-stack-list-arguments %d\n",show);
40 mi_send(h,"-stack-list-arguments %d %d %d\n",show,from,to);
43 void mi_stack_info_frame(mi_h *h)
48 void mi_stack_info_depth(mi_h *h, int depth)
51 mi_send(h,"-stack-info-depth\n");
53 mi_send(h,"-stack-info-depth %d\n",depth);
56 void mi_stack_select_frame(mi_h *h, int framenum)
58 mi_send(h,"-stack-select-frame %d\n",framenum);
61 void mi_stack_list_locals(mi_h *h, int show)
63 mi_send(h,"-stack-list-locals %d\n",show);
66 /* High level versions. */
68 /**[txh]********************************************************************
71 List of frames. Arguments aren't filled.
73 Command: -stack-list-frames
74 Return: A new list of mi_frames or NULL on error.
76 ***************************************************************************/
78 mi_frames *gmi_stack_list_frames(mi_h *h)
80 mi_stack_list_frames(h,-1,-1);
81 return mi_res_frames_array(h,"stack");
84 /**[txh]********************************************************************
87 List of frames. Arguments aren't filled. Only the frames in the @var{from}
88 - @var{to} range are returned.
90 Command: -stack-list-frames
91 Return: A new list of mi_frames or NULL on error.
93 ***************************************************************************/
95 mi_frames *gmi_stack_list_frames_r(mi_h *h, int from, int to)
97 mi_stack_list_frames(h,from,to);
98 return mi_res_frames_array(h,"stack");
101 /**[txh]********************************************************************
104 List arguments. Only @var{level} and @var{args} filled.
106 Command: -stack-list-arguments
107 Return: A new list of mi_frames or NULL on error.
109 ***************************************************************************/
111 mi_frames *gmi_stack_list_arguments(mi_h *h, int show)
113 mi_stack_list_arguments(h,show,-1,-1);
114 return mi_res_frames_array(h,"stack-args");
117 /**[txh]********************************************************************
120 List arguments. Only @var{level} and @var{args} filled. Only for the
121 frames in the @var{from} - @var{to} range.
123 Command: -stack-list-arguments
124 Return: A new list of mi_frames or NULL on error.
126 ***************************************************************************/
128 mi_frames *gmi_stack_list_arguments_r(mi_h *h, int show, int from, int to)
130 mi_stack_list_arguments(h,show,from,to);
131 return mi_res_frames_array(h,"stack-args");
134 /**[txh]********************************************************************
137 Information about the current frame, including args.
139 Command: -stack-info-frame [using frame]
140 Return: A new mi_frames or NULL on error.
142 ***************************************************************************/
144 mi_frames *gmi_stack_info_frame(mi_h *h)
146 mi_stack_info_frame(h);
147 return mi_res_frame(h);
150 /**[txh]********************************************************************
155 Command: -stack-info-depth
156 Return: The depth or -1 on error.
158 ***************************************************************************/
160 int gmi_stack_info_depth(mi_h *h, int max_depth)
165 mi_stack_info_depth(h,max_depth);
166 r=mi_res_done_var(h,"depth");
167 if (r && r->type==t_const)
175 /**[txh]********************************************************************
178 Set stack info depth.
180 Command: -stack-info-depth [no args]
181 Return: The depth or -1 on error.
184 ***************************************************************************/
186 int gmi_stack_info_depth_get(mi_h *h)
188 return gmi_stack_info_depth(h,-1);
191 /**[txh]********************************************************************
194 Change current frame.
196 Command: -stack-select-frame
199 ***************************************************************************/
201 int gmi_stack_select_frame(mi_h *h, int framenum)
203 mi_stack_select_frame(h,framenum);
204 return mi_res_simple_done(h);
207 /**[txh]********************************************************************
212 Command: -stack-list-locals
213 Return: A new mi_results tree containing the variables or NULL on error.
215 ***************************************************************************/
217 mi_results *gmi_stack_list_locals(mi_h *h, int show)
219 mi_stack_list_locals(h,show);
220 return mi_res_done_var(h,"locals");