1 /* TUI display registers in window.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
5 This file is part of GDB.
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.
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.
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. */
22 /* If we need <curses.h>, we must include it before we get "bfd.h". */
41 #include "tuiLayout.h"
43 #include "tuiDataWin.h"
44 #include "tuiGeneralWin.h"
47 /*****************************************
48 ** LOCAL DEFINITIONS **
49 ******************************************/
50 #define DOUBLE_FLOAT_LABEL_WIDTH 6
51 #define DOUBLE_FLOAT_LABEL_FMT "%6.6s: "
52 #define DOUBLE_FLOAT_VALUE_WIDTH 30 /*min of 16 but may be in sci notation */
54 #define SINGLE_FLOAT_LABEL_WIDTH 6
55 #define SINGLE_FLOAT_LABEL_FMT "%6.6s: "
56 #define SINGLE_FLOAT_VALUE_WIDTH 25 /* min of 8 but may be in sci notation */
58 #define SINGLE_LABEL_WIDTH 16
59 #define SINGLE_LABEL_FMT "%10.10s: "
60 #define SINGLE_VALUE_WIDTH 20 /* minimum of 8 but may be in sci notation */
62 /* In the code HP gave Cygnus, this was actually a function call to a
63 PA-specific function, which was supposed to determine whether the
64 target was a 64-bit or 32-bit processor. However, the 64-bit
65 support wasn't complete, so we didn't merge that in, so we leave
66 this here as a stub. */
69 /*****************************************
71 ******************************************/
74 /*****************************************
75 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
76 ******************************************/
77 static TuiStatus _tuiSetRegsContent
78 (int, int, struct frame_info
*, TuiRegisterDisplayType
, int);
79 static char *_tuiRegisterName (int);
80 static TuiStatus
_tuiGetRegisterRawValue (int, char *, struct frame_info
*);
81 static void _tuiSetRegisterElement
82 (int, struct frame_info
*, TuiDataElementPtr
, int);
83 static void _tuiDisplayRegister (int, TuiGenWinInfoPtr
, enum precision_type
);
84 static void _tuiRegisterFormat
85 (char *, int, int, TuiDataElementPtr
, enum precision_type
);
86 static TuiStatus
_tuiSetGeneralRegsContent (int);
87 static TuiStatus
_tuiSetSpecialRegsContent (int);
88 static TuiStatus
_tuiSetGeneralAndSpecialRegsContent (int);
89 static TuiStatus
_tuiSetFloatRegsContent (TuiRegisterDisplayType
, int);
90 static int _tuiRegValueHasChanged
91 (TuiDataElementPtr
, struct frame_info
*, char *);
92 static void _tuiShowFloat_command (char *, int);
93 static void _tuiShowGeneral_command (char *, int);
94 static void _tuiShowSpecial_command (char *, int);
95 static void _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType
);
96 static void _tuiToggleFloatRegs_command (char *, int);
97 static void _tuiScrollRegsForward_command (char *, int);
98 static void _tuiScrollRegsBackward_command (char *, int);
102 /*****************************************
103 ** PUBLIC FUNCTIONS **
104 ******************************************/
107 ** tuiLastRegsLineNo()
108 ** Answer the number of the last line in the regs display.
109 ** If there are no registers (-1) is returned.
112 tuiLastRegsLineNo (void)
114 register int numLines
= (-1);
116 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
118 numLines
= (dataWin
->detail
.dataDisplayInfo
.regsContentCount
/
119 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
);
120 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
%
121 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
125 } /* tuiLastRegsLineNo */
129 ** tuiLineFromRegElementNo()
130 ** Answer the line number that the register element at elementNo is
131 ** on. If elementNo is greater than the number of register elements
132 ** there are, -1 is returned.
135 tuiLineFromRegElementNo (int elementNo
)
137 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
145 (dataWin
->detail
.dataDisplayInfo
.regsColumnCount
* i
))
155 } /* tuiLineFromRegElementNo */
159 ** tuiFirstRegElementNoInLine()
160 ** Answer the index of the first element in lineNo. If lineNo is
161 ** past the register area (-1) is returned.
164 tuiFirstRegElementNoInLine (int lineNo
)
166 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
167 <= dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
168 return ((lineNo
+ 1) *
169 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) -
170 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
;
173 } /* tuiFirstRegElementNoInLine */
177 ** tuiLastRegElementNoInLine()
178 ** Answer the index of the last element in lineNo. If lineNo is past
179 ** the register area (-1) is returned.
182 tuiLastRegElementNoInLine (int lineNo
)
184 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) <=
185 dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
186 return ((lineNo
+ 1) *
187 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) - 1;
190 } /* tuiLastRegElementNoInLine */
194 ** tuiCalculateRegsColumnCount
195 ** Calculate the number of columns that should be used to display
199 tuiCalculateRegsColumnCount (TuiRegisterDisplayType dpyType
)
201 int colCount
, colWidth
;
203 if (IS_64BIT
|| dpyType
== TUI_DFLOAT_REGS
)
204 colWidth
= DOUBLE_FLOAT_VALUE_WIDTH
+ DOUBLE_FLOAT_LABEL_WIDTH
;
207 if (dpyType
== TUI_SFLOAT_REGS
)
208 colWidth
= SINGLE_FLOAT_VALUE_WIDTH
+ SINGLE_FLOAT_LABEL_WIDTH
;
210 colWidth
= SINGLE_VALUE_WIDTH
+ SINGLE_LABEL_WIDTH
;
212 colCount
= (dataWin
->generic
.width
- 2) / colWidth
;
215 } /* tuiCalulateRegsColumnCount */
219 ** tuiShowRegisters().
220 ** Show the registers int the data window as indicated by dpyType.
221 ** If there is any other registers being displayed, then they are
222 ** cleared. What registers are displayed is dependent upon dpyType.
225 tuiShowRegisters (TuiRegisterDisplayType dpyType
)
227 TuiStatus ret
= TUI_FAILURE
;
228 int refreshValuesOnly
= FALSE
;
230 /* Say that registers should be displayed, even if there is a problem */
231 dataWin
->detail
.dataDisplayInfo
.displayRegs
= TRUE
;
233 if (target_has_registers
)
236 (dpyType
== dataWin
->detail
.dataDisplayInfo
.regsDisplayType
);
239 case TUI_GENERAL_REGS
:
240 ret
= _tuiSetGeneralRegsContent (refreshValuesOnly
);
242 case TUI_SFLOAT_REGS
:
243 case TUI_DFLOAT_REGS
:
244 ret
= _tuiSetFloatRegsContent (dpyType
, refreshValuesOnly
);
247 /* could ifdef out */
249 case TUI_SPECIAL_REGS
:
250 ret
= _tuiSetSpecialRegsContent (refreshValuesOnly
);
252 case TUI_GENERAL_AND_SPECIAL_REGS
:
253 ret
= _tuiSetGeneralAndSpecialRegsContent (refreshValuesOnly
);
256 /* end of potential if def */
262 if (ret
== TUI_FAILURE
)
264 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= TUI_UNDEFINED_REGS
;
265 tuiEraseDataContent (NO_REGS_STRING
);
271 /* Clear all notation of changed values */
272 for (i
= 0; (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
274 TuiGenWinInfoPtr dataItemWin
;
276 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
277 regsContent
[i
]->whichElement
.dataWindow
;
278 (&((TuiWinElementPtr
)
279 dataItemWin
->content
[0])->whichElement
.data
)->highlight
= FALSE
;
281 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= dpyType
;
282 tuiDisplayAllData ();
284 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
287 } /* tuiShowRegisters */
291 ** tuiDisplayRegistersFrom().
292 ** Function to display the registers in the content from
293 ** 'startElementNo' until the end of the register content or the
294 ** end of the display height. No checking for displaying past
295 ** the end of the registers is done here.
298 tuiDisplayRegistersFrom (int startElementNo
)
300 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
301 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
303 register int i
= startElementNo
;
304 int j
, valueCharsWide
, charsWide
, itemWinWidth
, curY
, labelWidth
;
305 enum precision_type precision
;
307 precision
= (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
308 == TUI_DFLOAT_REGS
) ?
309 double_precision
: unspecified_precision
;
311 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
313 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
314 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
318 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
321 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
322 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
326 valueCharsWide
= SINGLE_VALUE_WIDTH
;
327 labelWidth
= SINGLE_LABEL_WIDTH
;
330 itemWinWidth
= valueCharsWide
+ labelWidth
;
332 ** Now create each data "sub" window, and write the display into it.
335 while (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
&&
336 curY
<= dataWin
->generic
.viewportHeight
)
339 (j
< dataWin
->detail
.dataDisplayInfo
.regsColumnCount
&&
340 i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); j
++)
342 TuiGenWinInfoPtr dataItemWin
;
343 TuiDataElementPtr dataElementPtr
;
345 /* create the window if necessary */
346 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
347 regsContent
[i
]->whichElement
.dataWindow
;
348 dataElementPtr
= &((TuiWinElementPtr
)
349 dataItemWin
->content
[0])->whichElement
.data
;
350 if (dataItemWin
->handle
== (WINDOW
*) NULL
)
352 dataItemWin
->height
= 1;
353 dataItemWin
->width
= (precision
== double_precision
) ?
354 itemWinWidth
+ 2 : itemWinWidth
+ 1;
355 dataItemWin
->origin
.x
= (itemWinWidth
* j
) + 1;
356 dataItemWin
->origin
.y
= curY
;
357 makeWindow (dataItemWin
, DONT_BOX_WINDOW
);
358 scrollok (dataItemWin
->handle
, FALSE
);
360 touchwin (dataItemWin
->handle
);
363 ** Get the printable representation of the register
366 _tuiDisplayRegister (
367 dataElementPtr
->itemNo
, dataItemWin
, precision
);
368 i
++; /* next register */
370 curY
++; /* next row; */
375 } /* tuiDisplayRegistersFrom */
379 ** tuiDisplayRegElementAtLine().
380 ** Function to display the registers in the content from
381 ** 'startElementNo' on 'startLineNo' until the end of the
382 ** register content or the end of the display height.
383 ** This function checks that we won't display off the end
384 ** of the register display.
387 tuiDisplayRegElementAtLine (int startElementNo
, int startLineNo
)
389 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
390 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
392 register int elementNo
= startElementNo
;
394 if (startElementNo
!= 0 && startLineNo
!= 0)
396 register int lastLineNo
, firstLineOnLastPage
;
398 lastLineNo
= tuiLastRegsLineNo ();
399 firstLineOnLastPage
= lastLineNo
- (dataWin
->generic
.height
- 2);
400 if (firstLineOnLastPage
< 0)
401 firstLineOnLastPage
= 0;
403 ** If there is no other data displayed except registers,
404 ** and the elementNo causes us to scroll past the end of the
405 ** registers, adjust what element to really start the display at.
407 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0 &&
408 startLineNo
> firstLineOnLastPage
)
409 elementNo
= tuiFirstRegElementNoInLine (firstLineOnLastPage
);
411 tuiDisplayRegistersFrom (elementNo
);
415 } /* tuiDisplayRegElementAtLine */
420 ** tuiDisplayRegistersFromLine().
421 ** Function to display the registers starting at line lineNo in
422 ** the data window. Answers the line number that the display
423 ** actually started from. If nothing is displayed (-1) is returned.
426 tuiDisplayRegistersFromLine (int lineNo
, int forceDisplay
)
430 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
436 else if (forceDisplay
)
438 ** If we must display regs (forceDisplay is true), then make
439 ** sure that we don't display off the end of the registers.
441 if (lineNo
>= tuiLastRegsLineNo ())
443 if ((line
= tuiLineFromRegElementNo (
444 dataWin
->detail
.dataDisplayInfo
.regsContentCount
- 1)) < 0)
453 elementNo
= tuiFirstRegElementNoInLine (line
);
454 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
455 tuiDisplayRegElementAtLine (elementNo
, line
);
462 return (-1); /* nothing was displayed */
463 } /* tuiDisplayRegistersFromLine */
467 ** tuiCheckRegisterValues()
468 ** This function check all displayed registers for changes in
469 ** values, given a particular frame. If the values have changed,
470 ** they are updated with the new value and highlighted.
473 tuiCheckRegisterValues (struct frame_info
*frame
)
475 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
477 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0 &&
478 dataWin
->detail
.dataDisplayInfo
.displayRegs
)
479 tuiShowRegisters ((tuiLayoutDef ())->regsDisplayType
);
483 char rawBuf
[MAX_REGISTER_RAW_SIZE
];
486 (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
488 TuiDataElementPtr dataElementPtr
;
489 TuiGenWinInfoPtr dataItemWinPtr
;
492 dataItemWinPtr
= &dataWin
->detail
.dataDisplayInfo
.
493 regsContent
[i
]->whichElement
.dataWindow
;
494 dataElementPtr
= &((TuiWinElementPtr
)
495 dataItemWinPtr
->content
[0])->whichElement
.data
;
496 wasHilighted
= dataElementPtr
->highlight
;
497 dataElementPtr
->highlight
=
498 _tuiRegValueHasChanged (dataElementPtr
, frame
, &rawBuf
[0]);
499 if (dataElementPtr
->highlight
)
503 size
= REGISTER_RAW_SIZE (dataElementPtr
->itemNo
);
504 for (j
= 0; j
< size
; j
++)
505 ((char *) dataElementPtr
->value
)[j
] = rawBuf
[j
];
506 _tuiDisplayRegister (
507 dataElementPtr
->itemNo
,
509 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
511 double_precision
: unspecified_precision
));
513 else if (wasHilighted
)
515 dataElementPtr
->highlight
= FALSE
;
516 _tuiDisplayRegister (
517 dataElementPtr
->itemNo
,
519 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
521 double_precision
: unspecified_precision
));
527 } /* tuiCheckRegisterValues */
531 ** tuiToggleFloatRegs().
534 tuiToggleFloatRegs (void)
536 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
538 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
539 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
541 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
543 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
&&
544 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_SFLOAT_REGS
||
545 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
))
546 tuiShowRegisters (layoutDef
->floatRegsDisplayType
);
549 } /* tuiToggleFloatRegs */
553 _initialize_tuiRegs (void)
557 add_com ("fr", class_tui
, _tuiShowFloat_command
,
558 "Display only floating point registers\n");
559 add_com ("gr", class_tui
, _tuiShowGeneral_command
,
560 "Display only general registers\n");
561 add_com ("sr", class_tui
, _tuiShowSpecial_command
,
562 "Display only special registers\n");
563 add_com ("+r", class_tui
, _tuiScrollRegsForward_command
,
564 "Scroll the registers window forward\n");
565 add_com ("-r", class_tui
, _tuiScrollRegsBackward_command
,
566 "Scroll the register window backward\n");
567 add_com ("tf", class_tui
, _tuiToggleFloatRegs_command
,
568 "Toggle between single and double precision floating point registers.\n");
569 add_cmd (TUI_FLOAT_REGS_NAME_LOWER
,
571 _tuiToggleFloatRegs_command
,
572 "Toggle between single and double precision floating point \
579 /*****************************************
580 ** STATIC LOCAL FUNCTIONS **
581 ******************************************/
585 ** _tuiRegisterName().
586 ** Return the register name.
589 _tuiRegisterName (int regNum
)
591 return REGISTER_NAME (regNum
);
593 extern int pagination_enabled
;
596 tui_restore_gdbout (void *ui
)
598 ui_file_delete (gdb_stdout
);
599 gdb_stdout
= (struct ui_file
*) ui
;
600 pagination_enabled
= 1;
604 ** _tuiRegisterFormat
605 ** Function to format the register name and value into a buffer,
606 ** suitable for printing or display
609 _tuiRegisterFormat (char *buf
, int bufLen
, int regNum
,
610 TuiDataElementPtr dataElement
,
611 enum precision_type precision
)
613 struct ui_file
*stream
;
614 struct ui_file
*old_stdout
;
616 struct cleanup
*cleanups
;
620 name
= REGISTER_NAME (regNum
);
627 pagination_enabled
= 0;
628 old_stdout
= gdb_stdout
;
629 stream
= tui_sfileopen (bufLen
);
631 cleanups
= make_cleanup (tui_restore_gdbout
, (void*) old_stdout
);
632 do_registers_info (regNum
, 0);
634 /* Save formatted output in the buffer. */
635 p
= tui_file_get_strbuf (stream
);
637 while (*p
&& *p
== *name
++ && bufLen
)
645 while (pos
< 8 && bufLen
)
651 strncpy (buf
, p
, bufLen
);
653 /* Remove the possible \n. */
654 p
= strchr (buf
, '\n');
658 do_cleanups (cleanups
);
662 #define NUM_GENERAL_REGS 32
664 ** _tuiSetGeneralRegsContent().
665 ** Set the content of the data window to consist of the general registers.
668 _tuiSetGeneralRegsContent (int refreshValuesOnly
)
670 return (_tuiSetRegsContent (0,
671 NUM_GENERAL_REGS
- 1,
676 } /* _tuiSetGeneralRegsContent */
679 #ifndef PCOQ_HEAD_REGNUM
680 #define START_SPECIAL_REGS 0
682 #define START_SPECIAL_REGS PCOQ_HEAD_REGNUM
686 ** _tuiSetSpecialRegsContent().
687 ** Set the content of the data window to consist of the special registers.
690 _tuiSetSpecialRegsContent (int refreshValuesOnly
)
692 TuiStatus ret
= TUI_FAILURE
;
695 endRegNum
= FP0_REGNUM
- 1;
698 for (i
= START_SPECIAL_REGS
; (i
< NUM_REGS
&& endRegNum
< 0); i
++)
699 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
702 ret
= _tuiSetRegsContent (START_SPECIAL_REGS
,
709 } /* _tuiSetSpecialRegsContent */
713 ** _tuiSetGeneralAndSpecialRegsContent().
714 ** Set the content of the data window to consist of the special registers.
717 _tuiSetGeneralAndSpecialRegsContent (int refreshValuesOnly
)
719 TuiStatus ret
= TUI_FAILURE
;
720 int i
, endRegNum
= (-1);
722 endRegNum
= FP0_REGNUM
- 1;
725 for (i
= 0; (i
< NUM_REGS
&& endRegNum
< 0); i
++)
726 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
729 ret
= _tuiSetRegsContent (
730 0, endRegNum
, selected_frame
, TUI_SPECIAL_REGS
, refreshValuesOnly
);
733 } /* _tuiSetGeneralAndSpecialRegsContent */
736 ** _tuiSetFloatRegsContent().
737 ** Set the content of the data window to consist of the float registers.
740 _tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType
, int refreshValuesOnly
)
742 TuiStatus ret
= TUI_FAILURE
;
745 startRegNum
= FP0_REGNUM
;
748 for (i
= NUM_REGS
- 1; (i
>= 0 && startRegNum
< 0); i
--)
749 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) != TYPE_CODE_FLT
)
752 ret
= _tuiSetRegsContent (startRegNum
,
759 } /* _tuiSetFloatRegsContent */
763 ** _tuiRegValueHasChanged().
764 ** Answer TRUE if the register's value has changed, FALSE otherwise.
765 ** If TRUE, newValue is filled in with the new value.
768 _tuiRegValueHasChanged (TuiDataElementPtr dataElement
,
769 struct frame_info
*frame
,
772 int hasChanged
= FALSE
;
774 if (dataElement
->itemNo
!= UNDEFINED_ITEM
&&
775 _tuiRegisterName (dataElement
->itemNo
) != (char *) NULL
)
777 char rawBuf
[MAX_REGISTER_RAW_SIZE
];
780 if (_tuiGetRegisterRawValue (
781 dataElement
->itemNo
, rawBuf
, frame
) == TUI_SUCCESS
)
783 int size
= REGISTER_RAW_SIZE (dataElement
->itemNo
);
785 for (i
= 0; (i
< size
&& !hasChanged
); i
++)
786 hasChanged
= (((char *) dataElement
->value
)[i
] != rawBuf
[i
]);
787 if (hasChanged
&& newValue
!= (char *) NULL
)
789 for (i
= 0; i
< size
; i
++)
790 newValue
[i
] = rawBuf
[i
];
795 } /* _tuiRegValueHasChanged */
800 ** _tuiGetRegisterRawValue().
801 ** Get the register raw value. The raw value is returned in regValue.
804 _tuiGetRegisterRawValue (int regNum
, char *regValue
, struct frame_info
*frame
)
806 TuiStatus ret
= TUI_FAILURE
;
808 if (target_has_registers
)
812 get_saved_register (regValue
, &opt
, (CORE_ADDR
*) NULL
, frame
,
813 regNum
, (enum lval_type
*) NULL
);
814 if (register_cached (regNum
) >= 0)
818 } /* _tuiGetRegisterRawValue */
823 ** _tuiSetRegisterElement().
824 ** Function to initialize a data element with the input and
825 ** the register value.
828 _tuiSetRegisterElement (int regNum
, struct frame_info
*frame
,
829 TuiDataElementPtr dataElement
,
830 int refreshValueOnly
)
832 if (dataElement
!= (TuiDataElementPtr
) NULL
)
834 if (!refreshValueOnly
)
836 dataElement
->itemNo
= regNum
;
837 dataElement
->name
= _tuiRegisterName (regNum
);
838 dataElement
->highlight
= FALSE
;
840 if (dataElement
->value
== (Opaque
) NULL
)
841 dataElement
->value
= (Opaque
) xmalloc (MAX_REGISTER_RAW_SIZE
);
842 if (dataElement
->value
!= (Opaque
) NULL
)
843 _tuiGetRegisterRawValue (regNum
, dataElement
->value
, frame
);
847 } /* _tuiSetRegisterElement */
851 ** _tuiSetRegsContent().
852 ** Set the content of the data window to consist of the registers
853 ** numbered from startRegNum to endRegNum. Note that if
854 ** refreshValuesOnly is TRUE, startRegNum and endRegNum are ignored.
857 _tuiSetRegsContent (int startRegNum
, int endRegNum
,
858 struct frame_info
*frame
,
859 TuiRegisterDisplayType dpyType
,
860 int refreshValuesOnly
)
862 TuiStatus ret
= TUI_FAILURE
;
863 int numRegs
= endRegNum
- startRegNum
+ 1;
864 int allocatedHere
= FALSE
;
866 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0 &&
869 freeDataContent (dataWin
->detail
.dataDisplayInfo
.regsContent
,
870 dataWin
->detail
.dataDisplayInfo
.regsContentCount
);
871 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= 0;
873 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0)
875 dataWin
->detail
.dataDisplayInfo
.regsContent
=
876 allocContent (numRegs
, DATA_WIN
);
877 allocatedHere
= TRUE
;
880 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
)
884 if (!refreshValuesOnly
|| allocatedHere
)
886 dataWin
->generic
.content
= (OpaquePtr
) NULL
;
887 dataWin
->generic
.contentSize
= 0;
888 addContentElements (&dataWin
->generic
, numRegs
);
889 dataWin
->detail
.dataDisplayInfo
.regsContent
=
890 (TuiWinContent
) dataWin
->generic
.content
;
891 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= numRegs
;
894 ** Now set the register names and values
896 for (i
= startRegNum
; (i
<= endRegNum
); i
++)
898 TuiGenWinInfoPtr dataItemWin
;
900 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
901 regsContent
[i
- startRegNum
]->whichElement
.dataWindow
;
902 _tuiSetRegisterElement (
905 &((TuiWinElementPtr
) dataItemWin
->content
[0])->whichElement
.data
,
906 !allocatedHere
&& refreshValuesOnly
);
908 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
=
909 tuiCalculateRegsColumnCount (dpyType
);
911 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
913 /* delete all the windows? */
914 /* realloc content equal to dataContentCount + regsContentCount */
915 /* append dataWin->detail.dataDisplayInfo.dataContent to content */
918 dataWin
->generic
.contentSize
=
919 dataWin
->detail
.dataDisplayInfo
.regsContentCount
+
920 dataWin
->detail
.dataDisplayInfo
.dataContentCount
;
925 } /* _tuiSetRegsContent */
929 ** _tuiDisplayRegister().
930 ** Function to display a register in a window. If hilite is TRUE,
931 ** than the value will be displayed in reverse video
934 _tuiDisplayRegister (int regNum
,
935 TuiGenWinInfoPtr winInfo
, /* the data item window */
936 enum precision_type precision
)
938 if (winInfo
->handle
!= (WINDOW
*) NULL
)
942 int valueCharsWide
, labelWidth
;
943 TuiDataElementPtr dataElementPtr
= &((TuiWinContent
)
944 winInfo
->content
)[0]->whichElement
.data
;
947 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
949 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
950 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
954 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
957 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
958 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
962 valueCharsWide
= SINGLE_VALUE_WIDTH
;
963 labelWidth
= SINGLE_LABEL_WIDTH
;
968 _tuiRegisterFormat (buf
,
969 valueCharsWide
+ labelWidth
,
974 if (dataElementPtr
->highlight
)
975 wstandout (winInfo
->handle
);
977 wmove (winInfo
->handle
, 0, 0);
978 for (i
= 1; i
< winInfo
->width
; i
++)
979 waddch (winInfo
->handle
, ' ');
980 wmove (winInfo
->handle
, 0, 0);
981 waddstr (winInfo
->handle
, buf
);
983 if (dataElementPtr
->highlight
)
984 wstandend (winInfo
->handle
);
985 tuiRefreshWin (winInfo
);
988 } /* _tuiDisplayRegister */
992 _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType dpyType
)
995 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
996 { /* Data window already displayed, show the registers */
997 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= dpyType
)
998 tuiShowRegisters (dpyType
);
1001 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
1004 } /* _tui_vShowRegisters_commandSupport */
1008 _tuiShowFloat_command (char *arg
, int fromTTY
)
1010 if (m_winPtrIsNull (dataWin
) || !dataWin
->generic
.isVisible
||
1011 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_SFLOAT_REGS
&&
1012 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_DFLOAT_REGS
))
1013 _tui_vShowRegisters_commandSupport ((tuiLayoutDef ())->floatRegsDisplayType
);
1016 } /* _tuiShowFloat_command */
1020 _tuiShowGeneral_command (char *arg
, int fromTTY
)
1022 _tui_vShowRegisters_commandSupport (TUI_GENERAL_REGS
);
1027 _tuiShowSpecial_command (char *arg
, int fromTTY
)
1029 _tui_vShowRegisters_commandSupport (TUI_SPECIAL_REGS
);
1034 _tuiToggleFloatRegs_command (char *arg
, int fromTTY
)
1036 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
1037 tuiToggleFloatRegs ();
1040 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
1042 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
1043 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
1045 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
1050 } /* _tuiToggleFloatRegs_command */
1054 _tuiScrollRegsForward_command (char *arg
, int fromTTY
)
1056 tui_scroll (FORWARD_SCROLL
, dataWin
, 1);
1061 _tuiScrollRegsBackward_command (char *arg
, int fromTTY
)
1063 tui_scroll (BACKWARD_SCROLL
, dataWin
, 1);