[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 8 21:18:13 PST 2023


================
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+                    lldb::FileSP file_sp)
+      : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+    const FileSpec file_spec;
+    m_core_file->GetFileSpec(const_cast<FileSpec &>(file_spec));
+    return file_spec;
----------------
JDevlieghere wrote:

I'm not sure I understand what's going on here. You're marking the local variable as `const` only to immediately `const_cast` it away in the line below? Can't you avoid all this like so:

```
FileSpec file_spec;
m_core_file->GetFileSpec(file_spec);
```

or even better, why doesn't `GetFileSpec` return a `FileSpec` instead of an out parameter?
```

https://github.com/llvm/llvm-project/pull/71769


More information about the lldb-commits mailing list