MCPcopy Create free account
hub / github.com/bloomberg/pystack / CorefileRemoteMemoryManager

Class CorefileRemoteMemoryManager

src/pystack/_pystack/mem.h:195–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193};
194
195class CorefileRemoteMemoryManager : public AbstractRemoteMemoryManager
196{
197 public:
198 // Constructors
199 explicit CorefileRemoteMemoryManager(
200 std::shared_ptr<CoreFileAnalyzer> analyzer,
201 std::vector<VirtualMap>& vmaps);
202
203 // Methods
204 ssize_t copyMemoryFromProcess(remote_addr_t addr, size_t size, void* destination) const override;
205
206 bool isAddressValid(remote_addr_t addr, const VirtualMap& map) const override;
207
208 private:
209 // Structs and Enums
210 enum class StatusCode {
211 SUCCESS,
212 ERROR,
213 };
214
215 struct ElfLoadSegment
216 {
217 GElf_Addr vaddr;
218 GElf_Off offset;
219 GElf_Xword size;
220 };
221 // Cache for PT_LOAD segments
222 mutable std::unordered_map<std::string, std::vector<ElfLoadSegment>> d_elf_load_segments_cache;
223
224 // Data members
225 std::shared_ptr<CoreFileAnalyzer> d_analyzer;
226 std::vector<VirtualMap> d_vmaps;
227 std::vector<SimpleVirtualMap> d_shared_libs;
228 size_t d_corefile_size;
229 std::unique_ptr<char, std::function<void(char*)>> d_corefile_data;
230
231 StatusCode readCorefile(int fd, const char* filename) noexcept;
232 StatusCode getMemoryLocationFromCore(remote_addr_t addr, off_t* offset_in_file) const;
233 StatusCode getMemoryLocationFromElf(
234 remote_addr_t addr,
235 const std::string** filename,
236 off_t* offset_in_file) const;
237 StatusCode initLoadSegments(const std::string& filename) const;
238};
239} // namespace pystack

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected