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