summaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c150
1 files changed, 65 insertions, 85 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 2f7d58061ab..d6c5cea3ddb 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -41,7 +41,7 @@
#include "language.h"
#include "parser-defs.h"
#include "gdbcmd.h"
-#include "symfile.h" /* for overlay functions */
+#include "symfile.h" /* for overlay functions */
#include "inferior.h"
#include "target-float.h"
#include "block.h"
@@ -53,14 +53,14 @@
#include "c-exp.h"
static unsigned int expressiondebug = 0;
+
static void
show_expressiondebug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Expression debugging is %s.\n"), value);
+ gdb_printf (file, _ ("Expression debugging is %s.\n"), value);
}
-
/* True if an expression parser should set yydebug. */
bool parser_debug;
@@ -68,15 +68,13 @@ static void
show_parserdebug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Parser debugging is %s.\n"), value);
+ gdb_printf (file, _ ("Parser debugging is %s.\n"), value);
}
-
-static expression_up parse_exp_in_context
- (const char **, CORE_ADDR,
- const struct block *, int,
- bool, innermost_block_tracker *,
- std::unique_ptr<expr_completion_base> *);
+static expression_up
+parse_exp_in_context (const char **, CORE_ADDR, const struct block *, int,
+ bool, innermost_block_tracker *,
+ std::unique_ptr<expr_completion_base> *);
/* Documented at it's declaration. */
@@ -85,28 +83,24 @@ innermost_block_tracker::update (const struct block *b,
innermost_block_tracker_types t)
{
if ((m_types & t) != 0
- && (m_innermost_block == NULL
- || contained_in (b, m_innermost_block)))
+ && (m_innermost_block == NULL || contained_in (b, m_innermost_block)))
m_innermost_block = b;
}
-
-
/* Return the type of MSYMBOL, a minimal symbol of OBJFILE. If
ADDRESS_P is not NULL, set it to the MSYMBOL's resolved
address. */
type *
-find_minsym_type_and_address (minimal_symbol *msymbol,
- struct objfile *objfile,
+find_minsym_type_and_address (minimal_symbol *msymbol, struct objfile *objfile,
CORE_ADDR *address_p)
{
- bound_minimal_symbol bound_msym = {msymbol, objfile};
+ bound_minimal_symbol bound_msym = { msymbol, objfile };
struct obj_section *section = msymbol->obj_section (objfile);
enum minimal_symbol_type type = msymbol->type ();
- bool is_tls = (section != NULL
- && section->the_bfd_section->flags & SEC_THREAD_LOCAL);
+ bool is_tls
+ = (section != NULL && section->the_bfd_section->flags & SEC_THREAD_LOCAL);
/* The minimal symbol might point to a function descriptor;
resolve it to the actual code address instead. */
@@ -199,11 +193,10 @@ parser_state::mark_completion_tag (enum type_code tag, const char *ptr,
int length)
{
gdb_assert (parse_completion && m_completion_state == nullptr);
- gdb_assert (tag == TYPE_CODE_UNION
- || tag == TYPE_CODE_STRUCT
+ gdb_assert (tag == TYPE_CODE_UNION || tag == TYPE_CODE_STRUCT
|| tag == TYPE_CODE_ENUM);
- m_completion_state.reset
- (new expr_complete_tag (tag, make_unique_xstrndup (ptr, length)));
+ m_completion_state.reset (
+ new expr_complete_tag (tag, make_unique_xstrndup (ptr, length)));
}
/* See parser-defs.h. */
@@ -236,9 +229,9 @@ parser_state::push_symbol (const char *name, block_symbol sym)
if (msymbol.minsym != NULL)
push_new<expr::var_msym_value_operation> (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
- error (_("No symbol table is loaded. Use the \"file\" command."));
+ error (_ ("No symbol table is loaded. Use the \"file\" command."));
else
- error (_("No symbol \"%s\" in current context."), name);
+ error (_ ("No symbol \"%s\" in current context."), name);
}
}
@@ -284,8 +277,7 @@ parser_state::push_dollar (struct stoken str)
/* Handle tokens that refer to machine registers:
$ followed by a register name. */
- i = user_reg_map_name_to_regnum (gdbarch (),
- str.ptr + 1, str.length - 1);
+ i = user_reg_map_name_to_regnum (gdbarch (), str.ptr + 1, str.length - 1);
if (i >= 0)
goto handle_register;
@@ -317,8 +309,8 @@ parser_state::push_dollar (struct stoken str)
/* Any other names are assumed to be debugger internal variables. */
- push_new<expr::internalvar_operation>
- (create_internalvar (copy.c_str () + 1));
+ push_new<expr::internalvar_operation> (create_internalvar (copy.c_str ()
+ + 1));
return;
handle_last:
push_new<expr::last_operation> (i);
@@ -332,8 +324,6 @@ handle_register:
return;
}
-
-
const char *
find_template_name_end (const char *p)
{
@@ -356,32 +346,31 @@ find_template_name_end (const char *p)
/* In future, may want to allow these?? */
return 0;
case '<':
- depth++; /* start nested template */
+ depth++; /* start nested template */
if (just_seen_colon || just_seen_right || just_seen_space)
- return 0; /* but not after : or :: or > or space */
+ return 0; /* but not after : or :: or > or space */
break;
case '>':
if (just_seen_colon || just_seen_right)
- return 0; /* end a (nested?) template */
- just_seen_right = 1; /* but not after : or :: */
- if (--depth == 0) /* also disallow >>, insist on > > */
- return ++p; /* if outermost ended, return */
+ return 0; /* end a (nested?) template */
+ just_seen_right = 1; /* but not after : or :: */
+ if (--depth == 0) /* also disallow >>, insist on > > */
+ return ++p; /* if outermost ended, return */
break;
case ':':
if (just_seen_space || (just_seen_colon > 1))
- return 0; /* nested class spec coming up */
- just_seen_colon++; /* we allow :: but not :::: */
+ return 0; /* nested class spec coming up */
+ just_seen_colon++; /* we allow :: but not :::: */
break;
case ' ':
break;
default:
- if (!((*p >= 'a' && *p <= 'z') || /* allow token chars */
- (*p >= 'A' && *p <= 'Z') ||
- (*p >= '0' && *p <= '9') ||
- (*p == '_') || (*p == ',') || /* commas for template args */
- (*p == '&') || (*p == '*') || /* pointer and ref types */
- (*p == '(') || (*p == ')') || /* function types */
- (*p == '[') || (*p == ']'))) /* array types */
+ if (!((*p >= 'a' && *p <= 'z') || /* allow token chars */
+ (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9')
+ || (*p == '_') || (*p == ',') || /* commas for template args */
+ (*p == '&') || (*p == '*') || /* pointer and ref types */
+ (*p == '(') || (*p == ')') || /* function types */
+ (*p == '[') || (*p == ']'))) /* array types */
return 0;
}
if (*p != ' ')
@@ -393,7 +382,6 @@ find_template_name_end (const char *p)
}
return 0;
}
-
/* Return a null-terminated temporary copy of the name of a string token.
@@ -408,7 +396,6 @@ copy_name (struct stoken token)
{
return std::string (token.ptr, token.length);
}
-
/* Read an expression from the string *STRINGPTR points to,
parse it, and return a pointer to a struct expression that we malloc.
@@ -424,8 +411,8 @@ expression_up
parse_exp_1 (const char **stringptr, CORE_ADDR pc, const struct block *block,
int comma, innermost_block_tracker *tracker)
{
- return parse_exp_in_context (stringptr, pc, block, comma, false,
- tracker, nullptr);
+ return parse_exp_in_context (stringptr, pc, block, comma, false, tracker,
+ nullptr);
}
/* As for parse_exp_1, except that if VOID_CONTEXT_P, then
@@ -433,15 +420,14 @@ parse_exp_1 (const char **stringptr, CORE_ADDR pc, const struct block *block,
static expression_up
parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
- const struct block *block,
- int comma, bool void_context_p,
- innermost_block_tracker *tracker,
+ const struct block *block, int comma,
+ bool void_context_p, innermost_block_tracker *tracker,
std::unique_ptr<expr_completion_base> *completer)
{
const struct language_defn *lang = NULL;
if (*stringptr == 0 || **stringptr == 0)
- error_no_arg (_("expression to compute"));
+ error_no_arg (_ ("expression to compute"));
const struct block *expression_context_block = block;
CORE_ADDR expression_context_pc = 0;
@@ -519,7 +505,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
/* If parsing for completion, allow this to succeed; but if no
expression elements have been written, then there's nothing
to do, so fail. */
- if (! ps.parse_completion || ps.expout->op == nullptr)
+ if (!ps.parse_completion || ps.expout->op == nullptr)
throw;
}
@@ -547,10 +533,9 @@ parse_expression (const char *string, innermost_block_tracker *tracker,
bool void_context_p)
{
expression_up exp = parse_exp_in_context (&string, 0, nullptr, 0,
- void_context_p,
- tracker, nullptr);
+ void_context_p, tracker, nullptr);
if (*string)
- error (_("Junk after end of expression."));
+ error (_ ("Junk after end of expression."));
return exp;
}
@@ -575,9 +560,8 @@ parse_expression_with_language (const char *string, enum language lang)
cases, return NULL. */
expression_up
-parse_expression_for_completion
- (const char *string,
- std::unique_ptr<expr_completion_base> *completer)
+parse_expression_for_completion (
+ const char *string, std::unique_ptr<expr_completion_base> *completer)
{
expression_up exp;
@@ -606,8 +590,7 @@ parse_expression_for_completion
NOTE: This accepts the floating point syntax that sscanf accepts. */
bool
-parse_float (const char *p, int len,
- const struct type *type, gdb_byte *data)
+parse_float (const char *p, int len, const struct type *type, gdb_byte *data)
{
return target_float_from_string (data, type, std::string (p, len));
}
@@ -629,7 +612,7 @@ fits_in_type (int n_sign, ULONGEST n, int type_bits, bool type_signed_p)
if (type_bits > sizeof (ULONGEST) * 8)
return true;
- ULONGEST smax = (ULONGEST)1 << (type_bits - 1);
+ ULONGEST smax = (ULONGEST) 1 << (type_bits - 1);
if (n_sign == -1)
{
/* Negative number, signed type. */
@@ -648,17 +631,17 @@ fits_in_type (int n_sign, ULONGEST n, int type_bits, bool type_signed_p)
else
gdb_assert_not_reached ("");
}
-
+
/* This function avoids direct calls to fprintf
in the parser generated debug code. */
void
parser_fprintf (FILE *x, const char *y, ...)
-{
+{
va_list args;
va_start (args, y);
if (x == stderr)
- gdb_vprintf (gdb_stderr, y, args);
+ gdb_vprintf (gdb_stderr, y, args);
else
{
gdb_printf (gdb_stderr, " Unknown FILE used.\n");
@@ -668,25 +651,22 @@ parser_fprintf (FILE *x, const char *y, ...)
}
void _initialize_parse ();
+
void
_initialize_parse ()
{
- add_setshow_zuinteger_cmd ("expression", class_maintenance,
- &expressiondebug,
- _("Set expression debugging."),
- _("Show expression debugging."),
- _("When non-zero, the internal representation "
- "of expressions will be printed."),
- NULL,
- show_expressiondebug,
- &setdebuglist, &showdebuglist);
- add_setshow_boolean_cmd ("parser", class_maintenance,
- &parser_debug,
- _("Set parser debugging."),
- _("Show parser debugging."),
- _("When non-zero, expression parser "
- "tracing will be enabled."),
- NULL,
- show_parserdebug,
- &setdebuglist, &showdebuglist);
+ add_setshow_zuinteger_cmd ("expression", class_maintenance, &expressiondebug,
+ _ ("Set expression debugging."),
+ _ ("Show expression debugging."),
+ _ ("When non-zero, the internal representation "
+ "of expressions will be printed."),
+ NULL, show_expressiondebug, &setdebuglist,
+ &showdebuglist);
+ add_setshow_boolean_cmd ("parser", class_maintenance, &parser_debug,
+ _ ("Set parser debugging."),
+ _ ("Show parser debugging."),
+ _ ("When non-zero, expression parser "
+ "tracing will be enabled."),
+ NULL, show_parserdebug, &setdebuglist,
+ &showdebuglist);
}