aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/runtime/backtrace.c
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2011-05-14 10:55:51 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2011-05-14 10:55:51 +0300
commit1028b2bded33a9ee92db6a1a968258f3ba29aa24 (patch)
treecd0c97323c6980b35b95ce189ac0bdc597d9c4dc /libgfortran/runtime/backtrace.c
parentb4224aec547b9e01f0b79d65c31c7b6da998b8cd (diff)
downloadgcc-1028b2bded33a9ee92db6a1a968258f3ba29aa24.zip
gcc-1028b2bded33a9ee92db6a1a968258f3ba29aa24.tar.gz
gcc-1028b2bded33a9ee92db6a1a968258f3ba29aa24.tar.bz2
Error printing thread safety, remove GFORTRAN_USE_STDERR
From-SVN: r173749
Diffstat (limited to 'libgfortran/runtime/backtrace.c')
-rw-r--r--libgfortran/runtime/backtrace.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/libgfortran/runtime/backtrace.c b/libgfortran/runtime/backtrace.c
index 5e4f15c..aa77025 100644
--- a/libgfortran/runtime/backtrace.c
+++ b/libgfortran/runtime/backtrace.c
@@ -95,7 +95,11 @@ dump_glibc_backtrace (int depth, char *str[])
int i;
for (i = 0; i < depth; i++)
- st_printf (" + %s\n", str[i]);
+ {
+ estr_write (" + ");
+ estr_write (str[i]);
+ estr_write ("\n");
+ }
free (str);
}
@@ -192,7 +196,7 @@ show_backtrace (void)
if (fgets (func, sizeof(func), output))
{
- st_printf ("\nBacktrace for this error:\n");
+ estr_write ("\nBacktrace for this error:\n");
do
{
@@ -222,7 +226,9 @@ show_backtrace (void)
if (func[0] == '?' && func[1] == '?' && file[0] == '?'
&& file[1] == '?')
{
- st_printf (" + %s\n", str[i]);
+ estr_write (" + ");
+ estr_write (str[i]);
+ estr_write ("\n");
continue;
}
@@ -239,15 +245,25 @@ show_backtrace (void)
line = -1;
if (strcmp (func, "MAIN__") == 0)
- st_printf (" + in the main program\n");
+ estr_write (" + in the main program\n");
else
- st_printf (" + function %s (0x%s)\n", func, addr[i]);
+ {
+ estr_write (" + function ");
+ estr_write (func);
+ estr_write (" (0x");
+ estr_write (addr[i]);
+ estr_write (")\n");
+ }
if (line <= 0 && strcmp (file, "??") == 0)
continue;
if (line <= 0)
- st_printf (" from file %s\n", file);
+ {
+ estr_write (" from file ");
+ estr_write (file);
+ estr_write ("\n");
+ }
else
st_printf (" at line %d of file %s\n", line, file);
}
@@ -257,8 +273,8 @@ show_backtrace (void)
return;
fallback:
- st_printf ("** Something went wrong while running addr2line. **\n"
- "** Falling back to a simpler backtrace scheme. **\n");
+ estr_write ("** Something went wrong while running addr2line. **\n"
+ "** Falling back to a simpler backtrace scheme. **\n");
}
}
while (0);
@@ -288,7 +304,7 @@ fallback:
char *arg[NUM_ARGS+1];
char buf[20];
- st_printf ("\nBacktrace for this error:\n");
+ estr_write ("\nBacktrace for this error:\n");
arg[0] = (char *) "pstack";
snprintf (buf, sizeof(buf), "%d", (int) getppid ());
arg[1] = buf;
@@ -301,7 +317,7 @@ fallback:
#if GLIBC_BACKTRACE
dump_glibc_backtrace (depth, str);
#else
- st_printf (" unable to produce a backtrace, sorry!\n");
+ estr_write (" unable to produce a backtrace, sorry!\n");
#endif
_exit (0);
@@ -316,7 +332,7 @@ fallback:
#if GLIBC_BACKTRACE
/* Fallback to the glibc backtrace. */
- st_printf ("\nBacktrace for this error:\n");
+ estr_write ("\nBacktrace for this error:\n");
dump_glibc_backtrace (depth, str);
#endif
}