2010-04-01 Stan Shebs <stan@codesourcery.com>

Nathan Sidwell  <nathan@codesourcery.com>

	* tracepoint.h (enum actionline_type): Remove.
	(validate_actionline): Change return to void.
	* tracepoint.c (report_agent_reqs_errors): New function.
	(validate_actionline): Call it, change return to void, report errors
	more consistently.
	(collect_symbol): Call report_agent_reqs_errors.
	(encode_actions_1): Ditto.
	(encode_actions): Don't expect a result from validate_actionline.

	* gdb.trace/actions.exp: Tweak expected output.
	* gdb.trace/while-stepping.exp: Tweak expected output.
This commit is contained in:
Stan Shebs 2010-04-01 22:57:25 +00:00
parent 615bcdefbf
commit fff87407d4
6 changed files with 86 additions and 83 deletions

View File

@ -1,3 +1,15 @@
2010-04-01 Stan Shebs <stan@codesourcery.com>
Nathan Sidwell <nathan@codesourcery.com>
* tracepoint.h (enum actionline_type): Remove.
(validate_actionline): Change return to void.
* tracepoint.c (report_agent_reqs_errors): New function.
(validate_actionline): Call it, change return to void, report errors
more consistently.
(collect_symbol): Call report_agent_reqs_errors.
(encode_actions_1): Ditto.
(encode_actions): Don't expect a result from validate_actionline.
2010-04-01 Stan Shebs <stan@codesourcery.com>
* tracepoint.c (trace_start_command): Confirm if trace is running.

View File

@ -1,3 +1,8 @@
2010-04-01 Stan Shebs <stan@codesourcery.com>
* gdb.trace/actions.exp: Tweak expected output.
* gdb.trace/while-stepping.exp: Tweak expected output.
2010-04-01 H.J. Lu <hongjiu.lu@intel.com>
* gdb.arch/amd64-byte.exp: Check "ah", "bh", "ch", "dh".

View File

@ -175,7 +175,7 @@ gdb_test "actions [expr $trcpt2 + $trcpt3]" \
gdb_trace_setactions "5.7: invalid action" \
"$trcpt1" \
"print gdb_c_test" \
"'print gdb_c_test' is not a supported tracepoint action"
"`print gdb_c_test' is not a supported tracepoint action"
# 5.8 help actions (collect, while-stepping, end)

View File

@ -82,7 +82,7 @@ proc while_stepping_bogus_arg { bogus msgstring } {
gdb_trace_setactions "$msgstring" \
"" \
"while-stepping $bogus" ".*bad step-count"
"while-stepping $bogus" ".*while-stepping step count"
}
# 5.14 while-stepping (no argument)

View File

@ -554,8 +554,35 @@ trace_actions_command (char *args, int from_tty)
/* else just return */
}
/* Report the results of checking the agent expression, as errors or
internal errors. */
static void
report_agent_reqs_errors (struct agent_expr *aexpr, struct agent_reqs *areqs)
{
/* All of the "flaws" are serious bytecode generation issues that
should never occur. */
if (areqs->flaw != agent_flaw_none)
internal_error (__FILE__, __LINE__, _("expression is malformed"));
/* If analysis shows a stack underflow, GDB must have done something
badly wrong in its bytecode generation. */
if (areqs->min_height < 0)
internal_error (__FILE__, __LINE__,
_("expression has min height < 0"));
/* Issue this error if the stack is predicted to get too deep. The
limit is rather arbitrary; a better scheme might be for the
target to report how much stack it will have available. The
depth roughly corresponds to parenthesization, so a limit of 20
amounts to 20 levels of expression nesting, which is actually
a pretty big hairy expression. */
if (areqs->max_height > 20)
error (_("Expression is too complicated."));
}
/* worker function */
enum actionline_type
void
validate_actionline (char **line, struct breakpoint *t)
{
struct cmd_list_element *c;
@ -563,34 +590,29 @@ validate_actionline (char **line, struct breakpoint *t)
struct cleanup *old_chain = NULL;
char *p, *tmp_p;
struct bp_location *loc;
struct agent_expr *aexpr;
struct agent_reqs areqs;
/* if EOF is typed, *line is NULL */
if (*line == NULL)
return END;
return;
for (p = *line; isspace ((int) *p);)
p++;
/* Symbol lookup etc. */
if (*p == '\0') /* empty line: just prompt for another line. */
return BADLINE;
return;
if (*p == '#') /* comment line */
return GENERIC;
return;
c = lookup_cmd (&p, cmdlist, "", -1, 1);
if (c == 0)
{
warning (_("'%s' is not an action that I know, or is ambiguous."),
p);
return BADLINE;
}
error (_("`%s' is not a tracepoint action, or is ambiguous."), p);
if (cmd_cfunc_eq (c, collect_pseudocommand))
{
struct agent_expr *aexpr;
struct agent_reqs areqs;
do
{ /* repeat over a comma-separated list */
QUIT; /* allow user to bail out with ^C */
@ -619,16 +641,14 @@ validate_actionline (char **line, struct breakpoint *t)
{
if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
{
warning (_("constant %s (value %ld) will not be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol),
SYMBOL_VALUE (exp->elts[2].symbol));
return BADLINE;
error (_("constant `%s' (value %ld) will not be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol),
SYMBOL_VALUE (exp->elts[2].symbol));
}
else if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_OPTIMIZED_OUT)
{
warning (_("%s is optimized away and cannot be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol));
return BADLINE;
error (_("`%s' is optimized away and cannot be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol));
}
}
@ -639,30 +659,21 @@ validate_actionline (char **line, struct breakpoint *t)
make_cleanup_free_agent_expr (aexpr);
if (aexpr->len > MAX_AGENT_EXPR_LEN)
error (_("expression too complicated, try simplifying"));
error (_("Expression is too complicated."));
ax_reqs (aexpr, &areqs);
(void) make_cleanup (xfree, areqs.reg_mask);
if (areqs.flaw != agent_flaw_none)
error (_("malformed expression"));
if (areqs.min_height < 0)
error (_("gdb: Internal error: expression has min height < 0"));
if (areqs.max_height > 20)
error (_("expression too complicated, try simplifying"));
report_agent_reqs_errors (aexpr, &areqs);
do_cleanups (old_chain);
}
}
while (p && *p++ == ',');
return GENERIC;
}
else if (cmd_cfunc_eq (c, teval_pseudocommand))
{
struct agent_expr *aexpr;
do
{ /* repeat over a comma-separated list */
QUIT; /* allow user to bail out with ^C */
@ -684,14 +695,19 @@ validate_actionline (char **line, struct breakpoint *t)
make_cleanup_free_agent_expr (aexpr);
if (aexpr->len > MAX_AGENT_EXPR_LEN)
error (_("expression too complicated, try simplifying"));
error (_("Expression is too complicated."));
ax_reqs (aexpr, &areqs);
(void) make_cleanup (xfree, areqs.reg_mask);
report_agent_reqs_errors (aexpr, &areqs);
do_cleanups (old_chain);
}
}
while (p && *p++ == ',');
return GENERIC;
}
else if (cmd_cfunc_eq (c, while_stepping_pseudocommand))
{
char *steparg; /* in case warning is necessary */
@ -700,19 +716,15 @@ validate_actionline (char **line, struct breakpoint *t)
p++;
steparg = p;
if (*p == '\0' ||
(t->step_count = strtol (p, &p, 0)) == 0)
{
error (_("'%s': bad step-count."), *line);
}
return STEPPING;
if (*p == '\0' || (t->step_count = strtol (p, &p, 0)) == 0)
error (_("while-stepping step count `%s' is malformed."), *line);
}
else if (cmd_cfunc_eq (c, end_actions_pseudocommand))
return END;
;
else
{
error (_("'%s' is not a supported tracepoint action."), *line);
}
error (_("`%s' is not a supported tracepoint action."), *line);
}
enum {
@ -977,13 +989,8 @@ collect_symbol (struct collection_list *collect,
old_chain1 = make_cleanup_free_agent_expr (aexpr);
ax_reqs (aexpr, &areqs);
if (areqs.flaw != agent_flaw_none)
error (_("malformed expression"));
if (areqs.min_height < 0)
error (_("gdb: Internal error: expression has min height < 0"));
if (areqs.max_height > 20)
error (_("expression too complicated, try simplifying"));
report_agent_reqs_errors (aexpr, &areqs);
discard_cleanups (old_chain1);
add_aexpr (collect, aexpr);
@ -1325,13 +1332,8 @@ encode_actions_1 (struct command_line *action,
old_chain1 = make_cleanup_free_agent_expr (aexpr);
ax_reqs (aexpr, &areqs);
if (areqs.flaw != agent_flaw_none)
error (_("malformed expression"));
if (areqs.min_height < 0)
error (_("gdb: Internal error: expression has min height < 0"));
if (areqs.max_height > 20)
error (_("expression too complicated, try simplifying"));
report_agent_reqs_errors (aexpr, &areqs);
discard_cleanups (old_chain1);
add_aexpr (collect, aexpr);
@ -1385,13 +1387,8 @@ encode_actions_1 (struct command_line *action,
old_chain1 = make_cleanup_free_agent_expr (aexpr);
ax_reqs (aexpr, &areqs);
if (areqs.flaw != agent_flaw_none)
error (_("malformed expression"));
if (areqs.min_height < 0)
error (_("gdb: Internal error: expression has min height < 0"));
if (areqs.max_height > 20)
error (_("expression too complicated, try simplifying"));
report_agent_reqs_errors (aexpr, &areqs);
discard_cleanups (old_chain1);
/* Even though we're not officially collecting, add
@ -1452,21 +1449,18 @@ encode_actions (struct breakpoint *t, struct bp_location *tloc,
if (*default_collect)
{
char *line;
enum actionline_type linetype;
default_collect_line = xstrprintf ("collect %s", default_collect);
make_cleanup (xfree, default_collect_line);
line = default_collect_line;
linetype = validate_actionline (&line, t);
if (linetype != BADLINE)
{
default_collect_action = xmalloc (sizeof (struct command_line));
make_cleanup (xfree, default_collect_action);
default_collect_action->next = t->commands->commands;
default_collect_action->line = line;
actions = default_collect_action;
}
validate_actionline (&line, t);
default_collect_action = xmalloc (sizeof (struct command_line));
make_cleanup (xfree, default_collect_action);
default_collect_action->next = t->commands->commands;
default_collect_action->line = line;
actions = default_collect_action;
}
encode_actions_1 (actions, t, tloc, frame_reg, frame_offset,
&tracepoint_list, &stepping_list);

View File

@ -23,14 +23,6 @@
#include "breakpoint.h"
#include "target.h"
enum actionline_type
{
BADLINE = -1,
GENERIC = 0,
END = 1,
STEPPING = 2
};
/* A trace state variable is a value managed by a target being
traced. A trace state variable (or tsv for short) can be accessed
and assigned to by tracepoint actions and conditionals, but is not
@ -176,7 +168,7 @@ void set_traceframe_number (int);
struct cleanup *make_cleanup_restore_current_traceframe (void);
void free_actions (struct breakpoint *);
enum actionline_type validate_actionline (char **, struct breakpoint *);
extern void validate_actionline (char **, struct breakpoint *);
extern void end_actions_pseudocommand (char *args, int from_tty);
extern void while_stepping_pseudocommand (char *args, int from_tty);