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]

Re: [PATCH] PR backtrace/9786


The problem was reported as follow: Doing an "info frame" right after
connecting to a remote target started through the gdbserver causes
a failed assertion:

    (gdb) target remote localhost:4444
    Remote debugging using localhost:4444
    0xb7fda810 in ?? () from /lib/ld-linux.so.2
    (gdb) info frame
    Stack level 0, frame at 0x0:
     eip = 0xb7fda810; saved eip 
    findvar.c:299: internal-error: value_of_register_lazy: Assertion `frame_id_p
    (get_frame_id (frame))' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

The problem occurs when trying to print the frame's return address
(saved eip ...). Of course, since the program has just been spawned
but hasn't started running yet, there is no return address...

The fix suggested by Nick is the following:

> @@ -976,7 +977,12 @@ frame_info (char *addr_exp, int from_tty
>    puts_filtered ("; ");
>    wrap_here ("    ");
>    printf_filtered ("saved %s ", pc_regname);
> -  fputs_filtered (paddress (frame_pc_unwind (fi)), gdb_stdout);
> +  value = frame_unwind_register_value (fi, gdbarch_pc_regnum (gdbarch));
> +  if (VALUE_LVAL (value)  == lval_register
> +      && !(frame_id_p (VALUE_FRAME_ID (value))))
> +    printf_filtered ("none");
> +  else
> +    fputs_filtered (paddress (frame_pc_unwind (fi)), gdb_stdout);
>    printf_filtered ("\n");

I wonder if it wouldn't be better to do a "get_prev_frame" and
check that this frame is valid, and if valid, then get the PC
from this prev_frame.

What do others think?

-- 
Joel


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