* [PATCH 1/2] sim: export cb_get_string for people to use @ 2011-05-26 19:41 Mike Frysinger 2011-05-26 19:41 ` [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls Mike Frysinger ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Mike Frysinger @ 2011-05-26 19:41 UTC (permalink / raw) To: gdb-patches; +Cc: toolchain-devel The common sim code provides a useful "get_string" function which reads a C string out of the target's memory space. So rename and export it for other people to use. Signed-off-by: Mike Frysinger <vapier@gentoo.org> include/gdb/: 2011-05-26 Mike Frysinger <vapier@gentoo.org> * callback.h (cb_get_string): New prototype. sim/common/: 2011-05-26 Mike Frysinger <vapier@gentoo.org> * syscall.c (cb_get_string): Rename from "get_string". (get_path): Rename get_string call to cb_get_string. --- include/gdb/callback.h | 4 ++++ sim/common/syscall.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/gdb/callback.h b/include/gdb/callback.h index 296dfc3..f888957 100644 --- a/include/gdb/callback.h +++ b/include/gdb/callback.h @@ -329,6 +329,10 @@ int cb_is_stdin (host_callback *, int); int cb_is_stdout (host_callback *, int); int cb_is_stderr (host_callback *, int); +/* Read a string out of the target. */ +int cb_get_string PARAMS ((host_callback *, CB_SYSCALL *, char *, int, + unsigned long)); + /* Perform a system call. */ CB_RC cb_syscall (host_callback *, CB_SYSCALL *); diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 28816c0..1dfe7aa 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -76,8 +76,8 @@ char *simulator_sysroot = ""; /* Utility of cb_syscall to fetch a path name or other string from the target. The result is 0 for success or a host errno value. */ -static int -get_string (cb, sc, buf, buflen, addr) +int +cb_get_string (cb, sc, buf, buflen, addr) host_callback *cb; CB_SYSCALL *sc; char *buf; @@ -121,7 +121,7 @@ get_path (cb, sc, addr, bufp) int result; int sysroot_len = strlen (simulator_sysroot); - result = get_string (cb, sc, buf, MAX_PATH_LEN - sysroot_len, addr); + result = cb_get_string (cb, sc, buf, MAX_PATH_LEN - sysroot_len, addr); if (result == 0) { /* Prepend absolute paths with simulator_sysroot. Relative paths -- 1.7.5.rc3 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls 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 2011-12-03 19:05 ` Mike Frysinger 2011-05-27 18:24 ` [PATCH 1/2] sim: export cb_get_string for people to use Tom Tromey 2011-05-28 14:56 ` [PATCH v2] " Mike Frysinger 2 siblings, 1 reply; 7+ messages in thread From: Mike Frysinger @ 2011-05-26 19:41 UTC (permalink / raw) To: gdb-patches; +Cc: toolchain-devel 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls 2011-05-26 19:41 ` [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls Mike Frysinger @ 2011-12-03 19:05 ` Mike Frysinger 0 siblings, 0 replies; 7+ messages in thread From: Mike Frysinger @ 2011-12-03 19:05 UTC (permalink / raw) To: gdb-patches; +Cc: toolchain-devel [-- Attachment #1: Type: Text/Plain, Size: 302 bytes --] On Thursday 26 May 2011 15:41:18 Mike Frysinger wrote: > 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. i've committed this now -mike [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] sim: export cb_get_string for people to use 2011-05-26 19:41 [PATCH 1/2] sim: export cb_get_string for people to use Mike Frysinger 2011-05-26 19:41 ` [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls Mike Frysinger @ 2011-05-27 18:24 ` Tom Tromey 2011-05-27 18:35 ` Mike Frysinger 2011-05-28 14:56 ` [PATCH v2] " Mike Frysinger 2 siblings, 1 reply; 7+ messages in thread From: Tom Tromey @ 2011-05-27 18:24 UTC (permalink / raw) To: Mike Frysinger; +Cc: gdb-patches, toolchain-devel >>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes: Mike> The common sim code provides a useful "get_string" function which reads Mike> a C string out of the target's memory space. So rename and export it Mike> for other people to use. I don't know enough about sim to say whether callback.h is the right place for this. I would appreciate comments on this. One nit: Mike> +int cb_get_string PARAMS ((host_callback *, CB_SYSCALL *, char *, int, Mike> + unsigned long)); Don't use PARAMS. Tom ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] sim: export cb_get_string for people to use 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 0 siblings, 0 replies; 7+ messages in thread From: Mike Frysinger @ 2011-05-27 18:35 UTC (permalink / raw) To: Tom Tromey; +Cc: toolchain-devel, gdb-patches On Fri, May 27, 2011 at 14:24, Tom Tromey wrote: > Mike> +int cb_get_string PARAMS ((host_callback *, CB_SYSCALL *, char *, int, > Mike> + unsigned long)); > > Don't use PARAMS. sorry, this was written against an older version which still uses PARAMS -mike ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] sim: export cb_get_string for people to use 2011-05-26 19:41 [PATCH 1/2] sim: export cb_get_string for people to use Mike Frysinger 2011-05-26 19:41 ` [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-28 14:56 ` Mike Frysinger 2011-12-03 18:40 ` Mike Frysinger 2 siblings, 1 reply; 7+ messages in thread From: Mike Frysinger @ 2011-05-28 14:56 UTC (permalink / raw) To: gdb-patches; +Cc: toolchain-devel The common sim code provides a useful "get_string" function which reads a C string out of the target's memory space. So rename and export it for other people to use. Signed-off-by: Mike Frysinger <vapier@gentoo.org> include/gdb/: 2011-05-26 Mike Frysinger <vapier@gentoo.org> * callback.h (cb_get_string): New prototype. sim/common/: 2011-05-26 Mike Frysinger <vapier@gentoo.org> * syscall.c (cb_get_string): Rename from "get_string". (get_path): Rename get_string call to cb_get_string. --- v2 - drop PARAMS include/gdb/callback.h | 3 +++ sim/common/syscall.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/gdb/callback.h b/include/gdb/callback.h index 296dfc3..6ffb56e 100644 --- a/include/gdb/callback.h +++ b/include/gdb/callback.h @@ -329,6 +329,9 @@ int cb_is_stdin (host_callback *, int); int cb_is_stdout (host_callback *, int); int cb_is_stderr (host_callback *, int); +/* Read a string out of the target. */ +int cb_get_string (host_callback *, CB_SYSCALL *, char *, int, unsigned long); + /* Perform a system call. */ CB_RC cb_syscall (host_callback *, CB_SYSCALL *); diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 28816c0..1dfe7aa 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -76,8 +76,8 @@ char *simulator_sysroot = ""; /* Utility of cb_syscall to fetch a path name or other string from the target. The result is 0 for success or a host errno value. */ -static int -get_string (cb, sc, buf, buflen, addr) +int +cb_get_string (cb, sc, buf, buflen, addr) host_callback *cb; CB_SYSCALL *sc; char *buf; @@ -121,7 +121,7 @@ get_path (cb, sc, addr, bufp) int result; int sysroot_len = strlen (simulator_sysroot); - result = get_string (cb, sc, buf, MAX_PATH_LEN - sysroot_len, addr); + result = cb_get_string (cb, sc, buf, MAX_PATH_LEN - sysroot_len, addr); if (result == 0) { /* Prepend absolute paths with simulator_sysroot. Relative paths -- 1.7.5.rc3 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] sim: export cb_get_string for people to use 2011-05-28 14:56 ` [PATCH v2] " Mike Frysinger @ 2011-12-03 18:40 ` Mike Frysinger 0 siblings, 0 replies; 7+ messages in thread From: Mike Frysinger @ 2011-12-03 18:40 UTC (permalink / raw) To: gdb-patches; +Cc: toolchain-devel [-- Attachment #1: Type: Text/Plain, Size: 259 bytes --] On Saturday 28 May 2011 11:00:45 Mike Frysinger wrote: > The common sim code provides a useful "get_string" function which reads > a C string out of the target's memory space. So rename and export it > for other people to use. i've committed this now -mike [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-12-03 19:05 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-05-26 19:41 [PATCH 1/2] sim: export cb_get_string for people to use Mike Frysinger 2011-05-26 19:41 ` [PATCH 2/2] sim: bfin: lookup target strings when tracing system calls Mike Frysinger 2011-12-03 19:05 ` 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).