OLD | NEW |
1 /* Disassemble support for GDB. | 1 /* Disassemble support for GDB. |
2 | 2 |
3 Copyright (C) 2000-2005, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2000-2005, 2007-2012 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (val == 0) | 90 if (val == 0) |
91 val = mle1->start_pc - mle2->start_pc; | 91 val = mle1->start_pc - mle2->start_pc; |
92 } | 92 } |
93 return val; | 93 return val; |
94 } | 94 } |
95 | 95 |
96 static int | 96 static int |
97 dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, | 97 dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, |
98 struct disassemble_info * di, | 98 struct disassemble_info * di, |
99 CORE_ADDR low, CORE_ADDR high, | 99 CORE_ADDR low, CORE_ADDR high, |
100 » int how_many, int flags, struct ui_stream *stb) | 100 » int how_many, int flags, struct ui_file *stb) |
101 { | 101 { |
102 int num_displayed = 0; | 102 int num_displayed = 0; |
103 CORE_ADDR pc; | 103 CORE_ADDR pc; |
104 | 104 |
105 /* parts of the symbolic representation of the address */ | 105 /* parts of the symbolic representation of the address */ |
106 int unmapped; | 106 int unmapped; |
107 int offset; | 107 int offset; |
108 int line; | 108 int line; |
109 struct cleanup *ui_out_chain; | 109 struct cleanup *ui_out_chain; |
110 | 110 |
(...skipping 27 matching lines...) Expand all Loading... |
138 ui_out_text (uiout, ">:\t"); | 138 ui_out_text (uiout, ">:\t"); |
139 } | 139 } |
140 else | 140 else |
141 ui_out_text (uiout, ":\t"); | 141 ui_out_text (uiout, ":\t"); |
142 | 142 |
143 if (filename != NULL) | 143 if (filename != NULL) |
144 xfree (filename); | 144 xfree (filename); |
145 if (name != NULL) | 145 if (name != NULL) |
146 xfree (name); | 146 xfree (name); |
147 | 147 |
148 ui_file_rewind (stb->stream); | 148 ui_file_rewind (stb); |
149 if (flags & DISASSEMBLY_RAW_INSN) | 149 if (flags & DISASSEMBLY_RAW_INSN) |
150 { | 150 { |
151 CORE_ADDR old_pc = pc; | 151 CORE_ADDR old_pc = pc; |
152 bfd_byte data; | 152 bfd_byte data; |
153 int status; | 153 int status; |
154 const char *spacer = ""; | 154 const char *spacer = ""; |
155 | 155 |
156 /* Build the opcodes using a temporary stream so we can | 156 /* Build the opcodes using a temporary stream so we can |
157 write them out in a single go for the MI. */ | 157 write them out in a single go for the MI. */ |
158 struct ui_stream *opcode_stream = ui_out_stream_new (uiout); | 158 struct ui_file *opcode_stream = mem_fileopen (); |
159 struct cleanup *cleanups = | 159 struct cleanup *cleanups = |
160 make_cleanup_ui_out_stream_delete (opcode_stream); | 160 make_cleanup_ui_file_delete (opcode_stream); |
161 | 161 |
162 pc += gdbarch_print_insn (gdbarch, pc, di); | 162 pc += gdbarch_print_insn (gdbarch, pc, di); |
163 for (;old_pc < pc; old_pc++) | 163 for (;old_pc < pc; old_pc++) |
164 { | 164 { |
165 status = (*di->read_memory_func) (old_pc, &data, 1, di); | 165 status = (*di->read_memory_func) (old_pc, &data, 1, di); |
166 if (status != 0) | 166 if (status != 0) |
167 (*di->memory_error_func) (status, old_pc, di); | 167 (*di->memory_error_func) (status, old_pc, di); |
168 fprintf_filtered (opcode_stream->stream, "%s%02x", | 168 fprintf_filtered (opcode_stream, "%s%02x", |
169 spacer, (unsigned) data); | 169 spacer, (unsigned) data); |
170 spacer = " "; | 170 spacer = " "; |
171 } | 171 } |
172 ui_out_field_stream (uiout, "opcodes", opcode_stream); | 172 ui_out_field_stream (uiout, "opcodes", opcode_stream); |
173 ui_out_text (uiout, "\t"); | 173 ui_out_text (uiout, "\t"); |
174 | 174 |
175 do_cleanups (cleanups); | 175 do_cleanups (cleanups); |
176 } | 176 } |
177 else | 177 else |
178 pc += gdbarch_print_insn (gdbarch, pc, di); | 178 pc += gdbarch_print_insn (gdbarch, pc, di); |
179 ui_out_field_stream (uiout, "inst", stb); | 179 ui_out_field_stream (uiout, "inst", stb); |
180 ui_file_rewind (stb->stream); | 180 ui_file_rewind (stb); |
181 do_cleanups (ui_out_chain); | 181 do_cleanups (ui_out_chain); |
182 ui_out_text (uiout, "\n"); | 182 ui_out_text (uiout, "\n"); |
183 } | 183 } |
184 return num_displayed; | 184 return num_displayed; |
185 } | 185 } |
186 | 186 |
187 /* The idea here is to present a source-O-centric view of a | 187 /* The idea here is to present a source-O-centric view of a |
188 function to the user. This means that things are presented | 188 function to the user. This means that things are presented |
189 in source order, with (possibly) out of order assembly | 189 in source order, with (possibly) out of order assembly |
190 immediately following. */ | 190 immediately following. */ |
191 | 191 |
192 static void | 192 static void |
193 do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, | 193 do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, |
194 struct disassemble_info *di, int nlines, | 194 struct disassemble_info *di, int nlines, |
195 struct linetable_entry *le, | 195 struct linetable_entry *le, |
196 CORE_ADDR low, CORE_ADDR high, | 196 CORE_ADDR low, CORE_ADDR high, |
197 struct symtab *symtab, | 197 struct symtab *symtab, |
198 » » » int how_many, int flags, struct ui_stream *stb) | 198 » » » int how_many, int flags, struct ui_file *stb) |
199 { | 199 { |
200 int newlines = 0; | 200 int newlines = 0; |
201 struct dis_line_entry *mle; | 201 struct dis_line_entry *mle; |
202 struct symtab_and_line sal; | 202 struct symtab_and_line sal; |
203 int i; | 203 int i; |
204 int out_of_order = 0; | 204 int out_of_order = 0; |
205 int next_line = 0; | 205 int next_line = 0; |
206 int num_displayed = 0; | 206 int num_displayed = 0; |
207 struct cleanup *ui_out_chain; | 207 struct cleanup *ui_out_chain; |
208 struct cleanup *ui_out_tuple_chain = make_cleanup (null_cleanup, 0); | 208 struct cleanup *ui_out_tuple_chain = make_cleanup (null_cleanup, 0); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 break; | 335 break; |
336 } | 336 } |
337 do_cleanups (ui_out_chain); | 337 do_cleanups (ui_out_chain); |
338 } | 338 } |
339 | 339 |
340 | 340 |
341 static void | 341 static void |
342 do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, | 342 do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, |
343 struct disassemble_info * di, | 343 struct disassemble_info * di, |
344 CORE_ADDR low, CORE_ADDR high, | 344 CORE_ADDR low, CORE_ADDR high, |
345 » » int how_many, int flags, struct ui_stream *stb) | 345 » » int how_many, int flags, struct ui_file *stb) |
346 { | 346 { |
347 int num_displayed = 0; | 347 int num_displayed = 0; |
348 struct cleanup *ui_out_chain; | 348 struct cleanup *ui_out_chain; |
349 | 349 |
350 ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); | 350 ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); |
351 | 351 |
352 num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, | 352 num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, |
353 flags, stb); | 353 flags, stb); |
354 | 354 |
355 do_cleanups (ui_out_chain); | 355 do_cleanups (ui_out_chain); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 di.application_data = gdbarch; | 395 di.application_data = gdbarch; |
396 disassemble_init_for_target (&di); | 396 disassemble_init_for_target (&di); |
397 return di; | 397 return di; |
398 } | 398 } |
399 | 399 |
400 void | 400 void |
401 gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, | 401 gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, |
402 char *file_string, int flags, int how_many, | 402 char *file_string, int flags, int how_many, |
403 CORE_ADDR low, CORE_ADDR high) | 403 CORE_ADDR low, CORE_ADDR high) |
404 { | 404 { |
405 struct ui_stream *stb = ui_out_stream_new (uiout); | 405 struct ui_file *stb = mem_fileopen (); |
406 struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb); | 406 struct cleanup *cleanups = make_cleanup_ui_file_delete (stb); |
407 struct disassemble_info di = gdb_disassemble_info (gdbarch, stb->stream); | 407 struct disassemble_info di = gdb_disassemble_info (gdbarch, stb); |
408 /* To collect the instruction outputted from opcodes. */ | 408 /* To collect the instruction outputted from opcodes. */ |
409 struct symtab *symtab = NULL; | 409 struct symtab *symtab = NULL; |
410 struct linetable_entry *le = NULL; | 410 struct linetable_entry *le = NULL; |
411 int nlines = -1; | 411 int nlines = -1; |
412 | 412 |
413 /* Assume symtab is valid for whole PC range. */ | 413 /* Assume symtab is valid for whole PC range. */ |
414 symtab = find_pc_symtab (low); | 414 symtab = find_pc_symtab (low); |
415 | 415 |
416 if (symtab != NULL && symtab->linetable != NULL) | 416 if (symtab != NULL && symtab->linetable != NULL) |
417 { | 417 { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 int | 520 int |
521 gdb_buffered_insn_length (struct gdbarch *gdbarch, | 521 gdb_buffered_insn_length (struct gdbarch *gdbarch, |
522 const gdb_byte *insn, int max_len, CORE_ADDR addr) | 522 const gdb_byte *insn, int max_len, CORE_ADDR addr) |
523 { | 523 { |
524 struct disassemble_info di; | 524 struct disassemble_info di; |
525 | 525 |
526 gdb_buffered_insn_length_init_dis (gdbarch, &di, insn, max_len, addr); | 526 gdb_buffered_insn_length_init_dis (gdbarch, &di, insn, max_len, addr); |
527 | 527 |
528 return gdbarch_print_insn (gdbarch, addr, &di); | 528 return gdbarch_print_insn (gdbarch, addr, &di); |
529 } | 529 } |
OLD | NEW |