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>
51 #include "tuiLayout.h"
53 #include "tuiDataWin.h"
54 #include "tuiGeneralWin.h"
57 /*****************************************
58 ** LOCAL DEFINITIONS **
59 ******************************************/
60 #define DOUBLE_FLOAT_LABEL_WIDTH 6
61 #define DOUBLE_FLOAT_LABEL_FMT "%6.6s: "
62 #define DOUBLE_FLOAT_VALUE_WIDTH 30 /*min of 16 but may be in sci notation */
64 #define SINGLE_FLOAT_LABEL_WIDTH 6
65 #define SINGLE_FLOAT_LABEL_FMT "%6.6s: "
66 #define SINGLE_FLOAT_VALUE_WIDTH 25 /* min of 8 but may be in sci notation */
68 #define SINGLE_LABEL_WIDTH 16
69 #define SINGLE_LABEL_FMT "%10.10s: "
70 #define SINGLE_VALUE_WIDTH 20 /* minimum of 8 but may be in sci notation */
72 /* In the code HP gave Cygnus, this was actually a function call to a
73 PA-specific function, which was supposed to determine whether the
74 target was a 64-bit or 32-bit processor. However, the 64-bit
75 support wasn't complete, so we didn't merge that in, so we leave
76 this here as a stub. */
79 /*****************************************
81 ******************************************/
84 /*****************************************
85 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
86 ******************************************/
87 static TuiStatus _tuiSetRegsContent
88 (int, int, struct frame_info
*, TuiRegisterDisplayType
, int);
89 static char *_tuiRegisterName (int);
90 static TuiStatus
_tuiGetRegisterRawValue (int, char *, struct frame_info
*);
91 static void _tuiSetRegisterElement
92 (int, struct frame_info
*, TuiDataElementPtr
, int);
93 static void _tuiDisplayRegister (int, TuiGenWinInfoPtr
, enum precision_type
);
94 static void _tuiRegisterFormat
95 (char *, int, int, TuiDataElementPtr
, enum precision_type
);
96 static TuiStatus
_tuiSetGeneralRegsContent (int);
97 static TuiStatus
_tuiSetSpecialRegsContent (int);
98 static TuiStatus
_tuiSetGeneralAndSpecialRegsContent (int);
99 static TuiStatus
_tuiSetFloatRegsContent (TuiRegisterDisplayType
, int);
100 static int _tuiRegValueHasChanged
101 (TuiDataElementPtr
, struct frame_info
*, char *);
102 static void _tuiShowFloat_command (char *, int);
103 static void _tuiShowGeneral_command (char *, int);
104 static void _tuiShowSpecial_command (char *, int);
105 static void _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType
);
106 static void _tuiToggleFloatRegs_command (char *, int);
107 static void _tuiScrollRegsForward_command (char *, int);
108 static void _tuiScrollRegsBackward_command (char *, int);
112 /*****************************************
113 ** PUBLIC FUNCTIONS **
114 ******************************************/
117 ** tuiLastRegsLineNo()
118 ** Answer the number of the last line in the regs display.
119 ** If there are no registers (-1) is returned.
122 tuiLastRegsLineNo (void)
124 register int numLines
= (-1);
126 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
128 numLines
= (dataWin
->detail
.dataDisplayInfo
.regsContentCount
/
129 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
);
130 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
%
131 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
135 } /* tuiLastRegsLineNo */
139 ** tuiLineFromRegElementNo()
140 ** Answer the line number that the register element at elementNo is
141 ** on. If elementNo is greater than the number of register elements
142 ** there are, -1 is returned.
145 tuiLineFromRegElementNo (int elementNo
)
147 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
155 (dataWin
->detail
.dataDisplayInfo
.regsColumnCount
* i
))
165 } /* tuiLineFromRegElementNo */
169 ** tuiFirstRegElementNoInLine()
170 ** Answer the index of the first element in lineNo. If lineNo is
171 ** past the register area (-1) is returned.
174 tuiFirstRegElementNoInLine (int lineNo
)
176 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
)
177 <= dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
178 return ((lineNo
+ 1) *
179 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) -
180 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
;
183 } /* tuiFirstRegElementNoInLine */
187 ** tuiLastRegElementNoInLine()
188 ** Answer the index of the last element in lineNo. If lineNo is past
189 ** the register area (-1) is returned.
192 tuiLastRegElementNoInLine (int lineNo
)
194 if ((lineNo
* dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) <=
195 dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
196 return ((lineNo
+ 1) *
197 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
) - 1;
200 } /* tuiLastRegElementNoInLine */
204 ** tuiCalculateRegsColumnCount
205 ** Calculate the number of columns that should be used to display
209 tuiCalculateRegsColumnCount (TuiRegisterDisplayType dpyType
)
211 int colCount
, colWidth
;
213 if (IS_64BIT
|| dpyType
== TUI_DFLOAT_REGS
)
214 colWidth
= DOUBLE_FLOAT_VALUE_WIDTH
+ DOUBLE_FLOAT_LABEL_WIDTH
;
217 if (dpyType
== TUI_SFLOAT_REGS
)
218 colWidth
= SINGLE_FLOAT_VALUE_WIDTH
+ SINGLE_FLOAT_LABEL_WIDTH
;
220 colWidth
= SINGLE_VALUE_WIDTH
+ SINGLE_LABEL_WIDTH
;
222 colCount
= (dataWin
->generic
.width
- 2) / colWidth
;
225 } /* tuiCalulateRegsColumnCount */
229 ** tuiShowRegisters().
230 ** Show the registers int the data window as indicated by dpyType.
231 ** If there is any other registers being displayed, then they are
232 ** cleared. What registers are displayed is dependent upon dpyType.
235 tuiShowRegisters (TuiRegisterDisplayType dpyType
)
237 TuiStatus ret
= TUI_FAILURE
;
238 int refreshValuesOnly
= FALSE
;
240 /* Say that registers should be displayed, even if there is a problem */
241 dataWin
->detail
.dataDisplayInfo
.displayRegs
= TRUE
;
243 if (target_has_registers
)
246 (dpyType
== dataWin
->detail
.dataDisplayInfo
.regsDisplayType
);
249 case TUI_GENERAL_REGS
:
250 ret
= _tuiSetGeneralRegsContent (refreshValuesOnly
);
252 case TUI_SFLOAT_REGS
:
253 case TUI_DFLOAT_REGS
:
254 ret
= _tuiSetFloatRegsContent (dpyType
, refreshValuesOnly
);
257 /* could ifdef out */
259 case TUI_SPECIAL_REGS
:
260 ret
= _tuiSetSpecialRegsContent (refreshValuesOnly
);
262 case TUI_GENERAL_AND_SPECIAL_REGS
:
263 ret
= _tuiSetGeneralAndSpecialRegsContent (refreshValuesOnly
);
266 /* end of potential if def */
272 if (ret
== TUI_FAILURE
)
274 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= TUI_UNDEFINED_REGS
;
275 tuiEraseDataContent (NO_REGS_STRING
);
281 /* Clear all notation of changed values */
282 for (i
= 0; (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
284 TuiGenWinInfoPtr dataItemWin
;
286 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
287 regsContent
[i
]->whichElement
.dataWindow
;
288 (&((TuiWinElementPtr
)
289 dataItemWin
->content
[0])->whichElement
.data
)->highlight
= FALSE
;
291 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
= dpyType
;
292 tuiDisplayAllData ();
294 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
297 } /* tuiShowRegisters */
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.
308 tuiDisplayRegistersFrom (int startElementNo
)
310 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
311 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
313 register int i
= startElementNo
;
314 int j
, valueCharsWide
, charsWide
, itemWinWidth
, curY
, labelWidth
;
315 enum precision_type precision
;
317 precision
= (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
318 == TUI_DFLOAT_REGS
) ?
319 double_precision
: unspecified_precision
;
321 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
323 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
324 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
328 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
331 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
332 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
336 valueCharsWide
= SINGLE_VALUE_WIDTH
;
337 labelWidth
= SINGLE_LABEL_WIDTH
;
340 itemWinWidth
= valueCharsWide
+ labelWidth
;
342 ** Now create each data "sub" window, and write the display into it.
345 while (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
&&
346 curY
<= dataWin
->generic
.viewportHeight
)
349 (j
< dataWin
->detail
.dataDisplayInfo
.regsColumnCount
&&
350 i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); j
++)
352 TuiGenWinInfoPtr dataItemWin
;
353 TuiDataElementPtr dataElementPtr
;
355 /* create the window if necessary */
356 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
357 regsContent
[i
]->whichElement
.dataWindow
;
358 dataElementPtr
= &((TuiWinElementPtr
)
359 dataItemWin
->content
[0])->whichElement
.data
;
360 if (dataItemWin
->handle
== (WINDOW
*) NULL
)
362 dataItemWin
->height
= 1;
363 dataItemWin
->width
= (precision
== double_precision
) ?
364 itemWinWidth
+ 2 : itemWinWidth
+ 1;
365 dataItemWin
->origin
.x
= (itemWinWidth
* j
) + 1;
366 dataItemWin
->origin
.y
= curY
;
367 makeWindow (dataItemWin
, DONT_BOX_WINDOW
);
368 scrollok (dataItemWin
->handle
, FALSE
);
370 touchwin (dataItemWin
->handle
);
373 ** Get the printable representation of the register
376 _tuiDisplayRegister (
377 dataElementPtr
->itemNo
, dataItemWin
, precision
);
378 i
++; /* next register */
380 curY
++; /* next row; */
385 } /* tuiDisplayRegistersFrom */
389 ** tuiDisplayRegElementAtLine().
390 ** Function to display the registers in the content from
391 ** 'startElementNo' on 'startLineNo' until the end of the
392 ** register content or the end of the display height.
393 ** This function checks that we won't display off the end
394 ** of the register display.
397 tuiDisplayRegElementAtLine (int startElementNo
, int startLineNo
)
399 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
&&
400 dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
402 register int elementNo
= startElementNo
;
404 if (startElementNo
!= 0 && startLineNo
!= 0)
406 register int lastLineNo
, firstLineOnLastPage
;
408 lastLineNo
= tuiLastRegsLineNo ();
409 firstLineOnLastPage
= lastLineNo
- (dataWin
->generic
.height
- 2);
410 if (firstLineOnLastPage
< 0)
411 firstLineOnLastPage
= 0;
413 ** If there is no other data displayed except registers,
414 ** and the elementNo causes us to scroll past the end of the
415 ** registers, adjust what element to really start the display at.
417 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
<= 0 &&
418 startLineNo
> firstLineOnLastPage
)
419 elementNo
= tuiFirstRegElementNoInLine (firstLineOnLastPage
);
421 tuiDisplayRegistersFrom (elementNo
);
425 } /* tuiDisplayRegElementAtLine */
430 ** tuiDisplayRegistersFromLine().
431 ** Function to display the registers starting at line lineNo in
432 ** the data window. Answers the line number that the display
433 ** actually started from. If nothing is displayed (-1) is returned.
436 tuiDisplayRegistersFromLine (int lineNo
, int forceDisplay
)
440 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0)
446 else if (forceDisplay
)
448 ** If we must display regs (forceDisplay is true), then make
449 ** sure that we don't display off the end of the registers.
451 if (lineNo
>= tuiLastRegsLineNo ())
453 if ((line
= tuiLineFromRegElementNo (
454 dataWin
->detail
.dataDisplayInfo
.regsContentCount
- 1)) < 0)
463 elementNo
= tuiFirstRegElementNoInLine (line
);
464 if (elementNo
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
)
465 tuiDisplayRegElementAtLine (elementNo
, line
);
472 return (-1); /* nothing was displayed */
473 } /* tuiDisplayRegistersFromLine */
477 ** tuiCheckRegisterValues()
478 ** This function check all displayed registers for changes in
479 ** values, given a particular frame. If the values have changed,
480 ** they are updated with the new value and highlighted.
483 tuiCheckRegisterValues (struct frame_info
*frame
)
485 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
487 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0 &&
488 dataWin
->detail
.dataDisplayInfo
.displayRegs
)
489 tuiShowRegisters ((tuiLayoutDef ())->regsDisplayType
);
493 char rawBuf
[MAX_REGISTER_RAW_SIZE
];
496 (i
< dataWin
->detail
.dataDisplayInfo
.regsContentCount
); i
++)
498 TuiDataElementPtr dataElementPtr
;
499 TuiGenWinInfoPtr dataItemWinPtr
;
502 dataItemWinPtr
= &dataWin
->detail
.dataDisplayInfo
.
503 regsContent
[i
]->whichElement
.dataWindow
;
504 dataElementPtr
= &((TuiWinElementPtr
)
505 dataItemWinPtr
->content
[0])->whichElement
.data
;
506 wasHilighted
= dataElementPtr
->highlight
;
507 dataElementPtr
->highlight
=
508 _tuiRegValueHasChanged (dataElementPtr
, frame
, &rawBuf
[0]);
509 if (dataElementPtr
->highlight
)
513 size
= REGISTER_RAW_SIZE (dataElementPtr
->itemNo
);
514 for (j
= 0; j
< size
; j
++)
515 ((char *) dataElementPtr
->value
)[j
] = rawBuf
[j
];
516 _tuiDisplayRegister (
517 dataElementPtr
->itemNo
,
519 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
521 double_precision
: unspecified_precision
));
523 else if (wasHilighted
)
525 dataElementPtr
->highlight
= FALSE
;
526 _tuiDisplayRegister (
527 dataElementPtr
->itemNo
,
529 ((dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
531 double_precision
: unspecified_precision
));
537 } /* tuiCheckRegisterValues */
541 ** tuiToggleFloatRegs().
544 tuiToggleFloatRegs (void)
546 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
548 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
549 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
551 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
553 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
&&
554 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_SFLOAT_REGS
||
555 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
))
556 tuiShowRegisters (layoutDef
->floatRegsDisplayType
);
559 } /* tuiToggleFloatRegs */
563 _initialize_tuiRegs (void)
567 add_com ("fr", class_tui
, _tuiShowFloat_command
,
568 "Display only floating point registers\n");
569 add_com ("gr", class_tui
, _tuiShowGeneral_command
,
570 "Display only general registers\n");
571 add_com ("sr", class_tui
, _tuiShowSpecial_command
,
572 "Display only special registers\n");
573 add_com ("+r", class_tui
, _tuiScrollRegsForward_command
,
574 "Scroll the registers window forward\n");
575 add_com ("-r", class_tui
, _tuiScrollRegsBackward_command
,
576 "Scroll the register window backward\n");
577 add_com ("tf", class_tui
, _tuiToggleFloatRegs_command
,
578 "Toggle between single and double precision floating point registers.\n");
579 add_cmd (TUI_FLOAT_REGS_NAME_LOWER
,
581 _tuiToggleFloatRegs_command
,
582 "Toggle between single and double precision floating point \
589 /*****************************************
590 ** STATIC LOCAL FUNCTIONS **
591 ******************************************/
595 ** _tuiRegisterName().
596 ** Return the register name.
599 _tuiRegisterName (int regNum
)
601 return REGISTER_NAME (regNum
);
603 extern int pagination_enabled
;
606 tui_restore_gdbout (void *ui
)
608 ui_file_delete (gdb_stdout
);
609 gdb_stdout
= (struct ui_file
*) ui
;
610 pagination_enabled
= 1;
614 ** _tuiRegisterFormat
615 ** Function to format the register name and value into a buffer,
616 ** suitable for printing or display
619 _tuiRegisterFormat (char *buf
, int bufLen
, int regNum
,
620 TuiDataElementPtr dataElement
,
621 enum precision_type precision
)
623 struct ui_file
*stream
;
624 struct ui_file
*old_stdout
;
626 struct cleanup
*cleanups
;
630 name
= REGISTER_NAME (regNum
);
637 pagination_enabled
= 0;
638 old_stdout
= gdb_stdout
;
639 stream
= tui_sfileopen (bufLen
);
641 cleanups
= make_cleanup (tui_restore_gdbout
, (void*) old_stdout
);
642 gdbarch_print_registers_info (current_gdbarch
, stream
, selected_frame
,
645 /* Save formatted output in the buffer. */
646 p
= tui_file_get_strbuf (stream
);
648 while (*p
&& *p
== *name
++ && bufLen
)
656 while (pos
< 8 && bufLen
)
662 strncpy (buf
, p
, bufLen
);
664 /* Remove the possible \n. */
665 p
= strchr (buf
, '\n');
669 do_cleanups (cleanups
);
673 #define NUM_GENERAL_REGS 32
675 ** _tuiSetGeneralRegsContent().
676 ** Set the content of the data window to consist of the general registers.
679 _tuiSetGeneralRegsContent (int refreshValuesOnly
)
681 return (_tuiSetRegsContent (0,
682 NUM_GENERAL_REGS
- 1,
687 } /* _tuiSetGeneralRegsContent */
690 #ifndef PCOQ_HEAD_REGNUM
691 #define START_SPECIAL_REGS 0
693 #define START_SPECIAL_REGS PCOQ_HEAD_REGNUM
697 ** _tuiSetSpecialRegsContent().
698 ** Set the content of the data window to consist of the special registers.
701 _tuiSetSpecialRegsContent (int refreshValuesOnly
)
703 TuiStatus ret
= TUI_FAILURE
;
706 endRegNum
= FP0_REGNUM
- 1;
709 for (i
= START_SPECIAL_REGS
; (i
< NUM_REGS
&& endRegNum
< 0); i
++)
710 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
713 ret
= _tuiSetRegsContent (START_SPECIAL_REGS
,
720 } /* _tuiSetSpecialRegsContent */
724 ** _tuiSetGeneralAndSpecialRegsContent().
725 ** Set the content of the data window to consist of the special registers.
728 _tuiSetGeneralAndSpecialRegsContent (int refreshValuesOnly
)
730 TuiStatus ret
= TUI_FAILURE
;
731 int i
, endRegNum
= (-1);
733 endRegNum
= FP0_REGNUM
- 1;
736 for (i
= 0; (i
< NUM_REGS
&& endRegNum
< 0); i
++)
737 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
740 ret
= _tuiSetRegsContent (
741 0, endRegNum
, selected_frame
, TUI_SPECIAL_REGS
, refreshValuesOnly
);
744 } /* _tuiSetGeneralAndSpecialRegsContent */
747 ** _tuiSetFloatRegsContent().
748 ** Set the content of the data window to consist of the float registers.
751 _tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType
, int refreshValuesOnly
)
753 TuiStatus ret
= TUI_FAILURE
;
756 startRegNum
= FP0_REGNUM
;
759 for (i
= NUM_REGS
- 1; (i
>= 0 && startRegNum
< 0); i
--)
760 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) != TYPE_CODE_FLT
)
763 ret
= _tuiSetRegsContent (startRegNum
,
770 } /* _tuiSetFloatRegsContent */
774 ** _tuiRegValueHasChanged().
775 ** Answer TRUE if the register's value has changed, FALSE otherwise.
776 ** If TRUE, newValue is filled in with the new value.
779 _tuiRegValueHasChanged (TuiDataElementPtr dataElement
,
780 struct frame_info
*frame
,
783 int hasChanged
= FALSE
;
785 if (dataElement
->itemNo
!= UNDEFINED_ITEM
&&
786 _tuiRegisterName (dataElement
->itemNo
) != (char *) NULL
)
788 char rawBuf
[MAX_REGISTER_RAW_SIZE
];
791 if (_tuiGetRegisterRawValue (
792 dataElement
->itemNo
, rawBuf
, frame
) == TUI_SUCCESS
)
794 int size
= REGISTER_RAW_SIZE (dataElement
->itemNo
);
796 for (i
= 0; (i
< size
&& !hasChanged
); i
++)
797 hasChanged
= (((char *) dataElement
->value
)[i
] != rawBuf
[i
]);
798 if (hasChanged
&& newValue
!= (char *) NULL
)
800 for (i
= 0; i
< size
; i
++)
801 newValue
[i
] = rawBuf
[i
];
806 } /* _tuiRegValueHasChanged */
811 ** _tuiGetRegisterRawValue().
812 ** Get the register raw value. The raw value is returned in regValue.
815 _tuiGetRegisterRawValue (int regNum
, char *regValue
, struct frame_info
*frame
)
817 TuiStatus ret
= TUI_FAILURE
;
819 if (target_has_registers
)
823 get_saved_register (regValue
, &opt
, (CORE_ADDR
*) NULL
, frame
,
824 regNum
, (enum lval_type
*) NULL
);
825 if (register_cached (regNum
) >= 0)
829 } /* _tuiGetRegisterRawValue */
834 ** _tuiSetRegisterElement().
835 ** Function to initialize a data element with the input and
836 ** the register value.
839 _tuiSetRegisterElement (int regNum
, struct frame_info
*frame
,
840 TuiDataElementPtr dataElement
,
841 int refreshValueOnly
)
843 if (dataElement
!= (TuiDataElementPtr
) NULL
)
845 if (!refreshValueOnly
)
847 dataElement
->itemNo
= regNum
;
848 dataElement
->name
= _tuiRegisterName (regNum
);
849 dataElement
->highlight
= FALSE
;
851 if (dataElement
->value
== (Opaque
) NULL
)
852 dataElement
->value
= (Opaque
) xmalloc (MAX_REGISTER_RAW_SIZE
);
853 if (dataElement
->value
!= (Opaque
) NULL
)
854 _tuiGetRegisterRawValue (regNum
, dataElement
->value
, frame
);
858 } /* _tuiSetRegisterElement */
862 ** _tuiSetRegsContent().
863 ** Set the content of the data window to consist of the registers
864 ** numbered from startRegNum to endRegNum. Note that if
865 ** refreshValuesOnly is TRUE, startRegNum and endRegNum are ignored.
868 _tuiSetRegsContent (int startRegNum
, int endRegNum
,
869 struct frame_info
*frame
,
870 TuiRegisterDisplayType dpyType
,
871 int refreshValuesOnly
)
873 TuiStatus ret
= TUI_FAILURE
;
874 int numRegs
= endRegNum
- startRegNum
+ 1;
875 int allocatedHere
= FALSE
;
877 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
> 0 &&
880 freeDataContent (dataWin
->detail
.dataDisplayInfo
.regsContent
,
881 dataWin
->detail
.dataDisplayInfo
.regsContentCount
);
882 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= 0;
884 if (dataWin
->detail
.dataDisplayInfo
.regsContentCount
<= 0)
886 dataWin
->detail
.dataDisplayInfo
.regsContent
=
887 allocContent (numRegs
, DATA_WIN
);
888 allocatedHere
= TRUE
;
891 if (dataWin
->detail
.dataDisplayInfo
.regsContent
!= (TuiWinContent
) NULL
)
895 if (!refreshValuesOnly
|| allocatedHere
)
897 dataWin
->generic
.content
= (OpaquePtr
) NULL
;
898 dataWin
->generic
.contentSize
= 0;
899 addContentElements (&dataWin
->generic
, numRegs
);
900 dataWin
->detail
.dataDisplayInfo
.regsContent
=
901 (TuiWinContent
) dataWin
->generic
.content
;
902 dataWin
->detail
.dataDisplayInfo
.regsContentCount
= numRegs
;
905 ** Now set the register names and values
907 for (i
= startRegNum
; (i
<= endRegNum
); i
++)
909 TuiGenWinInfoPtr dataItemWin
;
911 dataItemWin
= &dataWin
->detail
.dataDisplayInfo
.
912 regsContent
[i
- startRegNum
]->whichElement
.dataWindow
;
913 _tuiSetRegisterElement (
916 &((TuiWinElementPtr
) dataItemWin
->content
[0])->whichElement
.data
,
917 !allocatedHere
&& refreshValuesOnly
);
919 dataWin
->detail
.dataDisplayInfo
.regsColumnCount
=
920 tuiCalculateRegsColumnCount (dpyType
);
922 if (dataWin
->detail
.dataDisplayInfo
.dataContentCount
> 0)
924 /* delete all the windows? */
925 /* realloc content equal to dataContentCount + regsContentCount */
926 /* append dataWin->detail.dataDisplayInfo.dataContent to content */
929 dataWin
->generic
.contentSize
=
930 dataWin
->detail
.dataDisplayInfo
.regsContentCount
+
931 dataWin
->detail
.dataDisplayInfo
.dataContentCount
;
936 } /* _tuiSetRegsContent */
940 ** _tuiDisplayRegister().
941 ** Function to display a register in a window. If hilite is TRUE,
942 ** than the value will be displayed in reverse video
945 _tuiDisplayRegister (int regNum
,
946 TuiGenWinInfoPtr winInfo
, /* the data item window */
947 enum precision_type precision
)
949 if (winInfo
->handle
!= (WINDOW
*) NULL
)
953 int valueCharsWide
, labelWidth
;
954 TuiDataElementPtr dataElementPtr
= &((TuiWinContent
)
955 winInfo
->content
)[0]->whichElement
.data
;
958 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
== TUI_DFLOAT_REGS
)
960 valueCharsWide
= DOUBLE_FLOAT_VALUE_WIDTH
;
961 labelWidth
= DOUBLE_FLOAT_LABEL_WIDTH
;
965 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
==
968 valueCharsWide
= SINGLE_FLOAT_VALUE_WIDTH
;
969 labelWidth
= SINGLE_FLOAT_LABEL_WIDTH
;
973 valueCharsWide
= SINGLE_VALUE_WIDTH
;
974 labelWidth
= SINGLE_LABEL_WIDTH
;
979 _tuiRegisterFormat (buf
,
980 valueCharsWide
+ labelWidth
,
985 if (dataElementPtr
->highlight
)
986 wstandout (winInfo
->handle
);
988 wmove (winInfo
->handle
, 0, 0);
989 for (i
= 1; i
< winInfo
->width
; i
++)
990 waddch (winInfo
->handle
, ' ');
991 wmove (winInfo
->handle
, 0, 0);
992 waddstr (winInfo
->handle
, buf
);
994 if (dataElementPtr
->highlight
)
995 wstandend (winInfo
->handle
);
996 tuiRefreshWin (winInfo
);
999 } /* _tuiDisplayRegister */
1003 _tui_vShowRegisters_commandSupport (TuiRegisterDisplayType dpyType
)
1006 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
1007 { /* Data window already displayed, show the registers */
1008 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= dpyType
)
1009 tuiShowRegisters (dpyType
);
1012 (tuiLayoutDef ())->regsDisplayType
= dpyType
;
1015 } /* _tui_vShowRegisters_commandSupport */
1019 _tuiShowFloat_command (char *arg
, int fromTTY
)
1021 if (m_winPtrIsNull (dataWin
) || !dataWin
->generic
.isVisible
||
1022 (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_SFLOAT_REGS
&&
1023 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!= TUI_DFLOAT_REGS
))
1024 _tui_vShowRegisters_commandSupport ((tuiLayoutDef ())->floatRegsDisplayType
);
1027 } /* _tuiShowFloat_command */
1031 _tuiShowGeneral_command (char *arg
, int fromTTY
)
1033 _tui_vShowRegisters_commandSupport (TUI_GENERAL_REGS
);
1038 _tuiShowSpecial_command (char *arg
, int fromTTY
)
1040 _tui_vShowRegisters_commandSupport (TUI_SPECIAL_REGS
);
1045 _tuiToggleFloatRegs_command (char *arg
, int fromTTY
)
1047 if (m_winPtrNotNull (dataWin
) && dataWin
->generic
.isVisible
)
1048 tuiToggleFloatRegs ();
1051 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
1053 if (layoutDef
->floatRegsDisplayType
== TUI_SFLOAT_REGS
)
1054 layoutDef
->floatRegsDisplayType
= TUI_DFLOAT_REGS
;
1056 layoutDef
->floatRegsDisplayType
= TUI_SFLOAT_REGS
;
1061 } /* _tuiToggleFloatRegs_command */
1065 _tuiScrollRegsForward_command (char *arg
, int fromTTY
)
1067 tui_scroll (FORWARD_SCROLL
, dataWin
, 1);
1072 _tuiScrollRegsBackward_command (char *arg
, int fromTTY
)
1074 tui_scroll (BACKWARD_SCROLL
, dataWin
, 1);