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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [tui/] [tuiRegs.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
 
2
/*
3
   ** tuiRegs.c
4
   **         This module contains functions to support display of registers
5
   **         in the data window.
6
 */
7
 
8
 
9
#include "defs.h"
10
#include "tui.h"
11
#include "tuiData.h"
12
#include "symtab.h"
13
#include "gdbtypes.h"
14
#include "gdbcmd.h"
15
#include "frame.h"
16
#include "inferior.h"
17
#include "target.h"
18
#include "tuiLayout.h"
19
#include "tuiWin.h"
20
 
21
 
22
/*****************************************
23
** LOCAL DEFINITIONS                    **
24
******************************************/
25
#define DOUBLE_FLOAT_LABEL_WIDTH    6
26
#define DOUBLE_FLOAT_LABEL_FMT      "%6.6s: "
27
#define DOUBLE_FLOAT_VALUE_WIDTH    30  /*min of 16 but may be in sci notation */
28
 
29
#define SINGLE_FLOAT_LABEL_WIDTH    6
30
#define SINGLE_FLOAT_LABEL_FMT      "%6.6s: "
31
#define SINGLE_FLOAT_VALUE_WIDTH    25  /* min of 8 but may be in sci notation */
32
 
33
#define SINGLE_LABEL_WIDTH    10
34
#define SINGLE_LABEL_FMT      "%10.10s: "
35
#define SINGLE_VALUE_WIDTH    14        /* minimum of 8 but may be in sci notation */
36
 
37
/* In the code HP gave Cygnus, this was actually a function call to a
38
   PA-specific function, which was supposed to determine whether the
39
   target was a 64-bit or 32-bit processor.  However, the 64-bit
40
   support wasn't complete, so we didn't merge that in, so we leave
41
   this here as a stub.  */
42
#define IS_64BIT 0
43
 
44
/*****************************************
45
** STATIC DATA                          **
46
******************************************/
47
 
48
 
49
/*****************************************
50
** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
51
******************************************/
52
static TuiStatus _tuiSetRegsContent
53
  (int, int, struct frame_info *, TuiRegisterDisplayType, int);
54
static char *_tuiRegisterName (int);
55
static TuiStatus _tuiGetRegisterRawValue (int, char *, struct frame_info *);
56
static void _tuiSetRegisterElement
57
  (int, struct frame_info *, TuiDataElementPtr, int);
58
static void _tuiDisplayRegister (int, TuiGenWinInfoPtr, enum precision_type);
59
static void _tuiRegisterFormat
60
  (char *, int, int, TuiDataElementPtr, enum precision_type);
61
static TuiStatus _tuiSetGeneralRegsContent (int);
62
static TuiStatus _tuiSetSpecialRegsContent (int);
63
static TuiStatus _tuiSetGeneralAndSpecialRegsContent (int);
64
static TuiStatus _tuiSetFloatRegsContent (TuiRegisterDisplayType, int);
65
static int _tuiRegValueHasChanged
66
  (TuiDataElementPtr, struct frame_info *, char *);
67
static void _tuiShowFloat_command (char *, int);
68
static void _tuiShowGeneral_command (char *, int);
69
static void _tuiShowSpecial_command (char *, int);
70
static void _tui_vShowRegisters_commandSupport (va_list);
71
static void _tuiToggleFloatRegs_command (char *, int);
72
static void _tuiScrollRegsForward_command (char *, int);
73
static void _tuiScrollRegsBackward_command (char *, int);
74
static void _tui_vShowRegisters_commandSupport (va_list);
75
 
76
 
77
 
78
/*****************************************
79
** PUBLIC FUNCTIONS                     **
80
******************************************/
81
 
82
/*
83
   ** tuiLastRegsLineNo()
84
   **        Answer the number of the last line in the regs display.
85
   **        If there are no registers (-1) is returned.
86
 */
87
int
88
#ifdef __STDC__
89
tuiLastRegsLineNo (void)
90
#else
91
tuiLastRegsLineNo ()
92
#endif
93
{
94
  register int numLines = (-1);
95
 
96
  if (dataWin->detail.dataDisplayInfo.regsContentCount > 0)
97
    {
98
      numLines = (dataWin->detail.dataDisplayInfo.regsContentCount /
99
                  dataWin->detail.dataDisplayInfo.regsColumnCount);
100
      if (dataWin->detail.dataDisplayInfo.regsContentCount %
101
          dataWin->detail.dataDisplayInfo.regsColumnCount)
102
        numLines++;
103
    }
104
  return numLines;
105
}                               /* tuiLastRegsLineNo */
106
 
107
 
108
/*
109
   ** tuiLineFromRegElementNo()
110
   **        Answer the line number that the register element at elementNo is
111
   **        on.  If elementNo is greater than the number of register elements
112
   **        there are, -1 is returned.
113
 */
114
int
115
#ifdef __STDC__
116
tuiLineFromRegElementNo (
117
                          int elementNo)
118
#else
119
tuiLineFromRegElementNo (elementNo)
120
     int elementNo;
121
#endif
122
{
123
  if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
124
    {
125
      int i, line = (-1);
126
 
127
      i = 1;
128
      while (line == (-1))
129
        {
130
          if (elementNo <
131
              (dataWin->detail.dataDisplayInfo.regsColumnCount * i))
132
            line = i - 1;
133
          else
134
            i++;
135
        }
136
 
137
      return line;
138
    }
139
  else
140
    return (-1);
141
}                               /* tuiLineFromRegElementNo */
142
 
143
 
144
/*
145
   ** tuiFirstRegElementNoInLine()
146
   **        Answer the index of the first element in lineNo.  If lineNo is
147
   **        past the register area (-1) is returned.
148
 */
149
int
150
#ifdef __STDC__
151
tuiFirstRegElementNoInLine (
152
                             int lineNo)
153
#else
154
tuiFirstRegElementNoInLine (lineNo)
155
     int lineNo;
156
#endif
157
{
158
  if ((lineNo * dataWin->detail.dataDisplayInfo.regsColumnCount)
159
      <= dataWin->detail.dataDisplayInfo.regsContentCount)
160
    return ((lineNo + 1) *
161
            dataWin->detail.dataDisplayInfo.regsColumnCount) -
162
      dataWin->detail.dataDisplayInfo.regsColumnCount;
163
  else
164
    return (-1);
165
}                               /* tuiFirstRegElementNoInLine */
166
 
167
 
168
/*
169
   ** tuiLastRegElementNoInLine()
170
   **        Answer the index of the last element in lineNo.  If lineNo is past
171
   **        the register area (-1) is returned.
172
 */
173
int
174
#ifdef __STDC__
175
tuiLastRegElementNoInLine (
176
                            int lineNo)
177
#else
178
tuiLastRegElementNoInLine (lineNo)
179
     int lineNo;
180
#endif
181
{
182
  if ((lineNo * dataWin->detail.dataDisplayInfo.regsColumnCount) <=
183
      dataWin->detail.dataDisplayInfo.regsContentCount)
184
    return ((lineNo + 1) *
185
            dataWin->detail.dataDisplayInfo.regsColumnCount) - 1;
186
  else
187
    return (-1);
188
}                               /* tuiLastRegElementNoInLine */
189
 
190
 
191
/*
192
   ** tuiCalculateRegsColumnCount
193
   **        Calculate the number of columns that should be used to display
194
   **        the registers.
195
 */
196
int
197
#ifdef __STDC__
198
tuiCalculateRegsColumnCount (
199
                              TuiRegisterDisplayType dpyType)
200
#else
201
tuiCalculateRegsColumnCount (dpyType)
202
     TuiRegisterDisplayType dpyType;
203
#endif
204
{
205
  int colCount, colWidth;
206
 
207
  if (IS_64BIT || dpyType == TUI_DFLOAT_REGS)
208
    colWidth = DOUBLE_FLOAT_VALUE_WIDTH + DOUBLE_FLOAT_LABEL_WIDTH;
209
  else
210
    {
211
      if (dpyType == TUI_SFLOAT_REGS)
212
        colWidth = SINGLE_FLOAT_VALUE_WIDTH + SINGLE_FLOAT_LABEL_WIDTH;
213
      else
214
        colWidth = SINGLE_VALUE_WIDTH + SINGLE_LABEL_WIDTH;
215
    }
216
  colCount = (dataWin->generic.width - 2) / colWidth;
217
 
218
  return colCount;
219
}                               /* tuiCalulateRegsColumnCount */
220
 
221
 
222
/*
223
   ** tuiShowRegisters().
224
   **        Show the registers int the data window as indicated by dpyType.
225
   **        If there is any other registers being displayed, then they are
226
   **        cleared.  What registers are displayed is dependent upon dpyType.
227
 */
228
void
229
#ifdef __STDC__
230
tuiShowRegisters (
231
                   TuiRegisterDisplayType dpyType)
232
#else
233
tuiShowRegisters (dpyType)
234
     TuiRegisterDisplayType dpyType;
235
#endif
236
{
237
  TuiStatus ret = TUI_FAILURE;
238
  int refreshValuesOnly = FALSE;
239
 
240
  /* Say that registers should be displayed, even if there is a problem */
241
  dataWin->detail.dataDisplayInfo.displayRegs = TRUE;
242
 
243
  if (target_has_registers)
244
    {
245
      refreshValuesOnly =
246
        (dpyType == dataWin->detail.dataDisplayInfo.regsDisplayType);
247
      switch (dpyType)
248
        {
249
        case TUI_GENERAL_REGS:
250
          ret = _tuiSetGeneralRegsContent (refreshValuesOnly);
251
          break;
252
        case TUI_SFLOAT_REGS:
253
        case TUI_DFLOAT_REGS:
254
          ret = _tuiSetFloatRegsContent (dpyType, refreshValuesOnly);
255
          break;
256
 
257
/* could ifdef out */
258
 
259
        case TUI_SPECIAL_REGS:
260
          ret = _tuiSetSpecialRegsContent (refreshValuesOnly);
261
          break;
262
        case TUI_GENERAL_AND_SPECIAL_REGS:
263
          ret = _tuiSetGeneralAndSpecialRegsContent (refreshValuesOnly);
264
          break;
265
 
266
/* end of potential if def */
267
 
268
        default:
269
          break;
270
        }
271
    }
272
  if (ret == TUI_FAILURE)
273
    {
274
      dataWin->detail.dataDisplayInfo.regsDisplayType = TUI_UNDEFINED_REGS;
275
      tuiEraseDataContent (NO_REGS_STRING);
276
    }
277
  else
278
    {
279
      int i;
280
 
281
      /* Clear all notation of changed values */
282
      for (i = 0; (i < dataWin->detail.dataDisplayInfo.regsContentCount); i++)
283
        {
284
          TuiGenWinInfoPtr dataItemWin;
285
 
286
          dataItemWin = &dataWin->detail.dataDisplayInfo.
287
            regsContent[i]->whichElement.dataWindow;
288
          (&((TuiWinElementPtr)
289
             dataItemWin->content[0])->whichElement.data)->highlight = FALSE;
290
        }
291
      dataWin->detail.dataDisplayInfo.regsDisplayType = dpyType;
292
      tuiDisplayAllData ();
293
    }
294
  (tuiLayoutDef ())->regsDisplayType = dpyType;
295
 
296
  return;
297
}                               /* tuiShowRegisters */
298
 
299
 
300
/*
301
   ** tuiDisplayRegistersFrom().
302
   **        Function to display the registers in the content from
303
   **        'startElementNo' until the end of the register content or the
304
   **        end of the display height.  No checking for displaying past
305
   **        the end of the registers is done here.
306
 */
307
void
308
#ifdef __STDC__
309
tuiDisplayRegistersFrom (
310
                          int startElementNo)
311
#else
312
tuiDisplayRegistersFrom (startElementNo)
313
     int startElementNo;
314
#endif
315
{
316
  if (dataWin->detail.dataDisplayInfo.regsContent != (TuiWinContent) NULL &&
317
      dataWin->detail.dataDisplayInfo.regsContentCount > 0)
318
    {
319
      register int i = startElementNo;
320
      int j, valueCharsWide, charsWide, itemWinWidth, curY, labelWidth;
321
      enum precision_type precision;
322
 
323
      precision = (dataWin->detail.dataDisplayInfo.regsDisplayType
324
                   == TUI_DFLOAT_REGS) ?
325
        double_precision : unspecified_precision;
326
      if (IS_64BIT ||
327
          dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_DFLOAT_REGS)
328
        {
329
          valueCharsWide = DOUBLE_FLOAT_VALUE_WIDTH;
330
          labelWidth = DOUBLE_FLOAT_LABEL_WIDTH;
331
        }
332
      else
333
        {
334
          if (dataWin->detail.dataDisplayInfo.regsDisplayType ==
335
              TUI_SFLOAT_REGS)
336
            {
337
              valueCharsWide = SINGLE_FLOAT_VALUE_WIDTH;
338
              labelWidth = SINGLE_FLOAT_LABEL_WIDTH;
339
            }
340
          else
341
            {
342
              valueCharsWide = SINGLE_VALUE_WIDTH;
343
              labelWidth = SINGLE_LABEL_WIDTH;
344
            }
345
        }
346
      itemWinWidth = valueCharsWide + labelWidth;
347
      /*
348
         ** Now create each data "sub" window, and write the display into it.
349
       */
350
      curY = 1;
351
      while (i < dataWin->detail.dataDisplayInfo.regsContentCount &&
352
             curY <= dataWin->generic.viewportHeight)
353
        {
354
          for (j = 0;
355
               (j < dataWin->detail.dataDisplayInfo.regsColumnCount &&
356
                i < dataWin->detail.dataDisplayInfo.regsContentCount); j++)
357
            {
358
              TuiGenWinInfoPtr dataItemWin;
359
              TuiDataElementPtr dataElementPtr;
360
 
361
              /* create the window if necessary */
362
              dataItemWin = &dataWin->detail.dataDisplayInfo.
363
                regsContent[i]->whichElement.dataWindow;
364
              dataElementPtr = &((TuiWinElementPtr)
365
                                 dataItemWin->content[0])->whichElement.data;
366
              if (dataItemWin->handle == (WINDOW *) NULL)
367
                {
368
                  dataItemWin->height = 1;
369
                  dataItemWin->width = (precision == double_precision) ?
370
                    itemWinWidth + 2 : itemWinWidth + 1;
371
                  dataItemWin->origin.x = (itemWinWidth * j) + 1;
372
                  dataItemWin->origin.y = curY;
373
                  makeWindow (dataItemWin, DONT_BOX_WINDOW);
374
                }
375
              /*
376
                 ** Get the printable representation of the register
377
                 ** and display it
378
               */
379
              _tuiDisplayRegister (
380
                            dataElementPtr->itemNo, dataItemWin, precision);
381
              i++;              /* next register */
382
            }
383
          curY++;               /* next row; */
384
        }
385
    }
386
 
387
  return;
388
}                               /* tuiDisplayRegistersFrom */
389
 
390
 
391
/*
392
   ** tuiDisplayRegElementAtLine().
393
   **        Function to display the registers in the content from
394
   **        'startElementNo' on 'startLineNo' until the end of the
395
   **        register content or the end of the display height.
396
   **        This function checks that we won't display off the end
397
   **        of the register display.
398
 */
399
void
400
#ifdef __STDC__
401
tuiDisplayRegElementAtLine (
402
                             int startElementNo,
403
                             int startLineNo)
404
#else
405
tuiDisplayRegElementAtLine (startElementNo, startLineNo)
406
     int startElementNo;
407
     int startLineNo;
408
#endif
409
{
410
  if (dataWin->detail.dataDisplayInfo.regsContent != (TuiWinContent) NULL &&
411
      dataWin->detail.dataDisplayInfo.regsContentCount > 0)
412
    {
413
      register int elementNo = startElementNo;
414
 
415
      if (startElementNo != 0 && startLineNo != 0)
416
        {
417
          register int lastLineNo, firstLineOnLastPage;
418
 
419
          lastLineNo = tuiLastRegsLineNo ();
420
          firstLineOnLastPage = lastLineNo - (dataWin->generic.height - 2);
421
          if (firstLineOnLastPage < 0)
422
            firstLineOnLastPage = 0;
423
          /*
424
             ** If there is no other data displayed except registers,
425
             ** and the elementNo causes us to scroll past the end of the
426
             ** registers, adjust what element to really start the display at.
427
           */
428
          if (dataWin->detail.dataDisplayInfo.dataContentCount <= 0 &&
429
              startLineNo > firstLineOnLastPage)
430
            elementNo = tuiFirstRegElementNoInLine (firstLineOnLastPage);
431
        }
432
      tuiDisplayRegistersFrom (elementNo);
433
    }
434
 
435
  return;
436
}                               /* tuiDisplayRegElementAtLine */
437
 
438
 
439
 
440
/*
441
   ** tuiDisplayRegistersFromLine().
442
   **        Function to display the registers starting at line lineNo in
443
   **        the data window.  Answers the line number that the display
444
   **        actually started from.  If nothing is displayed (-1) is returned.
445
 */
446
int
447
#ifdef __STDC__
448
tuiDisplayRegistersFromLine (
449
                              int lineNo,
450
                              int forceDisplay)
451
#else
452
tuiDisplayRegistersFromLine (lineNo, forceDisplay)
453
     int lineNo;
454
     int forceDisplay;
455
#endif
456
{
457
  int elementNo;
458
 
459
  if (dataWin->detail.dataDisplayInfo.regsContentCount > 0)
460
    {
461
      int line, elementNo;
462
 
463
      if (lineNo < 0)
464
        line = 0;
465
      else if (forceDisplay)
466
        {                       /*
467
                                   ** If we must display regs (forceDisplay is true), then make
468
                                   ** sure that we don't display off the end of the registers.
469
                                 */
470
          if (lineNo >= tuiLastRegsLineNo ())
471
            {
472
              if ((line = tuiLineFromRegElementNo (
473
                 dataWin->detail.dataDisplayInfo.regsContentCount - 1)) < 0)
474
                line = 0;
475
            }
476
          else
477
            line = lineNo;
478
        }
479
      else
480
        line = lineNo;
481
 
482
      elementNo = tuiFirstRegElementNoInLine (line);
483
      if (elementNo < dataWin->detail.dataDisplayInfo.regsContentCount)
484
        tuiDisplayRegElementAtLine (elementNo, line);
485
      else
486
        line = (-1);
487
 
488
      return line;
489
    }
490
 
491
  return (-1);                  /* nothing was displayed */
492
}                               /* tuiDisplayRegistersFromLine */
493
 
494
 
495
/*
496
   ** tuiCheckRegisterValues()
497
   **        This function check all displayed registers for changes in
498
   **        values, given a particular frame.  If the values have changed,
499
   **        they are updated with the new value and highlighted.
500
 */
501
void
502
#ifdef __STDC__
503
tuiCheckRegisterValues (
504
                         struct frame_info *frame)
505
#else
506
tuiCheckRegisterValues (frame)
507
     struct frame_info *frame;
508
#endif
509
{
510
  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
511
    {
512
      if (dataWin->detail.dataDisplayInfo.regsContentCount <= 0 &&
513
          dataWin->detail.dataDisplayInfo.displayRegs)
514
        tuiShowRegisters ((tuiLayoutDef ())->regsDisplayType);
515
      else
516
        {
517
          int i, j;
518
          char rawBuf[MAX_REGISTER_RAW_SIZE];
519
 
520
          for (i = 0;
521
               (i < dataWin->detail.dataDisplayInfo.regsContentCount); i++)
522
            {
523
              TuiDataElementPtr dataElementPtr;
524
              TuiGenWinInfoPtr dataItemWinPtr;
525
              int wasHilighted;
526
 
527
              dataItemWinPtr = &dataWin->detail.dataDisplayInfo.
528
                regsContent[i]->whichElement.dataWindow;
529
              dataElementPtr = &((TuiWinElementPtr)
530
                             dataItemWinPtr->content[0])->whichElement.data;
531
              wasHilighted = dataElementPtr->highlight;
532
              dataElementPtr->highlight =
533
                _tuiRegValueHasChanged (dataElementPtr, frame, &rawBuf[0]);
534
              if (dataElementPtr->highlight)
535
                {
536
                  for (j = 0; j < MAX_REGISTER_RAW_SIZE; j++)
537
                    ((char *) dataElementPtr->value)[j] = rawBuf[j];
538
                  _tuiDisplayRegister (
539
                                        dataElementPtr->itemNo,
540
                                        dataItemWinPtr,
541
                        ((dataWin->detail.dataDisplayInfo.regsDisplayType ==
542
                          TUI_DFLOAT_REGS) ?
543
                         double_precision : unspecified_precision));
544
                }
545
              else if (wasHilighted)
546
                {
547
                  dataElementPtr->highlight = FALSE;
548
                  _tuiDisplayRegister (
549
                                        dataElementPtr->itemNo,
550
                                        dataItemWinPtr,
551
                        ((dataWin->detail.dataDisplayInfo.regsDisplayType ==
552
                          TUI_DFLOAT_REGS) ?
553
                         double_precision : unspecified_precision));
554
                }
555
            }
556
        }
557
    }
558
  return;
559
}                               /* tuiCheckRegisterValues */
560
 
561
 
562
/*
563
   ** tuiToggleFloatRegs().
564
 */
565
void
566
#ifdef __STDC__
567
tuiToggleFloatRegs (void)
568
#else
569
tuiToggleFloatRegs ()
570
#endif
571
{
572
  TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
573
 
574
  if (layoutDef->floatRegsDisplayType == TUI_SFLOAT_REGS)
575
    layoutDef->floatRegsDisplayType = TUI_DFLOAT_REGS;
576
  else
577
    layoutDef->floatRegsDisplayType = TUI_SFLOAT_REGS;
578
 
579
  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible &&
580
      (dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_SFLOAT_REGS ||
581
       dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_DFLOAT_REGS))
582
    tuiShowRegisters (layoutDef->floatRegsDisplayType);
583
 
584
  return;
585
}                               /* tuiToggleFloatRegs */
586
 
587
 
588
void
589
_initialize_tuiRegs (void)
590
{
591
  if (tui_version && xdb_commands)
592
    {
593
      add_com ("fr", class_tui, _tuiShowFloat_command,
594
               "Display only floating point registers\n");
595
      add_com ("gr", class_tui, _tuiShowGeneral_command,
596
               "Display only general registers\n");
597
      add_com ("sr", class_tui, _tuiShowSpecial_command,
598
               "Display only special registers\n");
599
      add_com ("+r", class_tui, _tuiScrollRegsForward_command,
600
               "Scroll the registers window forward\n");
601
      add_com ("-r", class_tui, _tuiScrollRegsBackward_command,
602
               "Scroll the register window backward\n");
603
      add_com ("tf", class_tui, _tuiToggleFloatRegs_command,
604
               "Toggle between single and double precision floating point registers.\n");
605
      add_cmd (TUI_FLOAT_REGS_NAME_LOWER,
606
               class_tui,
607
               _tuiToggleFloatRegs_command,
608
               "Toggle between single and double precision floating point \
609
registers.\n",
610
               &togglelist);
611
    }
612
 
613
  return;
614
}                               /* _initialize_tuiRegs */
615
 
616
 
617
/*****************************************
618
** STATIC LOCAL FUNCTIONS                 **
619
******************************************/
620
 
621
 
622
/*
623
   ** _tuiRegisterName().
624
   **        Return the register name.
625
 */
626
static char *
627
#ifdef __STDC__
628
_tuiRegisterName (
629
                   int regNum)
630
#else
631
_tuiRegisterName (regNum)
632
     int regNum;
633
#endif
634
{
635
  if (reg_names[regNum] != (char *) NULL && *(reg_names[regNum]) != (char) 0)
636
    return reg_names[regNum];
637
  else
638
    return ((char *) NULL);
639
}                               /* tuiGetRegisterName */
640
 
641
 
642
/*
643
   ** _tuiRegisterFormat
644
   **        Function to format the register name and value into a buffer,
645
   **        suitable for printing or display
646
 */
647
static void
648
#ifdef __STDC__
649
_tuiRegisterFormat (
650
                     char *buf,
651
                     int bufLen,
652
                     int regNum,
653
                     TuiDataElementPtr dataElement,
654
                     enum precision_type precision)
655
#else
656
_tuiRegisterFormat (buf, bufLen, regNum, dataElement, precision)
657
     char *buf;
658
     int bufLen;
659
     int regNum;
660
     TuiDataElementPtr dataElement;
661
     enum precision_type precision;
662
#endif
663
{
664
  char tmpBuf[15];
665
  char *fmt;
666
  struct ui_file *stream;
667
 
668
  stream = tui_sfileopen (bufLen);
669
  pa_do_strcat_registers_info (regNum, 0, stream, precision);
670
  strcpy (buf, tui_file_get_strbuf (stream));
671
  ui_file_delete (stream);
672
 
673
  return;
674
}                               /* _tuiRegisterFormat */
675
 
676
 
677
#define NUM_GENERAL_REGS    32
678
/*
679
   ** _tuiSetGeneralRegsContent().
680
   **      Set the content of the data window to consist of the general registers.
681
 */
682
static TuiStatus
683
#ifdef __STDC__
684
_tuiSetGeneralRegsContent (
685
                            int refreshValuesOnly)
686
#else
687
_tuiSetGeneralRegsContent (refreshValuesOnly)
688
     int refreshValuesOnly;
689
#endif
690
{
691
  return (_tuiSetRegsContent (0,
692
                              NUM_GENERAL_REGS - 1,
693
                              selected_frame,
694
                              TUI_GENERAL_REGS,
695
                              refreshValuesOnly));
696
 
697
}                               /* _tuiSetGeneralRegsContent */
698
 
699
 
700
#define START_SPECIAL_REGS    PCOQ_HEAD_REGNUM
701
/*
702
   ** _tuiSetSpecialRegsContent().
703
   **      Set the content of the data window to consist of the special registers.
704
 */
705
static TuiStatus
706
#ifdef __STDC__
707
_tuiSetSpecialRegsContent (
708
                            int refreshValuesOnly)
709
#else
710
_tuiSetSpecialRegsContent (refreshValuesOnly)
711
     int refreshValuesOnly;
712
#endif
713
{
714
  TuiStatus ret = TUI_FAILURE;
715
  int i, endRegNum;
716
 
717
  endRegNum = FP0_REGNUM - 1;
718
#if 0
719
  endRegNum = (-1);
720
  for (i = START_SPECIAL_REGS; (i < NUM_REGS && endRegNum < 0); i++)
721
    if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
722
      endRegNum = i - 1;
723
#endif
724
  ret = _tuiSetRegsContent (START_SPECIAL_REGS,
725
                            endRegNum,
726
                            selected_frame,
727
                            TUI_SPECIAL_REGS,
728
                            refreshValuesOnly);
729
 
730
  return ret;
731
}                               /* _tuiSetSpecialRegsContent */
732
 
733
 
734
/*
735
   ** _tuiSetGeneralAndSpecialRegsContent().
736
   **      Set the content of the data window to consist of the special registers.
737
 */
738
static TuiStatus
739
#ifdef __STDC__
740
_tuiSetGeneralAndSpecialRegsContent (
741
                                      int refreshValuesOnly)
742
#else
743
_tuiSetGeneralAndSpecialRegsContent (refreshValuesOnly)
744
     int refreshValuesOnly;
745
#endif
746
{
747
  TuiStatus ret = TUI_FAILURE;
748
  int i, endRegNum = (-1);
749
 
750
  endRegNum = FP0_REGNUM - 1;
751
#if 0
752
  endRegNum = (-1);
753
  for (i = 0; (i < NUM_REGS && endRegNum < 0); i++)
754
    if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
755
      endRegNum = i - 1;
756
#endif
757
  ret = _tuiSetRegsContent (
758
         0, endRegNum, selected_frame, TUI_SPECIAL_REGS, refreshValuesOnly);
759
 
760
  return ret;
761
}                               /* _tuiSetGeneralAndSpecialRegsContent */
762
 
