1 //===-- ProcessElfCore.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 // Notes about Linux Process core dumps:
9 // 1) Linux core dump is stored as ELF file.
10 // 2) The ELF file's PT_NOTE and PT_LOAD segments describes the program's
11 // address space and thread contexts.
12 // 3) PT_NOTE segment contains note entries which describes a thread context.
13 // 4) PT_LOAD segment describes a valid contigous range of process address
15 //===----------------------------------------------------------------------===//
17 #ifndef liblldb_ProcessElfCore_h_
18 #define liblldb_ProcessElfCore_h_
24 // Other libraries and framework includes
25 #include "lldb/Core/ConstString.h"
26 #include "lldb/Core/Error.h"
27 #include "lldb/Target/Process.h"
29 #include "Plugins/ObjectFile/ELF/ELFHeader.h"
33 class ProcessElfCore : public lldb_private::Process
36 //------------------------------------------------------------------
37 // Constructors and Destructors
38 //------------------------------------------------------------------
39 static lldb::ProcessSP
40 CreateInstance (lldb_private::Target& target,
41 lldb_private::Listener &listener,
42 const lldb_private::FileSpec *crash_file_path);
50 static lldb_private::ConstString
51 GetPluginNameStatic();
54 GetPluginDescriptionStatic();
56 //------------------------------------------------------------------
57 // Constructors and Destructors
58 //------------------------------------------------------------------
59 ProcessElfCore(lldb_private::Target& target,
60 lldb_private::Listener &listener,
61 const lldb_private::FileSpec &core_file);
66 //------------------------------------------------------------------
67 // Check if a given Process
68 //------------------------------------------------------------------
70 CanDebug (lldb_private::Target &target,
71 bool plugin_specified_by_name);
73 //------------------------------------------------------------------
74 // Creating a new process, or attaching to an existing one
75 //------------------------------------------------------------------
76 virtual lldb_private::Error
79 virtual lldb_private::DynamicLoader *
82 //------------------------------------------------------------------
83 // PluginInterface protocol
84 //------------------------------------------------------------------
85 virtual lldb_private::ConstString
91 //------------------------------------------------------------------
93 //------------------------------------------------------------------
94 virtual lldb_private::Error
98 RefreshStateAfterStop();
100 //------------------------------------------------------------------
102 //------------------------------------------------------------------
106 //------------------------------------------------------------------
108 //------------------------------------------------------------------
110 ReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error);
113 DoReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error);
116 GetImageInfoAddress ();
118 lldb_private::ArchSpec
121 // Returns AUXV structure found in the core file
122 const lldb::DataBufferSP
130 UpdateThreadList (lldb_private::ThreadList &old_thread_list,
131 lldb_private::ThreadList &new_thread_list);
134 //------------------------------------------------------------------
135 // For ProcessElfCore only
136 //------------------------------------------------------------------
137 typedef lldb_private::Range<lldb::addr_t, lldb::addr_t> FileRange;
138 typedef lldb_private::RangeDataArray<lldb::addr_t, lldb::addr_t, FileRange, 1> VMRangeToFileOffset;
140 lldb::ModuleSP m_core_module_sp;
141 lldb_private::FileSpec m_core_file;
142 std::string m_dyld_plugin_name;
143 DISALLOW_COPY_AND_ASSIGN (ProcessElfCore);
145 // True if m_thread_contexts contains valid entries
146 bool m_thread_data_valid;
148 // Contain thread data read from NOTE segments
149 std::vector<ThreadData> m_thread_data;
151 // AUXV structure found from the NOTE segment
152 lldb_private::DataExtractor m_auxv;
154 // Address ranges found in the core
155 VMRangeToFileOffset m_core_aranges;
157 // Parse thread(s) data structures(prstatus, prpsinfo) from given NOTE segment
159 ParseThreadContextsFromNoteSegment (const elf::ELFProgramHeader *segment_header,
160 lldb_private::DataExtractor segment_data);
162 // Returns number of thread contexts stored in the core file
164 GetNumThreadContexts();
166 // Parse a contiguous address range of the process from LOAD segment
168 AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *header);
171 #endif // liblldb_ProcessElffCore_h_