aboutsummaryrefslogtreecommitdiff
path: root/src/processor
diff options
context:
space:
mode:
Diffstat (limited to 'src/processor')
-rw-r--r--src/processor/disassembler_x86.h8
-rw-r--r--src/processor/disassembler_x86_unittest.cc4
2 files changed, 12 insertions, 0 deletions
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 <stddef.h>
+
#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_ ? &current_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) {