This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [MI tracepoints 2/9] unify breakpoint commands and tracepoint actions
On Monday 22 March 2010 18:01:28 Stan Shebs wrote:
> Vladimir Prus wrote:
> > Here's a revised version, also addressing Pedro's comments.
> >
> Looks great, just one little thing left to fix:
>
> + if (strstr (c->line, "eval ") == c->line)
> + error (_("The 'eval' command can only be used for tracepoints"));
>
>
> The command is now "teval" instead of "eval".
>
> With that change, we should be ready to roll in all 9 patches. Thanks
> again!
This patch is now in. Per discussion offlist, I've fused in the attached
patch, which fixes save-tracepoints, which this patch, as posted, broke.
Thanks,
--
Vladimir Prus
CodeSourcery
vladimir@codesourcery.com
(650) 331-3385 x722
commit 3303beea79612354b2bf6795b854582f2e2f4ae5
Author: vladimir <vladimir@e7755896-6108-0410-9592-8049d3e74e28>
Date: Mon Aug 10 18:44:43 2009 +0000
Fix tracepoint saving
git-svn-id: svn+ssh://cugel//net/svn-internal/subversion/Repository/csl/gdb/branches/ericsson-tracing@258025 e7755896-6108-0410-9592-8049d3e74e28
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 9499c3a..99955b8 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,10 @@
+2009-08-10 Vladimir Prus <vladimir@codesourcery.com>
+
+ Fix tracepoint saving.
+
+ * breakpoint.c (tracepoint_save_command):
+ Relay to print_command_lines.
+
2009-08-10 Pedro Alves <pedro@codesourcery.com>
gdb/gdbserver/
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index b95df83..ab5410d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8666,11 +8666,10 @@ tracepoint_save_command (char *args, int from_tty)
struct breakpoint *tp;
int any_tp = 0;
struct command_line *line;
- FILE *fp;
- char *i1 = " ", *i2 = " ";
- char *indent, *actionline, *pathname;
+ char *pathname;
char tmp[40];
struct cleanup *cleanup;
+ struct ui_file *fp;
if (args == 0 || *args == 0)
error (_("Argument required (file name in which to save tracepoints)"));
@@ -8689,49 +8688,43 @@ tracepoint_save_command (char *args, int from_tty)
pathname = tilde_expand (args);
cleanup = make_cleanup (xfree, pathname);
- if (!(fp = fopen (pathname, "w")))
+
+ fp = gdb_fopen (pathname, "w");
+ if (!fp)
error (_("Unable to open file '%s' for saving tracepoints (%s)"),
args, safe_strerror (errno));
- make_cleanup_fclose (fp);
+ make_cleanup_ui_file_delete (fp);
ALL_TRACEPOINTS (tp)
{
if (tp->addr_string)
- fprintf (fp, "trace %s\n", tp->addr_string);
+ fprintf_unfiltered (fp, "trace %s\n", tp->addr_string);
else
{
sprintf_vma (tmp, tp->loc->address);
- fprintf (fp, "trace *0x%s\n", tmp);
+ fprintf_unfiltered (fp, "trace *0x%s\n", tmp);
}
if (tp->pass_count)
- fprintf (fp, " passcount %d\n", tp->pass_count);
+ fprintf_unfiltered (fp, " passcount %d\n", tp->pass_count);
if (tp->commands)
{
- fprintf (fp, " actions\n");
- indent = i1;
- for (line = tp->commands; line; line = line->next)
+ volatile struct gdb_exception ex;
+
+ fprintf_unfiltered (fp, " actions\n");
+
+ ui_out_redirect (uiout, fp);
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
{
- struct cmd_list_element *cmd;
+ print_command_lines (uiout, tp->commands, 2);
+ }
+ ui_out_redirect (uiout, NULL);
- QUIT; /* allow user to bail out with ^C */
- actionline = line->line;
- while (isspace ((int) *actionline))
- actionline++;
+ if (ex.reason < 0)
+ throw_exception (ex);
- fprintf (fp, "%s%s\n", indent, actionline);
- if (*actionline != '#') /* skip for comment lines */
- {
- cmd = lookup_cmd (&actionline, cmdlist, "", -1, 1);
- if (cmd == 0)
- error (_("Bad action list item: %s"), actionline);
- if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
- indent = i2;
- else if (cmd_cfunc_eq (cmd, end_actions_pseudocommand))
- indent = i1;
- }
- }
+ fprintf_unfiltered (fp, " end\n");
}
}
do_cleanups (cleanup);