Skip to content

Commit 17e0cd3

Browse files
ptxed: move xed state into print_insn()
Also merge xed_state_zero() and xed_state_set_machine_mode() into xed_state_init2(). Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
1 parent 2ff808e commit 17e0cd3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ptxed/src/ptxed.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ static void xed_print_insn(const xed_decoded_inst_t *inst, uint64_t ip,
932932
printf(" %s", buffer);
933933
}
934934

935-
static void print_insn(const struct pt_insn *insn, xed_state_t *xed,
935+
static void print_insn(const struct pt_insn *insn,
936936
const struct ptxed_options *options, uint64_t offset,
937937
uint64_t time)
938938
{
@@ -956,11 +956,11 @@ static void print_insn(const struct pt_insn *insn, xed_state_t *xed,
956956
xed_machine_mode_enum_t mode;
957957
xed_decoded_inst_t inst;
958958
xed_error_enum_t errcode;
959+
xed_state_t xed;
959960

960961
mode = translate_mode(insn->mode);
961-
962-
xed_state_set_machine_mode(xed, mode);
963-
xed_decoded_inst_zero_set_mode(&inst, xed);
962+
xed_state_init2(&xed, mode, XED_ADDRESS_WIDTH_INVALID);
963+
xed_decoded_inst_zero_set_mode(&inst, &xed);
964964

965965
errcode = xed_decode(&inst, insn->raw, insn->size);
966966
switch (errcode) {
@@ -1519,16 +1519,13 @@ static void decode_insn(struct ptxed_decoder *decoder,
15191519
struct ptxed_stats *stats)
15201520
{
15211521
struct pt_insn_decoder *ptdec;
1522-
xed_state_t xed;
15231522
uint64_t offset, sync, time;
15241523

15251524
if (!decoder || !options) {
15261525
printf("[internal error]\n");
15271526
return;
15281527
}
15291528

1530-
xed_state_zero(&xed);
1531-
15321529
ptdec = decoder->variant.insn;
15331530
offset = 0ull;
15341531
sync = 0ull;
@@ -1597,7 +1594,7 @@ static void decode_insn(struct ptxed_decoder *decoder,
15971594
#endif
15981595
{
15991596
if (!options->quiet)
1600-
print_insn(&insn, &xed, options,
1597+
print_insn(&insn, options,
16011598
offset, time);
16021599
if (stats)
16031600
stats->insn += 1;
@@ -1609,7 +1606,7 @@ static void decode_insn(struct ptxed_decoder *decoder,
16091606
}
16101607

16111608
if (!options->quiet)
1612-
print_insn(&insn, &xed, options, offset, time);
1609+
print_insn(&insn, options, offset, time);
16131610

16141611
if (stats)
16151612
stats->insn += 1;

0 commit comments

Comments
 (0)