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