]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: add debug messages
authorKarel Zak <kzak@redhat.com>
Fri, 6 Jun 2014 11:47:06 +0000 (13:47 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 6 Jun 2014 11:47:06 +0000 (13:47 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
17 files changed:
disk-utils/cfdisk.c
disk-utils/partx.c
libsmartcols/src/cell.c
libsmartcols/src/column.c
libsmartcols/src/line.c
libsmartcols/src/smartcolsP.h
libsmartcols/src/table.c
libsmartcols/src/table_print.c
login-utils/lslogins.c
misc-utils/findmnt.c
misc-utils/lsblk.c
misc-utils/lslocks.c
sys-utils/losetup.c
sys-utils/lscpu.c
sys-utils/prlimit.c
sys-utils/swapon.c
sys-utils/wdctl.c

index b0185092a2cc2432514181ada4d69bd0d2b9f61e..bf49cf25772148f44b56c94a1ab286b804047fbb 100644 (file)
@@ -1981,6 +1981,8 @@ int main(int argc, char *argv[])
        colors_init(colormode, "cfdisk");
 
        fdisk_init_debug(0);
+       scols_init_debug(0);
+
        cf->cxt = fdisk_new_context();
        if (!cf->cxt)
                err(EXIT_FAILURE, _("failed to allocate libfdisk context"));
index 830af1f321653d2671f78b9725238560503f3613..bf5a4abf7eb8055cea2bea7c83a587c00ca4e0d9 100644 (file)
@@ -626,6 +626,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
        if (!nparts)
                return 0;
 
+       scols_init_debug(0);
        table = scols_new_table();
        if (!table) {
                warn(_("failed to initialize output table"));
index 2cc93c2967ed95d612223ad350efeca6caf62ae9..c05ceb81297acb6f8963a2d3ef7f116888491ef0 100644 (file)
@@ -46,6 +46,7 @@ int scols_reset_cell(struct libscols_cell *ce)
        if (!ce)
                return -EINVAL;
 
+       /*DBG(CELL, ul_debugobj(ce, "reset"));*/
        free(ce->data);
        free(ce->color);
        memset(ce, 0, sizeof(*ce));
@@ -241,5 +242,7 @@ int scols_cell_copy_content(struct libscols_cell *dest,
                rc = scols_cell_set_color(dest, scols_cell_get_color(src));
        if (!rc)
                dest->userdata = src->userdata;
+
+       DBG(CELL, ul_debugobj((void *) src, "copy into %p", dest));
        return rc;
 }
index 130a729e2556325d841d955b1000b5a34ab0ae46..7ba284c6e00f44aa1c7fe17c15216e8a3cfd5d50 100644 (file)
@@ -38,7 +38,7 @@ struct libscols_column *scols_new_column(void)
        cl = calloc(1, sizeof(*cl));
        if (!cl)
                return NULL;
-
+       DBG(COL, ul_debugobj(cl, "alloc"));
        cl->refcount = 1;
        INIT_LIST_HEAD(&cl->cl_columns);
        return cl;
@@ -65,6 +65,7 @@ void scols_ref_column(struct libscols_column *cl)
 void scols_unref_column(struct libscols_column *cl)
 {
        if (cl && --cl->refcount <= 0) {
+               DBG(COL, ul_debugobj(cl, "dealloc"));
                list_del(&cl->cl_columns);
                scols_reset_cell(&cl->header);
                free(cl->color);
@@ -76,7 +77,7 @@ void scols_unref_column(struct libscols_column *cl)
  * scols_copy_column:
  * @cl: a pointer to a struct libscols_column instance
  *
- * Creates a new column and copies @cl's data over to it. 
+ * Creates a new column and copies @cl's data over to it.
  *
  * Returns: a pointer to a new struct libscols_column instance.
  */
@@ -91,6 +92,8 @@ struct libscols_column *scols_copy_column(const struct libscols_column *cl)
        if (!ret)
                return NULL;
 
+       DBG(COL, ul_debugobj((void *) cl, "copy to %p", ret));
+
        if (scols_column_set_color(ret, cl->color))
                goto err;
        if (scols_cell_copy_content(&ret->header, &cl->header))
index 6112090819a488600af2ce5c4887b99158aac5ff..0ed765dcdf2c459f21027323f5890bc5a77e40e0 100644 (file)
@@ -41,6 +41,8 @@ struct libscols_line *scols_new_line(void)
        ln = calloc(1, sizeof(*ln));
        if (!ln)
                return NULL;
+
+       DBG(LINE, ul_debugobj(ln, "alloc"));
        ln->refcount = 1;
        INIT_LIST_HEAD(&ln->ln_lines);
        INIT_LIST_HEAD(&ln->ln_children);
@@ -70,9 +72,9 @@ void scols_unref_line(struct libscols_line *ln)
 {
 
        if (ln && --ln->refcount <= 0) {
+               DBG(CELL, ul_debugobj(ln, "dealloc"));
                list_del(&ln->ln_lines);
                list_del(&ln->ln_children);
-
                scols_line_free_cells(ln);
                free(ln->color);
                free(ln);
@@ -93,6 +95,8 @@ void scols_line_free_cells(struct libscols_line *ln)
        if (!ln || !ln->cells)
                return;
 
+       DBG(LINE, ul_debugobj(ln, "free cells"));
+
        for (i = 0; i < ln->ncells; i++)
                scols_reset_cell(&ln->cells[i]);
 
@@ -129,6 +133,8 @@ int scols_line_alloc_cells(struct libscols_line *ln, size_t n)
                return 0;
        }
 
+       DBG(LINE, ul_debugobj(ln, "alloc %zu cells", n));
+
        ce = realloc(ln->cells, n * sizeof(struct libscols_cell));
        if (!ce)
                return -errno;
@@ -188,6 +194,9 @@ int scols_line_remove_child(struct libscols_line *ln, struct libscols_line *chil
 
        if (!ln || !child)
                return -EINVAL;
+
+       DBG(LINE, ul_debugobj(ln, "remove child %p", child));
+
        list_del_init(&child->ln_children);
        scols_unref_line(child);
 
@@ -217,6 +226,8 @@ int scols_line_add_child(struct libscols_line *ln, struct libscols_line *child)
        if (child->parent)
                scols_line_remove_child(child->parent, child);
 
+       DBG(LINE, ul_debugobj(ln, "add child %p", child));
+
        /* new reference from parent to child */
        list_add_tail(&child->ln_children, &ln->ln_branch);
        scols_ref_line(child);
@@ -434,6 +445,8 @@ struct libscols_line *scols_copy_line(struct libscols_line *ln)
        ret->ncells   = ln->ncells;
        ret->seqnum   = ln->seqnum;
 
+       DBG(LINE, ul_debugobj(ln, "copy to %p", ret));
+
        for (i = 0; i < ret->ncells; ++i) {
                if (scols_cell_copy_content(&ret->cells[i], &ln->cells[i]))
                        goto err;
index 613ddd5871667e954a30fc9114bb12d16441104a..28246c14f7ba4f110b5d0f00a349c68c9eb9a6d3 100644 (file)
  * Debug
  */
 #define SCOLS_DEBUG_INIT       (1 << 1)
+#define SCOLS_DEBUG_CELL       (1 << 2)
+#define SCOLS_DEBUG_LINE       (1 << 3)
+#define SCOLS_DEBUG_TAB                (1 << 4)
+#define SCOLS_DEBUG_COL                (1 << 5)
+#define SCOLS_DEBUG_BUFF       (1 << 6)
 #define SCOLS_DEBUG_ALL                0xFFFF
 
 UL_DEBUG_DECLARE_MASK(libsmartcols);
index a51a84abcb65e966cafaa27d1be20e5f7c4f3b9d..53590038aaf9456ef11fb37f0efab3f46b8cbf56 100644 (file)
@@ -57,6 +57,7 @@ struct libscols_table *scols_new_table(void)
        INIT_LIST_HEAD(&tb->tb_lines);
        INIT_LIST_HEAD(&tb->tb_columns);
 
+       DBG(TAB, ul_debugobj(tb, "alloc"));
        return tb;
 }
 
@@ -81,6 +82,7 @@ void scols_ref_table(struct libscols_table *tb)
 void scols_unref_table(struct libscols_table *tb)
 {
        if (tb && (--tb->refcount <= 0)) {
+               DBG(TAB, ul_debugobj(tb, "dealloc"));
                scols_table_remove_lines(tb);
                scols_table_remove_columns(tb);
                scols_unref_symbols(tb->symbols);
@@ -110,6 +112,7 @@ int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl
        if (cl->flags & SCOLS_FL_TREE)
                tb->ntreecols++;
 
+       DBG(TAB, ul_debugobj(tb, "add column %p", cl));
        list_add_tail(&cl->cl_columns, &tb->tb_columns);
        cl->seqnum = tb->ncols++;
        scols_ref_column(cl);
@@ -144,6 +147,7 @@ int scols_table_remove_column(struct libscols_table *tb,
        if (cl->flags & SCOLS_FL_TREE)
                tb->ntreecols--;
 
+       DBG(TAB, ul_debugobj(tb, "remove column %p", cl));
        list_del_init(&cl->cl_columns);
        tb->ncols--;
        scols_unref_column(cl);
@@ -165,6 +169,7 @@ int scols_table_remove_columns(struct libscols_table *tb)
        if (!tb || !list_empty(&tb->tb_lines))
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "remove all columns"));
        while (!list_empty(&tb->tb_columns)) {
                struct libscols_column *cl = list_entry(tb->tb_columns.next,
                                        struct libscols_column, cl_columns);
@@ -219,6 +224,9 @@ struct libscols_column *scols_table_new_column(struct libscols_table *tb,
        assert (tb);
        if (!tb)
                return NULL;
+
+       DBG(TAB, ul_debugobj(tb, "new column name=%s, whint=%g, flags=%d",
+                               name, whint, flags));
        cl = scols_new_column();
        if (!cl)
                return NULL;
@@ -313,6 +321,7 @@ int scols_table_set_stream(struct libscols_table *tb, FILE *stream)
        if (!tb)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "setting alternative stream"));
        tb->out = stream;
        return 0;
 }
@@ -346,6 +355,7 @@ int scols_table_reduce_termwidth(struct libscols_table *tb, size_t reduce)
        if (!tb)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "reduce terminal width: %zu", reduce));
        tb->termreduce = reduce;
        return 0;
 }
@@ -402,6 +412,7 @@ int scols_table_add_line(struct libscols_table *tb, struct libscols_line *ln)
                        return rc;
        }
 
+       DBG(TAB, ul_debugobj(tb, "add line %p", ln));
        list_add_tail(&ln->ln_lines, &tb->tb_lines);
        ln->seqnum = tb->nlines++;
        scols_ref_line(ln);
@@ -427,6 +438,7 @@ int scols_table_remove_line(struct libscols_table *tb,
        if (!tb || !ln)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "remove line %p", ln));
        list_del_init(&ln->ln_lines);
        tb->nlines--;
        scols_unref_line(ln);
@@ -445,6 +457,7 @@ void scols_table_remove_lines(struct libscols_table *tb)
        if (!tb)
                return;
 
+       DBG(TAB, ul_debugobj(tb, "remove all lines"));
        while (!list_empty(&tb->tb_lines)) {
                struct libscols_line *ln = list_entry(tb->tb_lines.next,
                                                struct libscols_line, ln_lines);
@@ -508,6 +521,7 @@ struct libscols_line *scols_table_new_line(struct libscols_table *tb,
 
        if (!tb || !tb->ncols)
                return NULL;
+
        ln = scols_new_line();
        if (!ln)
                return NULL;
@@ -580,6 +594,8 @@ struct libscols_table *scols_copy_table(struct libscols_table *tb)
        if (!ret)
                return NULL;
 
+       DBG(TAB, ul_debugobj(tb, "copy into %p", ret));
+
        if (tb->symbols)
                scols_table_set_symbols(ret, tb->symbols);
 
@@ -642,6 +658,8 @@ int scols_table_set_symbols(struct libscols_table *tb,
        if (!tb)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "setting alternative symbols %p", sy));
+
        if (tb->symbols)                                /* unref old */
                scols_unref_symbols(tb->symbols);
        if (sy) {                                       /* ref user defined */
@@ -682,6 +700,8 @@ int scols_table_enable_colors(struct libscols_table *tb, int enable)
        assert(tb);
        if (!tb)
                return -EINVAL;
+
+       DBG(TAB, ul_debugobj(tb, "colors: %s", enable ? "ENABLE" : "DISABLE"));
        tb->colors_wanted = enable;
        return 0;
 }
@@ -701,6 +721,7 @@ int scols_table_enable_raw(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "raw: %s", enable ? "ENABLE" : "DISABLE"));
        if (enable)
                tb->format = SCOLS_FMT_RAW;
        else if (tb->format == SCOLS_FMT_RAW)
@@ -723,6 +744,8 @@ int scols_table_enable_export(struct libscols_table *tb, int enable)
        assert(tb);
        if (!tb)
                return -EINVAL;
+
+       DBG(TAB, ul_debugobj(tb, "export: %s", enable ? "ENABLE" : "DISABLE"));
        if (enable)
                tb->format = SCOLS_FMT_EXPORT;
        else if (tb->format == SCOLS_FMT_EXPORT)
@@ -750,6 +773,8 @@ int scols_table_enable_ascii(struct libscols_table *tb, int enable)
        assert(tb);
        if (!tb)
                return -EINVAL;
+
+       DBG(TAB, ul_debugobj(tb, "ascii: %s", enable ? "ENABLE" : "DISABLE"));
        tb->ascii = enable ? 1 : 0;
        return 0;
 }
@@ -768,6 +793,7 @@ int scols_table_enable_noheadings(struct libscols_table *tb, int enable)
        assert(tb);
        if (!tb)
                return -EINVAL;
+       DBG(TAB, ul_debugobj(tb, "noheading: %s", enable ? "ENABLE" : "DISABLE"));
        tb->no_headings = enable ? 1 : 0;
        return 0;
 }
