1 /* TUI display registers in window.
3 Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
25 /* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
26 "defs.h" should be included first. Unfortunatly some systems
27 (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
28 and they clash with "bfd.h"'s definiton of true/false. The correct
29 fix is to remove true/false from "bfd.h", however, until that
30 happens, hack around it by including "config.h" and <curses.h>
52 #include "tuiLayout.h"
54 #include "tuiDataWin.h"
55 #include "tuiGeneralWin.h"
58 /*****************************************
59 ** LOCAL DEFINITIONS **
60 ******************************************/
61 #define DOUBLE_FLOAT_LABEL_WIDTH 6
62 #define DOUBLE_FLOAT_LABEL_FMT "%6.6s: "
63 #define DOUBLE_FLOAT_VALUE_WIDTH 30 /*min of 16 but may be in sci notation */
65 #define SINGLE_FLOAT_LABEL_WIDTH 6
66 #define SINGLE_FLOAT_LABEL_FMT "%6.6s: "
67 #define SINGLE_FLOAT_VALUE_WIDTH 25 /* min of 8 but may be in sci notation */
69 #define SINGLE_LABEL_WIDTH 16
70 #define SINGLE_LABEL_FMT "%10.10s: "
71 #define SINGLE_VALUE_WIDTH 20 /* minimum of 8 but may be in sci notation */
73 /* In the code HP gave Cygnus, this was actually a function call to a
74 PA-specific function, which was supposed to determine whether the
75 target was a 64-bit or 32-bit processor. However, the 64-bit
76 support wasn't complete, so we didn't merge that in, so we leave
77 this here as a stub. */
80 /*****************************************
82 ******************************************/
85 /*****************************************
86 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
87 ******************************************/
88 static TuiStatus _tuiSetRegsContent
89 (int, int, struct frame_info
*, TuiRegisterDisplayType
, int);
90 static const char *_tuiRegisterName (int);
91 static TuiStatus
_tuiGetRegisterRawValue (int, char *, struct frame_info
*);
92 static void _tuiSetRegisterElement
93 (int, struct frame_info
*, TuiDataElementPtr
, int);
94 static void _tuiDisplayRegister (int, TuiGenWinInfoPtr
, enum precision_type
);
95 static void _tuiRegisterFormat
96 (char *, int, int, TuiDataElementPtr
, enum precision_type
);
97 static TuiStatus
_tuiSetGeneralRegsContent (int);
98 static TuiStatus
_tuiSetSpecialRegsContent (int);
99 static TuiStatus
_tuiSetGeneralAndSpecialRegsContent (int);
100 static TuiStatus
_tuiSetFloatRegsContent (TuiRegisterDisplayType
, int);
101 static int _tuiRegValueHasChanged
102 (TuiDataElementPtr
, struct frame_info
*, char *);
103 static void _tuiShowFloat_command (char *, int);
104 static void _tuiShowGeneral_command (char *, int);
105 static void _tuiShowSpecial_command (char *, int);
106 static void _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType
);
107 static void _tuiToggleFloatRegs_command (char *, int);
108 static void _tuiScrollRegsForward_command (char *, int);
109 static void _tuiScrollRegsBackward_command (char *, int);
113 /*****************************************
114 ** PUBLIC FUNCTIONS **
115 ******************************************/
118 ** tuiLastRegsLineNo()
119 ** Answer the number of the last line in the regs display.
120 ** If there are no registers (-1) is returned.
123 tuiLastRegsLineNo (void)
125 register int numLines
= (-1);
127 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
129 numLines
= (dataWin
->detail
.dataDisplayInfo
.regsContentCount
/
130 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
);
131 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
%
132 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
136 } /* tuiLastRegsLineNo */
140 ** tuiLineFromRegElementNo()
141 ** Answer the line number that the register element at elementNo is
142 ** on. If elementNo is greater than the number of register elements
143 ** there are, -1 is returned.
146 tuiLineFromRegElementNo (int elementNo
)
148 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
156 (dataWin
->detail
.dataDisplayInfo
.regsColumnCount
* i
))
166 } /* tuiLineFromRegElementNo */
170 ** tuiFirstRegElementNoInLine()
171 ** Answer the index of the first element in lineNo. If lineNo is
172 ** past the register area (-1) is returned.
175 tuiFirstRegElementNoInLine (int lineNo
)
177 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
178 <= dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
179 return ((lineNo
+ 1) *
180 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) -
181 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
;
184 } /* tuiFirstRegElementNoInLine */
188 ** tuiLastRegElementNoInLine()
189 ** Answer the index of the last element in lineNo. If lineNo is past
190 ** the register area (-1) is returned.
193 tuiLastRegElementNoInLine (int lineNo
)
195 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) <=
196 dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
197 return ((lineNo
+ 1) *
198 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) - 1;
201 } /* tuiLastRegElementNoInLine */
205 ** tuiCalculateRegsColumnCount
206 ** Calculate the number of columns that should be used to display
210 tuiCalculateRegsColumnCount (TuiRegisterDisplayType dpyType
)
212 int colCount
, colWidth
;
214 if (IS_64BIT
|| dpyType
== TUI_DFLOAT_REGS
)
215 colWidth
= DOUBLE_FLOAT_VALUE_WIDTH
+ DOUBLE_FLOAT_LABEL_WIDTH
;
218 if (dpyType
== TUI_SFLOAT_REGS
)
219 colWidth
= SINGLE_FLOAT_VALUE_WIDTH
+ SINGLE_FLOAT_LABEL_WIDTH
;
221 colWidth
= SINGLE_VALUE_WIDTH
+ SINGLE_LABEL_WIDTH
;
223 colCount
= (dataWin
->generic
.width
- 2) / colWidth
;
226 } /* tuiCalulateRegsColumnCount */
230 ** tuiShowRegisters().
231 ** Show the registers int the data window as indicated by dpyType.
232 ** If there is any other registers being displayed, then they are
233 ** cleared. What registers are displayed is dependent upon dpyType.
236 tuiShowRegisters (TuiRegisterDisplayType dpyType
)
238 TuiStatus ret
= TUI_FAILURE
;
239 int refreshValuesOnly
= FALSE
;
241 /* Say that registers should be displayed, even if there is a problem */
242 dataWin
->detail
.dataDisplayInfo
.displayRegs
= TRUE
;
244 if (target_has_registers
)
247 (dpyType
== dataWin
->detail
.dataDisplayInfo
.regsDisplayType
);
250 case TUI_GENERAL_REGS
:
251 ret
= _tuiSetGeneralRegsContent (refreshValuesOnly
);
253 case TUI_SFLOAT_REGS
:
254 case TUI_DFLOAT_REGS
:
255 ret
= _tuiSetFloatRegsContent (dpyType
, refreshValuesOnly
);
258 /* could ifdef out */
260 case TUI_SPECIAL_REGS
:
261 ret
= _tuiSetSpecialRegsContent (refreshValuesOnly
);
263 case TUI_GENERAL_AND_SPECIAL_REGS
:
264 ret
= _tuiSetGeneralAndSpecialRegsContent (refreshValuesOnly
);
267 /* end of potential if def */
273 if (ret
== TUI_FAILURE
)
275 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= TUI_UNDEFINED_REGS
;
276 tuiEraseDataContent (NO_REGS_STRING
);
282 /* Clear all notation of changed values */
283 for (i
= 0; (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
285 TuiGenWinInfoPtr dataItemWin
;
287 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
288 regsContent
[i
]->whichElement
.dataWindow
;
289 (&((TuiWinElementPtr
)
290 dataItemWin
->content
[0])->whichElement
.data
)->highlight
= FALSE
;
292 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= dpyType
;
293 tuiDisplayAllData ();
295 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
298 } /* tuiShowRegisters */
302 ** tuiDisplayRegistersFrom().
303 ** Function to display the registers in the content from
304 ** 'startElementNo' until the end of the register content or the
305 ** end of the display height. No checking for displaying past
306 ** the end of the registers is done here.
309 tuiDisplayRegistersFrom (int startElementNo
)
311 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
312 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
314 register int i
= startElementNo
;
315 int j
, valueCharsWide
, itemWinWidth
, curY
, labelWidth
;
316 enum precision_type precision
;
318 precision
= (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
319 == TUI_DFLOAT_REGS
) ?
320 double_precision
: unspecified_precision
;
322 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
324 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
325 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
329 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
332 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
333 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
337 valueCharsWide
= SINGLE_VALUE_WIDTH
;
338 labelWidth
= SINGLE_LABEL_WIDTH
;
341 itemWinWidth
= valueCharsWide
+ labelWidth
;
343 ** Now create each data "sub" window, and write the display into it.
346 while (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
&&
347 curY
<= dataWin
->generic
.viewportHeight
)
350 (j
< dataWin
->detail
.dataDisplayInfo
.regsColumnCount
&&
351 i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); j
++)
353 TuiGenWinInfoPtr dataItemWin
;
354 TuiDataElementPtr dataElementPtr
;
356 /* create the window if necessary */
357 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
358 regsContent
[i
]->whichElement
.dataWindow
;
359 dataElementPtr
= &((TuiWinElementPtr
)
360 dataItemWin
->content
[0])->whichElement
.data
;
361 if (dataItemWin
->handle
== (WINDOW
*) NULL
)
363 dataItemWin
->height
= 1;
364 dataItemWin
->width
= (precision
== double_precision
) ?
365 itemWinWidth
+ 2 : itemWinWidth
+ 1;
366 dataItemWin
->origin
.x
= (itemWinWidth
* j
) + 1;
367 dataItemWin
->origin
.y
= curY
;
368 makeWindow (dataItemWin
, DONT_BOX_WINDOW
);
369 scrollok (dataItemWin
->handle
, FALSE
);
371 touchwin (dataItemWin
->handle
);
374 ** Get the printable representation of the register
377 _tuiDisplayRegister (
378 dataElementPtr
->itemNo
, dataItemWin
, precision
);
379 i
++; /* next register */
381 curY
++; /* next row; */
386 } /* tuiDisplayRegistersFrom */
390 ** tuiDisplayRegElementAtLine().
391 ** Function to display the registers in the content from
392 ** 'startElementNo' on 'startLineNo' until the end of the
393 ** register content or the end of the display height.
394 ** This function checks that we won't display off the end
395 ** of the register display.
398 tuiDisplayRegElementAtLine (int startElementNo
, int startLineNo
)
400 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
401 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
403 register int elementNo
= startElementNo
;
405 if (startElementNo
!= 0 && startLineNo
!= 0)
407 register int lastLineNo
, firstLineOnLastPage
;
409 lastLineNo
= tuiLastRegsLineNo ();
410 firstLineOnLastPage
= lastLineNo
- (dataWin
->generic
.height
- 2);
411 if (firstLineOnLastPage
< 0)
412 firstLineOnLastPage
= 0;
414 ** If there is no other data displayed except registers,
415 ** and the elementNo causes us to scroll past the end of the
416 ** registers, adjust what element to really start the display at.
418 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0 &&
419 startLineNo
> firstLineOnLastPage
)
420 elementNo
= tuiFirstRegElementNoInLine (firstLineOnLastPage
);
422 tuiDisplayRegistersFrom (elementNo
);
426 } /* tuiDisplayRegElementAtLine */
431 ** tuiDisplayRegistersFromLine().
432 ** Function to display the registers starting at line lineNo in
433 ** the data window. Answers the line number that the display
434 ** actually started from. If nothing is displayed (-1) is returned.
437 tuiDisplayRegistersFromLine (int lineNo
, int forceDisplay
)
439 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
445 else if (forceDisplay
)
447 ** If we must display regs (forceDisplay is true), then make
448 ** sure that we don't display off the end of the registers.
450 if (lineNo
>= tuiLastRegsLineNo ())
452 if ((line
= tuiLineFromRegElementNo (
453 dataWin
->detail
.dataDisplayInfo
.regsContentCount
- 1)) < 0)
462 elementNo
= tuiFirstRegElementNoInLine (line
);
463 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
464 tuiDisplayRegElementAtLine (elementNo
, line
);
471 return (-1); /* nothing was displayed */
472 } /* tuiDisplayRegistersFromLine */
476 ** tuiCheckRegisterValues()
477 ** This function check all displayed registers for changes in
478 ** values, given a particular frame. If the values have changed,
479 ** they are updated with the new value and highlighted.
482 tuiCheckRegisterValues (struct frame_info
*frame
)
484 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
486 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0 &&
487 dataWin
->detail
.dataDisplayInfo
.displayRegs
)
488 tuiShowRegisters ((tuiLayoutDef ())->regsDisplayType
);
492 char rawBuf
[MAX_REGISTER_SIZE
];
495 (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
497 TuiDataElementPtr dataElementPtr
;
498 TuiGenWinInfoPtr dataItemWinPtr
;
501 dataItemWinPtr
= &dataWin
->detail
.dataDisplayInfo
.
502 regsContent
[i
]->whichElement
.dataWindow
;
503 dataElementPtr
= &((TuiWinElementPtr
)
504 dataItemWinPtr
->content
[0])->whichElement
.data
;
505 wasHilighted
= dataElementPtr
->highlight
;
506 dataElementPtr
->highlight
=
507 _tuiRegValueHasChanged (dataElementPtr
, frame
, &rawBuf
[0]);
508 if (dataElementPtr
->highlight
)
512 size
= REGISTER_RAW_SIZE (dataElementPtr
->itemNo
);
513 for (j
= 0; j
< size
; j
++)
514 ((char *) dataElementPtr
->value
)[j
] = rawBuf
[j
];
515 _tuiDisplayRegister (
516 dataElementPtr
->itemNo
,
518 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
520 double_precision
: unspecified_precision
));
522 else if (wasHilighted
)
524 dataElementPtr
->highlight
= FALSE
;
525 _tuiDisplayRegister (
526 dataElementPtr
->itemNo
,
528 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
530 double_precision
: unspecified_precision
));
536 } /* tuiCheckRegisterValues */
540 ** tuiToggleFloatRegs().
543 tuiToggleFloatRegs (void)
545 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
547 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
548 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
550 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
552 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
&&
553 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_SFLOAT_REGS
||
554 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
))
555 tuiShowRegisters (layoutDef
->floatRegsDisplayType
);
558 } /* tuiToggleFloatRegs */
562 _initialize_tuiRegs (void)
566 add_com ("fr", class_tui
, _tuiShowFloat_command
,
567 "Display only floating point registers\n");
568 add_com ("gr", class_tui
, _tuiShowGeneral_command
,
569 "Display only general registers\n");
570 add_com ("sr", class_tui
, _tuiShowSpecial_command
,
571 "Display only special registers\n");
572 add_com ("+r", class_tui
, _tuiScrollRegsForward_command
,
573 "Scroll the registers window forward\n");
574 add_com ("-r", class_tui
, _tuiScrollRegsBackward_command
,
575 "Scroll the register window backward\n");
576 add_com ("tf", class_tui
, _tuiToggleFloatRegs_command
,
577 "Toggle between single and double precision floating point registers.\n");
578 add_cmd (TUI_FLOAT_REGS_NAME_LOWER
,
580 _tuiToggleFloatRegs_command
,
581 "Toggle between single and double precision floating point \
588 /*****************************************
589 ** STATIC LOCAL FUNCTIONS **
590 ******************************************/
594 ** _tuiRegisterName().
595 ** Return the register name.
598 _tuiRegisterName (int regNum
)
600 return REGISTER_NAME (regNum
);
602 extern int pagination_enabled
;
605 tui_restore_gdbout (void *ui
)
607 ui_file_delete (gdb_stdout
);
608 gdb_stdout
= (struct ui_file
*) ui
;
609 pagination_enabled
= 1;
613 ** _tuiRegisterFormat
614 ** Function to format the register name and value into a buffer,
615 ** suitable for printing or display
618 _tuiRegisterFormat (char *buf
, int bufLen
, int regNum
,
619 TuiDataElementPtr dataElement
,
620 enum precision_type precision
)
622 struct ui_file
*stream
;
623 struct ui_file
*old_stdout
;
625 struct cleanup
*cleanups
;
629 name
= REGISTER_NAME (regNum
);
636 pagination_enabled
= 0;
637 old_stdout
= gdb_stdout
;
638 stream
= tui_sfileopen (bufLen
);
640 cleanups
= make_cleanup (tui_restore_gdbout
, (void*) old_stdout
);
641 gdbarch_print_registers_info (current_gdbarch
, stream
, deprecated_selected_frame
,
644 /* Save formatted output in the buffer. */
645 p
= tui_file_get_strbuf (stream
);
647 while (*p
&& *p
== *name
++ && bufLen
)
655 while (pos
< 8 && bufLen
)
661 strncpy (buf
, p
, bufLen
);
663 /* Remove the possible \n. */
664 p
= strchr (buf
, '\n');
668 do_cleanups (cleanups
);
672 #define NUM_GENERAL_REGS 32
674 ** _tuiSetGeneralRegsContent().
675 ** Set the content of the data window to consist of the general registers.
678 _tuiSetGeneralRegsContent (int refreshValuesOnly
)
680 return (_tuiSetRegsContent (0,
681 NUM_GENERAL_REGS
- 1,
682 deprecated_selected_frame
,
686 } /* _tuiSetGeneralRegsContent */
689 #ifndef PCOQ_HEAD_REGNUM
690 #define START_SPECIAL_REGS 0
692 #define START_SPECIAL_REGS PCOQ_HEAD_REGNUM
696 ** _tuiSetSpecialRegsContent().
697 ** Set the content of the data window to consist of the special registers.
700 _tuiSetSpecialRegsContent (int refreshValuesOnly
)
702 TuiStatus ret
= TUI_FAILURE
;
705 endRegNum
= FP0_REGNUM
- 1;
706 ret
= _tuiSetRegsContent (START_SPECIAL_REGS
,
708 deprecated_selected_frame
,
713 } /* _tuiSetSpecialRegsContent */
717 ** _tuiSetGeneralAndSpecialRegsContent().
718 ** Set the content of the data window to consist of the special registers.
721 _tuiSetGeneralAndSpecialRegsContent (int refreshValuesOnly
)
723 TuiStatus ret
= TUI_FAILURE
;
724 int endRegNum
= (-1);
726 endRegNum
= FP0_REGNUM
- 1;
727 ret
= _tuiSetRegsContent (
728 0, endRegNum
, deprecated_selected_frame
, TUI_SPECIAL_REGS
, refreshValuesOnly
);
731 } /* _tuiSetGeneralAndSpecialRegsContent */
734 ** _tuiSetFloatRegsContent().
735 ** Set the content of the data window to consist of the float registers.
738 _tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType
, int refreshValuesOnly
)
740 TuiStatus ret
= TUI_FAILURE
;
743 startRegNum
= FP0_REGNUM
;
744 ret
= _tuiSetRegsContent (startRegNum
,
746 deprecated_selected_frame
,
751 } /* _tuiSetFloatRegsContent */
755 ** _tuiRegValueHasChanged().
756 ** Answer TRUE if the register's value has changed, FALSE otherwise.
757 ** If TRUE, newValue is filled in with the new value.
760 _tuiRegValueHasChanged (TuiDataElementPtr dataElement
,
761 struct frame_info
*frame
,
764 int hasChanged
= FALSE
;
766 if (dataElement
->itemNo
!= UNDEFINED_ITEM
&&
767 _tuiRegisterName (dataElement
->itemNo
) != (char *) NULL
)
769 char rawBuf
[MAX_REGISTER_SIZE
];
772 if (_tuiGetRegisterRawValue (
773 dataElement
->itemNo
, rawBuf
, frame
) == TUI_SUCCESS
)
775 int size
= REGISTER_RAW_SIZE (dataElement
->itemNo
);
777 for (i
= 0; (i
< size
&& !hasChanged
); i
++)
778 hasChanged
= (((char *) dataElement
->value
)[i
] != rawBuf
[i
]);
779 if (hasChanged
&& newValue
!= (char *) NULL
)
781 for (i
= 0; i
< size
; i
++)
782 newValue
[i
] = rawBuf
[i
];
787 } /* _tuiRegValueHasChanged */
792 ** _tuiGetRegisterRawValue().
793 ** Get the register raw value. The raw value is returned in regValue.
796 _tuiGetRegisterRawValue (int regNum
, char *regValue
, struct frame_info
*frame
)
798 TuiStatus ret
= TUI_FAILURE
;
800 if (target_has_registers
)
802 frame_read_register (frame
, regNum
, regValue
);
803 /* NOTE: cagney/2003-03-13: This is bogus. It is refering to
804 the register cache and not the frame which could have pulled
805 the register value off the stack. */
806 if (register_cached (regNum
) >= 0)
810 } /* _tuiGetRegisterRawValue */
815 ** _tuiSetRegisterElement().
816 ** Function to initialize a data element with the input and
817 ** the register value.
820 _tuiSetRegisterElement (int regNum
, struct frame_info
*frame
,
821 TuiDataElementPtr dataElement
,
822 int refreshValueOnly
)
824 if (dataElement
!= (TuiDataElementPtr
) NULL
)
826 if (!refreshValueOnly
)
828 dataElement
->itemNo
= regNum
;
829 dataElement
->name
= _tuiRegisterName (regNum
);
830 dataElement
->highlight
= FALSE
;
832 if (dataElement
->value
== (Opaque
) NULL
)
833 dataElement
->value
= (Opaque
) xmalloc (MAX_REGISTER_SIZE
);
834 if (dataElement
->value
!= (Opaque
) NULL
)
835 _tuiGetRegisterRawValue (regNum
, dataElement
->value
, frame
);
839 } /* _tuiSetRegisterElement */
843 ** _tuiSetRegsContent().
844 ** Set the content of the data window to consist of the registers
845 ** numbered from startRegNum to endRegNum. Note that if
846 ** refreshValuesOnly is TRUE, startRegNum and endRegNum are ignored.
849 _tuiSetRegsContent (int startRegNum
, int endRegNum
,
850 struct frame_info
*frame
,
851 TuiRegisterDisplayType dpyType
,
852 int refreshValuesOnly
)
854 TuiStatus ret
= TUI_FAILURE
;
855 int numRegs
= endRegNum
- startRegNum
+ 1;
856 int allocatedHere
= FALSE
;
858 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0 &&
861 freeDataContent (dataWin
->detail
.dataDisplayInfo
.regsContent
,
862 dataWin
->detail
.dataDisplayInfo
.regsContentCount
);
863 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= 0;
865 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0)
867 dataWin
->detail
.dataDisplayInfo
.regsContent
=
868 allocContent (numRegs
, DATA_WIN
);
869 allocatedHere
= TRUE
;
872 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
)
876 if (!refreshValuesOnly
|| allocatedHere
)
878 dataWin
->generic
.content
= (OpaquePtr
) NULL
;
879 dataWin
->generic
.contentSize
= 0;
880 addContentElements (&dataWin
->generic
, numRegs
);
881 dataWin
->detail
.dataDisplayInfo
.regsContent
=
882 (TuiWinContent
) dataWin
->generic
.content
;
883 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= numRegs
;
886 ** Now set the register names and values
888 for (i
= startRegNum
; (i
<= endRegNum
); i
++)
890 TuiGenWinInfoPtr dataItemWin
;
892 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
893 regsContent
[i
- startRegNum
]->whichElement
.dataWindow
;
894 _tuiSetRegisterElement (
897 &((TuiWinElementPtr
) dataItemWin
->content
[0])->whichElement
.data
,
898 !allocatedHere
&& refreshValuesOnly
);
900 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
=
901 tuiCalculateRegsColumnCount (dpyType
);
903 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
905 /* delete all the windows? */
906 /* realloc content equal to dataContentCount + regsContentCount */
907 /* append dataWin->detail.dataDisplayInfo.dataContent to content */
910 dataWin
->generic
.contentSize
=
911 dataWin
->detail
.dataDisplayInfo
.regsContentCount
+
912 dataWin
->detail
.dataDisplayInfo
.dataContentCount
;
917 } /* _tuiSetRegsContent */
921 ** _tuiDisplayRegister().
922 ** Function to display a register in a window. If hilite is TRUE,
923 ** than the value will be displayed in reverse video
926 _tuiDisplayRegister (int regNum
,
927 TuiGenWinInfoPtr winInfo
, /* the data item window */
928 enum precision_type precision
)
930 if (winInfo
->handle
!= (WINDOW
*) NULL
)
934 int valueCharsWide
, labelWidth
;
935 TuiDataElementPtr dataElementPtr
= &((TuiWinContent
)
936 winInfo
->content
)[0]->whichElement
.data
;
939 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
941 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
942 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
946 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
949 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
950 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
954 valueCharsWide
= SINGLE_VALUE_WIDTH
;
955 labelWidth
= SINGLE_LABEL_WIDTH
;
960 _tuiRegisterFormat (buf
,
961 valueCharsWide
+ labelWidth
,
966 if (dataElementPtr
->highlight
)
967 wstandout (winInfo
->handle
);
969 wmove (winInfo
->handle
, 0, 0);
970 for (i
= 1; i
< winInfo
->width
; i
++)
971 waddch (winInfo
->handle
, ' ');
972 wmove (winInfo
->handle
, 0, 0);
973 waddstr (winInfo
->handle
, buf
);
975 if (dataElementPtr
->highlight
)
976 wstandend (winInfo
->handle
);
977 tuiRefreshWin (winInfo
);
980 } /* _tuiDisplayRegister */
984 _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType dpyType
)
987 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
988 { /* Data window already displayed, show the registers */
989 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= dpyType
)
990 tuiShowRegisters (dpyType
);
993 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
996 } /* _tui_vShowRegisters_commandSupport */
1000 _tuiShowFloat_command (char *arg
, int fromTTY
)
1002 if (m_winPtrIsNull (dataWin
) || !dataWin
->generic
.isVisible
||
1003 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_SFLOAT_REGS
&&
1004 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_DFLOAT_REGS
))
1005 _tui_vShowRegisters_commandSupport ((tuiLayoutDef ())->floatRegsDisplayType
);
1008 } /* _tuiShowFloat_command */
1012 _tuiShowGeneral_command (char *arg
, int fromTTY
)
1014 _tui_vShowRegisters_commandSupport (TUI_GENERAL_REGS
);
1019 _tuiShowSpecial_command (char *arg
, int fromTTY
)
1021 _tui_vShowRegisters_commandSupport (TUI_SPECIAL_REGS
);
1026 _tuiToggleFloatRegs_command (char *arg
, int fromTTY
)
1028 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
1029 tuiToggleFloatRegs ();
1032 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
1034 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
1035 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
1037 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
1042 } /* _tuiToggleFloatRegs_command */
1046 _tuiScrollRegsForward_command (char *arg
, int fromTTY
)
1048 tui_scroll (FORWARD_SCROLL
, dataWin
, 1);
1053 _tuiScrollRegsBackward_command (char *arg
, int fromTTY
)
1055 tui_scroll (BACKWARD_SCROLL
, dataWin
, 1);