diff options
Diffstat (limited to 'pathologist/src/mi/gdbmi_data_man.c')
-rw-r--r-- | pathologist/src/mi/gdbmi_data_man.c | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/pathologist/src/mi/gdbmi_data_man.c b/pathologist/src/mi/gdbmi_data_man.c new file mode 100644 index 0000000..06e1377 --- /dev/null +++ b/pathologist/src/mi/gdbmi_data_man.c | |||
@@ -0,0 +1,243 @@ | |||
1 | /**[txh]******************************************************************** | ||
2 | |||
3 | Copyright (c) 2004 by Salvador E. Tropea. | ||
4 | Covered by the GPL license. | ||
5 | |||
6 | Module: Data manipulation. | ||
7 | Comments: | ||
8 | GDB/MI commands for the "Data manipulation" section. | ||
9 | |||
10 | @<p> | ||
11 | |||
12 | @<pre> | ||
13 | gdb command: Implemented? | ||
14 | |||
15 | -data-disassemble Yes | ||
16 | -data-evaluate-expression Yes | ||
17 | -data-list-changed-registers No | ||
18 | -data-list-register-names Yes | ||
19 | -data-list-register-values No | ||
20 | -data-read-memory 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) | ||
26 | -environment-cd No | ||
27 | -environment-directory Yes, MI v1 implementation | ||
28 | -environment-path No | ||
29 | @</pre> | ||
30 | |||
31 | Notes: @<p> | ||
32 | |||
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> | ||
36 | |||
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: | ||
43 | |||
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 | ||
51 | @@ -423,7 +423,7 @@ | ||
52 | case, some entries of REGISTER_NAME will change depending upon | ||
53 | the particular processor being debugged. | ||
54 | |||
55 | - numregs = NUM_REGS; | ||
56 | + numregs = NUM_REGS + NUM_PSEUDO_REGS; | ||
57 | |||
58 | if (argc == 0) | ||
59 | { | ||
60 | ---- | ||
61 | |||
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: | ||
66 | |||
67 | 2004-09-12 Salvador E. Tropea <set@users.sf.net> | ||
68 | Andrew Cagney <cagney@gnu.org> | ||
69 | |||
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. | ||
74 | |||
75 | ***************************************************************************/ | ||
76 | |||
77 | #include "gdbmi.h" | ||
78 | |||
79 | /* Low level versions. */ | ||
80 | |||
81 | void mi_data_evaluate_expression(mi_h *h, const char *expression) | ||
82 | { | ||
83 | mi_send(h,"-data-evaluate-expression \"%s\"\n",expression); | ||
84 | } | ||
85 | |||
86 | void mi_dir(mi_h *h, const char *path) | ||
87 | { | ||
88 | if (h->version>=MI_VERSION2U(2,0,0)) | ||
89 | {// MI v2 | ||
90 | if (path) | ||
91 | mi_send(h,"-environment-directory \"%s\"\n",path); | ||
92 | else | ||
93 | mi_send(h,"-environment-directory -r\n"); | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | mi_send(h,"-environment-directory %s\n",path ? path : ""); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | void mi_data_read_memory_hx(mi_h *h, const char *exp, unsigned ws, | ||
102 | unsigned c, int convAddr) | ||
103 | { | ||
104 | if (convAddr) | ||
105 | mi_send(h,"-data-read-memory \"&%s\" x %d 1 %d\n",exp,ws,c); | ||
106 | else | ||
107 | mi_send(h,"-data-read-memory \"%s\" x %d 1 %d\n",exp,ws,c); | ||
108 | } | ||
109 | |||
110 | void mi_data_disassemble_se(mi_h *h, const char *start, const char *end, | ||
111 | int mode) | ||
112 | { | ||
113 | mi_send(h,"-data-disassemble -s \"%s\" -e \"%s\" -- %d\n",start,end,mode); | ||
114 | } | ||
115 | |||
116 | void mi_data_disassemble_fl(mi_h *h, const char *file, int line, int lines, | ||
117 | int mode) | ||
118 | { | ||
119 | mi_send(h,"-data-disassemble -f \"%s\" -l %d -n %d -- %d\n",file,line,lines, | ||
120 | mode); | ||
121 | } | ||
122 | |||
123 | void mi_data_list_register_names(mi_h *h) | ||
124 | { | ||
125 | mi_send(h,"-data-list-register-names\n"); | ||
126 | } | ||
127 | |||
128 | void mi_data_list_register_names_l(mi_h *h, mi_chg_reg *l) | ||
129 | { | ||
130 | mi_send(h,"-data-list-register-names "); | ||
131 | while (l) | ||
132 | { | ||
133 | mi_send(h,"%d ",l->reg); | ||
134 | l=l->next; | ||
135 | } | ||
136 | mi_send(h,"\n"); | ||
137 | } | ||
138 | |||
139 | void mi_data_list_changed_registers(mi_h *h) | ||
140 | { | ||
141 | mi_send(h,"-data-list-changed-registers\n"); | ||
142 | } | ||
143 | |||
144 | void mi_data_list_register_values(mi_h *h, enum mi_gvar_fmt fmt, mi_chg_reg *l) | ||
145 | { | ||
146 | mi_send(h,"-data-list-register-values %c ",mi_format_enum_to_char(fmt)); | ||
147 | while (l) | ||
148 | { | ||
149 | mi_send(h,"%d ",l->reg); | ||
150 | l=l->next; | ||
151 | } | ||
152 | mi_send(h,"\n"); | ||
153 | } | ||
154 | |||
155 | /* High level versions. */ | ||
156 | |||
157 | /**[txh]******************************************************************** | ||
158 | |||
159 | Description: | ||
160 | Evaluate an expression. Returns a parsed tree. | ||
161 | |||
162 | Command: -data-evaluate-expression | ||
163 | Return: The resulting value (as plain text) or NULL on error. | ||
164 | |||
165 | ***************************************************************************/ | ||
166 | |||
167 | char *gmi_data_evaluate_expression(mi_h *h, const char *expression) | ||
168 | { | ||
169 | mi_data_evaluate_expression(h,expression); | ||
170 | return mi_res_value(h); | ||
171 | } | ||
172 | |||
173 | /**[txh]******************************************************************** | ||
174 | |||
175 | Description: | ||
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. | ||
178 | |||
179 | Command: -environment-directory | ||
180 | Return: !=0 OK | ||
181 | |||
182 | ***************************************************************************/ | ||
183 | |||
184 | int gmi_dir(mi_h *h, const char *path) | ||
185 | { | ||
186 | mi_dir(h,path); | ||
187 | return mi_res_simple_done(h); | ||
188 | } | ||
189 | |||
190 | int gmi_read_memory(mi_h *h, const char *exp, unsigned size, | ||
191 | unsigned char *dest, int *na, int convAddr, | ||
192 | unsigned long *addr) | ||
193 | { | ||
194 | mi_data_read_memory_hx(h,exp,1,size,convAddr); | ||
195 | return mi_get_read_memory(h,dest,1,na,addr); | ||
196 | } | ||
197 | |||
198 | mi_asm_insns *gmi_data_disassemble_se(mi_h *h, const char *start, | ||
199 | const char *end, int mode) | ||
200 | { | ||
201 | mi_data_disassemble_se(h,start,end,mode); | ||
202 | return mi_get_asm_insns(h); | ||
203 | } | ||
204 | |||
205 | mi_asm_insns *gmi_data_disassemble_fl(mi_h *h, const char *file, int line, | ||
206 | int lines, int mode) | ||
207 | { | ||
208 | mi_data_disassemble_fl(h,file,line,lines,mode); | ||
209 | return mi_get_asm_insns(h); | ||
210 | } | ||
211 | |||
212 | // Affected by gdb bug mi/1770 | ||
213 | mi_chg_reg *gmi_data_list_register_names(mi_h *h, int *how_many) | ||
214 | { | ||
215 | mi_data_list_register_names(h); | ||
216 | return mi_get_list_registers(h,how_many); | ||
217 | } | ||
218 | |||
219 | int gmi_data_list_register_names_l(mi_h *h, mi_chg_reg *l) | ||
220 | { | ||
221 | mi_data_list_register_names_l(h,l); | ||
222 | return mi_get_list_registers_l(h,l); | ||
223 | } | ||
224 | |||
225 | mi_chg_reg *gmi_data_list_changed_registers(mi_h *h) | ||
226 | { | ||
227 | mi_error=MI_OK; | ||
228 | mi_data_list_changed_registers(h); | ||
229 | return mi_get_list_changed_regs(h); | ||
230 | } | ||
231 | |||
232 | int gmi_data_list_register_values(mi_h *h, enum mi_gvar_fmt fmt, mi_chg_reg *l) | ||
233 | { | ||
234 | mi_data_list_register_values(h,fmt,l); | ||
235 | return mi_get_reg_values(h,l); | ||
236 | } | ||
237 | |||
238 | mi_chg_reg *gmi_data_list_all_register_values(mi_h *h, enum mi_gvar_fmt fmt, int *how_many) | ||
239 | { | ||
240 | mi_data_list_register_values(h,fmt,NULL); | ||
241 | return mi_get_reg_values_l(h,how_many); | ||
242 | } | ||
243 | |||