@@ -787,6 +813,7 @@ int scols_table_enable_maxout(struct libscols_table *tb, int enable)
        assert(tb);
        if (!tb)
                return -EINVAL;
+       DBG(TAB, ul_debugobj(tb, "maxout: %s", enable ? "ENABLE" : "DISABLE"));
        tb->maxout = enable ? 1 : 0;
        return 0;
 }
@@ -913,6 +940,7 @@ int scols_table_set_column_separator(struct libscols_table *tb, const char *sep)
                        return -ENOMEM;
        }
 
+       DBG(TAB, ul_debugobj(tb, "new columns separator: %s", sep));
        free(tb->colsep);
        tb->colsep = p;
        return 0;
@@ -942,6 +970,7 @@ int scols_table_set_line_separator(struct libscols_table *tb, const char *sep)
                        return -ENOMEM;
        }
 
+       DBG(TAB, ul_debugobj(tb, "new lines separator: %s", sep));
        free(tb->linesep);
        tb->linesep = p;
        return 0;
@@ -1013,6 +1042,7 @@ int scols_sort_table(struct libscols_table *tb, struct libscols_column *cl)
        if (!tb || !cl)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "sorting table"));
        list_sort(&tb->tb_lines, cells_cmp_wrapper, cl);
        return 0;
 }
