1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-28 18:07:37 +01:00
Commit graph

133 commits

Author SHA1 Message Date
Konstantin Belousov
53095e6b3e Code for resume 2010-03-07 23:43:07 +02:00
Konstantin Belousov
c64723835c Support walk over freebsd sigframes 2010-03-07 21:53:01 +02:00
Arun Sharma
3468a6b33d Change MS_SYNC to MS_ASYNC
Hopefully this makes the address validation a bit cheaper.
2010-02-23 10:35:47 -08:00
Paul Pluzhnikov
54752e0df0 Implement getcontext for x86
Greetings,

Attached patch implements getcontext for x86.

Motivation is the same as:
http://lists.nongnu.org/archive/html/libunwind-devel/2008-06/msg00009.html

This also fixes check-name-space on x86.

Tested on Linux/86 with no new failures.

Thanks,
--
Paul Pluzhnikov
2009-12-23 09:59:52 -08:00
Paul Pluzhnikov
0cf76ed0b5 Check for NULL when validating addresses
This is rather on the obvious side.

While doing strace on an executable using libunwind, I noticed a
lot of:

  msync(0, 1, MS_SYNC) = -1 ENOMEM (Cannot allocate memory)

Since we know that the first page isn't mapped (or at least doesn't
contain the data we are looking for), we can eliminate all such
msync calls.

Tested on Linux/x86_64 with no regressions.
2009-12-01 13:59:45 -08:00
Paul Pluzhnikov
84d4150668 Allow caller to block signals.
Greetings,

We use libunwind just for stack traces (I suspect many others do as well).

The use pattern is:

GetStackTrace(void** result, int max_depth)
{
...
  unw_getcontext(&uc);
  unw_init_local(&cursor, &uc);

  while (n < max_depth) {
    if (unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip) < 0) {
      break;
    }
    result[n++] = ip;
    if (unw_step(&cursor) <= 0) {
      break;
    }
  }

Given this usage, it is quite convenient for us to block signals (or
prevent signal handlers from re-entering libunwind by other means) at the
"top level", which makes most of the sigprocmask calls performed by
libunwind itself unneccessary.

The second patch in this series adds a configure option which removes most
of the sigprocmask calls.

Attached patch is a preliminary for it -- consolidating all of the
"sigprocmask; mutex_lock;" sequences into lock_acquire and "mutex_unlock;
sigprocmask;" sequences into lock_release.

Thanks,
--
Paul Pluzhnikov

commit 402d15b123d54a7669db7cf17a76dd315094e472
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Mon Sep 21 10:18:28 2009 -0700

    Replace "sigprocmask + mutext_lock" with a single lock_acquire.
    Likewise, replace "mutext_unlock + sigprocmask" with lock_release.
2009-09-25 09:35:31 -07:00
Arun Sharma
ff0ae70cc3 Bad pointer validation for 32 bit x86.
This corresponds to commit 649f1fb344.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2009-03-16 21:34:49 -07:00
David Mosberger-Tang
a8be10e251 [X86] Cleanup XMM handling for x86
* Use explicit types for XMM registers
* Support full width (128 bits) access

Signed-off-by: Andrew Cagney <cagney@redhat.com>
Signed-off-by: Arun Sharma <aruns@google.com>
2008-01-07 15:41:20 -07:00
Andrew Cagney
05c8284b43 [X86] 2007-10-10 Andrew Cagney <cagney@redhat.com>
* src/x86/init.h (common_init): Fix typo: use UNW_X86_ESI for
     dwarf.loc[ESI].

Acked-by: Arun Sharma <aruns@google.com>
2007-10-15 10:32:07 -06:00
Jan Kratochvil
57e5696463 Mark Wielaard <mwielaard@redhat.com> writes:
On some systems executable stacks are denied. Since libunwind and the
tests don't actually need executable stacks this patch marks all
assembly files as not needing it.

The original patch comes from frysk:

2007-04-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

    * src/hppa/getcontext.S, src/hppa/setcontext.S, src/hppa/siglongjmp.S,
    src/ia64/Ginstall_cursor.S, src/ia64/Linstall_cursor.S,
    src/ia64/dyn_info_list.S, src/ia64/getcontext.S, src/ia64/longjmp.S,
    src/ia64/setjmp.S, src/ia64/siglongjmp.S, src/ia64/sigsetjmp.S,
    src/ppc64/longjmp.S, src/ppc64/siglongjmp.S, src/x86/longjmp.S,
    src/x86/siglongjmp.S, src/x86_64/longjmp.S, src/x86_64/setcontext.S,
    src/x86_64/siglongjmp.S: Stack should be non-executable, for SELinux.

I added a couple more markers for new files in current libunwind.

Before this patch you would get the following on selinux enabled
systems without allow_exec_stack: error while loading shared
libraries:

libunwind.so.7: cannot enable executable stack as shared object
	requires: Permission denied

