From 2b03b41d6ac4781c8aac2baa37e9ec282dd0d2b0 Mon Sep 17 00:00:00 2001 From: Stan Shebs Date: Tue, 6 Mar 2012 22:48:53 +0000 Subject: [PATCH] * mi/mi-cmd-break.c: Enforce coding standards, fix comments. * mi/mi-cmd-disas.c: Ditto. * mi/mi-cmd-env.c: Ditto. * mi/mi-cmd-file.c: Ditto. * mi/mi-cmd-stack.c: Ditto. * mi/mi-cmd-target.c: Ditto. * mi/mi-cmd-var.c: Ditto. * mi/mi-cmds.c: Ditto. * mi/mi-cmds.h: Ditto. * mi/mi-console.c: Ditto. * mi/mi-getopt.c: Ditto. * mi/mi-getopt.h: Ditto. * mi/mi-interp.c: Ditto. * mi/mi-main.c: Ditto. * mi/mi-out.c: Ditto. * mi/mi-parse.c: Ditto. * mi/mi-parse.h: Ditto. * mi/mi-symbol-cmds.c: Ditto. * mi/mi-getopt.h: Move mi_opt struct up. * mi/mi-main.c (captured_mi_execute_command): Remove redundant return. * mi/mi-out.c (_initialize_mi_out): Remove empty initialize. --- gdb/ChangeLog | 26 ++++ gdb/mi/mi-cmd-break.c | 8 +- gdb/mi/mi-cmd-disas.c | 31 ++-- gdb/mi/mi-cmd-env.c | 16 ++- gdb/mi/mi-cmd-file.c | 23 +-- gdb/mi/mi-cmd-stack.c | 46 +++--- gdb/mi/mi-cmd-target.c | 18 +-- gdb/mi/mi-cmd-var.c | 98 +++++++------ gdb/mi/mi-cmds.c | 22 +-- gdb/mi/mi-cmds.h | 9 +- gdb/mi/mi-console.c | 37 +++-- gdb/mi/mi-getopt.c | 14 +- gdb/mi/mi-getopt.h | 34 ++--- gdb/mi/mi-interp.c | 130 +++++++++-------- gdb/mi/mi-main.c | 304 ++++++++++++++++++++-------------------- gdb/mi/mi-out.c | 92 +++++------- gdb/mi/mi-parse.c | 48 +++---- gdb/mi/mi-parse.h | 2 +- gdb/mi/mi-symbol-cmds.c | 14 +- 19 files changed, 501 insertions(+), 471 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f28fbfd638..760ae5c865 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,29 @@ +2012-03-06 Stan Shebs + + * mi/mi-cmd-break.c: Enforce coding standards, fix comments. + * mi/mi-cmd-disas.c: Ditto. + * mi/mi-cmd-env.c: Ditto. + * mi/mi-cmd-file.c: Ditto. + * mi/mi-cmd-stack.c: Ditto. + * mi/mi-cmd-target.c: Ditto. + * mi/mi-cmd-var.c: Ditto. + * mi/mi-cmds.c: Ditto. + * mi/mi-cmds.h: Ditto. + * mi/mi-console.c: Ditto. + * mi/mi-getopt.c: Ditto. + * mi/mi-getopt.h: Ditto. + * mi/mi-interp.c: Ditto. + * mi/mi-main.c: Ditto. + * mi/mi-out.c: Ditto. + * mi/mi-parse.c: Ditto. + * mi/mi-parse.h: Ditto. + * mi/mi-symbol-cmds.c: Ditto. + + * mi/mi-getopt.h: Move mi_opt struct up. + * mi/mi-main.c (captured_mi_execute_command): Remove redundant + return. + * mi/mi-out.c (_initialize_mi_out): Remove empty initialize. + 2012-03-06 Tom Tromey * proc-service.c (ps_pglobal_lookup): Set the current program diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 7c89a3f29c..b3a3e32e4c 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -43,7 +43,7 @@ static int mi_breakpoint_observers_installed; static int mi_can_breakpoint_notify; -/* Output a single breakpoint, when allowed. */ +/* Output a single breakpoint, when allowed. */ static void breakpoint_notify (struct breakpoint *b) @@ -142,7 +142,7 @@ mi_cmd_break_insert (char *command, char **argv, int argc) error (_("-break-insert: Garbage following ")); address = argv[oind]; - /* Now we have what we need, let's insert the breakpoint! */ + /* Now we have what we need, let's insert the breakpoint! */ if (! mi_breakpoint_observers_installed) { observer_attach_breakpoint_created (breakpoint_notify); @@ -209,7 +209,7 @@ mi_cmd_break_passcount (char *command, char **argv, int argc) first argument: -break-watch --> insert a regular wp. -break-watch -r --> insert a read watchpoint. - -break-watch -a --> insert an access wp. */ + -break-watch -a --> insert an access wp. */ void mi_cmd_break_watch (char *command, char **argv, int argc) @@ -254,7 +254,7 @@ mi_cmd_break_watch (char *command, char **argv, int argc) error (_("-break-watch: Garbage following ")); expr = argv[oind]; - /* Now we have what we need, let's insert the watchpoint! */ + /* Now we have what we need, let's insert the watchpoint! */ switch (type) { case REG_WP: diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c index 281951c005..b6afb082c0 100644 --- a/gdb/mi/mi-cmd-disas.c +++ b/gdb/mi/mi-cmd-disas.c @@ -27,8 +27,7 @@ #include "ui-out.h" #include "disasm.h" -/* The arguments to be passed on the command line and parsed here are: - +/* The arguments to be passed on the command line and parsed here are either: START-ADDRESS: address to start the disassembly at. @@ -50,6 +49,7 @@ 2 -- disassembly and opcodes. 3 -- disassembly, source and opcodes. */ + void mi_cmd_disassemble (char *command, char **argv, int argc) { @@ -75,24 +75,25 @@ mi_cmd_disassemble (char *command, char **argv, int argc) CORE_ADDR high = 0; struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); - /* Options processing stuff. */ + /* Options processing stuff. */ int oind = 0; char *oarg; enum opt { FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT }; - static const struct mi_opt opts[] = { - {"f", FILE_OPT, 1}, - {"l", LINE_OPT, 1}, - {"n", NUM_OPT, 1}, - {"s", START_OPT, 1}, - {"e", END_OPT, 1}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = + { + {"f", FILE_OPT, 1}, + {"l", LINE_OPT, 1}, + {"n", NUM_OPT, 1}, + {"s", START_OPT, 1}, + {"e", END_OPT, 1}, + { 0, 0, 0 } + }; /* Get the options with their arguments. Keep track of what we - encountered. */ + encountered. */ while (1) { int opt = mi_getopt ("-data-disassemble", argc, argv, opts, @@ -128,7 +129,7 @@ mi_cmd_disassemble (char *command, char **argv, int argc) argc -= oind; /* Allow only filename + linenum (with how_many which is not - required) OR start_addr + and_addr */ + required) OR start_addr + end_addr. */ if (!((line_seen && file_seen && num_seen && !start_seen && !end_seen) || (line_seen && file_seen && !num_seen && !start_seen && !end_seen) @@ -144,7 +145,7 @@ mi_cmd_disassemble (char *command, char **argv, int argc) if (mode < 0 || mode > 3) error (_("-data-disassemble: Mode argument must be 0, 1, 2, or 3.")); - /* Convert the mode into a set of disassembly flags */ + /* Convert the mode into a set of disassembly flags. */ disasm_flags = 0; if (mode & 0x1) @@ -153,7 +154,7 @@ mi_cmd_disassemble (char *command, char **argv, int argc) disasm_flags |= DISASSEMBLY_RAW_INSN; /* We must get the function beginning and end where line_num is - contained. */ + contained. */ if (line_seen && file_seen) { diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c index 8324049881..ebf4974dd1 100644 --- a/gdb/mi/mi-cmd-env.c +++ b/gdb/mi/mi-cmd-env.c @@ -1,5 +1,4 @@ /* MI Command Set - environment commands. - Copyright (C) 2002-2004, 2007-2012 Free Software Foundation, Inc. Contributed by Red Hat Inc. @@ -36,6 +35,7 @@ #include "gdb_stat.h" static void env_mod_path (char *dirname, char **which_path); + extern void _initialize_mi_cmd_env (void); static const char path_var_name[] = "PATH"; @@ -44,6 +44,7 @@ static char *orig_path = NULL; /* The following is copied from mi-main.c so for m1 and below we can perform old behavior and use cli commands. If ARGS is non-null, append it to the CMD. */ + static void env_execute_cli_command (const char *cmd, const char *args) { @@ -63,15 +64,15 @@ env_execute_cli_command (const char *cmd, const char *args) } } - /* Print working directory. */ + void mi_cmd_env_pwd (char *command, char **argv, int argc) { struct ui_out *uiout = current_uiout; if (argc > 0) - error (_("-environment-pwd: No arguments required")); + error (_("-environment-pwd: No arguments allowed")); if (mi_version (uiout) < 2) { @@ -89,6 +90,7 @@ mi_cmd_env_pwd (char *command, char **argv, int argc) } /* Change working directory. */ + void mi_cmd_env_cd (char *command, char **argv, int argc) { @@ -110,6 +112,7 @@ env_mod_path (char *dirname, char **which_path) } /* Add one or more directories to start of executable search path. */ + void mi_cmd_env_path (char *command, char **argv, int argc) { @@ -184,6 +187,7 @@ mi_cmd_env_path (char *command, char **argv, int argc) } /* Add zero or more directories to the front of the source path. */ + void mi_cmd_env_dir (char *command, char **argv, int argc) { @@ -244,13 +248,15 @@ mi_cmd_env_dir (char *command, char **argv, int argc) } /* Set the inferior terminal device name. */ + void mi_cmd_inferior_tty_set (char *command, char **argv, int argc) { set_inferior_io_terminal (argv[0]); } -/* Print the inferior terminal device name */ +/* Print the inferior terminal device name. */ + void mi_cmd_inferior_tty_show (char *command, char **argv, int argc) { @@ -273,7 +279,7 @@ _initialize_mi_cmd_env (void) /* We want original execution path to reset to, if desired later. At this point, current inferior is not created, so cannot use current_inferior ()->environment. Also, there's no obvious - place where this code can be moved suchs that it surely run + place where this code can be moved such that it surely run before any code possibly mangles original PATH. */ environment = make_environ (); init_environ (environment); diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index c4d1461917..0b2b725a0c 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -1,4 +1,4 @@ -/* MI Command Set - breakpoint and watchpoint commands. +/* MI Command Set - file commands. Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc. Contributed by Cygnus Solutions (a Red Hat company). @@ -27,7 +27,7 @@ #include "psymtab.h" /* Return to the client the absolute path and line number of the - current file being executed. */ + current file being executed. */ void mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) @@ -38,20 +38,20 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv)) error (_("-file-list-exec-source-file: Usage: No args")); - /* Set the default file and line, also get them */ + /* Set the default file and line, also get them. */ set_default_source_symtab_and_line (); st = get_current_source_symtab_and_line (); - /* We should always get a symtab. - Apparently, filename does not need to be tested for NULL. - The documentation in symtab.h suggests it will always be correct */ + /* We should always get a symtab. Apparently, filename does not + need to be tested for NULL. The documentation in symtab.h + suggests it will always be correct. */ if (!st.symtab) error (_("-file-list-exec-source-file: No symtab")); - /* Extract the fullname if it is not known yet */ + /* Extract the fullname if it is not known yet. */ symtab_to_fullname (st.symtab); - /* Print to the user the line, filename and fullname */ + /* Print to the user the line, filename and fullname. */ ui_out_field_int (uiout, "line", st.line); ui_out_field_string (uiout, "file", st.symtab->filename); @@ -63,6 +63,7 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) } /* A callback for map_partial_symbol_filenames. */ + static void print_partial_file_name (const char *filename, const char *fullname, void *ignore) @@ -89,17 +90,17 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc) if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv)) error (_("-file-list-exec-source-files: Usage: No args")); - /* Print the table header */ + /* Print the table header. */ ui_out_begin (uiout, ui_out_type_list, "files"); - /* Look at all of the symtabs */ + /* Look at all of the symtabs. */ ALL_SYMTABS (objfile, s) { ui_out_begin (uiout, ui_out_type_tuple, NULL); ui_out_field_string (uiout, "file", s->filename); - /* Extract the fullname if it is not known yet */ + /* Extract the fullname if it is not known yet. */ symtab_to_fullname (s); if (s->fullname) diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 4ad9f7c1f0..efb2abe272 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -39,11 +39,12 @@ static void list_args_or_locals (enum what_to_list what, enum print_values values, struct frame_info *fi); -/* Print a list of the stack frames. Args can be none, in which case +/* Print a list of the stack frames. Args can be none, in which case we want to print the whole backtrace, or a pair of numbers specifying the frame numbers at which to start and stop the - display. If the two numbers are equal, a single frame will be - displayed. */ + display. If the two numbers are equal, a single frame will be + displayed. */ + void mi_cmd_stack_list_frames (char *command, char **argv, int argc) { @@ -64,14 +65,14 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc) else { /* Called with no arguments, it means we want the whole - backtrace. */ + backtrace. */ frame_low = -1; frame_high = -1; } /* Let's position fi on the frame at which to start the display. Could be the innermost frame if the whole stack needs - displaying, or if frame_low is 0. */ + displaying, or if frame_low is 0. */ for (i = 0, fi = get_current_frame (); fi && i < frame_low; i++, fi = get_prev_frame (fi)); @@ -81,15 +82,15 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc) cleanup_stack = make_cleanup_ui_out_list_begin_end (current_uiout, "stack"); - /* Now let;s print the frames up to frame_high, or until there are - frames in the stack. */ + /* Now let's print the frames up to frame_high, or until there are + frames in the stack. */ for (; fi && (i <= frame_high || frame_high == -1); i++, fi = get_prev_frame (fi)) { QUIT; /* Print the location and the address always, even for level 0. - args == 0: don't print the arguments. */ + If args is 0, don't print the arguments. */ print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */ ); } @@ -110,7 +111,7 @@ mi_cmd_stack_info_depth (char *command, char **argv, int argc) frame_high = atoi (argv[0]); else /* Called with no arguments, it means we want the real depth of - the stack. */ + the stack. */ frame_high = -1; for (i = 0, fi = get_current_frame (); @@ -141,7 +142,8 @@ parse_print_values (char *name) /* Print a list of the locals for the current frame. With argument of 0, print only the names, with argument of 1 print also the - values. */ + values. */ + void mi_cmd_stack_list_locals (char *command, char **argv, int argc) { @@ -157,7 +159,8 @@ mi_cmd_stack_list_locals (char *command, char **argv, int argc) /* Print a list of the arguments for the current frame. With argument of 0, print only the names, with argument of 1 print also the - values. */ + values. */ + void mi_cmd_stack_list_args (char *command, char **argv, int argc) { @@ -181,7 +184,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) else { /* Called with no arguments, it means we want args for the whole - backtrace. */ + backtrace. */ frame_low = -1; frame_high = -1; } @@ -190,7 +193,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) /* Let's position fi on the frame at which to start the display. Could be the innermost frame if the whole stack needs - displaying, or if frame_low is 0. */ + displaying, or if frame_low is 0. */ for (i = 0, fi = get_current_frame (); fi && i < frame_low; i++, fi = get_prev_frame (fi)); @@ -202,7 +205,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) = make_cleanup_ui_out_list_begin_end (uiout, "stack-args"); /* Now let's print the frames up to frame_high, or until there are - frames in the stack. */ + frames in the stack. */ for (; fi && (i <= frame_high || frame_high == -1); i++, fi = get_prev_frame (fi)) @@ -223,6 +226,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) current frame. ARGC must be 1 and ARGV[0] specify if only the names, or both names and values of the variables must be printed. See parse_print_value for possible values. */ + void mi_cmd_stack_list_variables (char *command, char **argv, int argc) { @@ -236,11 +240,11 @@ mi_cmd_stack_list_variables (char *command, char **argv, int argc) list_args_or_locals (all, parse_print_values (argv[0]), frame); } -/* Print single local or argument. ARG must be already read in. For WHAT and - VALUES see list_args_or_locals. +/* Print single local or argument. ARG must be already read in. For + WHAT and VALUES see list_args_or_locals. - Errors are printed as if they would be the parameter value. Use zeroed ARG - iff it should not be printed accoring to VALUES. */ + Errors are printed as if they would be the parameter value. Use + zeroed ARG iff it should not be printed according to VALUES. */ static void list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, @@ -312,7 +316,8 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, /* Print a list of the locals or the arguments for the currently selected frame. If the argument passed is 0, printonly the names of the variables, if an argument of 1 is passed, print the values - as well. */ + as well. */ + static void list_args_or_locals (enum what_to_list what, enum print_values values, struct frame_info *fi) @@ -425,6 +430,7 @@ list_args_or_locals (enum what_to_list what, enum print_values values, xfree (entryarg.error); } } + if (BLOCK_FUNCTION (block)) break; else @@ -447,7 +453,7 @@ void mi_cmd_stack_info_frame (char *command, char **argv, int argc) { if (argc > 0) - error (_("-stack-info-frame: No arguments required")); + error (_("-stack-info-frame: No arguments allowed")); print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0); } diff --git a/gdb/mi/mi-cmd-target.c b/gdb/mi/mi-cmd-target.c index 35ca4f6fa1..e6e04a7d11 100644 --- a/gdb/mi/mi-cmd-target.c +++ b/gdb/mi/mi-cmd-target.c @@ -30,9 +30,9 @@ mi_cmd_target_file_get (char *command, char **argv, int argc) char *oarg; const char *remote_file, *local_file; static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + { + { 0, 0, 0 } + }; static const char prefix[] = "-target-file-get"; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 @@ -54,9 +54,9 @@ mi_cmd_target_file_put (char *command, char **argv, int argc) char *oarg; const char *remote_file, *local_file; static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + { + { 0, 0, 0 } + }; static const char prefix[] = "-target-file-put"; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 @@ -78,9 +78,9 @@ mi_cmd_target_file_delete (char *command, char **argv, int argc) char *oarg; const char *remote_file; static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + { + { 0, 0, 0 } + }; static const char prefix[] = "-target-file-delete"; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 4de73924b9..06036794b3 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -1,5 +1,4 @@ /* MI Command Set - varobj commands. - Copyright (C) 2000, 2002, 2004-2005, 2007-2012 Free Software Foundation, Inc. @@ -38,8 +37,8 @@ const char mi_all_values[] = "--all-values"; extern int varobjdebug; /* defined in varobj.c. */ static void varobj_update_one (struct varobj *var, - enum print_values print_values, - int explicit); + enum print_values print_values, + int explicit); static int mi_print_value_p (struct varobj *var, enum print_values print_values); @@ -47,6 +46,7 @@ static int mi_print_value_p (struct varobj *var, /* Print variable object VAR. The PRINT_VALUES parameter controls if the value should be printed. The PRINT_EXPRESSION parameter controls if the expression should be printed. */ + static void print_varobj (struct varobj *var, enum print_values print_values, int print_expression) @@ -109,15 +109,11 @@ mi_cmd_var_create (char *command, char **argv, int argc) enum varobj_type var_type; if (argc != 3) - { - /* mi_error_message = xstrprintf ("-var-create: Usage: - ...."); return MI_CMD_ERROR; */ - error (_("-var-create: Usage: NAME FRAME EXPRESSION.")); - } + error (_("-var-create: Usage: NAME FRAME EXPRESSION.")); name = xstrdup (argv[0]); - /* Add cleanup for name. Must be free_current_contents as - name can be reallocated */ + /* Add cleanup for name. Must be free_current_contents as name can + be reallocated. */ old_cleanups = make_cleanup (free_current_contents, &name); frame = xstrdup (argv[1]); @@ -175,12 +171,12 @@ mi_cmd_var_delete (char *command, char **argv, int argc) error (_("-var-delete: Usage: [-c] EXPRESSION.")); name = xstrdup (argv[0]); - /* Add cleanup for name. Must be free_current_contents as - name can be reallocated */ + /* Add cleanup for name. Must be free_current_contents as name can + be reallocated. */ old_cleanups = make_cleanup (free_current_contents, &name); /* If we have one single argument it cannot be '-c' or any string - starting with '-'. */ + starting with '-'. */ if (argc == 1) { if (strcmp (name, "-c") == 0) @@ -191,7 +187,7 @@ mi_cmd_var_delete (char *command, char **argv, int argc) } /* If we have 2 arguments they must be '-c' followed by a string - which would be the variable name. */ + which would be the variable name. */ if (argc == 2) { if (strcmp (name, "-c") != 0) @@ -203,7 +199,7 @@ mi_cmd_var_delete (char *command, char **argv, int argc) } /* If we didn't error out, now NAME contains the name of the - variable. */ + variable. */ var = varobj_get_handle (name); @@ -252,18 +248,18 @@ mi_cmd_var_set_format (char *command, char **argv, int argc) if (argc != 2) error (_("-var-set-format: Usage: NAME FORMAT.")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); format = mi_parse_format (argv[1]); - /* Set the format of VAR to given format */ + /* Set the format of VAR to the given format. */ varobj_set_display_format (var, format); - /* Report the new current format */ + /* Report the new current format. */ ui_out_field_string (uiout, "format", varobj_format_string[(int) format]); - /* Report the value in the new format */ + /* Report the value in the new format. */ val = varobj_get_value (var); ui_out_field_string (uiout, "value", val); xfree (val); @@ -305,12 +301,11 @@ mi_cmd_var_set_frozen (char *command, char **argv, int argc) varobj_set_frozen (var, frozen); - /* We don't automatically return the new value, or what varobjs got new - values during unfreezing. If this information is required, client - should call -var-update explicitly. */ + /* We don't automatically return the new value, or what varobjs got + new values during unfreezing. If this information is required, + client should call -var-update explicitly. */ } - void mi_cmd_var_show_format (char *command, char **argv, int argc) { @@ -321,12 +316,12 @@ mi_cmd_var_show_format (char *command, char **argv, int argc) if (argc != 1) error (_("-var-show-format: Usage: NAME.")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); format = varobj_get_display_format (var); - /* Report the current format */ + /* Report the current format. */ ui_out_field_string (uiout, "format", varobj_format_string[(int) format]); } @@ -339,7 +334,7 @@ mi_cmd_var_info_num_children (char *command, char **argv, int argc) if (argc != 1) error (_("-var-info-num-children: Usage: NAME.")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); ui_out_field_int (uiout, "numchild", varobj_get_num_children (var)); @@ -413,7 +408,7 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) error (_("-var-list-children: Usage: " "[PRINT_VALUES] NAME [FROM TO]")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ if (argc == 1 || argc == 3) var = varobj_get_handle (argv[0]); else @@ -479,7 +474,7 @@ mi_cmd_var_info_type (char *command, char **argv, int argc) if (argc != 1) error (_("-var-info-type: Usage: NAME.")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); ui_out_field_string (uiout, "type", varobj_get_type (var)); @@ -513,7 +508,7 @@ mi_cmd_var_info_expression (char *command, char **argv, int argc) if (argc != 1) error (_("-var-info-expression: Usage: NAME.")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); lang = varobj_get_language (var); @@ -558,16 +553,16 @@ mi_cmd_var_evaluate_expression (char *command, char **argv, int argc) char *oarg; enum opt - { - OP_FORMAT - }; - static const struct mi_opt opts[] = { - {"f", OP_FORMAT, 1}, - { 0, 0, 0 } + OP_FORMAT }; + static const struct mi_opt opts[] = + { + {"f", OP_FORMAT, 1}, + { 0, 0, 0 } + }; - /* Parse arguments */ + /* Parse arguments. */ format = FORMAT_NATURAL; formatFound = 0; oind = 0; @@ -579,7 +574,7 @@ mi_cmd_var_evaluate_expression (char *command, char **argv, int argc) if (opt < 0) break; switch ((enum opt) opt) - { + { case OP_FORMAT: if (formatFound) error (_("Cannot specify format more than once")); @@ -587,7 +582,7 @@ mi_cmd_var_evaluate_expression (char *command, char **argv, int argc) format = mi_parse_format (oarg); formatFound = 1; break; - } + } } if (oind >= argc) @@ -596,7 +591,7 @@ mi_cmd_var_evaluate_expression (char *command, char **argv, int argc) if (oind < argc - 1) error (_("Garbage at end of command")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[oind]); if (formatFound) @@ -625,7 +620,7 @@ mi_cmd_var_assign (char *command, char **argv, int argc) if (argc != 2) error (_("-var-assign: Usage: NAME EXPRESSION.")); - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); if (!varobj_editable_p (var)) @@ -672,9 +667,9 @@ mi_cmd_var_update_iter (struct varobj *var, void *data_pointer) thread_stopped = 1; } - if (thread_stopped) - if (!data->only_floating || varobj_floating_p (var)) - varobj_update_one (var, data->print_values, 0 /* implicit */); + if (thread_stopped + && (!data->only_floating || varobj_floating_p (var))) + varobj_update_one (var, data->print_values, 0 /* implicit */); } void @@ -691,7 +686,7 @@ mi_cmd_var_update (char *command, char **argv, int argc) if (argc == 1) name = argv[0]; else - name = (argv[1]); + name = argv[1]; if (argc == 2) print_values = mi_parse_values_option (argv[0]); @@ -703,25 +698,25 @@ mi_cmd_var_update (char *command, char **argv, int argc) else cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist"); - /* Check if the parameter is a "*" which means that we want - to update all variables */ + /* Check if the parameter is a "*", which means that we want to + update all variables. */ if ((*name == '*' || *name == '@') && (*(name + 1) == '\0')) { struct mi_cmd_var_update data; - data.only_floating = *name == '@'; + data.only_floating = (*name == '@'); data.print_values = print_values; - /* varobj_update_one automatically updates all the children of VAROBJ. - Therefore update each VAROBJ only once by iterating only the root - VAROBJs. */ + /* varobj_update_one automatically updates all the children of + VAROBJ. Therefore update each VAROBJ only once by iterating + only the root VAROBJs. */ all_root_varobjs (mi_cmd_var_update_iter, &data); } else { - /* Get varobj handle, if a valid var obj name was specified */ + /* Get varobj handle, if a valid var obj name was specified. */ struct varobj *var = varobj_get_handle (name); varobj_update_one (var, print_values, 1 /* explicit */); @@ -835,6 +830,7 @@ mi_cmd_enable_pretty_printing (char *command, char **argv, int argc) { if (argc != 0) error (_("-enable-pretty-printing: no arguments allowed")); + varobj_enable_pretty_printing (); } diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 81648a7bdc..9152489f5f 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -1,5 +1,4 @@ /* MI Command Set for GDB, the GNU debugger. - Copyright (C) 2000-2001, 2003, 2007-2012 Free Software Foundation, Inc. @@ -26,11 +25,11 @@ #include "gdb_string.h" extern void _initialize_mi_cmds (void); + struct mi_cmd; static struct mi_cmd **lookup_table (const char *command); static void build_table (struct mi_cmd *commands); - struct mi_cmd mi_cmds[] = { { "ada-task-info", { NULL, 0 }, mi_cmd_ada_task_info }, @@ -140,24 +139,25 @@ struct mi_cmd mi_cmds[] = { NULL, } }; -/* Pointer to the mi command table (built at run time) */ +/* Pointer to the mi command table (built at run time). */ static struct mi_cmd **mi_table; -/* A prime large enough to accomodate the entire command table */ +/* A prime large enough to accomodate the entire command table. */ enum { MI_TABLE_SIZE = 227 }; -/* Exported function used to obtain info from the table */ +/* Exported function used to obtain info from the table. */ struct mi_cmd * mi_lookup (const char *command) { return *lookup_table (command); } -/* stat collecting */ +/* Used for collecting hash hit/miss statistics. */ + struct mi_cmd_stats { int hit; @@ -166,20 +166,21 @@ struct mi_cmd_stats }; struct mi_cmd_stats stats; -/* our lookup function */ +/* Look up a command. */ + static struct mi_cmd ** lookup_table (const char *command) { const char *chp; unsigned int index = 0; - /* compute our hash */ + /* Compute our hash. */ for (chp = command; *chp; chp++) { - /* some what arbitrary */ + /* We use a somewhat arbitrary formula. */ index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE; } - /* look it up */ + while (1) { struct mi_cmd **entry = &mi_table[index]; @@ -218,6 +219,7 @@ build_table (struct mi_cmd *commands) _("command `%s' appears to be duplicated"), command->name); *entry = command; + /* FIXME lose these prints */ if (0) { fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n", diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index 309a3cede7..c8465f0021 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -35,7 +35,8 @@ extern const char mi_all_values[]; typedef void (mi_cmd_argv_ftype) (char *command, char **argv, int argc); -/* Function implementing each command */ +/* Declarations of the functions implementing each command. */ + extern mi_cmd_argv_ftype mi_cmd_ada_task_info; extern mi_cmd_argv_ftype mi_cmd_add_inferior; extern mi_cmd_argv_ftype mi_cmd_break_insert; @@ -117,7 +118,7 @@ extern mi_cmd_argv_ftype mi_cmd_var_update; extern mi_cmd_argv_ftype mi_cmd_enable_pretty_printing; extern mi_cmd_argv_ftype mi_cmd_var_set_update_range; -/* Description of a single command. */ +/* Description of a single command. */ struct mi_cli { @@ -129,7 +130,7 @@ struct mi_cli struct mi_cmd { - /* official name of the command. */ + /* Official name of the command. */ const char *name; /* The corresponding CLI command that can be used to implement this MI command (if cli.lhs is non NULL). */ @@ -138,7 +139,7 @@ struct mi_cmd mi_cmd_argv_ftype *argv_func; }; -/* Lookup a command in the mi comand table */ +/* Lookup a command in the MI command table. */ extern struct mi_cmd *mi_lookup (const char *command); diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c index 6b4601b224..102b8bee49 100644 --- a/gdb/mi/mi-console.c +++ b/gdb/mi/mi-console.c @@ -19,12 +19,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +/* An MI console is a kind of ui_file stream that sends output to + stdout, but encapsulated and prefixed with a distinctive string; + for instance, error output is normally identified by a leading + "&". */ + #include "defs.h" #include "mi-console.h" #include "gdb_string.h" -/* MI-console: send output to std-out but correcty encapsulated */ - static ui_file_fputs_ftype mi_console_file_fputs; static ui_file_flush_ftype mi_console_file_flush; static ui_file_delete_ftype mi_console_file_delete; @@ -38,11 +41,15 @@ struct mi_console_file char quote; }; -int mi_console_file_magic; +/* Use the address of this otherwise-unused global as a magic number + identifying this class of ui_file objects. */ +static int mi_console_file_magic; + +/* Create a console that wraps the given output stream RAW with the + string PREFIX and quoting it with QUOTE. */ struct ui_file * -mi_console_file_new (struct ui_file *raw, - const char *prefix, char quote) +mi_console_file_new (struct ui_file *raw, const char *prefix, char quote) { struct ui_file *ui_file = ui_file_new (); struct mi_console_file *mi_console = XMALLOC (struct mi_console_file); @@ -55,6 +62,7 @@ mi_console_file_new (struct ui_file *raw, set_ui_file_fputs (ui_file, mi_console_file_fputs); set_ui_file_flush (ui_file, mi_console_file_flush); set_ui_file_data (ui_file, mi_console, mi_console_file_delete); + return ui_file; } @@ -66,36 +74,36 @@ mi_console_file_delete (struct ui_file *file) if (mi_console->magic != &mi_console_file_magic) internal_error (__FILE__, __LINE__, _("mi_console_file_delete: bad magic number")); + xfree (mi_console); } static void -mi_console_file_fputs (const char *buf, - struct ui_file *file) +mi_console_file_fputs (const char *buf, struct ui_file *file) { struct mi_console_file *mi_console = ui_file_data (file); if (mi_console->magic != &mi_console_file_magic) internal_error (__FILE__, __LINE__, "mi_console_file_fputs: bad magic number"); - /* Append the text to our internal buffer */ + + /* Append the text to our internal buffer. */ fputs_unfiltered (buf, mi_console->buffer); - /* Flush when an embedded \n */ + /* Flush when an embedded newline is present anywhere in the buffer. */ if (strchr (buf, '\n') != NULL) gdb_flush (file); } -/* Transform a byte sequence into a console output packet. */ +/* Transform a byte sequence into a console output packet. */ + static void -mi_console_raw_packet (void *data, - const char *buf, - long length_buf) +mi_console_raw_packet (void *data, const char *buf, long length_buf) { struct mi_console_file *mi_console = data; if (mi_console->magic != &mi_console_file_magic) internal_error (__FILE__, __LINE__, - _("mi_console_file_transform: bad magic number")); + _("mi_console_raw_packet: bad magic number")); if (length_buf > 0) { @@ -124,6 +132,7 @@ mi_console_file_flush (struct ui_file *file) if (mi_console->magic != &mi_console_file_magic) internal_error (__FILE__, __LINE__, _("mi_console_file_flush: bad magic number")); + ui_file_put (mi_console->buffer, mi_console_raw_packet, mi_console); ui_file_rewind (mi_console->buffer); } diff --git a/gdb/mi/mi-getopt.c b/gdb/mi/mi-getopt.c index f836fa7a03..3a7c6a300d 100644 --- a/gdb/mi/mi-getopt.c +++ b/gdb/mi/mi-getopt.c @@ -30,7 +30,7 @@ mi_getopt (const char *prefix, char *arg; const struct mi_opt *opt; - /* We assume that argv/argc are ok. */ + /* We assume that argv/argc are ok. */ if (*oind > argc || *oind < 0) internal_error (__FILE__, __LINE__, _("mi_getopt_long: oind out of bounds")); @@ -44,20 +44,20 @@ mi_getopt (const char *prefix, *oarg = NULL; return -1; } - /* End of option list. */ + /* End of option list. */ if (arg[0] != '-') { *oarg = NULL; return -1; } - /* Look the option up. */ + /* Look the option up. */ for (opt = opts; opt->name != NULL; opt++) { if (strcmp (opt->name, arg + 1) != 0) continue; if (opt->arg_p) { - /* A non-simple oarg option. */ + /* A non-simple oarg option. */ if (argc < *oind + 2) error (_("%s: Option %s requires an argument"), prefix, arg); *oarg = argv[(*oind) + 1]; @@ -80,9 +80,9 @@ mi_valid_noargs (const char *prefix, int argc, char **argv) int oind = 0; char *oarg; static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + { + { 0, 0, 0 } + }; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) == -1) return 1; diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h index ea09b44070..bfb305db3a 100644 --- a/gdb/mi/mi-getopt.h +++ b/gdb/mi/mi-getopt.h @@ -20,6 +20,16 @@ #ifndef MI_GETOPT_H #define MI_GETOPT_H +/* The option list. Terminated by NAME==NULL. ARG_P that the option + requires an argument. INDEX is returned to identify the option. */ + +struct mi_opt + { + const char *name; + int index; + int arg_p; + }; + /* Like getopt() but with simpler semantics. An option has the form ``-''. The special option ``--'' @@ -37,30 +47,16 @@ to specify the non-option argument. OPTARG is set to NULL. mi_getopt() calls ``error("%s: Unknown option %c", prefix, - option)'' if an unknown option is encountered. */ + option)'' if an unknown option is encountered. */ -struct mi_opt; extern int mi_getopt (const char *prefix, int argc, char **argv, const struct mi_opt *opt, int *optind, char **optarg); -/* The option list. Terminated by NAME==NULL. ARG_P that the option - requires an argument. INDEX is returned to identify th option. */ - -struct mi_opt - { - const char *name; - int index; - int arg_p; - }; - -struct mi_opt; - -/* mi_valid_noargs - - Determines if ARGC/ARGV are a valid set of parameters to satisfy - an MI function that is not supposed to recieve any arguments. +/* mi_valid_noargs determines if ARGC/ARGV are a valid set of + parameters to satisfy an MI function that is not supposed to + recieve any arguments. - An MI function that should not recieve arguments can still be + An MI function that should not receive arguments can still be passed parameters after the special option '--' such as below. Example: The MI function -exec-run takes no args. diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index cb22ce220d..cb125494be 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -36,15 +36,18 @@ #include "solist.h" #include "gdb.h" -/* These are the interpreter setup, etc. functions for the MI interpreter */ +/* These are the interpreter setup, etc. functions for the MI + interpreter. */ + static void mi_execute_command_wrapper (char *cmd); static void mi_command_loop (int mi_version); /* These are hooks that we put in place while doing interpreter_exec - so we can report interesting things that happened "behind the mi's - back" in this command */ + so we can report interesting things that happened "behind the MI's + back" in this command. */ + static int mi_interp_query_hook (const char *ctlstr, va_list ap) - ATTRIBUTE_PRINTF (1, 0); + ATTRIBUTE_PRINTF (1, 0); static void mi3_command_loop (void); static void mi2_command_loop (void); @@ -77,14 +80,16 @@ mi_interpreter_init (struct interp *interp, int top_level) const char *name; int mi_version; - /* HACK: We need to force stdout/stderr to point at the console. This avoids - any potential side effects caused by legacy code that is still - using the TUI / fputs_unfiltered_hook. So we set up output channels for - this now, and swap them in when we are run. */ + /* HACK: We need to force stdout/stderr to point at the console. + This avoids any potential side effects caused by legacy code that + is still using the TUI / fputs_unfiltered_hook. So we set up + output channels for this now, and swap them in when we are + run. */ raw_stdout = stdio_fileopen (stdout); - /* Create MI channels */ + /* Create MI console channels, each with a different prefix so they + can be distinguished. */ mi->out = mi_console_file_new (raw_stdout, "~", '"'); mi->err = mi_console_file_new (raw_stdout, "&", '"'); mi->log = mi->err; @@ -124,9 +129,10 @@ mi_interpreter_init (struct interp *interp, int top_level) observer_attach_breakpoint_deleted (mi_breakpoint_deleted); observer_attach_breakpoint_modified (mi_breakpoint_modified); - /* The initial inferior is created before this function is called, so we - need to report it explicitly. Use iteration in case future version - of GDB creates more than one inferior up-front. */ + /* The initial inferior is created before this function is + called, so we need to report it explicitly. Use iteration in + case future version of GDB creates more than one inferior + up-front. */ iterate_over_inferiors (report_initial_inferior, mi); } @@ -138,7 +144,8 @@ mi_interpreter_resume (void *data) { struct mi_interp *mi = data; - /* As per hack note in mi_interpreter_init, swap in the output channels... */ + /* As per hack note in mi_interpreter_init, swap in the output + channels... */ gdb_setup_readline (); /* These overwrite some of the initialization done in @@ -156,12 +163,12 @@ mi_interpreter_resume (void *data) sync_execution = 0; gdb_stdout = mi->out; - /* Route error and log output through the MI */ + /* Route error and log output through the MI. */ gdb_stderr = mi->err; gdb_stdlog = mi->log; - /* Route target output through the MI. */ + /* Route target output through the MI. */ gdb_stdtarg = mi->targ; - /* Route target error through the MI as well. */ + /* Route target error through the MI as well. */ gdb_stdtargerr = mi->targ; /* Replace all the hooks that we know about. There really needs to @@ -170,7 +177,7 @@ mi_interpreter_resume (void *data) deprecated_show_load_progress = mi_load_progress; - /* If we're _the_ interpreter, take control. */ + /* If we're _the_ interpreter, take control. */ if (current_interp_named_p (INTERP_MI1)) deprecated_command_loop_hook = mi1_command_loop; else if (current_interp_named_p (INTERP_MI2)) @@ -200,7 +207,8 @@ mi_interpreter_exec (void *data, const char *command) return exception_none; } -/* Never display the default gdb prompt in mi case. */ +/* Never display the default GDB prompt in MI case. */ + static int mi_interpreter_prompt_p (void *data) { @@ -229,13 +237,14 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc) "does not support command execution"), argv[0]); - /* Insert the MI out hooks, making sure to also call the interpreter's hooks - if it has any. */ - /* KRS: We shouldn't need this... Events should be installed and they should - just ALWAYS fire something out down the MI channel... */ + /* Insert the MI out hooks, making sure to also call the + interpreter's hooks if it has any. */ + /* KRS: We shouldn't need this... Events should be installed and + they should just ALWAYS fire something out down the MI + channel. */ mi_insert_notify_hooks (); - /* Now run the code... */ + /* Now run the code. */ old_chain = make_cleanup (null_cleanup, 0); for (i = 1; i < argc; i++) @@ -257,14 +266,12 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc) do_cleanups (old_chain); } -/* - * mi_insert_notify_hooks - This inserts a number of hooks that are - * meant to produce async-notify ("=") MI messages while running - * commands in another interpreter using mi_interpreter_exec. The - * canonical use for this is to allow access to the gdb CLI - * interpreter from within the MI, while still producing MI style - * output when actions in the CLI command change gdb's state. -*/ +/* This inserts a number of hooks that are meant to produce + async-notify ("=") MI messages while running commands in another + interpreter using mi_interpreter_exec. The canonical use for this + is to allow access to the gdb CLI interpreter from within the MI, + while still producing MI style output when actions in the CLI + command change GDB's state. */ static void mi_insert_notify_hooks (void) @@ -312,11 +319,13 @@ static void mi_command_loop (int mi_version) { /* Turn off 8 bit strings in quoted output. Any character with the - high bit set is printed using C's octal format. */ + high bit set is printed using C's octal format. */ sevenbit_strings = 1; - /* Tell the world that we're alive */ + + /* Tell the world that we're alive. */ fputs_unfiltered ("(gdb) \n", raw_stdout); gdb_flush (raw_stdout); + start_event_loop (); } @@ -420,11 +429,11 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame) if (current_uiout != mi_uiout) { - /* The normal_stop function has printed frame information into - CLI uiout, or some other non-MI uiout. There's no way we - can extract proper fields from random uiout object, so we print - the frame again. In practice, this can only happen when running - a CLI command in MI. */ + /* The normal_stop function has printed frame information + into CLI uiout, or some other non-MI uiout. There's no + way we can extract proper fields from random uiout + object, so we print the frame again. In practice, this + can only happen when running a CLI command in MI. */ struct ui_out *saved_uiout = current_uiout; struct target_waitstatus last; ptid_t last_ptid; @@ -483,9 +492,11 @@ mi_about_to_proceed (void) /* When non-zero, no MI notifications will be emitted in response to breakpoint change observers. */ + int mi_suppress_breakpoint_notifications = 0; /* Emit notification about a created breakpoint. */ + static void mi_breakpoint_created (struct breakpoint *b) { @@ -503,12 +514,12 @@ mi_breakpoint_created (struct breakpoint *b) fprintf_unfiltered (mi->event_channel, "breakpoint-created"); /* We want the output from gdb_breakpoint_query to go to - mi->event_channel. One approach would be to just - call gdb_breakpoint_query, and then use mi_out_put to - send the current content of mi_outout into mi->event_channel. - However, that will break if anything is output to mi_uiout - prior the calling the breakpoint_created notifications. - So, we use ui_out_redirect. */ + mi->event_channel. One approach would be to just call + gdb_breakpoint_query, and then use mi_out_put to send the current + content of mi_outout into mi->event_channel. However, that will + break if anything is output to mi_uiout prior to calling the + breakpoint_created notifications. So, we use + ui_out_redirect. */ ui_out_redirect (mi_uiout, mi->event_channel); TRY_CATCH (e, RETURN_MASK_ERROR) gdb_breakpoint_query (mi_uiout, b->number, NULL); @@ -518,6 +529,7 @@ mi_breakpoint_created (struct breakpoint *b) } /* Emit notification about deleted breakpoint. */ + static void mi_breakpoint_deleted (struct breakpoint *b) { @@ -538,6 +550,7 @@ mi_breakpoint_deleted (struct breakpoint *b) } /* Emit notification about modified breakpoint. */ + static void mi_breakpoint_modified (struct breakpoint *b) { @@ -555,12 +568,12 @@ mi_breakpoint_modified (struct breakpoint *b) fprintf_unfiltered (mi->event_channel, "breakpoint-modified"); /* We want the output from gdb_breakpoint_query to go to - mi->event_channel. One approach would be to just - call gdb_breakpoint_query, and then use mi_out_put to - send the current content of mi_outout into mi->event_channel. - However, that will break if anything is output to mi_uiout - prior the calling the breakpoint_created notifications. - So, we use ui_out_redirect. */ + mi->event_channel. One approach would be to just call + gdb_breakpoint_query, and then use mi_out_put to send the current + content of mi_outout into mi->event_channel. However, that will + break if anything is output to mi_uiout prior to calling the + breakpoint_created notifications. So, we use + ui_out_redirect. */ ui_out_redirect (mi_uiout, mi->event_channel); TRY_CATCH (e, RETURN_MASK_ERROR) gdb_breakpoint_query (mi_uiout, b->number, NULL); @@ -569,7 +582,6 @@ mi_breakpoint_modified (struct breakpoint *b) gdb_flush (mi->event_channel); } - static int mi_output_running_pid (struct thread_info *info, void *arg) { @@ -738,14 +750,14 @@ void _initialize_mi_interp (void) { static const struct interp_procs procs = - { - mi_interpreter_init, /* init_proc */ - mi_interpreter_resume, /* resume_proc */ - mi_interpreter_suspend, /* suspend_proc */ - mi_interpreter_exec, /* exec_proc */ - mi_interpreter_prompt_p, /* prompt_proc_p */ - mi_ui_out /* ui_out_proc */ - }; + { + mi_interpreter_init, /* init_proc */ + mi_interpreter_resume, /* resume_proc */ + mi_interpreter_suspend, /* suspend_proc */ + mi_interpreter_exec, /* exec_proc */ + mi_interpreter_prompt_p, /* prompt_proc_p */ + mi_ui_out /* ui_out_proc */ + }; /* The various interpreter levels. */ interp_add (interp_new (INTERP_MI1, &procs)); diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index cc68c9edca..a03e230806 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -19,8 +19,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Work in progress. */ - #include "defs.h" #include "arch-utils.h" #include "target.h" @@ -71,18 +69,19 @@ enum }; int mi_debug_p; + struct ui_file *raw_stdout; -/* This is used to pass the current command timestamp - down to continuation routines. */ +/* This is used to pass the current command timestamp down to + continuation routines. */ static struct mi_timestamp *current_command_ts; static int do_timings = 0; char *current_token; -/* Few commands would like to know if options like --thread-group - were explicitly specified. This variable keeps the current - parsed command including all option, and make it possible. */ +/* Few commands would like to know if options like --thread-group were + explicitly specified. This variable keeps the current parsed + command including all option, and make it possible. */ static struct mi_parse *current_context; int running_result_record_printed = 1; @@ -178,7 +177,7 @@ void mi_cmd_exec_return (char *command, char **argv, int argc) { /* This command doesn't really execute the target, it just pops the - specified number of frames. */ + specified number of frames. */ if (argc) /* Call return_command with from_tty argument equal to 0 so as to avoid being queried. */ @@ -214,7 +213,6 @@ proceed_thread (struct thread_info *thread, int pid) proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); } - static int proceed_thread_callback (struct thread_info *thread, void *arg) { @@ -229,9 +227,10 @@ exec_continue (char **argv, int argc) { if (non_stop) { - /* In non-stop mode, 'resume' always resumes a single thread. Therefore, - to resume all threads of the current inferior, or all threads in all - inferiors, we need to iterate over threads. + /* In non-stop mode, 'resume' always resumes a single thread. + Therefore, to resume all threads of the current inferior, or + all threads in all inferiors, we need to iterate over + threads. See comment on infcmd.c:proceed_thread_callback for rationale. */ if (current_context->all || current_context->thread_group != -1) @@ -265,9 +264,10 @@ exec_continue (char **argv, int argc) } else { - /* In all-stop mode, -exec-continue traditionally resumed either - all threads, or one thread, depending on the 'scheduler-locking' - variable. Let's continue to do the same. */ + /* In all-stop mode, -exec-continue traditionally resumed + either all threads, or one thread, depending on the + 'scheduler-locking' variable. Let's continue to do the + same. */ continue_1 (1); } do_cleanups (back_to); @@ -322,11 +322,12 @@ interrupt_thread_callback (struct thread_info *thread, void *arg) return 0; } -/* Interrupt the execution of the target. Note how we must play around - with the token variables, in order to display the current token in - the result of the interrupt command, and the previous execution - token when the target finally stops. See comments in +/* Interrupt the execution of the target. Note how we must play + around with the token variables, in order to display the current + token in the result of the interrupt command, and the previous + execution token when the target finally stops. See comments in mi_cmd_execute. */ + void mi_cmd_exec_interrupt (char *command, char **argv, int argc) { @@ -609,8 +610,9 @@ print_one_inferior (struct inferior *inferior, void *xdata) return 0; } -/* Output a field named 'cores' with a list as the value. The elements of - the list are obtained by splitting 'cores' on comma. */ +/* Output a field named 'cores' with a list as the value. The + elements of the list are obtained by splitting 'cores' on + comma. */ static void output_cores (struct ui_out *uiout, const char *field_name, const char *xcores) @@ -797,15 +799,15 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc) VEC (int) *ids = 0; enum opt - { - AVAILABLE_OPT, RECURSE_OPT - }; - static const struct mi_opt opts[] = { - {"-available", AVAILABLE_OPT, 0}, - {"-recurse", RECURSE_OPT, 1}, - { 0, 0, 0 } + AVAILABLE_OPT, RECURSE_OPT }; + static const struct mi_opt opts[] = + { + {"-available", AVAILABLE_OPT, 0}, + {"-recurse", RECURSE_OPT, 1}, + { 0, 0, 0 } + }; int oind = 0; char *oarg; @@ -861,7 +863,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc) } else if (VEC_length (int, ids) == 1) { - /* Local thread groups, single id. */ + /* Local thread groups, single id. */ int id = *VEC_address (int, ids); struct inferior *inf = find_inferior_id (id); @@ -899,10 +901,11 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc) struct cleanup *cleanup; /* Note that the test for a valid register must include checking the - gdbarch_register_name because gdbarch_num_regs may be allocated for - the union of the register sets within a family of related processors. - In this case, some entries of gdbarch_register_name will change depending - upon the particular processor being debugged. */ + gdbarch_register_name because gdbarch_num_regs may be allocated + for the union of the register sets within a family of related + processors. In this case, some entries of gdbarch_register_name + will change depending upon the particular processor being + debugged. */ gdbarch = get_current_arch (); numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); @@ -952,27 +955,30 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc) int i; struct cleanup *cleanup; - /* The last time we visited this function, the current frame's register - contents were saved in THIS_REGS. Move THIS_REGS over to PREV_REGS, - and refresh THIS_REGS with the now-current register contents. */ + /* The last time we visited this function, the current frame's + register contents were saved in THIS_REGS. Move THIS_REGS over + to PREV_REGS, and refresh THIS_REGS with the now-current register + contents. */ prev_regs = this_regs; this_regs = frame_save_as_regcache (get_selected_frame (NULL)); cleanup = make_cleanup_regcache_xfree (prev_regs); /* Note that the test for a valid register must include checking the - gdbarch_register_name because gdbarch_num_regs may be allocated for - the union of the register sets within a family of related processors. - In this case, some entries of gdbarch_register_name will change depending - upon the particular processor being debugged. */ + gdbarch_register_name because gdbarch_num_regs may be allocated + for the union of the register sets within a family of related + processors. In this case, some entries of gdbarch_register_name + will change depending upon the particular processor being + debugged. */ gdbarch = get_regcache_arch (this_regs); numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); make_cleanup_ui_out_list_begin_end (uiout, "changed-registers"); - if (argc == 0) /* No args, just do all the regs. */ + if (argc == 0) { + /* No args, just do all the regs. */ for (regnum = 0; regnum < numregs; regnum++) @@ -1042,11 +1048,13 @@ register_changed_p (int regnum, struct regcache *prev_regs, /* Return a list of register number and value pairs. The valid arguments expected are: a letter indicating the format in which to - display the registers contents. This can be one of: x (hexadecimal), d - (decimal), N (natural), t (binary), o (octal), r (raw). After the - format argumetn there can be a sequence of numbers, indicating which - registers to fetch the content of. If the format is the only argument, - a list of all the registers with their values is returned. */ + display the registers contents. This can be one of: x + (hexadecimal), d (decimal), N (natural), t (binary), o (octal), r + (raw). After the format argument there can be a sequence of + numbers, indicating which registers to fetch the content of. If + the format is the only argument, a list of all the registers with + their values is returned. */ + void mi_cmd_data_list_register_values (char *command, char **argv, int argc) { @@ -1058,10 +1066,11 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc) struct cleanup *list_cleanup, *tuple_cleanup; /* Note that the test for a valid register must include checking the - gdbarch_register_name because gdbarch_num_regs may be allocated for - the union of the register sets within a family of related processors. - In this case, some entries of gdbarch_register_name will change depending - upon the particular processor being debugged. */ + gdbarch_register_name because gdbarch_num_regs may be allocated + for the union of the register sets within a family of related + processors. In this case, some entries of gdbarch_register_name + will change depending upon the particular processor being + debugged. */ if (argc == 0) error (_("-data-list-register-values: Usage: " @@ -1075,8 +1084,9 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc) list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values"); - if (argc == 1) /* No args, beside the format: do all the regs. */ + if (argc == 1) { + /* No args, beside the format: do all the regs. */ for (regnum = 0; regnum < numregs; regnum++) @@ -1113,6 +1123,7 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc) } /* Output one register's contents in the desired format. */ + static void get_register (struct frame_info *frame, int regnum, int format) { @@ -1150,7 +1161,6 @@ get_register (struct frame_info *frame, int regnum, int format) ptr += 2; } ui_out_field_string (uiout, "value", buf); - /*fputs_filtered (buf, gdb_stdout); */ } else { @@ -1180,10 +1190,11 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc) char format; /* Note that the test for a valid register must include checking the - gdbarch_register_name because gdbarch_num_regs may be allocated for - the union of the register sets within a family of related processors. - In this case, some entries of gdbarch_register_name will change depending - upon the particular processor being debugged. */ + gdbarch_register_name because gdbarch_num_regs may be allocated + for the union of the register sets within a family of related + processors. In this case, some entries of gdbarch_register_name + will change depending upon the particular processor being + debugged. */ regcache = get_current_regcache (); gdbarch = get_regcache_arch (regcache); @@ -1229,6 +1240,7 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc) /* Evaluate the value of the argument. The argument is an expression. If the expression contains spaces it needs to be included in double quotes. */ + void mi_cmd_data_evaluate_expression (char *command, char **argv, int argc) { @@ -1265,7 +1277,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc) do_cleanups (old_chain); } -/* DATA-MEMORY-READ: +/* This is the -data-read-memory command. ADDR: start address of data to be dumped. WORD-FORMAT: a char indicating format for the ``word''. See @@ -1282,7 +1294,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc) {addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...} Returns: - The number of bytes read is SIZE*ROW*COL. */ + The number of bytes read is SIZE*ROW*COL. */ void mi_cmd_data_read_memory (char *command, char **argv, int argc) @@ -1291,9 +1303,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); CORE_ADDR addr; - long total_bytes; - long nr_cols; - long nr_rows; + long total_bytes, nr_cols, nr_rows; char word_format; struct type *word_type; long word_size; @@ -1305,14 +1315,14 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) int oind = 0; char *oarg; enum opt - { - OFFSET_OPT - }; - static const struct mi_opt opts[] = { - {"o", OFFSET_OPT, 1}, - { 0, 0, 0 } + OFFSET_OPT }; + static const struct mi_opt opts[] = + { + {"o", OFFSET_OPT, 1}, + { 0, 0, 0 } + }; while (1) { @@ -1340,7 +1350,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) /* Start address of the memory dump. */ addr = parse_and_eval_address (argv[0]) + offset; /* The format character to use when displaying a memory word. See - the ``x'' command. */ + the ``x'' command. */ word_format = argv[1][0]; /* The size of the memory word. */ word_size = atol (argv[2]); @@ -1456,13 +1466,9 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) byte < row_byte + word_size * nr_cols; byte++) { if (byte >= nr_bytes) - { - fputc_unfiltered ('X', stream->stream); - } + fputc_unfiltered ('X', stream->stream); else if (mbuf[byte] < 32 || mbuf[byte] > 126) - { - fputc_unfiltered (aschar, stream->stream); - } + fputc_unfiltered (aschar, stream->stream); else fputc_unfiltered (mbuf[byte], stream->stream); } @@ -1491,14 +1497,14 @@ mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc) int oind = 0; char *oarg; enum opt - { - OFFSET_OPT - }; - static const struct mi_opt opts[] = { - {"o", OFFSET_OPT, 1}, - { 0, 0, 0 } + OFFSET_OPT }; + static const struct mi_opt opts[] = + { + {"o", OFFSET_OPT, 1}, + { 0, 0, 0 } + }; while (1) { @@ -1558,8 +1564,7 @@ mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc) do_cleanups (cleanups); } - -/* DATA-MEMORY-WRITE: +/* Implementation of the -data-write_memory command. COLUMN_OFFSET: optional argument. Must be preceded by '-o'. The offset from the beginning of the memory grid row where the cell to @@ -1575,6 +1580,7 @@ mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc) Writes VALUE into ADDR + (COLUMN_OFFSET * WORD_SIZE). Prints nothing. */ + void mi_cmd_data_write_memory (char *command, char **argv, int argc) { @@ -1592,14 +1598,14 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc) int oind = 0; char *oarg; enum opt - { - OFFSET_OPT - }; - static const struct mi_opt opts[] = { - {"o", OFFSET_OPT, 1}, - { 0, 0, 0 } + OFFSET_OPT }; + static const struct mi_opt opts[] = + { + {"o", OFFSET_OPT, 1}, + { 0, 0, 0 } + }; while (1) { @@ -1628,7 +1634,7 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc) /* The format character to use when displaying a memory word. See the ``x'' command. */ word_format = argv[1][0]; - /* The size of the memory word. */ + /* The size of the memory word. */ word_size = atol (argv[2]); /* Calculate the real address of the write destination. */ @@ -1646,10 +1652,11 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc) do_cleanups (old_chain); } -/* DATA-MEMORY-WRITE-RAW: +/* Implementation of the -data-write-memory-bytes command. ADDR: start address - DATA: string of bytes to write at that address. */ + DATA: string of bytes to write at that address. */ + void mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc) { @@ -1673,7 +1680,7 @@ mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc) { int x; sscanf (cdata + i * 2, "%02x", &x); - data[i] = (gdb_byte)x; + data[i] = (gdb_byte) x; } r = target_write_memory (addr, data, len); @@ -1683,7 +1690,6 @@ mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc) do_cleanups (back_to); } - void mi_cmd_enable_timings (char *command, char **argv, int argc) { @@ -1768,8 +1774,8 @@ mi_cmd_add_inferior (char *command, char **argv, int argc) ui_out_field_fmt (current_uiout, "inferior", "i%d", inf->num); } -/* Callback used to find the first inferior other than the - current one. */ +/* Callback used to find the first inferior other than the current + one. */ static int get_other_inferior (struct inferior *inf, void *arg) @@ -1825,7 +1831,7 @@ mi_cmd_remove_inferior (char *command, char **argv, int argc) args->action will tell mi_execute_command what action to perfrom after the given command has executed (display/suppress - prompt, display error). */ + prompt, display error). */ static void captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) @@ -1849,15 +1855,14 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n", context->token, context->command, context->args); - mi_cmd_execute (context); /* Print the result if there were no errors. Remember that on the way out of executing a command, you have - to directly use the mi_interp's uiout, since the command could - have reset the interpreter, in which case the current uiout - will most likely crash in the mi_out_* routines. */ + to directly use the mi_interp's uiout, since the command + could have reset the interpreter, in which case the current + uiout will most likely crash in the mi_out_* routines. */ if (!running_result_record_printed) { fputs_unfiltered (context->token, raw_stdout); @@ -1871,9 +1876,9 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) fputs_unfiltered ("\n", raw_stdout); } else - /* The command does not want anything to be printed. In that - case, the command probably should not have written anything - to uiout, but in case it has written something, discard it. */ + /* The command does not want anything to be printed. In that + case, the command probably should not have written anything + to uiout, but in case it has written something, discard it. */ mi_out_rewind (uiout); break; @@ -1911,12 +1916,9 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) } break; } - } do_cleanups (cleanup); - - return; } /* Print a gdb exception to the MI output stream. */ @@ -2028,8 +2030,6 @@ mi_execute_command (char *cmd, int from_tty) fputs_unfiltered ("(gdb) \n", raw_stdout); gdb_flush (raw_stdout); - /* Print any buffered hook code. */ - /* ..... */ } static void @@ -2061,9 +2061,10 @@ mi_cmd_execute (struct mi_parse *parse) set_current_inferior (inf); /* This behaviour means that if --thread-group option identifies - an inferior with multiple threads, then a random one will be picked. - This is not a problem -- frontend should always provide --thread if - it wishes to operate on a specific thread. */ + an inferior with multiple threads, then a random one will be + picked. This is not a problem -- frontend should always + provide --thread if it wishes to operate on a specific + thread. */ if (inf->pid != 0) tp = any_thread_of_process (inf->pid); switch_to_thread (tp ? tp->ptid : null_ptid); @@ -2154,7 +2155,7 @@ mi_execute_cli_command (const char *cmd, int args_p, const char *args) fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n", cmd, run); old_cleanups = make_cleanup (xfree, run); - execute_command ( /*ui */ run, 0 /*from_tty */ ); + execute_command (run, 0 /* from_tty */ ); do_cleanups (old_cleanups); return; } @@ -2172,7 +2173,7 @@ mi_execute_async_cli_command (char *cli_command, char **argv, int argc) run = xstrprintf ("%s %s", cli_command, argc ? *argv : ""); old_cleanups = make_cleanup (xfree, run); - execute_command ( /*ui */ run, 0 /*from_tty */ ); + execute_command (run, 0 /* from_tty */ ); /* Do this before doing any printing. It would appear that some print code leaves garbage around in the buffer. */ @@ -2273,61 +2274,61 @@ mi_load_progress (const char *section_name, static void timestamp (struct mi_timestamp *tv) - { - gettimeofday (&tv->wallclock, NULL); +{ + gettimeofday (&tv->wallclock, NULL); #ifdef HAVE_GETRUSAGE - getrusage (RUSAGE_SELF, &rusage); - tv->utime.tv_sec = rusage.ru_utime.tv_sec; - tv->utime.tv_usec = rusage.ru_utime.tv_usec; - tv->stime.tv_sec = rusage.ru_stime.tv_sec; - tv->stime.tv_usec = rusage.ru_stime.tv_usec; + getrusage (RUSAGE_SELF, &rusage); + tv->utime.tv_sec = rusage.ru_utime.tv_sec; + tv->utime.tv_usec = rusage.ru_utime.tv_usec; + tv->stime.tv_sec = rusage.ru_stime.tv_sec; + tv->stime.tv_usec = rusage.ru_stime.tv_usec; #else - { - long usec = get_run_time (); + { + long usec = get_run_time (); - tv->utime.tv_sec = usec/1000000L; - tv->utime.tv_usec = usec - 1000000L*tv->utime.tv_sec; - tv->stime.tv_sec = 0; - tv->stime.tv_usec = 0; - } -#endif + tv->utime.tv_sec = usec/1000000L; + tv->utime.tv_usec = usec - 1000000L*tv->utime.tv_sec; + tv->stime.tv_sec = 0; + tv->stime.tv_usec = 0; } +#endif +} static void print_diff_now (struct mi_timestamp *start) - { - struct mi_timestamp now; +{ + struct mi_timestamp now; - timestamp (&now); - print_diff (start, &now); - } + timestamp (&now); + print_diff (start, &now); +} void mi_print_timing_maybe (void) { - /* If the command is -enable-timing then do_timings may be - true whilst current_command_ts is not initialized. */ + /* If the command is -enable-timing then do_timings may be true + whilst current_command_ts is not initialized. */ if (do_timings && current_command_ts) print_diff_now (current_command_ts); } static long timeval_diff (struct timeval start, struct timeval end) - { - return ((end.tv_sec - start.tv_sec) * 1000000L) - + (end.tv_usec - start.tv_usec); - } +{ + return ((end.tv_sec - start.tv_sec) * 1000000L) + + (end.tv_usec - start.tv_usec); +} static void print_diff (struct mi_timestamp *start, struct mi_timestamp *end) - { - fprintf_unfiltered - (raw_stdout, - ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}", - timeval_diff (start->wallclock, end->wallclock) / 1000000.0, - timeval_diff (start->utime, end->utime) / 1000000.0, - timeval_diff (start->stime, end->stime) / 1000000.0); - } +{ + fprintf_unfiltered + (raw_stdout, + ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}", + timeval_diff (start->wallclock, end->wallclock) / 1000000.0, + timeval_diff (start->utime, end->utime) / 1000000.0, + timeval_diff (start->stime, end->stime) / 1000000.0); +} void mi_cmd_trace_define_variable (char *command, char **argv, int argc) @@ -2371,7 +2372,7 @@ void mi_cmd_trace_list_variables (char *command, char **argv, int argc) { if (argc != 0) - error (_("-trace-list-variables: no arguments are allowed")); + error (_("-trace-list-variables: no arguments allowed")); tvariables_info_1 (); } @@ -2456,9 +2457,7 @@ mi_cmd_trace_find (char *command, char **argv, int argc) error (_("Invalid mode '%s'"), mode); if (has_stack_frames () || get_traceframe_number () >= 0) - { - print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); - } + print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); } void @@ -2486,7 +2485,6 @@ mi_cmd_trace_save (char *command, char **argv, int argc) trace_save (filename, target_saves); } - void mi_cmd_trace_start (char *command, char **argv, int argc) { @@ -2506,7 +2504,7 @@ mi_cmd_trace_stop (char *command, char **argv, int argc) trace_status_mi (1); } -/* Implement the "-ada-task-info" GDB/MI command. */ +/* Implement the "-ada-task-info" command. */ void mi_cmd_ada_task_info (char *command, char **argv, int argc) diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index f8f62257a9..b39e05a3f6 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -100,7 +100,7 @@ static void mi_open (struct ui_out *uiout, const char *name, enum ui_out_type type); static void mi_close (struct ui_out *uiout, enum ui_out_type type); -/* Mark beginning of a table */ +/* Mark beginning of a table. */ void mi_table_begin (struct ui_out *uiout, @@ -109,14 +109,12 @@ mi_table_begin (struct ui_out *uiout, const char *tblid) { mi_open (uiout, tblid, ui_out_type_tuple); - mi_field_int (uiout, -1/*fldno*/, -1/*width*/, -1/*alin*/, - "nr_rows", nr_rows); - mi_field_int (uiout, -1/*fldno*/, -1/*width*/, -1/*alin*/, - "nr_cols", nr_cols); + mi_field_int (uiout, -1, -1, -1, "nr_rows", nr_rows); + mi_field_int (uiout, -1, -1, -1, "nr_cols", nr_cols); mi_open (uiout, "hdr", ui_out_type_list); } -/* Mark beginning of a table body */ +/* Mark beginning of a table body. */ void mi_table_body (struct ui_out *uiout) @@ -130,7 +128,7 @@ mi_table_body (struct ui_out *uiout) mi_open (uiout, "body", ui_out_type_list); } -/* Mark end of a table */ +/* Mark end of a table. */ void mi_table_end (struct ui_out *uiout) @@ -142,17 +140,17 @@ mi_table_end (struct ui_out *uiout) mi_close (uiout, ui_out_type_tuple); } -/* Specify table header */ +/* Specify table header. */ void mi_table_header (struct ui_out *uiout, int width, enum ui_align alignment, - const char *col_name, - const char *colhdr) + const char *col_name, const char *colhdr) { mi_out_data *data = ui_out_data (uiout); if (data->suppress_output) return; + mi_open (uiout, NULL, ui_out_type_tuple); mi_field_int (uiout, 0, 0, 0, "width", width); mi_field_int (uiout, 0, 0, 0, "alignment", alignment); @@ -161,38 +159,36 @@ mi_table_header (struct ui_out *uiout, int width, enum ui_align alignment, mi_close (uiout, ui_out_type_tuple); } -/* Mark beginning of a list */ +/* Mark beginning of a list. */ void -mi_begin (struct ui_out *uiout, - enum ui_out_type type, - int level, +mi_begin (struct ui_out *uiout, enum ui_out_type type, int level, const char *id) { mi_out_data *data = ui_out_data (uiout); if (data->suppress_output) return; + mi_open (uiout, id, type); } -/* Mark end of a list */ +/* Mark end of a list. */ void -mi_end (struct ui_out *uiout, - enum ui_out_type type, - int level) +mi_end (struct ui_out *uiout, enum ui_out_type type, int level) { mi_out_data *data = ui_out_data (uiout); if (data->suppress_output) return; + mi_close (uiout, type); } -/* output an int field */ +/* Output an int field. */ -void +static void mi_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align alignment, const char *fldname, int value) { @@ -206,7 +202,7 @@ mi_field_int (struct ui_out *uiout, int fldno, int width, mi_field_string (uiout, fldno, width, alignment, fldname, buffer); } -/* used to ommit a field */ +/* Used to omit a field. */ void mi_field_skip (struct ui_out *uiout, int fldno, int width, @@ -214,21 +210,18 @@ mi_field_skip (struct ui_out *uiout, int fldno, int width, { } -/* other specific mi_field_* end up here so alignment and field - separators are both handled by mi_field_string */ +/* Other specific mi_field_* end up here so alignment and field + separators are both handled by mi_field_string. */ void -mi_field_string (struct ui_out *uiout, - int fldno, - int width, - enum ui_align align, - const char *fldname, - const char *string) +mi_field_string (struct ui_out *uiout, int fldno, int width, + enum ui_align align, const char *fldname, const char *string) { mi_out_data *data = ui_out_data (uiout); if (data->suppress_output) return; + field_separator (uiout); if (fldname) fprintf_unfiltered (data->buffer, "%s=", fldname); @@ -238,19 +231,18 @@ mi_field_string (struct ui_out *uiout, fprintf_unfiltered (data->buffer, "\""); } -/* This is the only field function that does not align */ +/* This is the only field function that does not align. */ void -mi_field_fmt (struct ui_out *uiout, int fldno, - int width, enum ui_align align, - const char *fldname, - const char *format, - va_list args) +mi_field_fmt (struct ui_out *uiout, int fldno, int width, + enum ui_align align, const char *fldname, + const char *format, va_list args) { mi_out_data *data = ui_out_data (uiout); if (data->suppress_output) return; + field_separator (uiout); if (fldname) fprintf_unfiltered (data->buffer, "%s=\"", fldname); @@ -272,8 +264,7 @@ mi_text (struct ui_out *uiout, const char *string) void mi_message (struct ui_out *uiout, int verbosity, - const char *format, - va_list args) + const char *format, va_list args) { } @@ -326,9 +317,7 @@ field_separator (struct ui_out *uiout) } static void -mi_open (struct ui_out *uiout, - const char *name, - enum ui_out_type type) +mi_open (struct ui_out *uiout, const char *name, enum ui_out_type type) { mi_out_data *data = ui_out_data (uiout); @@ -350,8 +339,7 @@ mi_open (struct ui_out *uiout, } static void -mi_close (struct ui_out *uiout, - enum ui_out_type type) +mi_close (struct ui_out *uiout, enum ui_out_type type) { mi_out_data *data = ui_out_data (uiout); @@ -369,7 +357,7 @@ mi_close (struct ui_out *uiout, data->suppress_field_separator = 0; } -/* add a string to the buffer */ +/* Add a string to the buffer. */ void mi_out_buffered (struct ui_out *uiout, char *string) @@ -379,7 +367,7 @@ mi_out_buffered (struct ui_out *uiout, char *string) fprintf_unfiltered (data->buffer, "%s", string); } -/* clear the buffer */ +/* Clear the buffer. */ void mi_out_rewind (struct ui_out *uiout) @@ -389,7 +377,7 @@ mi_out_rewind (struct ui_out *uiout) ui_file_rewind (data->buffer); } -/* dump the buffer onto the specified stream */ +/* Dump the buffer onto the specified stream. */ static void do_write (void *data, const char *buffer, long length_buffer) @@ -398,8 +386,7 @@ do_write (void *data, const char *buffer, long length_buffer) } void -mi_out_put (struct ui_out *uiout, - struct ui_file *stream) +mi_out_put (struct ui_out *uiout, struct ui_file *stream) { mi_out_data *data = ui_out_data (uiout); @@ -407,7 +394,7 @@ mi_out_put (struct ui_out *uiout, ui_file_rewind (data->buffer); } -/* Current MI version. */ +/* Return the current MI version. */ int mi_version (struct ui_out *uiout) @@ -417,7 +404,7 @@ mi_version (struct ui_out *uiout) return data->mi_version; } -/* initalize private members at startup */ +/* Initialize private members at startup. */ struct ui_out * mi_out_new (int mi_version) @@ -433,10 +420,3 @@ mi_out_new (int mi_version) data->buffer = mem_fileopen (); return ui_out_new (&mi_ui_out_impl, data, flags); } - -/* standard gdb initialization hook */ -void -_initialize_mi_out (void) -{ - /* nothing happens here */ -} diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c index 2fbfc382c1..02700c4eec 100644 --- a/gdb/mi/mi-parse.c +++ b/gdb/mi/mi-parse.c @@ -113,7 +113,7 @@ mi_parse_argv (char *args, struct mi_parse *parse) { char *arg; - /* skip leading white space */ + /* Skip leading white space. */ while (isspace (*chp)) chp++; /* Three possibilities: EOF, quoted string, or other text. */ @@ -125,11 +125,11 @@ mi_parse_argv (char *args, struct mi_parse *parse) return; case '"': { - /* A quoted string. */ + /* A quoted string. */ int len; char *start = chp + 1; - /* Determine the buffer size. */ + /* Determine the buffer size. */ chp = start; len = 0; while (*chp != '\0' && *chp != '"') @@ -139,7 +139,7 @@ mi_parse_argv (char *args, struct mi_parse *parse) chp++; if (mi_parse_escape (&chp) <= 0) { - /* Do not allow split lines or "\000" */ + /* Do not allow split lines or "\000". */ freeargv (argv); return; } @@ -148,21 +148,20 @@ mi_parse_argv (char *args, struct mi_parse *parse) chp++; len++; } - /* Insist on a closing quote. */ + /* Insist on a closing quote. */ if (*chp != '"') { freeargv (argv); return; } - /* Insist on trailing white space. */ + /* Insist on trailing white space. */ if (chp[1] != '\0' && !isspace (chp[1])) { freeargv (argv); return; } - /* create the buffer. */ + /* Create the buffer and copy characters in. */ arg = xmalloc ((len + 1) * sizeof (char)); - /* And copy the characters in. */ chp = start; len = 0; while (*chp != '\0' && *chp != '"') @@ -177,13 +176,13 @@ mi_parse_argv (char *args, struct mi_parse *parse) len++; } arg[len] = '\0'; - chp++; /* that closing quote. */ + chp++; /* That closing quote. */ break; } default: { - /* An unquoted string. Accumulate all non blank - characters into a buffer. */ + /* An unquoted string. Accumulate all non-blank + characters into a buffer. */ int len; char *start = chp; @@ -198,14 +197,13 @@ mi_parse_argv (char *args, struct mi_parse *parse) break; } } - /* Append arg to argv. */ + /* Append arg to argv. */ argv = xrealloc (argv, (argc + 2) * sizeof (char *)); argv[argc++] = arg; argv[argc] = NULL; } } - void mi_parse_free (struct mi_parse *parse) { @@ -245,18 +243,18 @@ mi_parse (char *cmd, char **token) cleanup = make_cleanup (mi_parse_cleanup, parse); - /* Before starting, skip leading white space. */ + /* Before starting, skip leading white space. */ while (isspace (*cmd)) cmd++; - /* Find/skip any token and then extract it. */ + /* Find/skip any token and then extract it. */ for (chp = cmd; *chp >= '0' && *chp <= '9'; chp++) ; *token = xmalloc (chp - cmd + 1); memcpy (*token, cmd, (chp - cmd)); (*token)[chp - cmd] = '\0'; - /* This wasn't a real MI command. Return it as a CLI_COMMAND. */ + /* This wasn't a real MI command. Return it as a CLI_COMMAND. */ if (*chp != '-') { while (isspace (*chp)) @@ -269,7 +267,7 @@ mi_parse (char *cmd, char **token) return parse; } - /* Extract the command. */ + /* Extract the command. */ { char *tmp = chp + 1; /* discard ``-'' */ @@ -280,20 +278,20 @@ mi_parse (char *cmd, char **token) parse->command[chp - tmp] = '\0'; } - /* Find the command in the MI table. */ + /* Find the command in the MI table. */ parse->cmd = mi_lookup (parse->command); if (parse->cmd == NULL) error (_("Undefined MI command: %s"), parse->command); - /* Skip white space following the command. */ + /* Skip white space following the command. */ while (isspace (*chp)) chp++; /* Parse the --thread and --frame options, if present. At present, - some important commands, like '-break-*' are implemented by forwarding - to the CLI layer directly. We want to parse --thread and --frame - here, so as not to leave those option in the string that will be passed - to CLI. */ + some important commands, like '-break-*' are implemented by + forwarding to the CLI layer directly. We want to parse --thread + and --frame here, so as not to leave those option in the string + that will be passed to CLI. */ for (;;) { const char *option; @@ -350,7 +348,7 @@ mi_parse (char *cmd, char **token) } /* For new argv commands, attempt to return the parsed argument - list. */ + list. */ if (parse->cmd->argv_func != NULL) { mi_parse_argv (chp, parse); @@ -366,7 +364,7 @@ mi_parse (char *cmd, char **token) discard_cleanups (cleanup); - /* Fully parsed. */ + /* Fully parsed, flag as an MI command. */ parse->op = MI_COMMAND; return parse; } diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h index 59e57de5a7..9b8e858206 100644 --- a/gdb/mi/mi-parse.h +++ b/gdb/mi/mi-parse.h @@ -62,7 +62,7 @@ struct mi_parse extern struct mi_parse *mi_parse (char *cmd, char **token); -/* Free a command returned by mi_parse_command. */ +/* Free a command returned by mi_parse_command. */ extern void mi_parse_free (struct mi_parse *cmd); diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 7feb02435d..2fdea910a4 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -22,11 +22,9 @@ #include "objfiles.h" #include "ui-out.h" -/* SYMBOL-LIST-LINES: - - Print the list of all pc addresses and lines of code for - the provided (full or base) source file name. The entries - are sorted in ascending PC order. */ +/* Print the list of all pc addresses and lines of code for the + provided (full or base) source file name. The entries are sorted + in ascending PC order. */ void mi_cmd_symbol_list_lines (char *command, char **argv, int argc) @@ -47,9 +45,9 @@ mi_cmd_symbol_list_lines (char *command, char **argv, int argc) if (s == NULL) error (_("-symbol-list-lines: Unknown source file name.")); - /* Now, dump the associated line table. The pc addresses are already - sorted by increasing values in the symbol table, so no need to - perform any other sorting. */ + /* Now, dump the associated line table. The pc addresses are + already sorted by increasing values in the symbol table, so no + need to perform any other sorting. */ gdbarch = get_objfile_arch (s->objfile); cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines"); -- 2.34.1