summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2013-12-30 22:00:57 +0100
committerMark Wielaard <[email protected]>2013-12-31 13:59:51 +0100
commit19108019192ab273c53ae324be448d29dac806ca (patch)
tree6605f8c9e3e15ea50c77ccd9fe1d2b69f68959b5 /src
parentac65261cc5f4b313d4f852e0a7f2b1b91918550b (diff)
libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.
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]>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/stack.c16
2 files changed, 21 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cb9c8151..811004d3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-30 Mark Wielaard <[email protected]>
+
+ * stack.c (parse_opt): Explicitly call dwfl_linux_proc_attach
+ or dwfl_core_file_attach and check for errors.
+
2013-12-28 Mark Wielaard <[email protected]>
* stack.c (print_frames): Remove address width code and use...
diff --git a/src/stack.c b/src/stack.c
index 156455c0..2c1d8ff7 100644
--- a/src/stack.c
+++ b/src/stack.c
@@ -443,6 +443,22 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
if (dwfl_report_end (dwfl, NULL, NULL) != 0)
error (EXIT_BAD, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
+ if (pid != 0)
+ {
+ int err = dwfl_linux_proc_attach (dwfl, pid, false);
+ if (err < 0)
+ error (EXIT_BAD, 0, "dwfl_linux_proc_attach pid %d: %s", pid,
+ dwfl_errmsg (-1));
+ else if (err > 0)
+ error (EXIT_BAD, err, "dwfl_linux_proc_attach pid %d", pid);
+ }
+
+ if (core != NULL)
+ {
+ if (dwfl_core_file_attach (dwfl, core) < 0)
+ error (EXIT_BAD, 0, "dwfl_core_file_report: %s", dwfl_errmsg (-1));
+ }
+
/* Makes sure we are properly attached. */
if (dwfl_pid (dwfl) < 0)
error (EXIT_BAD, 0, "dwfl_pid: %s\n", dwfl_errmsg (-1));