This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Disallow pseudo-registers in agent expression.


Collecting a pseudo-register in a tracepoint action gives a failed
assert and probably wouldn't work anyway:

(gdb) action
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
> collect $pc
regcache.c:163: internal-error: register_type: Assertion `regnum >= 0
&& regnum < descr->nr_cooked_registers' failed.
A problem internal to GDB has been detected,

The patch also prevents a segfault when "action" or "while-stepping"
is ended with a ^D.

Attached is a mailer-unmangled version of the same file:
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1607,6 +1607,8 @@ gen_expr (union exp_element **pc, struct agent_expr *ax,
        if (reg == -1)
          internal_error (__FILE__, __LINE__,
                          _("Register $%s not available"), name);
+       if (reg >= gdbarch_num_regs (current_gdbarch))
+         error (_("GDB agent expressions cannot use pseudo-registers."));
        value->kind = axs_lvalue_register;
        value->u.reg = reg;
        value->type = register_type (current_gdbarch, reg);
index 2d744ae..ba57fee 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -862,8 +862,11 @@ read_actions (struct tracepoint *t)
        line = gdb_readline (0);

       if (!line)
-       line = "end";
-
+       {
+         line = xstrdup ("end");
+         printf_filtered ("end\n");
+       }
+
       linetype = validate_actionline (&line, t);
       if (linetype == BADLINE)
        continue;               /* already warned -- collect another line */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]