1 //===-- SBInstructionList.cpp -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBInstructionList.h"
11 #include "lldb/API/SBInstruction.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Core/Disassembler.h"
14 #include "lldb/Core/Stream.h"
17 using namespace lldb_private;
20 SBInstructionList::SBInstructionList () :
25 SBInstructionList::SBInstructionList(const SBInstructionList &rhs) :
26 m_opaque_sp (rhs.m_opaque_sp)
30 const SBInstructionList &
31 SBInstructionList::operator = (const SBInstructionList &rhs)
34 m_opaque_sp = rhs.m_opaque_sp;
39 SBInstructionList::~SBInstructionList ()
44 SBInstructionList::IsValid () const
46 return m_opaque_sp.get() != NULL;
50 SBInstructionList::GetSize ()
53 return m_opaque_sp->GetInstructionList().GetSize();
58 SBInstructionList::GetInstructionAtIndex (uint32_t idx)
61 if (m_opaque_sp && idx < m_opaque_sp->GetInstructionList().GetSize())
62 inst.SetOpaque (m_opaque_sp->GetInstructionList().GetInstructionAtIndex (idx));
67 SBInstructionList::Clear ()
73 SBInstructionList::AppendInstruction (SBInstruction insn)
78 SBInstructionList::SetDisassembler (const lldb::DisassemblerSP &opaque_sp)
80 m_opaque_sp = opaque_sp;
84 SBInstructionList::Print (FILE *out)
92 SBInstructionList::GetDescription (lldb::SBStream &description)
96 size_t num_instructions = GetSize ();
99 // Call the ref() to make sure a stream is created if one deesn't
100 // exist already inside description...
101 Stream &sref = description.ref();
102 const uint32_t max_opcode_byte_size = m_opaque_sp->GetInstructionList().GetMaxOpcocdeByteSize();
103 for (size_t i=0; i<num_instructions; ++i)
105 Instruction *inst = m_opaque_sp->GetInstructionList().GetInstructionAtIndex (i).get();
108 inst->Dump (&sref, max_opcode_byte_size, true, false, NULL);
119 SBInstructionList::DumpEmulationForAllInstructions (const char *triple)
123 size_t len = GetSize();
124 for (size_t i = 0; i < len; ++i)
126 if (!GetInstructionAtIndex((uint32_t) i).DumpEmulation (triple))