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. */
31 #include "tuiLayout.h"
33 #include "tuiDataWin.h"
34 #include "tuiGeneralWin.h"
37 /*****************************************
38 ** LOCAL DEFINITIONS **
39 ******************************************/
40 #define DOUBLE_FLOAT_LABEL_WIDTH 6
41 #define DOUBLE_FLOAT_LABEL_FMT "%6.6s: "
42 #define DOUBLE_FLOAT_VALUE_WIDTH 30 /*min of 16 but may be in sci notation */
44 #define SINGLE_FLOAT_LABEL_WIDTH 6
45 #define SINGLE_FLOAT_LABEL_FMT "%6.6s: "
46 #define SINGLE_FLOAT_VALUE_WIDTH 25 /* min of 8 but may be in sci notation */
48 #define SINGLE_LABEL_WIDTH 16
49 #define SINGLE_LABEL_FMT "%10.10s: "
50 #define SINGLE_VALUE_WIDTH 20 /* minimum of 8 but may be in sci notation */
52 /* In the code HP gave Cygnus, this was actually a function call to a
53 PA-specific function, which was supposed to determine whether the
54 target was a 64-bit or 32-bit processor. However, the 64-bit
55 support wasn't complete, so we didn't merge that in, so we leave
56 this here as a stub. */
59 /*****************************************
61 ******************************************/
64 /*****************************************
65 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
66 ******************************************/
67 static TuiStatus _tuiSetRegsContent
68 (int, int, struct frame_info
*, TuiRegisterDisplayType
, int);
69 static char *_tuiRegisterName (int);
70 static TuiStatus
_tuiGetRegisterRawValue (int, char *, struct frame_info
*);
71 static void _tuiSetRegisterElement
72 (int, struct frame_info
*, TuiDataElementPtr
, int);
73 static void _tuiDisplayRegister (int, TuiGenWinInfoPtr
, enum precision_type
);
74 static void _tuiRegisterFormat
75 (char *, int, int, TuiDataElementPtr
, enum precision_type
);
76 static TuiStatus
_tuiSetGeneralRegsContent (int);
77 static TuiStatus
_tuiSetSpecialRegsContent (int);
78 static TuiStatus
_tuiSetGeneralAndSpecialRegsContent (int);
79 static TuiStatus
_tuiSetFloatRegsContent (TuiRegisterDisplayType
, int);
80 static int _tuiRegValueHasChanged
81 (TuiDataElementPtr
, struct frame_info
*, char *);
82 static void _tuiShowFloat_command (char *, int);
83 static void _tuiShowGeneral_command (char *, int);
84 static void _tuiShowSpecial_command (char *, int);
85 static void _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType
);
86 static void _tuiToggleFloatRegs_command (char *, int);
87 static void _tuiScrollRegsForward_command (char *, int);
88 static void _tuiScrollRegsBackward_command (char *, int);
92 /*****************************************
93 ** PUBLIC FUNCTIONS **
94 ******************************************/
97 ** tuiLastRegsLineNo()
98 ** Answer the number of the last line in the regs display.
99 ** If there are no registers (-1) is returned.
102 tuiLastRegsLineNo (void)
104 register int numLines
= (-1);
106 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
108 numLines
= (dataWin
->detail
.dataDisplayInfo
.regsContentCount
/
109 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
);
110 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
%
111 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
115 } /* tuiLastRegsLineNo */
119 ** tuiLineFromRegElementNo()
120 ** Answer the line number that the register element at elementNo is
121 ** on. If elementNo is greater than the number of register elements
122 ** there are, -1 is returned.
125 tuiLineFromRegElementNo (int elementNo
)
127 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
135 (dataWin
->detail
.dataDisplayInfo
.regsColumnCount
* i
))
145 } /* tuiLineFromRegElementNo */
149 ** tuiFirstRegElementNoInLine()
150 ** Answer the index of the first element in lineNo. If lineNo is
151 ** past the register area (-1) is returned.
154 tuiFirstRegElementNoInLine (int lineNo
)
156 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
157 <= dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
158 return ((lineNo
+ 1) *
159 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) -
160 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
;
163 } /* tuiFirstRegElementNoInLine */
167 ** tuiLastRegElementNoInLine()
168 ** Answer the index of the last element in lineNo. If lineNo is past
169 ** the register area (-1) is returned.
172 tuiLastRegElementNoInLine (int lineNo
)
174 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) <=
175 dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
176 return ((lineNo
+ 1) *
177 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) - 1;
180 } /* tuiLastRegElementNoInLine */
184 ** tuiCalculateRegsColumnCount
185 ** Calculate the number of columns that should be used to display
189 tuiCalculateRegsColumnCount (TuiRegisterDisplayType dpyType
)
191 int colCount
, colWidth
;
193 if (IS_64BIT
|| dpyType
== TUI_DFLOAT_REGS
)
194 colWidth
= DOUBLE_FLOAT_VALUE_WIDTH
+ DOUBLE_FLOAT_LABEL_WIDTH
;
197 if (dpyType
== TUI_SFLOAT_REGS
)
198 colWidth
= SINGLE_FLOAT_VALUE_WIDTH
+ SINGLE_FLOAT_LABEL_WIDTH
;
200 colWidth
= SINGLE_VALUE_WIDTH
+ SINGLE_LABEL_WIDTH
;
202 colCount
= (dataWin
->generic
.width
- 2) / colWidth
;
205 } /* tuiCalulateRegsColumnCount */
209 ** tuiShowRegisters().
210 ** Show the registers int the data window as indicated by dpyType.
211 ** If there is any other registers being displayed, then they are
212 ** cleared. What registers are displayed is dependent upon dpyType.
215 tuiShowRegisters (TuiRegisterDisplayType dpyType
)
217 TuiStatus ret
= TUI_FAILURE
;
218 int refreshValuesOnly
= FALSE
;
220 /* Say that registers should be displayed, even if there is a problem */
221 dataWin
->detail
.dataDisplayInfo
.displayRegs
= TRUE
;
223 if (target_has_registers
)
226 (dpyType
== dataWin
->detail
.dataDisplayInfo
.regsDisplayType
);
229 case TUI_GENERAL_REGS
:
230 ret
= _tuiSetGeneralRegsContent (refreshValuesOnly
);
232 case TUI_SFLOAT_REGS
:
233 case TUI_DFLOAT_REGS
:
234 ret
= _tuiSetFloatRegsContent (dpyType
, refreshValuesOnly
);
237 /* could ifdef out */
239 case TUI_SPECIAL_REGS
:
240 ret
= _tuiSetSpecialRegsContent (refreshValuesOnly
);
242 case TUI_GENERAL_AND_SPECIAL_REGS
:
243 ret
= _tuiSetGeneralAndSpecialRegsContent (refreshValuesOnly
);
246 /* end of potential if def */
252 if (ret
== TUI_FAILURE
)
254 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= TUI_UNDEFINED_REGS
;
255 tuiEraseDataContent (NO_REGS_STRING
);
261 /* Clear all notation of changed values */
262 for (i
= 0; (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
264 TuiGenWinInfoPtr dataItemWin
;
266 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
267 regsContent
[i
]->whichElement
.dataWindow
;
268 (&((TuiWinElementPtr
)
269 dataItemWin
->content
[0])->whichElement
.data
)->highlight
= FALSE
;
271 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= dpyType
;
272 tuiDisplayAllData ();
274 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
277 } /* tuiShowRegisters */
281 ** tuiDisplayRegistersFrom().
282 ** Function to display the registers in the content from
283 ** 'startElementNo' until the end of the register content or the
284 ** end of the display height. No checking for displaying past
285 ** the end of the registers is done here.
288 tuiDisplayRegistersFrom (int startElementNo
)
290 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
291 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
293 register int i
= startElementNo
;
294 int j
, valueCharsWide
, charsWide
, itemWinWidth
, curY
, labelWidth
;
295 enum precision_type precision
;
297 precision
= (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
298 == TUI_DFLOAT_REGS
) ?
299 double_precision
: unspecified_precision
;
301 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
303 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
304 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
308 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
311 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
312 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
316 valueCharsWide
= SINGLE_VALUE_WIDTH
;
317 labelWidth
= SINGLE_LABEL_WIDTH
;
320 itemWinWidth
= valueCharsWide
+ labelWidth
;
322 ** Now create each data "sub" window, and write the display into it.
325 while (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
&&
326 curY
<= dataWin
->generic
.viewportHeight
)
329 (j
< dataWin
->detail
.dataDisplayInfo
.regsColumnCount
&&
330 i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); j
++)
332 TuiGenWinInfoPtr dataItemWin
;
333 TuiDataElementPtr dataElementPtr
;
335 /* create the window if necessary */
336 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
337 regsContent
[i
]->whichElement
.dataWindow
;
338 dataElementPtr
= &((TuiWinElementPtr
)
339 dataItemWin
->content
[0])->whichElement
.data
;
340 if (dataItemWin
->handle
== (WINDOW
*) NULL
)
342 dataItemWin
->height
= 1;
343 dataItemWin
->width
= (precision
== double_precision
) ?
344 itemWinWidth
+ 2 : itemWinWidth
+ 1;
345 dataItemWin
->origin
.x
= (itemWinWidth
* j
) + 1;
346 dataItemWin
->origin
.y
= curY
;
347 makeWindow (dataItemWin
, DONT_BOX_WINDOW
);
348 scrollok (dataItemWin
->handle
, FALSE
);
351 ** Get the printable representation of the register
354 _tuiDisplayRegister (
355 dataElementPtr
->itemNo
, dataItemWin
, precision
);
356 i
++; /* next register */
358 curY
++; /* next row; */
363 } /* tuiDisplayRegistersFrom */
367 ** tuiDisplayRegElementAtLine().
368 ** Function to display the registers in the content from
369 ** 'startElementNo' on 'startLineNo' until the end of the
370 ** register content or the end of the display height.
371 ** This function checks that we won't display off the end
372 ** of the register display.
375 tuiDisplayRegElementAtLine (int startElementNo
, int startLineNo
)
377 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
378 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
380 register int elementNo
= startElementNo
;
382 if (startElementNo
!= 0 && startLineNo
!= 0)
384 register int lastLineNo
, firstLineOnLastPage
;
386 lastLineNo
= tuiLastRegsLineNo ();
387 firstLineOnLastPage
= lastLineNo
- (dataWin
->generic
.height
- 2);
388 if (firstLineOnLastPage
< 0)
389 firstLineOnLastPage
= 0;
391 ** If there is no other data displayed except registers,
392 ** and the elementNo causes us to scroll past the end of the
393 ** registers, adjust what element to really start the display at.
395 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0 &&
396 startLineNo
> firstLineOnLastPage
)
397 elementNo
= tuiFirstRegElementNoInLine (firstLineOnLastPage
);
399 tuiDisplayRegistersFrom (elementNo
);
403 } /* tuiDisplayRegElementAtLine */
408 ** tuiDisplayRegistersFromLine().
409 ** Function to display the registers starting at line lineNo in
410 ** the data window. Answers the line number that the display
411 ** actually started from. If nothing is displayed (-1) is returned.
414 tuiDisplayRegistersFromLine (int lineNo
, int forceDisplay
)
418 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
424 else if (forceDisplay
)
426 ** If we must display regs (forceDisplay is true), then make
427 ** sure that we don't display off the end of the registers.
429 if (lineNo
>= tuiLastRegsLineNo ())
431 if ((line
= tuiLineFromRegElementNo (
432 dataWin
->detail
.dataDisplayInfo
.regsContentCount
- 1)) < 0)
441 elementNo
= tuiFirstRegElementNoInLine (line
);
442 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
443 tuiDisplayRegElementAtLine (elementNo
, line
);
450 return (-1); /* nothing was displayed */
451 } /* tuiDisplayRegistersFromLine */
455 ** tuiCheckRegisterValues()
456 ** This function check all displayed registers for changes in
457 ** values, given a particular frame. If the values have changed,
458 ** they are updated with the new value and highlighted.
461 tuiCheckRegisterValues (struct frame_info
*frame
)
463 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
465 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0 &&
466 dataWin
->detail
.dataDisplayInfo
.displayRegs
)
467 tuiShowRegisters ((tuiLayoutDef ())->regsDisplayType
);
471 char rawBuf
[MAX_REGISTER_RAW_SIZE
];
474 (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
476 TuiDataElementPtr dataElementPtr
;
477 TuiGenWinInfoPtr dataItemWinPtr
;
480 dataItemWinPtr
= &dataWin
->detail
.dataDisplayInfo
.
481 regsContent
[i
]->whichElement
.dataWindow
;
482 dataElementPtr
= &((TuiWinElementPtr
)
483 dataItemWinPtr
->content
[0])->whichElement
.data
;
484 wasHilighted
= dataElementPtr
->highlight
;
485 dataElementPtr
->highlight
=
486 _tuiRegValueHasChanged (dataElementPtr
, frame
, &rawBuf
[0]);
487 if (dataElementPtr
->highlight
)
491 size
= REGISTER_RAW_SIZE (dataElementPtr
->itemNo
);
492 for (j
= 0; j
< size
; j
++)
493 ((char *) dataElementPtr
->value
)[j
] = rawBuf
[j
];
494 _tuiDisplayRegister (
495 dataElementPtr
->itemNo
,
497 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
499 double_precision
: unspecified_precision
));
501 else if (wasHilighted
)
503 dataElementPtr
->highlight
= FALSE
;
504 _tuiDisplayRegister (
505 dataElementPtr
->itemNo
,
507 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
509 double_precision
: unspecified_precision
));
515 } /* tuiCheckRegisterValues */
519 ** tuiToggleFloatRegs().
522 tuiToggleFloatRegs (void)
524 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
526 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
527 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
529 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
531 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
&&
532 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_SFLOAT_REGS
||
533 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
))
534 tuiShowRegisters (layoutDef
->floatRegsDisplayType
);
537 } /* tuiToggleFloatRegs */
541 _initialize_tuiRegs (void)
543 if (tui_version
&& xdb_commands
)
545 add_com ("fr", class_tui
, _tuiShowFloat_command
,
546 "Display only floating point registers\n");
547 add_com ("gr", class_tui
, _tuiShowGeneral_command
,
548 "Display only general registers\n");
549 add_com ("sr", class_tui
, _tuiShowSpecial_command
,
550 "Display only special registers\n");
551 add_com ("+r", class_tui
, _tuiScrollRegsForward_command
,
552 "Scroll the registers window forward\n");
553 add_com ("-r", class_tui
, _tuiScrollRegsBackward_command
,
554 "Scroll the register window backward\n");
555 add_com ("tf", class_tui
, _tuiToggleFloatRegs_command
,
556 "Toggle between single and double precision floating point registers.\n");
557 add_cmd (TUI_FLOAT_REGS_NAME_LOWER
,
559 _tuiToggleFloatRegs_command
,
560 "Toggle between single and double precision floating point \
566 } /* _initialize_tuiRegs */
569 /*****************************************
570 ** STATIC LOCAL FUNCTIONS **
571 ******************************************/
575 ** _tuiRegisterName().
576 ** Return the register name.
579 _tuiRegisterName (int regNum
)
581 return REGISTER_NAME (regNum
);
583 extern int pagination_enabled
;
586 tui_restore_gdbout (void *ui
)
588 ui_file_delete (gdb_stdout
);
589 gdb_stdout
= (struct ui_file
*) ui
;
590 pagination_enabled
= 1;
594 ** _tuiRegisterFormat
595 ** Function to format the register name and value into a buffer,
596 ** suitable for printing or display
599 _tuiRegisterFormat (char *buf
, int bufLen
, int regNum
,
600 TuiDataElementPtr dataElement
,
601 enum precision_type precision
)
603 struct ui_file
*stream
;
604 struct ui_file
*old_stdout
;
606 struct cleanup
*cleanups
;
609 name
= REGISTER_NAME (regNum
);
616 pagination_enabled
= 0;
617 old_stdout
= gdb_stdout
;
618 stream
= tui_sfileopen (bufLen
);
620 cleanups
= make_cleanup (tui_restore_gdbout
, (void*) old_stdout
);
621 do_registers_info (regNum
, 0);
623 /* Save formatted output in the buffer. */
624 strncpy (buf
, tui_file_get_strbuf (stream
), bufLen
);
626 /* Remove the possible \n. */
627 p
= strchr (buf
, '\n');
631 do_cleanups (cleanups
);
635 #define NUM_GENERAL_REGS 32
637 ** _tuiSetGeneralRegsContent().
638 ** Set the content of the data window to consist of the general registers.
641 _tuiSetGeneralRegsContent (int refreshValuesOnly
)
643 return (_tuiSetRegsContent (0,
644 NUM_GENERAL_REGS
- 1,
649 } /* _tuiSetGeneralRegsContent */
652 #ifndef PCOQ_HEAD_REGNUM
653 #define START_SPECIAL_REGS 0
655 #define START_SPECIAL_REGS PCOQ_HEAD_REGNUM
659 ** _tuiSetSpecialRegsContent().
660 ** Set the content of the data window to consist of the special registers.
663 _tuiSetSpecialRegsContent (int refreshValuesOnly
)
665 TuiStatus ret
= TUI_FAILURE
;
668 endRegNum
= FP0_REGNUM
- 1;
671 for (i
= START_SPECIAL_REGS
; (i
< NUM_REGS
&& endRegNum
< 0); i
++)
672 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
675 ret
= _tuiSetRegsContent (START_SPECIAL_REGS
,
682 } /* _tuiSetSpecialRegsContent */
686 ** _tuiSetGeneralAndSpecialRegsContent().
687 ** Set the content of the data window to consist of the special registers.
690 _tuiSetGeneralAndSpecialRegsContent (int refreshValuesOnly
)
692 TuiStatus ret
= TUI_FAILURE
;
693 int i
, endRegNum
= (-1);
695 endRegNum
= FP0_REGNUM
- 1;
698 for (i
= 0; (i
< NUM_REGS
&& endRegNum
< 0); i
++)
699 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
702 ret
= _tuiSetRegsContent (
703 0, endRegNum
, selected_frame
, TUI_SPECIAL_REGS
, refreshValuesOnly
);
706 } /* _tuiSetGeneralAndSpecialRegsContent */
709 ** _tuiSetFloatRegsContent().
710 ** Set the content of the data window to consist of the float registers.
713 _tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType
, int refreshValuesOnly
)
715 TuiStatus ret
= TUI_FAILURE
;
718 startRegNum
= FP0_REGNUM
;
721 for (i
= NUM_REGS
- 1; (i
>= 0 && startRegNum
< 0); i
--)
722 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) != TYPE_CODE_FLT
)
725 ret
= _tuiSetRegsContent (startRegNum
,
732 } /* _tuiSetFloatRegsContent */
736 ** _tuiRegValueHasChanged().
737 ** Answer TRUE if the register's value has changed, FALSE otherwise.
738 ** If TRUE, newValue is filled in with the new value.
741 _tuiRegValueHasChanged (TuiDataElementPtr dataElement
,
742 struct frame_info
*frame
,
745 int hasChanged
= FALSE
;
747 if (dataElement
->itemNo
!= UNDEFINED_ITEM
&&
748 _tuiRegisterName (dataElement
->itemNo
) != (char *) NULL
)
750 char rawBuf
[MAX_REGISTER_RAW_SIZE
];
753 if (_tuiGetRegisterRawValue (
754 dataElement
->itemNo
, rawBuf
, frame
) == TUI_SUCCESS
)
756 int size
= REGISTER_RAW_SIZE (dataElement
->itemNo
);
758 for (i
= 0; (i
< size
&& !hasChanged
); i
++)
759 hasChanged
= (((char *) dataElement
->value
)[i
] != rawBuf
[i
]);
760 if (hasChanged
&& newValue
!= (char *) NULL
)
762 for (i
= 0; i
< size
; i
++)
763 newValue
[i
] = rawBuf
[i
];
768 } /* _tuiRegValueHasChanged */
773 ** _tuiGetRegisterRawValue().
774 ** Get the register raw value. The raw value is returned in regValue.
777 _tuiGetRegisterRawValue (int regNum
, char *regValue
, struct frame_info
*frame
)
779 TuiStatus ret
= TUI_FAILURE
;
781 if (target_has_registers
)
785 get_saved_register (regValue
, &opt
, (CORE_ADDR
*) NULL
, frame
,
786 regNum
, (enum lval_type
*) NULL
);
787 if (register_cached (regNum
) >= 0)
791 } /* _tuiGetRegisterRawValue */
796 ** _tuiSetRegisterElement().
797 ** Function to initialize a data element with the input and
798 ** the register value.
801 _tuiSetRegisterElement (int regNum
, struct frame_info
*frame
,
802 TuiDataElementPtr dataElement
,
803 int refreshValueOnly
)
805 if (dataElement
!= (TuiDataElementPtr
) NULL
)
807 if (!refreshValueOnly
)
809 dataElement
->itemNo
= regNum
;
810 dataElement
->name
= _tuiRegisterName (regNum
);
811 dataElement
->highlight
= FALSE
;
813 if (dataElement
->value
== (Opaque
) NULL
)
814 dataElement
->value
= (Opaque
) xmalloc (MAX_REGISTER_RAW_SIZE
);
815 if (dataElement
->value
!= (Opaque
) NULL
)
816 _tuiGetRegisterRawValue (regNum
, dataElement
->value
, frame
);
820 } /* _tuiSetRegisterElement */
824 ** _tuiSetRegsContent().
825 ** Set the content of the data window to consist of the registers
826 ** numbered from startRegNum to endRegNum. Note that if
827 ** refreshValuesOnly is TRUE, startRegNum and endRegNum are ignored.
830 _tuiSetRegsContent (int startRegNum
, int endRegNum
,
831 struct frame_info
*frame
,
832 TuiRegisterDisplayType dpyType
,
833 int refreshValuesOnly
)
835 TuiStatus ret
= TUI_FAILURE
;
836 int numRegs
= endRegNum
- startRegNum
+ 1;
837 int allocatedHere
= FALSE
;
839 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0 &&
842 freeDataContent (dataWin
->detail
.dataDisplayInfo
.regsContent
,
843 dataWin
->detail
.dataDisplayInfo
.regsContentCount
);
844 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= 0;
846 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0)
848 dataWin
->detail
.dataDisplayInfo
.regsContent
=
849 allocContent (numRegs
, DATA_WIN
);
850 allocatedHere
= TRUE
;
853 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
)
857 if (!refreshValuesOnly
|| allocatedHere
)
859 dataWin
->generic
.content
= (OpaquePtr
) NULL
;
860 dataWin
->generic
.contentSize
= 0;
861 addContentElements (&dataWin
->generic
, numRegs
);
862 dataWin
->detail
.dataDisplayInfo
.regsContent
=
863 (TuiWinContent
) dataWin
->generic
.content
;
864 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= numRegs
;
867 ** Now set the register names and values
869 for (i
= startRegNum
; (i
<= endRegNum
); i
++)
871 TuiGenWinInfoPtr dataItemWin
;
873 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
874 regsContent
[i
- startRegNum
]->whichElement
.dataWindow
;
875 _tuiSetRegisterElement (
878 &((TuiWinElementPtr
) dataItemWin
->content
[0])->whichElement
.data
,
879 !allocatedHere
&& refreshValuesOnly
);
881 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
=
882 tuiCalculateRegsColumnCount (dpyType
);
884 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
886 /* delete all the windows? */
887 /* realloc content equal to dataContentCount + regsContentCount */
888 /* append dataWin->detail.dataDisplayInfo.dataContent to content */
891 dataWin
->generic
.contentSize
=
892 dataWin
->detail
.dataDisplayInfo
.regsContentCount
+
893 dataWin
->detail
.dataDisplayInfo
.dataContentCount
;
898 } /* _tuiSetRegsContent */
902 ** _tuiDisplayRegister().
903 ** Function to display a register in a window. If hilite is TRUE,
904 ** than the value will be displayed in reverse video
907 _tuiDisplayRegister (int regNum
,
908 TuiGenWinInfoPtr winInfo
, /* the data item window */
909 enum precision_type precision
)
911 if (winInfo
->handle
!= (WINDOW
*) NULL
)
915 int valueCharsWide
, labelWidth
;
916 TuiDataElementPtr dataElementPtr
= &((TuiWinContent
)
917 winInfo
->content
)[0]->whichElement
.data
;
920 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
922 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
923 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
927 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
930 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
931 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
935 valueCharsWide
= SINGLE_VALUE_WIDTH
;
936 labelWidth
= SINGLE_LABEL_WIDTH
;
941 _tuiRegisterFormat (buf
,
942 valueCharsWide
+ labelWidth
,
947 if (dataElementPtr
->highlight
)
948 wstandout (winInfo
->handle
);
950 wmove (winInfo
->handle
, 0, 0);
951 for (i
= 1; i
< winInfo
->width
; i
++)
952 waddch (winInfo
->handle
, ' ');
953 wmove (winInfo
->handle
, 0, 0);
954 waddstr (winInfo
->handle
, buf
);
956 if (dataElementPtr
->highlight
)
957 wstandend (winInfo
->handle
);
958 tuiRefreshWin (winInfo
);
961 } /* _tuiDisplayRegister */
965 _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType dpyType
)
968 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
969 { /* Data window already displayed, show the registers */
970 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= dpyType
)
971 tuiShowRegisters (dpyType
);
974 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
977 } /* _tui_vShowRegisters_commandSupport */
981 _tuiShowFloat_command (char *arg
, int fromTTY
)
983 if (m_winPtrIsNull (dataWin
) || !dataWin
->generic
.isVisible
||
984 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_SFLOAT_REGS
&&
985 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_DFLOAT_REGS
))
986 _tui_vShowRegisters_commandSupport ((tuiLayoutDef ())->floatRegsDisplayType
);
989 } /* _tuiShowFloat_command */
993 _tuiShowGeneral_command (char *arg
, int fromTTY
)
995 _tui_vShowRegisters_commandSupport (TUI_GENERAL_REGS
);
1000 _tuiShowSpecial_command (char *arg
, int fromTTY
)
1002 _tui_vShowRegisters_commandSupport (TUI_SPECIAL_REGS
);
1007 _tuiToggleFloatRegs_command (char *arg
, int fromTTY
)
1009 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
1010 tuiToggleFloatRegs ();
1013 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
1015 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
1016 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
1018 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
1023 } /* _tuiToggleFloatRegs_command */
1027 _tuiScrollRegsForward_command (char *arg
, int fromTTY
)
1029 tui_scroll (FORWARD_SCROLL
, dataWin
, 1);
1034 _tuiScrollRegsBackward_command (char *arg
, int fromTTY
)
1036 tui_scroll (BACKWARD_SCROLL
, dataWin
, 1);