Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI display source/assembly window. |
f33c6cbf | 2 | |
65f05602 AC |
3 | Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software |
4 | Foundation, Inc. | |
f33c6cbf | 5 | |
f377b406 SC |
6 | Contributed by Hewlett-Packard Company. |
7 | ||
8 | This file is part of GDB. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 2 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
24 | |
25 | #include "defs.h" | |
26 | #include <ctype.h> | |
27 | #include "symtab.h" | |
28 | #include "frame.h" | |
29 | #include "breakpoint.h" | |
fd0407d6 | 30 | #include "value.h" |
52575520 | 31 | #include "source.h" |
c906108c | 32 | |
d7b2e967 AC |
33 | #include "tui/tui.h" |
34 | #include "tui/tui-data.h" | |
35 | #include "tui/tui-stack.h" | |
36 | #include "tui/tui-win.h" | |
37 | #include "tui/tui-wingeneral.h" | |
38 | #include "tui/tui-winsource.h" | |
39 | #include "tui/tui-source.h" | |
40 | #include "tui/tui-disasm.h" | |
c906108c | 41 | |
88289b6e | 42 | #include "gdb_string.h" |
6a83354a | 43 | #include "gdb_curses.h" |
c906108c | 44 | |
1f393769 | 45 | /* Function to display the "main" routine. */ |
c906108c | 46 | void |
1f393769 | 47 | tui_display_main (void) |
c906108c | 48 | { |
dd1abb8c | 49 | if ((tui_source_windows ())->count > 0) |
c906108c SS |
50 | { |
51 | CORE_ADDR addr; | |
52 | ||
65f05602 | 53 | addr = tui_get_begin_asm_address (); |
c774cec6 | 54 | if (addr != (CORE_ADDR) 0) |
c906108c SS |
55 | { |
56 | struct symtab_and_line sal; | |
57 | ||
f80bda8e | 58 | tui_update_source_windows_with_addr (addr); |
c906108c | 59 | sal = find_pc_line (addr, 0); |
2e17b763 | 60 | if (sal.symtab) |
47d3492a | 61 | tui_update_locator_filename (sal.symtab->filename); |
2e17b763 | 62 | else |
47d3492a | 63 | tui_update_locator_filename ("??"); |
c906108c SS |
64 | } |
65 | } | |
2e17b763 | 66 | } |
c906108c SS |
67 | |
68 | ||
69 | ||
f80bda8e AC |
70 | /* Function to display source in the source window. This function |
71 | initializes the horizontal scroll to 0. */ | |
c906108c | 72 | void |
6d012f14 | 73 | tui_update_source_window (struct tui_win_info * win_info, struct symtab *s, |
6ba8e26f | 74 | union tui_line_or_address line_or_addr, int noerror) |
c906108c | 75 | { |
6d012f14 | 76 | win_info->detail.source_info.horizontal_offset = 0; |
6ba8e26f | 77 | tui_update_source_window_as_is (win_info, s, line_or_addr, noerror); |
c906108c SS |
78 | |
79 | return; | |
f80bda8e | 80 | } |
c906108c SS |
81 | |
82 | ||
f80bda8e AC |
83 | /* Function to display source in the source/asm window. This function |
84 | shows the source as specified by the horizontal offset. */ | |
c906108c | 85 | void |
6d012f14 | 86 | tui_update_source_window_as_is (struct tui_win_info * win_info, struct symtab *s, |
6ba8e26f | 87 | union tui_line_or_address line_or_addr, int noerror) |
c906108c | 88 | { |
22940a24 | 89 | enum tui_status ret; |
c906108c | 90 | |
6d012f14 | 91 | if (win_info->generic.type == SRC_WIN) |
6ba8e26f | 92 | ret = tui_set_source_content (s, line_or_addr.line_no, noerror); |
c906108c | 93 | else |
6ba8e26f | 94 | ret = tui_set_disassem_content (line_or_addr.addr); |
c906108c SS |
95 | |
96 | if (ret == TUI_FAILURE) | |
97 | { | |
6d012f14 AC |
98 | tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT); |
99 | tui_clear_exec_info_content (win_info); | |
c906108c SS |
100 | } |
101 | else | |
102 | { | |
6d012f14 AC |
103 | tui_update_breakpoint_info (win_info, 0); |
104 | tui_show_source_content (win_info); | |
105 | tui_update_exec_info (win_info); | |
106 | if (win_info->generic.type == SRC_WIN) | |
c906108c | 107 | { |
52575520 EZ |
108 | struct symtab_and_line sal; |
109 | ||
6ba8e26f | 110 | sal.line = line_or_addr.line_no + |
6d012f14 | 111 | (win_info->generic.content_size - 2); |
52575520 EZ |
112 | sal.symtab = s; |
113 | set_current_source_symtab_and_line (&sal); | |
c906108c | 114 | /* |
c5aa993b JM |
115 | ** If the focus was in the asm win, put it in the src |
116 | ** win if we don't have a split layout | |
117 | */ | |
6d012f14 | 118 | if (tui_win_with_focus () == TUI_DISASM_WIN && |
dd1abb8c | 119 | tui_current_layout () != SRC_DISASSEM_COMMAND) |
6d012f14 | 120 | tui_set_win_focus_to (TUI_SRC_WIN); |
c906108c SS |
121 | } |
122 | } | |
123 | ||
124 | ||
125 | return; | |
f80bda8e | 126 | } |
c906108c SS |
127 | |
128 | ||
f80bda8e AC |
129 | /* Function to ensure that the source and/or disassemly windows |
130 | reflect the input address. */ | |
c906108c | 131 | void |
f80bda8e | 132 | tui_update_source_windows_with_addr (CORE_ADDR addr) |
c906108c | 133 | { |
c774cec6 | 134 | if (addr != 0) |
c906108c SS |
135 | { |
136 | struct symtab_and_line sal; | |
2a8854a7 | 137 | union tui_line_or_address l; |
a4b99e53 | 138 | |
dd1abb8c | 139 | switch (tui_current_layout ()) |
c906108c SS |
140 | { |
141 | case DISASSEM_COMMAND: | |
142 | case DISASSEM_DATA_COMMAND: | |
65f05602 | 143 | tui_show_disassem (addr); |
c906108c SS |
144 | break; |
145 | case SRC_DISASSEM_COMMAND: | |
65f05602 | 146 | tui_show_disassem_and_update_source (addr); |
c906108c SS |
147 | break; |
148 | default: | |
c774cec6 | 149 | sal = find_pc_line (addr, 0); |
6d012f14 | 150 | l.line_no = sal.line; |
a358af15 | 151 | tui_show_symtab_source (sal.symtab, l, FALSE); |
c906108c SS |
152 | break; |
153 | } | |
154 | } | |
155 | else | |
156 | { | |
157 | int i; | |
158 | ||
dd1abb8c | 159 | for (i = 0; i < (tui_source_windows ())->count; i++) |
c906108c | 160 | { |
6d012f14 | 161 | struct tui_win_info * win_info = (struct tui_win_info *) (tui_source_windows ())->list[i]; |
c906108c | 162 | |
6d012f14 AC |
163 | tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT); |
164 | tui_clear_exec_info_content (win_info); | |
c906108c SS |
165 | } |
166 | } | |
6ba8e26f | 167 | } |
c906108c | 168 | |
f80bda8e AC |
169 | /* Function to ensure that the source and/or disassemly windows |
170 | reflect the input address. */ | |
c906108c | 171 | void |
f80bda8e | 172 | tui_update_source_windows_with_line (struct symtab *s, int line) |
c906108c | 173 | { |
84b1e7c7 | 174 | CORE_ADDR pc; |
2a8854a7 | 175 | union tui_line_or_address l; |
a4b99e53 | 176 | |
dd1abb8c | 177 | switch (tui_current_layout ()) |
c906108c SS |
178 | { |
179 | case DISASSEM_COMMAND: | |
180 | case DISASSEM_DATA_COMMAND: | |
84b1e7c7 | 181 | find_line_pc (s, line, &pc); |
f80bda8e | 182 | tui_update_source_windows_with_addr (pc); |
c906108c SS |
183 | break; |
184 | default: | |
6d012f14 | 185 | l.line_no = line; |
a358af15 | 186 | tui_show_symtab_source (s, l, FALSE); |
dd1abb8c | 187 | if (tui_current_layout () == SRC_DISASSEM_COMMAND) |
84b1e7c7 SC |
188 | { |
189 | find_line_pc (s, line, &pc); | |
65f05602 | 190 | tui_show_disassem (pc); |
84b1e7c7 | 191 | } |
c906108c SS |
192 | break; |
193 | } | |
194 | ||
195 | return; | |
f80bda8e | 196 | } |
c906108c | 197 | |
c906108c | 198 | void |
6ba8e26f | 199 | tui_clear_source_content (struct tui_win_info * win_info, int display_prompt) |
c906108c | 200 | { |
6d012f14 | 201 | if (win_info != NULL) |
c906108c | 202 | { |
d02c80cd | 203 | int i; |
c906108c | 204 | |
6d012f14 | 205 | win_info->generic.content_in_use = FALSE; |
6ba8e26f | 206 | tui_erase_source_content (win_info, display_prompt); |
6d012f14 | 207 | for (i = 0; i < win_info->generic.content_size; i++) |
c906108c | 208 | { |
2a8854a7 | 209 | struct tui_win_element * element = |
6d012f14 AC |
210 | (struct tui_win_element *) win_info->generic.content[i]; |
211 | element->which_element.source.has_break = FALSE; | |
212 | element->which_element.source.is_exec_point = FALSE; | |
c906108c SS |
213 | } |
214 | } | |
6ba8e26f | 215 | } |
c906108c SS |
216 | |
217 | ||
c906108c | 218 | void |
6ba8e26f | 219 | tui_erase_source_content (struct tui_win_info * win_info, int display_prompt) |
c906108c | 220 | { |
6ba8e26f AC |
221 | int x_pos; |
222 | int half_width = (win_info->generic.width - 2) / 2; | |
c906108c | 223 | |
6d012f14 | 224 | if (win_info->generic.handle != (WINDOW *) NULL) |
c906108c | 225 | { |
6d012f14 AC |
226 | werase (win_info->generic.handle); |
227 | tui_check_and_display_highlight_if_needed (win_info); | |
6ba8e26f | 228 | if (display_prompt == EMPTY_SOURCE_PROMPT) |
c906108c | 229 | { |
6ba8e26f | 230 | char *no_src_str; |
c906108c | 231 | |
6d012f14 | 232 | if (win_info->generic.type == SRC_WIN) |
6ba8e26f | 233 | no_src_str = NO_SRC_STRING; |
c906108c | 234 | else |
6ba8e26f AC |
235 | no_src_str = NO_DISASSEM_STRING; |
236 | if (strlen (no_src_str) >= half_width) | |
237 | x_pos = 1; | |
c906108c | 238 | else |
6ba8e26f | 239 | x_pos = half_width - strlen (no_src_str); |
6d012f14 AC |
240 | mvwaddstr (win_info->generic.handle, |
241 | (win_info->generic.height / 2), | |
6ba8e26f AC |
242 | x_pos, |
243 | no_src_str); | |
c906108c SS |
244 | |
245 | /* elz: added this function call to set the real contents of | |
c5aa993b JM |
246 | the window to what is on the screen, so that later calls |
247 | to refresh, do display | |
248 | the correct stuff, and not the old image */ | |
c906108c | 249 | |
6ba8e26f | 250 | tui_set_source_content_nil (win_info, no_src_str); |
c906108c | 251 | } |
6d012f14 | 252 | tui_refresh_win (&win_info->generic); |
c906108c | 253 | } |
6ba8e26f | 254 | } |
c906108c SS |
255 | |
256 | ||
bc712bbf SC |
257 | /* Redraw the complete line of a source or disassembly window. */ |
258 | static void | |
6d012f14 | 259 | tui_show_source_line (struct tui_win_info * win_info, int lineno) |
bc712bbf | 260 | { |
2a8854a7 | 261 | struct tui_win_element * line; |
bc712bbf SC |
262 | int x, y; |
263 | ||
6d012f14 AC |
264 | line = (struct tui_win_element *) win_info->generic.content[lineno - 1]; |
265 | if (line->which_element.source.is_exec_point) | |
266 | wattron (win_info->generic.handle, A_STANDOUT); | |
bc712bbf | 267 | |
6d012f14 AC |
268 | mvwaddstr (win_info->generic.handle, lineno, 1, |
269 | line->which_element.source.line); | |
270 | if (line->which_element.source.is_exec_point) | |
271 | wattroff (win_info->generic.handle, A_STANDOUT); | |
bc712bbf SC |
272 | |
273 | /* Clear to end of line but stop before the border. */ | |
6d012f14 AC |
274 | getyx (win_info->generic.handle, y, x); |
275 | while (x + 1 < win_info->generic.width) | |
bc712bbf | 276 | { |
6d012f14 AC |
277 | waddch (win_info->generic.handle, ' '); |
278 | getyx (win_info->generic.handle, y, x); | |
bc712bbf SC |
279 | } |
280 | } | |
281 | ||
c906108c | 282 | void |
6d012f14 | 283 | tui_show_source_content (struct tui_win_info * win_info) |
c906108c | 284 | { |
6d012f14 | 285 | if (win_info->generic.content_size > 0) |
c906108c | 286 | { |
bc712bbf SC |
287 | int lineno; |
288 | ||
6d012f14 AC |
289 | for (lineno = 1; lineno <= win_info->generic.content_size; lineno++) |
290 | tui_show_source_line (win_info, lineno); | |
c906108c | 291 | } |
bc712bbf | 292 | else |
6d012f14 | 293 | tui_erase_source_content (win_info, TRUE); |
bc712bbf | 294 | |
6d012f14 AC |
295 | tui_check_and_display_highlight_if_needed (win_info); |
296 | tui_refresh_win (&win_info->generic); | |
297 | win_info->generic.content_in_use = TRUE; | |
bc712bbf | 298 | } |
c906108c SS |
299 | |
300 | ||
f80bda8e | 301 | /* Scroll the source forward or backward horizontally. */ |
c906108c | 302 | void |
6d012f14 | 303 | tui_horizontal_source_scroll (struct tui_win_info * win_info, |
2a8854a7 | 304 | enum tui_scroll_direction direction, |
6ba8e26f | 305 | int num_to_scroll) |
c906108c | 306 | { |
6d012f14 | 307 | if (win_info->generic.content != NULL) |
c906108c SS |
308 | { |
309 | int offset; | |
310 | struct symtab *s; | |
52575520 | 311 | struct symtab_and_line cursal = get_current_source_symtab_and_line (); |
c906108c | 312 | |
52575520 | 313 | if (cursal.symtab == (struct symtab *) NULL) |
f70a7d61 | 314 | s = find_pc_symtab (get_frame_pc (deprecated_selected_frame)); |
c906108c | 315 | else |
52575520 | 316 | s = cursal.symtab; |
c906108c SS |
317 | |
318 | if (direction == LEFT_SCROLL) | |
6ba8e26f | 319 | offset = win_info->detail.source_info.horizontal_offset + num_to_scroll; |
c906108c SS |
320 | else |
321 | { | |
322 | if ((offset = | |
6ba8e26f | 323 | win_info->detail.source_info.horizontal_offset - num_to_scroll) < 0) |
c906108c SS |
324 | offset = 0; |
325 | } | |
6d012f14 AC |
326 | win_info->detail.source_info.horizontal_offset = offset; |
327 | tui_update_source_window_as_is (win_info, s, | |
2a8854a7 | 328 | ((struct tui_win_element *) |
6d012f14 | 329 | win_info->generic.content[0])->which_element.source.line_or_addr, |
f80bda8e | 330 | FALSE); |
c906108c SS |
331 | } |
332 | ||
333 | return; | |
6ba8e26f | 334 | } |
c906108c SS |
335 | |
336 | ||
6d012f14 | 337 | /* Set or clear the has_break flag in the line whose line is line_no. */ |
c906108c | 338 | void |
6d012f14 | 339 | tui_set_is_exec_point_at (union tui_line_or_address l, struct tui_win_info * win_info) |
c906108c | 340 | { |
00b90ae2 | 341 | int changed = 0; |
c906108c | 342 | int i; |
6d012f14 | 343 | tui_win_content content = (tui_win_content) win_info->generic.content; |
c906108c SS |
344 | |
345 | i = 0; | |
6d012f14 | 346 | while (i < win_info->generic.content_size) |
c906108c | 347 | { |
6ba8e26f | 348 | int new_state; |
00b90ae2 | 349 | |
6d012f14 | 350 | if (content[i]->which_element.source.line_or_addr.addr == l.addr) |
6ba8e26f | 351 | new_state = TRUE; |
c906108c | 352 | else |
6ba8e26f AC |
353 | new_state = FALSE; |
354 | if (new_state != content[i]->which_element.source.is_exec_point) | |
00b90ae2 SC |
355 | { |
356 | changed++; | |
6ba8e26f | 357 | content[i]->which_element.source.is_exec_point = new_state; |
6d012f14 | 358 | tui_show_source_line (win_info, i + 1); |
00b90ae2 | 359 | } |
c906108c SS |
360 | i++; |
361 | } | |
00b90ae2 | 362 | if (changed) |
6d012f14 | 363 | tui_refresh_win (&win_info->generic); |
00b90ae2 | 364 | } |
c906108c | 365 | |
00b2bad4 SC |
366 | /* Update the execution windows to show the active breakpoints. |
367 | This is called whenever a breakpoint is inserted, removed or | |
368 | has its state changed. */ | |
c906108c | 369 | void |
d02c80cd | 370 | tui_update_all_breakpoint_info (void) |
c906108c | 371 | { |
2a8854a7 | 372 | struct tui_list *list = tui_source_windows (); |
c906108c | 373 | int i; |
c906108c | 374 | |
00b2bad4 | 375 | for (i = 0; i < list->count; i++) |
c906108c | 376 | { |
2a8854a7 | 377 | struct tui_win_info * win = (struct tui_win_info *) list->list[i]; |
c906108c | 378 | |
00b2bad4 SC |
379 | if (tui_update_breakpoint_info (win, FALSE)) |
380 | { | |
f80bda8e | 381 | tui_update_exec_info (win); |
00b2bad4 | 382 | } |
c906108c | 383 | } |
00b2bad4 | 384 | } |
c906108c SS |
385 | |
386 | ||
00b2bad4 | 387 | /* Scan the source window and the breakpoints to update the |
6d012f14 | 388 | has_break information for each line. |
00b2bad4 SC |
389 | Returns 1 if something changed and the execution window |
390 | must be refreshed. */ | |
391 | int | |
2a8854a7 | 392 | tui_update_breakpoint_info (struct tui_win_info * win, int current_only) |
c906108c SS |
393 | { |
394 | int i; | |
00b2bad4 | 395 | int need_refresh = 0; |
6d012f14 | 396 | struct tui_source_info * src = &win->detail.source_info; |
c906108c | 397 | |
6d012f14 | 398 | for (i = 0; i < win->generic.content_size; i++) |
00b2bad4 SC |
399 | { |
400 | struct breakpoint *bp; | |
401 | extern struct breakpoint *breakpoint_chain; | |
402 | int mode; | |
2a8854a7 | 403 | struct tui_source_element* line; |
00b2bad4 | 404 | |
6d012f14 AC |
405 | line = &((struct tui_win_element *) win->generic.content[i])->which_element.source; |
406 | if (current_only && !line->is_exec_point) | |
00b2bad4 SC |
407 | continue; |
408 | ||
409 | /* Scan each breakpoint to see if the current line has something to | |
410 | do with it. Identify enable/disabled breakpoints as well as | |
411 | those that we already hit. */ | |
412 | mode = 0; | |
413 | for (bp = breakpoint_chain; | |
414 | bp != (struct breakpoint *) NULL; | |
415 | bp = bp->next) | |
416 | { | |
6d012f14 | 417 | if ((win == TUI_SRC_WIN |
00b2bad4 SC |
418 | && bp->source_file |
419 | && (strcmp (src->filename, bp->source_file) == 0) | |
6d012f14 AC |
420 | && bp->line_number == line->line_or_addr.line_no) |
421 | || (win == TUI_DISASM_WIN | |
422 | && bp->loc->address == line->line_or_addr.addr)) | |
00b2bad4 SC |
423 | { |
424 | if (bp->enable_state == bp_disabled) | |
425 | mode |= TUI_BP_DISABLED; | |
426 | else | |
427 | mode |= TUI_BP_ENABLED; | |
428 | if (bp->hit_count) | |
429 | mode |= TUI_BP_HIT; | |
430 | if (bp->cond) | |
431 | mode |= TUI_BP_CONDITIONAL; | |
432 | if (bp->type == bp_hardware_breakpoint) | |
433 | mode |= TUI_BP_HARDWARE; | |
434 | } | |
435 | } | |
6d012f14 | 436 | if (line->has_break != mode) |
00b2bad4 | 437 | { |
6d012f14 | 438 | line->has_break = mode; |
00b2bad4 SC |
439 | need_refresh = 1; |
440 | } | |
441 | } | |
442 | return need_refresh; | |
443 | } | |
c906108c | 444 | |
c906108c | 445 | |
6ba8e26f AC |
446 | /* Function to initialize the content of the execution info window, |
447 | based upon the input window which is either the source or | |
448 | disassembly window. */ | |
22940a24 | 449 | enum tui_status |
6ba8e26f | 450 | tui_set_exec_info_content (struct tui_win_info * win_info) |
c906108c | 451 | { |
22940a24 | 452 | enum tui_status ret = TUI_SUCCESS; |
c906108c | 453 | |
6d012f14 | 454 | if (win_info->detail.source_info.execution_info != (struct tui_gen_win_info *) NULL) |
c906108c | 455 | { |
6ba8e26f | 456 | struct tui_gen_win_info * exec_info_ptr = win_info->detail.source_info.execution_info; |
c906108c | 457 | |
6ba8e26f AC |
458 | if (exec_info_ptr->content == NULL) |
459 | exec_info_ptr->content = | |
6d012f14 | 460 | (void **) tui_alloc_content (win_info->generic.height, |
6ba8e26f AC |
461 | exec_info_ptr->type); |
462 | if (exec_info_ptr->content != NULL) | |
c906108c SS |
463 | { |
464 | int i; | |
465 | ||
6d012f14 AC |
466 | tui_update_breakpoint_info (win_info, 1); |
467 | for (i = 0; i < win_info->generic.content_size; i++) | |
c906108c | 468 | { |
2a8854a7 | 469 | struct tui_win_element * element; |
6ba8e26f | 470 | struct tui_win_element * src_element; |
00b2bad4 | 471 | int mode; |
c906108c | 472 | |
6ba8e26f AC |
473 | element = (struct tui_win_element *) exec_info_ptr->content[i]; |
474 | src_element = (struct tui_win_element *) win_info->generic.content[i]; | |
00b2bad4 | 475 | |
6d012f14 AC |
476 | memset(element->which_element.simple_string, ' ', |
477 | sizeof(element->which_element.simple_string)); | |
478 | element->which_element.simple_string[TUI_EXECINFO_SIZE - 1] = 0; | |
00b2bad4 SC |
479 | |
480 | /* Now update the exec info content based upon the state | |
481 | of each line as indicated by the source content. */ | |
6ba8e26f | 482 | mode = src_element->which_element.source.has_break; |
00b2bad4 | 483 | if (mode & TUI_BP_HIT) |
6d012f14 | 484 | element->which_element.simple_string[TUI_BP_HIT_POS] = |
00b2bad4 SC |
485 | (mode & TUI_BP_HARDWARE) ? 'H' : 'B'; |
486 | else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED)) | |
6d012f14 | 487 | element->which_element.simple_string[TUI_BP_HIT_POS] = |
00b2bad4 SC |
488 | (mode & TUI_BP_HARDWARE) ? 'h' : 'b'; |
489 | ||
490 | if (mode & TUI_BP_ENABLED) | |
6d012f14 | 491 | element->which_element.simple_string[TUI_BP_BREAK_POS] = '+'; |
00b2bad4 | 492 | else if (mode & TUI_BP_DISABLED) |
6d012f14 | 493 | element->which_element.simple_string[TUI_BP_BREAK_POS] = '-'; |
00b2bad4 | 494 | |
6ba8e26f | 495 | if (src_element->which_element.source.is_exec_point) |
6d012f14 | 496 | element->which_element.simple_string[TUI_EXEC_POS] = '>'; |
c906108c | 497 | } |
6ba8e26f | 498 | exec_info_ptr->content_size = win_info->generic.content_size; |
c906108c SS |
499 | } |
500 | else | |
501 | ret = TUI_FAILURE; | |
502 | } | |
503 | ||
504 | return ret; | |
00b2bad4 | 505 | } |
c906108c SS |
506 | |
507 | ||
c906108c | 508 | void |
6ba8e26f | 509 | tui_show_exec_info_content (struct tui_win_info * win_info) |
c906108c | 510 | { |
6ba8e26f AC |
511 | struct tui_gen_win_info * exec_info = win_info->detail.source_info.execution_info; |
512 | int cur_line; | |
513 | ||
514 | werase (exec_info->handle); | |
515 | tui_refresh_win (exec_info); | |
516 | for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++) | |
517 | mvwaddstr (exec_info->handle, | |
518 | cur_line, | |
c906108c | 519 | 0, |
2a8854a7 | 520 | ((struct tui_win_element *) |
6ba8e26f AC |
521 | exec_info->content[cur_line - 1])->which_element.simple_string); |
522 | tui_refresh_win (exec_info); | |
523 | exec_info->content_in_use = TRUE; | |
f80bda8e | 524 | } |
c906108c SS |
525 | |
526 | ||
c906108c | 527 | void |
6d012f14 | 528 | tui_erase_exec_info_content (struct tui_win_info * win_info) |
c906108c | 529 | { |
6ba8e26f | 530 | struct tui_gen_win_info * exec_info = win_info->detail.source_info.execution_info; |
c906108c | 531 | |
6ba8e26f AC |
532 | werase (exec_info->handle); |
533 | tui_refresh_win (exec_info); | |
f80bda8e | 534 | } |
c906108c | 535 | |
c906108c | 536 | void |
6d012f14 | 537 | tui_clear_exec_info_content (struct tui_win_info * win_info) |
c906108c | 538 | { |
6d012f14 AC |
539 | win_info->detail.source_info.execution_info->content_in_use = FALSE; |
540 | tui_erase_exec_info_content (win_info); | |
c906108c SS |
541 | |
542 | return; | |
f80bda8e | 543 | } |
c906108c | 544 | |
f80bda8e | 545 | /* Function to update the execution info window. */ |
c906108c | 546 | void |
6d012f14 | 547 | tui_update_exec_info (struct tui_win_info * win_info) |
c906108c | 548 | { |
6ba8e26f AC |
549 | tui_set_exec_info_content (win_info); |
550 | tui_show_exec_info_content (win_info); | |
551 | } | |
c906108c | 552 | |
f80bda8e | 553 | enum tui_status |
6d012f14 | 554 | tui_alloc_source_buffer (struct tui_win_info *win_info) |
c906108c | 555 | { |
d02c80cd AC |
556 | char *src_line_buf; |
557 | int i, line_width, max_lines; | |
22940a24 | 558 | enum tui_status ret = TUI_FAILURE; |
c906108c | 559 | |
6ba8e26f AC |
560 | max_lines = win_info->generic.height; /* less the highlight box */ |
561 | line_width = win_info->generic.width - 1; | |
c906108c | 562 | /* |
c5aa993b JM |
563 | ** Allocate the buffer for the source lines. Do this only once since they |
564 | ** will be re-used for all source displays. The only other time this will | |
565 | ** be done is when a window's size changes. | |
566 | */ | |
6d012f14 | 567 | if (win_info->generic.content == NULL) |
c906108c | 568 | { |
6ba8e26f AC |
569 | src_line_buf = (char *) xmalloc ((max_lines * line_width) * sizeof (char)); |
570 | if (src_line_buf == (char *) NULL) | |
c906108c SS |
571 | fputs_unfiltered ( |
572 | "Unable to Allocate Memory for Source or Disassembly Display.\n", | |
573 | gdb_stderr); | |
574 | else | |
575 | { | |
576 | /* allocate the content list */ | |
6d012f14 | 577 | if ((win_info->generic.content = |
6ba8e26f | 578 | (void **) tui_alloc_content (max_lines, SRC_WIN)) == NULL) |
c906108c | 579 | { |
6ba8e26f AC |
580 | xfree (src_line_buf); |
581 | src_line_buf = (char *) NULL; | |
c906108c SS |
582 | fputs_unfiltered ( |
583 | "Unable to Allocate Memory for Source or Disassembly Display.\n", | |
584 | gdb_stderr); | |
585 | } | |
586 | } | |
6ba8e26f | 587 | for (i = 0; i < max_lines; i++) |
2a8854a7 | 588 | ((struct tui_win_element *) |
6d012f14 | 589 | win_info->generic.content[i])->which_element.source.line = |
6ba8e26f | 590 | src_line_buf + (line_width * i); |
c906108c SS |
591 | ret = TUI_SUCCESS; |
592 | } | |
593 | else | |
594 | ret = TUI_SUCCESS; | |
595 | ||
596 | return ret; | |
6ba8e26f | 597 | } |
c906108c SS |
598 | |
599 | ||
f80bda8e AC |
600 | /* Answer whether the a particular line number or address is displayed |
601 | in the current source window. */ | |
c906108c | 602 | int |
6d012f14 | 603 | tui_line_is_displayed (int line, struct tui_win_info * win_info, |
6ba8e26f | 604 | int check_threshold) |
c906108c | 605 | { |
6ba8e26f | 606 | int is_displayed = FALSE; |
c906108c SS |
607 | int i, threshold; |
608 | ||
6ba8e26f | 609 | if (check_threshold) |
c906108c SS |
610 | threshold = SCROLL_THRESHOLD; |
611 | else | |
612 | threshold = 0; | |
613 | i = 0; | |
6ba8e26f | 614 | while (i < win_info->generic.content_size - threshold && !is_displayed) |
c906108c | 615 | { |
6ba8e26f | 616 | is_displayed = (((struct tui_win_element *) |
6d012f14 | 617 | win_info->generic.content[i])->which_element.source.line_or_addr.line_no |
a4b99e53 | 618 | == (int) line); |
c906108c SS |
619 | i++; |
620 | } | |
621 | ||
6ba8e26f | 622 | return is_displayed; |
f80bda8e | 623 | } |
c906108c SS |
624 | |
625 | ||
f80bda8e AC |
626 | /* Answer whether the a particular line number or address is displayed |
627 | in the current source window. */ | |
a4b99e53 | 628 | int |
6d012f14 | 629 | tui_addr_is_displayed (CORE_ADDR addr, struct tui_win_info * win_info, |
6ba8e26f | 630 | int check_threshold) |
a4b99e53 | 631 | { |
6ba8e26f | 632 | int is_displayed = FALSE; |
a4b99e53 SC |
633 | int i, threshold; |
634 | ||
6ba8e26f | 635 | if (check_threshold) |
a4b99e53 SC |
636 | threshold = SCROLL_THRESHOLD; |
637 | else | |
638 | threshold = 0; | |
639 | i = 0; | |
6ba8e26f | 640 | while (i < win_info->generic.content_size - threshold && !is_displayed) |
a4b99e53 | 641 | { |
6ba8e26f | 642 | is_displayed = (((struct tui_win_element *) |
6d012f14 | 643 | win_info->generic.content[i])->which_element.source.line_or_addr.addr |
a4b99e53 SC |
644 | == addr); |
645 | i++; | |
646 | } | |
647 | ||
6ba8e26f | 648 | return is_displayed; |
a4b99e53 SC |
649 | } |
650 | ||
651 | ||
c906108c SS |
652 | /***************************************** |
653 | ** STATIC LOCAL FUNCTIONS ** | |
654 | ******************************************/ |