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