763
/*
764
   ** _tuiSetFloatRegsContent().
765
   **        Set the content of the data window to consist of the float registers.
766
 */
767
static TuiStatus
768
#ifdef __STDC__
769
_tuiSetFloatRegsContent (
770
                          TuiRegisterDisplayType dpyType,
771
                          int refreshValuesOnly)
772
#else
773
_tuiSetFloatRegsContent (dpyType, refreshValuesOnly)
774
     TuiRegisterDisplayType dpyType;
775
     int refreshValuesOnly;
776
#endif
777
{
778
  TuiStatus ret = TUI_FAILURE;
779
  int i, startRegNum;
780
 
781
  startRegNum = FP0_REGNUM;
782
#if 0
783
  startRegNum = (-1);
784
  for (i = NUM_REGS - 1; (i >= 0 && startRegNum < 0); i--)
785
    if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) != TYPE_CODE_FLT)
786
      startRegNum = i + 1;
787
#endif
788
  ret = _tuiSetRegsContent (startRegNum,
789
                            NUM_REGS - 1,
790
                            selected_frame,
791
                            dpyType,
792
                            refreshValuesOnly);
793
 
794
  return ret;
795
}                               /* _tuiSetFloatRegsContent */
796
 
797
 
798
/*
799
   ** _tuiRegValueHasChanged().
800
   **        Answer TRUE if the register's value has changed, FALSE otherwise.
801
   **        If TRUE, newValue is filled in with the new value.
802
 */
803
static int
804
#ifdef __STDC__
805
_tuiRegValueHasChanged (
806
                         TuiDataElementPtr dataElement,
807
                         struct frame_info *frame,
808
                         char *newValue)
809
#else
810
_tuiRegValueHasChanged (dataElement, frame, newValue)
811
     TuiDataElementPtr dataElement;
812
     struct frame_info *frame;
813
     char *newValue;
814
#endif
815
{
816
  int hasChanged = FALSE;
817
 
818
  if (dataElement->itemNo != UNDEFINED_ITEM &&
819
      _tuiRegisterName (dataElement->itemNo) != (char *) NULL)
820
    {
821
      char rawBuf[MAX_REGISTER_RAW_SIZE];
822
      int i;
823
 
824
      if (_tuiGetRegisterRawValue (
825
                         dataElement->itemNo, rawBuf, frame) == TUI_SUCCESS)
826
        {
827
          for (i = 0; (i < MAX_REGISTER_RAW_SIZE && !hasChanged); i++)
828
            hasChanged = (((char *) dataElement->value)[i] != rawBuf[i]);
829
          if (hasChanged && newValue != (char *) NULL)
830
            {
831
              for (i = 0; (i < MAX_REGISTER_RAW_SIZE); i++)
832
                newValue[i] = rawBuf[i];
833
            }
834
        }
835
    }
836
  return hasChanged;
837
}                               /* _tuiRegValueHasChanged */
838
 
839
 
840
 
841
/*
842
   ** _tuiGetRegisterRawValue().
843
   **        Get the register raw value.  The raw value is returned in regValue.
844
 */
845
static TuiStatus
846
#ifdef __STDC__
847
_tuiGetRegisterRawValue (
848
                          int regNum,
849
                          char *regValue,
850
                          struct frame_info *frame)
851
#else
852
_tuiGetRegisterRawValue (regNum, regValue, frame)
853
     int regNum;
854
     char *regValue;
855
     struct frame_info *frame;
856
#endif
857
{
858
  TuiStatus ret = TUI_FAILURE;
859
 
860
  if (target_has_registers)
861
    {
862
      read_relative_register_raw_bytes_for_frame (regNum, regValue, frame);
863
      ret = TUI_SUCCESS;
864
    }
865
 
866
  return ret;
867
}                               /* _tuiGetRegisterRawValue */
868
 
869
 
870
 
871
/*
872
   ** _tuiSetRegisterElement().
873
   **       Function to initialize a data element with the input and
874
   **       the register value.
875
 */
876
static void
877
#ifdef __STDC__
878
_tuiSetRegisterElement (
879
                         int regNum,
880
                         struct frame_info *frame,
881
                         TuiDataElementPtr dataElement,
882
                         int refreshValueOnly)
883
#else
884
_tuiSetRegisterElement (regNum, frame, dataElement, refreshValueOnly)
885
     int regNum;
886
     struct frame_info *frame;
887
     TuiDataElementPtr dataElement;
888
     int refreshValueOnly;
889
#endif
890
{
891
  if (dataElement != (TuiDataElementPtr) NULL)
892
    {
893
      if (!refreshValueOnly)
894
        {
895
          dataElement->itemNo = regNum;
896
          dataElement->name = _tuiRegisterName (regNum);
897
          dataElement->highlight = FALSE;
898
        }
899
      if (dataElement->value == (Opaque) NULL)
900
        dataElement->value = (Opaque) xmalloc (MAX_REGISTER_RAW_SIZE);
901
      if (dataElement->value != (Opaque) NULL)
902
        _tuiGetRegisterRawValue (regNum, dataElement->value, frame);
903
    }
904
 
905
  return;
906
}                               /* _tuiSetRegisterElement */
907
 
908
 
909
/*
910
   ** _tuiSetRegsContent().
911
   **        Set the content of the data window to consist of the registers
912
   **        numbered from startRegNum to endRegNum.  Note that if
913
   **        refreshValuesOnly is TRUE, startRegNum and endRegNum are ignored.
914
 */
