2000-02-23 01:25:43 +01:00
|
|
|
/* MI Command Set - MI parser.
|
2002-03-19 03:51:09 +01:00
|
|
|
|
2014-01-01 04:54:24 +01:00
|
|
|
Copyright (C) 2000-2014 Free Software Foundation, Inc.
|
2002-03-19 03:51:09 +01:00
|
|
|
|
2000-02-23 07:19:22 +01:00
|
|
|
Contributed by Cygnus Solutions (a Red Hat company).
|
2000-02-23 01:25:43 +01:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2000-02-23 01:25:43 +01:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2000-02-23 01:25:43 +01:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "mi-cmds.h"
|
|
|
|
#include "mi-parse.h"
|
2010-03-05 21:18:19 +01:00
|
|
|
#include "charset.h"
|
2000-02-23 01:25:43 +01:00
|
|
|
|
|
|
|
#include <ctype.h>
|
2013-03-07 22:57:30 +01:00
|
|
|
#include "cli/cli-utils.h"
|
GDB/MI: Add new "--language LANG" command option.
Frontend sometimes need to evaluate expressions that are
language-specific. For instance, Eclipse uses the following
expression to determine the size of an address on the target:
-data-evaluate-expression "sizeof (void*)"
Unfortunately, if the main of the program being debugged is not C,
this may not work. For instance, if the main is in Ada, you get...
-data-evaluate-expression "sizeof (void*)"
^error,msg="No definition of \"sizeof\" in current context."
... and apparently decides to stop the debugging session as a result.
The recommendation sent was to specifically set the language to C
before trying to evaluate the expression. Something such as:
1. save current language
2. set language c
3. -data-evaluate-expression "sizeof (void*)"
4. Restore language
This has the same disadvantages as the ones outlined in the "Context
Management" section of the GDB/MI documentation regarding setting
the current thread or the current frame, thus recommending the use of
general command-line switches such as --frame, or --thread instead.
This patch follows the same steps for the language, adding a similar
new command option: --language LANG. Example of use:
-data-evaluate-expression --language c "sizeof (void*)"
^done,value="4"
gdb/ChangeLog:
* mi/mi-parse.h (struct mi_parse) <language>: New field.
* mi/mi-main.c (mi_cmd_execute): Temporarily set language to
PARSE->LANGUAGE during command execution, if set.
* mi/mi-parse.c: Add "language.h" #include.
(mi_parse): Add parsing of "--language" command option.
* NEWS: Add entry mentioning the new "--language" command option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-language.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Show): Add xref anchor for "show language" command.
(Context management): Place current subsection text into its own
subsubsection. Add new subsubsection describing the "--language"
command option.
2013-11-11 06:21:44 +01:00
|
|
|
#include "language.h"
|
2000-02-23 01:25:43 +01:00
|
|
|
|
add -Wold-style-declaration
This adds -Wold-style-declaration to gdb's list of warnings.
It turns out that a few places use "const static" rather than
"static const". The former is deprecated according to the C standard.
Tested by rebuilding with --enable-targets=all on x86-64 Fedora 18.
* configure.ac (build_warnings): Add -Wold-style-declaration.
* configure: Rebuild.
* dsrec.c (make_srec): Use "static const", not "const static".
* h8300-tdep.c (h8300_breakpoint_from_pc): Use "static const",
not "const static".
* mi/mi-parse.c (mi_no_values, mi_simple_values, mi_all_values):
Use "static const", not "const static".
* mn10300-tdep.c (mn10300_breakpoint_from_pc): Use "static const",
not "const static".
* moxie-tdep.c (moxie_breakpoint_from_pc): Use "static const",
not "const static".
* rs6000-tdep.c (rs6000_breakpoint_from_pc): Use "static const",
not "const static".
* v850-tdep.c (v850_breakpoint_from_pc): Use "static const",
not "const static".
(v850_dbtrap_breakpoint_from_pc): Likewise.
* xstormy16-tdep.c (xstormy16_breakpoint_from_pc): Use "static const",
not "const static".
2013-07-01 21:50:11 +02:00
|
|
|
static const char mi_no_values[] = "--no-values";
|
|
|
|
static const char mi_simple_values[] = "--simple-values";
|
|
|
|
static const char mi_all_values[] = "--all-values";
|
2013-06-03 05:16:24 +02:00
|
|
|
|
2010-03-05 21:18:19 +01:00
|
|
|
/* Like parse_escape, but leave the results as a host char, not a
|
|
|
|
target char. */
|
|
|
|
|
|
|
|
static int
|
2013-03-12 19:50:39 +01:00
|
|
|
mi_parse_escape (const char **string_ptr)
|
2010-03-05 21:18:19 +01:00
|
|
|
{
|
|
|
|
int c = *(*string_ptr)++;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2010-03-05 21:18:19 +01:00
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '\n':
|
|
|
|
return -2;
|
|
|
|
case 0:
|
|
|
|
(*string_ptr)--;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case '0':
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
{
|
|
|
|
int i = host_hex_value (c);
|
|
|
|
int count = 0;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2010-03-05 21:18:19 +01:00
|
|
|
while (++count < 3)
|
|
|
|
{
|
|
|
|
c = (**string_ptr);
|
|
|
|
if (isdigit (c) && c != '8' && c != '9')
|
|
|
|
{
|
|
|
|
(*string_ptr)++;
|
|
|
|
i *= 8;
|
|
|
|
i += host_hex_value (c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'a':
|
|
|
|
c = '\a';
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
c = '\b';
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
c = '\f';
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
c = '\n';
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
c = '\r';
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
c = '\t';
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
c = '\v';
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
static void
|
2013-03-12 19:50:39 +01:00
|
|
|
mi_parse_argv (const char *args, struct mi_parse *parse)
|
2000-02-23 01:25:43 +01:00
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
const char *chp = args;
|
2000-02-23 01:25:43 +01:00
|
|
|
int argc = 0;
|
|
|
|
char **argv = xmalloc ((argc + 1) * sizeof (char *));
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
argv[argc] = NULL;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
char *arg;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Skip leading white space. */
|
2013-03-12 19:50:39 +01:00
|
|
|
chp = skip_spaces_const (chp);
|
2000-02-23 01:25:43 +01:00
|
|
|
/* Three possibilities: EOF, quoted string, or other text. */
|
|
|
|
switch (*chp)
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
parse->argv = argv;
|
|
|
|
parse->argc = argc;
|
|
|
|
return;
|
|
|
|
case '"':
|
|
|
|
{
|
2012-03-06 23:48:53 +01:00
|
|
|
/* A quoted string. */
|
2000-02-23 01:25:43 +01:00
|
|
|
int len;
|
2013-03-12 19:50:39 +01:00
|
|
|
const char *start = chp + 1;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Determine the buffer size. */
|
2000-02-23 01:25:43 +01:00
|
|
|
chp = start;
|
|
|
|
len = 0;
|
|
|
|
while (*chp != '\0' && *chp != '"')
|
|
|
|
{
|
|
|
|
if (*chp == '\\')
|
|
|
|
{
|
|
|
|
chp++;
|
2010-03-05 21:18:19 +01:00
|
|
|
if (mi_parse_escape (&chp) <= 0)
|
2000-02-23 01:25:43 +01:00
|
|
|
{
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Do not allow split lines or "\000". */
|
2000-02-23 01:25:43 +01:00
|
|
|
freeargv (argv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
chp++;
|
|
|
|
len++;
|
|
|
|
}
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Insist on a closing quote. */
|
2000-02-23 01:25:43 +01:00
|
|
|
if (*chp != '"')
|
|
|
|
{
|
|
|
|
freeargv (argv);
|
|
|
|
return;
|
|
|
|
}
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Insist on trailing white space. */
|
2000-02-23 01:25:43 +01:00
|
|
|
if (chp[1] != '\0' && !isspace (chp[1]))
|
|
|
|
{
|
|
|
|
freeargv (argv);
|
|
|
|
return;
|
|
|
|
}
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Create the buffer and copy characters in. */
|
2000-02-23 01:25:43 +01:00
|
|
|
arg = xmalloc ((len + 1) * sizeof (char));
|
|
|
|
chp = start;
|
|
|
|
len = 0;
|
|
|
|
while (*chp != '\0' && *chp != '"')
|
|
|
|
{
|
|
|
|
if (*chp == '\\')
|
|
|
|
{
|
|
|
|
chp++;
|
2010-03-05 21:18:19 +01:00
|
|
|
arg[len] = mi_parse_escape (&chp);
|
2000-02-23 01:25:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
arg[len] = *chp++;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
arg[len] = '\0';
|
2012-03-06 23:48:53 +01:00
|
|
|
chp++; /* That closing quote. */
|
2000-02-23 01:25:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2012-03-06 23:48:53 +01:00
|
|
|
/* An unquoted string. Accumulate all non-blank
|
|
|
|
characters into a buffer. */
|
2000-02-23 01:25:43 +01:00
|
|
|
int len;
|
2013-03-12 19:50:39 +01:00
|
|
|
const char *start = chp;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
while (*chp != '\0' && !isspace (*chp))
|
|
|
|
{
|
|
|
|
chp++;
|
|
|
|
}
|
|
|
|
len = chp - start;
|
|
|
|
arg = xmalloc ((len + 1) * sizeof (char));
|
|
|
|
strncpy (arg, start, len);
|
|
|
|
arg[len] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Append arg to argv. */
|
2000-02-23 01:25:43 +01:00
|
|
|
argv = xrealloc (argv, (argc + 2) * sizeof (char *));
|
|
|
|
argv[argc++] = arg;
|
|
|
|
argv[argc] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mi_parse_free (struct mi_parse *parse)
|
|
|
|
{
|
|
|
|
if (parse == NULL)
|
|
|
|
return;
|
|
|
|
if (parse->command != NULL)
|
2000-12-15 02:01:51 +01:00
|
|
|
xfree (parse->command);
|
2000-02-23 01:25:43 +01:00
|
|
|
if (parse->token != NULL)
|
2000-12-15 02:01:51 +01:00
|
|
|
xfree (parse->token);
|
2000-02-23 01:25:43 +01:00
|
|
|
if (parse->args != NULL)
|
2000-12-15 02:01:51 +01:00
|
|
|
xfree (parse->args);
|
2000-02-23 01:25:43 +01:00
|
|
|
if (parse->argv != NULL)
|
|
|
|
freeargv (parse->argv);
|
2000-12-15 02:01:51 +01:00
|
|
|
xfree (parse);
|
2000-02-23 01:25:43 +01:00
|
|
|
}
|
|
|
|
|
2010-12-09 20:23:49 +01:00
|
|
|
/* A cleanup that calls mi_parse_free. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
mi_parse_cleanup (void *arg)
|
|
|
|
{
|
|
|
|
mi_parse_free (arg);
|
|
|
|
}
|
2000-02-23 01:25:43 +01:00
|
|
|
|
|
|
|
struct mi_parse *
|
2013-03-12 19:50:39 +01:00
|
|
|
mi_parse (const char *cmd, char **token)
|
2000-02-23 01:25:43 +01:00
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
const char *chp;
|
2013-12-28 23:31:23 +01:00
|
|
|
struct mi_parse *parse = XNEW (struct mi_parse);
|
2010-12-09 20:23:49 +01:00
|
|
|
struct cleanup *cleanup;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
memset (parse, 0, sizeof (*parse));
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
parse->all = 0;
|
|
|
|
parse->thread_group = -1;
|
2008-07-12 18:37:57 +02:00
|
|
|
parse->thread = -1;
|
|
|
|
parse->frame = -1;
|
GDB/MI: Add new "--language LANG" command option.
Frontend sometimes need to evaluate expressions that are
language-specific. For instance, Eclipse uses the following
expression to determine the size of an address on the target:
-data-evaluate-expression "sizeof (void*)"
Unfortunately, if the main of the program being debugged is not C,
this may not work. For instance, if the main is in Ada, you get...
-data-evaluate-expression "sizeof (void*)"
^error,msg="No definition of \"sizeof\" in current context."
... and apparently decides to stop the debugging session as a result.
The recommendation sent was to specifically set the language to C
before trying to evaluate the expression. Something such as:
1. save current language
2. set language c
3. -data-evaluate-expression "sizeof (void*)"
4. Restore language
This has the same disadvantages as the ones outlined in the "Context
Management" section of the GDB/MI documentation regarding setting
the current thread or the current frame, thus recommending the use of
general command-line switches such as --frame, or --thread instead.
This patch follows the same steps for the language, adding a similar
new command option: --language LANG. Example of use:
-data-evaluate-expression --language c "sizeof (void*)"
^done,value="4"
gdb/ChangeLog:
* mi/mi-parse.h (struct mi_parse) <language>: New field.
* mi/mi-main.c (mi_cmd_execute): Temporarily set language to
PARSE->LANGUAGE during command execution, if set.
* mi/mi-parse.c: Add "language.h" #include.
(mi_parse): Add parsing of "--language" command option.
* NEWS: Add entry mentioning the new "--language" command option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-language.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Show): Add xref anchor for "show language" command.
(Context management): Place current subsection text into its own
subsubsection. Add new subsubsection describing the "--language"
command option.
2013-11-11 06:21:44 +01:00
|
|
|
parse->language = language_unknown;
|
2000-02-23 01:25:43 +01:00
|
|
|
|
2010-12-09 20:23:49 +01:00
|
|
|
cleanup = make_cleanup (mi_parse_cleanup, parse);
|
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Before starting, skip leading white space. */
|
2013-03-12 19:50:39 +01:00
|
|
|
cmd = skip_spaces_const (cmd);
|
2000-02-23 01:25:43 +01:00
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Find/skip any token and then extract it. */
|
2000-02-23 01:25:43 +01:00
|
|
|
for (chp = cmd; *chp >= '0' && *chp <= '9'; chp++)
|
|
|
|
;
|
2011-04-29 20:44:15 +02:00
|
|
|
*token = xmalloc (chp - cmd + 1);
|
2010-12-09 20:23:49 +01:00
|
|
|
memcpy (*token, cmd, (chp - cmd));
|
|
|
|
(*token)[chp - cmd] = '\0';
|
2000-02-23 01:25:43 +01:00
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* This wasn't a real MI command. Return it as a CLI_COMMAND. */
|
2000-02-23 01:25:43 +01:00
|
|
|
if (*chp != '-')
|
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
chp = skip_spaces_const (chp);
|
2000-02-23 01:25:43 +01:00
|
|
|
parse->command = xstrdup (chp);
|
|
|
|
parse->op = CLI_COMMAND;
|
2010-12-09 20:23:49 +01:00
|
|
|
|
|
|
|
discard_cleanups (cleanup);
|
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
return parse;
|
|
|
|
}
|
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Extract the command. */
|
2000-02-23 01:25:43 +01:00
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
const char *tmp = chp + 1; /* discard ``-'' */
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
for (; *chp && !isspace (*chp); chp++)
|
|
|
|
;
|
2011-04-29 20:44:15 +02:00
|
|
|
parse->command = xmalloc (chp - tmp + 1);
|
2000-02-23 01:25:43 +01:00
|
|
|
memcpy (parse->command, tmp, chp - tmp);
|
|
|
|
parse->command[chp - tmp] = '\0';
|
|
|
|
}
|
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Find the command in the MI table. */
|
2000-02-23 01:25:43 +01:00
|
|
|
parse->cmd = mi_lookup (parse->command);
|
|
|
|
if (parse->cmd == NULL)
|
2013-11-18 13:55:16 +01:00
|
|
|
throw_error (UNDEFINED_COMMAND_ERROR,
|
|
|
|
_("Undefined MI command: %s"), parse->command);
|
2000-02-23 01:25:43 +01:00
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Skip white space following the command. */
|
2013-03-12 19:50:39 +01:00
|
|
|
chp = skip_spaces_const (chp);
|
2000-02-23 01:25:43 +01:00
|
|
|
|
2008-07-12 18:37:57 +02:00
|
|
|
/* Parse the --thread and --frame options, if present. At present,
|
2012-03-06 23:48:53 +01:00
|
|
|
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
|
GDB/MI: Add new "--language LANG" command option.
Frontend sometimes need to evaluate expressions that are
language-specific. For instance, Eclipse uses the following
expression to determine the size of an address on the target:
-data-evaluate-expression "sizeof (void*)"
Unfortunately, if the main of the program being debugged is not C,
this may not work. For instance, if the main is in Ada, you get...
-data-evaluate-expression "sizeof (void*)"
^error,msg="No definition of \"sizeof\" in current context."
... and apparently decides to stop the debugging session as a result.
The recommendation sent was to specifically set the language to C
before trying to evaluate the expression. Something such as:
1. save current language
2. set language c
3. -data-evaluate-expression "sizeof (void*)"
4. Restore language
This has the same disadvantages as the ones outlined in the "Context
Management" section of the GDB/MI documentation regarding setting
the current thread or the current frame, thus recommending the use of
general command-line switches such as --frame, or --thread instead.
This patch follows the same steps for the language, adding a similar
new command option: --language LANG. Example of use:
-data-evaluate-expression --language c "sizeof (void*)"
^done,value="4"
gdb/ChangeLog:
* mi/mi-parse.h (struct mi_parse) <language>: New field.
* mi/mi-main.c (mi_cmd_execute): Temporarily set language to
PARSE->LANGUAGE during command execution, if set.
* mi/mi-parse.c: Add "language.h" #include.
(mi_parse): Add parsing of "--language" command option.
* NEWS: Add entry mentioning the new "--language" command option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-language.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Show): Add xref anchor for "show language" command.
(Context management): Place current subsection text into its own
subsubsection. Add new subsubsection describing the "--language"
command option.
2013-11-11 06:21:44 +01:00
|
|
|
that will be passed to CLI.
|
|
|
|
|
|
|
|
Same for the --language option. */
|
|
|
|
|
2008-07-12 18:37:57 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
2010-12-09 21:41:54 +01:00
|
|
|
const char *option;
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
size_t as = sizeof ("--all ") - 1;
|
|
|
|
size_t tgs = sizeof ("--thread-group ") - 1;
|
2008-07-12 18:37:57 +02:00
|
|
|
size_t ts = sizeof ("--thread ") - 1;
|
|
|
|
size_t fs = sizeof ("--frame ") - 1;
|
GDB/MI: Add new "--language LANG" command option.
Frontend sometimes need to evaluate expressions that are
language-specific. For instance, Eclipse uses the following
expression to determine the size of an address on the target:
-data-evaluate-expression "sizeof (void*)"
Unfortunately, if the main of the program being debugged is not C,
this may not work. For instance, if the main is in Ada, you get...
-data-evaluate-expression "sizeof (void*)"
^error,msg="No definition of \"sizeof\" in current context."
... and apparently decides to stop the debugging session as a result.
The recommendation sent was to specifically set the language to C
before trying to evaluate the expression. Something such as:
1. save current language
2. set language c
3. -data-evaluate-expression "sizeof (void*)"
4. Restore language
This has the same disadvantages as the ones outlined in the "Context
Management" section of the GDB/MI documentation regarding setting
the current thread or the current frame, thus recommending the use of
general command-line switches such as --frame, or --thread instead.
This patch follows the same steps for the language, adding a similar
new command option: --language LANG. Example of use:
-data-evaluate-expression --language c "sizeof (void*)"
^done,value="4"
gdb/ChangeLog:
* mi/mi-parse.h (struct mi_parse) <language>: New field.
* mi/mi-main.c (mi_cmd_execute): Temporarily set language to
PARSE->LANGUAGE during command execution, if set.
* mi/mi-parse.c: Add "language.h" #include.
(mi_parse): Add parsing of "--language" command option.
* NEWS: Add entry mentioning the new "--language" command option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-language.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Show): Add xref anchor for "show language" command.
(Context management): Place current subsection text into its own
subsubsection. Add new subsubsection describing the "--language"
command option.
2013-11-11 06:21:44 +01:00
|
|
|
size_t ls = sizeof ("--language ") - 1;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
if (strncmp (chp, "--all ", as) == 0)
|
|
|
|
{
|
|
|
|
parse->all = 1;
|
|
|
|
chp += as;
|
|
|
|
}
|
|
|
|
/* See if --all is the last token in the input. */
|
|
|
|
if (strcmp (chp, "--all") == 0)
|
|
|
|
{
|
|
|
|
parse->all = 1;
|
|
|
|
chp += strlen (chp);
|
|
|
|
}
|
|
|
|
if (strncmp (chp, "--thread-group ", tgs) == 0)
|
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
char *endp;
|
|
|
|
|
2010-12-09 21:41:54 +01:00
|
|
|
option = "--thread-group";
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
if (parse->thread_group != -1)
|
|
|
|
error (_("Duplicate '--thread-group' option"));
|
|
|
|
chp += tgs;
|
|
|
|
if (*chp != 'i')
|
|
|
|
error (_("Invalid thread group id"));
|
|
|
|
chp += 1;
|
2013-03-12 19:50:39 +01:00
|
|
|
parse->thread_group = strtol (chp, &endp, 10);
|
|
|
|
chp = endp;
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
}
|
2010-12-06 15:16:43 +01:00
|
|
|
else if (strncmp (chp, "--thread ", ts) == 0)
|
2008-07-12 18:37:57 +02:00
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
char *endp;
|
|
|
|
|
2010-12-09 21:41:54 +01:00
|
|
|
option = "--thread";
|
2008-07-12 18:37:57 +02:00
|
|
|
if (parse->thread != -1)
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
error (_("Duplicate '--thread' option"));
|
2008-07-12 18:37:57 +02:00
|
|
|
chp += ts;
|
2013-03-12 19:50:39 +01:00
|
|
|
parse->thread = strtol (chp, &endp, 10);
|
|
|
|
chp = endp;
|
2008-07-12 18:37:57 +02:00
|
|
|
}
|
|
|
|
else if (strncmp (chp, "--frame ", fs) == 0)
|
|
|
|
{
|
2013-03-12 19:50:39 +01:00
|
|
|
char *endp;
|
|
|
|
|
2010-12-09 21:41:54 +01:00
|
|
|
option = "--frame";
|
2008-07-12 18:37:57 +02:00
|
|
|
if (parse->frame != -1)
|
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
2010-02-24 08:51:46 +01:00
|
|
|
error (_("Duplicate '--frame' option"));
|
2008-07-12 18:37:57 +02:00
|
|
|
chp += fs;
|
2013-03-12 19:50:39 +01:00
|
|
|
parse->frame = strtol (chp, &endp, 10);
|
|
|
|
chp = endp;
|
2008-07-12 18:37:57 +02:00
|
|
|
}
|
GDB/MI: Add new "--language LANG" command option.
Frontend sometimes need to evaluate expressions that are
language-specific. For instance, Eclipse uses the following
expression to determine the size of an address on the target:
-data-evaluate-expression "sizeof (void*)"
Unfortunately, if the main of the program being debugged is not C,
this may not work. For instance, if the main is in Ada, you get...
-data-evaluate-expression "sizeof (void*)"
^error,msg="No definition of \"sizeof\" in current context."
... and apparently decides to stop the debugging session as a result.
The recommendation sent was to specifically set the language to C
before trying to evaluate the expression. Something such as:
1. save current language
2. set language c
3. -data-evaluate-expression "sizeof (void*)"
4. Restore language
This has the same disadvantages as the ones outlined in the "Context
Management" section of the GDB/MI documentation regarding setting
the current thread or the current frame, thus recommending the use of
general command-line switches such as --frame, or --thread instead.
This patch follows the same steps for the language, adding a similar
new command option: --language LANG. Example of use:
-data-evaluate-expression --language c "sizeof (void*)"
^done,value="4"
gdb/ChangeLog:
* mi/mi-parse.h (struct mi_parse) <language>: New field.
* mi/mi-main.c (mi_cmd_execute): Temporarily set language to
PARSE->LANGUAGE during command execution, if set.
* mi/mi-parse.c: Add "language.h" #include.
(mi_parse): Add parsing of "--language" command option.
* NEWS: Add entry mentioning the new "--language" command option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-language.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Show): Add xref anchor for "show language" command.
(Context management): Place current subsection text into its own
subsubsection. Add new subsubsection describing the "--language"
command option.
2013-11-11 06:21:44 +01:00
|
|
|
else if (strncmp (chp, "--language ", ls) == 0)
|
|
|
|
{
|
|
|
|
char *lang_name;
|
|
|
|
struct cleanup *old_chain;
|
|
|
|
|
|
|
|
option = "--language";
|
|
|
|
chp += ls;
|
|
|
|
lang_name = extract_arg_const (&chp);
|
|
|
|
old_chain = make_cleanup (xfree, lang_name);
|
|
|
|
|
|
|
|
parse->language = language_enum (lang_name);
|
|
|
|
if (parse->language == language_unknown
|
|
|
|
|| parse->language == language_auto)
|
|
|
|
error (_("Invalid --language argument: %s"), lang_name);
|
|
|
|
|
|
|
|
do_cleanups (old_chain);
|
|
|
|
}
|
2008-07-12 18:37:57 +02:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (*chp != '\0' && !isspace (*chp))
|
2010-12-09 21:41:54 +01:00
|
|
|
error (_("Invalid value for the '%s' option"), option);
|
2013-03-12 19:50:39 +01:00
|
|
|
chp = skip_spaces_const (chp);
|
2008-07-12 18:37:57 +02:00
|
|
|
}
|
|
|
|
|
2000-02-23 01:25:43 +01:00
|
|
|
/* For new argv commands, attempt to return the parsed argument
|
2012-03-06 23:48:53 +01:00
|
|
|
list. */
|
2000-02-23 01:25:43 +01:00
|
|
|
if (parse->cmd->argv_func != NULL)
|
|
|
|
{
|
|
|
|
mi_parse_argv (chp, parse);
|
|
|
|
if (parse->argv == NULL)
|
2010-12-09 20:23:49 +01:00
|
|
|
error (_("Problem parsing arguments: %s %s"), parse->command, chp);
|
2000-02-23 01:25:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: DELETE THIS */
|
2008-04-24 15:28:06 +02:00
|
|
|
/* For CLI commands, also return the remainder of the
|
2000-02-23 01:25:43 +01:00
|
|
|
command line as a single string. */
|
2008-04-24 15:28:06 +02:00
|
|
|
if (parse->cmd->cli.cmd != NULL)
|
|
|
|
parse->args = xstrdup (chp);
|
2000-02-23 01:25:43 +01:00
|
|
|
|
2010-12-09 20:23:49 +01:00
|
|
|
discard_cleanups (cleanup);
|
|
|
|
|
2012-03-06 23:48:53 +01:00
|
|
|
/* Fully parsed, flag as an MI command. */
|
2000-02-23 01:25:43 +01:00
|
|
|
parse->op = MI_COMMAND;
|
|
|
|
return parse;
|
|
|
|
}
|
2013-06-03 05:16:24 +02:00
|
|
|
|
|
|
|
enum print_values
|
|
|
|
mi_parse_print_values (const char *name)
|
|
|
|
{
|
|
|
|
if (strcmp (name, "0") == 0
|
|
|
|
|| strcmp (name, mi_no_values) == 0)
|
|
|
|
return PRINT_NO_VALUES;
|
|
|
|
else if (strcmp (name, "1") == 0
|
|
|
|
|| strcmp (name, mi_all_values) == 0)
|
|
|
|
return PRINT_ALL_VALUES;
|
|
|
|
else if (strcmp (name, "2") == 0
|
|
|
|
|| strcmp (name, mi_simple_values) == 0)
|
|
|
|
return PRINT_SIMPLE_VALUES;
|
|
|
|
else
|
|
|
|
error (_("Unknown value for PRINT_VALUES: must be: \
|
|
|
|
0 or \"%s\", 1 or \"%s\", 2 or \"%s\""),
|
|
|
|
mi_no_values, mi_all_values, mi_simple_values);
|
|
|
|
}
|