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