From: Andrew Burgess Date: Thu, 6 Feb 2025 12:16:48 +0000 (+0000) Subject: gdb/tui: update maybe_update to take gdbarch X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ea89e2ddb2af33f1778faeeeb8149a2f575fbd3;p=thirdparty%2Fbinutils-gdb.git gdb/tui: update maybe_update to take gdbarch This is a refactor to setup for the next commit. The maybe_update function currently takes a frame_info_ptr&, however, it only uses this to get the frame's gdbarch. In the next commit I want to call maybe_update when I have a gdbarch, but no frame_info_ptr& (the inferior hasn't even started). So, update maybe_update to take the gdbarch, and update the callers to pass that through. Most callers already have the gdbarch to hand, but in one place I do need to extract this from the frame_info_ptr&. There should be no user visible changes after this commit. Approved-By: Tom Tromey --- diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index cd828537a5a..f45c30c109b 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -485,12 +485,10 @@ tui_disasm_window::addr_is_displayed (CORE_ADDR addr) const } void -tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) +tui_disasm_window::maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) { CORE_ADDR low; - struct gdbarch *frame_arch = get_frame_arch (fi); - if (find_pc_partial_function (sal.pc, NULL, &low, NULL) == 0) { /* There is no symbol available for current PC. There is no @@ -498,7 +496,7 @@ tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) low = sal.pc; } else - low = tui_get_low_disassembly_address (frame_arch, low, sal.pc); + low = tui_get_low_disassembly_address (gdbarch, low, sal.pc); struct tui_line_or_address a; @@ -507,7 +505,7 @@ tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) if (!addr_is_displayed (sal.pc)) { sal.pc = low; - update_source_window (frame_arch, sal); + update_source_window (gdbarch, sal); } else { diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h index a49719a0dca..4279bb03406 100644 --- a/gdb/tui/tui-disasm.h +++ b/gdb/tui/tui-disasm.h @@ -42,7 +42,7 @@ struct tui_disasm_window : public tui_source_window_base bool location_matches_p (struct bp_location *loc, int line_no) override; - void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override; + void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) override; void erase_source_content () override { diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 9a0a04142b2..2ef0308bb3c 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -207,7 +207,7 @@ tui_source_window::line_is_displayed (int line) const } void -tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) +tui_source_window::maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) { int start_line = (sal.line - ((height - box_size ()) / 2)) + 1; if (start_line <= 0) @@ -219,7 +219,7 @@ tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) if (!(source_already_displayed && line_is_displayed (sal.line))) { sal.line = start_line; - update_source_window (get_frame_arch (fi), sal); + update_source_window (gdbarch, sal); } else { diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 9cad4ff91b4..10702b22f65 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -46,7 +46,7 @@ struct tui_source_window : public tui_source_window_base bool showing_source_p (const char *filename) const; - void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override; + void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) override; void erase_source_content () override { diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c index d76c2db78e8..fa2d07c9b35 100644 --- a/gdb/tui/tui-status.c +++ b/gdb/tui/tui-status.c @@ -278,8 +278,9 @@ tui_show_frame_info (const frame_info_ptr &fi) else func_name = _(""); + struct gdbarch *gdbarch = get_frame_arch (fi); status_changed_p - = tui_location.set_location (get_frame_arch (fi), sal, func_name); + = tui_location.set_location (gdbarch, sal, func_name); /* If the status information has not changed, then frame information has not changed. If frame information has not changed, then the windows' @@ -289,7 +290,7 @@ tui_show_frame_info (const frame_info_ptr &fi) for (struct tui_source_window_base *win_info : tui_source_windows ()) { - win_info->maybe_update (fi, sal); + win_info->maybe_update (gdbarch, sal); win_info->update_exec_info (); } } diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 2883ec9cf9f..deae786aea2 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -160,7 +160,7 @@ public: /* Update the window to display the given location. Does nothing if the location is already displayed. */ - virtual void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) = 0; + virtual void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) = 0; void update_source_window_as_is (struct gdbarch *gdbarch, const struct symtab_and_line &sal);