1 //===-- Materializer.h ------------------------------------------*- 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 #ifndef lldb_Materializer_h
11 #define lldb_Materializer_h
13 #include "lldb/lldb-private-types.h"
14 #include "lldb/Core/Error.h"
15 #include "lldb/Expression/IRMemoryMap.h"
16 #include "lldb/Host/Mutex.h"
17 #include "lldb/Symbol/SymbolContext.h"
18 #include "lldb/Target/StackFrame.h"
22 namespace lldb_private
37 m_process_address(LLDB_INVALID_ADDRESS)
46 void Dematerialize (Error &err,
47 lldb::ClangExpressionVariableSP &result_sp,
48 lldb::addr_t frame_top,
49 lldb::addr_t frame_bottom);
55 return m_materializer && m_map && (m_process_address != LLDB_INVALID_ADDRESS);
58 friend class Materializer;
60 Dematerializer (Materializer &materializer,
61 lldb::StackFrameSP &frame_sp,
63 lldb::addr_t process_address) :
64 m_materializer(&materializer),
66 m_process_address(process_address)
70 m_thread_wp = frame_sp->GetThread();
71 m_stack_id = frame_sp->GetStackID();
75 Materializer *m_materializer;
76 lldb::ThreadWP m_thread_wp;
79 lldb::addr_t m_process_address;
82 typedef std::shared_ptr<Dematerializer> DematerializerSP;
83 typedef std::weak_ptr<Dematerializer> DematerializerWP;
85 DematerializerSP Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err);
87 uint32_t AddPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp, Error &err);
88 uint32_t AddVariable (lldb::VariableSP &variable_sp, Error &err);
89 uint32_t AddResultVariable (const TypeFromUser &type, bool is_lvalue, bool keep_in_memory, Error &err);
90 uint32_t AddSymbol (const Symbol &symbol_sp, Error &err);
91 uint32_t AddRegister (const RegisterInfo ®ister_info, Error &err);
93 uint32_t GetStructAlignment ()
95 return m_struct_alignment;
98 uint32_t GetStructByteSize ()
100 return m_current_offset;
103 uint32_t GetResultOffset ()
106 return m_result_entity->GetOffset();
125 virtual void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err) = 0;
126 virtual void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address,
127 lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err) = 0;
128 virtual void DumpToLog (IRMemoryMap &map, lldb::addr_t process_address, Log *log) = 0;
129 virtual void Wipe (IRMemoryMap &map, lldb::addr_t process_address) = 0;
131 uint32_t GetAlignment ()
141 uint32_t GetOffset ()
146 void SetOffset (uint32_t offset)
151 void SetSizeAndAlignmentFromType (ClangASTType &type);
153 uint32_t m_alignment;
159 uint32_t AddStructMember (Entity &entity);
161 typedef std::unique_ptr<Entity> EntityUP;
162 typedef std::vector<EntityUP> EntityVector;
164 DematerializerWP m_dematerializer_wp;
165 EntityVector m_entities;
166 Entity *m_result_entity;
167 uint32_t m_current_offset;
168 uint32_t m_struct_alignment;