summaryrefslogtreecommitdiffstats
path: root/libdwfl/linux-pid-attach.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't include sys/uio.h if we don't need itUlf Hermann2018-07-191-1/+1
| | | | | | | The PID attaching only works on linux. Change-Id: I00428a711b64cb490429363ef28a867b1347956e Reviewed-by: Christian Kandeler <[email protected]>
* Merge tag 'elfutils-0.173'Ulf Hermann2018-07-131-2/+84
|\ | | | | | | | | | | elfutils 0.173 release Change-Id: I83dc56dd15c26fe7acf4ce73c29df65b8b65e757
| * libdwfl: Use process_vm_readv when available.Mark Wielaard2018-03-281-1/+83
| | | | | | | | | | | | | | | | | | | | If possible use process_vm_readv to read 4K blocks instead of fetching each word individually with ptrace. For unwinding this often means we only have to do one process_vm_readv of the stack instead of dozens of ptrace calls. There is one 4K cache per process, cleared whenever a thread is detached. Signed-off-by: Mark Wielaard <[email protected]>
| * Include sys/ptrace.h as early as possible.Mark Wielaard2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some systems, at least on Fedora 27 ppc64le with glibc 2.26-24 and kernel 4.14.18-300, including sys/ptrace.h late (after signal.h or sys/wait.h for example) will cause issues and produce errors like: In file included from /usr/include/asm/sigcontext.h:12:0, from /usr/include/bits/sigcontext.h:30, from /usr/include/signal.h:287, from /usr/include/sys/wait.h:36, from linux-pid-attach.c:38: /usr/include/sys/ptrace.h:73:3: error: expected identifier before numeric constant PTRACE_GETREGS = 12, ^ Swapping the include order fixes these issues. Signed-off-by: Mark Wielaard <[email protected]>
| * Avoid double-including config.hUlf Hermann2017-05-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Signed-off-by: Ulf Hermann <[email protected]>
| * Clean up linux-specific system includesUlf Hermann2017-04-261-2/+3
| | | | | | | | | | | | We only include them where we actually need them and only on linux. Signed-off-by: Ulf Hermann <[email protected]>
* | Open files in O_BINARYUlf Hermann2017-05-081-3/+3
| | | | | | | | | | | | | | | | | | If O_BINARY is not defined, define it to 0, so that the change has no effect then. Some systems have separate binary and text modes for files, and we don't want the text mode to be used. Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce Reviewed-by: Christian Kandeler <[email protected]>
* | Avoid double-including config.hUlf Hermann2017-04-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Change-Id: Ib78dd7e058ef8ac93cd379dcd14a2ffbc86c1988 Reviewed-by: Christian Kandeler <[email protected]>
* | Clean up linux-specific system includesUlf Hermann2017-04-211-2/+3
|/ | | | | | | We only include them where we actually need them and only on linux. Change-Id: Ic3065ffab67ba1177f63204fb91a92c5f4336dbb Reviewed-by: Christian Kandeler <[email protected]>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-121-4/+0
| | | | | | | | | | This change also creates a new header file libeu.h to provide the prototypes for the function of libeu. That hides the definition of function crc32, which can conflict with zlib, from libelf. It also prevents mistakes to refer those functions from a component which doesn't link with libeu, such as libelf. Signed-off-by: Akihiko Odaki <[email protected]>
* libdwfl: clean up non-Linux GNU platforms codeSteven Chamberlain2016-03-021-63/+0
| | | | | | | | | | | | | | | | | | | For non-Linux GNU platforms (like kFreeBSD, Hurd), linux-pid-attach.c had some stub functions that are not used or exported. Since gcc-6, having these caused compiler errors due to -Wall -Werror: linux-pid-attach.c:479:36: error: 'pid_thread_callbacks' defined but not used [-Werror=unused-const-variable=] linux-pid-attach.c:474:1: error: 'pid_thread_detach' defined but not used [-Werror=unused-function] linux-pid-attach.c:461:1: error: 'pid_detach' defined but not used [-Werror=unused-function] linux-pid-attach.c:452:1: error: 'pid_set_initial_registers' defined but not used [-Werror=unused-function] linux-pid-attach.c:441:1: error: 'pid_memory_read' defined but not used [-Werror=unused-function] linux-pid-attach.c:420:1: error: 'pid_getthread' defined but not used [-Werror=unused-function] linux-pid-attach.c:410:1: error: 'pid_next_thread' defined but not used [-Werror=unused-function] This part of the source file is guarded by #ifndef __linux__ Signed-off-by: Steven Chamberlain <[email protected]>
* libdwfl: Make dwfl_linux_proc_attach work even without any Dwfl_Modules.Mark Wielaard2015-09-141-6/+37
| | | | | | | | | dwfl_linux_proc_attach depended on a Dwfl_Module with the correct ELF header already being available. That isn't really necessary since when we attach we have the main exe ELF file available. Just use that to make dwfl_linux_proc_attach always work. Signed-off-by: Mark Wielaard <[email protected]>
* Make the attach code build again on non-Linux hosts.Kurt Roeckx2014-06-251-0/+17
| | | | Signed-off-by: Kurt Roeckx <[email protected]>
* libdwfl: Record dwfl_attach_state error and return it on failure.Mark Wielaard2014-06-111-4/+21
| | | | | | | | | | | When dwfl_attach_state fails functions that need the process state should return the error that caused the attach to fail. Use this in the backtrace test to signal any attach failure. This makes sure that architectures that don't provide unwinder support get properly detected (and the tests SKIPs) Also don't assert when trying to attach a non-core ELF file, but return an error to indicate failure. Signed-off-by: Mark Wielaard <[email protected]>
* Unwinding is only supported on LinuxKurt Roeckx2014-04-231-0/+85
| | | | Signed-off-by: Kurt Roeckx <[email protected]>
* libdwfl: dwfl_linux_proc_find_elf use elf_from_remote_memory for (deleted).Mark Wielaard2014-03-101-29/+36
| | | | | | | | If a module has a "(deleted)" main ELF file, then try to read it from remote memory if the Dwfl has process state attached by reusing the ptrace mechanism from linux-pid-attach. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: linux-pid-attach.c (dwfl_linux_proc_attach): Use and check strtolMark Wielaard2014-01-021-2/+9
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.Mark Wielaard2013-12-311-20/+24
| | | | | | | | | | | | | | Rewrite __libdwfl_attach_state_for_pid and __libdwfl_attach_state_for_core as public functions and don't call them from dwfl_linux_proc_report and dwfl_core_file_report anymore. This lets the user attach state explicitly independ from how the dwfl modules have been reported. Since attaching state is an explicit action now the error can be returned directly and we don't need to keep track of process_attach_error. dwfl_linux_proc_attach lets the user can tell libdwfl whether caller takes care of ptrace attaching and stopping the threads under inspection, or whether the callback needs to take care of that and detaching again. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.Mark Wielaard2013-12-251-0/+24
| | | | Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Add dwfl_getthread_frames.Mark Wielaard2013-12-231-0/+15
| | | | | | | | | | | | | | | | dwfl_getthread_frames is a convenience function for when the user is only interested in one specific thread id of a process. It can be implemented by a simple wrapper function that removes an extra callback layer just to filter on thread id. But it also provides an optimized path to getting access to just one particular Dwfl_Thread of the Dwfl process by providing and (optional) new callback for the state provider. The pid_thread_callbacks now provide an (optional) pid_getthread that doesn't need to travers all threads anymore. Which is implemented for the linux-pid-attach provider. stack now uses this to implement a new '-1' option that shows just one specific thread of a process. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: linux-pid-attach.c (pid_next_thread): Use rewinddir on first call.Mark Wielaard2013-12-171-0/+3
| | | | | | | | dwfl_getthreads would otherwise fail to report any threads after it was called once. Reported-by: Masatake YAMATO <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* unwinder: ppc and ppc64Jan Kratochvil2013-12-151-0/+8
| | | | Signed-off-by: Jan Kratochvil <[email protected]>
* Compatibility with older kernels such as RHEL-6.Jan Kratochvil2013-11-191-4/+12
| | | | Signed-off-by: Jan Kratochvil <[email protected]>
* Code cleanup: Remove const in prototypeJan Kratochvil2013-11-141-4/+2
| | | | Signed-off-by: Jan Kratochvil <[email protected]>
* Fix dwfl_attach_state machine->elfJan Kratochvil2013-11-141-1/+1
| | | | Signed-off-by: Jan Kratochvil <[email protected]>
* Unwinder for x86*.Jan Kratochvil2013-11-071-0/+282
Signed-off-by: Jan Kratochvil <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>