summaryrefslogtreecommitdiffstats
path: root/src/audit-error.c
diff options
context:
space:
mode:
authorJiri Olsa <Jiri Olsa jolsa@redhat.com>2011-10-18 09:10:05 +0200
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2011-11-24 21:20:27 +0100
commitfa668f3b96fd0363bae1adc640105b3914faa138 (patch)
tree25148826f7a96db52d9e806def1e1a409be0fddd /src/audit-error.c
parentc6bb0e49bed67c0cd53cd725f5efa09e6e94df56 (diff)
downloadlatrace-fa668f3b96fd0363bae1adc640105b3914faa138.tar.gz
latrace-fa668f3b96fd0363bae1adc640105b3914faa138.tar.xz
latrace-fa668f3b96fd0363bae1adc640105b3914faa138.zip
error simulation: added support to display backtrace info
Diffstat (limited to 'src/audit-error.c')
-rw-r--r--src/audit-error.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/audit-error.c b/src/audit-error.c
index 6a9bc50..428d41e 100644
--- a/src/audit-error.c
+++ b/src/audit-error.c
@@ -8,6 +8,7 @@
#include <string.h>
#include "config.h"
+#include "backtrace.h"
int lt_audit_parse_init(struct lt_config_shared *cfg);
int lt_audit_parse();
@@ -43,14 +44,43 @@ struct lt_error_sym* lt_error_sym_get(struct lt_config_shared *cfg,
extern __thread int pipe_fd;
+static void share_info(struct lt_config_audit *cfg,
+ struct lt_error_sym *esym,
+ struct timeval *tv,
+ struct link_map *lr,
+ const La_regs *inregs)
+{
+ void *ret_addr;
+#define LT_MAXMSG 100
+ char text[LT_MAXMSG];
+
+ lt_error_get_retaddr(cfg, &ret_addr, inregs);
+ ret_addr -= lr->l_addr;
+
+ snprintf(text, LT_MAXMSG, "ERROR SIMULATION inserted %ld, ret %p",
+ esym->ret, ret_addr);
+
+ if (lt_sh(cfg, pipe)) {
+ char buf[LT_FIFO_MSG_MAXLEN];
+ int len;
+
+ len = lt_fifo_mtext_get(cfg->sh, buf, tv, text);
+ /* TODO erro handling */
+ lt_fifo_send(cfg->sh, pipe_fd, buf, len);
+ } else
+ lt_out_text(cfg->sh, tv, syscall(SYS_gettid), text);
+
+ dump_backtrace(cfg->sh, 0);
+}
+
int lt_error_sym_exit(struct lt_config_audit *cfg,
struct lt_symbol *sym,
struct timeval *tv,
+ struct link_map *lr,
+ const La_regs *inregs,
La_retval *outregs)
{
struct lt_error_sym *esym;
-#define LT_MAXMSG 100
- char text[LT_MAXMSG];
/* we're not interested in this symbol */
if (!sym || !sym->error)
@@ -69,22 +99,11 @@ int lt_error_sym_exit(struct lt_config_audit *cfg,
esym->ret);
/* The fun begins right now.. let's change the return
- * value for the symbol */
-
+ * value for the symbol ... */
lt_error_set_retval(cfg, esym->ret, outregs);
- snprintf(text, LT_MAXMSG, "ERROR SIMULATION inserted %ld",
- esym->ret);
-
- if (lt_sh(cfg, pipe)) {
- char buf[LT_FIFO_MSG_MAXLEN];
- int len;
-
- len = lt_fifo_mtext_get(cfg, buf, tv, text);
- return lt_fifo_send(cfg, pipe_fd, buf, len);
- }
-
- lt_out_text(cfg->sh, tv, syscall(SYS_gettid), text);
+ /* and share some info about the sinner */
+ share_info(cfg, esym, tv, lr, inregs);
return 0;
}