(gdb_print_insn): Likewise.
* disasm.c (dump_insns): Add GDBARCH parameter. Use it instead
of current_gdbarch.
(do_mixed_source_and_assembly): Add GDBARCH parameter. Pass to
dump_insns.
(do_assembly_only): Likewise.
(gdb_disassembly): Add GDBARCH parameter. Use it instead of
current_gdbarch. Pass to subroutines.
(gdb_print_insn): Add GDBARCH parameter. Use it instead of
current_gdbarch.
* stack.c (struct gdb_disassembly_stub_args): Add GDBARCH member.
(gdb_disassembly_stub): Pass architecture to gdb_disassembly.
(do_gdb_disassembly): Add GDBARCH argument. Store into args.
(print_frame_info): Pass architecture to do_gdb_disassembly.
* printcmd.c (print_formatted): Pass architecture to gdb_print_insn.
* mi/mi-cmd-disas.c: Include "arch-utils.h"
(mi_cmd_disassemble): Pass architecture to gdb_disassembly.
* cli/cli-cmds.c: Include "arch-utils.h".
(print_disassembly): Add GDBARCH parameter. Pass to gdb_disassembly
and tui_show_assembly.
(disassemble_current_function): Pass architecture to
tui_get_low_disassembly_address and print_disassembly.
(disassemble_command): Pass architecture to
tui_get_low_disassembly_address and print_disassembly.
* tui/tui.c (tui_show_assembly): Add GDBARCH parameter. Pass to
tui_update_source_windows_with_addr.
* tui/tui-data.h (struct tui_locator_element): Add GDBARCH member.
(struct tui_source_info): Likewise.
* tui/tui-data.c (tui_clear_win_detail): Clear source_info.gdbarch.
* tui/tui-disasm.c (tui_disassemble): Add GDBARCH parameter.
Pass to gdb_print_insn.
(tui_find_disassembly_address): Add GDBARCH parameter. Pass to
tui_disassemble.
(tui_set_disassem_content): Add GDBARCH parameter. Install into
source_info.gdbarch. Pass to tui_disassemble.
(tui_show_disassem): Add GDBARCH parameter. Pass to
tui_update_source_window.
(tui_show_disassem_and_update_source): Add GDBARCH parameter. Pass to
tui_show_disassem and tui_update_source_window.
(tui_get_begin_asm_address): Return locator architecture in addition
to locator PC value.
(tui_get_low_disassembly_address): Add GDBARCH parameter. Pass to
tui_get_low_disassembly_address.
(tui_vertical_disassem_scroll): Pass architecture to subroutines.
* tui/tui-disasm.h (tui_set_disassem_content): Add GDBARCH parameter.
(tui_show_disassem): Likewise.
(tui_show_disassem_and_update_source): Likewise.
(tui_get_begin_asm_address): Return architecture and PC value.
* tui/tui.h (tui_get_low_disassembly_address): Add GDBARCH parameter.
(tui_show_assembly): Add GDBARCH parameter.
* tui/tui-layout.c (extract_display_start_addr): Return current window
architecture in addition to current PC value.
(tui_set_layout): Update calls to tui_get_low_disassembly_address and
extract_display_start_addr. Pass architecture to
tui_update_source_windows_with_addr.
* tui/tui-source.c: Include "objfiles.h".
(tui_set_source_content): Initialize window architecture.
(tui_show_symtab_source): Add GDBARCH parameter. Pass to
tui_update_source_window_as_is
* tui/tui-source.h (tui_show_symtab_source): Add GDBARCH parameter.
* tui/tui-stack.c (tui_set_locator_info): Add GDBARCH parameter.
Install locator architecture.
(tui_set_locator_filename): Update call.
(tui_show_frame_info): Pass architecture to tui_set_locator_info
and subroutines.
* tui/tui-win.c (make_visible_with_new_height): Pass architecture
to tui_update_source_window.
* tui/tui-winsource.c: Include "objfiles.h".
(tui_display_main): Update call to tui_get_begin_asm_address.
Pass architecture to tui_update_source_windows_with_addr.
(tui_update_source_window): Add GDBARCH parameter. Pass to
tui_update_source_window_as_is.
(tui_update_source_window_as_is): Add GDBARCH parameter.
Pass to tui_set_disassem_content.
(tui_update_source_windows_with_addr): Add GDBARCH parameter.
Pass to subroutines.
(tui_update_source_windows_with_line): Pass objfile architecture
to subroutines.
(tui_horizontal_source_scroll): Pass architecture to
tui_update_source_window_as_is.
* tui/tui-winsource.h (tui_update_source_window): Add GDBARCH
parameter.
(tui_update_source_window_as_is): Likewise.
(tui_update_source_windows_with_addr): Likewise.
+2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * disasm.h (gdb_disassembly): Add GDBARCH parameter.
+ (gdb_print_insn): Likewise.
+ * disasm.c (dump_insns): Add GDBARCH parameter. Use it instead
+ of current_gdbarch.
+ (do_mixed_source_and_assembly): Add GDBARCH parameter. Pass to
+ dump_insns.
+ (do_assembly_only): Likewise.
+ (gdb_disassembly): Add GDBARCH parameter. Use it instead of
+ current_gdbarch. Pass to subroutines.
+ (gdb_print_insn): Add GDBARCH parameter. Use it instead of
+ current_gdbarch.
+
+ * stack.c (struct gdb_disassembly_stub_args): Add GDBARCH member.
+ (gdb_disassembly_stub): Pass architecture to gdb_disassembly.
+ (do_gdb_disassembly): Add GDBARCH argument. Store into args.
+ (print_frame_info): Pass architecture to do_gdb_disassembly.
+
+ * printcmd.c (print_formatted): Pass architecture to gdb_print_insn.
+
+ * mi/mi-cmd-disas.c: Include "arch-utils.h"
+ (mi_cmd_disassemble): Pass architecture to gdb_disassembly.
+
+ * cli/cli-cmds.c: Include "arch-utils.h".
+ (print_disassembly): Add GDBARCH parameter. Pass to gdb_disassembly
+ and tui_show_assembly.
+ (disassemble_current_function): Pass architecture to
+ tui_get_low_disassembly_address and print_disassembly.
+ (disassemble_command): Pass architecture to
+ tui_get_low_disassembly_address and print_disassembly.
+
+ * tui/tui.c (tui_show_assembly): Add GDBARCH parameter. Pass to
+ tui_update_source_windows_with_addr.
+
+ * tui/tui-data.h (struct tui_locator_element): Add GDBARCH member.
+ (struct tui_source_info): Likewise.
+ * tui/tui-data.c (tui_clear_win_detail): Clear source_info.gdbarch.
+
+ * tui/tui-disasm.c (tui_disassemble): Add GDBARCH parameter.
+ Pass to gdb_print_insn.
+ (tui_find_disassembly_address): Add GDBARCH parameter. Pass to
+ tui_disassemble.
+ (tui_set_disassem_content): Add GDBARCH parameter. Install into
+ source_info.gdbarch. Pass to tui_disassemble.
+ (tui_show_disassem): Add GDBARCH parameter. Pass to
+ tui_update_source_window.
+ (tui_show_disassem_and_update_source): Add GDBARCH parameter. Pass to
+ tui_show_disassem and tui_update_source_window.
+
+ (tui_get_begin_asm_address): Return locator architecture in addition
+ to locator PC value.
+
+ (tui_get_low_disassembly_address): Add GDBARCH parameter. Pass to
+ tui_get_low_disassembly_address.
+
+ (tui_vertical_disassem_scroll): Pass architecture to subroutines.
+
+ * tui/tui-disasm.h (tui_set_disassem_content): Add GDBARCH parameter.
+ (tui_show_disassem): Likewise.
+ (tui_show_disassem_and_update_source): Likewise.
+ (tui_get_begin_asm_address): Return architecture and PC value.
+
+ * tui/tui.h (tui_get_low_disassembly_address): Add GDBARCH parameter.
+ (tui_show_assembly): Add GDBARCH parameter.
+
+ * tui/tui-layout.c (extract_display_start_addr): Return current window
+ architecture in addition to current PC value.
+
+ (tui_set_layout): Update calls to tui_get_low_disassembly_address and
+ extract_display_start_addr. Pass architecture to
+ tui_update_source_windows_with_addr.
+
+ * tui/tui-source.c: Include "objfiles.h".
+ (tui_set_source_content): Initialize window architecture.
+ (tui_show_symtab_source): Add GDBARCH parameter. Pass to
+ tui_update_source_window_as_is
+
+ * tui/tui-source.h (tui_show_symtab_source): Add GDBARCH parameter.
+
+ * tui/tui-stack.c (tui_set_locator_info): Add GDBARCH parameter.
+ Install locator architecture.
+ (tui_set_locator_filename): Update call.
+ (tui_show_frame_info): Pass architecture to tui_set_locator_info
+ and subroutines.
+
+ * tui/tui-win.c (make_visible_with_new_height): Pass architecture
+ to tui_update_source_window.
+
+ * tui/tui-winsource.c: Include "objfiles.h".
+ (tui_display_main): Update call to tui_get_begin_asm_address.
+ Pass architecture to tui_update_source_windows_with_addr.
+ (tui_update_source_window): Add GDBARCH parameter. Pass to
+ tui_update_source_window_as_is.
+ (tui_update_source_window_as_is): Add GDBARCH parameter.
+ Pass to tui_set_disassem_content.
+ (tui_update_source_windows_with_addr): Add GDBARCH parameter.
+ Pass to subroutines.
+ (tui_update_source_windows_with_line): Pass objfile architecture
+ to subroutines.
+ (tui_horizontal_source_scroll): Pass architecture to
+ tui_update_source_window_as_is.
+
+ * tui/tui-winsource.h (tui_update_source_window): Add GDBARCH
+ parameter.
+ (tui_update_source_window_as_is): Likewise.
+ (tui_update_source_windows_with_addr): Likewise.
+
2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
* breakpoint.h (struct breakpoint): New member GDBARCH.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "arch-utils.h"
#include "readline/readline.h"
#include "readline/tilde.h"
#include "completer.h"
MIXED is non-zero to print source with the assembler. */
static void
-print_disassembly (const char *name, CORE_ADDR low, CORE_ADDR high, int mixed)
+print_disassembly (struct gdbarch *gdbarch, const char *name,
+ CORE_ADDR low, CORE_ADDR high, int mixed)
{
#if defined(TUI)
if (!tui_is_window_visible (DISASSEM_WIN))
printf_filtered ("from %s to %s:\n", paddress (low), paddress (high));
/* Dump the specified range. */
- gdb_disassembly (uiout, 0, mixed, -1, low, high);
+ gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high);
printf_filtered ("End of assembler dump.\n");
gdb_flush (gdb_stdout);
#if defined(TUI)
else
{
- tui_show_assembly (low);
+ tui_show_assembly (gdbarch, low);
}
#endif
}
static void
disassemble_current_function (int mixed)
{
+ struct frame_info *frame;
+ struct gdbarch *gdbarch;
CORE_ADDR low, high, pc;
char *name;
- pc = get_frame_pc (get_selected_frame (_("No frame selected.")));
+ frame = get_selected_frame (_("No frame selected."));
+ gdbarch = get_frame_arch (frame);
+ pc = get_frame_pc (frame);
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
error (_("No function contains program counter for selected frame."));
#if defined(TUI)
`tui_version'. */
if (tui_active)
/* FIXME: cagney/2004-02-07: This should be an observer. */
- low = tui_get_low_disassembly_address (low, pc);
+ low = tui_get_low_disassembly_address (gdbarch, low, pc);
#endif
- low += gdbarch_deprecated_function_start_offset (current_gdbarch);
+ low += gdbarch_deprecated_function_start_offset (gdbarch);
- print_disassembly (name, low, high, mixed);
+ print_disassembly (gdbarch, name, low, high, mixed);
}
/* Dump a specified section of assembly code.
static void
disassemble_command (char *arg, int from_tty)
{
+ struct gdbarch *gdbarch = get_current_arch ();
CORE_ADDR low, high;
char *name;
CORE_ADDR pc, pc_masked;
`tui_version'. */
if (tui_active)
/* FIXME: cagney/2004-02-07: This should be an observer. */
- low = tui_get_low_disassembly_address (low, pc);
+ low = tui_get_low_disassembly_address (gdbarch, low, pc);
#endif
- low += gdbarch_deprecated_function_start_offset (current_gdbarch);
+ low += gdbarch_deprecated_function_start_offset (gdbarch);
}
else
{
high = parse_and_eval_address (space_index + 1);
}
- print_disassembly (name, low, high, mixed_source_and_assembly);
+ print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly);
}
static void
}
static int
-dump_insns (struct ui_out *uiout, struct disassemble_info * di,
+dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
+ struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
int how_many, struct ui_stream *stb)
{
xfree (name);
ui_file_rewind (stb->stream);
- pc += gdbarch_print_insn (current_gdbarch, pc, di);
+ pc += gdbarch_print_insn (gdbarch, pc, di);
ui_out_field_stream (uiout, "inst", stb);
ui_file_rewind (stb->stream);
do_cleanups (ui_out_chain);
in source order, with (possibly) out of order assembly
immediately following. */
static void
-do_mixed_source_and_assembly (struct ui_out *uiout,
+do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info *di, int nlines,
struct linetable_entry *le,
CORE_ADDR low, CORE_ADDR high,
= make_cleanup_ui_out_list_begin_end (uiout, "line_asm_insn");
}
- num_displayed += dump_insns (uiout, di, mle[i].start_pc, mle[i].end_pc,
+ num_displayed += dump_insns (gdbarch, uiout, di,
+ mle[i].start_pc, mle[i].end_pc,
how_many, stb);
/* When we've reached the end of the mle array, or we've seen the last
static void
-do_assembly_only (struct ui_out *uiout, struct disassemble_info * di,
+do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
+ struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
int how_many, struct ui_stream *stb)
{
ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns");
- num_displayed = dump_insns (uiout, di, low, high, how_many, stb);
+ num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb);
do_cleanups (ui_out_chain);
}
}
void
-gdb_disassembly (struct ui_out *uiout,
+gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string,
int mixed_source_and_assembly,
int how_many, CORE_ADDR low, CORE_ADDR high)
{
struct ui_stream *stb = ui_out_stream_new (uiout);
struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb);
- struct disassemble_info di = gdb_disassemble_info (current_gdbarch, stb->stream);
+ struct disassemble_info di = gdb_disassemble_info (gdbarch, stb->stream);
/* To collect the instruction outputted from opcodes. */
struct symtab *symtab = NULL;
struct linetable_entry *le = NULL;
if (!mixed_source_and_assembly || nlines <= 0
|| symtab == NULL || symtab->linetable == NULL)
- do_assembly_only (uiout, &di, low, high, how_many, stb);
+ do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb);
else if (mixed_source_and_assembly)
- do_mixed_source_and_assembly (uiout, &di, nlines, le, low,
+ do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low,
high, symtab, how_many, stb);
do_cleanups (cleanups);
and, if requested, the number of branch delay slot instructions. */
int
-gdb_print_insn (CORE_ADDR memaddr, struct ui_file *stream,
- int *branch_delay_insns)
+gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
+ struct ui_file *stream, int *branch_delay_insns)
{
struct disassemble_info di;
int length;
- di = gdb_disassemble_info (current_gdbarch, stream);
- length = gdbarch_print_insn (current_gdbarch, memaddr, &di);
+ di = gdb_disassemble_info (gdbarch, stream);
+ length = gdbarch_print_insn (gdbarch, memaddr, &di);
if (branch_delay_insns)
{
if (di.insn_info_valid)
struct ui_out;
struct ui_file;
-extern void gdb_disassembly (struct ui_out *uiout,
+extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string,
int mixed_source_and_assembly,
int how_many, CORE_ADDR low, CORE_ADDR high);
on STREAM. Returns the length of the instruction, in bytes,
and, if requested, the number of branch delay slot instructions. */
-extern int gdb_print_insn (CORE_ADDR memaddr,
- struct ui_file *stream,
- int *branch_delay_insns);
+extern int gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
+ struct ui_file *stream, int *branch_delay_insns);
#endif
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "arch-utils.h"
#include "target.h"
#include "value.h"
#include "mi-cmds.h"
void
mi_cmd_disassemble (char *command, char **argv, int argc)
{
+ struct gdbarch *gdbarch = get_current_arch ();
CORE_ADDR start;
int mixed_source_and_assembly;
error (_("mi_cmd_disassemble: No function contains specified address"));
}
- gdb_disassembly (uiout,
+ gdb_disassembly (gdbarch, uiout,
file_string,
mixed_source_and_assembly, how_many, low, high);
/* We often wrap here if there are long symbolic names. */
wrap_here (" ");
next_address = (value_address (val)
- + gdb_print_insn (value_address (val), stream,
+ + gdb_print_insn (get_type_arch (type),
+ value_address (val), stream,
&branch_delay_insns));
return;
}
struct gdb_disassembly_stub_args
{
+ struct gdbarch *gdbarch;
int how_many;
CORE_ADDR low;
CORE_ADDR high;
gdb_disassembly_stub (void *args)
{
struct gdb_disassembly_stub_args *p = args;
- gdb_disassembly (uiout, 0, 0, p->how_many, p->low, p->high);
+ gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high);
}
/* Use TRY_CATCH to catch the exception from the gdb_disassembly
because it will be broken by filter sometime. */
static void
-do_gdb_disassembly (int how_many, CORE_ADDR low, CORE_ADDR high)
+do_gdb_disassembly (struct gdbarch *gdbarch,
+ int how_many, CORE_ADDR low, CORE_ADDR high)
{
volatile struct gdb_exception exception;
struct gdb_disassembly_stub_args args;
+ args.gdbarch = gdbarch;
args.how_many = how_many;
args.low = low;
args.high = high;
if ((disassemble_next_line == AUTO_BOOLEAN_AUTO
|| disassemble_next_line == AUTO_BOOLEAN_TRUE)
&& source_print && !sal.symtab)
- do_gdb_disassembly (1, get_frame_pc (frame), get_frame_pc (frame) + 1);
+ do_gdb_disassembly (get_frame_arch (frame), 1,
+ get_frame_pc (frame), get_frame_pc (frame) + 1);
if (source_print && sal.symtab)
{
/* If disassemble-next-line is set to on and there is line debug
messages, output assembly codes for next line. */
if (disassemble_next_line == AUTO_BOOLEAN_TRUE)
- do_gdb_disassembly (-1, get_frame_pc (frame), sal.end);
+ do_gdb_disassembly (get_frame_arch (frame), -1,
+ get_frame_pc (frame), sal.end);
}
if (print_what != LOCATION)
{
case SRC_WIN:
case DISASSEM_WIN:
+ win_info->detail.source_info.gdbarch = NULL;
win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
win_info->detail.source_info.start_line_or_addr.u.addr = 0;
win_info->detail.source_info.horizontal_offset = 0;
win_info->detail.source_info.execution_info = (struct tui_gen_win_info *) NULL;
win_info->detail.source_info.has_locator = FALSE;
win_info->detail.source_info.horizontal_offset = 0;
+ win_info->detail.source_info.gdbarch = NULL;
win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
win_info->detail.source_info.start_line_or_addr.u.addr = 0;
win_info->detail.source_info.filename = 0;
char proc_name[MAX_LOCATOR_ELEMENT_LEN];
int line_no;
CORE_ADDR addr;
+ /* Architecture associated with code at this location. */
+ struct gdbarch *gdbarch;
};
/* Flags to tell what kind of breakpoint is at current line. */
int horizontal_offset; /* Used for horizontal scroll. */
struct tui_line_or_address start_line_or_addr;
char *filename;
+ /* Architecture associated with code at this location. */
+ struct gdbarch *gdbarch;
};
Disassemble count lines starting at pc.
Return address of the count'th instruction after pc. */
static CORE_ADDR
-tui_disassemble (struct tui_asm_line *asm_lines,
+tui_disassemble (struct gdbarch *gdbarch, struct tui_asm_line *asm_lines,
CORE_ADDR pc, int count)
{
struct ui_file *gdb_dis_out;
ui_file_rewind (gdb_dis_out);
- pc = pc + gdb_print_insn (pc, gdb_dis_out, NULL);
+ pc = pc + gdb_print_insn (gdbarch, pc, gdb_dis_out, NULL);
asm_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
or below the PC. Variable sized instructions are taken into
account by the algorithm. */
static CORE_ADDR
-tui_find_disassembly_address (CORE_ADDR pc, int from)
+tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
{
CORE_ADDR new_low;
int max_lines;
new_low = pc;
if (from > 0)
{
- tui_disassemble (asm_lines, pc, max_lines);
+ tui_disassemble (gdbarch, asm_lines, pc, max_lines);
new_low = asm_lines[max_lines - 1].addr;
}
else
else
new_low += 1 * max_lines;
- tui_disassemble (asm_lines, new_low, max_lines);
+ tui_disassemble (gdbarch, asm_lines, new_low, max_lines);
last_addr = asm_lines[pos].addr;
} while (last_addr > pc && msymbol);
if (pos >= max_lines)
pos = 0;
- next_addr = tui_disassemble (&asm_lines[pos], last_addr, 1);
+ next_addr = tui_disassemble (gdbarch, &asm_lines[pos],
+ last_addr, 1);
/* If there are some problems while disassembling exit. */
if (next_addr <= last_addr)
/* Function to set the disassembly window's content. */
enum tui_status
-tui_set_disassem_content (CORE_ADDR pc)
+tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum tui_status ret = TUI_FAILURE;
int i;
if (ret != TUI_SUCCESS)
return ret;
+ TUI_DISASM_WIN->detail.source_info.gdbarch = gdbarch;
TUI_DISASM_WIN->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr = pc;
cur_pc = (CORE_ADDR)
line_width = TUI_DISASM_WIN->generic.width - 1;
- tui_disassemble (asm_lines, pc, max_lines);
+ tui_disassemble (gdbarch, asm_lines, pc, max_lines);
/* See what is the maximum length of an address and of a line. */
addr_size = 0;
/* Function to display the disassembly window with disassembled code. */
void
-tui_show_disassem (CORE_ADDR start_addr)
+tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
{
struct symtab *s = find_pc_symtab (start_addr);
struct tui_win_info *win_with_focus = tui_win_with_focus ();
val.loa = LOA_ADDRESS;
val.u.addr = start_addr;
tui_add_win_to_layout (DISASSEM_WIN);
- tui_update_source_window (TUI_DISASM_WIN, s, val, FALSE);
+ tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val, FALSE);
/* If the focus was in the src win, put it in the asm win, if the
source view isn't split. */
/* Function to display the disassembly window. */
void
-tui_show_disassem_and_update_source (CORE_ADDR start_addr)
+tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
+ CORE_ADDR start_addr)
{
struct symtab_and_line sal;
- tui_show_disassem (start_addr);
+ tui_show_disassem (gdbarch, start_addr);
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
{
struct tui_line_or_address val;
sal = find_pc_line (start_addr, 0);
val.loa = LOA_LINE;
val.u.line_no = sal.line;
- tui_update_source_window (TUI_SRC_WIN, sal.symtab, val, TRUE);
+ tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val, TRUE);
if (sal.symtab)
{
set_current_source_symtab_and_line (&sal);
return;
}
-CORE_ADDR
-tui_get_begin_asm_address (void)
+void
+tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
struct tui_gen_win_info *locator;
struct tui_locator_element *element;
+ struct gdbarch *gdbarch = NULL;
CORE_ADDR addr;
locator = tui_locator_win_info_ptr ();
addr = 0;
}
else /* The target is executing. */
- addr = element->addr;
+ {
+ gdbarch = element->gdbarch;
+ addr = element->addr;
+ }
- return addr;
+ *gdbarch_p = gdbarch;
+ *addr_p = addr;
}
/* Determine what the low address will be to display in the TUI's
disassembly window. This may or may not be the same as the low
address input. */
CORE_ADDR
-tui_get_low_disassembly_address (CORE_ADDR low,
- CORE_ADDR pc)
+tui_get_low_disassembly_address (struct gdbarch *gdbarch,
+ CORE_ADDR low, CORE_ADDR pc)
{
int pos;
/* Determine where to start the disassembly so that the pc is about
in the middle of the viewport. */
pos = tui_default_win_viewport_height (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
- pc = tui_find_disassembly_address (pc, -pos);
+ pc = tui_find_disassembly_address (gdbarch, pc, -pos);
if (pc < low)
pc = low;
{
if (TUI_DISASM_WIN->generic.content != NULL)
{
+ struct gdbarch *gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
CORE_ADDR pc;
tui_win_content content;
struct tui_line_or_address val;
dir = (scroll_direction == FORWARD_SCROLL) ? num_to_scroll : -num_to_scroll;
val.loa = LOA_ADDRESS;
- val.u.addr = tui_find_disassembly_address (pc, dir);
- tui_update_source_window_as_is (TUI_DISASM_WIN, NULL, val, FALSE);
+ val.u.addr = tui_find_disassembly_address (gdbarch, pc, dir);
+ tui_update_source_window_as_is (TUI_DISASM_WIN, gdbarch, NULL, val, FALSE);
}
}
#include "tui/tui.h" /* For enum tui_status. */
#include "tui/tui-data.h" /* For enum tui_scroll_direction. */
-extern enum tui_status tui_set_disassem_content (CORE_ADDR);
-extern void tui_show_disassem (CORE_ADDR);
-extern void tui_show_disassem_and_update_source (CORE_ADDR);
+extern enum tui_status tui_set_disassem_content (struct gdbarch *, CORE_ADDR);
+extern void tui_show_disassem (struct gdbarch *, CORE_ADDR);
+extern void tui_show_disassem_and_update_source (struct gdbarch *, CORE_ADDR);
extern void tui_vertical_disassem_scroll (enum tui_scroll_direction,
int);
-extern CORE_ADDR tui_get_begin_asm_address (void);
+extern void tui_get_begin_asm_address (struct gdbarch **, CORE_ADDR *);
#endif
static void tui_layout_command (char *, int);
static void tui_toggle_layout_command (char *, int);
static void tui_toggle_split_layout_command (char *, int);
-static CORE_ADDR extract_display_start_addr (void);
+static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
static void tui_handle_xdb_layout (struct tui_layout_def *);
enum tui_layout_type cur_layout = tui_current_layout (),
new_layout = UNDEFINED_LAYOUT;
int regs_populate = FALSE;
- CORE_ADDR addr = extract_display_start_addr ();
+ struct gdbarch *gdbarch;
+ CORE_ADDR addr;
struct tui_win_info *win_with_focus = tui_win_with_focus ();
struct tui_layout_def *layout_def = tui_layout_def ();
+ extract_display_start_addr (&gdbarch, &addr);
if (layout_type == UNDEFINED_LAYOUT
&& regs_display_type != TUI_UNDEFINED_REGS)
2. if target was compiled without -g
We still want to show the assembly though! */
- addr = tui_get_begin_asm_address ();
+ tui_get_begin_asm_address (&gdbarch, &addr);
tui_set_win_focus_to (TUI_DISASM_WIN);
layout_def->display_mode = DISASSEM_WIN;
layout_def->split = FALSE;
2. if target was compiled without -g
We still want to show the assembly though! */
- addr = tui_get_begin_asm_address ();
+ tui_get_begin_asm_address (&gdbarch, &addr);
if (win_with_focus == TUI_SRC_WIN)
tui_set_win_focus_to (TUI_SRC_WIN);
else
2. if target was compiled without -g
We still want to show the assembly though! */
- addr = tui_get_begin_asm_address ();
+ tui_get_begin_asm_address (&gdbarch, &addr);
if (win_with_focus != TUI_DATA_WIN)
tui_set_win_focus_to (TUI_DISASM_WIN);
else
|| new_layout == DISASSEM_DATA_COMMAND))
tui_display_all_data ();
- tui_update_source_windows_with_addr (addr);
+ tui_update_source_windows_with_addr (gdbarch, addr);
}
if (regs_populate)
{
}
-static CORE_ADDR
-extract_display_start_addr (void)
+static void
+extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
enum tui_layout_type cur_layout = tui_current_layout ();
+ struct gdbarch *gdbarch = NULL;
CORE_ADDR addr;
CORE_ADDR pc;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
{
case SRC_COMMAND:
case SRC_DATA_COMMAND:
+ gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
find_line_pc (cursal.symtab,
TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
&pc);
case DISASSEM_COMMAND:
case SRC_DISASSEM_COMMAND:
case DISASSEM_DATA_COMMAND:
+ gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
break;
default:
break;
}
- return addr;
+ *gdbarch_p = gdbarch;
+ *addr_p = addr;
}
#include "breakpoint.h"
#include "source.h"
#include "symtab.h"
+#include "objfiles.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
stream = fdopen (desc, FOPEN_RT);
clearerr (stream);
cur_line = 0;
+ src->gdbarch = get_objfile_arch (s->objfile);
src->start_line_or_addr.loa = LOA_LINE;
cur_line_no = src->start_line_or_addr.u.line_no = line_no;
if (offset > 0)
/* Function to display source in the source window. This function
initializes the horizontal scroll to 0. */
void
-tui_show_symtab_source (struct symtab *s,
+tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s,
struct tui_line_or_address line,
int noerror)
{
TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
- tui_update_source_window_as_is (TUI_SRC_WIN, s, line, noerror);
+ tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
}
extern enum tui_status tui_set_source_content (struct symtab *,
int, int);
-extern void tui_show_symtab_source (struct symtab *,
+extern void tui_show_symtab_source (struct gdbarch *, struct symtab *,
struct tui_line_or_address,
int);
extern int tui_source_is_displayed (char *);
static void tui_set_locator_filename (const char *filename);
/* Update the locator, with the provided arguments. */
-static void tui_set_locator_info (const char *filename,
+static void tui_set_locator_info (struct gdbarch *gdbarch,
+ const char *filename,
const char *procname,
int lineno, CORE_ADDR addr);
if (locator->content[0] == NULL)
{
- tui_set_locator_info (filename, NULL, 0, 0);
+ tui_set_locator_info (NULL, filename, NULL, 0, 0);
return;
}
/* Update the locator, with the provided arguments. */
static void
-tui_set_locator_info (const char *filename,
+tui_set_locator_info (struct gdbarch *gdbarch,
+ const char *filename,
const char *procname,
int lineno,
CORE_ADDR addr)
strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
element->line_no = lineno;
element->addr = addr;
+ element->gdbarch = gdbarch;
tui_set_locator_filename (filename);
}
source_already_displayed = sal.symtab != 0
&& tui_source_is_displayed (sal.symtab->filename);
- tui_set_locator_info (sal.symtab == 0 ? "??" : sal.symtab->filename,
+ tui_set_locator_info (get_frame_arch (fi),
+ sal.symtab == 0 ? "??" : sal.symtab->filename,
tui_get_function_from_frame (fi),
sal.line,
get_frame_pc (fi));
&low, (CORE_ADDR) 0) == 0)
error (_("No function contains program counter for selected frame."));
else
- low = tui_get_low_disassembly_address (low, get_frame_pc (fi));
+ low = tui_get_low_disassembly_address (get_frame_arch (fi),
+ low, get_frame_pc (fi));
}
if (win_info == TUI_SRC_WIN)
l.u.line_no = start_line;
if (!(source_already_displayed
&& tui_line_is_displayed (item->locator.line_no, win_info, TRUE)))
- tui_update_source_window (win_info, sal.symtab, l, TRUE);
+ tui_update_source_window (win_info, get_frame_arch (fi),
+ sal.symtab, l, TRUE);
else
{
l.u.line_no = item->locator.line_no;
a.loa = LOA_ADDRESS;
a.u.addr = low;
if (!tui_addr_is_displayed (item->locator.addr, win_info, TRUE))
- tui_update_source_window (win_info, sal.symtab, a, TRUE);
+ tui_update_source_window (win_info, get_frame_arch (fi),
+ sal.symtab, a, TRUE);
else
{
a.u.addr = item->locator.addr;
}
else
{
- tui_set_locator_info (NULL, NULL, 0, (CORE_ADDR) 0);
+ tui_set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0);
tui_show_locator_content ();
for (i = 0; i < (tui_source_windows ())->count; i++)
{
tui_make_visible (win_info->detail.source_info.execution_info);
if (win_info->generic.content != NULL)
{
+ struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch;
struct tui_line_or_address line_or_addr;
struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
line_or_addr = win_info->detail.source_info.start_line_or_addr;
tui_free_win_content (&win_info->generic);
- tui_update_source_window (win_info, cursal.symtab, line_or_addr, TRUE);
+ tui_update_source_window (win_info, gdbarch,
+ cursal.symtab, line_or_addr, TRUE);
}
else if (deprecated_safe_get_selected_frame () != NULL)
{
struct tui_line_or_address line;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
struct frame_info *frame = deprecated_safe_get_selected_frame ();
+ struct gdbarch *gdbarch = get_frame_arch (frame);
s = find_pc_symtab (get_frame_pc (frame));
if (win_info->generic.type == SRC_WIN)
line.loa = LOA_ADDRESS;
find_line_pc (s, cursal.line, &line.u.addr);
}
- tui_update_source_window (win_info, s, line, TRUE);
+ tui_update_source_window (win_info, gdbarch, s, line, TRUE);
}
if (tui_win_has_locator (win_info))
{
#include "breakpoint.h"
#include "value.h"
#include "source.h"
+#include "objfiles.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
{
if ((tui_source_windows ())->count > 0)
{
+ struct gdbarch *gdbarch;
CORE_ADDR addr;
- addr = tui_get_begin_asm_address ();
+ tui_get_begin_asm_address (&gdbarch, &addr);
if (addr != (CORE_ADDR) 0)
{
struct symtab_and_line sal;
- tui_update_source_windows_with_addr (addr);
+ tui_update_source_windows_with_addr (gdbarch, addr);
sal = find_pc_line (addr, 0);
if (sal.symtab)
tui_update_locator_filename (sal.symtab->filename);
initializes the horizontal scroll to 0. */
void
tui_update_source_window (struct tui_win_info *win_info,
+ struct gdbarch *gdbarch,
struct symtab *s,
struct tui_line_or_address line_or_addr,
int noerror)
{
win_info->detail.source_info.horizontal_offset = 0;
- tui_update_source_window_as_is (win_info, s, line_or_addr, noerror);
+ tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
return;
}
shows the source as specified by the horizontal offset. */
void
tui_update_source_window_as_is (struct tui_win_info *win_info,
+ struct gdbarch *gdbarch,
struct symtab *s,
struct tui_line_or_address line_or_addr,
int noerror)
if (win_info->generic.type == SRC_WIN)
ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror);
else
- ret = tui_set_disassem_content (line_or_addr.u.addr);
+ ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr);
if (ret == TUI_FAILURE)
{
/* Function to ensure that the source and/or disassemly windows
reflect the input address. */
void
-tui_update_source_windows_with_addr (CORE_ADDR addr)
+tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
{
if (addr != 0)
{
{
case DISASSEM_COMMAND:
case DISASSEM_DATA_COMMAND:
- tui_show_disassem (addr);
+ tui_show_disassem (gdbarch, addr);
break;
case SRC_DISASSEM_COMMAND:
- tui_show_disassem_and_update_source (addr);
+ tui_show_disassem_and_update_source (gdbarch, addr);
break;
default:
sal = find_pc_line (addr, 0);
l.loa = LOA_LINE;
l.u.line_no = sal.line;
- tui_show_symtab_source (sal.symtab, l, FALSE);
+ tui_show_symtab_source (gdbarch, sal.symtab, l, FALSE);
break;
}
}
void
tui_update_source_windows_with_line (struct symtab *s, int line)
{
+ struct gdbarch *gdbarch;
CORE_ADDR pc;
struct tui_line_or_address l;
-
+
+ if (!s)
+ return;
+
+ gdbarch = get_objfile_arch (s->objfile);
+
switch (tui_current_layout ())
{
case DISASSEM_COMMAND:
case DISASSEM_DATA_COMMAND:
find_line_pc (s, line, &pc);
- tui_update_source_windows_with_addr (pc);
+ tui_update_source_windows_with_addr (gdbarch, pc);
break;
default:
l.loa = LOA_LINE;
l.u.line_no = line;
- tui_show_symtab_source (s, l, FALSE);
+ tui_show_symtab_source (gdbarch, s, l, FALSE);
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
{
find_line_pc (s, line, &pc);
- tui_show_disassem (pc);
+ tui_show_disassem (gdbarch, pc);
}
break;
}
{
if (win_info->generic.content != NULL)
{
+ struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch;
int offset;
struct symtab *s = NULL;
offset = 0;
}
win_info->detail.source_info.horizontal_offset = offset;
- tui_update_source_window_as_is (win_info, s,
+ tui_update_source_window_as_is (win_info, gdbarch, s,
((struct tui_win_element *)
win_info->generic.content[0])->which_element.source.line_or_addr,
FALSE);
/* Function to display the "main" routine. */
extern void tui_display_main (void);
extern void tui_update_source_window (struct tui_win_info *,
- struct symtab *,
+ struct gdbarch *, struct symtab *,
struct tui_line_or_address,
int);
extern void tui_update_source_window_as_is (struct tui_win_info *,
- struct symtab *,
+ struct gdbarch *, struct symtab *,
struct tui_line_or_address,
int);
-extern void tui_update_source_windows_with_addr (CORE_ADDR);
+extern void tui_update_source_windows_with_addr (struct gdbarch *, CORE_ADDR);
extern void tui_update_source_windows_with_line (struct symtab *,
int);
extern void tui_clear_source_content (struct tui_win_info *, int);
}
void
-tui_show_assembly (CORE_ADDR addr)
+tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr)
{
tui_add_win_to_layout (DISASSEM_WIN);
- tui_update_source_windows_with_addr (addr);
+ tui_update_source_windows_with_addr (gdbarch, addr);
}
int
/* GENERAL TUI FUNCTIONS */
/* tui.c */
-extern CORE_ADDR tui_get_low_disassembly_address (CORE_ADDR,
- CORE_ADDR);
-extern void tui_show_assembly (CORE_ADDR addr);
+extern CORE_ADDR tui_get_low_disassembly_address (struct gdbarch *,
+ CORE_ADDR, CORE_ADDR);
+extern void tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr);
extern int tui_is_window_visible (enum tui_win_type type);
extern int tui_get_command_dimension (unsigned int *width,
unsigned int *height);