915
static TuiStatus
916
#ifdef __STDC__
917
_tuiSetRegsContent (
918
                     int startRegNum,
919
                     int endRegNum,
920
                     struct frame_info *frame,
921
                     TuiRegisterDisplayType dpyType,
922
                     int refreshValuesOnly)
923
#else
924
_tuiSetRegsContent (startRegNum, endRegNum, frame, dpyType, refreshValuesOnly)
925
     int startRegNum;
926
     int endRegNum;
927
     struct frame_info *frame;
928
     TuiRegisterDisplayType dpyType;
929
     int refreshValuesOnly;
930
#endif
931
{
932
  TuiStatus ret = TUI_FAILURE;
933
  int numRegs = endRegNum - startRegNum + 1;
934
  int allocatedHere = FALSE;
935
 
936
  if (dataWin->detail.dataDisplayInfo.regsContentCount > 0 &&
937
      !refreshValuesOnly)
938
    {
939
      freeDataContent (dataWin->detail.dataDisplayInfo.regsContent,
940
                       dataWin->detail.dataDisplayInfo.regsContentCount);
941
      dataWin->detail.dataDisplayInfo.regsContentCount = 0;
942
    }
943
  if (dataWin->detail.dataDisplayInfo.regsContentCount <= 0)
944
    {
945
      dataWin->detail.dataDisplayInfo.regsContent =
946
        allocContent (numRegs, DATA_WIN);
947
      allocatedHere = TRUE;
948
    }
949
 
950
  if (dataWin->detail.dataDisplayInfo.regsContent != (TuiWinContent) NULL)
951
    {
952
      int i;
953
 
954
      if (!refreshValuesOnly || allocatedHere)
955
        {
956
          dataWin->generic.content = (OpaquePtr) NULL;
957
          dataWin->generic.contentSize = 0;
958
          addContentElements (&dataWin->generic, numRegs);
959
          dataWin->detail.dataDisplayInfo.regsContent =
960
            (TuiWinContent) dataWin->generic.content;
961
          dataWin->detail.dataDisplayInfo.regsContentCount = numRegs;
962
        }
963
      /*
964
         ** Now set the register names and values
965
       */
966
      for (i = startRegNum; (i <= endRegNum); i++)
967
        {
968
          TuiGenWinInfoPtr dataItemWin;
969
 
970
          dataItemWin = &dataWin->detail.dataDisplayInfo.
971
            regsContent[i - startRegNum]->whichElement.dataWindow;
972
          _tuiSetRegisterElement (
973
                                   i,
974
                                   frame,
975
           &((TuiWinElementPtr) dataItemWin->content[0])->whichElement.data,
976
                                   !allocatedHere && refreshValuesOnly);
977
        }
978
      dataWin->detail.dataDisplayInfo.regsColumnCount =
979
        tuiCalculateRegsColumnCount (dpyType);
980
#ifdef LATER
981
      if (dataWin->detail.dataDisplayInfo.dataContentCount > 0)
982
        {
983
          /* delete all the windows? */
984
          /* realloc content equal to dataContentCount + regsContentCount */
985
          /* append dataWin->detail.dataDisplayInfo.dataContent to content */
986
        }
987
#endif
988
      dataWin->generic.contentSize =
989
        dataWin->detail.dataDisplayInfo.regsContentCount +
990
        dataWin->detail.dataDisplayInfo.dataContentCount;
991
      ret = TUI_SUCCESS;
992
    }
993
 
994
  return ret;
995
}                               /* _tuiSetRegsContent */
996
 
997
 
998
/*
999
   ** _tuiDisplayRegister().
1000
   **        Function to display a register in a window.  If hilite is TRUE,
1001
   **        than the value will be displayed in reverse video
1002
 */
1003
static void
1004
#ifdef __STDC__
1005
_tuiDisplayRegister (
1006
                      int regNum,
1007
                      TuiGenWinInfoPtr winInfo,         /* the data item window */
1008
                      enum precision_type precision)
1009
#else
1010
_tuiDisplayRegister (regNum, winInfo, precision)
1011
     int regNum;
1012
     TuiGenWinInfoPtr winInfo;  /* the data item window */
1013
     enum precision_type precision;
1014
#endif
1015
{
1016
  if (winInfo->handle != (WINDOW *) NULL)
1017
    {
1018
      char buf[100];
1019
      int valueCharsWide, labelWidth;
1020
      TuiDataElementPtr dataElementPtr = &((TuiWinContent)
1021
                                    winInfo->content)[0]->whichElement.data;
1022
 
1023
      if (IS_64BIT ||
1024
          dataWin->detail.dataDisplayInfo.regsDisplayType == TUI_DFLOAT_REGS)
1025
        {
1026
          valueCharsWide = DOUBLE_FLOAT_VALUE_WIDTH;
1027
          labelWidth = DOUBLE_FLOAT_LABEL_WIDTH;
1028
        }
1029
      else
1030
        {
1031
          if (dataWin->detail.dataDisplayInfo.regsDisplayType ==
1032
              TUI_SFLOAT_REGS)
1033
            {
1034
              valueCharsWide = SINGLE_FLOAT_VALUE_WIDTH;
1035
              labelWidth = SINGLE_FLOAT_LABEL_WIDTH;
1036
            }
1037
          else
1038
            {
1039
              valueCharsWide = SINGLE_VALUE_WIDTH;
1040
              labelWidth = SINGLE_LABEL_WIDTH;
1041
            }
1042
        }
1043
 
1044
      buf[0] = (char) 0;
1045
      _tuiRegisterFormat (buf,
1046
                          valueCharsWide + labelWidth,
1047
                          regNum,
1048
                          dataElementPtr,
1049
                          precision);
1050
      if (dataElementPtr->highlight)
1051
        wstandout (winInfo->handle);
1052
 
1053
      werase (winInfo->handle);
1054
      wmove (winInfo->handle, 0, 0);
1055
      waddstr (winInfo->handle, buf);
1056
 
1057
      if (dataElementPtr->highlight)
1058
        wstandend (winInfo->handle);
1059
      tuiRefreshWin (winInfo);
1060
    }
1061
  return;
1062
}                               /* _tuiDisplayRegister */
1063
 
