Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: gdb/mi/mi-main.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/mi/mi-interp.c ('k') | gdb/mi/mi-out.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* MI Command Set. 1 /* MI Command Set.
2 2
3 Copyright (C) 2000-2005, 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 2000-2005, 2007-2012 Free Software Foundation, Inc.
4 4
5 Contributed by Cygnus Solutions (a Red Hat company). 5 Contributed by Cygnus Solutions (a Red Hat 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 /* Work in progress. */
23
24 #include "defs.h" 22 #include "defs.h"
25 #include "arch-utils.h" 23 #include "arch-utils.h"
26 #include "target.h" 24 #include "target.h"
27 #include "inferior.h" 25 #include "inferior.h"
28 #include "gdb_string.h" 26 #include "gdb_string.h"
29 #include "exceptions.h" 27 #include "exceptions.h"
30 #include "top.h" 28 #include "top.h"
31 #include "gdbthread.h" 29 #include "gdbthread.h"
32 #include "mi-cmds.h" 30 #include "mi-cmds.h"
33 #include "mi-parse.h" 31 #include "mi-parse.h"
(...skipping 30 matching lines...) Expand all
64 #ifdef HAVE_GETRUSAGE 62 #ifdef HAVE_GETRUSAGE
65 struct rusage rusage; 63 struct rusage rusage;
66 #endif 64 #endif
67 65
68 enum 66 enum
69 { 67 {
70 FROM_TTY = 0 68 FROM_TTY = 0
71 }; 69 };
72 70
73 int mi_debug_p; 71 int mi_debug_p;
72
74 struct ui_file *raw_stdout; 73 struct ui_file *raw_stdout;
75 74
76 /* This is used to pass the current command timestamp 75 /* This is used to pass the current command timestamp down to
77 down to continuation routines. */ 76 continuation routines. */
78 static struct mi_timestamp *current_command_ts; 77 static struct mi_timestamp *current_command_ts;
79 78
80 static int do_timings = 0; 79 static int do_timings = 0;
81 80
82 char *current_token; 81 char *current_token;
83 /* Few commands would like to know if options like --thread-group 82 /* Few commands would like to know if options like --thread-group were
84 were explicitly specified. This variable keeps the current 83 explicitly specified. This variable keeps the current parsed
85 parsed command including all option, and make it possible. */ 84 command including all option, and make it possible. */
86 static struct mi_parse *current_context; 85 static struct mi_parse *current_context;
87 86
88 int running_result_record_printed = 1; 87 int running_result_record_printed = 1;
89 88
90 /* Flag indicating that the target has proceeded since the last 89 /* Flag indicating that the target has proceeded since the last
91 command was issued. */ 90 command was issued. */
92 int mi_proceeded; 91 int mi_proceeded;
93 92
94 extern void _initialize_mi_main (void); 93 extern void _initialize_mi_main (void);
95 static void mi_cmd_execute (struct mi_parse *parse); 94 static void mi_cmd_execute (struct mi_parse *parse);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (argc > 0 && strcmp(argv[0], "--reverse") == 0) 170 if (argc > 0 && strcmp(argv[0], "--reverse") == 0)
172 mi_execute_async_cli_command ("reverse-finish", argv + 1, argc - 1); 171 mi_execute_async_cli_command ("reverse-finish", argv + 1, argc - 1);
173 else 172 else
174 mi_execute_async_cli_command ("finish", argv, argc); 173 mi_execute_async_cli_command ("finish", argv, argc);
175 } 174 }
176 175
177 void 176 void
178 mi_cmd_exec_return (char *command, char **argv, int argc) 177 mi_cmd_exec_return (char *command, char **argv, int argc)
179 { 178 {
180 /* This command doesn't really execute the target, it just pops the 179 /* This command doesn't really execute the target, it just pops the
181 specified number of frames. */ 180 specified number of frames. */
182 if (argc) 181 if (argc)
183 /* Call return_command with from_tty argument equal to 0 so as to 182 /* Call return_command with from_tty argument equal to 0 so as to
184 avoid being queried. */ 183 avoid being queried. */
185 return_command (*argv, 0); 184 return_command (*argv, 0);
186 else 185 else
187 /* Call return_command with from_tty argument equal to 0 so as to 186 /* Call return_command with from_tty argument equal to 0 so as to
188 avoid being queried. */ 187 avoid being queried. */
189 return_command (NULL, 0); 188 return_command (NULL, 0);
190 189
191 /* Because we have called return_command with from_tty = 0, we need 190 /* Because we have called return_command with from_tty = 0, we need
(...skipping 12 matching lines...) Expand all
204 proceed_thread (struct thread_info *thread, int pid) 203 proceed_thread (struct thread_info *thread, int pid)
205 { 204 {
206 if (!is_stopped (thread->ptid)) 205 if (!is_stopped (thread->ptid))
207 return; 206 return;
208 207
209 if (pid != 0 && PIDGET (thread->ptid) != pid) 208 if (pid != 0 && PIDGET (thread->ptid) != pid)
210 return; 209 return;
211 210
212 switch_to_thread (thread->ptid); 211 switch_to_thread (thread->ptid);
213 clear_proceed_status (); 212 clear_proceed_status ();
214 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); 213 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT, 0);
215 } 214 }
216 215
217
218 static int 216 static int
219 proceed_thread_callback (struct thread_info *thread, void *arg) 217 proceed_thread_callback (struct thread_info *thread, void *arg)
220 { 218 {
221 int pid = *(int *)arg; 219 int pid = *(int *)arg;
222 220
223 proceed_thread (thread, pid); 221 proceed_thread (thread, pid);
224 return 0; 222 return 0;
225 } 223 }
226 224
227 static void 225 static void
228 exec_continue (char **argv, int argc) 226 exec_continue (char **argv, int argc)
229 { 227 {
230 if (non_stop) 228 if (non_stop)
231 { 229 {
232 /* In non-stop mode, 'resume' always resumes a single thread. Therefore, 230 /* In non-stop mode, 'resume' always resumes a single thread.
233 » to resume all threads of the current inferior, or all threads in all 231 » Therefore, to resume all threads of the current inferior, or
234 » inferiors, we need to iterate over threads. 232 » all threads in all inferiors, we need to iterate over
233 » threads.
235 234
236 See comment on infcmd.c:proceed_thread_callback for rationale. */ 235 See comment on infcmd.c:proceed_thread_callback for rationale. */
237 if (current_context->all || current_context->thread_group != -1) 236 if (current_context->all || current_context->thread_group != -1)
238 { 237 {
239 int pid = 0; 238 int pid = 0;
240 struct cleanup *back_to = make_cleanup_restore_current_thread (); 239 struct cleanup *back_to = make_cleanup_restore_current_thread ();
241 240
242 if (!current_context->all) 241 if (!current_context->all)
243 { 242 {
244 struct inferior *inf 243 struct inferior *inf
(...skipping 13 matching lines...) Expand all
258 { 257 {
259 struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi); 258 struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi);
260 259
261 if (current_context->all) 260 if (current_context->all)
262 { 261 {
263 sched_multi = 1; 262 sched_multi = 1;
264 continue_1 (0); 263 continue_1 (0);
265 } 264 }
266 else 265 else
267 { 266 {
268 » /* In all-stop mode, -exec-continue traditionally resumed either 267 » /* In all-stop mode, -exec-continue traditionally resumed
269 » all threads, or one thread, depending on the 'scheduler-locking' 268 » either all threads, or one thread, depending on the
270 » variable. Let's continue to do the same. */ 269 » 'scheduler-locking' variable. Let's continue to do the
270 » same. */
271 continue_1 (1); 271 continue_1 (1);
272 } 272 }
273 do_cleanups (back_to); 273 do_cleanups (back_to);
274 } 274 }
275 } 275 }
276 276
277 static void 277 static void
278 exec_direction_forward (void *notused) 278 exec_direction_forward (void *notused)
279 { 279 {
280 execution_direction = EXEC_FORWARD; 280 execution_direction = EXEC_FORWARD;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (!is_running (thread->ptid)) 315 if (!is_running (thread->ptid))
316 return 0; 316 return 0;
317 317
318 if (PIDGET (thread->ptid) != pid) 318 if (PIDGET (thread->ptid) != pid)
319 return 0; 319 return 0;
320 320
321 target_stop (thread->ptid); 321 target_stop (thread->ptid);
322 return 0; 322 return 0;
323 } 323 }
324 324
325 /* Interrupt the execution of the target. Note how we must play around 325 /* Interrupt the execution of the target. Note how we must play
326 with the token variables, in order to display the current token in 326 around with the token variables, in order to display the current
327 the result of the interrupt command, and the previous execution 327 token in the result of the interrupt command, and the previous
328 token when the target finally stops. See comments in 328 execution token when the target finally stops. See comments in
329 mi_cmd_execute. */ 329 mi_cmd_execute. */
330
330 void 331 void
331 mi_cmd_exec_interrupt (char *command, char **argv, int argc) 332 mi_cmd_exec_interrupt (char *command, char **argv, int argc)
332 { 333 {
333 /* In all-stop mode, everything stops, so we don't need to try 334 /* In all-stop mode, everything stops, so we don't need to try
334 anything specific. */ 335 anything specific. */
335 if (!non_stop) 336 if (!non_stop)
336 { 337 {
337 interrupt_target_1 (0); 338 interrupt_target_1 (0);
338 return; 339 return;
339 } 340 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 501
501 void 502 void
502 mi_cmd_thread_info (char *command, char **argv, int argc) 503 mi_cmd_thread_info (char *command, char **argv, int argc)
503 { 504 {
504 if (argc != 0 && argc != 1) 505 if (argc != 0 && argc != 1)
505 error (_("Invalid MI command")); 506 error (_("Invalid MI command"));
506 507
507 print_thread_info (current_uiout, argv[0], -1); 508 print_thread_info (current_uiout, argv[0], -1);
508 } 509 }
509 510
511 DEF_VEC_I(int);
512
510 struct collect_cores_data 513 struct collect_cores_data
511 { 514 {
512 int pid; 515 int pid;
513 516
514 VEC (int) *cores; 517 VEC (int) *cores;
515 }; 518 };
516 519
517 static int 520 static int
518 collect_cores (struct thread_info *ti, void *xdata) 521 collect_cores (struct thread_info *ti, void *xdata)
519 { 522 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 605
603 if (top_data->recurse) 606 if (top_data->recurse)
604 print_thread_info (uiout, NULL, inferior->pid); 607 print_thread_info (uiout, NULL, inferior->pid);
605 608
606 do_cleanups (back_to); 609 do_cleanups (back_to);
607 } 610 }
608 611
609 return 0; 612 return 0;
610 } 613 }
611 614
612 /* Output a field named 'cores' with a list as the value. The elements of 615 /* Output a field named 'cores' with a list as the value. The
613 the list are obtained by splitting 'cores' on comma. */ 616 elements of the list are obtained by splitting 'cores' on
617 comma. */
614 618
615 static void 619 static void
616 output_cores (struct ui_out *uiout, const char *field_name, const char *xcores) 620 output_cores (struct ui_out *uiout, const char *field_name, const char *xcores)
617 { 621 {
618 struct cleanup *back_to = make_cleanup_ui_out_list_begin_end (uiout, 622 struct cleanup *back_to = make_cleanup_ui_out_list_begin_end (uiout,
619 field_name); 623 field_name);
620 char *cores = xstrdup (xcores); 624 char *cores = xstrdup (xcores);
621 char *p = cores; 625 char *p = cores;
622 626
623 make_cleanup (xfree, cores); 627 make_cleanup (xfree, cores);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 void 794 void
791 mi_cmd_list_thread_groups (char *command, char **argv, int argc) 795 mi_cmd_list_thread_groups (char *command, char **argv, int argc)
792 { 796 {
793 struct ui_out *uiout = current_uiout; 797 struct ui_out *uiout = current_uiout;
794 struct cleanup *back_to; 798 struct cleanup *back_to;
795 int available = 0; 799 int available = 0;
796 int recurse = 0; 800 int recurse = 0;
797 VEC (int) *ids = 0; 801 VEC (int) *ids = 0;
798 802
799 enum opt 803 enum opt
804 {
805 AVAILABLE_OPT, RECURSE_OPT
806 };
807 static const struct mi_opt opts[] =
800 { 808 {
801 AVAILABLE_OPT, RECURSE_OPT 809 {"-available", AVAILABLE_OPT, 0},
810 {"-recurse", RECURSE_OPT, 1},
811 { 0, 0, 0 }
802 }; 812 };
803 static const struct mi_opt opts[] =
804 {
805 {"-available", AVAILABLE_OPT, 0},
806 {"-recurse", RECURSE_OPT, 1},
807 { 0, 0, 0 }
808 };
809 813
810 int optind = 0; 814 int oind = 0;
811 char *optarg; 815 char *oarg;
812 816
813 while (1) 817 while (1)
814 { 818 {
815 int opt = mi_getopt ("-list-thread-groups", argc, argv, opts, 819 int opt = mi_getopt ("-list-thread-groups", argc, argv, opts,
816 » » » &optind, &optarg); 820 » » » &oind, &oarg);
817 821
818 if (opt < 0) 822 if (opt < 0)
819 break; 823 break;
820 switch ((enum opt) opt) 824 switch ((enum opt) opt)
821 { 825 {
822 case AVAILABLE_OPT: 826 case AVAILABLE_OPT:
823 available = 1; 827 available = 1;
824 break; 828 break;
825 case RECURSE_OPT: 829 case RECURSE_OPT:
826 » if (strcmp (optarg, "0") == 0) 830 » if (strcmp (oarg, "0") == 0)
827 ; 831 ;
828 » else if (strcmp (optarg, "1") == 0) 832 » else if (strcmp (oarg, "1") == 0)
829 recurse = 1; 833 recurse = 1;
830 else 834 else
831 error (_("only '0' and '1' are valid values " 835 error (_("only '0' and '1' are valid values "
832 "for the '--recurse' option")); 836 "for the '--recurse' option"));
833 break; 837 break;
834 } 838 }
835 } 839 }
836 840
837 for (; optind < argc; ++optind) 841 for (; oind < argc; ++oind)
838 { 842 {
839 char *end; 843 char *end;
840 int inf; 844 int inf;
841 845
842 if (*(argv[optind]) != 'i') 846 if (*(argv[oind]) != 'i')
843 » error (_("invalid syntax of group id '%s'"), argv[optind]); 847 » error (_("invalid syntax of group id '%s'"), argv[oind]);
844 848
845 inf = strtoul (argv[optind] + 1, &end, 0); 849 inf = strtoul (argv[oind] + 1, &end, 0);
846 850
847 if (*end != '\0') 851 if (*end != '\0')
848 » error (_("invalid syntax of group id '%s'"), argv[optind]); 852 » error (_("invalid syntax of group id '%s'"), argv[oind]);
849 VEC_safe_push (int, ids, inf); 853 VEC_safe_push (int, ids, inf);
850 } 854 }
851 if (VEC_length (int, ids) > 1) 855 if (VEC_length (int, ids) > 1)
852 qsort (VEC_address (int, ids), 856 qsort (VEC_address (int, ids),
853 VEC_length (int, ids), 857 VEC_length (int, ids),
854 sizeof (int), compare_positive_ints); 858 sizeof (int), compare_positive_ints);
855 859
856 back_to = make_cleanup (free_vector_of_ints, &ids); 860 back_to = make_cleanup (free_vector_of_ints, &ids);
857 861
858 if (available) 862 if (available)
859 { 863 {
860 list_available_thread_groups (ids, recurse); 864 list_available_thread_groups (ids, recurse);
861 } 865 }
862 else if (VEC_length (int, ids) == 1) 866 else if (VEC_length (int, ids) == 1)
863 { 867 {
864 /* Local thread groups, single id. */ 868 /* Local thread groups, single id. */
865 int id = *VEC_address (int, ids); 869 int id = *VEC_address (int, ids);
866 struct inferior *inf = find_inferior_id (id); 870 struct inferior *inf = find_inferior_id (id);
867 871
868 if (!inf) 872 if (!inf)
869 error (_("Non-existent thread group id '%d'"), id); 873 error (_("Non-existent thread group id '%d'"), id);
870 874
871 print_thread_info (uiout, NULL, inf->pid); 875 print_thread_info (uiout, NULL, inf->pid);
872 } 876 }
873 else 877 else
874 { 878 {
(...skipping 17 matching lines...) Expand all
892 void 896 void
893 mi_cmd_data_list_register_names (char *command, char **argv, int argc) 897 mi_cmd_data_list_register_names (char *command, char **argv, int argc)
894 { 898 {
895 struct gdbarch *gdbarch; 899 struct gdbarch *gdbarch;
896 struct ui_out *uiout = current_uiout; 900 struct ui_out *uiout = current_uiout;
897 int regnum, numregs; 901 int regnum, numregs;
898 int i; 902 int i;
899 struct cleanup *cleanup; 903 struct cleanup *cleanup;
900 904
901 /* Note that the test for a valid register must include checking the 905 /* Note that the test for a valid register must include checking the
902 gdbarch_register_name because gdbarch_num_regs may be allocated for 906 gdbarch_register_name because gdbarch_num_regs may be allocated
903 the union of the register sets within a family of related processors. 907 for the union of the register sets within a family of related
904 In this case, some entries of gdbarch_register_name will change depending 908 processors. In this case, some entries of gdbarch_register_name
905 upon the particular processor being debugged. */ 909 will change depending upon the particular processor being
910 debugged. */
906 911
907 gdbarch = get_current_arch (); 912 gdbarch = get_current_arch ();
908 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); 913 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
909 914
910 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names"); 915 cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names");
911 916
912 if (argc == 0) /* No args, just do all the regs. */ 917 if (argc == 0) /* No args, just do all the regs. */
913 { 918 {
914 for (regnum = 0; 919 for (regnum = 0;
915 regnum < numregs; 920 regnum < numregs;
(...skipping 29 matching lines...) Expand all
945 mi_cmd_data_list_changed_registers (char *command, char **argv, int argc) 950 mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
946 { 951 {
947 static struct regcache *this_regs = NULL; 952 static struct regcache *this_regs = NULL;
948 struct ui_out *uiout = current_uiout; 953 struct ui_out *uiout = current_uiout;
949 struct regcache *prev_regs; 954 struct regcache *prev_regs;
950 struct gdbarch *gdbarch; 955 struct gdbarch *gdbarch;
951 int regnum, numregs, changed; 956 int regnum, numregs, changed;
952 int i; 957 int i;
953 struct cleanup *cleanup; 958 struct cleanup *cleanup;
954 959
955 /* The last time we visited this function, the current frame's register 960 /* The last time we visited this function, the current frame's
956 contents were saved in THIS_REGS. Move THIS_REGS over to PREV_REGS, 961 register contents were saved in THIS_REGS. Move THIS_REGS over
957 and refresh THIS_REGS with the now-current register contents. */ 962 to PREV_REGS, and refresh THIS_REGS with the now-current register
963 contents. */
958 964
959 prev_regs = this_regs; 965 prev_regs = this_regs;
960 this_regs = frame_save_as_regcache (get_selected_frame (NULL)); 966 this_regs = frame_save_as_regcache (get_selected_frame (NULL));
961 cleanup = make_cleanup_regcache_xfree (prev_regs); 967 cleanup = make_cleanup_regcache_xfree (prev_regs);
962 968
963 /* Note that the test for a valid register must include checking the 969 /* Note that the test for a valid register must include checking the
964 gdbarch_register_name because gdbarch_num_regs may be allocated for 970 gdbarch_register_name because gdbarch_num_regs may be allocated
965 the union of the register sets within a family of related processors. 971 for the union of the register sets within a family of related
966 In this case, some entries of gdbarch_register_name will change depending 972 processors. In this case, some entries of gdbarch_register_name
967 upon the particular processor being debugged. */ 973 will change depending upon the particular processor being
974 debugged. */
968 975
969 gdbarch = get_regcache_arch (this_regs); 976 gdbarch = get_regcache_arch (this_regs);
970 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); 977 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
971 978
972 make_cleanup_ui_out_list_begin_end (uiout, "changed-registers"); 979 make_cleanup_ui_out_list_begin_end (uiout, "changed-registers");
973 980
974 if (argc == 0)» » /* No args, just do all the regs. */ 981 if (argc == 0)
975 { 982 {
983 /* No args, just do all the regs. */
976 for (regnum = 0; 984 for (regnum = 0;
977 regnum < numregs; 985 regnum < numregs;
978 regnum++) 986 regnum++)
979 { 987 {
980 if (gdbarch_register_name (gdbarch, regnum) == NULL 988 if (gdbarch_register_name (gdbarch, regnum) == NULL
981 || *(gdbarch_register_name (gdbarch, regnum)) == '\0') 989 || *(gdbarch_register_name (gdbarch, regnum)) == '\0')
982 continue; 990 continue;
983 changed = register_changed_p (regnum, prev_regs, this_regs); 991 changed = register_changed_p (regnum, prev_regs, this_regs);
984 if (changed < 0) 992 if (changed < 0)
985 error (_("-data-list-changed-registers: " 993 error (_("-data-list-changed-registers: "
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 return 1; 1043 return 1;
1036 else if (this_status == REG_VALID) 1044 else if (this_status == REG_VALID)
1037 return memcmp (prev_buffer, this_buffer, 1045 return memcmp (prev_buffer, this_buffer,
1038 register_size (gdbarch, regnum)) != 0; 1046 register_size (gdbarch, regnum)) != 0;
1039 else 1047 else
1040 return 0; 1048 return 0;
1041 } 1049 }
1042 1050
1043 /* Return a list of register number and value pairs. The valid 1051 /* Return a list of register number and value pairs. The valid
1044 arguments expected are: a letter indicating the format in which to 1052 arguments expected are: a letter indicating the format in which to
1045 display the registers contents. This can be one of: x (hexadecimal), d 1053 display the registers contents. This can be one of: x
1046 (decimal), N (natural), t (binary), o (octal), r (raw). After the 1054 (hexadecimal), d (decimal), N (natural), t (binary), o (octal), r
1047 format argumetn there can be a sequence of numbers, indicating which 1055 (raw). After the format argument there can be a sequence of
1048 registers to fetch the content of. If the format is the only argument, 1056 numbers, indicating which registers to fetch the content of. If
1049 a list of all the registers with their values is returned. */ 1057 the format is the only argument, a list of all the registers with
1058 their values is returned. */
1059
1050 void 1060 void
1051 mi_cmd_data_list_register_values (char *command, char **argv, int argc) 1061 mi_cmd_data_list_register_values (char *command, char **argv, int argc)
1052 { 1062 {
1053 struct ui_out *uiout = current_uiout; 1063 struct ui_out *uiout = current_uiout;
1054 struct frame_info *frame; 1064 struct frame_info *frame;
1055 struct gdbarch *gdbarch; 1065 struct gdbarch *gdbarch;
1056 int regnum, numregs, format; 1066 int regnum, numregs, format;
1057 int i; 1067 int i;
1058 struct cleanup *list_cleanup, *tuple_cleanup; 1068 struct cleanup *list_cleanup, *tuple_cleanup;
1059 1069
1060 /* Note that the test for a valid register must include checking the 1070 /* Note that the test for a valid register must include checking the
1061 gdbarch_register_name because gdbarch_num_regs may be allocated for 1071 gdbarch_register_name because gdbarch_num_regs may be allocated
1062 the union of the register sets within a family of related processors. 1072 for the union of the register sets within a family of related
1063 In this case, some entries of gdbarch_register_name will change depending 1073 processors. In this case, some entries of gdbarch_register_name
1064 upon the particular processor being debugged. */ 1074 will change depending upon the particular processor being
1075 debugged. */
1065 1076
1066 if (argc == 0) 1077 if (argc == 0)
1067 error (_("-data-list-register-values: Usage: " 1078 error (_("-data-list-register-values: Usage: "
1068 "-data-list-register-values <format> [<regnum1>...<regnumN>]")); 1079 "-data-list-register-values <format> [<regnum1>...<regnumN>]"));
1069 1080
1070 format = (int) argv[0][0]; 1081 format = (int) argv[0][0];
1071 1082
1072 frame = get_selected_frame (NULL); 1083 frame = get_selected_frame (NULL);
1073 gdbarch = get_frame_arch (frame); 1084 gdbarch = get_frame_arch (frame);
1074 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); 1085 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
1075 1086
1076 list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values"); 1087 list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values");
1077 1088
1078 if (argc == 1)» /* No args, beside the format: do all the regs. */ 1089 if (argc == 1)
1079 { 1090 {
1091 /* No args, beside the format: do all the regs. */
1080 for (regnum = 0; 1092 for (regnum = 0;
1081 regnum < numregs; 1093 regnum < numregs;
1082 regnum++) 1094 regnum++)
1083 { 1095 {
1084 if (gdbarch_register_name (gdbarch, regnum) == NULL 1096 if (gdbarch_register_name (gdbarch, regnum) == NULL
1085 || *(gdbarch_register_name (gdbarch, regnum)) == '\0') 1097 || *(gdbarch_register_name (gdbarch, regnum)) == '\0')
1086 continue; 1098 continue;
1087 tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 1099 tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
1088 ui_out_field_int (uiout, "number", regnum); 1100 ui_out_field_int (uiout, "number", regnum);
1089 get_register (frame, regnum, format); 1101 get_register (frame, regnum, format);
(...skipping 16 matching lines...) Expand all
1106 get_register (frame, regnum, format); 1118 get_register (frame, regnum, format);
1107 do_cleanups (tuple_cleanup); 1119 do_cleanups (tuple_cleanup);
1108 } 1120 }
1109 else 1121 else
1110 error (_("bad register number")); 1122 error (_("bad register number"));
1111 } 1123 }
1112 do_cleanups (list_cleanup); 1124 do_cleanups (list_cleanup);
1113 } 1125 }
1114 1126
1115 /* Output one register's contents in the desired format. */ 1127 /* Output one register's contents in the desired format. */
1128
1116 static void 1129 static void
1117 get_register (struct frame_info *frame, int regnum, int format) 1130 get_register (struct frame_info *frame, int regnum, int format)
1118 { 1131 {
1119 struct gdbarch *gdbarch = get_frame_arch (frame); 1132 struct gdbarch *gdbarch = get_frame_arch (frame);
1120 struct ui_out *uiout = current_uiout; 1133 struct ui_out *uiout = current_uiout;
1121 CORE_ADDR addr;
1122 enum lval_type lval;
1123 struct ui_stream *stb;
1124 struct value *val; 1134 struct value *val;
1125 1135
1126 stb = ui_out_stream_new (uiout);
1127
1128 if (format == 'N') 1136 if (format == 'N')
1129 format = 0; 1137 format = 0;
1130 1138
1131 val = get_frame_register_value (frame, regnum); 1139 val = get_frame_register_value (frame, regnum);
1132 1140
1133 if (value_optimized_out (val)) 1141 if (value_optimized_out (val))
1134 error (_("Optimized out")); 1142 error (_("Optimized out"));
1135 1143
1136 if (format == 'r') 1144 if (format == 'r')
1137 { 1145 {
1138 int j; 1146 int j;
1139 char *ptr, buf[1024]; 1147 char *ptr, buf[1024];
1140 const gdb_byte *valaddr = value_contents_for_printing (val); 1148 const gdb_byte *valaddr = value_contents_for_printing (val);
1141 1149
1142 strcpy (buf, "0x"); 1150 strcpy (buf, "0x");
1143 ptr = buf + 2; 1151 ptr = buf + 2;
1144 for (j = 0; j < register_size (gdbarch, regnum); j++) 1152 for (j = 0; j < register_size (gdbarch, regnum); j++)
1145 { 1153 {
1146 int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 1154 int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ?
1147 j : register_size (gdbarch, regnum) - 1 - j; 1155 j : register_size (gdbarch, regnum) - 1 - j;
1148 1156
1149 sprintf (ptr, "%02x", (unsigned char) valaddr[idx]); 1157 sprintf (ptr, "%02x", (unsigned char) valaddr[idx]);
1150 ptr += 2; 1158 ptr += 2;
1151 } 1159 }
1152 ui_out_field_string (uiout, "value", buf); 1160 ui_out_field_string (uiout, "value", buf);
1153 /*fputs_filtered (buf, gdb_stdout); */
1154 } 1161 }
1155 else 1162 else
1156 { 1163 {
1157 struct value_print_options opts; 1164 struct value_print_options opts;
1165 struct ui_file *stb;
1166 struct cleanup *old_chain;
1167
1168 stb = mem_fileopen ();
1169 old_chain = make_cleanup_ui_file_delete (stb);
1158 1170
1159 get_formatted_print_options (&opts, format); 1171 get_formatted_print_options (&opts, format);
1160 opts.deref_ref = 1; 1172 opts.deref_ref = 1;
1161 val_print (value_type (val), 1173 val_print (value_type (val),
1162 value_contents_for_printing (val), 1174 value_contents_for_printing (val),
1163 value_embedded_offset (val), 0, 1175 value_embedded_offset (val), 0,
1164 » » stb->stream, 0, val, &opts, current_language); 1176 » » stb, 0, val, &opts, current_language);
1165 ui_out_field_stream (uiout, "value", stb); 1177 ui_out_field_stream (uiout, "value", stb);
1166 ui_out_stream_delete (stb); 1178 do_cleanups (old_chain);
1167 } 1179 }
1168 } 1180 }
1169 1181
1170 /* Write given values into registers. The registers and values are 1182 /* Write given values into registers. The registers and values are
1171 given as pairs. The corresponding MI command is 1183 given as pairs. The corresponding MI command is
1172 -data-write-register-values <format> 1184 -data-write-register-values <format>
1173 [<regnum1> <value1>...<regnumN> <valueN>] */ 1185 [<regnum1> <value1>...<regnumN> <valueN>] */
1174 void 1186 void
1175 mi_cmd_data_write_register_values (char *command, char **argv, int argc) 1187 mi_cmd_data_write_register_values (char *command, char **argv, int argc)
1176 { 1188 {
1177 struct regcache *regcache; 1189 struct regcache *regcache;
1178 struct gdbarch *gdbarch; 1190 struct gdbarch *gdbarch;
1179 int numregs, i; 1191 int numregs, i;
1180 char format; 1192 char format;
1181 1193
1182 /* Note that the test for a valid register must include checking the 1194 /* Note that the test for a valid register must include checking the
1183 gdbarch_register_name because gdbarch_num_regs may be allocated for 1195 gdbarch_register_name because gdbarch_num_regs may be allocated
1184 the union of the register sets within a family of related processors. 1196 for the union of the register sets within a family of related
1185 In this case, some entries of gdbarch_register_name will change depending 1197 processors. In this case, some entries of gdbarch_register_name
1186 upon the particular processor being debugged. */ 1198 will change depending upon the particular processor being
1199 debugged. */
1187 1200
1188 regcache = get_current_regcache (); 1201 regcache = get_current_regcache ();
1189 gdbarch = get_regcache_arch (regcache); 1202 gdbarch = get_regcache_arch (regcache);
1190 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); 1203 numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
1191 1204
1192 if (argc == 0) 1205 if (argc == 0)
1193 error (_("-data-write-register-values: Usage: -data-write-register-" 1206 error (_("-data-write-register-values: Usage: -data-write-register-"
1194 "values <format> [<regnum1> <value1>...<regnumN> <valueN>]")); 1207 "values <format> [<regnum1> <value1>...<regnumN> <valueN>]"));
1195 1208
1196 format = (int) argv[0][0]; 1209 format = (int) argv[0][0];
(...skipping 25 matching lines...) Expand all
1222 regcache_cooked_write_signed (regcache, regnum, value); 1235 regcache_cooked_write_signed (regcache, regnum, value);
1223 } 1236 }
1224 else 1237 else
1225 error (_("bad register number")); 1238 error (_("bad register number"));
1226 } 1239 }
1227 } 1240 }
1228 1241
1229 /* Evaluate the value of the argument. The argument is an 1242 /* Evaluate the value of the argument. The argument is an
1230 expression. If the expression contains spaces it needs to be 1243 expression. If the expression contains spaces it needs to be
1231 included in double quotes. */ 1244 included in double quotes. */
1245
1232 void 1246 void
1233 mi_cmd_data_evaluate_expression (char *command, char **argv, int argc) 1247 mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
1234 { 1248 {
1235 struct expression *expr; 1249 struct expression *expr;
1236 struct cleanup *old_chain = NULL; 1250 struct cleanup *old_chain;
1237 struct value *val; 1251 struct value *val;
1238 struct ui_stream *stb = NULL; 1252 struct ui_file *stb;
1239 struct value_print_options opts; 1253 struct value_print_options opts;
1240 struct ui_out *uiout = current_uiout; 1254 struct ui_out *uiout = current_uiout;
1241 1255
1242 stb = ui_out_stream_new (uiout); 1256 stb = mem_fileopen ();
1257 old_chain = make_cleanup_ui_file_delete (stb);
1243 1258
1244 if (argc != 1) 1259 if (argc != 1)
1245 { 1260 error (_("-data-evaluate-expression: "
1246 ui_out_stream_delete (stb); 1261 » "Usage: -data-evaluate-expression expression"));
1247 error (_("-data-evaluate-expression: "
1248 » "Usage: -data-evaluate-expression expression"));
1249 }
1250 1262
1251 expr = parse_expression (argv[0]); 1263 expr = parse_expression (argv[0]);
1252 1264
1253 old_chain = make_cleanup (free_current_contents, &expr); 1265 make_cleanup (free_current_contents, &expr);
1254 1266
1255 val = evaluate_expression (expr); 1267 val = evaluate_expression (expr);
1256 1268
1257 /* Print the result of the expression evaluation. */ 1269 /* Print the result of the expression evaluation. */
1258 get_user_print_options (&opts); 1270 get_user_print_options (&opts);
1259 opts.deref_ref = 0; 1271 opts.deref_ref = 0;
1260 common_val_print (val, stb->stream, 0, &opts, current_language); 1272 common_val_print (val, stb, 0, &opts, current_language);
1261 1273
1262 ui_out_field_stream (uiout, "value", stb); 1274 ui_out_field_stream (uiout, "value", stb);
1263 ui_out_stream_delete (stb);
1264 1275
1265 do_cleanups (old_chain); 1276 do_cleanups (old_chain);
1266 } 1277 }
1267 1278
1268 /* DATA-MEMORY-READ: 1279 /* This is the -data-read-memory command.
1269 1280
1270 ADDR: start address of data to be dumped. 1281 ADDR: start address of data to be dumped.
1271 WORD-FORMAT: a char indicating format for the ``word''. See 1282 WORD-FORMAT: a char indicating format for the ``word''. See
1272 the ``x'' command. 1283 the ``x'' command.
1273 WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes. 1284 WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes.
1274 NR_ROW: Number of rows. 1285 NR_ROW: Number of rows.
1275 NR_COL: The number of colums (words per row). 1286 NR_COL: The number of colums (words per row).
1276 ASCHAR: (OPTIONAL) Append an ascii character dump to each row. Use 1287 ASCHAR: (OPTIONAL) Append an ascii character dump to each row. Use
1277 ASCHAR for unprintable characters. 1288 ASCHAR for unprintable characters.
1278 1289
1279 Reads SIZE*NR_ROW*NR_COL bytes starting at ADDR from memory and 1290 Reads SIZE*NR_ROW*NR_COL bytes starting at ADDR from memory and
1280 displayes them. Returns: 1291 displayes them. Returns:
1281 1292
1282 {addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...} 1293 {addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...}
1283 1294
1284 Returns: 1295 Returns:
1285 The number of bytes read is SIZE*ROW*COL. */ 1296 The number of bytes read is SIZE*ROW*COL. */
1286 1297
1287 void 1298 void
1288 mi_cmd_data_read_memory (char *command, char **argv, int argc) 1299 mi_cmd_data_read_memory (char *command, char **argv, int argc)
1289 { 1300 {
1290 struct gdbarch *gdbarch = get_current_arch (); 1301 struct gdbarch *gdbarch = get_current_arch ();
1291 struct ui_out *uiout = current_uiout; 1302 struct ui_out *uiout = current_uiout;
1292 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); 1303 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
1293 CORE_ADDR addr; 1304 CORE_ADDR addr;
1294 long total_bytes; 1305 long total_bytes, nr_cols, nr_rows;
1295 long nr_cols;
1296 long nr_rows;
1297 char word_format; 1306 char word_format;
1298 struct type *word_type; 1307 struct type *word_type;
1299 long word_size; 1308 long word_size;
1300 char word_asize; 1309 char word_asize;
1301 char aschar; 1310 char aschar;
1302 gdb_byte *mbuf; 1311 gdb_byte *mbuf;
1303 int nr_bytes; 1312 int nr_bytes;
1304 long offset = 0; 1313 long offset = 0;
1305 int optind = 0; 1314 int oind = 0;
1306 char *optarg; 1315 char *oarg;
1307 enum opt 1316 enum opt
1317 {
1318 OFFSET_OPT
1319 };
1320 static const struct mi_opt opts[] =
1308 { 1321 {
1309 OFFSET_OPT 1322 {"o", OFFSET_OPT, 1},
1323 { 0, 0, 0 }
1310 }; 1324 };
1311 static const struct mi_opt opts[] =
1312 {
1313 {"o", OFFSET_OPT, 1},
1314 { 0, 0, 0 }
1315 };
1316 1325
1317 while (1) 1326 while (1)
1318 { 1327 {
1319 int opt = mi_getopt ("-data-read-memory", argc, argv, opts, 1328 int opt = mi_getopt ("-data-read-memory", argc, argv, opts,
1320 » » » &optind, &optarg); 1329 » » » &oind, &oarg);
1321 1330
1322 if (opt < 0) 1331 if (opt < 0)
1323 break; 1332 break;
1324 switch ((enum opt) opt) 1333 switch ((enum opt) opt)
1325 { 1334 {
1326 case OFFSET_OPT: 1335 case OFFSET_OPT:
1327 » offset = atol (optarg); 1336 » offset = atol (oarg);
1328 break; 1337 break;
1329 } 1338 }
1330 } 1339 }
1331 argv += optind; 1340 argv += oind;
1332 argc -= optind; 1341 argc -= oind;
1333 1342
1334 if (argc < 5 || argc > 6) 1343 if (argc < 5 || argc > 6)
1335 error (_("-data-read-memory: Usage: " 1344 error (_("-data-read-memory: Usage: "
1336 "ADDR WORD-FORMAT WORD-SIZE NR-ROWS NR-COLS [ASCHAR].")); 1345 "ADDR WORD-FORMAT WORD-SIZE NR-ROWS NR-COLS [ASCHAR]."));
1337 1346
1338 /* Extract all the arguments. */ 1347 /* Extract all the arguments. */
1339 1348
1340 /* Start address of the memory dump. */ 1349 /* Start address of the memory dump. */
1341 addr = parse_and_eval_address (argv[0]) + offset; 1350 addr = parse_and_eval_address (argv[0]) + offset;
1342 /* The format character to use when displaying a memory word. See 1351 /* The format character to use when displaying a memory word. See
1343 the ``x'' command. */ 1352 the ``x'' command. */
1344 word_format = argv[1][0]; 1353 word_format = argv[1][0];
1345 /* The size of the memory word. */ 1354 /* The size of the memory word. */
1346 word_size = atol (argv[2]); 1355 word_size = atol (argv[2]);
1347 switch (word_size) 1356 switch (word_size)
1348 { 1357 {
1349 case 1: 1358 case 1:
1350 word_type = builtin_type (gdbarch)->builtin_int8; 1359 word_type = builtin_type (gdbarch)->builtin_int8;
1351 word_asize = 'b'; 1360 word_asize = 'b';
1352 break; 1361 break;
1353 case 2: 1362 case 2:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 ui_out_field_int (uiout, "total-bytes", total_bytes); 1410 ui_out_field_int (uiout, "total-bytes", total_bytes);
1402 ui_out_field_core_addr (uiout, "next-row", 1411 ui_out_field_core_addr (uiout, "next-row",
1403 gdbarch, addr + word_size * nr_cols); 1412 gdbarch, addr + word_size * nr_cols);
1404 ui_out_field_core_addr (uiout, "prev-row", 1413 ui_out_field_core_addr (uiout, "prev-row",
1405 gdbarch, addr - word_size * nr_cols); 1414 gdbarch, addr - word_size * nr_cols);
1406 ui_out_field_core_addr (uiout, "next-page", gdbarch, addr + total_bytes); 1415 ui_out_field_core_addr (uiout, "next-page", gdbarch, addr + total_bytes);
1407 ui_out_field_core_addr (uiout, "prev-page", gdbarch, addr - total_bytes); 1416 ui_out_field_core_addr (uiout, "prev-page", gdbarch, addr - total_bytes);
1408 1417
1409 /* Build the result as a two dimentional table. */ 1418 /* Build the result as a two dimentional table. */
1410 { 1419 {
1411 struct ui_stream *stream = ui_out_stream_new (uiout); 1420 struct ui_file *stream;
1412 struct cleanup *cleanup_list_memory; 1421 struct cleanup *cleanup_stream;
1413 int row; 1422 int row;
1414 int row_byte; 1423 int row_byte;
1415 1424
1416 cleanup_list_memory = make_cleanup_ui_out_list_begin_end (uiout, "memory"); 1425 stream = mem_fileopen ();
1426 cleanup_stream = make_cleanup_ui_file_delete (stream);
1427
1428 make_cleanup_ui_out_list_begin_end (uiout, "memory");
1417 for (row = 0, row_byte = 0; 1429 for (row = 0, row_byte = 0;
1418 row < nr_rows; 1430 row < nr_rows;
1419 row++, row_byte += nr_cols * word_size) 1431 row++, row_byte += nr_cols * word_size)
1420 { 1432 {
1421 int col; 1433 int col;
1422 int col_byte; 1434 int col_byte;
1423 struct cleanup *cleanup_tuple; 1435 struct cleanup *cleanup_tuple;
1424 struct cleanup *cleanup_list_data; 1436 struct cleanup *cleanup_list_data;
1425 struct value_print_options opts; 1437 struct value_print_options opts;
1426 1438
1427 cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 1439 cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
1428 ui_out_field_core_addr (uiout, "addr", gdbarch, addr + row_byte); 1440 ui_out_field_core_addr (uiout, "addr", gdbarch, addr + row_byte);
1429 /* ui_out_field_core_addr_symbolic (uiout, "saddr", addr + 1441 /* ui_out_field_core_addr_symbolic (uiout, "saddr", addr +
1430 row_byte); */ 1442 row_byte); */
1431 cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data"); 1443 cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data");
1432 get_formatted_print_options (&opts, word_format); 1444 get_formatted_print_options (&opts, word_format);
1433 for (col = 0, col_byte = row_byte; 1445 for (col = 0, col_byte = row_byte;
1434 col < nr_cols; 1446 col < nr_cols;
1435 col++, col_byte += word_size) 1447 col++, col_byte += word_size)
1436 { 1448 {
1437 if (col_byte + word_size > nr_bytes) 1449 if (col_byte + word_size > nr_bytes)
1438 { 1450 {
1439 ui_out_field_string (uiout, NULL, "N/A"); 1451 ui_out_field_string (uiout, NULL, "N/A");
1440 } 1452 }
1441 else 1453 else
1442 { 1454 {
1443 » » ui_file_rewind (stream->stream); 1455 » » ui_file_rewind (stream);
1444 print_scalar_formatted (mbuf + col_byte, word_type, &opts, 1456 print_scalar_formatted (mbuf + col_byte, word_type, &opts,
1445 » » » » » word_asize, stream->stream); 1457 » » » » » word_asize, stream);
1446 ui_out_field_stream (uiout, NULL, stream); 1458 ui_out_field_stream (uiout, NULL, stream);
1447 } 1459 }
1448 } 1460 }
1449 do_cleanups (cleanup_list_data); 1461 do_cleanups (cleanup_list_data);
1450 if (aschar) 1462 if (aschar)
1451 { 1463 {
1452 int byte; 1464 int byte;
1453 1465
1454 » ui_file_rewind (stream->stream); 1466 » ui_file_rewind (stream);
1455 for (byte = row_byte; 1467 for (byte = row_byte;
1456 byte < row_byte + word_size * nr_cols; byte++) 1468 byte < row_byte + word_size * nr_cols; byte++)
1457 { 1469 {
1458 if (byte >= nr_bytes) 1470 if (byte >= nr_bytes)
1459 » » { 1471 » » fputc_unfiltered ('X', stream);
1460 » » fputc_unfiltered ('X', stream->stream);
1461 » » }
1462 else if (mbuf[byte] < 32 || mbuf[byte] > 126) 1472 else if (mbuf[byte] < 32 || mbuf[byte] > 126)
1463 » » { 1473 » » fputc_unfiltered (aschar, stream);
1464 » » fputc_unfiltered (aschar, stream->stream);
1465 » » }
1466 else 1474 else
1467 » » fputc_unfiltered (mbuf[byte], stream->stream); 1475 » » fputc_unfiltered (mbuf[byte], stream);
1468 } 1476 }
1469 ui_out_field_stream (uiout, "ascii", stream); 1477 ui_out_field_stream (uiout, "ascii", stream);
1470 } 1478 }
1471 do_cleanups (cleanup_tuple); 1479 do_cleanups (cleanup_tuple);
1472 } 1480 }
1473 ui_out_stream_delete (stream); 1481 do_cleanups (cleanup_stream);
1474 do_cleanups (cleanup_list_memory);
1475 } 1482 }
1476 do_cleanups (cleanups); 1483 do_cleanups (cleanups);
1477 } 1484 }
1478 1485
1479 void 1486 void
1480 mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc) 1487 mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc)
1481 { 1488 {
1482 struct gdbarch *gdbarch = get_current_arch (); 1489 struct gdbarch *gdbarch = get_current_arch ();
1483 struct ui_out *uiout = current_uiout; 1490 struct ui_out *uiout = current_uiout;
1484 struct cleanup *cleanups; 1491 struct cleanup *cleanups;
1485 CORE_ADDR addr; 1492 CORE_ADDR addr;
1486 LONGEST length; 1493 LONGEST length;
1487 memory_read_result_s *read_result; 1494 memory_read_result_s *read_result;
1488 int ix; 1495 int ix;
1489 VEC(memory_read_result_s) *result; 1496 VEC(memory_read_result_s) *result;
1490 long offset = 0; 1497 long offset = 0;
1491 int optind = 0; 1498 int oind = 0;
1492 char *optarg; 1499 char *oarg;
1493 enum opt 1500 enum opt
1501 {
1502 OFFSET_OPT
1503 };
1504 static const struct mi_opt opts[] =
1494 { 1505 {
1495 OFFSET_OPT 1506 {"o", OFFSET_OPT, 1},
1507 { 0, 0, 0 }
1496 }; 1508 };
1497 static const struct mi_opt opts[] =
1498 {
1499 {"o", OFFSET_OPT, 1},
1500 { 0, 0, 0 }
1501 };
1502 1509
1503 while (1) 1510 while (1)
1504 { 1511 {
1505 int opt = mi_getopt ("-data-read-memory-bytes", argc, argv, opts, 1512 int opt = mi_getopt ("-data-read-memory-bytes", argc, argv, opts,
1506 » » » &optind, &optarg); 1513 » » » &oind, &oarg);
1507 if (opt < 0) 1514 if (opt < 0)
1508 break; 1515 break;
1509 switch ((enum opt) opt) 1516 switch ((enum opt) opt)
1510 { 1517 {
1511 case OFFSET_OPT: 1518 case OFFSET_OPT:
1512 » offset = atol (optarg); 1519 » offset = atol (oarg);
1513 break; 1520 break;
1514 } 1521 }
1515 } 1522 }
1516 argv += optind; 1523 argv += oind;
1517 argc -= optind; 1524 argc -= oind;
1518 1525
1519 if (argc != 2) 1526 if (argc != 2)
1520 error (_("Usage: [ -o OFFSET ] ADDR LENGTH.")); 1527 error (_("Usage: [ -o OFFSET ] ADDR LENGTH."));
1521 1528
1522 addr = parse_and_eval_address (argv[0]) + offset; 1529 addr = parse_and_eval_address (argv[0]) + offset;
1523 length = atol (argv[1]); 1530 length = atol (argv[1]);
1524 1531
1525 result = read_memory_robust (current_target.beneath, addr, length); 1532 result = read_memory_robust (current_target.beneath, addr, length);
1526 1533
1527 cleanups = make_cleanup (free_memory_read_result_vector, result); 1534 cleanups = make_cleanup (free_memory_read_result_vector, result);
(...skipping 23 matching lines...) Expand all
1551 { 1558 {
1552 sprintf (p, "%02x", read_result->data[i]); 1559 sprintf (p, "%02x", read_result->data[i]);
1553 } 1560 }
1554 ui_out_field_string (uiout, "contents", data); 1561 ui_out_field_string (uiout, "contents", data);
1555 xfree (data); 1562 xfree (data);
1556 do_cleanups (t); 1563 do_cleanups (t);
1557 } 1564 }
1558 do_cleanups (cleanups); 1565 do_cleanups (cleanups);
1559 } 1566 }
1560 1567
1561 1568 /* Implementation of the -data-write_memory command.
1562 /* DATA-MEMORY-WRITE:
1563 1569
1564 COLUMN_OFFSET: optional argument. Must be preceded by '-o'. The 1570 COLUMN_OFFSET: optional argument. Must be preceded by '-o'. The
1565 offset from the beginning of the memory grid row where the cell to 1571 offset from the beginning of the memory grid row where the cell to
1566 be written is. 1572 be written is.
1567 ADDR: start address of the row in the memory grid where the memory 1573 ADDR: start address of the row in the memory grid where the memory
1568 cell is, if OFFSET_COLUMN is specified. Otherwise, the address of 1574 cell is, if OFFSET_COLUMN is specified. Otherwise, the address of
1569 the location to write to. 1575 the location to write to.
1570 FORMAT: a char indicating format for the ``word''. See 1576 FORMAT: a char indicating format for the ``word''. See
1571 the ``x'' command. 1577 the ``x'' command.
1572 WORD_SIZE: size of each ``word''; 1,2,4, or 8 bytes 1578 WORD_SIZE: size of each ``word''; 1,2,4, or 8 bytes
1573 VALUE: value to be written into the memory address. 1579 VALUE: value to be written into the memory address.
1574 1580
1575 Writes VALUE into ADDR + (COLUMN_OFFSET * WORD_SIZE). 1581 Writes VALUE into ADDR + (COLUMN_OFFSET * WORD_SIZE).
1576 1582
1577 Prints nothing. */ 1583 Prints nothing. */
1584
1578 void 1585 void
1579 mi_cmd_data_write_memory (char *command, char **argv, int argc) 1586 mi_cmd_data_write_memory (char *command, char **argv, int argc)
1580 { 1587 {
1581 struct gdbarch *gdbarch = get_current_arch (); 1588 struct gdbarch *gdbarch = get_current_arch ();
1582 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 1589 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1583 CORE_ADDR addr; 1590 CORE_ADDR addr;
1584 char word_format; 1591 char word_format;
1585 long word_size; 1592 long word_size;
1586 /* FIXME: ezannoni 2000-02-17 LONGEST could possibly not be big 1593 /* FIXME: ezannoni 2000-02-17 LONGEST could possibly not be big
1587 enough when using a compiler other than GCC. */ 1594 enough when using a compiler other than GCC. */
1588 LONGEST value; 1595 LONGEST value;
1589 void *buffer; 1596 void *buffer;
1590 struct cleanup *old_chain; 1597 struct cleanup *old_chain;
1591 long offset = 0; 1598 long offset = 0;
1592 int optind = 0; 1599 int oind = 0;
1593 char *optarg; 1600 char *oarg;
1594 enum opt 1601 enum opt
1602 {
1603 OFFSET_OPT
1604 };
1605 static const struct mi_opt opts[] =
1595 { 1606 {
1596 OFFSET_OPT 1607 {"o", OFFSET_OPT, 1},
1608 { 0, 0, 0 }
1597 }; 1609 };
1598 static const struct mi_opt opts[] =
1599 {
1600 {"o", OFFSET_OPT, 1},
1601 { 0, 0, 0 }
1602 };
1603 1610
1604 while (1) 1611 while (1)
1605 { 1612 {
1606 int opt = mi_getopt ("-data-write-memory", argc, argv, opts, 1613 int opt = mi_getopt ("-data-write-memory", argc, argv, opts,
1607 » » » &optind, &optarg); 1614 » » » &oind, &oarg);
1608 1615
1609 if (opt < 0) 1616 if (opt < 0)
1610 break; 1617 break;
1611 switch ((enum opt) opt) 1618 switch ((enum opt) opt)
1612 { 1619 {
1613 case OFFSET_OPT: 1620 case OFFSET_OPT:
1614 » offset = atol (optarg); 1621 » offset = atol (oarg);
1615 break; 1622 break;
1616 } 1623 }
1617 } 1624 }
1618 argv += optind; 1625 argv += oind;
1619 argc -= optind; 1626 argc -= oind;
1620 1627
1621 if (argc != 4) 1628 if (argc != 4)
1622 error (_("-data-write-memory: Usage: " 1629 error (_("-data-write-memory: Usage: "
1623 "[-o COLUMN_OFFSET] ADDR FORMAT WORD-SIZE VALUE.")); 1630 "[-o COLUMN_OFFSET] ADDR FORMAT WORD-SIZE VALUE."));
1624 1631
1625 /* Extract all the arguments. */ 1632 /* Extract all the arguments. */
1626 /* Start address of the memory dump. */ 1633 /* Start address of the memory dump. */
1627 addr = parse_and_eval_address (argv[0]); 1634 addr = parse_and_eval_address (argv[0]);
1628 /* The format character to use when displaying a memory word. See 1635 /* The format character to use when displaying a memory word. See
1629 the ``x'' command. */ 1636 the ``x'' command. */
1630 word_format = argv[1][0]; 1637 word_format = argv[1][0];
1631 /* The size of the memory word. */ 1638 /* The size of the memory word. */
1632 word_size = atol (argv[2]); 1639 word_size = atol (argv[2]);
1633 1640
1634 /* Calculate the real address of the write destination. */ 1641 /* Calculate the real address of the write destination. */
1635 addr += (offset * word_size); 1642 addr += (offset * word_size);
1636 1643
1637 /* Get the value as a number. */ 1644 /* Get the value as a number. */
1638 value = parse_and_eval_address (argv[3]); 1645 value = parse_and_eval_address (argv[3]);
1639 /* Get the value into an array. */ 1646 /* Get the value into an array. */
1640 buffer = xmalloc (word_size); 1647 buffer = xmalloc (word_size);
1641 old_chain = make_cleanup (xfree, buffer); 1648 old_chain = make_cleanup (xfree, buffer);
1642 store_signed_integer (buffer, word_size, byte_order, value); 1649 store_signed_integer (buffer, word_size, byte_order, value);
1643 /* Write it down to memory. */ 1650 /* Write it down to memory. */
1644 write_memory (addr, buffer, word_size); 1651 write_memory (addr, buffer, word_size);
1645 /* Free the buffer. */ 1652 /* Free the buffer. */
1646 do_cleanups (old_chain); 1653 do_cleanups (old_chain);
1647 } 1654 }
1648 1655
1649 /* DATA-MEMORY-WRITE-RAW: 1656 /* Implementation of the -data-write-memory-bytes command.
1650 1657
1651 ADDR: start address 1658 ADDR: start address
1652 DATA: string of bytes to write at that address. */ 1659 DATA: string of bytes to write at that address. */
1660
1653 void 1661 void
1654 mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc) 1662 mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc)
1655 { 1663 {
1656 CORE_ADDR addr; 1664 CORE_ADDR addr;
1657 char *cdata; 1665 char *cdata;
1658 gdb_byte *data; 1666 gdb_byte *data;
1659 int len, r, i; 1667 int len, r, i;
1660 struct cleanup *back_to; 1668 struct cleanup *back_to;
1661 1669
1662 if (argc != 2) 1670 if (argc != 2)
1663 error (_("Usage: ADDR DATA.")); 1671 error (_("Usage: ADDR DATA."));
1664 1672
1665 addr = parse_and_eval_address (argv[0]); 1673 addr = parse_and_eval_address (argv[0]);
1666 cdata = argv[1]; 1674 cdata = argv[1];
1667 len = strlen (cdata)/2; 1675 len = strlen (cdata)/2;
1668 1676
1669 data = xmalloc (len); 1677 data = xmalloc (len);
1670 back_to = make_cleanup (xfree, data); 1678 back_to = make_cleanup (xfree, data);
1671 1679
1672 for (i = 0; i < len; ++i) 1680 for (i = 0; i < len; ++i)
1673 { 1681 {
1674 int x; 1682 int x;
1675 sscanf (cdata + i * 2, "%02x", &x); 1683 sscanf (cdata + i * 2, "%02x", &x);
1676 data[i] = (gdb_byte)x; 1684 data[i] = (gdb_byte) x;
1677 } 1685 }
1678 1686
1679 r = target_write_memory (addr, data, len); 1687 r = target_write_memory (addr, data, len);
1680 if (r != 0) 1688 if (r != 0)
1681 error (_("Could not write memory")); 1689 error (_("Could not write memory"));
1682 1690
1683 do_cleanups (back_to); 1691 do_cleanups (back_to);
1684 } 1692 }
1685 1693
1686
1687 void 1694 void
1688 mi_cmd_enable_timings (char *command, char **argv, int argc) 1695 mi_cmd_enable_timings (char *command, char **argv, int argc)
1689 { 1696 {
1690 if (argc == 0) 1697 if (argc == 0)
1691 do_timings = 1; 1698 do_timings = 1;
1692 else if (argc == 1) 1699 else if (argc == 1)
1693 { 1700 {
1694 if (strcmp (argv[0], "yes") == 0) 1701 if (strcmp (argv[0], "yes") == 0)
1695 do_timings = 1; 1702 do_timings = 1;
1696 else if (strcmp (argv[0], "no") == 0) 1703 else if (strcmp (argv[0], "no") == 0)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 struct inferior *inf; 1768 struct inferior *inf;
1762 1769
1763 if (argc != 0) 1770 if (argc != 0)
1764 error (_("-add-inferior should be passed no arguments")); 1771 error (_("-add-inferior should be passed no arguments"));
1765 1772
1766 inf = add_inferior_with_spaces (); 1773 inf = add_inferior_with_spaces ();
1767 1774
1768 ui_out_field_fmt (current_uiout, "inferior", "i%d", inf->num); 1775 ui_out_field_fmt (current_uiout, "inferior", "i%d", inf->num);
1769 } 1776 }
1770 1777
1771 /* Callback used to find the first inferior other than the 1778 /* Callback used to find the first inferior other than the current
1772 current one. */ 1779 one. */
1773 1780
1774 static int 1781 static int
1775 get_other_inferior (struct inferior *inf, void *arg) 1782 get_other_inferior (struct inferior *inf, void *arg)
1776 { 1783 {
1777 if (inf == current_inferior ()) 1784 if (inf == current_inferior ())
1778 return 0; 1785 return 0;
1779 1786
1780 return 1; 1787 return 1;
1781 } 1788 }
1782 1789
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 set_current_program_space (new_inferior->pspace); 1822 set_current_program_space (new_inferior->pspace);
1816 } 1823 }
1817 1824
1818 delete_inferior_1 (inf, 1 /* silent */); 1825 delete_inferior_1 (inf, 1 /* silent */);
1819 } 1826 }
1820 1827
1821 1828
1822 1829
1823 1830
1824 /* Execute a command within a safe environment. 1831 /* Execute a command within a safe environment.

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/mi/mi-interp.c ('k') | gdb/mi/mi-out.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698