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.
13 gdb command: Implemented?
16 -data-evaluate-expression Yes
17 -data-list-changed-registers No
18 -data-list-register-names Yes
19 -data-list-register-values No
21 -display-delete N.A. (delete display)
22 -display-disable N.A. (disable display)
23 -display-enable N.A. (enable display)
24 -display-insert N.A. (display)
25 -display-list N.A. (info display)
27 -environment-directory Yes, MI v1 implementation
33 1) -display* aren't implemented. You can use CLI command display, but the
34 results are sent to the console. So it looks like the best is to manually
35 use -data-evaluate-expression to emulate it. @<p>
37 2) GDB bug mi/1770: Affects gdb<=6.2, when you ask for the names of the
38 registers you get it plus the name of the "pseudo-registers", but if you
39 try to get the value of a pseudo-register you get an error saying the
40 register number is invalid. I reported to gdb-patches@sources.redhat.com
41 on 2004/08/25 and as I didn't get any answer I filled a bug report on
42 2004/09/02. The patch to fix this annoying bug is:
44 Index: gdb/mi/mi-main.c
45 ===================================================================
46 RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
47 retrieving revision 1.64
48 diff -u -r1.64 mi-main.c
49 --- gdb/mi/mi-main.c 3 Aug 2004 00:57:27 -0000 1.64
50 +++ gdb/mi/mi-main.c 25 Aug 2004 14:12:50 -0000
52 case, some entries of REGISTER_NAME will change depending upon
53 the particular processor being debugged.
56 + numregs = NUM_REGS + NUM_PSEUDO_REGS;
62 Note I had to remove an end of comment in the patch to include it here.
63 This bug forced me to create another set of functions. The only way is to
64 first get the values and then the names.
65 Fixed by Changelog entry:
67 2004-09-12 Salvador E. Tropea <set@users.sf.net>
68 Andrew Cagney <cagney@gnu.org>
70 * mi/mi-main.c (mi_cmd_data_list_changed_registers)
71 (mi_cmd_data_list_register_values)
72 (mi_cmd_data_write_register_values): Include the PSEUDO_REGS in
73 the register number computation.
75 ***************************************************************************/
79 /* Low level versions. */
81 void mi_data_evaluate_expression(mi_h *h, const char *expression)
83 mi_send(h,"-data-evaluate-expression \"%s\"\n",expression);
86 void mi_dir(mi_h *h, const char *path)
88 if (h->version>=MI_VERSION2U(2,0,0))
91 mi_send(h,"-environment-directory \"%s\"\n",path);
93 mi_send(h,"-environment-directory -r\n");
97 mi_send(h,"-environment-directory %s\n",path ? path : "");
101 void mi_data_read_memory_hx(mi_h *h, const char *exp, unsigned ws,
102 unsigned c, int convAddr)
105 mi_send(h,"-data-read-memory \"&%s\" x %d 1 %d\n",exp,ws,c);
107 mi_send(h,"-data-read-memory \"%s\" x %d 1 %d\n",exp,ws,c);
110 void mi_data_disassemble_se(mi_h *h, const char *start, const char *end,
113 mi_send(h,"-data-disassemble -s \"%s\" -e \"%s\" -- %d\n",start,end,mode);
116 void mi_data_disassemble_fl(mi_h *h, const char *file, int line, int lines,
119 mi_send(h,"-data-disassemble -f \"%s\" -l %d -n %d -- %d\n",file,line,lines,
123 void mi_data_list_register_names(mi_h *h)
125 mi_send(h,"-data-list-register-names\n");
128 void mi_data_list_register_names_l(mi_h *h, mi_chg_reg *l)
130 mi_send(h,"-data-list-register-names ");
133 mi_send(h,"%d ",l->reg);
139 void mi_data_list_changed_registers(mi_h *h)
141 mi_send(h,"-data-list-changed-registers\n");
144 void mi_data_list_register_values(mi_h *h, enum mi_gvar_fmt fmt, mi_chg_reg *l)
146 mi_send(h,"-data-list-register-values %c ",mi_format_enum_to_char(fmt));
149 mi_send(h,"%d ",l->reg);
155 /* High level versions. */
157 /**[txh]********************************************************************
160 Evaluate an expression. Returns a parsed tree.
162 Command: -data-evaluate-expression
163 Return: The resulting value (as plain text) or NULL on error.
165 ***************************************************************************/
167 char *gmi_data_evaluate_expression(mi_h *h, const char *expression)
169 mi_data_evaluate_expression(h,expression);
170 return mi_res_value(h);
173 /**[txh]********************************************************************
176 Path for sources. You must use it to indicate where are the sources for
177 the program to debug. Only the MI v1 implementation is available.
179 Command: -environment-directory
182 ***************************************************************************/
184 int gmi_dir(mi_h *h, const char *path)
187 return mi_res_simple_done(h);
190 int gmi_read_memory(mi_h *h, const char *exp, unsigned size,
191 unsigned char *dest, int *na, int convAddr,
194 mi_data_read_memory_hx(h,exp,1,size,convAddr);
195 return mi_get_read_memory(h,dest,1,na,addr);
198 mi_asm_insns *gmi_data_disassemble_se(mi_h *h, const char *start,
199 const char *end, int mode)
201 mi_data_disassemble_se(h,start,end,mode);
202 return mi_get_asm_insns(h);
205 mi_asm_insns *gmi_data_disassemble_fl(mi_h *h, const char *file, int line,
208 mi_data_disassemble_fl(h,file,line,lines,mode);
209 return mi_get_asm_insns(h);
212 // Affected by gdb bug mi/1770
213 mi_chg_reg *gmi_data_list_register_names(mi_h *h, int *how_many)
215 mi_data_list_register_names(h);
216 return mi_get_list_registers(h,how_many);
219 int gmi_data_list_register_names_l(mi_h *h, mi_chg_reg *l)
221 mi_data_list_register_names_l(h,l);
222 return mi_get_list_registers_l(h,l);
225 mi_chg_reg *gmi_data_list_changed_registers(mi_h *h)
228 mi_data_list_changed_registers(h);
229 return mi_get_list_changed_regs(h);
232 int gmi_data_list_register_values(mi_h *h, enum mi_gvar_fmt fmt, mi_chg_reg *l)
234 mi_data_list_register_values(h,fmt,l);
235 return mi_get_reg_values(h,l);
238 mi_chg_reg *gmi_data_list_all_register_values(mi_h *h, enum mi_gvar_fmt fmt, int *how_many)
240 mi_data_list_register_values(h,fmt,NULL);
241 return mi_get_reg_values_l(h,how_many);