Re: [RFA/RFC] mips tracepoint: fix Bug 12013

Pedro Alves
2010-12-28T18:04:34Z

On Tuesday 28 December 2010 17:23:59, Pedro Alves wrote:
> On Tuesday 28 December 2010 17:08:52, Joel Brobecker wrote:
> > > Joel, do you think this patch can check in to 7.2.1.
> >
> > I think that it's borderline, and I'm tempted to say no, considering
> > that this is not a crash or a regression (just a limitation). But
> > it looks relatively safe to me. So, if Pedro agrees, it's OK with me.
>
> Yeah. I understand that without this patch, MIPS tracepoints are
> practically useless on 7.2, so on those grounds, I'd be okay.
>
> However, I just went to check whether collecting a pseudo or
> user register in x86/x86_64 still gives a reasonable error, and
> I now get:
>
> >./gdb -q ./gdb
> Reading symbols from /home/pedro/gdb/baseline/build/gdb/gdb...done.
> (top-gdb) start
> Temporary breakpoint 3 at 0x4565c3: file ../../src/gdb/gdb.c, line 29.
> Starting program: /home/pedro/gdb/baseline/build/gdb/gdb
> [Thread debugging using libthread_db enabled]
>
> Temporary breakpoint 3, main (argc=1, argv=0x7fffffffe108) at ../../src/gdb/gdb.c:29
> 29 memset (&args, 0, sizeof args);
> (top-gdb) maint agent $sp
> ../../src/gdb/regcache.c:166: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)
>
> While before (on 7.2), we'd get:
>
> (top-gdb) maint agent $sp
> 'sp' is a pseudo-register; GDB cannot yet trace pseudoregister contents.
>
> We'll need to get this fixed this before considering a backport to 7.2.
>
>

Fixed for now. I've reinstated the exact same old error, but under
a stricter check: we now error out for user registers, but let
pseudo-registers pass:

(top-gdb) maint agent $pc
'pc' is a pseudo-register; GDB cannot yet trace pseudoregister contents.

Pseudo-registers will error out further on, on the new errors that Hui
added when the new gdbarch callbacks aren't implemented. On x86_64:

(top-gdb) maint agent $rsp
Scope: 0x4565c3
Reg mask: 80
0 end

(top-gdb) maint agent $esp
'esp' is a pseudo-register; GDB cannot yet trace its contents.

--
Pedro Alves

2010-12-28 Pedro Alves <pedro@codesourcery.com>

gdb/
* ax-gdb.c (gen_expr) <OP_REGISTER>: Error out if trying to
collect a user register.

---
gdb/ax-gdb.c | 6 ++++++
1 file changed, 6 insertions(+)

Index: src/gdb/ax-gdb.c
===================================================================
--- src.orig/gdb/ax-gdb.c 2010-12-28 16:22:01.000000000 +0000
+++ src/gdb/ax-gdb.c 2010-12-28 17:54:45.000000000 +0000
@@ -1978,6 +1978,12 @@ gen_expr (struct expression *exp, union
if (reg == -1)
internal_error (__FILE__, __LINE__,
_("Register $%s not available"), name);
+ /* No support for tracing user registers yet. */
+ if (reg >= gdbarch_num_regs (exp->gdbarch)
+ + gdbarch_num_pseudo_regs (exp->gdbarch))
+ error (_("'%s' is a pseudo-register; "
+ "GDB cannot yet trace pseudoregister contents."),
+ name);
value->kind = axs_lvalue_register;
value->u.reg = reg;
value->type = register_type (exp->gdbarch, reg);