From ed1c70b5b8b04911a1c357b0f49a51ff65c7d30e Mon Sep 17 00:00:00 2001 From: "ted.mielczarek" Date: Wed, 26 Jan 2011 22:13:37 +0000 Subject: Expose actual instruction from DisassemblerX86 R=cdn at http://breakpad.appspot.com/260001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@766 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/processor/disassembler_x86.h | 8 ++++++++ src/processor/disassembler_x86_unittest.cc | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'src/processor') diff --git a/src/processor/disassembler_x86.h b/src/processor/disassembler_x86.h index 3eea838e..3bdd558f 100644 --- a/src/processor/disassembler_x86.h +++ b/src/processor/disassembler_x86.h @@ -36,6 +36,8 @@ #ifndef GOOGLE_BREAKPAD_PROCESSOR_DISASSEMBLER_X86_H_ #define GOOGLE_BREAKPAD_PROCESSOR_DISASSEMBLER_X86_H_ +#include + #include "google_breakpad/common/breakpad_types.h" namespace libdis { @@ -73,6 +75,12 @@ class DisassemblerX86 { // Indicates whether the current disassembled instruction was valid. bool currentInstructionValid() { return instr_valid_; } + // Returns the current instruction as defined in libdis.h, + // or NULL if the current instruction is not valid. + const libdis::x86_insn_t* currentInstruction() { + return instr_valid_ ? ¤t_instr_ : NULL; + } + // Returns the type of the current instruction as defined in libdis.h. libdis::x86_insn_group currentInstructionGroup() { return current_instr_.group; diff --git a/src/processor/disassembler_x86_unittest.cc b/src/processor/disassembler_x86_unittest.cc index cc4754b2..b6884c1e 100644 --- a/src/processor/disassembler_x86_unittest.cc +++ b/src/processor/disassembler_x86_unittest.cc @@ -96,8 +96,12 @@ TEST(DisassemblerX86Test, SimpleReturnInstruction) { EXPECT_EQ(0, dis.flags()); EXPECT_EQ(true, dis.endOfBlock()); EXPECT_EQ(libdis::insn_controlflow, dis.currentInstructionGroup()); + const libdis::x86_insn_t* instruction = dis.currentInstruction(); + EXPECT_EQ(libdis::insn_controlflow, instruction->group); + EXPECT_EQ(libdis::insn_return, instruction->type); EXPECT_EQ(0, dis.NextInstruction()); EXPECT_EQ(false, dis.currentInstructionValid()); + EXPECT_EQ(NULL, dis.currentInstruction()); } TEST(DisassemblerX86Test, SimpleInvalidInstruction) { -- cgit v1.2.1