aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/runtime/main.c
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2011-05-29 23:13:52 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2011-05-29 23:13:52 +0300
commit155732f56dacb4f10aa48db4d952745aed720bc7 (patch)
treecb0da06274fcd0419a2fe0ae1c347faf09af5f70 /libgfortran/runtime/main.c
parenteb93b31f68a621299de05ce7774d68c948950123 (diff)
downloadgcc-155732f56dacb4f10aa48db4d952745aed720bc7.zip
gcc-155732f56dacb4f10aa48db4d952745aed720bc7.tar.gz
gcc-155732f56dacb4f10aa48db4d952745aed720bc7.tar.bz2
PR 48931 Use async-signal-safe execve instead of execvp
From-SVN: r174415
Diffstat (limited to 'libgfortran/runtime/main.c')
-rw-r--r--libgfortran/runtime/main.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c
index 54d9e09..bc8dab4 100644
--- a/libgfortran/runtime/main.c
+++ b/libgfortran/runtime/main.c
@@ -139,6 +139,40 @@ full_exe_path (void)
}
+char *addr2line_path;
+
+/* Find addr2line and store the path. */
+
+void
+find_addr2line (void)
+{
+#ifdef HAVE_ACCESS
+#define A2L_LEN 10
+ char *path = getenv ("PATH");
+ size_t n = strlen (path);
+ char ap[n + 1 + A2L_LEN];
+ size_t ai = 0;
+ for (size_t i = 0; i < n; i++)
+ {
+ if (path[i] != ':')
+ ap[ai++] = path[i];
+ else
+ {
+ ap[ai++] = '/';
+ memcpy (ap + ai, "addr2line", A2L_LEN);
+ if (access (ap, R_OK|X_OK) == 0)
+ {
+ addr2line_path = strdup (ap);
+ return;
+ }
+ else
+ ai = 0;
+ }
+ }
+#endif
+}
+
+
/* Set the saved values of the command line arguments. */
void
@@ -185,6 +219,9 @@ init (void)
/* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */
#endif
+ if (options.backtrace == 1)
+ find_addr2line ();
+
random_seed_i4 (NULL, NULL, NULL);
}
@@ -198,4 +235,6 @@ cleanup (void)
if (please_free_exe_path_when_done)
free ((char *) exe_path);
+
+ free (addr2line_path);
}