Replace some uses of error with fprintf
error is not standard so it has no business being used in generic code.
The linux-gnu back end is useful for android, and that doesn't have that
interface either.
diff --git a/sysdeps/linux-gnu/breakpoint.c b/sysdeps/linux-gnu/breakpoint.c
index 5f60bec..e05e730 100644
--- a/sysdeps/linux-gnu/breakpoint.c
+++ b/sysdeps/linux-gnu/breakpoint.c
@@ -2,8 +2,8 @@
#include <sys/ptrace.h>
#include <errno.h>
-#include <error.h>
#include <string.h>
+#include <stdio.h>
#include "common.h"
#include "sysdep.h"
@@ -28,9 +28,10 @@
long a = ptrace(PTRACE_PEEKTEXT, pid,
sbp->addr + i * sizeof(long), 0);
if (a == -1 && errno) {
- error(0, errno,
- "enable_breakpoint pid=%d, addr=%p, symbol=%s",
- pid, sbp->addr, breakpoint_name(sbp));
+ fprintf(stderr, "enable_breakpoint"
+ " pid=%d, addr=%p, symbol=%s: %s\n",
+ pid, sbp->addr, breakpoint_name(sbp),
+ strerror(errno));
return;
}
for (j = 0;
@@ -44,9 +45,10 @@
a = ptrace(PTRACE_POKETEXT, pid,
sbp->addr + i * sizeof(long), a);
if (a == -1) {
- error(0, errno,
- "enable_breakpoint pid=%d, addr=%p, symbol=%s",
- pid, sbp->addr, breakpoint_name(sbp));
+ fprintf(stderr, "enable_breakpoint"
+ " pid=%d, addr=%p, symbol=%s: %s\n",
+ pid, sbp->addr, breakpoint_name(sbp),
+ strerror(errno));
return;
}
}
@@ -77,8 +79,9 @@
long a = ptrace(PTRACE_PEEKTEXT, pid,
sbp->addr + i * sizeof(long), 0);
if (a == -1 && errno) {
- error(0, errno, "disable_breakpoint pid=%d, addr=%p",
- pid, sbp->addr);
+ fprintf(stderr,
+ "disable_breakpoint pid=%d, addr=%p: %s\n",
+ pid, sbp->addr, strerror(errno));
return;
}
for (j = 0;
@@ -91,8 +94,9 @@
a = ptrace(PTRACE_POKETEXT, pid,
sbp->addr + i * sizeof(long), a);
if (a == -1 && errno) {
- error(0, errno, "disable_breakpoint pid=%d, addr=%p",
- pid, sbp->addr);
+ fprintf(stderr,
+ "disable_breakpoint pid=%d, addr=%p: %s\n",
+ pid, sbp->addr, strerror(errno));
return;
}
}
diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c
index e1e3c36..b3b41c9 100644
--- a/sysdeps/linux-gnu/proc.c
+++ b/sysdeps/linux-gnu/proc.c
@@ -1,20 +1,19 @@
#define _GNU_SOURCE /* For getline. */
#include "config.h"
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <link.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <signal.h>
#include <unistd.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <errno.h>
-#include <sys/syscall.h>
-#include <error.h>
#include "common.h"
#include "breakpoint.h"
@@ -182,7 +181,8 @@
each_line_starting(file, "State:\t", &process_status_cb, &ret);
fclose(file);
if (ret == ps_invalid)
- error(0, errno, "process_status %d", pid);
+ fprintf(stderr, "process_status %d: %s", pid,
+ strerror(errno));
} else
/* If the file is not present, the process presumably
* exited already. */
@@ -466,8 +466,8 @@
fail:
if (lib != NULL)
library_destroy(lib);
- error(0, errno, "Couldn't load ELF object %s\n",
- lib_name);
+ fprintf(stderr, "Couldn't load ELF object %s: %s\n",
+ lib_name, strerror(errno));
continue;
}
library_init(lib, LT_LIBTYPE_DSO);
@@ -539,7 +539,8 @@
struct debug_struct *debug = malloc(sizeof(*debug));
if (debug == NULL) {
- error(0, errno, "couldn't allocate debug struct");
+ fprintf(stderr, "couldn't allocate debug struct: %s\n",
+ strerror(errno));
fail:
proc->debug = NULL;
free(debug);
@@ -612,7 +613,7 @@
int fd = open(fn, O_RDONLY);
if (fd == -1) {
fail:
- error(0, errno, "couldn't read %s", fn);
+ fprintf(stderr, "couldn't read %s: %s", fn, strerror(errno));
done:
if (fd != -1)
close(fd);
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c
index 5ad82cd..d5c5262 100644
--- a/sysdeps/linux-gnu/trace.c
+++ b/sysdeps/linux-gnu/trace.c
@@ -5,7 +5,6 @@
#include <sys/wait.h>
#include <assert.h>
#include <errno.h>
-#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>