]> sourceware.org Git - systemtap.git/commitdiff
PR10589: switch to kernel vscnprintf for _stp_{dbug,warn,error} calls in runtime
authorFrank Ch. Eigler <fche@elastic.org>
Wed, 2 Sep 2009 16:01:27 +0000 (12:01 -0400)
committerFrank Ch. Eigler <fche@elastic.org>
Wed, 2 Sep 2009 16:01:27 +0000 (12:01 -0400)
_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.

runtime/io.c
runtime/runtime.h
runtime/sym.c
runtime/unwind.c
translate.cxx

index 8ddb53acdb6ce3c3a5711270877cde88d7338585..687926fd8d39ec48d3d6fcbc014d16cef650d2d0 100644 (file)
@@ -22,6 +22,9 @@
 #define ERR_STRING "ERROR: "
 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;
@@ -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';
index c3bf501dc087a7884fd3fda4d515e47b232bbfe8..064ded7b295b3a835e83057b74b3db57f06d3482 100644 (file)
@@ -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);
 
index 30b6fc5acb6f25fda0e1905df08f0fae5d4aff70..dd2235cce63e81126b1425749a22589df9715092 100644 (file)
@@ -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 */
index cf0bc2f36433e2c4e3cef09f0498bb067a4496f9..00108a39168cf34f2e39fcdf4bccfd93dbefe4a1 100644 (file)
@@ -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)
index 56d6de4c499b03dc3dde6ff5b3cc5107a71a8a4e..65acd2cab8c7511d87d88958284788a71ebaf796 100644 (file)
@@ -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) << "}";
This page took 0.038565 seconds and 5 git commands to generate.