* [RFA/alpha-osf] another next frame confusion in signal unwinder?
@ 2004-12-01 23:51 Joel Brobecker
2004-12-12 16:27 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2004-12-01 23:51 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 4190 bytes --]
Hello,
Using the following C program:
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
void blow_up (int x)
{
*((int*) (x|1)) = 3;
}
void handler (int sig) {
blow_up (sig);
printf ("This is a test.\n");
}
main ()
{
signal (SIGTERM, handler);
kill (getpid (), SIGTERM);
}
Compiled on Tru64 5.1a with GCC:
% gcc -g -o cause_signal cause_signal.c
The following transcript reveals that GDB is unable to unwind
the stack past the signal handler frame:
(gdb) run
Starting program: /usr/prague.a/brobecke/53-63/ex/cause_signal
Program received signal SIGTERM, Terminated.
0x000003ff800e8a78 in kill () from /usr/shlib/libc.so
(gdb) cont
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000120001248 in blow_up (x=15) at cause_signal.c:7
7 *((int*) (x|1)) = 3;
(gdb) bt
#0 0x0000000120001248 in blow_up (x=15) at cause_signal.c:7
#1 0x0000000120001290 in handler (sig=15) at cause_signal.c:12
#2 <signal handler called>
#3 0xa79db5f0b43c0000 in ?? ()
warning: Hit heuristic-fence-post without finding
warning: enclosing function for address 0xa79db5f0b43c0000
This warning occurs if you are debugging a function without any symbols
(for example, in a stripped executable). In that case, you may wish to
increase the size of the search with the `set heuristic-fence-post'
+command.
Otherwise, you told GDB there was a function where there isn't one, or
(more likely) you have encountered a bug in GDB.
#4 0x2c9000006bfa8001 in ?? ()
warning: Hit heuristic-fence-post without finding
warning: enclosing function for address 0x2c9000006bfa8001
warning: Previous frame identical to this frame (corrupt stack?)
The expected output for the "bt" command is:
(gdb) bt
#0 0x0000000120001248 in blow_up (x=15) at cause_signal.c:7
#1 0x0000000120001290 in handler (sig=15) at cause_signal.c:12
#2 <signal handler called>
#3 0x000003ff800e8a78 in kill () from /usr/shlib/libc.so
#4 0x0000000120001318 in main () at cause_signal.c:20
When trying to compute the frame previous to the signal handler one,
GDB computes the frame cache, and as a consequence ends up calling
static struct alpha_sigtramp_unwind_cache *
alpha_sigtramp_frame_unwind_cache (struct frame_info *next_frame,
void **this_prologue_cache)
{
[...]
info->sigcontext_addr = tdep->sigcontext_addr (next_frame);
return info;
}
This results in a call to:
static CORE_ADDR
alpha_osf1_sigcontext_addr (struct frame_info *frame)
{
struct frame_info *next_frame = get_next_frame (frame);
if (next_frame != NULL)
return (read_memory_integer (get_frame_base (next_frame), 8));
else
return (read_memory_integer (get_frame_base (frame), 8));
}
It looks to me that we already have the next frame, so computing
the next frame of that frame in alpha_osf1_sigcontext_addr() is
making us using the wrong frame when getting the base address for
the signal context area. So I changed this function to:
static CORE_ADDR
alpha_osf1_sigcontext_addr (struct frame_info *next_frame)
{
return (read_memory_integer (get_frame_base (next_frame), 8));
}
This fixes the problem above, and I obtain the expected callstack.
2004-12-01 Joel Brobecker <brobecker@gnat.com>
* alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Change
parameter name to make it clear that we already have a next
frame. Return the sigcontext from that next frame instead
of the frame following it.
Fixes [DB30-017].
Tested on alpha-tru64 5.1a. No regression.
OK to apply?
--
Joel
[-- Attachment #2: signal.diff --]
[-- Type: text/plain, Size: 827 bytes --]
Index: alpha-osf1-tdep.c
===================================================================
RCS file: /nile.c/cvs/Dev/gdb/gdb-6.3/gdb/alpha-osf1-tdep.c,v
retrieving revision 1.3
diff -u -p -r1.3 alpha-osf1-tdep.c
--- alpha-osf1-tdep.c 21 Oct 2004 00:08:34 -0000 1.3
+++ alpha-osf1-tdep.c 1 Dec 2004 17:54:46 -0000
@@ -35,14 +35,9 @@ alpha_osf1_pc_in_sigtramp (CORE_ADDR pc,
}
static CORE_ADDR
-alpha_osf1_sigcontext_addr (struct frame_info *frame)
+alpha_osf1_sigcontext_addr (struct frame_info *next_frame)
{
- struct frame_info *next_frame = get_next_frame (frame);
-
- if (next_frame != NULL)
- return (read_memory_integer (get_frame_base (next_frame), 8));
- else
- return (read_memory_integer (get_frame_base (frame), 8));
+ return (read_memory_integer (get_frame_base (next_frame), 8));
}
static void
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA/alpha-osf] another next frame confusion in signal unwinder?
2004-12-01 23:51 [RFA/alpha-osf] another next frame confusion in signal unwinder? Joel Brobecker
@ 2004-12-12 16:27 ` Andrew Cagney
2004-12-13 8:43 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2004-12-12 16:27 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> It looks to me that we already have the next frame, so computing
> the next frame of that frame in alpha_osf1_sigcontext_addr() is
> making us using the wrong frame when getting the base address for
> the signal context area. So I changed this function to:
>
> static CORE_ADDR
> alpha_osf1_sigcontext_addr (struct frame_info *next_frame)
> {
> return (read_memory_integer (get_frame_base (next_frame), 8));
> }
>
> This fixes the problem above, and I obtain the expected callstack.
>
> 2004-12-01 Joel Brobecker <brobecker@gnat.com>
>
> * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Change
> parameter name to make it clear that we already have a next
> frame. Return the sigcontext from that next frame instead
> of the frame following it.
> Fixes [DB30-017].
>
> Tested on alpha-tru64 5.1a. No regression.
>
> OK to apply?
>
>
> ------------------------------------------------------------------------
>
> Index: alpha-osf1-tdep.c
> ===================================================================
> RCS file: /nile.c/cvs/Dev/gdb/gdb-6.3/gdb/alpha-osf1-tdep.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 alpha-osf1-tdep.c
> --- alpha-osf1-tdep.c 21 Oct 2004 00:08:34 -0000 1.3
> +++ alpha-osf1-tdep.c 1 Dec 2004 17:54:46 -0000
> @@ -35,14 +35,9 @@ alpha_osf1_pc_in_sigtramp (CORE_ADDR pc,
> }
>
> static CORE_ADDR
> -alpha_osf1_sigcontext_addr (struct frame_info *frame)
> +alpha_osf1_sigcontext_addr (struct frame_info *next_frame)
> {
> - struct frame_info *next_frame = get_next_frame (frame);
> -
> - if (next_frame != NULL)
> - return (read_memory_integer (get_frame_base (next_frame), 8));
> - else
> - return (read_memory_integer (get_frame_base (frame), 8));
> + return (read_memory_integer (get_frame_base (next_frame), 8));
(I need to deprecate get frame base). Can you just tweak this to return
get_frame_id().stack_addr before committing.
thanks,
Andrew
> }
>
> static void
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA/alpha-osf] another next frame confusion in signal unwinder?
2004-12-12 16:27 ` Andrew Cagney
@ 2004-12-13 8:43 ` Joel Brobecker
0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2004-12-13 8:43 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
> (I need to deprecate get frame base). Can you just tweak this to return
> get_frame_id().stack_addr before committing.
Sure. Attached is what I ended up checking in.
2004-12-13 Joel Brobecker <brobecker@gnat.com>
* alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Change
parameter name to make it clear that we already have a next
frame. Return the sigcontext from that next frame instead
of the frame following it.
Thanks,
--
Joel
[-- Attachment #2: osf.diff --]
[-- Type: text/plain, Size: 869 bytes --]
Index: alpha-osf1-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-osf1-tdep.c,v
retrieving revision 1.18
diff -u -p -r1.18 alpha-osf1-tdep.c
--- alpha-osf1-tdep.c 1 May 2004 15:34:49 -0000 1.18
+++ alpha-osf1-tdep.c 13 Dec 2004 05:04:53 -0000
@@ -35,14 +35,11 @@ alpha_osf1_pc_in_sigtramp (CORE_ADDR pc,
}
static CORE_ADDR
-alpha_osf1_sigcontext_addr (struct frame_info *frame)
+alpha_osf1_sigcontext_addr (struct frame_info *next_frame)
{
- struct frame_info *next_frame = get_next_frame (frame);
+ const struct frame_id next_id = get_frame_id (next_frame);
- if (next_frame != NULL)
- return (read_memory_integer (get_frame_base (next_frame), 8));
- else
- return (read_memory_integer (get_frame_base (frame), 8));
+ return (read_memory_integer (next_id.stack_addr, 8));
}
static void
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-12-13 5:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01 23:51 [RFA/alpha-osf] another next frame confusion in signal unwinder? Joel Brobecker
2004-12-12 16:27 ` Andrew Cagney
2004-12-13 8:43 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox