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