Also add documentation for this argument. This allows the default of 20 to be overridden, and is helpful for using the hotblocks plugin for analysis scripts that require collecting data on a larger number of blocks (e.g. setting limit=0 to dump information on all blocks).
Signed-off-by: Alex Bradbury <[email protected]> Reviewed-by: Pierrick Bouvier <[email protected]> --- contrib/plugins/hotblocks.c | 10 +++++++++- docs/about/emulation.rst | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 40d8dae1cd..8ecf033997 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -84,7 +84,8 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) if (sorted_counts) { g_string_append_printf(report, "pc, tcount, icount, ecount\n"); - for (i = 0, it = sorted_counts; i < limit && it; i++, it = it->next) { + for (i = 0, it = sorted_counts; (limit == 0 || i < limit) && it; + i++, it = it->next) { ExecCount *rec = (ExecCount *) it->data; g_string_append_printf( report, "0x%016"PRIx64", %d, %ld, %"PRIu64"\n", @@ -170,6 +171,13 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, fprintf(stderr, "boolean argument parsing failed: %s\n", opt); return -1; } + } else if (g_strcmp0(tokens[0], "limit") == 0) { + char *endptr = NULL; + limit = g_ascii_strtoull(tokens[1], &endptr, 10); + if (endptr == tokens[1] || *endptr != '\0') { + fprintf(stderr, "unsigned integer parsing failed: %s\n", opt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index 543efc4d7d..e8793b0f9c 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -473,6 +473,8 @@ Behaviour can be tweaked with the following arguments: - Description * - inline=true|false - Use faster inline addition of a single counter. + * - limit=N + - The number of blocks to be printed. (Default: N = 20, use 0 for no limit). Hot Pages ......... -- 2.52.0
