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