The -p option says, an associated with sbitmap_queue array contains the pointers on a structure. This allows the sbitmapq command works correctly with the array of pointers attached to the sbitmap_queue. Signed-off-by: Sergey Samoylenko <s.samoylenko@xxxxxxxxx> --- help.c | 4 +++- sbitmap.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/help.c b/help.c index 82defda..483e7dc 100644 --- a/help.c +++ b/help.c @@ -965,7 +965,7 @@ NULL char *help_sbitmapq[] = { "sbitmapq", "sbitmap_queue struct contents", -"[-s struct[.member[,member]] -a address [-v]] -[x|d] address", +"[-s struct[.member[,member]] -a address [-p] [-v]] -[x|d] address", " The command dumps the contents of the sbitmap_queue structure and", " the used bits in the bitmap. Also, it shows the dump of a structure", " array associated with the sbitmap_queue.", @@ -979,6 +979,8 @@ char *help_sbitmapq[] = { " -a address - address of a structure array associated with sbitmap_queue", " structure. The set bits in sbitmap are used for the index", " in an associated array.", +" -p - associated with sbitmap_queue array contains the points of", +" structure." " -x - override default output format with hexadecimal format.", " -d - override default output format with decimal format.", " -v - By default, the sbitmap command shows only a used sbitmap", diff --git a/sbitmap.c b/sbitmap.c index 4d8feb9..91a5274 100644 --- a/sbitmap.c +++ b/sbitmap.c @@ -34,6 +34,7 @@ struct sbitmapq_data { #define SBITMAPQ_DATA_FLAG_STRUCT_NAME (VERBOSE << 1) #define SBITMAPQ_DATA_FLAG_STRUCT_MEMBER (VERBOSE << 2) #define SBITMAPQ_DATA_FLAG_ARRAY_ADDR (VERBOSE << 3) +#define SBITMAPQ_DATA_FLAG_ARRAY_OF_POINTS (VERBOSE << 4) ulong flags; int radix; /* sbitmap_queue info */ @@ -442,9 +443,22 @@ static bool sbitmap_data_print(unsigned int idx, ulong addr, void *p) const struct sbitmapq_data *sd = p; bool verbose = !!(sd->flags & VERBOSE); bool members = !!(sd->flags & SBITMAPQ_DATA_FLAG_STRUCT_MEMBER); + bool points = !!(sd->flags & SBITMAPQ_DATA_FLAG_ARRAY_OF_POINTS); if (verbose) { fprintf(fp, "%d (0x%08lx):\n", idx, addr); + + if (points) { + ulong p_addr; + + if (!readmem(addr, KVADDR, &p_addr, sizeof(void *), + "read point of data", RETURN_ON_ERROR)) { + error(INFO, "Failed to read the point of data: 0x%08lx\n", addr); + return false; + } + addr = p_addr; + } + if (members) dump_struct_members(sd->data_name, addr, sd->radix); else @@ -459,7 +473,7 @@ static void sbitmap_queue_data_dump(struct sbitmapq_data *sd) { struct sbitmapq_ops ops = { .addr = sd->data_addr, - .size = sd->data_size, + .size = (sd->flags & SBITMAPQ_DATA_FLAG_ARRAY_OF_POINTS) ? sizeof(void *) : sd->data_size, .fn = sbitmap_data_print, .p = sd }; @@ -556,7 +570,7 @@ void cmd_sbitmapq(void) struct sbitmapq_data sd = {0}; int c; - while ((c = getopt(argcnt, args, "s:a:xdv")) != EOF) { + while ((c = getopt(argcnt, args, "s:a:pxdv")) != EOF) { switch (c) { case 's': if (sd.flags & SBITMAPQ_DATA_FLAG_STRUCT_NAME) @@ -580,6 +594,10 @@ void cmd_sbitmapq(void) break; + case 'p': + sd.flags |= SBITMAPQ_DATA_FLAG_ARRAY_OF_POINTS; + break; + case 'v': sd.flags |= VERBOSE; break; @@ -629,6 +647,12 @@ void cmd_sbitmapq(void) cmd_usage(pc->curcmd, SYNOPSIS); } + if ((sd.flags & SBITMAPQ_DATA_FLAG_ARRAY_OF_POINTS) && + !(sd.flags & SBITMAPQ_DATA_FLAG_ARRAY_ADDR)) { + error(INFO, "-p option requires -a option\n"); + cmd_usage(pc->curcmd, SYNOPSIS); + } + if (sd.flags & SBITMAPQ_DATA_FLAG_STRUCT_NAME) { if (count_chars(sd.data_name, '.') > 0) sd.flags |= SBITMAPQ_DATA_FLAG_STRUCT_MEMBER; -- 2.25.1 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility