OLD | NEW |
1 /* TUI display registers in window. | 1 /* TUI display registers in window. |
2 | 2 |
3 Copyright (C) 1998-2004, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1998-2013 Free Software Foundation, Inc. |
4 | 4 |
5 Contributed by Hewlett-Packard Company. | 5 Contributed by Hewlett-Packard Company. |
6 | 6 |
7 This file is part of GDB. | 7 This file is part of GDB. |
8 | 8 |
9 This program is free software; you can redistribute it and/or modify | 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 | 10 it under the terms of the GNU General Public License as published by |
11 the Free Software Foundation; either version 3 of the License, or | 11 the Free Software Foundation; either version 3 of the License, or |
12 (at your option) any later version. | 12 (at your option) any later version. |
13 | 13 |
14 This program is distributed in the hope that it will be useful, | 14 This program is distributed in the hope that it will be useful, |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 GNU General Public License for more details. | 17 GNU General Public License for more details. |
18 | 18 |
19 You should have received a copy of the GNU General Public License | 19 You should have received a copy of the GNU General Public License |
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
21 | 21 |
22 #include "defs.h" | 22 #include "defs.h" |
23 #include "arch-utils.h" | 23 #include "arch-utils.h" |
24 #include "tui/tui.h" | 24 #include "tui/tui.h" |
25 #include "tui/tui-data.h" | 25 #include "tui/tui-data.h" |
26 #include "symtab.h" | 26 #include "symtab.h" |
27 #include "gdbtypes.h" | 27 #include "gdbtypes.h" |
28 #include "gdbcmd.h" | 28 #include "gdbcmd.h" |
29 #include "frame.h" | 29 #include "frame.h" |
30 #include "regcache.h" | 30 #include "regcache.h" |
31 #include "inferior.h" | 31 #include "inferior.h" |
32 #include "target.h" | 32 #include "target.h" |
33 #include "gdb_string.h" | 33 #include <string.h> |
34 #include "tui/tui-layout.h" | 34 #include "tui/tui-layout.h" |
35 #include "tui/tui-win.h" | 35 #include "tui/tui-win.h" |
36 #include "tui/tui-windata.h" | 36 #include "tui/tui-windata.h" |
37 #include "tui/tui-wingeneral.h" | 37 #include "tui/tui-wingeneral.h" |
38 #include "tui/tui-file.h" | 38 #include "tui/tui-file.h" |
39 #include "tui/tui-regs.h" | 39 #include "tui/tui-regs.h" |
40 #include "reggroups.h" | 40 #include "reggroups.h" |
41 #include "valprint.h" | 41 #include "valprint.h" |
42 | 42 |
43 #include "gdb_curses.h" | 43 #include "gdb_curses.h" |
44 | 44 |
45 | 45 |
46 /***************************************** | 46 /***************************************** |
47 ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** | 47 ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** |
48 ******************************************/ | 48 ******************************************/ |
49 static void | 49 static void |
50 tui_display_register (struct tui_data_element *data, | 50 tui_display_register (struct tui_data_element *data, |
51 struct tui_gen_win_info *win_info); | 51 struct tui_gen_win_info *win_info); |
52 | 52 |
53 static enum tui_status tui_show_register_group (struct reggroup *group, | 53 static enum tui_status tui_show_register_group (struct reggroup *group, |
54 struct frame_info *frame, | 54 struct frame_info *frame, |
55 int refresh_values_only); | 55 int refresh_values_only); |
56 | 56 |
57 static enum tui_status tui_get_register (struct frame_info *frame, | 57 static enum tui_status tui_get_register (struct frame_info *frame, |
58 struct tui_data_element *data, | 58 struct tui_data_element *data, |
59 int regnum, int *changedp); | 59 int regnum, int *changedp); |
60 | 60 |
61 static void tui_register_format (struct frame_info *, | |
62 struct tui_data_element*, int); | |
63 | |
64 static void tui_scroll_regs_forward_command (char *, int); | 61 static void tui_scroll_regs_forward_command (char *, int); |
65 static void tui_scroll_regs_backward_command (char *, int); | 62 static void tui_scroll_regs_backward_command (char *, int); |
66 | 63 |
67 | 64 |
68 | 65 |
69 /***************************************** | 66 /***************************************** |
70 ** PUBLIC FUNCTIONS ** | 67 ** PUBLIC FUNCTIONS ** |
71 ******************************************/ | 68 ******************************************/ |
72 | 69 |
73 /* Answer the number of the last line in the regs display. If there | 70 /* Answer the number of the last line in the regs display. If there |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 display_info = &TUI_DATA_WIN->detail.data_display_info; | 147 display_info = &TUI_DATA_WIN->detail.data_display_info; |
151 if (group == 0) | 148 if (group == 0) |
152 group = general_reggroup; | 149 group = general_reggroup; |
153 | 150 |
154 /* Say that registers should be displayed, even if there is a | 151 /* Say that registers should be displayed, even if there is a |
155 problem. */ | 152 problem. */ |
156 display_info->display_regs = TRUE; | 153 display_info->display_regs = TRUE; |
157 | 154 |
158 if (target_has_registers && target_has_stack && target_has_memory) | 155 if (target_has_registers && target_has_stack && target_has_memory) |
159 { | 156 { |
160 ret = tui_show_register_group (group, get_current_frame (), | 157 ret = tui_show_register_group (group, get_selected_frame (NULL), |
161 group == display_info->current_group); | 158 group == display_info->current_group); |
162 } | 159 } |
163 if (ret == TUI_FAILURE) | 160 if (ret == TUI_FAILURE) |
164 { | 161 { |
165 display_info->current_group = 0; | 162 display_info->current_group = 0; |
166 tui_erase_data_content (NO_REGS_STRING); | 163 tui_erase_data_content (NO_REGS_STRING); |
167 } | 164 } |
168 else | 165 else |
169 { | 166 { |
170 int i; | 167 int i; |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 add_com ("-r", class_tui, tui_scroll_regs_backward_command, | 651 add_com ("-r", class_tui, tui_scroll_regs_backward_command, |
655 _("Scroll the register window backward\n")); | 652 _("Scroll the register window backward\n")); |
656 } | 653 } |
657 } | 654 } |
658 | 655 |
659 | 656 |
660 /***************************************** | 657 /***************************************** |
661 ** STATIC LOCAL FUNCTIONS ** | 658 ** STATIC LOCAL FUNCTIONS ** |
662 ******************************************/ | 659 ******************************************/ |
663 | 660 |
664 extern int pagination_enabled; | |
665 | |
666 static void | 661 static void |
667 tui_restore_gdbout (void *ui) | 662 tui_restore_gdbout (void *ui) |
668 { | 663 { |
669 ui_file_delete (gdb_stdout); | 664 ui_file_delete (gdb_stdout); |
670 gdb_stdout = (struct ui_file*) ui; | 665 gdb_stdout = (struct ui_file*) ui; |
671 pagination_enabled = 1; | 666 pagination_enabled = 1; |
672 } | 667 } |
673 | 668 |
674 /* Get the register from the frame and make a printable representation | 669 /* Get the register from the frame and return a printable |
675 of it in the data element. */ | 670 representation of it. */ |
676 static void | 671 |
677 tui_register_format (struct frame_info *frame, | 672 static char * |
678 struct tui_data_element *data_element, | 673 tui_register_format (struct frame_info *frame, int regnum) |
679 » » int regnum) | |
680 { | 674 { |
681 struct gdbarch *gdbarch = get_frame_arch (frame); | 675 struct gdbarch *gdbarch = get_frame_arch (frame); |
682 struct ui_file *stream; | 676 struct ui_file *stream; |
683 struct ui_file *old_stdout; | 677 struct ui_file *old_stdout; |
684 const char *name; | |
685 struct cleanup *cleanups; | 678 struct cleanup *cleanups; |
686 char *p, *s; | 679 char *p, *s; |
687 | 680 char *ret; |
688 name = gdbarch_register_name (gdbarch, regnum); | |
689 if (name == 0 || *name == '\0') | |
690 return; | |
691 | 681 |
692 pagination_enabled = 0; | 682 pagination_enabled = 0; |
693 old_stdout = gdb_stdout; | 683 old_stdout = gdb_stdout; |
694 stream = tui_sfileopen (256); | 684 stream = tui_sfileopen (256); |
695 gdb_stdout = stream; | 685 gdb_stdout = stream; |
696 cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout); | 686 cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout); |
697 gdbarch_print_registers_info (gdbarch, stream, frame, regnum, 1); | 687 gdbarch_print_registers_info (gdbarch, stream, frame, regnum, 1); |
698 | 688 |
699 /* Save formatted output in the buffer. */ | 689 /* Save formatted output in the buffer. */ |
700 p = tui_file_get_strbuf (stream); | 690 p = tui_file_get_strbuf (stream); |
701 | 691 |
702 /* Remove the possible \n. */ | 692 /* Remove the possible \n. */ |
703 s = strrchr (p, '\n'); | 693 s = strrchr (p, '\n'); |
704 if (s && s[1] == 0) | 694 if (s && s[1] == 0) |
705 *s = 0; | 695 *s = 0; |
706 | 696 |
707 xfree (data_element->content); | 697 ret = xstrdup (p); |
708 data_element->content = xstrdup (p); | |
709 do_cleanups (cleanups); | 698 do_cleanups (cleanups); |
| 699 |
| 700 return ret; |
710 } | 701 } |
711 | 702 |
712 /* Get the register value from the given frame and format it for the | 703 /* Get the register value from the given frame and format it for the |
713 display. When changep is set, check if the new register value has | 704 display. When changep is set, check if the new register value has |
714 changed with respect to the previous call. */ | 705 changed with respect to the previous call. */ |
715 static enum tui_status | 706 static enum tui_status |
716 tui_get_register (struct frame_info *frame, | 707 tui_get_register (struct frame_info *frame, |
717 struct tui_data_element *data, | 708 struct tui_data_element *data, |
718 int regnum, int *changedp) | 709 int regnum, int *changedp) |
719 { | 710 { |
720 enum tui_status ret = TUI_FAILURE; | 711 enum tui_status ret = TUI_FAILURE; |
721 | 712 |
722 if (changedp) | 713 if (changedp) |
723 *changedp = FALSE; | 714 *changedp = FALSE; |
724 if (target_has_registers) | 715 if (target_has_registers) |
725 { | 716 { |
726 struct value *old_val = data->value; | 717 char *prev_content = data->content; |
727 | 718 |
728 data->value = get_frame_register_value (frame, regnum); | 719 data->content = tui_register_format (frame, regnum); |
729 release_value (data->value); | |
730 if (changedp) | |
731 » { | |
732 » struct gdbarch *gdbarch = get_frame_arch (frame); | |
733 » int size = register_size (gdbarch, regnum); | |
734 | 720 |
735 » if (value_optimized_out (data->value) != value_optimized_out (old_val) | 721 if (changedp != NULL |
736 » || !value_available_contents_eq (data->value, 0, | 722 » && strcmp (prev_content, data->content) != 0) |
737 » » » » » old_val, 0, size)) | 723 » *changedp = 1; |
738 » *changedp = TRUE; | |
739 » } | |
740 | 724 |
741 value_free (old_val); | 725 xfree (prev_content); |
742 | |
743 /* Reformat the data content if the value changed. */ | |
744 if (changedp == 0 || *changedp == TRUE) | |
745 » tui_register_format (frame, data, regnum); | |
746 | 726 |
747 ret = TUI_SUCCESS; | 727 ret = TUI_SUCCESS; |
748 } | 728 } |
749 return ret; | 729 return ret; |
750 } | 730 } |
751 | 731 |
752 static void | 732 static void |
753 tui_scroll_regs_forward_command (char *arg, int from_tty) | 733 tui_scroll_regs_forward_command (char *arg, int from_tty) |
754 { | 734 { |
755 tui_scroll (FORWARD_SCROLL, TUI_DATA_WIN, 1); | 735 tui_scroll (FORWARD_SCROLL, TUI_DATA_WIN, 1); |
756 } | 736 } |
757 | 737 |
758 | 738 |
759 static void | 739 static void |
760 tui_scroll_regs_backward_command (char *arg, int from_tty) | 740 tui_scroll_regs_backward_command (char *arg, int from_tty) |
761 { | 741 { |
762 tui_scroll (BACKWARD_SCROLL, TUI_DATA_WIN, 1); | 742 tui_scroll (BACKWARD_SCROLL, TUI_DATA_WIN, 1); |
763 } | 743 } |
OLD | NEW |