After the patch that error disappears and all test results are similar
to the results on systems without executable stack protection.
2007-10-01 08:35:01 -06:00
David Mosberger-Tang
e6b9f350f7 Introduce a tdep_get_func_addr_hook() in the ELF lookup_symbol()
routine and add address-space argument.  This is needed because on
PPC64, a the function-name symbol refers to a function descriptor
(unlike, for example, on ia64, where the @fptr() operator is needed to
refer to a function descriptor).  Thus, in order to look up the name
of a function, we need to dereference the function descriptor.  To
make matters more "interesting", the function descriptors are normally
resolved by the dynamic linker, so we can't get their values from the
ELF file.  Instead, we have to read them from the running image, hence
the need for the address-space argument.
2007-08-22 13:02:09 -06:00
Arun Sharma
cdb96f333c [x86] (common_init): Fix spurious errors caused by uninitialized members.
Signed-off-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 22:09:10 -06:00
David Mosberger-Tang
a369768c27 Revert "Initial revision"
This reverts 06d223e924 commit.
2006-07-26 14:47:44 -06:00
hp.com!davidm
d9e100753f Include "libunwind_i.h" instead of "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
07b01ad205 Include "libunwind_i.h" instead of "tdep.h" and "internal.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
mostang.com!davidm
06d223e924 Initial revision 2005-05-03 09:13:17 +00:00
mostang.com!davidm
239ea4e7ea Implement for real. Note: this version is currently broken.
We don't pass sigmask the way this routine expects because it
can't work.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
7fbb8a9593 Adjust for sigset_t to intrmask_t renaming.
(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
3f16641760 (x86_local_resume): Delete unused code.
(establish_machine_state): Fix off-by-one error.
	Fix Debug-statement formatting & debug-level.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
fa0828ac7d (unw_step): Also print IP as part of the function-trace.
2004/11/23 12:49:54-08:00 mostang.com!davidm
(unw_step): If dwarf_step() fails on a signal-frame, fill in the
	save-locations for everything that gets saved in the
	sigcontext structure.

2004/10/25 17:43:57+02:00 homeip.net!davidm
Add Debug statement for return-value.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
db1517609c (tdep_access_reg): Buffer writes to EH argument registers (EAX
and EDX) in dwarf.eh_args[].


2004/11/17 02:43:39-08:00 mostang.com!davidm
(tdep_access_reg): Treat UNW_X86_ESP exactly like UNW_X86_CFA.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
bbe87ea403 (common_init): Don't forget to clear c->dwarf members args_size,
ret_addr_column, pi_valid, and pi_is_dynamic.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
8a66c9c635 (access_reg): Delete left-over Debug statement.
(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
04fde4a63b (Logical change 1.290) 2005-05-03 09:13:17 +00:00
hp.com!davidm
df5acdd24a Fix missing NELEMS -> ARRAY_SIZE adjustment.
(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
caa528e1e8 Add dummy implementation of _UI_longjmp_cont().
(Logical change 1.268)
2004-09-09 16:26:15 +00:00
mostang.com!davidm
21dd6ad5cb (x86_local_resume): Tweak debug-level code to match ia64-version.
(Logical change 1.265)
2004-09-09 10:51:29 +00:00
mostang.com!davidm
f226ffec68 (common_init): Don't forget to initialize cursors sigcontext_format
and sigcontext_addr members.

(Logical change 1.263)
2004-09-09 10:47:55 +00:00
hp.com!davidm
f576cce748 Drop debug-level for function-trace to 1.
(Logical change 1.257)
2004-08-26 10:02:46 +00:00
homeip.net!davidm
be2bed2712 (tdep_access_reg): If c->dwarf.cfa_is_sp is set, treat UNW_X86_64_RSP
as a read-only alias of CFA.

(Logical change 1.253)
2004-08-20 11:23:15 +00:00
homeip.net!davidm
5742642c24 (unw_step): Drop extra 'x' from Debug statement.
(Logical change 1.248)
2004-08-19 12:26:11 +00:00
homeip.net!davidm
8f4a9df420 Rename: src/x86/siglongjmp-x86.S -> src/x86/siglongjmp.S
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
b8f4069f9f Rename: src/x86/siglongjmp-x86.S -> src/x86/siglongjmp.S
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
c298861c67 Rename: src/x86/regname-x86.c -> src/x86/regname.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
85b14bb7f6 Rename: src/x86/regname-x86.c -> src/x86/regname.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
0219cd0e73 Rename: src/x86/is_fpreg-x86.c -> src/x86/is_fpreg.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
188032186b Rename: src/x86/is_fpreg-x86.c -> src/x86/is_fpreg.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
2e94aaed46 Rename: src/x86/Gstep-x86.c -> src/x86/Gstep.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
3dab98edbc Rename: src/x86/Gstep-x86.c -> src/x86/Gstep.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
fe971b1989 Rename: src/x86/Gresume-x86.c -> src/x86/Gresume.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
bcd0aff352 Rename: src/x86/Gresume-x86.c -> src/x86/Gresume.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
e7671cd144 Rename: src/x86/Gregs-x86.c -> src/x86/Gregs.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
6607424863 Rename: src/x86/Gregs-x86.c -> src/x86/Gregs.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
8652314904 Rename: src/x86/Gis_signal_frame-x86.c -> src/x86/Gis_signal_frame.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
e1eb2d4656 Rename: src/x86/Gis_signal_frame-x86.c -> src/x86/Gis_signal_frame.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
475062bfda Rename: src/x86/Ginit_remote-x86.c -> src/x86/Ginit_remote.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
9f2cd2318d Rename: src/x86/Ginit_remote-x86.c -> src/x86/Ginit_remote.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
66fe735a7d Rename: src/x86/Ginit_local-x86.c -> src/x86/Ginit_local.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
db8a0c4373 Rename: src/x86/Ginit_local-x86.c -> src/x86/Ginit_local.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
5bb574d178 Rename: src/x86/Ginit-x86.c -> src/x86/Ginit.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00