]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | /* Copyright (C) 2021-2023 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 | #ifndef TUI_TUI_LOCATION_H | |
19 | #define TUI_TUI_LOCATION_H | |
20 | ||
21 | #include "tui/tui.h" | |
22 | #include "tui/tui.h" | |
23 | #include "gdb_curses.h" /* For WINDOW. */ | |
24 | #include "observable.h" | |
25 | ||
26 | /* Class used to track the current location that the TUI is displaying. An | |
27 | instance of this class will be created; as events occur within GDB the | |
28 | location information within this instance will be updated. As windows | |
29 | like the status window, source window, or disassembler window need to | |
30 | update themselves, they will ask this instance which location they | |
31 | should be displaying. */ | |
32 | ||
33 | struct tui_location_tracker | |
34 | { | |
35 | /* Update the current location with the provided arguments. Returns true | |
36 | if any of the locator's fields were actually changed, and false | |
37 | otherwise. */ | |
38 | bool set_location (struct gdbarch *gdbarch, | |
39 | const struct symtab_and_line &sal, | |
40 | const char *procname); | |
41 | ||
42 | /* Update the current location with the with the provided argument. | |
43 | Return true if any of the fields actually changed, otherwise false. */ | |
44 | bool set_location (struct symtab *symtab); | |
45 | ||
46 | /* Return the address of the current location. */ | |
47 | CORE_ADDR addr () const | |
48 | { return m_addr; } | |
49 | ||
50 | /* Return the architecture for the current location. */ | |
51 | struct gdbarch *gdbarch () const | |
52 | { return m_gdbarch; } | |
53 | ||
54 | /* Return the full name of the file containing the current location. */ | |
55 | const std::string &full_name () const | |
56 | { return m_full_name; } | |
57 | ||
58 | /* Return the name of the function containing the current location. */ | |
59 | const std::string &proc_name () const | |
60 | { return m_proc_name; } | |
61 | ||
62 | /* Return the line number for the current location. */ | |
63 | int line_no () const | |
64 | { return m_line_no; } | |
65 | ||
66 | private: | |
67 | ||
68 | /* Update M_FULL_NAME from SYMTAB. Return true if M_FULL_NAME actually | |
69 | changed, otherwise, return false. */ | |
70 | bool set_fullname (struct symtab *symtab); | |
71 | ||
72 | /* The full name for the file containing the current location. */ | |
73 | std::string m_full_name; | |
74 | ||
75 | /* The name of the function we're currently within. */ | |
76 | std::string m_proc_name; | |
77 | ||
78 | /* The line number for the current location. */ | |
79 | int m_line_no = 0; | |
80 | ||
81 | /* The address of the current location. */ | |
82 | CORE_ADDR m_addr = 0; | |
83 | ||
84 | /* Architecture associated with code at this location. */ | |
85 | struct gdbarch *m_gdbarch = nullptr; | |
86 | }; | |
87 | ||
88 | /* The single global instance of the location tracking class. Tracks the | |
89 | current location that the TUI windows are displaying. */ | |
90 | ||
91 | extern tui_location_tracker tui_location; | |
92 | ||
93 | #endif /* TUI_TUI_LOCATION_H */ |