From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Cc: toolchain-devel@blackfin.uclinux.org
Subject: [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls
Date: Thu, 26 May 2011 19:41:00 -0000 [thread overview]
Message-ID: <1306438878-14479-2-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1306438878-14479-1-git-send-email-vapier@gentoo.org>
Parsing target addresses is hard if not generally useless, so use the new
cb_get_string function to lookup the associated strings as well. Now the
trace output is quickly useful instead of just marginally so.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-26 Mike Frysinger <vapier@gentoo.org>
* interp.c (bfin_syscall): Increase _tbuf storage. Declare new local
tstr buffer. Call cb_get_string on tstr when handling CB_SYS_stat64,
CB_SYS_lstat64, CB_SYS_open, CB_SYS_write, CB_SYS_unlink,
CB_SYS_truncate, CB_SYS_rename, CB_SYS_stat, CB_SYS_lstat. Include
tstr in the tbuf output.
---
sim/bfin/interp.c | 43 +++++++++++++++++++++++++++++++++----------
1 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index aac35e6..7ae05f0 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -156,7 +156,7 @@ bfin_syscall (SIM_CPU *cpu)
bu32 args[6];
CB_SYSCALL sc;
char *p;
- char _tbuf[512], *tbuf = _tbuf;
+ char _tbuf[1024 * 3], *tbuf = _tbuf, tstr[1024];
int fmt_ret_hex = 0;
CB_SYSCALL_INIT (&sc);
@@ -435,14 +435,18 @@ bfin_syscall (SIM_CPU *cpu)
break;
case CB_SYS_stat64:
- tbuf += sprintf (tbuf, "stat64(%#x, %u)", args[0], args[1]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "stat64(%#x:\"%s\", %u)", args[0], tstr, args[1]);
cb->stat_map = stat_map_64;
sc.func = TARGET_LINUX_SYS_stat;
cb_syscall (cb, &sc);
cb->stat_map = stat_map_32;
break;
case CB_SYS_lstat64:
- tbuf += sprintf (tbuf, "lstat64(%#x, %u)", args[0], args[1]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "lstat64(%#x:\"%s\", %u)", args[0], tstr, args[1]);
cb->stat_map = stat_map_64;
sc.func = TARGET_LINUX_SYS_lstat;
cb_syscall (cb, &sc);
@@ -510,7 +514,10 @@ bfin_syscall (SIM_CPU *cpu)
break;
case CB_SYS_open:
- tbuf += sprintf (tbuf, "open(%#x, %#x, %o)", args[0], args[1], args[2]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "open(%#x:\"%s\", %#x, %o)",
+ args[0], tstr, args[1], args[2]);
goto case_default;
case CB_SYS_close:
tbuf += sprintf (tbuf, "close(%i)", args[0]);
@@ -519,31 +526,47 @@ bfin_syscall (SIM_CPU *cpu)
tbuf += sprintf (tbuf, "read(%i, %#x, %u)", args[0], args[1], args[2]);
goto case_default;
case CB_SYS_write:
- tbuf += sprintf (tbuf, "write(%i, %#x, %u)", args[0], args[1], args[2]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[1]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "write(%i, %#x:\"%s\", %u)",
+ args[0], args[1], tstr, args[2]);
goto case_default;
case CB_SYS_lseek:
tbuf += sprintf (tbuf, "lseek(%i, %i, %i)", args[0], args[1], args[2]);
goto case_default;
case CB_SYS_unlink:
- tbuf += sprintf (tbuf, "unlink(%#x)", args[0]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "unlink(%#x:\"%s\")", args[0], tstr);
goto case_default;
case CB_SYS_truncate:
- tbuf += sprintf (tbuf, "truncate(%#x, %i)", args[0], args[1]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "truncate(%#x:\"%s\", %i)", args[0], tstr, args[1]);
goto case_default;
case CB_SYS_ftruncate:
tbuf += sprintf (tbuf, "ftruncate(%i, %i)", args[0], args[1]);
goto case_default;
case CB_SYS_rename:
- tbuf += sprintf (tbuf, "rename(%#x, %#x)", args[0], args[1]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "rename(%#x:\"%s\", ", args[0], tstr);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[1]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "%#x:\"%s\")", args[1], tstr);
goto case_default;
case CB_SYS_stat:
- tbuf += sprintf (tbuf, "stat(%#x, %#x)", args[0], args[1]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "stat(%#x:\"%s\", %#x)", args[0], tstr, args[1]);
goto case_default;
case CB_SYS_fstat:
tbuf += sprintf (tbuf, "fstat(%i, %#x)", args[0], args[1]);
goto case_default;
case CB_SYS_lstat:
- tbuf += sprintf (tbuf, "lstat(%i, %#x)", args[0], args[1]);
+ if (cb_get_string (cb, &sc, tstr, sizeof (tstr), args[0]))
+ strcpy (tstr, "???");
+ tbuf += sprintf (tbuf, "lstat(%#x:\"%s\", %#x)", args[0], tstr, args[1]);
goto case_default;
case CB_SYS_pipe:
tbuf += sprintf (tbuf, "pipe(%#x, %#x)", args[0], args[1]);
--
1.7.5.rc3
next prev parent reply other threads:[~2011-05-26 19:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 19:41 [PATCH 1/2] sim: export cb_get_string for people to use Mike Frysinger
2011-05-26 19:41 ` Mike Frysinger [this message]
2011-12-03 19:05 ` [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls Mike Frysinger
2011-05-27 18:24 ` [PATCH 1/2] sim: export cb_get_string for people to use Tom Tromey
2011-05-27 18:35 ` Mike Frysinger
2011-05-28 14:56 ` [PATCH v2] " Mike Frysinger
2011-12-03 18:40 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306438878-14479-2-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
--cc=toolchain-devel@blackfin.uclinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox