summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2009-09-02 12:01:27 -0400
committerFrank Ch. Eigler <fche@elastic.org>2009-09-02 12:01:27 -0400
commite66aaecc057ef417d0dd1d0b94454f6704147e7f (patch)
tree9eb27159000da1d759c4b12c9af4cb04ebc9abed
parentcce3b4efd1f1401246f1e1301040414db00891fa (diff)
downloadsystemtap-steved-e66aaecc057ef417d0dd1d0b94454f6704147e7f.tar.gz
systemtap-steved-e66aaecc057ef417d0dd1d0b94454f6704147e7f.tar.xz
systemtap-steved-e66aaecc057ef417d0dd1d0b94454f6704147e7f.zip
PR10589: switch to kernel vscnprintf for _stp_{dbug,warn,error} calls in runtime
_stp_vscnprintf is only suitable for calls from the script, with slightly different conventions (64-bit ints/pointers, extra formatting directives). * runtime/runtime.h (_stp_{dbug,warn,error}): Add __attribute__ format(printf). * runtime/io.c (_stp_vlog): Ditto. Use vscnprintf(). * runtime/sym.c (_stp_module_check): Remove hexdumping (%.*M) of mismatching buildids. Switch to _stp_warn from printk (KERN_WARNING). * translate.cxx, runtime/unwind.c: Numerous print formatting tweaks.
-rw-r--r--runtime/io.c5
-rw-r--r--runtime/runtime.h6
-rw-r--r--runtime/sym.c14
-rw-r--r--runtime/unwind.c18
-rw-r--r--translate.cxx2
5 files changed, 24 insertions, 21 deletions
diff --git a/runtime/io.c b/runtime/io.c
index 8ddb53ac..687926fd 100644
--- a/runtime/io.c
+++ b/runtime/io.c
@@ -23,6 +23,9 @@
enum code { INFO=0, WARN, ERROR, DBUG };
static void _stp_vlog (enum code type, const char *func, int line, const char *fmt, va_list args)
+ __attribute ((format (printf, 4, 0)));
+
+static void _stp_vlog (enum code type, const char *func, int line, const char *fmt, va_list args)
{
int num;
char *buf = per_cpu_ptr(Stp_lbuf, get_cpu());
@@ -38,7 +41,7 @@ static void _stp_vlog (enum code type, const char *func, int line, const char *f
start = sizeof(ERR_STRING) - 1;
}
- num = _stp_vscnprintf (buf + start, STP_LOG_BUF_LEN - start - 1, fmt, args);
+ num = vscnprintf (buf + start, STP_LOG_BUF_LEN - start - 1, fmt, args);
if (num + start) {
if (buf[num + start - 1] != '\n') {
buf[num + start] = '\n';
diff --git a/runtime/runtime.h b/runtime/runtime.h
index c3bf501d..064ded7b 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -48,9 +48,9 @@
#define stp_for_each_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
#endif
-static void _stp_dbug (const char *func, int line, const char *fmt, ...);
-static void _stp_error (const char *fmt, ...);
-static void _stp_warn (const char *fmt, ...);
+static void _stp_dbug (const char *func, int line, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
+static void _stp_error (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+static void _stp_warn (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
static void _stp_exit(void);
diff --git a/runtime/sym.c b/runtime/sym.c
index 30b6fc5a..dd2235cc 100644
--- a/runtime/sym.c
+++ b/runtime/sym.c
@@ -276,24 +276,22 @@ static int _stp_module_check(void)
continue;
if (memcmp(m->build_id_bits, (unsigned char*) notes_addr, m->build_id_len)) {
const char *basename;
-
basename = strrchr(m->path, '/');
if (basename)
basename++;
else
basename = m->path;
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
- _stp_error ("Build-id mismatch: \"%s\" %.*M"
- " vs. \"%s\" %.*M\n",
- m->name, m->build_id_len, notes_addr,
- basename, m->build_id_len, m->build_id_bits);
+ _stp_error ("Build-id mismatch: \"%s\" vs. \"%s\"\n",
+ m->name, basename);
return 1;
#else
/* This branch is a surrogate for kernels
* affected by Fedora bug #465873. */
- printk(KERN_WARNING
- "Build-id mismatch: \"%s\" vs. \"%s\"\n",
- m->name, basename);
+ _stp_warn (KERN_WARNING
+ "Build-id mismatch: \"%s\" vs. \"%s\"\n",
+ m->name, basename);
#endif
}
} /* end checking */
diff --git a/runtime/unwind.c b/runtime/unwind.c
index cf0bc2f3..00108a39 100644
--- a/runtime/unwind.c
+++ b/runtime/unwind.c
@@ -121,7 +121,7 @@ static const u32 *cie_for_fde(const u32 *fde, void *unwind_data,
if (*cie <= sizeof(*cie) + 4 || *cie >= fde[1] - sizeof(*fde)
|| (*cie & (sizeof(*cie) - 1))
|| (cie[1] != 0xffffffff && cie[1] != 0)) {
- dbug_unwind(1, "cie is not valid %lx %x %x %x\n", cie, *cie, fde[1], cie[1]);
+ dbug_unwind(1, "cie is not valid %lx %x %x %x\n", (unsigned long)cie, *cie, fde[1], cie[1]);
return NULL; /* this is not a (valid) CIE */
}
@@ -260,7 +260,7 @@ static int advance_loc(unsigned long delta, struct unwind_state *state)
static void set_rule(uleb128_t reg, enum item_location where, uleb128_t value, struct unwind_state *state)
{
- dbug_unwind(1, "reg=%d, where=%d, value=%lx\n", reg, where, value);
+ dbug_unwind(1, "reg=%lx, where=%d, value=%lx\n", reg, where, value);
if (reg < ARRAY_SIZE(state->regs)) {
state->regs[reg].where = where;
state->regs[reg].value = value;
@@ -556,7 +556,7 @@ static u32 *_stp_search_unwind_hdr(unsigned long pc,
num = read_pointer(&ptr, end, hdr[2]);
if (num == 0 || num != (end - ptr) / (2 * tableSize) || (end - ptr) % (2 * tableSize)) {
- dbug_unwind(1, "Bad num=%d end-ptr=%ld 2*tableSize=%d", num, end - ptr, 2 * tableSize);
+ dbug_unwind(1, "Bad num=%d end-ptr=%ld 2*tableSize=%d", num, (long)(end - ptr), 2 * tableSize);
return NULL;
}
@@ -575,7 +575,7 @@ static u32 *_stp_search_unwind_hdr(unsigned long pc,
if (num == 1 && (startLoc = adjustStartLoc(read_pointer(&ptr, ptr + tableSize, hdr[3]), m, s, hdr[3], 1)) != 0 && pc >= startLoc)
fde = (void *)read_pointer(&ptr, ptr + tableSize, hdr[3]);
- dbug_unwind(1, "returning fde=%lx startLoc=%lx", fde, startLoc);
+ dbug_unwind(1, "returning fde=%lx startLoc=%lx", (unsigned long) fde, startLoc);
return fde;
}
@@ -602,7 +602,7 @@ static int unwind_frame(struct unwind_frame_info *frame,
}
fde = _stp_search_unwind_hdr(pc, m, s);
- dbug_unwind(1, "%s: fde=%lx\n", m->name, fde);
+ dbug_unwind(1, "%s: fde=%lx\n", m->name, (unsigned long) fde);
/* found the fde, now set startLoc and endLoc */
if (fde != NULL) {
@@ -655,7 +655,8 @@ static int unwind_frame(struct unwind_frame_info *frame,
}
}
- dbug_unwind(1, "cie=%lx fde=%lx startLoc=%lx endLoc=%lx, pc=%lx\n", cie, fde, startLoc, endLoc, pc);
+ dbug_unwind(1, "cie=%lx fde=%lx startLoc=%lx endLoc=%lx, pc=%lx\n",
+ (unsigned long) cie, (unsigned long)fde, (unsigned long) startLoc, (unsigned long) endLoc, pc);
if (cie == NULL || fde == NULL)
goto err;
@@ -750,14 +751,15 @@ static int unwind_frame(struct unwind_frame_info *frame,
if (STACK_LIMIT(startLoc) != STACK_LIMIT(endLoc)) {
startLoc = min(STACK_LIMIT(cfa), cfa);
endLoc = max(STACK_LIMIT(cfa), cfa);
- dbug_unwind(1, "cfa startLoc=%p, endLoc=%p\n", (u64)startLoc, (u64)endLoc);
+ dbug_unwind(1, "cfa startLoc=%lx, endLoc=%lx\n",
+ (unsigned long)startLoc, (unsigned long)endLoc);
}
#ifndef CONFIG_64BIT
# define CASES CASE(8); CASE(16); CASE(32)
#else
# define CASES CASE(8); CASE(16); CASE(32); CASE(64)
#endif
- dbug_unwind(1, "cie=%lx fde=%lx\n", cie, fde);
+ dbug_unwind(1, "cie=%lx fde=%lx\n", (unsigned long) cie, (unsigned long) fde);
for (i = 0; i < ARRAY_SIZE(state.regs); ++i) {
if (REG_INVALID(i)) {
if (state.regs[i].where == Nowhere)
diff --git a/translate.cxx b/translate.cxx
index 56d6de4c..65acd2ca 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -1189,7 +1189,7 @@ c_unparser::emit_module_init ()
o->newline() << "if (sizeof (struct context) <= 131072)";
o->newline(1) << "contexts = alloc_percpu (struct context);";
o->newline(-1) << "if (contexts == NULL) {";
- o->newline(1) << "_stp_error (\"percpu context (size %lu) allocation failed\", sizeof (struct context));";
+ o->newline(1) << "_stp_error (\"percpu context (size %lu) allocation failed\", (unsigned long) sizeof (struct context));";
o->newline() << "rc = -ENOMEM;";
o->newline() << "goto out;";
o->newline(-1) << "}";