1 /**[txh]********************************************************************
3 Copyright (c) 2004 by Salvador E. Tropea.
4 Covered by the GPL license.
6 Module: Data manipulation.
8 GDB/MI commands for the "Data manipulation" section.@p
11 gdb command: Implemented?
14 -data-evaluate-expression Yes
15 -data-list-changed-registers No
16 -data-list-register-names Yes
17 -data-list-register-values No
19 -display-delete N.A. (delete display)
20 -display-disable N.A. (disable display)
21 -display-enable N.A. (enable display)
22 -display-insert N.A. (display)
23 -display-list N.A. (info display)
25 -environment-directory Yes, MI v1 implementation
31 1) -display* aren't implemented. You can use CLI command display, but the
32 results are sent to the console. So it looks like the best is to manually
33 use -data-evaluate-expression to emulate it.@p
35 2) GDB bug mi/1770: Affects gdb<=6.2, when you ask for the names of the
36 registers you get it plus the name of the "pseudo-registers", but if you
37 try to get the value of a pseudo-register you get an error saying the
38 register number is invalid. I reported to gdb-patches@sources.redhat.com
39 on 2004/08/25 and as I didn't get any answer I filled a bug report on
40 2004/09/02. The patch to fix this annoying bug is:
42 Index: gdb/mi/mi-main.c
43 ===================================================================
44 RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
45 retrieving revision 1.64
46 diff -u -r1.64 mi-main.c
47 --- gdb/mi/mi-main.c 3 Aug 2004 00:57:27 -0000 1.64
48 +++ gdb/mi/mi-main.c 25 Aug 2004 14:12:50 -0000
50 case, some entries of REGISTER_NAME will change depending upon
51 the particular processor being debugged.
54 + numregs = NUM_REGS + NUM_PSEUDO_REGS;
60 Note I had to remove an end of comment in the patch to include it here.
61 This bug forced me to create another set of functions. The only way is to
62 first get the values and then the names.
63 Fixed by Changelog entry:
65 2004-09-12 Salvador E. Tropea <set@users.sf.net>
66 Andrew Cagney <cagney@gnu.org>
68 * mi/mi-main.c (mi_cmd_data_list_changed_registers)
69 (mi_cmd_data_list_register_values)
70 (mi_cmd_data_write_register_values): Include the PSEUDO_REGS in
71 the register number computation.
73 ***************************************************************************/
77 /* Low level versions. */
79 void mi_data_evaluate_expression(mi_h *h, const char *expression)
81 mi_send(h,"-data-evaluate-expression \"%s\"\n",expression);
84 void mi_dir(mi_h *h, const char *path)
86 if (h->version>=MI_VERSION2U(2,0,0))
89 mi_send(h,"-environment-directory \"%s\"\n",path);
91 mi_send(h,"-environment-directory -r\n");
95 mi_send(h,"-environment-directory %s\n",path ? path : "");
99 void mi_data_read_memory_hx(mi_h *h, const char *exp, unsigned ws,
100 unsigned c, int convAddr)
103 mi_send(h,"-data-read-memory \"&%s\" x %d 1 %d\n",exp,ws,c);
105 mi_send(h,"-data-read-memory \"%s\" x %d 1 %d\n",exp,ws,c);
108 void mi_data_disassemble_se(mi_h *h, const char *start, const char *end,
111 mi_send(h,"-data-disassemble -s \"%s\" -e \"%s\" -- %d\n",start,end,mode);
114 void mi_data_disassemble_fl(mi_h *h, const char *file, int line, int lines,
117 mi_send(h,"-data-disassemble -f \"%s\" -l %d -n %d -- %d\n",file,line,lines,
121 void mi_data_list_register_names(mi_h *h)
123 mi_send(h,"-data-list-register-names\n");
126 void mi_data_list_register_names_l(mi_h *h, mi_chg_reg *l)
128 mi_send(h,"-data-list-register-names ");
131 mi_send(h,"%d ",l->reg);
137 void mi_data_list_changed_registers(mi_h *h)
139 mi_send(h,"-data-list-changed-registers\n");
142 void mi_data_list_register_values(mi_h *h, enum mi_gvar_fmt fmt, mi_chg_reg *l)
144 mi_send(h,"-data-list-register-values %c ",mi_format_enum_to_char(fmt));
147 mi_send(h,"%d ",l->reg);
153 /* High level versions. */
155 /**[txh]********************************************************************
158 Evaluate an expression. Returns a parsed tree.
160 Command: -data-evaluate-expression
161 Return: The resulting value (as plain text) or NULL on error.
163 ***************************************************************************/
165 char *gmi_data_evaluate_expression(mi_h *h, const char *expression)
167 mi_data_evaluate_expression(h,expression);
168 return mi_res_value(h);
171 /**[txh]********************************************************************
174 Path for sources. You must use it to indicate where are the sources for
175 the program to debug. Only the MI v1 implementation is available.
177 Command: -environment-directory
180 ***************************************************************************/
182 int gmi_dir(mi_h *h, const char *path)
185 return mi_res_simple_done(h);
188 int gmi_read_memory(mi_h *h, const char *exp, unsigned size,
189 unsigned char *dest, int *na, int convAddr,
192 mi_data_read_memory_hx(h,exp,1,size,convAddr);
193 return mi_get_read_memory(h,dest,1,na,addr);
196 mi_asm_insns *gmi_data_disassemble_se(mi_h *h, const char *start,
197 const char *end, int mode)
199 mi_data_disassemble_se(h,start,end,mode);
200 return mi_get_asm_insns(h);
203 mi_asm_insns *gmi_data_disassemble_fl(mi_h *h, const char *file, int line,
206 mi_data_disassemble_fl(h,file,line,lines,mode);
207 return mi_get_asm_insns(h);
210 // Affected by gdb bug mi/1770
211 mi_chg_reg *gmi_data_list_register_names(mi_h *h, int *how_many)
213 mi_data_list_register_names(h);
214 return mi_get_list_registers(h,how_many);
217 int gmi_data_list_register_names_l(mi_h *h, mi_chg_reg *l)
219 mi_data_list_register_names_l(h,l);
220 return mi_get_list_registers_l(h,l);
223 mi_chg_reg *gmi_data_list_changed_registers(mi_h *h)
226 mi_data_list_changed_registers(h);
227 return mi_get_list_changed_regs(h);
230 int gmi_data_list_register_values(mi_h *h, enum mi_gvar_fmt fmt, mi_chg_reg *l)
232 mi_data_list_register_values(h,fmt,l);
233 return mi_get_reg_values(h,l);
236 mi_chg_reg *gmi_data_list_all_register_values(mi_h *h, enum mi_gvar_fmt fmt, int *how_many)
238 mi_data_list_register_values(h,fmt,NULL);
239 return mi_get_reg_values_l(h,how_many);