ptxed: show blocks
Add a new options --block:show-blocks to show blocks in the output.
Change-Id: I81c5e6dec1fa1e0c32fba9f20152a4581b2414bc
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
diff --git a/ptxed/src/ptxed.c b/ptxed/src/ptxed.c
index 8615bad..94d0609 100644
--- a/ptxed/src/ptxed.c
+++ b/ptxed/src/ptxed.c
@@ -78,6 +78,12 @@
/* Print information about section loads and unloads. */
uint32_t track_image:1;
+ /* Track blocks in the output.
+ *
+ * This only applies to the block decoder.
+ */
+ uint32_t track_blocks:1;
+
/* Print in AT&T format. */
uint32_t att_format:1;
@@ -176,6 +182,7 @@
" --cpuid-0x15.ebx set the value of cpuid[0x15].ebx.\n"
" --insn-decoder use the instruction flow decoder (default).\n"
" --block-decoder use the block decoder.\n"
+ " --block:show-blocks show blocks in the output.\n"
"\n"
#if defined(FEATURE_ELF)
"You must specify at least one binary or ELF file (--raw|--elf).\n"
@@ -776,7 +783,9 @@
static void print_block(struct pt_block *block,
struct pt_image_section_cache *iscache,
- const struct ptxed_options *options, uint64_t offset)
+ const struct ptxed_options *options,
+ const struct ptxed_stats *stats,
+ uint64_t offset)
{
xed_machine_mode_enum_t mode;
xed_state_t xed;
@@ -796,6 +805,13 @@
if (block->resumed)
printf("[resumed]\n");
+ if (options->track_blocks) {
+ printf("[block");
+ if (stats)
+ printf(" %" PRIx64, stats->blocks);
+ printf("]\n");
+ }
+
mode = translate_mode(block->mode);
xed_state_init2(&xed, mode, XED_ADDRESS_WIDTH_INVALID);
@@ -942,7 +958,8 @@
if (!options->quiet)
print_block(&block, iscache,
- options, offset);
+ options, stats,
+ offset);
}
break;
}
@@ -953,7 +970,8 @@
}
if (!options->quiet)
- print_block(&block, iscache, options, offset);
+ print_block(&block, iscache, options, stats,
+ offset);
if (errcode & pts_eos) {
if (!block.disabled && !options->quiet)
@@ -1367,6 +1385,11 @@
continue;
}
+ if (strcmp(arg, "--block:show-blocks") == 0) {
+ options.track_blocks = 1;
+ continue;
+ }
+
fprintf(stderr, "%s: unknown option: %s.\n", prog, arg);
goto err;
}