Change tui_set_layout to return void
[deliverable/binutils-gdb.git] / gdb / tui / tui-regs.c
CommitLineData
f377b406 1/* TUI display registers in window.
f33c6cbf 2
42a4f53d 3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
f33c6cbf 4
f377b406 5 Contributed by Hewlett-Packard Company.
c906108c 6
f377b406 7 This file is part of GDB.
c906108c 8
f377b406
SC
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
f377b406
SC
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
21
22#include "defs.h"
e17c207e 23#include "arch-utils.h"
d7b2e967
AC
24#include "tui/tui.h"
25#include "tui/tui-data.h"
c906108c
SS
26#include "symtab.h"
27#include "gdbtypes.h"
28#include "gdbcmd.h"
29#include "frame.h"
bc77de56 30#include "regcache.h"
c906108c
SS
31#include "inferior.h"
32#include "target.h"
d7b2e967
AC
33#include "tui/tui-layout.h"
34#include "tui/tui-win.h"
35#include "tui/tui-windata.h"
36#include "tui/tui-wingeneral.h"
37#include "tui/tui-file.h"
2c0b251b 38#include "tui/tui-regs.h"
312809f8 39#include "tui/tui-io.h"
10f59415 40#include "reggroups.h"
79a45b7d 41#include "valprint.h"
51f0e40d 42#include "completer.h"
c906108c 43
6a83354a 44#include "gdb_curses.h"
96ec9981 45
c906108c
SS
46
47/*****************************************
10f59415 48** STATIC LOCAL FUNCTIONS FORWARD DECLS **
c906108c 49******************************************/
41bcff7f 50static void tui_display_register (struct tui_data_item_window *data);
c906108c 51
e80cd204
TT
52static void tui_show_register_group (tui_data_window *win_info,
53 struct reggroup *group,
21e1c91e
TT
54 struct frame_info *frame,
55 int refresh_values_only);
5eccfcc2
UW
56
57static enum tui_status tui_get_register (struct frame_info *frame,
41bcff7f
TT
58 struct tui_data_item_window *data,
59 int regnum, bool *changedp);
5eccfcc2 60
c906108c
SS
61
62
63/*****************************************
64** PUBLIC FUNCTIONS **
65******************************************/
66
0b5ec218
TT
67/* See tui-data.h. */
68
c906108c 69int
0b5ec218 70tui_data_window::last_regs_line_no () const
c906108c 71{
d02c80cd 72 int num_lines = (-1);
c906108c 73
0b5ec218 74 if (!regs_content.empty ())
c906108c 75 {
0b5ec218
TT
76 num_lines = regs_content.size () / regs_column_count;
77 if (regs_content.size () % regs_column_count)
6ba8e26f 78 num_lines++;
c906108c 79 }
6ba8e26f 80 return num_lines;
55fb0713 81}
c906108c 82
3b23c5f2 83/* See tui-data.h. */
c906108c 84
c906108c 85int
3b23c5f2 86tui_data_window::line_from_reg_element_no (int element_no) const
c906108c 87{
3b23c5f2 88 if (element_no < regs_content.size ())
c906108c
SS
89 {
90 int i, line = (-1);
91
92 i = 1;
93 while (line == (-1))
94 {
3b23c5f2 95 if (element_no < regs_column_count * i)
c906108c
SS
96 line = i - 1;
97 else
98 i++;
99 }
100
101 return line;
102 }
103 else
104 return (-1);
55fb0713 105}
c906108c 106
baff0c28 107/* See tui-data.h. */
c906108c 108
c906108c 109int
baff0c28 110tui_data_window::first_reg_element_no_inline (int line_no) const
c906108c 111{
baff0c28
TT
112 if (line_no * regs_column_count <= regs_content.size ())
113 return ((line_no + 1) * regs_column_count) - regs_column_count;
c906108c
SS
114 else
115 return (-1);
55fb0713 116}
c906108c
SS
117
118
10f59415
SC
119/* Show the registers of the given group in the data window
120 and refresh the window. */
c906108c 121void
10f59415 122tui_show_registers (struct reggroup *group)
c906108c 123{
0bfbda3b
SC
124 /* Make sure the curses mode is enabled. */
125 tui_enable ();
126
127 /* Make sure the register window is visible. If not, select an
128 appropriate layout. */
cb2ce893 129 if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
7bd0be3a 130 tui_set_layout_by_name (DATA_NAME);
0bfbda3b 131
10f59415
SC
132 if (group == 0)
133 group = general_reggroup;
c906108c 134
1cc6d956
MS
135 /* Say that registers should be displayed, even if there is a
136 problem. */
ceb13a13 137 TUI_DATA_WIN->display_regs = true;
10f59415
SC
138
139 if (target_has_registers && target_has_stack && target_has_memory)
c906108c 140 {
e80cd204 141 tui_show_register_group (TUI_DATA_WIN, group, get_selected_frame (NULL),
21e1c91e 142 group == TUI_DATA_WIN->current_group);
368c1354 143
1cc6d956 144 /* Clear all notation of changed values. */
21e1c91e 145 for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
c906108c 146 {
21e1c91e
TT
147 if (data_item_win != nullptr)
148 data_item_win->highlight = false;
c906108c 149 }
238eb706 150 TUI_DATA_WIN->current_group = group;
50daf268 151 TUI_DATA_WIN->display_all_data ();
c906108c 152 }
368c1354
TT
153 else
154 {
155 TUI_DATA_WIN->current_group = 0;
156 TUI_DATA_WIN->erase_data_content (NO_REGS_STRING);
157 }
55fb0713 158}
c906108c
SS
159
160
10f59415 161/* Set the data window to display the registers of the register group
1cc6d956
MS
162 using the given frame. Values are refreshed only when
163 refresh_values_only is TRUE. */
10f59415 164
21e1c91e 165static void
e80cd204
TT
166tui_show_register_group (tui_data_window *win_info,
167 struct reggroup *group,
08ef48c5
MS
168 struct frame_info *frame,
169 int refresh_values_only)
10f59415 170{
5eccfcc2 171 struct gdbarch *gdbarch = get_frame_arch (frame);
10f59415 172 int nr_regs;
10f59415
SC
173 int regnum, pos;
174 char title[80];
10f59415
SC
175
176 /* Make a new title showing which group we display. */
177 snprintf (title, sizeof (title) - 1, "Register group: %s",
178 reggroup_name (group));
e80cd204
TT
179 xfree (win_info->title);
180 win_info->title = xstrdup (title);
10f59415
SC
181
182 /* See how many registers must be displayed. */
183 nr_regs = 0;
f6efe3f8 184 for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
10f59415 185 {
d20c1c3f
PA
186 const char *name;
187
188 /* Must be in the group. */
189 if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
190 continue;
191
192 /* If the register name is empty, it is undefined for this
193 processor, so don't display anything. */
194 name = gdbarch_register_name (gdbarch, regnum);
195 if (name == 0 || *name == '\0')
196 continue;
197
198 nr_regs++;
10f59415
SC
199 }
200
21e1c91e 201 if (!refresh_values_only)
e80cd204 202 win_info->regs_content.clear ();
10f59415 203
e80cd204
TT
204 if (nr_regs < win_info->regs_content.size ())
205 win_info->regs_content.resize (nr_regs);
21e1c91e 206 else
10f59415 207 {
e80cd204
TT
208 for (int i = win_info->regs_content.size (); i < nr_regs; ++i)
209 win_info->regs_content.emplace_back (new tui_data_item_window ());
10f59415
SC
210 }
211
21e1c91e
TT
212 /* Now set the register names and values. */
213 pos = 0;
214 for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
10f59415 215 {
21e1c91e
TT
216 struct tui_data_item_window *data_item_win;
217 const char *name;
10f59415 218
21e1c91e
TT
219 /* Must be in the group. */
220 if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
221 continue;
10f59415 222
21e1c91e
TT
223 /* If the register name is empty, it is undefined for this
224 processor, so don't display anything. */
225 name = gdbarch_register_name (gdbarch, regnum);
226 if (name == 0 || *name == '\0')
227 continue;
10f59415 228
e80cd204 229 data_item_win = win_info->regs_content[pos].get ();
21e1c91e
TT
230 if (data_item_win)
231 {
232 if (!refresh_values_only)
233 {
234 data_item_win->item_no = regnum;
235 data_item_win->name = name;
236 data_item_win->highlight = false;
237 }
238 tui_get_register (frame, data_item_win, regnum, 0);
239 }
240 pos++;
241 }
10f59415
SC
242}
243
517e9505
TT
244/* See tui-data.h. */
245
c906108c 246void
517e9505 247tui_data_window::display_registers_from (int start_element_no)
c906108c 248{
517e9505 249 if (!regs_content.empty ())
c906108c 250 {
0043e6a5 251 int j, item_win_width, cur_y;
10f59415
SC
252
253 int max_len = 0;
517e9505 254 for (auto &&data_item_win : regs_content)
10f59415 255 {
10f59415
SC
256 char *p;
257 int len;
258
10f59415 259 len = 0;
41bcff7f 260 p = data_item_win->content;
10f59415
SC
261 if (p != 0)
262 while (*p)
263 {
264 if (*p++ == '\t')
265 len = 8 * ((len / 8) + 1);
266 else
267 len++;
268 }
269
270 if (len > max_len)
271 max_len = len;
272 }
273 item_win_width = max_len + 1;
21e1c91e 274 int i = start_element_no;
10f59415 275
517e9505
TT
276 regs_column_count = (width - 2) / item_win_width;
277 if (regs_column_count == 0)
278 regs_column_count = 1;
279 item_win_width = (width - 2) / regs_column_count;
10f59415 280
ef5eab5a
MS
281 /* Now create each data "sub" window, and write the display into
282 it. */
6ba8e26f 283 cur_y = 1;
517e9505
TT
284 while (i < regs_content.size ()
285 && cur_y <= viewport_height)
c906108c
SS
286 {
287 for (j = 0;
517e9505 288 j < regs_column_count && i < regs_content.size ();
e5908723 289 j++)
c906108c 290 {
41bcff7f 291 struct tui_data_item_window *data_item_win;
c906108c 292
1cc6d956 293 /* Create the window if necessary. */
517e9505 294 data_item_win = regs_content[i].get ();
cafb3438 295 if (data_item_win->handle != NULL
10f59415
SC
296 && (data_item_win->height != 1
297 || data_item_win->width != item_win_width
298 || data_item_win->origin.x != (item_win_width * j) + 1
299 || data_item_win->origin.y != cur_y))
300 {
301 tui_delete_win (data_item_win->handle);
302 data_item_win->handle = 0;
303 }
304
cafb3438 305 if (data_item_win->handle == NULL)
c906108c 306 {
6ba8e26f 307 data_item_win->height = 1;
10f59415 308 data_item_win->width = item_win_width;
6ba8e26f
AC
309 data_item_win->origin.x = (item_win_width * j) + 1;
310 data_item_win->origin.y = cur_y;
311 tui_make_window (data_item_win, DONT_BOX_WINDOW);
312 scrollok (data_item_win->handle, FALSE);
c906108c 313 }
6ba8e26f 314 touchwin (data_item_win->handle);
fea14702 315
10f59415
SC
316 /* Get the printable representation of the register
317 and display it. */
41bcff7f 318 tui_display_register (data_item_win);
1cc6d956 319 i++; /* Next register. */
c906108c 320 }
1cc6d956 321 cur_y++; /* Next row. */
c906108c
SS
322 }
323 }
55fb0713 324}
c906108c 325
aca2dd16 326/* See tui-data.h. */
c906108c 327
aca2dd16
TT
328void
329tui_data_window::display_reg_element_at_line (int start_element_no,
330 int start_line_no)
c906108c 331{
aca2dd16 332 if (!regs_content.empty ())
c906108c 333 {
d02c80cd 334 int element_no = start_element_no;
c906108c 335
6ba8e26f 336 if (start_element_no != 0 && start_line_no != 0)
c906108c 337 {
d02c80cd 338 int last_line_no, first_line_on_last_page;
c906108c 339
aca2dd16
TT
340 last_line_no = last_regs_line_no ();
341 first_line_on_last_page = last_line_no - (height - 2);
6ba8e26f
AC
342 if (first_line_on_last_page < 0)
343 first_line_on_last_page = 0;
ef5eab5a 344
115ac53b 345 /* If the element_no causes us to scroll past the end of the
ef5eab5a
MS
346 registers, adjust what element to really start the
347 display at. */
115ac53b 348 if (start_line_no > first_line_on_last_page)
aca2dd16 349 element_no = first_reg_element_no_inline (first_line_on_last_page);
c906108c 350 }
aca2dd16 351 display_registers_from (element_no);
c906108c 352 }
6ba8e26f 353}
c906108c 354
517e9505 355/* See tui-data.h. */
c906108c 356
c906108c 357int
517e9505 358tui_data_window::display_registers_from_line (int line_no)
c906108c 359{
517e9505
TT
360 tui_check_and_display_highlight_if_needed (this);
361 if (!regs_content.empty ())
c906108c 362 {
80cb6c27 363 int element_no;
c906108c 364
6ba8e26f 365 if (line_no < 0)
80cb6c27
TT
366 line_no = 0;
367 else
368 {
369 /* Make sure that we don't display off the end of the
ef5eab5a 370 registers. */
517e9505 371 if (line_no >= last_regs_line_no ())
c906108c 372 {
517e9505
TT
373 line_no = line_from_reg_element_no (regs_content.size () - 1);
374 if (line_no < 0)
80cb6c27 375 line_no = 0;
c906108c 376 }
c906108c 377 }
c906108c 378
517e9505
TT
379 element_no = first_reg_element_no_inline (line_no);
380 if (element_no < regs_content.size ())
aca2dd16 381 display_reg_element_at_line (element_no, line_no);
c906108c 382 else
80cb6c27 383 line_no = (-1);
c906108c 384
80cb6c27 385 return line_no;
c906108c
SS
386 }
387
1cc6d956 388 return (-1); /* Nothing was displayed. */
55fb0713 389}
c906108c
SS
390
391
55fb0713
AC
392/* This function check all displayed registers for changes in values,
393 given a particular frame. If the values have changed, they are
394 updated with the new value and highlighted. */
c906108c 395void
55fb0713 396tui_check_register_values (struct frame_info *frame)
c906108c 397{
e5908723 398 if (TUI_DATA_WIN != NULL
cb2ce893 399 && TUI_DATA_WIN->is_visible)
c906108c 400 {
21e1c91e 401 if (TUI_DATA_WIN->regs_content.empty ()
238eb706
TT
402 && TUI_DATA_WIN->display_regs)
403 tui_show_registers (TUI_DATA_WIN->current_group);
c906108c
SS
404 else
405 {
21e1c91e 406 for (auto &&data_item_win_ptr : TUI_DATA_WIN->regs_content)
c906108c 407 {
6ba8e26f 408 int was_hilighted;
c906108c 409
41bcff7f 410 was_hilighted = data_item_win_ptr->highlight;
10f59415 411
21e1c91e 412 tui_get_register (frame, data_item_win_ptr.get (),
41bcff7f
TT
413 data_item_win_ptr->item_no,
414 &data_item_win_ptr->highlight);
10f59415 415
41bcff7f 416 if (data_item_win_ptr->highlight || was_hilighted)
21e1c91e 417 tui_display_register (data_item_win_ptr.get ());
c906108c
SS
418 }
419 }
420 }
55fb0713 421}
c906108c 422
1cc6d956
MS
423/* Display a register in a window. If hilite is TRUE, then the value
424 will be displayed in reverse video. */
10f59415 425static void
41bcff7f 426tui_display_register (struct tui_data_item_window *data)
10f59415 427{
41bcff7f 428 if (data->handle != NULL)
10f59415
SC
429 {
430 int i;
c906108c 431
10f59415 432 if (data->highlight)
cae3f17b
JB
433 /* We ignore the return value, casting it to void in order to avoid
434 a compiler warning. The warning itself was introduced by a patch
435 to ncurses 5.7 dated 2009-08-29, changing this macro to expand
436 to code that causes the compiler to generate an unused-value
437 warning. */
41bcff7f 438 (void) wstandout (data->handle);
10f59415 439
41bcff7f
TT
440 wmove (data->handle, 0, 0);
441 for (i = 1; i < data->width; i++)
442 waddch (data->handle, ' ');
443 wmove (data->handle, 0, 0);
10f59415 444 if (data->content)
41bcff7f 445 waddstr (data->handle, data->content);
10f59415
SC
446
447 if (data->highlight)
cae3f17b
JB
448 /* We ignore the return value, casting it to void in order to avoid
449 a compiler warning. The warning itself was introduced by a patch
450 to ncurses 5.7 dated 2009-08-29, changing this macro to expand
451 to code that causes the compiler to generate an unused-value
452 warning. */
41bcff7f
TT
453 (void) wstandend (data->handle);
454 data->refresh_window ();
10f59415
SC
455 }
456}
457
51f0e40d
AB
458/* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap
459 around behaviour. Returns the next register group, or NULL if the
460 register window is not currently being displayed. */
461
462static struct reggroup *
fe3eaf1c 463tui_reg_next (struct reggroup *current_group, struct gdbarch *gdbarch)
c906108c 464{
51f0e40d 465 struct reggroup *group = NULL;
e17c207e 466
fe3eaf1c 467 if (current_group != NULL)
10f59415 468 {
fe3eaf1c 469 group = reggroup_next (gdbarch, current_group);
b75c69bb
AB
470 if (group == NULL)
471 group = reggroup_next (gdbarch, NULL);
10f59415 472 }
51f0e40d 473 return group;
10f59415
SC
474}
475
51f0e40d
AB
476/* Helper for "tui reg prev", wraps a call to REGGROUP_PREV, but adds wrap
477 around behaviour. Returns the previous register group, or NULL if the
478 register window is not currently being displayed. */
55b40027 479
51f0e40d 480static struct reggroup *
fe3eaf1c 481tui_reg_prev (struct reggroup *current_group, struct gdbarch *gdbarch)
55b40027 482{
51f0e40d 483 struct reggroup *group = NULL;
55b40027 484
fe3eaf1c 485 if (current_group != NULL)
55b40027 486 {
fe3eaf1c 487 group = reggroup_prev (gdbarch, current_group);
55b40027
AB
488 if (group == NULL)
489 group = reggroup_prev (gdbarch, NULL);
55b40027 490 }
51f0e40d 491 return group;
55b40027
AB
492}
493
51f0e40d
AB
494/* Implement the 'tui reg' command. Changes the register group displayed
495 in the tui register window. Displays the tui register window if it is
496 not already on display. */
c906108c 497
10f59415 498static void
e2d8ae16 499tui_reg_command (const char *args, int from_tty)
10f59415 500{
51f0e40d 501 struct gdbarch *gdbarch = get_current_arch ();
c906108c 502
51f0e40d
AB
503 if (args != NULL)
504 {
505 struct reggroup *group, *match = NULL;
506 size_t len = strlen (args);
507
508 /* Make sure the curses mode is enabled. */
509 tui_enable ();
510
511 /* Make sure the register window is visible. If not, select an
512 appropriate layout. We need to do this before trying to run the
513 'next' or 'prev' commands. */
cb2ce893 514 if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
51f0e40d
AB
515 tui_set_layout_by_name (DATA_NAME);
516
fe3eaf1c
TT
517 struct reggroup *current_group = NULL;
518 if (TUI_DATA_WIN != NULL)
519 current_group = TUI_DATA_WIN->current_group;
51f0e40d 520 if (strncmp (args, "next", len) == 0)
fe3eaf1c 521 match = tui_reg_next (current_group, gdbarch);
51f0e40d 522 else if (strncmp (args, "prev", len) == 0)
fe3eaf1c 523 match = tui_reg_prev (current_group, gdbarch);
51f0e40d
AB
524
525 /* This loop matches on the initial part of a register group
526 name. If this initial part in ARGS matches only one register
527 group then the switch is made. */
528 for (group = reggroup_next (gdbarch, NULL);
529 group != NULL;
530 group = reggroup_next (gdbarch, group))
531 {
532 if (strncmp (reggroup_name (group), args, len) == 0)
533 {
534 if (match != NULL)
535 error (_("ambiguous register group name '%s'"), args);
536 match = group;
537 }
538 }
539
540 if (match == NULL)
541 error (_("unknown register group '%s'"), args);
542
543 tui_show_registers (match);
544 }
545 else
546 {
547 struct reggroup *group;
548 int first;
549
550 printf_unfiltered (_("\"tui reg\" must be followed by the name of "
551 "either a register group,\nor one of 'next' "
552 "or 'prev'. Known register groups are:\n"));
553
554 for (first = 1, group = reggroup_next (gdbarch, NULL);
555 group != NULL;
556 first = 0, group = reggroup_next (gdbarch, group))
557 {
558 if (!first)
559 printf_unfiltered (", ");
560 printf_unfiltered ("%s", reggroup_name (group));
561 }
562
563 printf_unfiltered ("\n");
564 }
10f59415
SC
565}
566
51f0e40d
AB
567/* Complete names of register groups, and add the special "prev" and "next"
568 names. */
c906108c 569
eb3ff9a5 570static void
51f0e40d 571tui_reggroup_completer (struct cmd_list_element *ignore,
eb3ff9a5 572 completion_tracker &tracker,
51f0e40d 573 const char *text, const char *word)
10f59415 574{
51f0e40d
AB
575 static const char *extra[] = { "next", "prev", NULL };
576 size_t len = strlen (word);
577 const char **tmp;
578
eb3ff9a5 579 reggroup_completer (ignore, tracker, text, word);
51f0e40d 580
eb3ff9a5 581 /* XXXX use complete_on_enum instead? */
51f0e40d
AB
582 for (tmp = extra; *tmp != NULL; ++tmp)
583 {
584 if (strncmp (word, *tmp, len) == 0)
b02f78f9 585 tracker.add_completion (make_unique_xstrdup (*tmp));
51f0e40d 586 }
10f59415 587}
c906108c
SS
588
589void
6ba8e26f 590_initialize_tui_regs (void)
c906108c 591{
51f0e40d 592 struct cmd_list_element **tuicmd, *cmd;
10f59415
SC
593
594 tuicmd = tui_get_cmd_list ();
595
51f0e40d
AB
596 cmd = add_cmd ("reg", class_tui, tui_reg_command, _("\
597TUI command to control the register window."), tuicmd);
598 set_cmd_completer (cmd, tui_reggroup_completer);
41783295 599}
c906108c
SS
600
601
602/*****************************************
603** STATIC LOCAL FUNCTIONS **
604******************************************/
605
6eed1678
PA
606/* Get the register from the frame and return a printable
607 representation of it. */
608
609static char *
610tui_register_format (struct frame_info *frame, int regnum)
c906108c 611{
5eccfcc2 612 struct gdbarch *gdbarch = get_frame_arch (frame);
d20c1c3f 613
d7e74731
PA
614 string_file stream;
615
31b68d4a
TT
616 scoped_restore save_pagination
617 = make_scoped_restore (&pagination_enabled, 0);
618 scoped_restore save_stdout
619 = make_scoped_restore (&gdb_stdout, &stream);
620
d7e74731 621 gdbarch_print_registers_info (gdbarch, &stream, frame, regnum, 1);
c46cc7df
SC
622
623 /* Remove the possible \n. */
d7e74731
PA
624 std::string &str = stream.string ();
625 if (!str.empty () && str.back () == '\n')
626 str.resize (str.size () - 1);
c46cc7df 627
312809f8 628 /* Expand tabs into spaces, since ncurses on MS-Windows doesn't. */
31b68d4a 629 return tui_expand_tabs (str.c_str (), 0);
c46cc7df 630}
c906108c 631
1cc6d956
MS
632/* Get the register value from the given frame and format it for the
633 display. When changep is set, check if the new register value has
634 changed with respect to the previous call. */
22940a24 635static enum tui_status
5eccfcc2 636tui_get_register (struct frame_info *frame,
41bcff7f
TT
637 struct tui_data_item_window *data,
638 int regnum, bool *changedp)
c906108c 639{
22940a24 640 enum tui_status ret = TUI_FAILURE;
c906108c 641
10f59415 642 if (changedp)
41bcff7f 643 *changedp = false;
c906108c
SS
644 if (target_has_registers)
645 {
6eed1678 646 char *prev_content = data->content;
10f59415 647
6eed1678 648 data->content = tui_register_format (frame, regnum);
9c5ea4d9 649
6eed1678
PA
650 if (changedp != NULL
651 && strcmp (prev_content, data->content) != 0)
41bcff7f 652 *changedp = true;
d20c1c3f 653
6eed1678 654 xfree (prev_content);
9c5ea4d9
UW
655
656 ret = TUI_SUCCESS;
c906108c 657 }
c906108c 658 return ret;
6ba8e26f 659}
This page took 2.049375 seconds and 4 git commands to generate.