PageRenderTime 26ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/src/freebsd/contrib/gdb/gdb/tui/tui-regs.c

https://bitbucket.org/killerpenguinassassins/open_distrib_devel
C | 754 lines | 552 code | 106 blank | 96 comment | 118 complexity | a87f4748cf7971f7029fb85eb32a9c1c MD5 | raw file
Possible License(s): CC0-1.0, MIT, LGPL-2.0, LGPL-3.0, WTFPL, GPL-2.0, BSD-2-Clause, AGPL-3.0, CC-BY-SA-3.0, MPL-2.0, JSON, BSD-3-Clause-No-Nuclear-License-2014, LGPL-2.1, CPL-1.0, AGPL-1.0, 0BSD, ISC, Apache-2.0, GPL-3.0, IPL-1.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /* TUI display registers in window.
  2. Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
  3. Foundation, Inc.
  4. Contributed by Hewlett-Packard Company.
  5. This file is part of GDB.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place - Suite 330,
  17. Boston, MA 02111-1307, USA. */
  18. #include "defs.h"
  19. #include "tui/tui.h"
  20. #include "tui/tui-data.h"
  21. #include "symtab.h"
  22. #include "gdbtypes.h"
  23. #include "gdbcmd.h"
  24. #include "frame.h"
  25. #include "regcache.h"
  26. #include "inferior.h"
  27. #include "target.h"
  28. #include "gdb_string.h"
  29. #include "tui/tui-layout.h"
  30. #include "tui/tui-win.h"
  31. #include "tui/tui-windata.h"
  32. #include "tui/tui-wingeneral.h"
  33. #include "tui/tui-file.h"
  34. #include "reggroups.h"
  35. #include "gdb_curses.h"
  36. /*****************************************
  37. ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
  38. ******************************************/
  39. static void
  40. tui_display_register (struct tui_data_element *data,
  41. struct tui_gen_win_info *win_info);
  42. static enum tui_status
  43. tui_show_register_group (struct gdbarch *gdbarch, struct reggroup *group,
  44. struct frame_info *frame, int refresh_values_only);
  45. static enum tui_status
  46. tui_get_register (struct gdbarch *gdbarch, struct frame_info *frame,
  47. struct tui_data_element *data, int regnum, int *changedp);
  48. static void tui_register_format
  49. (struct gdbarch *, struct frame_info *, struct tui_data_element*, int);
  50. static void tui_scroll_regs_forward_command (char *, int);
  51. static void tui_scroll_regs_backward_command (char *, int);
  52. /*****************************************
  53. ** PUBLIC FUNCTIONS **
  54. ******************************************/
  55. /* Answer the number of the last line in the regs display. If there
  56. are no registers (-1) is returned. */
  57. int
  58. tui_last_regs_line_no (void)
  59. {
  60. int num_lines = (-1);
  61. if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
  62. {
  63. num_lines = (TUI_DATA_WIN->detail.data_display_info.regs_content_count /
  64. TUI_DATA_WIN->detail.data_display_info.regs_column_count);
  65. if (TUI_DATA_WIN->detail.data_display_info.regs_content_count %
  66. TUI_DATA_WIN->detail.data_display_info.regs_column_count)
  67. num_lines++;
  68. }
  69. return num_lines;
  70. }
  71. /* Answer the line number that the register element at element_no is
  72. on. If element_no is greater than the number of register elements
  73. there are, -1 is returned. */
  74. int
  75. tui_line_from_reg_element_no (int element_no)
  76. {
  77. if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
  78. {
  79. int i, line = (-1);
  80. i = 1;
  81. while (line == (-1))
  82. {
  83. if (element_no <
  84. (TUI_DATA_WIN->detail.data_display_info.regs_column_count * i))
  85. line = i - 1;
  86. else
  87. i++;
  88. }
  89. return line;
  90. }
  91. else
  92. return (-1);
  93. }
  94. /* Answer the index of the first element in line_no. If line_no is past
  95. the register area (-1) is returned. */
  96. int
  97. tui_first_reg_element_no_inline (int line_no)
  98. {
  99. if ((line_no * TUI_DATA_WIN->detail.data_display_info.regs_column_count)
  100. <= TUI_DATA_WIN->detail.data_display_info.regs_content_count)
  101. return ((line_no + 1) *
  102. TUI_DATA_WIN->detail.data_display_info.regs_column_count) -
  103. TUI_DATA_WIN->detail.data_display_info.regs_column_count;
  104. else
  105. return (-1);
  106. }
  107. /* Answer the index of the last element in line_no. If line_no is
  108. past the register area (-1) is returned. */
  109. int
  110. tui_last_reg_element_no_in_line (int line_no)
  111. {
  112. if ((line_no * TUI_DATA_WIN->detail.data_display_info.regs_column_count) <=
  113. TUI_DATA_WIN->detail.data_display_info.regs_content_count)
  114. return ((line_no + 1) *
  115. TUI_DATA_WIN->detail.data_display_info.regs_column_count) - 1;
  116. else
  117. return (-1);
  118. }
  119. /* Show the registers of the given group in the data window
  120. and refresh the window. */
  121. void
  122. tui_show_registers (struct reggroup *group)
  123. {
  124. enum tui_status ret = TUI_FAILURE;
  125. struct tui_data_info *display_info;
  126. /* Make sure the curses mode is enabled. */
  127. tui_enable ();
  128. /* Make sure the register window is visible. If not, select an
  129. appropriate layout. */
  130. if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->generic.is_visible)
  131. tui_set_layout_for_display_command (DATA_NAME);
  132. display_info = &TUI_DATA_WIN->detail.data_display_info;
  133. if (group == 0)
  134. group = general_reggroup;
  135. /* Say that registers should be displayed, even if there is a problem. */
  136. display_info->display_regs = TRUE;
  137. if (target_has_registers && target_has_stack && target_has_memory)
  138. {
  139. ret = tui_show_register_group (current_gdbarch, group,
  140. get_current_frame (),
  141. group == display_info->current_group);
  142. }
  143. if (ret == TUI_FAILURE)
  144. {
  145. display_info->current_group = 0;
  146. tui_erase_data_content (NO_REGS_STRING);
  147. }
  148. else
  149. {
  150. int i;
  151. /* Clear all notation of changed values */
  152. for (i = 0; i < display_info->regs_content_count; i++)
  153. {
  154. struct tui_gen_win_info *data_item_win;
  155. struct tui_win_element *win;
  156. data_item_win = &display_info->regs_content[i]
  157. ->which_element.data_window;
  158. win = (struct tui_win_element *) data_item_win->content[0];
  159. win->which_element.data.highlight = FALSE;
  160. }
  161. display_info->current_group = group;
  162. tui_display_all_data ();
  163. }
  164. }
  165. /* Set the data window to display the registers of the register group
  166. using the given frame. Values are refreshed only when refresh_values_only
  167. is TRUE. */
  168. static enum tui_status
  169. tui_show_register_group (struct gdbarch *gdbarch, struct reggroup *group,
  170. struct frame_info *frame, int refresh_values_only)
  171. {
  172. enum tui_status ret = TUI_FAILURE;
  173. int nr_regs;
  174. int allocated_here = FALSE;
  175. int regnum, pos;
  176. char title[80];
  177. struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;
  178. /* Make a new title showing which group we display. */
  179. snprintf (title, sizeof (title) - 1, "Register group: %s",
  180. reggroup_name (group));
  181. xfree (TUI_DATA_WIN->generic.title);
  182. TUI_DATA_WIN->generic.title = xstrdup (title);
  183. /* See how many registers must be displayed. */
  184. nr_regs = 0;
  185. for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
  186. {
  187. /* Must be in the group and have a name. */
  188. if (gdbarch_register_reggroup_p (gdbarch, regnum, group)
  189. && gdbarch_register_name (gdbarch, regnum) != 0)
  190. nr_regs++;
  191. }
  192. if (display_info->regs_content_count > 0 && !refresh_values_only)
  193. {
  194. tui_free_data_content (display_info->regs_content,
  195. display_info->regs_content_count);
  196. display_info->regs_content_count = 0;
  197. }
  198. if (display_info->regs_content_count <= 0)
  199. {
  200. display_info->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
  201. allocated_here = TRUE;
  202. refresh_values_only = FALSE;
  203. }
  204. if (display_info->regs_content != (tui_win_content) NULL)
  205. {
  206. if (!refresh_values_only || allocated_here)
  207. {
  208. TUI_DATA_WIN->generic.content = (void*) NULL;
  209. TUI_DATA_WIN->generic.content_size = 0;
  210. tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs);
  211. display_info->regs_content
  212. = (tui_win_content) TUI_DATA_WIN->generic.content;
  213. display_info->regs_content_count = nr_regs;
  214. }
  215. /* Now set the register names and values */
  216. pos = 0;
  217. for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
  218. {
  219. struct tui_gen_win_info *data_item_win;
  220. struct tui_data_element *data;
  221. const char *name;
  222. if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
  223. continue;
  224. name = gdbarch_register_name (gdbarch, regnum);
  225. if (name == 0)
  226. continue;
  227. data_item_win =
  228. &display_info->regs_content[pos]->which_element.data_window;
  229. data =
  230. &((struct tui_win_element *) data_item_win->content[0])->which_element.data;
  231. if (data)
  232. {
  233. if (!refresh_values_only)
  234. {
  235. data->item_no = regnum;
  236. data->name = name;
  237. data->highlight = FALSE;
  238. }
  239. if (data->value == (void*) NULL)
  240. data->value = (void*) xmalloc (MAX_REGISTER_SIZE);
  241. tui_get_register (gdbarch, frame, data, regnum, 0);
  242. }
  243. pos++;
  244. }
  245. TUI_DATA_WIN->generic.content_size =
  246. display_info->regs_content_count + display_info->data_content_count;
  247. ret = TUI_SUCCESS;
  248. }
  249. return ret;
  250. }
  251. /* Function to display the registers in the content from
  252. 'start_element_no' until the end of the register content or the end
  253. of the display height. No checking for displaying past the end of
  254. the registers is done here. */
  255. void
  256. tui_display_registers_from (int start_element_no)
  257. {
  258. struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info;
  259. if (display_info->regs_content != (tui_win_content) NULL &&
  260. display_info->regs_content_count > 0)
  261. {
  262. int i = start_element_no;
  263. int j, value_chars_wide, item_win_width, cur_y;
  264. int max_len = 0;
  265. for (i = 0; i < display_info->regs_content_count; i++)
  266. {
  267. struct tui_data_element *data;
  268. struct tui_gen_win_info *data_item_win;
  269. char *p;
  270. int len;
  271. data_item_win = &display_info->regs_content[i]->which_element.data_window;
  272. data = &((struct tui_win_element *)
  273. data_item_win->content[0])->which_element.data;
  274. len = 0;
  275. p = data->content;
  276. if (p != 0)
  277. while (*p)
  278. {
  279. if (*p++ == '\t')
  280. len = 8 * ((len / 8) + 1);
  281. else
  282. len++;
  283. }
  284. if (len > max_len)
  285. max_len = len;
  286. }
  287. item_win_width = max_len + 1;
  288. i = start_element_no;
  289. display_info->regs_column_count =
  290. (TUI_DATA_WIN->generic.width - 2) / item_win_width;
  291. if (display_info->regs_column_count == 0)
  292. display_info->regs_column_count = 1;
  293. item_win_width =
  294. (TUI_DATA_WIN->generic.width - 2) / display_info->regs_column_count;
  295. /*
  296. ** Now create each data "sub" window, and write the display into it.
  297. */
  298. cur_y = 1;
  299. while (i < display_info->regs_content_count &&
  300. cur_y <= TUI_DATA_WIN->generic.viewport_height)
  301. {
  302. for (j = 0;
  303. (j < display_info->regs_column_count &&
  304. i < display_info->regs_content_count); j++)
  305. {
  306. struct tui_gen_win_info * data_item_win;
  307. struct tui_data_element * data_element_ptr;
  308. /* create the window if necessary */
  309. data_item_win = &display_info->regs_content[i]
  310. ->which_element.data_window;
  311. data_element_ptr = &((struct tui_win_element *)
  312. data_item_win->content[0])->which_element.data;
  313. if (data_item_win->handle != (WINDOW*) NULL
  314. && (data_item_win->height != 1
  315. || data_item_win->width != item_win_width
  316. || data_item_win->origin.x != (item_win_width * j) + 1
  317. || data_item_win->origin.y != cur_y))
  318. {
  319. tui_delete_win (data_item_win->handle);
  320. data_item_win->handle = 0;
  321. }
  322. if (data_item_win->handle == (WINDOW *) NULL)
  323. {
  324. data_item_win->height = 1;
  325. data_item_win->width = item_win_width;
  326. data_item_win->origin.x = (item_win_width * j) + 1;
  327. data_item_win->origin.y = cur_y;
  328. tui_make_window (data_item_win, DONT_BOX_WINDOW);
  329. scrollok (data_item_win->handle, FALSE);
  330. }
  331. touchwin (data_item_win->handle);
  332. /* Get the printable representation of the register
  333. and display it. */
  334. tui_display_register (data_element_ptr, data_item_win);
  335. i++; /* next register */
  336. }
  337. cur_y++; /* next row; */
  338. }
  339. }
  340. }
  341. /* Function to display the registers in the content from
  342. 'start_element_no' on 'start_line_no' until the end of the register
  343. content or the end of the display height. This function checks
  344. that we won't display off the end of the register display. */
  345. void
  346. tui_display_reg_element_at_line (int start_element_no, int start_line_no)
  347. {
  348. if (TUI_DATA_WIN->detail.data_display_info.regs_content != (tui_win_content) NULL &&
  349. TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
  350. {
  351. int element_no = start_element_no;
  352. if (start_element_no != 0 && start_line_no != 0)
  353. {
  354. int last_line_no, first_line_on_last_page;
  355. last_line_no = tui_last_regs_line_no ();
  356. first_line_on_last_page = last_line_no - (TUI_DATA_WIN->generic.height - 2);
  357. if (first_line_on_last_page < 0)
  358. first_line_on_last_page = 0;
  359. /*
  360. ** If there is no other data displayed except registers,
  361. ** and the element_no causes us to scroll past the end of the
  362. ** registers, adjust what element to really start the display at.
  363. */
  364. if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0 &&
  365. start_line_no > first_line_on_last_page)
  366. element_no = tui_first_reg_element_no_inline (first_line_on_last_page);
  367. }
  368. tui_display_registers_from (element_no);
  369. }
  370. }
  371. /* Function to display the registers starting at line line_no in the
  372. data window. Answers the line number that the display actually
  373. started from. If nothing is displayed (-1) is returned. */
  374. int
  375. tui_display_registers_from_line (int line_no, int force_display)
  376. {
  377. if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
  378. {
  379. int line, element_no;
  380. if (line_no < 0)
  381. line = 0;
  382. else if (force_display)
  383. { /*
  384. ** If we must display regs (force_display is true), then make
  385. ** sure that we don't display off the end of the registers.
  386. */
  387. if (line_no >= tui_last_regs_line_no ())
  388. {
  389. if ((line = tui_line_from_reg_element_no (
  390. TUI_DATA_WIN->detail.data_display_info.regs_content_count - 1)) < 0)
  391. line = 0;
  392. }
  393. else
  394. line = line_no;
  395. }
  396. else
  397. line = line_no;
  398. element_no = tui_first_reg_element_no_inline (line);
  399. if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
  400. tui_display_reg_element_at_line (element_no, line);
  401. else
  402. line = (-1);
  403. return line;
  404. }
  405. return (-1); /* nothing was displayed */
  406. }
  407. /* This function check all displayed registers for changes in values,
  408. given a particular frame. If the values have changed, they are
  409. updated with the new value and highlighted. */
  410. void
  411. tui_check_register_values (struct frame_info *frame)
  412. {
  413. if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->generic.is_visible)
  414. {
  415. struct tui_data_info *display_info
  416. = &TUI_DATA_WIN->detail.data_display_info;
  417. if (display_info->regs_content_count <= 0 && display_info->display_regs)
  418. tui_show_registers (display_info->current_group);
  419. else
  420. {
  421. int i, j;
  422. for (i = 0; (i < display_info->regs_content_count); i++)
  423. {
  424. struct tui_data_element *data;
  425. struct tui_gen_win_info *data_item_win_ptr;
  426. int was_hilighted;
  427. data_item_win_ptr = &display_info->regs_content[i]->
  428. which_element.data_window;
  429. data = &((struct tui_win_element *)
  430. data_item_win_ptr->content[0])->which_element.data;
  431. was_hilighted = data->highlight;
  432. tui_get_register (current_gdbarch, frame, data,
  433. data->item_no, &data->highlight);
  434. if (data->highlight || was_hilighted)
  435. {
  436. tui_display_register (data, data_item_win_ptr);
  437. }
  438. }
  439. }
  440. }
  441. }
  442. /* Display a register in a window. If hilite is TRUE,
  443. then the value will be displayed in reverse video */
  444. static void
  445. tui_display_register (struct tui_data_element *data,
  446. struct tui_gen_win_info *win_info)
  447. {
  448. if (win_info->handle != (WINDOW *) NULL)
  449. {
  450. int i;
  451. if (data->highlight)
  452. wstandout (win_info->handle);
  453. wmove (win_info->handle, 0, 0);
  454. for (i = 1; i < win_info->width; i++)
  455. waddch (win_info->handle, ' ');
  456. wmove (win_info->handle, 0, 0);
  457. if (data->content)
  458. waddstr (win_info->handle, data->content);
  459. if (data->highlight)
  460. wstandend (win_info->handle);
  461. tui_refresh_win (win_info);
  462. }
  463. }
  464. static void
  465. tui_reg_next_command (char *arg, int from_tty)
  466. {
  467. if (TUI_DATA_WIN != 0)
  468. {
  469. struct reggroup *group
  470. = TUI_DATA_WIN->detail.data_display_info.current_group;
  471. group = reggroup_next (current_gdbarch, group);
  472. if (group == 0)
  473. group = reggroup_next (current_gdbarch, 0);
  474. if (group)
  475. tui_show_registers (group);
  476. }
  477. }
  478. static void
  479. tui_reg_float_command (char *arg, int from_tty)
  480. {
  481. tui_show_registers (float_reggroup);
  482. }
  483. static void
  484. tui_reg_general_command (char *arg, int from_tty)
  485. {
  486. tui_show_registers (general_reggroup);
  487. }
  488. static void
  489. tui_reg_system_command (char *arg, int from_tty)
  490. {
  491. tui_show_registers (system_reggroup);
  492. }
  493. static struct cmd_list_element *tuireglist;
  494. static void
  495. tui_reg_command (char *args, int from_tty)
  496. {
  497. printf_unfiltered ("\"tui reg\" must be followed by the name of a "
  498. "tui reg command.\n");
  499. help_list (tuireglist, "tui reg ", -1, gdb_stdout);
  500. }
  501. void
  502. _initialize_tui_regs (void)
  503. {
  504. struct cmd_list_element **tuicmd;
  505. tuicmd = tui_get_cmd_list ();
  506. add_prefix_cmd ("reg", class_tui, tui_reg_command,
  507. "TUI commands to control the register window.",
  508. &tuireglist, "tui reg ", 0,
  509. tuicmd);
  510. add_cmd ("float", class_tui, tui_reg_float_command,
  511. "Display only floating point registers\n",
  512. &tuireglist);
  513. add_cmd ("general", class_tui, tui_reg_general_command,
  514. "Display only general registers\n",
  515. &tuireglist);
  516. add_cmd ("system", class_tui, tui_reg_system_command,
  517. "Display only system registers\n",
  518. &tuireglist);
  519. add_cmd ("next", class_tui, tui_reg_next_command,
  520. "Display next register group\n",
  521. &tuireglist);
  522. if (xdb_commands)
  523. {
  524. add_com ("fr", class_tui, tui_reg_float_command,
  525. "Display only floating point registers\n");
  526. add_com ("gr", class_tui, tui_reg_general_command,
  527. "Display only general registers\n");
  528. add_com ("sr", class_tui, tui_reg_system_command,
  529. "Display only special registers\n");
  530. add_com ("+r", class_tui, tui_scroll_regs_forward_command,
  531. "Scroll the registers window forward\n");
  532. add_com ("-r", class_tui, tui_scroll_regs_backward_command,
  533. "Scroll the register window backward\n");
  534. }
  535. }
  536. /*****************************************
  537. ** STATIC LOCAL FUNCTIONS **
  538. ******************************************/
  539. extern int pagination_enabled;
  540. static void
  541. tui_restore_gdbout (void *ui)
  542. {
  543. ui_file_delete (gdb_stdout);
  544. gdb_stdout = (struct ui_file*) ui;
  545. pagination_enabled = 1;
  546. }
  547. /* Get the register from the frame and make a printable representation
  548. of it in the data element. */
  549. static void
  550. tui_register_format (struct gdbarch *gdbarch, struct frame_info *frame,
  551. struct tui_data_element *data_element, int regnum)
  552. {
  553. struct ui_file *stream;
  554. struct ui_file *old_stdout;
  555. const char *name;
  556. struct cleanup *cleanups;
  557. char *p, *s;
  558. int pos;
  559. struct type *type = gdbarch_register_type (gdbarch, regnum);
  560. name = gdbarch_register_name (gdbarch, regnum);
  561. if (name == 0)
  562. {
  563. return;
  564. }
  565. pagination_enabled = 0;
  566. old_stdout = gdb_stdout;
  567. stream = tui_sfileopen (256);
  568. gdb_stdout = stream;
  569. cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout);
  570. if (TYPE_VECTOR (type) != 0 && 0)
  571. {
  572. char buf[MAX_REGISTER_SIZE];
  573. int len;
  574. len = register_size (current_gdbarch, regnum);
  575. fprintf_filtered (stream, "%-14s ", name);
  576. get_frame_register (frame, regnum, buf);
  577. print_scalar_formatted (buf, type, 'f', len, stream);
  578. }
  579. else
  580. {
  581. gdbarch_print_registers_info (current_gdbarch, stream,
  582. frame, regnum, 1);
  583. }
  584. /* Save formatted output in the buffer. */
  585. p = tui_file_get_strbuf (stream);
  586. /* Remove the possible \n. */
  587. s = strrchr (p, '\n');
  588. if (s && s[1] == 0)
  589. *s = 0;
  590. xfree (data_element->content);
  591. data_element->content = xstrdup (p);
  592. do_cleanups (cleanups);
  593. }
  594. /* Get the register value from the given frame and format it for
  595. the display. When changep is set, check if the new register value
  596. has changed with respect to the previous call. */
  597. static enum tui_status
  598. tui_get_register (struct gdbarch *gdbarch, struct frame_info *frame,
  599. struct tui_data_element *data, int regnum, int *changedp)
  600. {
  601. enum tui_status ret = TUI_FAILURE;
  602. if (changedp)
  603. *changedp = FALSE;
  604. if (target_has_registers)
  605. {
  606. char buf[MAX_REGISTER_SIZE];
  607. get_frame_register (frame, regnum, buf);
  608. /* NOTE: cagney/2003-03-13: This is bogus. It is refering to
  609. the register cache and not the frame which could have pulled
  610. the register value off the stack. */
  611. if (register_cached (regnum) >= 0)
  612. {
  613. if (changedp)
  614. {
  615. int size = register_size (gdbarch, regnum);
  616. char *old = (char*) data->value;
  617. int i;
  618. for (i = 0; i < size; i++)
  619. if (buf[i] != old[i])
  620. {
  621. *changedp = TRUE;
  622. old[i] = buf[i];
  623. }
  624. }
  625. /* Reformat the data content if the value changed. */
  626. if (changedp == 0 || *changedp == TRUE)
  627. tui_register_format (gdbarch, frame, data, regnum);
  628. ret = TUI_SUCCESS;
  629. }
  630. }
  631. return ret;
  632. }
  633. static void
  634. tui_scroll_regs_forward_command (char *arg, int from_tty)
  635. {
  636. tui_scroll (FORWARD_SCROLL, TUI_DATA_WIN, 1);
  637. }
  638. static void
  639. tui_scroll_regs_backward_command (char *arg, int from_tty)
  640. {
  641. tui_scroll (BACKWARD_SCROLL, TUI_DATA_WIN, 1);
  642. }