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