Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI display source/assembly window. |
f33c6cbf AC |
2 | |
3 | Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, | |
4 | Inc. | |
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 | 24 | |
f33c6cbf AC |
25 | /* FIXME: cagney/2002-02-28: The GDB coding standard indicates that |
26 | "defs.h" should be included first. Unfortunatly some systems | |
27 | (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h> | |
28 | and they clash with "bfd.h"'s definiton of true/false. The correct | |
29 | fix is to remove true/false from "bfd.h", however, until that | |
30 | happens, hack around it by including "config.h" and <curses.h> | |
31 | first. */ | |
32 | ||
4e8f7a8b DJ |
33 | #include "config.h" |
34 | #ifdef HAVE_NCURSES_H | |
35 | #include <ncurses.h> | |
36 | #else | |
37 | #ifdef HAVE_CURSES_H | |
38 | #include <curses.h> | |
39 | #endif | |
40 | #endif | |
41 | ||
c906108c SS |
42 | #include "defs.h" |
43 | #include <ctype.h> | |
44 | #include "symtab.h" | |
45 | #include "frame.h" | |
46 | #include "breakpoint.h" | |
fd0407d6 | 47 | #include "value.h" |
c906108c SS |
48 | |
49 | #include "tui.h" | |
50 | #include "tuiData.h" | |
51 | #include "tuiStack.h" | |
c774cec6 SC |
52 | #include "tuiWin.h" |
53 | #include "tuiGeneralWin.h" | |
c906108c SS |
54 | #include "tuiSourceWin.h" |
55 | #include "tuiSource.h" | |
56 | #include "tuiDisassem.h" | |
57 | ||
58 | ||
59 | /***************************************** | |
60 | ** EXTERNAL FUNCTION DECLS ** | |
61 | ******************************************/ | |
62 | ||
63 | /***************************************** | |
64 | ** EXTERNAL DATA DECLS ** | |
65 | ******************************************/ | |
66 | extern int current_source_line; | |
67 | extern struct symtab *current_source_symtab; | |
68 | ||
c906108c | 69 | /* |
c5aa993b JM |
70 | ** tuiDisplayMainFunction(). |
71 | ** Function to display the "main" routine" | |
72 | */ | |
c906108c | 73 | void |
c906108c | 74 | tuiDisplayMainFunction (void) |
c906108c SS |
75 | { |
76 | if ((sourceWindows ())->count > 0) | |
77 | { | |
78 | CORE_ADDR addr; | |
79 | ||
80 | addr = parse_and_eval_address ("main"); | |
c774cec6 | 81 | if (addr == (CORE_ADDR) 0) |
c906108c | 82 | addr = parse_and_eval_address ("MAIN"); |
c774cec6 | 83 | if (addr != (CORE_ADDR) 0) |
c906108c SS |
84 | { |
85 | struct symtab_and_line sal; | |
86 | ||
c774cec6 | 87 | tuiUpdateSourceWindowsWithAddr (addr); |
c906108c SS |
88 | sal = find_pc_line (addr, 0); |
89 | tuiSwitchFilename (sal.symtab->filename); | |
90 | } | |
91 | } | |
92 | ||
93 | return; | |
94 | } /* tuiDisplayMainFunction */ | |
95 | ||
96 | ||
97 | ||
98 | /* | |
c5aa993b JM |
99 | ** tuiUpdateSourceWindow(). |
100 | ** Function to display source in the source window. This function | |
101 | ** initializes the horizontal scroll to 0. | |
102 | */ | |
c906108c | 103 | void |
eca6576c | 104 | tuiUpdateSourceWindow (TuiWinInfoPtr winInfo, struct symtab *s, |
a4b99e53 | 105 | TuiLineOrAddress lineOrAddr, int noerror) |
c906108c SS |
106 | { |
107 | winInfo->detail.sourceInfo.horizontalOffset = 0; | |
108 | tuiUpdateSourceWindowAsIs (winInfo, s, lineOrAddr, noerror); | |
109 | ||
110 | return; | |
111 | } /* tuiUpdateSourceWindow */ | |
112 | ||
113 | ||
114 | /* | |
c5aa993b JM |
115 | ** tuiUpdateSourceWindowAsIs(). |
116 | ** Function to display source in the source/asm window. This | |
117 | ** function shows the source as specified by the horizontal offset. | |
118 | */ | |
c906108c | 119 | void |
eca6576c | 120 | tuiUpdateSourceWindowAsIs (TuiWinInfoPtr winInfo, struct symtab *s, |
a4b99e53 | 121 | TuiLineOrAddress lineOrAddr, int noerror) |
c906108c SS |
122 | { |
123 | TuiStatus ret; | |
124 | ||
125 | if (winInfo->generic.type == SRC_WIN) | |
a4b99e53 | 126 | ret = tuiSetSourceContent (s, lineOrAddr.lineNo, noerror); |
c906108c | 127 | else |
a4b99e53 | 128 | ret = tuiSetDisassemContent (s, lineOrAddr.addr); |
c906108c SS |
129 | |
130 | if (ret == TUI_FAILURE) | |
131 | { | |
132 | tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT); | |
133 | tuiClearExecInfoContent (winInfo); | |
134 | } | |
135 | else | |
136 | { | |
137 | tuiEraseSourceContent (winInfo, NO_EMPTY_SOURCE_PROMPT); | |
138 | tuiShowSourceContent (winInfo); | |
139 | tuiUpdateExecInfo (winInfo); | |
140 | if (winInfo->generic.type == SRC_WIN) | |
141 | { | |
a4b99e53 | 142 | current_source_line = lineOrAddr.lineNo + |
c906108c SS |
143 | (winInfo->generic.contentSize - 2); |
144 | current_source_symtab = s; | |
145 | /* | |
c5aa993b JM |
146 | ** If the focus was in the asm win, put it in the src |
147 | ** win if we don't have a split layout | |
148 | */ | |
c906108c SS |
149 | if (tuiWinWithFocus () == disassemWin && |
150 | currentLayout () != SRC_DISASSEM_COMMAND) | |
151 | tuiSetWinFocusTo (srcWin); | |
152 | } | |
153 | } | |
154 | ||
155 | ||
156 | return; | |
157 | } /* tuiUpdateSourceWindowAsIs */ | |
158 | ||
159 | ||
160 | /* | |
c5aa993b JM |
161 | ** tuiUpdateSourceWindowsWithAddr(). |
162 | ** Function to ensure that the source and/or disassemly windows | |
163 | ** reflect the input address. | |
164 | */ | |
c906108c | 165 | void |
c774cec6 | 166 | tuiUpdateSourceWindowsWithAddr (CORE_ADDR addr) |
c906108c | 167 | { |
c774cec6 | 168 | if (addr != 0) |
c906108c SS |
169 | { |
170 | struct symtab_and_line sal; | |
a4b99e53 SC |
171 | TuiLineOrAddress l; |
172 | ||
c906108c SS |
173 | switch (currentLayout ()) |
174 | { | |
175 | case DISASSEM_COMMAND: | |
176 | case DISASSEM_DATA_COMMAND: | |
177 | tuiShowDisassem (addr); | |
178 | break; | |
179 | case SRC_DISASSEM_COMMAND: | |
180 | tuiShowDisassemAndUpdateSource (addr); | |
181 | break; | |
182 | default: | |
c774cec6 | 183 | sal = find_pc_line (addr, 0); |
a4b99e53 SC |
184 | l.lineNo = sal.line; |
185 | tuiShowSource (sal.symtab, l, FALSE); | |
c906108c SS |
186 | break; |
187 | } | |
188 | } | |
189 | else | |
190 | { | |
191 | int i; | |
192 | ||
193 | for (i = 0; i < (sourceWindows ())->count; i++) | |
194 | { | |
195 | TuiWinInfoPtr winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i]; | |
196 | ||
197 | tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT); | |
198 | tuiClearExecInfoContent (winInfo); | |
199 | } | |
200 | } | |
201 | ||
202 | return; | |
203 | } /* tuiUpdateSourceWindowsWithAddr */ | |
204 | ||
c906108c | 205 | /* |
c5aa993b JM |
206 | ** tuiUpdateSourceWindowsWithLine(). |
207 | ** Function to ensure that the source and/or disassemly windows | |
208 | ** reflect the input address. | |
209 | */ | |
c906108c | 210 | void |
eca6576c | 211 | tuiUpdateSourceWindowsWithLine (struct symtab *s, int line) |
c906108c | 212 | { |
84b1e7c7 | 213 | CORE_ADDR pc; |
a4b99e53 SC |
214 | TuiLineOrAddress l; |
215 | ||
c906108c SS |
216 | switch (currentLayout ()) |
217 | { | |
218 | case DISASSEM_COMMAND: | |
219 | case DISASSEM_DATA_COMMAND: | |
84b1e7c7 | 220 | find_line_pc (s, line, &pc); |
c774cec6 | 221 | tuiUpdateSourceWindowsWithAddr (pc); |
c906108c SS |
222 | break; |
223 | default: | |
a4b99e53 SC |
224 | l.lineNo = line; |
225 | tuiShowSource (s, l, FALSE); | |
c906108c | 226 | if (currentLayout () == SRC_DISASSEM_COMMAND) |
84b1e7c7 SC |
227 | { |
228 | find_line_pc (s, line, &pc); | |
c774cec6 | 229 | tuiShowDisassem (pc); |
84b1e7c7 | 230 | } |
c906108c SS |
231 | break; |
232 | } | |
233 | ||
234 | return; | |
235 | } /* tuiUpdateSourceWindowsWithLine */ | |
236 | ||
c906108c | 237 | /* |
c5aa993b JM |
238 | ** tuiClearSourceContent(). |
239 | */ | |
c906108c | 240 | void |
eca6576c | 241 | tuiClearSourceContent (TuiWinInfoPtr winInfo, int displayPrompt) |
c906108c SS |
242 | { |
243 | if (m_winPtrNotNull (winInfo)) | |
244 | { | |
245 | register int i; | |
246 | ||
247 | winInfo->generic.contentInUse = FALSE; | |
248 | tuiEraseSourceContent (winInfo, displayPrompt); | |
249 | for (i = 0; i < winInfo->generic.contentSize; i++) | |
250 | { | |
251 | TuiWinElementPtr element = | |
252 | (TuiWinElementPtr) winInfo->generic.content[i]; | |
253 | element->whichElement.source.hasBreak = FALSE; | |
254 | element->whichElement.source.isExecPoint = FALSE; | |
255 | } | |
256 | } | |
257 | ||
258 | return; | |
259 | } /* tuiClearSourceContent */ | |
260 | ||
261 | ||
c906108c | 262 | /* |
c5aa993b JM |
263 | ** tuiEraseSourceContent(). |
264 | */ | |
c906108c | 265 | void |
eca6576c | 266 | tuiEraseSourceContent (TuiWinInfoPtr winInfo, int displayPrompt) |
c906108c SS |
267 | { |
268 | int xPos; | |
269 | int halfWidth = (winInfo->generic.width - 2) / 2; | |
270 | ||
271 | if (winInfo->generic.handle != (WINDOW *) NULL) | |
272 | { | |
273 | werase (winInfo->generic.handle); | |
274 | checkAndDisplayHighlightIfNeeded (winInfo); | |
275 | if (displayPrompt == EMPTY_SOURCE_PROMPT) | |
276 | { | |
277 | char *noSrcStr; | |
278 | ||
279 | if (winInfo->generic.type == SRC_WIN) | |
280 | noSrcStr = NO_SRC_STRING; | |
281 | else | |
282 | noSrcStr = NO_DISASSEM_STRING; | |
283 | if (strlen (noSrcStr) >= halfWidth) | |
284 | xPos = 1; | |
285 | else | |
286 | xPos = halfWidth - strlen (noSrcStr); | |
287 | mvwaddstr (winInfo->generic.handle, | |
288 | (winInfo->generic.height / 2), | |
289 | xPos, | |
290 | noSrcStr); | |
291 | ||
292 | /* elz: added this function call to set the real contents of | |
c5aa993b JM |
293 | the window to what is on the screen, so that later calls |
294 | to refresh, do display | |
295 | the correct stuff, and not the old image */ | |
c906108c SS |
296 | |
297 | tuiSetSourceContentNil (winInfo, noSrcStr); | |
298 | } | |
299 | tuiRefreshWin (&winInfo->generic); | |
300 | } | |
301 | return; | |
302 | } /* tuiEraseSourceContent */ | |
303 | ||
304 | ||
305 | /* | |
c5aa993b JM |
306 | ** tuiEraseAllSourceContent(). |
307 | */ | |
c906108c | 308 | void |
eca6576c | 309 | tuiEraseAllSourceWinsContent (int displayPrompt) |
c906108c SS |
310 | { |
311 | int i; | |
312 | ||
313 | for (i = 0; i < (sourceWindows ())->count; i++) | |
314 | tuiEraseSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i], | |
315 | displayPrompt); | |
316 | ||
317 | return; | |
318 | } /* tuiEraseAllSourceWinsContent */ | |
319 | ||
320 | ||
bc712bbf SC |
321 | /* Redraw the complete line of a source or disassembly window. */ |
322 | static void | |
323 | tui_show_source_line (TuiWinInfoPtr winInfo, int lineno) | |
324 | { | |
325 | TuiWinElementPtr line; | |
326 | int x, y; | |
327 | ||
328 | line = (TuiWinElementPtr) winInfo->generic.content[lineno - 1]; | |
329 | if (line->whichElement.source.isExecPoint) | |
330 | wattron (winInfo->generic.handle, A_STANDOUT); | |
331 | ||
332 | mvwaddstr (winInfo->generic.handle, lineno, 1, | |
333 | line->whichElement.source.line); | |
334 | if (line->whichElement.source.isExecPoint) | |
335 | wattroff (winInfo->generic.handle, A_STANDOUT); | |
336 | ||
337 | /* Clear to end of line but stop before the border. */ | |
338 | getyx (winInfo->generic.handle, y, x); | |
339 | while (x + 1 < winInfo->generic.width) | |
340 | { | |
341 | waddch (winInfo->generic.handle, ' '); | |
342 | getyx (winInfo->generic.handle, y, x); | |
343 | } | |
344 | } | |
345 | ||
c906108c | 346 | /* |
c5aa993b JM |
347 | ** tuiShowSourceContent(). |
348 | */ | |
c906108c | 349 | void |
eca6576c | 350 | tuiShowSourceContent (TuiWinInfoPtr winInfo) |
c906108c | 351 | { |
c906108c SS |
352 | if (winInfo->generic.contentSize > 0) |
353 | { | |
bc712bbf SC |
354 | int lineno; |
355 | ||
356 | for (lineno = 1; lineno <= winInfo->generic.contentSize; lineno++) | |
357 | tui_show_source_line (winInfo, lineno); | |
c906108c | 358 | } |
bc712bbf SC |
359 | else |
360 | tuiEraseSourceContent (winInfo, TRUE); | |
361 | ||
c906108c SS |
362 | checkAndDisplayHighlightIfNeeded (winInfo); |
363 | tuiRefreshWin (&winInfo->generic); | |
364 | winInfo->generic.contentInUse = TRUE; | |
bc712bbf | 365 | } |
c906108c SS |
366 | |
367 | ||
c906108c | 368 | /* |
c5aa993b JM |
369 | ** tuiHorizontalSourceScroll(). |
370 | ** Scroll the source forward or backward horizontally | |
371 | */ | |
c906108c | 372 | void |
eca6576c SC |
373 | tuiHorizontalSourceScroll (TuiWinInfoPtr winInfo, |
374 | TuiScrollDirection direction, | |
375 | int numToScroll) | |
c906108c SS |
376 | { |
377 | if (winInfo->generic.content != (OpaquePtr) NULL) | |
378 | { | |
379 | int offset; | |
380 | struct symtab *s; | |
381 | ||
382 | if (current_source_symtab == (struct symtab *) NULL) | |
383 | s = find_pc_symtab (selected_frame->pc); | |
384 | else | |
385 | s = current_source_symtab; | |
386 | ||
387 | if (direction == LEFT_SCROLL) | |
388 | offset = winInfo->detail.sourceInfo.horizontalOffset + numToScroll; | |
389 | else | |
390 | { | |
391 | if ((offset = | |
392 | winInfo->detail.sourceInfo.horizontalOffset - numToScroll) < 0) | |
393 | offset = 0; | |
394 | } | |
395 | winInfo->detail.sourceInfo.horizontalOffset = offset; | |
396 | tuiUpdateSourceWindowAsIs ( | |
397 | winInfo, | |
398 | s, | |
a4b99e53 SC |
399 | ((TuiWinElementPtr) |
400 | winInfo->generic.content[0])->whichElement.source.lineOrAddr, | |
401 | FALSE); | |
c906108c SS |
402 | } |
403 | ||
404 | return; | |
405 | } /* tuiHorizontalSourceScroll */ | |
406 | ||
407 | ||
408 | /* | |
c5aa993b JM |
409 | ** tuiSetHasExecPointAt(). |
410 | ** Set or clear the hasBreak flag in the line whose line is lineNo. | |
411 | */ | |
c906108c | 412 | void |
a4b99e53 | 413 | tuiSetIsExecPointAt (TuiLineOrAddress l, TuiWinInfoPtr winInfo) |
c906108c SS |
414 | { |
415 | int i; | |
416 | TuiWinContent content = (TuiWinContent) winInfo->generic.content; | |
417 | ||
418 | i = 0; | |
419 | while (i < winInfo->generic.contentSize) | |
420 | { | |
a4b99e53 | 421 | if (content[i]->whichElement.source.lineOrAddr.addr == l.addr) |
c906108c SS |
422 | content[i]->whichElement.source.isExecPoint = TRUE; |
423 | else | |
424 | content[i]->whichElement.source.isExecPoint = FALSE; | |
425 | i++; | |
426 | } | |
427 | ||
428 | return; | |
429 | } /* tuiSetIsExecPointAt */ | |
430 | ||
c906108c | 431 | /* |
c5aa993b JM |
432 | ** tuiSetHasBreakAt(). |
433 | ** Set or clear the hasBreak flag in the line whose line is lineNo. | |
434 | */ | |
c906108c | 435 | void |
eca6576c | 436 | tuiSetHasBreakAt (struct breakpoint *bp, TuiWinInfoPtr winInfo, int hasBreak) |
c906108c SS |
437 | { |
438 | int i; | |
439 | TuiWinContent content = (TuiWinContent) winInfo->generic.content; | |
440 | ||
441 | i = 0; | |
442 | while (i < winInfo->generic.contentSize) | |
443 | { | |
444 | int gotIt; | |
445 | TuiGenWinInfoPtr locator = locatorWinInfoPtr (); | |
446 | ||
447 | if (winInfo == srcWin) | |
448 | { | |
449 | char *fileNameDisplayed = (char *) NULL; | |
450 | ||
451 | if (((TuiWinElementPtr) | |
452 | locator->content[0])->whichElement.locator.fileName != | |
453 | (char *) NULL) | |
454 | fileNameDisplayed = ((TuiWinElementPtr) | |
455 | locator->content[0])->whichElement.locator.fileName; | |
456 | else if (current_source_symtab != (struct symtab *) NULL) | |
457 | fileNameDisplayed = current_source_symtab->filename; | |
458 | ||
459 | gotIt = (fileNameDisplayed != (char *) NULL && | |
84b1e7c7 | 460 | bp->source_file != NULL && |
c906108c SS |
461 | (strcmp (bp->source_file, fileNameDisplayed) == 0) && |
462 | content[i]->whichElement.source.lineOrAddr.lineNo == | |
463 | bp->line_number); | |
464 | } | |
465 | else | |
466 | gotIt = (content[i]->whichElement.source.lineOrAddr.addr | |
c774cec6 | 467 | == bp->address); |
c906108c SS |
468 | if (gotIt) |
469 | { | |
470 | content[i]->whichElement.source.hasBreak = hasBreak; | |
471 | break; | |
472 | } | |
473 | i++; | |
474 | } | |
475 | ||
476 | return; | |
477 | } /* tuiSetHasBreakAt */ | |
478 | ||
479 | ||
480 | /* | |
c5aa993b JM |
481 | ** tuiAllSetHasBreakAt(). |
482 | ** Set or clear the hasBreak flag in all displayed source windows. | |
483 | */ | |
c906108c | 484 | void |
eca6576c | 485 | tuiAllSetHasBreakAt (struct breakpoint *bp, int hasBreak) |
c906108c SS |
486 | { |
487 | int i; | |
488 | ||
489 | for (i = 0; i < (sourceWindows ())->count; i++) | |
490 | tuiSetHasBreakAt (bp, | |
491 | (TuiWinInfoPtr) (sourceWindows ())->list[i], hasBreak); | |
492 | ||
493 | return; | |
494 | } /* tuiAllSetHasBreakAt */ | |
495 | ||
496 | ||
c906108c SS |
497 | /********************************* |
498 | ** EXECUTION INFO FUNCTIONS ** | |
499 | *********************************/ | |
500 | ||
501 | /* | |
c5aa993b JM |
502 | ** tuiSetExecInfoContent(). |
503 | ** Function to initialize the content of the execution info window, | |
504 | ** based upon the input window which is either the source or | |
505 | ** disassembly window. | |
506 | */ | |
c906108c | 507 | TuiStatus |
eca6576c | 508 | tuiSetExecInfoContent (TuiWinInfoPtr winInfo) |
c906108c SS |
509 | { |
510 | TuiStatus ret = TUI_SUCCESS; | |
511 | ||
512 | if (winInfo->detail.sourceInfo.executionInfo != (TuiGenWinInfoPtr) NULL) | |
513 | { | |
514 | TuiGenWinInfoPtr execInfoPtr = winInfo->detail.sourceInfo.executionInfo; | |
515 | ||
516 | if (execInfoPtr->content == (OpaquePtr) NULL) | |
517 | execInfoPtr->content = | |
518 | (OpaquePtr) allocContent (winInfo->generic.height, | |
519 | execInfoPtr->type); | |
520 | if (execInfoPtr->content != (OpaquePtr) NULL) | |
521 | { | |
522 | int i; | |
523 | ||
524 | for (i = 0; i < winInfo->generic.contentSize; i++) | |
525 | { | |
526 | TuiWinElementPtr element; | |
527 | TuiWinElementPtr srcElement; | |
528 | ||
529 | element = (TuiWinElementPtr) execInfoPtr->content[i]; | |
530 | srcElement = (TuiWinElementPtr) winInfo->generic.content[i]; | |
531 | /* | |
c5aa993b JM |
532 | ** First check to see if we have a breakpoint that is |
533 | ** temporary. If so, and this is our current execution point, | |
534 | ** then clear the break indicator. | |
535 | */ | |
c906108c SS |
536 | if (srcElement->whichElement.source.hasBreak && |
537 | srcElement->whichElement.source.isExecPoint) | |
538 | { | |
539 | struct breakpoint *bp; | |
540 | int found = FALSE; | |
541 | extern struct breakpoint *breakpoint_chain; | |
542 | ||
543 | for (bp = breakpoint_chain; | |
544 | (bp != (struct breakpoint *) NULL && !found); | |
545 | bp = bp->next) | |
546 | { | |
547 | found = | |
548 | (winInfo == srcWin && | |
549 | bp->line_number == | |
550 | srcElement->whichElement.source.lineOrAddr.lineNo) || | |
551 | (winInfo == disassemWin && | |
552 | bp->address == (CORE_ADDR) | |
553 | srcElement->whichElement.source.lineOrAddr.addr); | |
554 | if (found) | |
555 | srcElement->whichElement.source.hasBreak = | |
b5de0fa7 | 556 | (bp->disposition != disp_del || bp->hit_count <= 0); |
c906108c SS |
557 | } |
558 | if (!found) | |
559 | srcElement->whichElement.source.hasBreak = FALSE; | |
560 | } | |
561 | /* | |
c5aa993b JM |
562 | ** Now update the exec info content based upon the state |
563 | ** of each line as indicated by the source content. | |
564 | */ | |
c906108c SS |
565 | if (srcElement->whichElement.source.hasBreak && |
566 | srcElement->whichElement.source.isExecPoint) | |
567 | element->whichElement.simpleString = breakLocationStr (); | |
568 | else if (srcElement->whichElement.source.hasBreak) | |
569 | element->whichElement.simpleString = breakStr (); | |
570 | else if (srcElement->whichElement.source.isExecPoint) | |
571 | element->whichElement.simpleString = locationStr (); | |
572 | else | |
573 | element->whichElement.simpleString = blankStr (); | |
574 | } | |
575 | execInfoPtr->contentSize = winInfo->generic.contentSize; | |
576 | } | |
577 | else | |
578 | ret = TUI_FAILURE; | |
579 | } | |
580 | ||
581 | return ret; | |
582 | } /* tuiSetExecInfoContent */ | |
583 | ||
584 | ||
585 | /* | |
c5aa993b JM |
586 | ** tuiShowExecInfoContent(). |
587 | */ | |
c906108c | 588 | void |
eca6576c | 589 | tuiShowExecInfoContent (TuiWinInfoPtr winInfo) |
c906108c SS |
590 | { |
591 | TuiGenWinInfoPtr execInfo = winInfo->detail.sourceInfo.executionInfo; | |
592 | int curLine; | |
593 | ||
594 | werase (execInfo->handle); | |
595 | tuiRefreshWin (execInfo); | |
596 | for (curLine = 1; (curLine <= execInfo->contentSize); curLine++) | |
597 | mvwaddstr (execInfo->handle, | |
598 | curLine, | |
599 | 0, | |
600 | ((TuiWinElementPtr) | |
601 | execInfo->content[curLine - 1])->whichElement.simpleString); | |
602 | tuiRefreshWin (execInfo); | |
603 | execInfo->contentInUse = TRUE; | |
604 | ||
605 | return; | |
606 | } /* tuiShowExecInfoContent */ | |
607 | ||
608 | ||
609 | /* | |
c5aa993b JM |
610 | ** tuiShowAllExecInfosContent() |
611 | */ | |
c906108c | 612 | void |
c906108c | 613 | tuiShowAllExecInfosContent (void) |
c906108c SS |
614 | { |
615 | int i; | |
616 | ||
617 | for (i = 0; i < (sourceWindows ())->count; i++) | |
618 | tuiShowExecInfoContent ((TuiWinInfoPtr) (sourceWindows ())->list[i]); | |
619 | ||
620 | return; | |
621 | } /* tuiShowAllExecInfosContent */ | |
622 | ||
623 | ||
624 | /* | |
c5aa993b JM |
625 | ** tuiEraseExecInfoContent(). |
626 | */ | |
c906108c | 627 | void |
eca6576c | 628 | tuiEraseExecInfoContent (TuiWinInfoPtr winInfo) |
c906108c SS |
629 | { |
630 | TuiGenWinInfoPtr execInfo = winInfo->detail.sourceInfo.executionInfo; | |
631 | ||
632 | werase (execInfo->handle); | |
633 | tuiRefreshWin (execInfo); | |
634 | ||
635 | return; | |
636 | } /* tuiEraseExecInfoContent */ | |
637 | ||
c906108c | 638 | /* |
c5aa993b JM |
639 | ** tuiClearExecInfoContent(). |
640 | */ | |
c906108c | 641 | void |
eca6576c | 642 | tuiClearExecInfoContent (TuiWinInfoPtr winInfo) |
c906108c SS |
643 | { |
644 | winInfo->detail.sourceInfo.executionInfo->contentInUse = FALSE; | |
645 | tuiEraseExecInfoContent (winInfo); | |
646 | ||
647 | return; | |
648 | } /* tuiClearExecInfoContent */ | |
649 | ||
c906108c | 650 | /* |
c5aa993b JM |
651 | ** tuiUpdateExecInfo(). |
652 | ** Function to update the execution info window | |
653 | */ | |
c906108c | 654 | void |
eca6576c | 655 | tuiUpdateExecInfo (TuiWinInfoPtr winInfo) |
c906108c SS |
656 | { |
657 | tuiSetExecInfoContent (winInfo); | |
658 | tuiShowExecInfoContent (winInfo); | |
19eb139b | 659 | } /* tuiUpdateExecInfo */ |
c906108c SS |
660 | |
661 | ||
c5aa993b JM |
662 | /* |
663 | ** tuiUpdateAllExecInfos() | |
664 | */ | |
c906108c | 665 | void |
c906108c | 666 | tuiUpdateAllExecInfos (void) |
c906108c SS |
667 | { |
668 | int i; | |
669 | ||
670 | for (i = 0; i < (sourceWindows ())->count; i++) | |
671 | tuiUpdateExecInfo ((TuiWinInfoPtr) (sourceWindows ())->list[i]); | |
672 | ||
673 | return; | |
c5aa993b | 674 | } /* tuiUpdateAllExecInfos */ |
c906108c | 675 | |
c906108c | 676 | TuiStatus |
eca6576c | 677 | tuiAllocSourceBuffer (TuiWinInfoPtr winInfo) |
c906108c SS |
678 | { |
679 | register char *srcLine, *srcLineBuf; | |
680 | register int i, lineWidth, c, maxLines; | |
681 | TuiStatus ret = TUI_FAILURE; | |
682 | ||
683 | maxLines = winInfo->generic.height; /* less the highlight box */ | |
684 | lineWidth = winInfo->generic.width - 1; | |
685 | /* | |
c5aa993b JM |
686 | ** Allocate the buffer for the source lines. Do this only once since they |
687 | ** will be re-used for all source displays. The only other time this will | |
688 | ** be done is when a window's size changes. | |
689 | */ | |
c906108c SS |
690 | if (winInfo->generic.content == (OpaquePtr) NULL) |
691 | { | |
692 | srcLineBuf = (char *) xmalloc ((maxLines * lineWidth) * sizeof (char)); | |
693 | if (srcLineBuf == (char *) NULL) | |
694 | fputs_unfiltered ( | |
695 | "Unable to Allocate Memory for Source or Disassembly Display.\n", | |
696 | gdb_stderr); | |
697 | else | |
698 | { | |
699 | /* allocate the content list */ | |
700 | if ((winInfo->generic.content = | |
701 | (OpaquePtr) allocContent (maxLines, SRC_WIN)) == (OpaquePtr) NULL) | |
702 | { | |
703 | tuiFree (srcLineBuf); | |
704 | srcLineBuf = (char *) NULL; | |
705 | fputs_unfiltered ( | |
706 | "Unable to Allocate Memory for Source or Disassembly Display.\n", | |
707 | gdb_stderr); | |
708 | } | |
709 | } | |
710 | for (i = 0; i < maxLines; i++) | |
711 | ((TuiWinElementPtr) | |
712 | winInfo->generic.content[i])->whichElement.source.line = | |
713 | srcLineBuf + (lineWidth * i); | |
714 | ret = TUI_SUCCESS; | |
715 | } | |
716 | else | |
717 | ret = TUI_SUCCESS; | |
718 | ||
719 | return ret; | |
720 | } /* tuiAllocSourceBuffer */ | |
721 | ||
722 | ||
723 | /* | |
c5aa993b JM |
724 | ** tuiLineIsDisplayed(). |
725 | ** Answer whether the a particular line number or address is displayed | |
726 | ** in the current source window. | |
727 | */ | |
c906108c | 728 | int |
a4b99e53 | 729 | tuiLineIsDisplayed (int line, TuiWinInfoPtr winInfo, |
eca6576c | 730 | int checkThreshold) |
c906108c SS |
731 | { |
732 | int isDisplayed = FALSE; | |
733 | int i, threshold; | |
734 | ||
735 | if (checkThreshold) | |
736 | threshold = SCROLL_THRESHOLD; | |
737 | else | |
738 | threshold = 0; | |
739 | i = 0; | |
740 | while (i < winInfo->generic.contentSize - threshold && !isDisplayed) | |
741 | { | |
a4b99e53 SC |
742 | isDisplayed = (((TuiWinElementPtr) |
743 | winInfo->generic.content[i])->whichElement.source.lineOrAddr.lineNo | |
744 | == (int) line); | |
c906108c SS |
745 | i++; |
746 | } | |
747 | ||
748 | return isDisplayed; | |
749 | } /* tuiLineIsDisplayed */ | |
750 | ||
751 | ||
a4b99e53 SC |
752 | /* |
753 | ** tuiLineIsDisplayed(). | |
754 | ** Answer whether the a particular line number or address is displayed | |
755 | ** in the current source window. | |
756 | */ | |
757 | int | |
758 | tuiAddrIsDisplayed (CORE_ADDR addr, TuiWinInfoPtr winInfo, | |
759 | int checkThreshold) | |
760 | { | |
761 | int isDisplayed = FALSE; | |
762 | int i, threshold; | |
763 | ||
764 | if (checkThreshold) | |
765 | threshold = SCROLL_THRESHOLD; | |
766 | else | |
767 | threshold = 0; | |
768 | i = 0; | |
769 | while (i < winInfo->generic.contentSize - threshold && !isDisplayed) | |
770 | { | |
771 | isDisplayed = (((TuiWinElementPtr) | |
772 | winInfo->generic.content[i])->whichElement.source.lineOrAddr.addr | |
773 | == addr); | |
774 | i++; | |
775 | } | |
776 | ||
777 | return isDisplayed; | |
778 | } | |
779 | ||
780 | ||
c906108c SS |
781 | /***************************************** |
782 | ** STATIC LOCAL FUNCTIONS ** | |
783 | ******************************************/ |