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