index 24b73f942d50172d791287b7c8c9221b391d9095..c9f3d8f4b042c202c4e338f8db4ef50b38b71973 100644 (file)
@@ -48,11 +48,16 @@ static struct libscols_buffer *new_buffer(size_t sz)
        buf->cur = buf->begin = ((char *) buf) + sizeof(struct libscols_buffer);
        buf->encdata = NULL;
        buf->bufsz = sz;
+
+       DBG(BUFF, ul_debugobj(buf, "alloc (size=%zu)", sz));
        return buf;
 }
 
 static void free_buffer(struct libscols_buffer *buf)
 {
+       if (!buf)
+               return;
+       DBG(BUFF, ul_debugobj(buf, "dealloc"));
        free(buf->encdata);
        free(buf);
 }
@@ -62,6 +67,7 @@ static int buffer_reset_data(struct libscols_buffer *buf)
        if (!buf)
                return -EINVAL;
 
+       /*DBG(BUFF, ul_debugobj(buf, "reset data"));*/
        buf->begin[0] = '\0';
        buf->cur = buf->begin;
        buf->art_idx = 0;
@@ -97,8 +103,10 @@ static int buffer_set_data(struct libscols_buffer *buf, const char *str)
 /* save the current buffer possition to art_idx */
 static void buffer_set_art_index(struct libscols_buffer *buf)
 {
-       if (buf)
+       if (buf) {
                buf->art_idx = buf->cur - buf->begin;
+               /*DBG(BUFF, ul_debugobj(buf, "art index: %zu", buf->art_idx));*/
+       }
 }
 
 static char *buffer_get_data(struct libscols_buffer *buf)
@@ -162,6 +170,10 @@ static int print_data(struct libscols_table *tb,
        assert(tb);
        assert(cl);
 
+       DBG(TAB, ul_debugobj(tb,
+                       " -> data, column=%p, line=%p, cell=%p, buff=%p",
+                       cl, ln, ce, buf));
+
        data = buffer_get_data(buf);
        if (!data)
                data = "";
@@ -340,6 +352,8 @@ static int print_line(struct libscols_table *tb,
 
        assert(ln);
 
+       DBG(TAB, ul_debugobj(tb, "printing line, line=%p, buff=%p", ln, buf));
+
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
        while (rc == 0 && scols_table_next_column(tb, &itr, &cl) == 0) {
                rc = cell_to_buffer(tb, ln, cl, buf);
@@ -367,6 +381,8 @@ static int print_header(struct libscols_table *tb, struct libscols_buffer *buf)
            list_empty(&tb->tb_lines))
                return 0;
 
+       DBG(TAB, ul_debugobj(tb, "printing header"));
+
        /* set width according to the size of data
         */
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -431,6 +447,8 @@ static int print_tree(struct libscols_table *tb, struct libscols_buffer *buf)
 
        assert(tb);
 
+       DBG(TAB, ul_debugobj(tb, "printing tree"));
+
        rc = print_header(tb, buf);
 
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -443,6 +461,31 @@ static int print_tree(struct libscols_table *tb, struct libscols_buffer *buf)
        return rc;
 }
 
+static void dbg_column(struct libscols_table *tb, struct libscols_column *cl)
+{
+       DBG(COL, ul_debugobj(cl, "%15s seq=%zu, width=%zd, "
+                                "hint=%d, avg=%zu, max=%zu, min=%zu, "
+                                "extreme=%s",
+
+               cl->header.data, cl->seqnum, cl->width,
+               cl->width_hint > 1 ? (int) cl->width_hint :
+                                    (int) (cl->width_hint * tb->termwidth),
+               cl->width_avg,
+               cl->width_max,
+               cl->width_min,
+               cl->is_extreme ? "yes" : "not"));
+}
+
+static void dbg_columns(struct libscols_table *tb)
+{
+       struct libscols_iter itr;
+       struct libscols_column *cl;
+
+       scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
+       while (scols_table_next_column(tb, &itr, &cl) == 0)
+               dbg_column(tb, cl);
+}
+
 /*
  * This function counts column width.
  *
@@ -514,9 +557,11 @@ static int count_column_width(struct libscols_table *tb,
 
                cl->width = (size_t) cl->width_hint;
 
+       ON_DBG(COL, dbg_column(tb, cl));
        return rc;
 }
 
+
 /*
  * This is core of the scols_* voodo...
  */
@@ -528,6 +573,9 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
        int trunc_only, rc = 0;
        int extremes = 0;
 
+
+       DBG(TAB, ul_debugobj(tb, "recounting widths (termwidth=%zu)", tb->termwidth));
+
        /* set basic columns width
         */
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -546,6 +594,8 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
        /* reduce columns with extreme fields
         */
        if (width > tb->termwidth && extremes) {
+               DBG(TAB, ul_debugobj(tb, "   reduce width (extreme columns)"));
+
                scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
                while (scols_table_next_column(tb, &itr, &cl) == 0) {
                        size_t org_width;
@@ -566,9 +616,9 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
        }
 
        if (width < tb->termwidth) {
-               /* try to found extreme column which fits into available space
-                */
                if (extremes) {
+                       DBG(TAB, ul_debugobj(tb, "   enlarge width (extreme columns)"));
+
                        /* enlarge the first extreme column */
                        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
                        while (scols_table_next_column(tb, &itr, &cl) == 0) {
@@ -596,6 +646,8 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
                }
 
                if (width < tb->termwidth && scols_table_is_maxout(tb)) {
+                       DBG(TAB, ul_debugobj(tb, "   enlarge width (max-out)"));
+
                        /* try enlarge all columns */
                        while (width < tb->termwidth) {
                                scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -611,6 +663,8 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
                        struct libscols_column *cl = list_entry(
                                tb->tb_columns.prev, struct libscols_column, cl_columns);
 
+                       DBG(TAB, ul_debugobj(tb, "   enlarge width (last column)"));
+
                        if (!scols_column_is_right(cl) && tb->termwidth - width > 0) {
                                cl->width += tb->termwidth - width;
                                width = tb->termwidth;
@@ -626,6 +680,11 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
        while (width > tb->termwidth) {
                size_t org = width;
 
+               DBG(TAB, ul_debugobj(tb, "   reduce width (current=%zu, "
+                                        "wanted=%zu, mode=%s)",
+                                       width, tb->termwidth,
+                                       trunc_only ? "trunc-only" : "all-relative"));
+
                scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
                while (scols_table_next_column(tb, &itr, &cl) == 0) {
                        if (width <= tb->termwidth)
@@ -661,20 +720,9 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
                }
        }
 
-/*
-       fprintf(stderr, "terminal: %d, output: %d\n", tb->termwidth, width);
+       DBG(TAB, ul_debugobj(tb, "  result: %zu", width));
+       ON_DBG(TAB, dbg_columns(tb));
 
-       scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
-       while (scols_table_next_column(tb, &itr, &cl) == 0) {
-               fprintf(stderr, "width: %s=%zd [hint=%d, avg=%zd, max=%zd, extreme=%s]\n",
-                       cl->name, cl->width,
-                       cl->width_hint > 1 ? (int) cl->width_hint :
-                                            (int) (cl->width_hint * tb->termwidth),
-                       cl->width_avg,
-                       cl->width_max,
-                       cl->is_extreme ? "yes" : "not");
-       }
-*/
        return rc;
 }
 
@@ -716,6 +764,7 @@ int scols_print_table(struct libscols_table *tb)
        if (!tb)
                return -1;
 
+       DBG(TAB, ul_debugobj(tb, "printing"));
        if (!tb->symbols)
                scols_table_set_symbols(tb, NULL);      /* use default */
 
@@ -773,6 +822,8 @@ int scols_print_table_to_string(struct libscols_table *tb, char **data)
        if (!tb)
                return -EINVAL;
 
+       DBG(TAB, ul_debugobj(tb, "printing to string"));
+
        /* create a stream for output */
        stream = open_memstream(data, &sz);
        if (!stream)
index d869a23ef21a09b37dd8776dc6a7abeb88902fba..09cded7737606a68a5fe85a58ea1cd848cbc49d4 100644 (file)
@@ -1384,6 +1384,8 @@ int main(int argc, char *argv[])
        } else if (argc != optind)
                usage(stderr);
 
+       scols_init_debug(0);
+
        /* lslogins -u -s == lslogins */
        if (lslogins_flag & F_USRAC && lslogins_flag & F_SYSAC)
                lslogins_flag &= ~(F_USRAC | F_SYSAC);
index 3386061cb6a5183ba257826c4c7bfda78815db03..16250ae649d79c8e859e0bb4c0bc1779f14a4790 100644 (file)
@@ -1443,6 +1443,7 @@ int main(int argc, char *argv[])
         * initialize libmount
         */
        mnt_init_debug(0);
+       scols_init_debug(0);
 
        tb = parse_tabfiles(tabfiles, ntabfiles, tabtype);
        if (!tb)
index 2eac8b80ae6d3a611fca6bfb231032f57d940abc..688ee6dea4ac37768dbfde27a581951ec2acfb7e 100644 (file)
@@ -1697,6 +1697,7 @@ int main(int argc, char *argv[])
                errx(EXIT_FAILURE, _("the sort column has to be between output columns."));
 
        mnt_init_debug(0);
+       scols_init_debug(0);
 
        /*
         * initialize output columns
index 1495bd4d658d74f7ff939c7fcaa52f8cb68b28df..1e5dbd930e0e6142b166872365a07b380d4ddcc5 100644 (file)
@@ -594,6 +594,8 @@ int main(int argc, char *argv[])
                                         &ncolumns, column_name_to_id) < 0)
                return EXIT_FAILURE;
 
+       scols_init_debug(0);
+
        rc = get_local_locks(&locks);
 
        if (!rc && !list_empty(&locks))
index 6ad94be4cc8f6d6ee55b0177dda74f273d0f516d..b1fda736898e06a82ef263722cdef18bb9109f09 100644 (file)
@@ -297,6 +297,8 @@ static int show_table(struct loopdev_cxt *lc,
        struct libscols_line *ln;
        int i, rc = 0;
 
+       scols_init_debug(0);
+
        if (!(tb = scols_new_table()))
                err(EXIT_FAILURE, _("failed to initialize output table"));
        scols_table_enable_raw(tb, raw);
index 3b3faf81ad8d7db328f0fad0a9c9525db0303638..6b128b140376025c34f39e18963cf648bc4300d7 100644 (file)
@@ -1395,8 +1395,11 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
        int i;
        char buf[BUFSIZ];
        const char *data;
-       struct libscols_table *table = scols_new_table();
+       struct libscols_table *table;
 
+       scols_init_debug(0);
+
+       table = scols_new_table();
        if (!table)
                 err(EXIT_FAILURE, _("failed to initialize output table"));
 
index d37ec651e0d3d1a0423db53e388b520115d8114f..826507ce3a25b752c975e97fca843dc42ab2e7a0 100644 (file)
@@ -618,6 +618,8 @@ int main(int argc, char **argv)
                columns[ncolumns++] = COL_UNITS;
        }
 
+       scols_init_debug(0);
+
        if (list_empty(&lims)) {
                /* default is to print all resources */
                size_t n;
index 4f98500efeb709a50baa0d61b38372359ea4016e..8c36b2c8598a80e3b167b12339b82d52a07e3229 100644 (file)
@@ -236,6 +236,8 @@ static int show_table(int bytes)
        if (!itr)
                err(EXIT_FAILURE, _("failed to initialize libmount iterator"));
 
+       scols_init_debug(0);
+
        table = scols_new_table();
        if (!table)
                err(EXIT_FAILURE, _("failed to initialize output table"));
index d63a110e384ccdd6a2ff384c21d068d2301abaea..137649a3d77e3db42b89331442e2002bd2e336fe 100644 (file)
@@ -250,6 +250,8 @@ static int show_flags(struct wdinfo *wd, uint32_t wanted)
        struct libscols_table *table;
        uint32_t flags;
 
+       scols_init_debug(0);
+
        /* create output table */
        table = scols_new_table();
        if (!table) {