aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.txt3
-rwxr-xr-xmakewrappers28
-rw-r--r--templates/wrapfuncs.c4
3 files changed, 33 insertions, 2 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index e2bd123..9b39838 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+2015-09-04:
+ * (seebs) add return value printing to wrapper debug!
+
2015-09-03:
* (seebs) Use original mode, not 0600, for the chmods used to
ensure that an 0700 umask didn't prevent writing.
diff --git a/makewrappers b/makewrappers
index 15b4274..e9191ed 100755
--- a/makewrappers
+++ b/makewrappers
@@ -195,6 +195,26 @@ class Argument:
def __repr__(self):
return self.decl()
+typedata = {
+ 'char *': { 'format': '%s', 'value': 'rc ? rc : "<nil>"' },
+ 'const char *': { 'format': '%s', 'value': 'rc ? rc : "<nil>"' },
+ 'DIR *': { 'format': '%p', 'value': '(void *) rc' },
+ 'FILE *': { 'format': '%p', 'value': '(void *) rc' },
+ 'FTS *': { 'format': '%p', 'value': '(void *) rc' },
+ 'gid_t': { 'format': '%ld', 'value': ' (long) rc' },
+ 'int': { 'format': '%d', 'value': 'rc' },
+ 'long': { 'format': '%ld', 'value': 'rc' },
+ 'mode_t': { 'format': '0%lo', 'value': '(long) rc' },
+ 'off_t': { 'format': '%lld', 'value': '(long long) rc' },
+ 'size_t': { 'format': '%lu', 'value': '(unsigned long) rc' },
+ 'ssize_t': { 'format': '%ld', 'value': '(long) rc' },
+ 'struct group *': { 'format': '%p', 'value': '(void *) rc' },
+ 'struct passwd *': { 'format': '%p', 'value': '(void *) rc' },
+ 'uid_t': { 'format': '%ld', 'value': ' (long) rc' },
+ 'void *': { 'format': '%p', 'value': 'rc' },
+ 'void': { 'format': 'void%s', 'value': '""' },
+}
+
class Function:
"""A function signature and additional data about how the function works"""
def __init__(self, port, line):
@@ -371,6 +391,14 @@ class Function:
else:
return "return rc;"
+ def rc_format(self):
+ """the format string to use for the return value"""
+ return typedata.get(self.type, { 'format': '[%s]', 'value': '"' + self.type + '"' })['format']
+
+ def rc_value(self):
+ """the value to pass for the format string for the return value"""
+ return typedata.get(self.type, { 'format': '[%s]', 'value': '"' + self.type + '"' })['value']
+
def rc_decl(self):
"""declare rc (if needed)"""
if self.type == 'void':
diff --git a/templates/wrapfuncs.c b/templates/wrapfuncs.c
index 2d13031..3859183 100644
--- a/templates/wrapfuncs.c
+++ b/templates/wrapfuncs.c
@@ -73,9 +73,9 @@ ${maybe_async_skip}
/* This can cause hangs on some recentish systems which use locale
* stuff for strerror...
*/
- pseudo_debug(PDBGF_WRAPPER, "wrapper completed: ${name} (maybe: %s)\n", strerror(save_errno));
+ pseudo_debug(PDBGF_WRAPPER, "wrapper completed: ${name} returns ${rc_format} (errno: %s)\n", ${rc_value}, strerror(save_errno));
#endif
- pseudo_debug(PDBGF_WRAPPER, "wrapper completed: ${name} (errno: %d)\n", save_errno);
+ pseudo_debug(PDBGF_WRAPPER, "wrapper completed: ${name} returns ${rc_format} (errno: %d)\n", ${rc_value}, save_errno);
errno = save_errno;
PROFILE_DONE;
${rc_return}