xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Symbol/SaveCoreOptions.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- SaveCoreOptions.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
11 
12 #include "lldb/Target/ThreadCollection.h"
13 #include "lldb/Utility/FileSpec.h"
14 #include "lldb/Utility/RangeMap.h"
15 
16 #include <optional>
17 #include <string>
18 #include <unordered_set>
19 
20 using MemoryRanges = lldb_private::RangeVector<lldb::addr_t, lldb::addr_t>;
21 
22 namespace lldb_private {
23 
24 class SaveCoreOptions {
25 public:
SaveCoreOptions()26   SaveCoreOptions(){};
27   ~SaveCoreOptions() = default;
28 
29   lldb_private::Status SetPluginName(const char *name);
30   std::optional<std::string> GetPluginName() const;
31 
32   void SetStyle(lldb::SaveCoreStyle style);
33   lldb::SaveCoreStyle GetStyle() const;
34 
35   void SetOutputFile(lldb_private::FileSpec file);
36   const std::optional<lldb_private::FileSpec> GetOutputFile() const;
37 
38   Status SetProcess(lldb::ProcessSP process_sp);
39 
40   Status AddThread(lldb::ThreadSP thread_sp);
41   bool RemoveThread(lldb::ThreadSP thread_sp);
42   bool ShouldThreadBeSaved(lldb::tid_t tid) const;
43   bool HasSpecifiedThreads() const;
44 
45   Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
46   const MemoryRanges &GetCoreFileMemoryRanges() const;
47 
48   void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo &region);
49 
50   lldb_private::ThreadCollection::collection GetThreadsToSave() const;
51 
52   llvm::Expected<uint64_t> GetCurrentSizeInBytes();
53 
54   void Clear();
55 
56 private:
57   void ClearProcessSpecificData();
58 
59   std::optional<std::string> m_plugin_name;
60   std::optional<lldb_private::FileSpec> m_file;
61   std::optional<lldb::SaveCoreStyle> m_style;
62   lldb::ProcessSP m_process_sp;
63   std::unordered_set<lldb::tid_t> m_threads_to_save;
64   MemoryRanges m_regions_to_save;
65 };
66 } // namespace lldb_private
67 
68 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_SAVECOREOPTIONS_H
69