1064
 
1065
static void
1066
#ifdef __STDC__
1067
_tui_vShowRegisters_commandSupport (
1068
                                     va_list args)
1069
#else
1070
_tui_vShowRegisters_commandSupport (args)
1071
     va_list args;
1072
#endif
1073
{
1074
  TuiRegisterDisplayType dpyType = va_arg (args, TuiRegisterDisplayType);
1075
 
1076
  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
1077
    {                           /* Data window already displayed, show the registers */
1078
      if (dataWin->detail.dataDisplayInfo.regsDisplayType != dpyType)
1079
        tuiShowRegisters (dpyType);
1080
    }
1081
  else
1082
    (tuiLayoutDef ())->regsDisplayType = dpyType;
1083
 
1084
  return;
1085
}                               /* _tui_vShowRegisters_commandSupport */
1086
 
1087
 
1088
static void
1089
#ifdef __STDC__
1090
_tuiShowFloat_command (
1091
                        char *arg,
1092
                        int fromTTY)
1093
#else
1094
_tuiShowFloat_command (arg, fromTTY)
1095
     char *arg;
1096
     int fromTTY;
1097
#endif
1098
{
1099
  if (m_winPtrIsNull (dataWin) || !dataWin->generic.isVisible ||
1100
      (dataWin->detail.dataDisplayInfo.regsDisplayType != TUI_SFLOAT_REGS &&
1101
       dataWin->detail.dataDisplayInfo.regsDisplayType != TUI_DFLOAT_REGS))
1102
    tuiDo ((TuiOpaqueFuncPtr) _tui_vShowRegisters_commandSupport,
1103
           (tuiLayoutDef ())->floatRegsDisplayType);
1104
 
1105
  return;
1106
}                               /* _tuiShowFloat_command */
1107
 
1108
 
1109
static void
1110
#ifdef __STDC__
1111
_tuiShowGeneral_command (
1112
                          char *arg,
1113
                          int fromTTY)
1114
#else
1115
_tuiShowGeneral_command (arg, fromTTY)
1116
     char *arg;
1117
     int fromTTY;
1118
#endif
1119
{
1120
  tuiDo ((TuiOpaqueFuncPtr) _tui_vShowRegisters_commandSupport,
1121
         TUI_GENERAL_REGS);
1122
 
1123
  return;
1124
}                               /* _tuiShowGeneral_command */
1125
 
1126
 
1127
static void
1128
#ifdef __STDC__
1129
_tuiShowSpecial_command (
1130
                          char *arg,
1131
                          int fromTTY)
1132
#else
1133
_tuiShowSpecial_command (arg, fromTTY)
1134
     char *arg;
1135
     int fromTTY;
1136
#endif
1137
{
1138
  tuiDo ((TuiOpaqueFuncPtr) _tui_vShowRegisters_commandSupport,
1139
         TUI_SPECIAL_REGS);
1140
 
1141
  return;
1142
}                               /* _tuiShowSpecial_command */
1143
 
1144
 
1145
static void
1146
#ifdef __STDC__
1147
_tuiToggleFloatRegs_command (
1148
                              char *arg,
1149
                              int fromTTY)
1150
#else
1151
_tuiToggleFloatRegs_command (arg, fromTTY)
1152
     char *arg;
1153
     int fromTTY;
1154
#endif
1155
{
1156
  if (m_winPtrNotNull (dataWin) && dataWin->generic.isVisible)
1157
    tuiDo ((TuiOpaqueFuncPtr) tuiToggleFloatRegs);
1158
  else
1159
    {
1160
      TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
1161
 
1162
      if (layoutDef->floatRegsDisplayType == TUI_SFLOAT_REGS)
1163
        layoutDef->floatRegsDisplayType = TUI_DFLOAT_REGS;
1164
      else
1165
        layoutDef->floatRegsDisplayType = TUI_SFLOAT_REGS;
1166
    }
1167
 
1168
 
1169
  return;
1170
}                               /* _tuiToggleFloatRegs_command */
1171
 
1172
 
1173
static void
1174
#ifdef __STDC__
1175
_tuiScrollRegsForward_command (
1176
                                char *arg,
1177
                                int fromTTY)
1178
#else
1179
_tuiScrollRegsForward_command (arg, fromTTY)
1180
     char *arg;
1181
     int fromTTY;
1182
#endif
1183
{
1184
  tuiDo ((TuiOpaqueFuncPtr) tui_vScroll, FORWARD_SCROLL, dataWin, 1);
1185
 
1186
  return;
1187
}                               /* _tuiScrollRegsForward_command */
1188
 
1189
 
1190
static void
1191
#ifdef __STDC__
1192
_tuiScrollRegsBackward_command (
1193
                                 char *arg,
1194
                                 int fromTTY)
1195
#else
1196
_tuiScrollRegsBackward_command (arg, fromTTY)
1197
     char *arg;
1198
     int fromTTY;
1199
#endif
1200
{
1201
  tuiDo ((TuiOpaqueFuncPtr) tui_vScroll, BACKWARD_SCROLL, dataWin, 1);
1202
 
1203
  return;
1204
}                               /* _tuiScrollRegsBackward_command */

powered by: WebSVN 2.1.0

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