OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [tui/] [tuiSourceWin.c] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.