Commit | Line | Data |
---|---|---|
88b9d363 | 1 | /* Copyright (C) 2021-2022 Free Software Foundation, Inc. |
f237f998 AB |
2 | |
3 | This file is part of GDB. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | #include "defs.h" | |
19 | #include "tui/tui.h" | |
20 | #include "tui/tui-stack.h" | |
21 | #include "tui/tui-data.h" | |
22 | #include "tui/tui-location.h" | |
23 | #include "symtab.h" | |
24 | #include "source.h" | |
25 | ||
26 | /* See tui/tui-location.h. */ | |
27 | ||
28 | tui_location_tracker tui_location; | |
29 | ||
30 | /* See tui/tui-location.h. */ | |
31 | ||
32 | bool | |
33 | tui_location_tracker::set_location (struct gdbarch *gdbarch, | |
34 | const struct symtab_and_line &sal, | |
35 | const char *procname) | |
36 | { | |
37 | gdb_assert (procname != nullptr); | |
38 | ||
39 | bool location_changed_p = set_fullname (sal.symtab); | |
40 | location_changed_p |= procname != m_proc_name; | |
41 | location_changed_p |= sal.line != m_line_no; | |
42 | location_changed_p |= sal.pc != m_addr; | |
43 | location_changed_p |= gdbarch != m_gdbarch; | |
44 | ||
45 | m_proc_name = procname; | |
46 | m_line_no = sal.line; | |
47 | m_addr = sal.pc; | |
48 | m_gdbarch = gdbarch; | |
49 | ||
50 | if (location_changed_p) | |
51 | tui_show_locator_content (); | |
52 | ||
53 | return location_changed_p; | |
54 | } | |
55 | ||
56 | /* See tui/tui-location.h. */ | |
57 | ||
58 | bool | |
59 | tui_location_tracker::set_location (struct symtab *symtab) | |
60 | { | |
61 | bool location_changed_p = set_fullname (symtab); | |
62 | ||
63 | if (location_changed_p) | |
64 | tui_show_locator_content (); | |
65 | ||
66 | return location_changed_p; | |
67 | } | |
68 | ||
69 | /* See tui/tui-location.h. */ | |
70 | ||
71 | bool | |
72 | tui_location_tracker::set_fullname (struct symtab *symtab) | |
73 | { | |
74 | const char *fullname = (symtab == nullptr | |
75 | ? "??" | |
76 | : symtab_to_fullname (symtab)); | |
77 | bool location_changed_p = fullname != m_full_name; | |
78 | m_full_name = std::string (fullname); | |
79 | ||
80 | return location_changed_p; | |
81 | } |