Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 9 | #include "SBReproducerPrivate.h" |
Alex Langford | d17cd90 | 2018-05-25 20:28:16 +0000 | [diff] [blame] | 10 | #include "SystemInitializerFull.h" |
| 11 | |
Eli Friedman | ca93cc1 | 2010-06-09 07:37:52 +0000 | [diff] [blame] | 12 | #include "lldb/API/SBDebugger.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 14 | #include "lldb/lldb-private.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | |
Eli Friedman | ca93cc1 | 2010-06-09 07:37:52 +0000 | [diff] [blame] | 16 | #include "lldb/API/SBBroadcaster.h" |
| 17 | #include "lldb/API/SBCommandInterpreter.h" |
| 18 | #include "lldb/API/SBCommandReturnObject.h" |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 19 | #include "lldb/API/SBError.h" |
Eli Friedman | ca93cc1 | 2010-06-09 07:37:52 +0000 | [diff] [blame] | 20 | #include "lldb/API/SBEvent.h" |
| 21 | #include "lldb/API/SBFrame.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 22 | #include "lldb/API/SBListener.h" |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 23 | #include "lldb/API/SBProcess.h" |
| 24 | #include "lldb/API/SBSourceManager.h" |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 25 | #include "lldb/API/SBStream.h" |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 26 | #include "lldb/API/SBStringList.h" |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 27 | #include "lldb/API/SBStructuredData.h" |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 28 | #include "lldb/API/SBTarget.h" |
| 29 | #include "lldb/API/SBThread.h" |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 30 | #include "lldb/API/SBTypeCategory.h" |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 31 | #include "lldb/API/SBTypeFilter.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 32 | #include "lldb/API/SBTypeFormat.h" |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 33 | #include "lldb/API/SBTypeNameSpecifier.h" |
| 34 | #include "lldb/API/SBTypeSummary.h" |
| 35 | #include "lldb/API/SBTypeSynthetic.h" |
| 36 | |
Greg Clayton | 6eee5aa | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 37 | #include "lldb/Core/Debugger.h" |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 38 | #include "lldb/Core/PluginManager.h" |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 39 | #include "lldb/Core/StreamFile.h" |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 40 | #include "lldb/Core/StructuredDataImpl.h" |
Enrico Granata | 5548cb5 | 2013-01-28 23:47:25 +0000 | [diff] [blame] | 41 | #include "lldb/DataFormatters/DataVisualization.h" |
Pavel Labath | f1389e9 | 2018-02-19 15:06:28 +0000 | [diff] [blame] | 42 | #include "lldb/Host/XML.h" |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 43 | #include "lldb/Initialization/SystemLifetimeManager.h" |
Greg Clayton | 6eee5aa | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 44 | #include "lldb/Interpreter/CommandInterpreter.h" |
Pavel Labath | 47cbf4a | 2018-04-10 09:03:59 +0000 | [diff] [blame] | 45 | #include "lldb/Interpreter/OptionArgParser.h" |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 46 | #include "lldb/Interpreter/OptionGroupPlatform.h" |
Greg Clayton | 6eee5aa | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 47 | #include "lldb/Target/Process.h" |
| 48 | #include "lldb/Target/TargetList.h" |
Pavel Labath | 145d95c | 2018-04-17 18:53:35 +0000 | [diff] [blame] | 49 | #include "lldb/Utility/Args.h" |
Pavel Labath | d821c99 | 2018-08-07 11:07:21 +0000 | [diff] [blame] | 50 | #include "lldb/Utility/State.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 51 | |
Enrico Granata | d717cc9 | 2015-10-20 04:50:09 +0000 | [diff] [blame] | 52 | #include "llvm/ADT/STLExtras.h" |
Zachary Turner | 7b2e5a3 | 2016-09-16 19:09:12 +0000 | [diff] [blame] | 53 | #include "llvm/ADT/StringRef.h" |
Zachary Turner | 58a559c | 2014-08-27 20:15:09 +0000 | [diff] [blame] | 54 | #include "llvm/Support/DynamicLibrary.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 55 | #include "llvm/Support/ManagedStatic.h" |
Zachary Turner | 58a559c | 2014-08-27 20:15:09 +0000 | [diff] [blame] | 56 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 57 | using namespace lldb; |
| 58 | using namespace lldb_private; |
| 59 | |
Jonas Devlieghere | d77c2e0 | 2019-03-02 00:20:26 +0000 | [diff] [blame] | 60 | /// Helper class for replaying commands through the reproducer. |
| 61 | class CommandLoader { |
| 62 | public: |
| 63 | CommandLoader(std::vector<std::string> files) : m_files(files) {} |
| 64 | |
| 65 | static std::unique_ptr<CommandLoader> Create() { |
| 66 | repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); |
| 67 | if (!loader) |
| 68 | return {}; |
| 69 | |
| 70 | FileSpec file = loader->GetFile<repro::CommandInfo>(); |
| 71 | if (!file) |
| 72 | return {}; |
| 73 | |
| 74 | auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); |
| 75 | if (auto err = error_or_file.getError()) |
| 76 | return {}; |
| 77 | |
| 78 | std::vector<std::string> files; |
| 79 | llvm::yaml::Input yin((*error_or_file)->getBuffer()); |
| 80 | yin >> files; |
| 81 | |
| 82 | if (auto err = yin.error()) |
| 83 | return {}; |
| 84 | |
| 85 | return llvm::make_unique<CommandLoader>(std::move(files)); |
| 86 | } |
| 87 | |
| 88 | FILE *GetNextFile() { |
| 89 | if (m_index >= m_files.size()) |
| 90 | return nullptr; |
| 91 | return FileSystem::Instance().Fopen(m_files[m_index++].c_str(), "r"); |
| 92 | } |
| 93 | |
| 94 | private: |
| 95 | std::vector<std::string> m_files; |
| 96 | unsigned m_index = 0; |
| 97 | }; |
| 98 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 99 | static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, |
| 100 | const FileSpec &spec, |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 101 | Status &error) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 102 | llvm::sys::DynamicLibrary dynlib = |
| 103 | llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str()); |
| 104 | if (dynlib.isValid()) { |
| 105 | typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger); |
| 106 | |
| 107 | lldb::SBDebugger debugger_sb(debugger_sp); |
| 108 | // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) |
| 109 | // function. |
| 110 | // TODO: mangle this differently for your system - on OSX, the first |
| 111 | // underscore needs to be removed and the second one stays |
| 112 | LLDBCommandPluginInit init_func = |
Stephane Sezer | 22701b2 | 2017-10-24 23:46:00 +0000 | [diff] [blame] | 113 | (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 114 | "_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); |
| 115 | if (init_func) { |
| 116 | if (init_func(debugger_sb)) |
| 117 | return dynlib; |
| 118 | else |
| 119 | error.SetErrorString("plug-in refused to load " |
| 120 | "(lldb::PluginInitialize(lldb::SBDebugger) " |
| 121 | "returned false)"); |
| 122 | } else { |
| 123 | error.SetErrorString("plug-in is missing the required initialization: " |
| 124 | "lldb::PluginInitialize(lldb::SBDebugger)"); |
Greg Clayton | 5fb8f79 | 2013-12-02 19:35:49 +0000 | [diff] [blame] | 125 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 126 | } else { |
Jonas Devlieghere | dbd7fab | 2018-11-01 17:09:25 +0000 | [diff] [blame] | 127 | if (FileSystem::Instance().Exists(spec)) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 128 | error.SetErrorString("this file does not represent a loadable dylib"); |
Greg Clayton | 5fb8f79 | 2013-12-02 19:35:49 +0000 | [diff] [blame] | 129 | else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 130 | error.SetErrorString("no such file"); |
| 131 | } |
| 132 | return llvm::sys::DynamicLibrary(); |
Greg Clayton | 5fb8f79 | 2013-12-02 19:35:49 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 135 | static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime; |
| 136 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 137 | SBError SBInputReader::Initialize( |
| 138 | lldb::SBDebugger &sb_debugger, |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 139 | unsigned long (*callback)(void *, lldb::SBInputReader *, |
| 140 | lldb::InputReaderAction, char const *, |
| 141 | unsigned long), |
| 142 | void *a, lldb::InputReaderGranularity b, char const *c, char const *d, |
| 143 | bool e) { |
Jonas Devlieghere | 7bc8356 | 2019-03-11 20:31:21 +0000 | [diff] [blame] | 144 | LLDB_RECORD_DUMMY( |
| 145 | lldb::SBError, SBInputReader, Initialize, |
| 146 | (lldb::SBDebugger &, |
| 147 | unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, |
| 148 | const char *, unsigned long), |
| 149 | void *, lldb::InputReaderGranularity, const char *, const char *, bool), |
| 150 | sb_debugger, callback, a, b, c, d, e); |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 151 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 152 | return SBError(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 155 | void SBInputReader::SetIsDone(bool b) { |
| 156 | LLDB_RECORD_METHOD(void, SBInputReader, SetIsDone, (bool), b); |
| 157 | } |
Eugene Zelenko | dbb0abb | 2015-10-31 01:22:59 +0000 | [diff] [blame] | 158 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 159 | bool SBInputReader::IsActive() const { |
| 160 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInputReader, IsActive); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 161 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 162 | return false; |
| 163 | } |
| 164 | |
| 165 | SBDebugger::SBDebugger() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDebugger); } |
Eugene Zelenko | dbb0abb | 2015-10-31 01:22:59 +0000 | [diff] [blame] | 166 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 167 | SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 168 | : m_opaque_sp(debugger_sp) { |
| 169 | LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &), debugger_sp); |
| 170 | } |
Eugene Zelenko | dbb0abb | 2015-10-31 01:22:59 +0000 | [diff] [blame] | 171 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 172 | SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) { |
| 173 | LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &), rhs); |
| 174 | } |
Eugene Zelenko | dbb0abb | 2015-10-31 01:22:59 +0000 | [diff] [blame] | 175 | |
| 176 | SBDebugger::~SBDebugger() = default; |
| 177 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 178 | SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 179 | LLDB_RECORD_METHOD(lldb::SBDebugger &, |
| 180 | SBDebugger, operator=,(const lldb::SBDebugger &), rhs); |
| 181 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 182 | if (this != &rhs) { |
| 183 | m_opaque_sp = rhs.m_opaque_sp; |
| 184 | } |
| 185 | return *this; |
Eugene Zelenko | dbb0abb | 2015-10-31 01:22:59 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 188 | void SBDebugger::Initialize() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 189 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize); |
Jonas Devlieghere | 936c624 | 2019-02-21 22:26:16 +0000 | [diff] [blame] | 190 | SBError ignored = SBDebugger::InitializeWithErrorHandling(); |
Jonas Devlieghere | 15eacd7 | 2018-12-03 17:28:29 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Jonas Devlieghere | 936c624 | 2019-02-21 22:26:16 +0000 | [diff] [blame] | 193 | lldb::SBError SBDebugger::InitializeWithErrorHandling() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 194 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger, |
| 195 | InitializeWithErrorHandling); |
| 196 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 197 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 198 | |
Jonas Devlieghere | 15eacd7 | 2018-12-03 17:28:29 +0000 | [diff] [blame] | 199 | SBError error; |
| 200 | if (auto e = g_debugger_lifetime->Initialize( |
Jonas Devlieghere | 936c624 | 2019-02-21 22:26:16 +0000 | [diff] [blame] | 201 | llvm::make_unique<SystemInitializerFull>(), LoadPlugin)) { |
Jonas Devlieghere | 15eacd7 | 2018-12-03 17:28:29 +0000 | [diff] [blame] | 202 | error.SetError(Status(std::move(e))); |
| 203 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 204 | return LLDB_RECORD_RESULT(error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 205 | } |
| 206 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 207 | void SBDebugger::Terminate() { |
| 208 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate); |
| 209 | |
| 210 | g_debugger_lifetime->Terminate(); |
| 211 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 212 | |
| 213 | void SBDebugger::Clear() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 214 | LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear); |
| 215 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 216 | |
| 217 | if (m_opaque_sp) |
| 218 | m_opaque_sp->ClearIOHandlers(); |
| 219 | |
| 220 | m_opaque_sp.reset(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 221 | } |
| 222 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 223 | SBDebugger SBDebugger::Create() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 224 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBDebugger, SBDebugger, Create); |
| 225 | |
| 226 | return LLDB_RECORD_RESULT(SBDebugger::Create(false, nullptr, nullptr)); |
Greg Clayton | 48e4254 | 2010-07-30 20:12:55 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 229 | SBDebugger SBDebugger::Create(bool source_init_files) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 230 | LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool), |
| 231 | source_init_files); |
| 232 | |
| 233 | return LLDB_RECORD_RESULT( |
| 234 | SBDebugger::Create(source_init_files, nullptr, nullptr)); |
Jim Ingham | 0694269 | 2011-08-13 00:22:20 +0000 | [diff] [blame] | 235 | } |
| 236 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 237 | SBDebugger SBDebugger::Create(bool source_init_files, |
| 238 | lldb::LogOutputCallback callback, void *baton) |
Jim Ingham | 228063c | 2012-02-21 02:23:08 +0000 | [diff] [blame] | 239 | |
| 240 | { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 241 | LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create, |
Jonas Devlieghere | 7bc8356 | 2019-03-11 20:31:21 +0000 | [diff] [blame] | 242 | (bool, lldb::LogOutputCallback, void *), source_init_files, |
| 243 | callback, baton); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 244 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 245 | SBDebugger debugger; |
Greg Clayton | cb172b1 | 2014-05-19 20:42:14 +0000 | [diff] [blame] | 246 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 247 | // Currently we have issues if this function is called simultaneously on two |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 248 | // different threads. The issues mainly revolve around the fact that the |
| 249 | // lldb_private::FormatManager uses global collections and having two threads |
| 250 | // parsing the .lldbinit files can cause mayhem. So to get around this for |
| 251 | // now we need to use a mutex to prevent bad things from happening. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 252 | static std::recursive_mutex g_mutex; |
| 253 | std::lock_guard<std::recursive_mutex> guard(g_mutex); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 254 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 255 | debugger.reset(Debugger::CreateInstance(callback, baton)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 256 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 257 | |
| 258 | SBCommandInterpreter interp = debugger.GetCommandInterpreter(); |
| 259 | if (source_init_files) { |
| 260 | interp.get()->SkipLLDBInitFiles(false); |
| 261 | interp.get()->SkipAppInitFiles(false); |
| 262 | SBCommandReturnObject result; |
| 263 | interp.SourceInitFileInHomeDirectory(result); |
| 264 | } else { |
| 265 | interp.get()->SkipLLDBInitFiles(true); |
| 266 | interp.get()->SkipAppInitFiles(true); |
| 267 | } |
| 268 | return debugger; |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 269 | } |
| 270 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 271 | void SBDebugger::Destroy(SBDebugger &debugger) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 272 | LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &), |
| 273 | debugger); |
| 274 | |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 275 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 276 | Debugger::Destroy(debugger.m_opaque_sp); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 277 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 278 | if (debugger.m_opaque_sp.get() != nullptr) |
| 279 | debugger.m_opaque_sp.reset(); |
Caroline Tice | e02657b | 2011-01-22 01:02:07 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 282 | void SBDebugger::MemoryPressureDetected() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 283 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, MemoryPressureDetected); |
| 284 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 285 | // Since this function can be call asynchronously, we allow it to be non- |
| 286 | // mandatory. We have seen deadlocks with this function when called so we |
| 287 | // need to safeguard against this until we can determine what is causing the |
| 288 | // deadlocks. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 289 | |
| 290 | const bool mandatory = false; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 291 | |
| 292 | ModuleList::RemoveOrphanSharedModules(mandatory); |
Greg Clayton | f932241 | 2011-12-15 04:38:41 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 295 | bool SBDebugger::IsValid() const { |
| 296 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, IsValid); |
Pavel Labath | 7f5237b | 2019-03-11 13:58:46 +0000 | [diff] [blame] | 297 | return this->operator bool(); |
| 298 | } |
| 299 | SBDebugger::operator bool() const { |
| 300 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, operator bool); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 301 | |
| 302 | return m_opaque_sp.get() != nullptr; |
| 303 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 304 | |
| 305 | void SBDebugger::SetAsync(bool b) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 306 | LLDB_RECORD_METHOD(void, SBDebugger, SetAsync, (bool), b); |
| 307 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 308 | if (m_opaque_sp) |
| 309 | m_opaque_sp->SetAsyncExecution(b); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 312 | bool SBDebugger::GetAsync() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 313 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetAsync); |
| 314 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 315 | return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 316 | } |
| 317 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 318 | void SBDebugger::SkipLLDBInitFiles(bool b) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 319 | LLDB_RECORD_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool), b); |
| 320 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 321 | if (m_opaque_sp) |
| 322 | m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b); |
Jim Ingham | e64f0dc | 2011-09-13 23:25:31 +0000 | [diff] [blame] | 323 | } |
| 324 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 325 | void SBDebugger::SkipAppInitFiles(bool b) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 326 | LLDB_RECORD_METHOD(void, SBDebugger, SkipAppInitFiles, (bool), b); |
| 327 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 328 | if (m_opaque_sp) |
| 329 | m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b); |
Greg Clayton | 6eee5aa | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 330 | } |
| 331 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 332 | // Shouldn't really be settable after initialization as this could cause lots |
| 333 | // of problems; don't want users trying to switch modes in the middle of a |
| 334 | // debugging session. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 335 | void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 336 | LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh, |
| 337 | transfer_ownership); |
| 338 | |
Jonas Devlieghere | d77c2e0 | 2019-03-02 00:20:26 +0000 | [diff] [blame] | 339 | if (!m_opaque_sp) |
| 340 | return; |
| 341 | |
| 342 | repro::DataRecorder *recorder = nullptr; |
| 343 | if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) |
| 344 | recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder(); |
| 345 | |
| 346 | static std::unique_ptr<CommandLoader> loader = CommandLoader::Create(); |
| 347 | if (loader) |
| 348 | fh = loader->GetNextFile(); |
| 349 | |
| 350 | m_opaque_sp->SetInputFileHandle(fh, transfer_ownership, recorder); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 353 | void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 354 | LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh, |
| 355 | transfer_ownership); |
| 356 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 357 | if (m_opaque_sp) |
| 358 | m_opaque_sp->SetOutputFileHandle(fh, transfer_ownership); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 359 | } |
| 360 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 361 | void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 362 | LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh, |
| 363 | transfer_ownership); |
| 364 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 365 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 366 | if (m_opaque_sp) |
| 367 | m_opaque_sp->SetErrorFileHandle(fh, transfer_ownership); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 370 | FILE *SBDebugger::GetInputFileHandle() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 371 | LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle); |
| 372 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 373 | if (m_opaque_sp) { |
| 374 | StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile()); |
| 375 | if (stream_file_sp) |
| 376 | return stream_file_sp->GetFile().GetStream(); |
| 377 | } |
| 378 | return nullptr; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 379 | } |
| 380 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 381 | FILE *SBDebugger::GetOutputFileHandle() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 382 | LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle); |
| 383 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 384 | if (m_opaque_sp) { |
| 385 | StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile()); |
| 386 | if (stream_file_sp) |
| 387 | return stream_file_sp->GetFile().GetStream(); |
| 388 | } |
| 389 | return nullptr; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 392 | FILE *SBDebugger::GetErrorFileHandle() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 393 | LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle); |
| 394 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 395 | if (m_opaque_sp) { |
| 396 | StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); |
| 397 | if (stream_file_sp) |
| 398 | return stream_file_sp->GetFile().GetStream(); |
| 399 | } |
| 400 | return nullptr; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 403 | void SBDebugger::SaveInputTerminalState() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 404 | LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, SaveInputTerminalState); |
| 405 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 406 | if (m_opaque_sp) |
| 407 | m_opaque_sp->SaveInputTerminalState(); |
Jim Ingham | c5917d9 | 2012-11-30 20:23:19 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 410 | void SBDebugger::RestoreInputTerminalState() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 411 | LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, RestoreInputTerminalState); |
| 412 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 413 | if (m_opaque_sp) |
| 414 | m_opaque_sp->RestoreInputTerminalState(); |
Jim Ingham | c5917d9 | 2012-11-30 20:23:19 +0000 | [diff] [blame] | 415 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 416 | SBCommandInterpreter SBDebugger::GetCommandInterpreter() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 417 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger, |
| 418 | GetCommandInterpreter); |
| 419 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 420 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 421 | SBCommandInterpreter sb_interpreter; |
| 422 | if (m_opaque_sp) |
| 423 | sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 424 | |
Caroline Tice | 750cd17 | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 425 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 426 | return LLDB_RECORD_RESULT(sb_interpreter); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 427 | } |
| 428 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 429 | void SBDebugger::HandleCommand(const char *command) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 430 | LLDB_RECORD_METHOD(void, SBDebugger, HandleCommand, (const char *), command); |
| 431 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 432 | if (m_opaque_sp) { |
| 433 | TargetSP target_sp(m_opaque_sp->GetSelectedTarget()); |
| 434 | std::unique_lock<std::recursive_mutex> lock; |
| 435 | if (target_sp) |
| 436 | lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 437 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 438 | SBCommandInterpreter sb_interpreter(GetCommandInterpreter()); |
| 439 | SBCommandReturnObject result; |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 440 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 441 | sb_interpreter.HandleCommand(command, result, false); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 442 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 443 | if (GetErrorFileHandle() != nullptr) |
| 444 | result.PutError(GetErrorFileHandle()); |
| 445 | if (GetOutputFileHandle() != nullptr) |
| 446 | result.PutOutput(GetOutputFileHandle()); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 447 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 448 | if (!m_opaque_sp->GetAsyncExecution()) { |
| 449 | SBProcess process(GetCommandInterpreter().GetProcess()); |
| 450 | ProcessSP process_sp(process.GetSP()); |
| 451 | if (process_sp) { |
| 452 | EventSP event_sp; |
| 453 | ListenerSP lldb_listener_sp = m_opaque_sp->GetListener(); |
Pavel Labath | d35031e1 | 2016-11-30 10:41:42 +0000 | [diff] [blame] | 454 | while (lldb_listener_sp->GetEventForBroadcaster( |
| 455 | process_sp.get(), event_sp, std::chrono::seconds(0))) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 456 | SBEvent event(event_sp); |
| 457 | HandleProcessEvent(process, event, GetOutputFileHandle(), |
| 458 | GetErrorFileHandle()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 459 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 460 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 461 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 462 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 465 | SBListener SBDebugger::GetListener() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 466 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener); |
| 467 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 468 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 469 | SBListener sb_listener; |
| 470 | if (m_opaque_sp) |
| 471 | sb_listener.reset(m_opaque_sp->GetListener()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 472 | |
Caroline Tice | 750cd17 | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 473 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 474 | return LLDB_RECORD_RESULT(sb_listener); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 475 | } |
| 476 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 477 | void SBDebugger::HandleProcessEvent(const SBProcess &process, |
| 478 | const SBEvent &event, FILE *out, |
| 479 | FILE *err) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 480 | LLDB_RECORD_METHOD( |
| 481 | void, SBDebugger, HandleProcessEvent, |
| 482 | (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process, |
| 483 | event, out, err); |
| 484 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 485 | if (!process.IsValid()) |
| 486 | return; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 487 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 488 | TargetSP target_sp(process.GetTarget().GetSP()); |
| 489 | if (!target_sp) |
| 490 | return; |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 491 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 492 | const uint32_t event_type = event.GetType(); |
| 493 | char stdio_buffer[1024]; |
| 494 | size_t len; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 495 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 496 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Saleem Abdulrasool | bb19a13 | 2016-05-19 05:13:57 +0000 | [diff] [blame] | 497 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 498 | if (event_type & |
| 499 | (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) { |
| 500 | // Drain stdout when we stop just in case we have any bytes |
| 501 | while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0) |
| 502 | if (out != nullptr) |
| 503 | ::fwrite(stdio_buffer, 1, len, out); |
| 504 | } |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 505 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 506 | if (event_type & |
| 507 | (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) { |
| 508 | // Drain stderr when we stop just in case we have any bytes |
| 509 | while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0) |
| 510 | if (err != nullptr) |
| 511 | ::fwrite(stdio_buffer, 1, len, err); |
| 512 | } |
| 513 | |
| 514 | if (event_type & Process::eBroadcastBitStateChanged) { |
| 515 | StateType event_state = SBProcess::GetStateFromEvent(event); |
| 516 | |
| 517 | if (event_state == eStateInvalid) |
| 518 | return; |
| 519 | |
| 520 | bool is_stopped = StateIsStoppedState(event_state); |
| 521 | if (!is_stopped) |
| 522 | process.ReportEventState(event, out); |
| 523 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 524 | } |
| 525 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 526 | SBSourceManager SBDebugger::GetSourceManager() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 527 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBDebugger, |
| 528 | GetSourceManager); |
| 529 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 530 | SBSourceManager sb_source_manager(*this); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 531 | return LLDB_RECORD_RESULT(sb_source_manager); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 532 | } |
| 533 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 534 | bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 535 | LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture, |
| 536 | (char *, size_t), "", arch_name_len); |
| 537 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 538 | if (arch_name && arch_name_len) { |
| 539 | ArchSpec default_arch = Target::GetDefaultArchitecture(); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 540 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 541 | if (default_arch.IsValid()) { |
| 542 | const std::string &triple_str = default_arch.GetTriple().str(); |
| 543 | if (!triple_str.empty()) |
| 544 | ::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str()); |
| 545 | else |
| 546 | ::snprintf(arch_name, arch_name_len, "%s", |
| 547 | default_arch.GetArchitectureName()); |
| 548 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 549 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 550 | } |
| 551 | if (arch_name && arch_name_len) |
| 552 | arch_name[0] = '\0'; |
| 553 | return false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 556 | bool SBDebugger::SetDefaultArchitecture(const char *arch_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 557 | LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, |
| 558 | (const char *), arch_name); |
| 559 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 560 | if (arch_name) { |
| 561 | ArchSpec arch(arch_name); |
| 562 | if (arch.IsValid()) { |
| 563 | Target::SetDefaultArchitecture(arch); |
| 564 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 565 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 566 | } |
| 567 | return false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | ScriptLanguage |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 571 | SBDebugger::GetScriptingLanguage(const char *script_language_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 572 | LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, |
| 573 | (const char *), script_language_name); |
| 574 | |
Zachary Turner | 7b2e5a3 | 2016-09-16 19:09:12 +0000 | [diff] [blame] | 575 | if (!script_language_name) return eScriptLanguageDefault; |
Pavel Labath | 47cbf4a | 2018-04-10 09:03:59 +0000 | [diff] [blame] | 576 | return OptionArgParser::ToScriptLanguage( |
| 577 | llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 578 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 579 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 580 | const char *SBDebugger::GetVersionString() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 581 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, GetVersionString); |
| 582 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 583 | return lldb_private::GetVersion(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 584 | } |
| 585 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 586 | const char *SBDebugger::StateAsCString(StateType state) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 587 | LLDB_RECORD_STATIC_METHOD(const char *, SBDebugger, StateAsCString, |
| 588 | (lldb::StateType), state); |
| 589 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 590 | return lldb_private::StateAsCString(state); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 591 | } |
| 592 | |
Pavel Labath | f1389e9 | 2018-02-19 15:06:28 +0000 | [diff] [blame] | 593 | static void AddBoolConfigEntry(StructuredData::Dictionary &dict, |
| 594 | llvm::StringRef name, bool value, |
| 595 | llvm::StringRef description) { |
| 596 | auto entry_up = llvm::make_unique<StructuredData::Dictionary>(); |
| 597 | entry_up->AddBooleanItem("value", value); |
| 598 | entry_up->AddStringItem("description", description); |
| 599 | dict.AddItem(name, std::move(entry_up)); |
| 600 | } |
| 601 | |
Pavel Labath | abc0c6a | 2018-06-28 14:23:04 +0000 | [diff] [blame] | 602 | static void AddLLVMTargets(StructuredData::Dictionary &dict) { |
| 603 | auto array_up = llvm::make_unique<StructuredData::Array>(); |
| 604 | #define LLVM_TARGET(target) \ |
| 605 | array_up->AddItem(llvm::make_unique<StructuredData::String>(#target)); |
| 606 | #include "llvm/Config/Targets.def" |
| 607 | auto entry_up = llvm::make_unique<StructuredData::Dictionary>(); |
| 608 | entry_up->AddItem("value", std::move(array_up)); |
| 609 | entry_up->AddStringItem("description", "A list of configured LLVM targets."); |
| 610 | dict.AddItem("targets", std::move(entry_up)); |
| 611 | } |
| 612 | |
Pavel Labath | f1389e9 | 2018-02-19 15:06:28 +0000 | [diff] [blame] | 613 | SBStructuredData SBDebugger::GetBuildConfiguration() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 614 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger, |
| 615 | GetBuildConfiguration); |
| 616 | |
Pavel Labath | f1389e9 | 2018-02-19 15:06:28 +0000 | [diff] [blame] | 617 | auto config_up = llvm::make_unique<StructuredData::Dictionary>(); |
| 618 | AddBoolConfigEntry( |
| 619 | *config_up, "xml", XMLDocument::XMLEnabled(), |
| 620 | "A boolean value that indicates if XML support is enabled in LLDB"); |
Pavel Labath | abc0c6a | 2018-06-28 14:23:04 +0000 | [diff] [blame] | 621 | AddLLVMTargets(*config_up); |
Pavel Labath | f1389e9 | 2018-02-19 15:06:28 +0000 | [diff] [blame] | 622 | |
| 623 | SBStructuredData data; |
| 624 | data.m_impl_up->SetObjectSP(std::move(config_up)); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 625 | return LLDB_RECORD_RESULT(data); |
Pavel Labath | f1389e9 | 2018-02-19 15:06:28 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 628 | bool SBDebugger::StateIsRunningState(StateType state) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 629 | LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, |
| 630 | (lldb::StateType), state); |
| 631 | |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 632 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 633 | const bool result = lldb_private::StateIsRunningState(state); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 634 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 635 | return result; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 636 | } |
| 637 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 638 | bool SBDebugger::StateIsStoppedState(StateType state) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 639 | LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, |
| 640 | (lldb::StateType), state); |
| 641 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 642 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 643 | const bool result = lldb_private::StateIsStoppedState(state, false); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 644 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 645 | return result; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 646 | } |
| 647 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 648 | lldb::SBTarget SBDebugger::CreateTarget(const char *filename, |
| 649 | const char *target_triple, |
| 650 | const char *platform_name, |
| 651 | bool add_dependent_modules, |
| 652 | lldb::SBError &sb_error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 653 | LLDB_RECORD_METHOD( |
| 654 | lldb::SBTarget, SBDebugger, CreateTarget, |
| 655 | (const char *, const char *, const char *, bool, lldb::SBError &), |
| 656 | filename, target_triple, platform_name, add_dependent_modules, sb_error); |
| 657 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 658 | SBTarget sb_target; |
| 659 | TargetSP target_sp; |
| 660 | if (m_opaque_sp) { |
| 661 | sb_error.Clear(); |
| 662 | OptionGroupPlatform platform_options(false); |
| 663 | platform_options.SetPlatformName(platform_name); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 664 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 665 | sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget( |
Jonas Devlieghere | f9a07e9 | 2018-09-20 09:09:05 +0000 | [diff] [blame] | 666 | *m_opaque_sp, filename, target_triple, |
| 667 | add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 668 | &platform_options, target_sp); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 669 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 670 | if (sb_error.Success()) |
| 671 | sb_target.SetSP(target_sp); |
| 672 | } else { |
| 673 | sb_error.SetErrorString("invalid debugger"); |
| 674 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 675 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 676 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 677 | if (log) |
| 678 | log->Printf("SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, " |
| 679 | "platform_name=%s, add_dependent_modules=%u, error=%s) => " |
| 680 | "SBTarget(%p)", |
| 681 | static_cast<void *>(m_opaque_sp.get()), filename, target_triple, |
| 682 | platform_name, add_dependent_modules, sb_error.GetCString(), |
| 683 | static_cast<void *>(target_sp.get())); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 684 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 685 | return LLDB_RECORD_RESULT(sb_target); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 686 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 687 | |
| 688 | SBTarget |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 689 | SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, |
| 690 | const char *target_triple) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 691 | LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, |
| 692 | CreateTargetWithFileAndTargetTriple, |
| 693 | (const char *, const char *), filename, target_triple); |
| 694 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 695 | SBTarget sb_target; |
| 696 | TargetSP target_sp; |
| 697 | if (m_opaque_sp) { |
| 698 | const bool add_dependent_modules = true; |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 699 | Status error(m_opaque_sp->GetTargetList().CreateTarget( |
Jonas Devlieghere | f9a07e9 | 2018-09-20 09:09:05 +0000 | [diff] [blame] | 700 | *m_opaque_sp, filename, target_triple, |
| 701 | add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 702 | target_sp)); |
| 703 | sb_target.SetSP(target_sp); |
| 704 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 705 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 706 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 707 | if (log) |
| 708 | log->Printf("SBDebugger(%p)::CreateTargetWithFileAndTargetTriple " |
| 709 | "(filename=\"%s\", triple=%s) => SBTarget(%p)", |
| 710 | static_cast<void *>(m_opaque_sp.get()), filename, target_triple, |
| 711 | static_cast<void *>(target_sp.get())); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 712 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 713 | return LLDB_RECORD_RESULT(sb_target); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 714 | } |
| 715 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 716 | SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, |
| 717 | const char *arch_cstr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 718 | LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch, |
| 719 | (const char *, const char *), filename, arch_cstr); |
| 720 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 721 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 722 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 723 | SBTarget sb_target; |
| 724 | TargetSP target_sp; |
| 725 | if (m_opaque_sp) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 726 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 727 | const bool add_dependent_modules = true; |
| 728 | |
| 729 | error = m_opaque_sp->GetTargetList().CreateTarget( |
Jonas Devlieghere | f9a07e9 | 2018-09-20 09:09:05 +0000 | [diff] [blame] | 730 | *m_opaque_sp, filename, arch_cstr, |
| 731 | add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 732 | target_sp); |
| 733 | |
| 734 | if (error.Success()) { |
| 735 | m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); |
| 736 | sb_target.SetSP(target_sp); |
Greg Clayton | 6920b52 | 2012-08-22 18:39:03 +0000 | [diff] [blame] | 737 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | if (log) |
| 741 | log->Printf("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", " |
| 742 | "arch=%s) => SBTarget(%p)", |
| 743 | static_cast<void *>(m_opaque_sp.get()), filename, arch_cstr, |
| 744 | static_cast<void *>(target_sp.get())); |
| 745 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 746 | return LLDB_RECORD_RESULT(sb_target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | SBTarget SBDebugger::CreateTarget(const char *filename) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 750 | LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, (const char *), |
| 751 | filename); |
| 752 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 753 | SBTarget sb_target; |
| 754 | TargetSP target_sp; |
| 755 | if (m_opaque_sp) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 756 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 757 | const bool add_dependent_modules = true; |
| 758 | error = m_opaque_sp->GetTargetList().CreateTarget( |
Jonas Devlieghere | f9a07e9 | 2018-09-20 09:09:05 +0000 | [diff] [blame] | 759 | *m_opaque_sp, filename, "", |
| 760 | add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, |
| 761 | target_sp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 762 | |
| 763 | if (error.Success()) { |
| 764 | m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); |
| 765 | sb_target.SetSP(target_sp); |
Greg Clayton | 6920b52 | 2012-08-22 18:39:03 +0000 | [diff] [blame] | 766 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 767 | } |
| 768 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 769 | if (log) |
| 770 | log->Printf( |
| 771 | "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)", |
| 772 | static_cast<void *>(m_opaque_sp.get()), filename, |
| 773 | static_cast<void *>(target_sp.get())); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 774 | return LLDB_RECORD_RESULT(sb_target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 775 | } |
| 776 | |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 777 | SBTarget SBDebugger::GetDummyTarget() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 778 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetDummyTarget); |
| 779 | |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 780 | SBTarget sb_target; |
| 781 | if (m_opaque_sp) { |
| 782 | sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this()); |
| 783 | } |
| 784 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 785 | if (log) |
| 786 | log->Printf( |
| 787 | "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)", |
| 788 | static_cast<void *>(m_opaque_sp.get()), |
| 789 | static_cast<void *>(sb_target.GetSP().get())); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 790 | return LLDB_RECORD_RESULT(sb_target); |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 791 | } |
| 792 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 793 | bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 794 | LLDB_RECORD_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &), |
| 795 | target); |
| 796 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 797 | bool result = false; |
| 798 | if (m_opaque_sp) { |
| 799 | TargetSP target_sp(target.GetSP()); |
| 800 | if (target_sp) { |
| 801 | // No need to lock, the target list is thread safe |
| 802 | result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp); |
| 803 | target_sp->Destroy(); |
| 804 | target.Clear(); |
| 805 | const bool mandatory = true; |
| 806 | ModuleList::RemoveOrphanSharedModules(mandatory); |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 811 | if (log) |
| 812 | log->Printf("SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i", |
| 813 | static_cast<void *>(m_opaque_sp.get()), |
| 814 | static_cast<void *>(target.m_opaque_sp.get()), result); |
| 815 | |
| 816 | return result; |
| 817 | } |
| 818 | |
| 819 | SBTarget SBDebugger::GetTargetAtIndex(uint32_t idx) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 820 | LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, (uint32_t), |
| 821 | idx); |
| 822 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 823 | SBTarget sb_target; |
| 824 | if (m_opaque_sp) { |
| 825 | // No need to lock, the target list is thread safe |
| 826 | sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx)); |
| 827 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 828 | return LLDB_RECORD_RESULT(sb_target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 832 | LLDB_RECORD_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, (lldb::SBTarget), |
| 833 | target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 834 | |
| 835 | lldb::TargetSP target_sp = target.GetSP(); |
| 836 | if (!target_sp) |
| 837 | return UINT32_MAX; |
| 838 | |
| 839 | if (!m_opaque_sp) |
| 840 | return UINT32_MAX; |
| 841 | |
| 842 | return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP()); |
| 843 | } |
| 844 | |
| 845 | SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 846 | LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, |
| 847 | (lldb::pid_t), pid); |
| 848 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 849 | SBTarget sb_target; |
| 850 | if (m_opaque_sp) { |
| 851 | // No need to lock, the target list is thread safe |
| 852 | sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid)); |
| 853 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 854 | return LLDB_RECORD_RESULT(sb_target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, |
| 858 | const char *arch_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 859 | LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, |
| 860 | (const char *, const char *), filename, arch_name); |
| 861 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 862 | SBTarget sb_target; |
| 863 | if (m_opaque_sp && filename && filename[0]) { |
| 864 | // No need to lock, the target list is thread safe |
Pavel Labath | 7263f1b | 2017-10-31 10:56:03 +0000 | [diff] [blame] | 865 | ArchSpec arch = Platform::GetAugmentedArchSpec( |
| 866 | m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 867 | TargetSP target_sp( |
| 868 | m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture( |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 869 | FileSpec(filename), arch_name ? &arch : nullptr)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 870 | sb_target.SetSP(target_sp); |
| 871 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 872 | return LLDB_RECORD_RESULT(sb_target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) { |
| 876 | SBTarget sb_target; |
| 877 | if (m_opaque_sp) { |
| 878 | // No need to lock, the target list is thread safe |
| 879 | sb_target.SetSP( |
| 880 | m_opaque_sp->GetTargetList().FindTargetWithProcess(process_sp.get())); |
| 881 | } |
| 882 | return sb_target; |
| 883 | } |
| 884 | |
| 885 | uint32_t SBDebugger::GetNumTargets() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 886 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumTargets); |
| 887 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 888 | if (m_opaque_sp) { |
| 889 | // No need to lock, the target list is thread safe |
| 890 | return m_opaque_sp->GetTargetList().GetNumTargets(); |
| 891 | } |
| 892 | return 0; |
| 893 | } |
| 894 | |
| 895 | SBTarget SBDebugger::GetSelectedTarget() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 896 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetSelectedTarget); |
| 897 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 898 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 899 | |
| 900 | SBTarget sb_target; |
| 901 | TargetSP target_sp; |
| 902 | if (m_opaque_sp) { |
| 903 | // No need to lock, the target list is thread safe |
| 904 | target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget(); |
| 905 | sb_target.SetSP(target_sp); |
| 906 | } |
| 907 | |
| 908 | if (log) { |
| 909 | SBStream sstr; |
| 910 | sb_target.GetDescription(sstr, eDescriptionLevelBrief); |
| 911 | log->Printf("SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s", |
| 912 | static_cast<void *>(m_opaque_sp.get()), |
| 913 | static_cast<void *>(target_sp.get()), sstr.GetData()); |
| 914 | } |
| 915 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 916 | return LLDB_RECORD_RESULT(sb_target); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | void SBDebugger::SetSelectedTarget(SBTarget &sb_target) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 920 | LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &), |
| 921 | sb_target); |
| 922 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 923 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 924 | |
| 925 | TargetSP target_sp(sb_target.GetSP()); |
| 926 | if (m_opaque_sp) { |
| 927 | m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); |
| 928 | } |
| 929 | if (log) { |
| 930 | SBStream sstr; |
| 931 | sb_target.GetDescription(sstr, eDescriptionLevelBrief); |
| 932 | log->Printf("SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s", |
| 933 | static_cast<void *>(m_opaque_sp.get()), |
| 934 | static_cast<void *>(target_sp.get()), sstr.GetData()); |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | SBPlatform SBDebugger::GetSelectedPlatform() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 939 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBDebugger, GetSelectedPlatform); |
| 940 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 941 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 942 | |
| 943 | SBPlatform sb_platform; |
| 944 | DebuggerSP debugger_sp(m_opaque_sp); |
| 945 | if (debugger_sp) { |
| 946 | sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform()); |
| 947 | } |
| 948 | if (log) |
| 949 | log->Printf("SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s", |
| 950 | static_cast<void *>(m_opaque_sp.get()), |
| 951 | static_cast<void *>(sb_platform.GetSP().get()), |
| 952 | sb_platform.GetName()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 953 | return LLDB_RECORD_RESULT(sb_platform); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 957 | LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedPlatform, |
| 958 | (lldb::SBPlatform &), sb_platform); |
| 959 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 960 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 961 | |
| 962 | DebuggerSP debugger_sp(m_opaque_sp); |
| 963 | if (debugger_sp) { |
| 964 | debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP()); |
| 965 | } |
| 966 | |
| 967 | if (log) |
| 968 | log->Printf("SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)", |
| 969 | static_cast<void *>(m_opaque_sp.get()), |
| 970 | static_cast<void *>(sb_platform.GetSP().get()), |
| 971 | sb_platform.GetName()); |
| 972 | } |
| 973 | |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 974 | uint32_t SBDebugger::GetNumPlatforms() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 975 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumPlatforms); |
| 976 | |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 977 | if (m_opaque_sp) { |
| 978 | // No need to lock, the platform list is thread safe |
| 979 | return m_opaque_sp->GetPlatformList().GetSize(); |
| 980 | } |
| 981 | return 0; |
| 982 | } |
| 983 | |
| 984 | SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 985 | LLDB_RECORD_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, |
| 986 | (uint32_t), idx); |
| 987 | |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 988 | SBPlatform sb_platform; |
| 989 | if (m_opaque_sp) { |
| 990 | // No need to lock, the platform list is thread safe |
| 991 | sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx)); |
| 992 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 993 | return LLDB_RECORD_RESULT(sb_platform); |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | uint32_t SBDebugger::GetNumAvailablePlatforms() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 997 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumAvailablePlatforms); |
| 998 | |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 999 | uint32_t idx = 0; |
| 1000 | while (true) { |
| 1001 | if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) { |
| 1002 | break; |
| 1003 | } |
| 1004 | ++idx; |
| 1005 | } |
| 1006 | // +1 for the host platform, which should always appear first in the list. |
| 1007 | return idx + 1; |
| 1008 | } |
| 1009 | |
| 1010 | SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1011 | LLDB_RECORD_METHOD(lldb::SBStructuredData, SBDebugger, |
| 1012 | GetAvailablePlatformInfoAtIndex, (uint32_t), idx); |
| 1013 | |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 1014 | SBStructuredData data; |
| 1015 | auto platform_dict = llvm::make_unique<StructuredData::Dictionary>(); |
| 1016 | llvm::StringRef name_str("name"), desc_str("description"); |
| 1017 | |
| 1018 | if (idx == 0) { |
| 1019 | PlatformSP host_platform_sp(Platform::GetHostPlatform()); |
| 1020 | platform_dict->AddStringItem( |
| 1021 | name_str, host_platform_sp->GetPluginName().GetStringRef()); |
| 1022 | platform_dict->AddStringItem( |
| 1023 | desc_str, llvm::StringRef(host_platform_sp->GetDescription())); |
| 1024 | } else if (idx > 0) { |
| 1025 | const char *plugin_name = |
| 1026 | PluginManager::GetPlatformPluginNameAtIndex(idx - 1); |
| 1027 | if (!plugin_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1028 | return LLDB_RECORD_RESULT(data); |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 1029 | } |
| 1030 | platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name)); |
| 1031 | |
| 1032 | const char *plugin_desc = |
| 1033 | PluginManager::GetPlatformPluginDescriptionAtIndex(idx - 1); |
| 1034 | if (!plugin_desc) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1035 | return LLDB_RECORD_RESULT(data); |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 1036 | } |
| 1037 | platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc)); |
| 1038 | } |
| 1039 | |
| 1040 | data.m_impl_up->SetObjectSP( |
| 1041 | StructuredData::ObjectSP(platform_dict.release())); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1042 | return LLDB_RECORD_RESULT(data); |
Vadim Macagon | c10e34d | 2017-08-09 09:20:40 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1045 | void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 1046 | LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, |
| 1047 | (void *, const void *, size_t), baton, data, data_len); |
| 1048 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1049 | DispatchInput(data, data_len); |
| 1050 | } |
| 1051 | |
| 1052 | void SBDebugger::DispatchInput(const void *data, size_t data_len) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 1053 | LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, (const void *, size_t), |
| 1054 | data, data_len); |
| 1055 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1056 | // Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1057 | // |
| 1058 | // if (log) |
| 1059 | // log->Printf ("SBDebugger(%p)::DispatchInput (data=\"%.*s\", |
| 1060 | // size_t=%" PRIu64 ")", |
| 1061 | // m_opaque_sp.get(), |
| 1062 | // (int) data_len, |
| 1063 | // (const char *) data, |
| 1064 | // (uint64_t)data_len); |
| 1065 | // |
| 1066 | // if (m_opaque_sp) |
| 1067 | // m_opaque_sp->DispatchInput ((const char *) data, data_len); |
| 1068 | } |
| 1069 | |
| 1070 | void SBDebugger::DispatchInputInterrupt() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1071 | LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputInterrupt); |
| 1072 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1073 | if (m_opaque_sp) |
| 1074 | m_opaque_sp->DispatchInputInterrupt(); |
| 1075 | } |
| 1076 | |
| 1077 | void SBDebugger::DispatchInputEndOfFile() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1078 | LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputEndOfFile); |
| 1079 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1080 | if (m_opaque_sp) |
| 1081 | m_opaque_sp->DispatchInputEndOfFile(); |
| 1082 | } |
| 1083 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1084 | void SBDebugger::PushInputReader(SBInputReader &reader) { |
| 1085 | LLDB_RECORD_METHOD(void, SBDebugger, PushInputReader, (lldb::SBInputReader &), |
| 1086 | reader); |
| 1087 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1088 | |
| 1089 | void SBDebugger::RunCommandInterpreter(bool auto_handle_events, |
| 1090 | bool spawn_thread) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1091 | LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool), |
| 1092 | auto_handle_events, spawn_thread); |
| 1093 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1094 | if (m_opaque_sp) { |
| 1095 | CommandInterpreterRunOptions options; |
| 1096 | |
| 1097 | m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter( |
| 1098 | auto_handle_events, spawn_thread, options); |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | void SBDebugger::RunCommandInterpreter(bool auto_handle_events, |
| 1103 | bool spawn_thread, |
| 1104 | SBCommandInterpreterRunOptions &options, |
| 1105 | int &num_errors, bool &quit_requested, |
| 1106 | bool &stopped_for_crash) |
| 1107 | |
| 1108 | { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1109 | LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, |
| 1110 | (bool, bool, lldb::SBCommandInterpreterRunOptions &, int &, |
| 1111 | bool &, bool &), |
| 1112 | auto_handle_events, spawn_thread, options, num_errors, |
| 1113 | quit_requested, stopped_for_crash); |
| 1114 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1115 | if (m_opaque_sp) { |
| 1116 | CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter(); |
| 1117 | interp.RunCommandInterpreter(auto_handle_events, spawn_thread, |
| 1118 | options.ref()); |
| 1119 | num_errors = interp.GetNumErrors(); |
| 1120 | quit_requested = interp.GetQuitRequested(); |
| 1121 | stopped_for_crash = interp.GetStoppedForCrash(); |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | SBError SBDebugger::RunREPL(lldb::LanguageType language, |
| 1126 | const char *repl_options) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1127 | LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL, |
| 1128 | (lldb::LanguageType, const char *), language, |
| 1129 | repl_options); |
| 1130 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1131 | SBError error; |
| 1132 | if (m_opaque_sp) |
| 1133 | error.ref() = m_opaque_sp->RunREPL(language, repl_options); |
| 1134 | else |
| 1135 | error.SetErrorString("invalid debugger"); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1136 | return LLDB_RECORD_RESULT(error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | void SBDebugger::reset(const DebuggerSP &debugger_sp) { |
| 1140 | m_opaque_sp = debugger_sp; |
| 1141 | } |
| 1142 | |
| 1143 | Debugger *SBDebugger::get() const { return m_opaque_sp.get(); } |
| 1144 | |
| 1145 | Debugger &SBDebugger::ref() const { |
| 1146 | assert(m_opaque_sp.get()); |
| 1147 | return *m_opaque_sp; |
| 1148 | } |
| 1149 | |
| 1150 | const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; } |
| 1151 | |
| 1152 | SBDebugger SBDebugger::FindDebuggerWithID(int id) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1153 | LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID, |
| 1154 | (int), id); |
| 1155 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1156 | // No need to lock, the debugger list is thread safe |
| 1157 | SBDebugger sb_debugger; |
| 1158 | DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id); |
| 1159 | if (debugger_sp) |
| 1160 | sb_debugger.reset(debugger_sp); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1161 | return LLDB_RECORD_RESULT(sb_debugger); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | const char *SBDebugger::GetInstanceName() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1165 | LLDB_RECORD_METHOD_NO_ARGS(const char *, SBDebugger, GetInstanceName); |
| 1166 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1167 | return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr); |
| 1168 | } |
| 1169 | |
| 1170 | SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, |
| 1171 | const char *debugger_instance_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1172 | LLDB_RECORD_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, |
| 1173 | (const char *, const char *, const char *), |
| 1174 | var_name, value, debugger_instance_name); |
| 1175 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1176 | SBError sb_error; |
| 1177 | DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( |
| 1178 | ConstString(debugger_instance_name))); |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 1179 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1180 | if (debugger_sp) { |
| 1181 | ExecutionContext exe_ctx( |
| 1182 | debugger_sp->GetCommandInterpreter().GetExecutionContext()); |
| 1183 | error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign, |
| 1184 | var_name, value); |
| 1185 | } else { |
| 1186 | error.SetErrorStringWithFormat("invalid debugger instance name '%s'", |
| 1187 | debugger_instance_name); |
| 1188 | } |
| 1189 | if (error.Fail()) |
| 1190 | sb_error.SetError(error); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1191 | return LLDB_RECORD_RESULT(sb_error); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 1192 | } |
| 1193 | |
Greg Clayton | 431ce67 | 2011-04-18 23:15:17 +0000 | [diff] [blame] | 1194 | SBStringList |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1195 | SBDebugger::GetInternalVariableValue(const char *var_name, |
| 1196 | const char *debugger_instance_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1197 | LLDB_RECORD_STATIC_METHOD( |
| 1198 | lldb::SBStringList, SBDebugger, GetInternalVariableValue, |
| 1199 | (const char *, const char *), var_name, debugger_instance_name); |
| 1200 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1201 | SBStringList ret_value; |
| 1202 | DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( |
| 1203 | ConstString(debugger_instance_name))); |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 1204 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1205 | if (debugger_sp) { |
| 1206 | ExecutionContext exe_ctx( |
| 1207 | debugger_sp->GetCommandInterpreter().GetExecutionContext()); |
| 1208 | lldb::OptionValueSP value_sp( |
| 1209 | debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error)); |
| 1210 | if (value_sp) { |
| 1211 | StreamString value_strm; |
| 1212 | value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue); |
| 1213 | const std::string &value_str = value_strm.GetString(); |
| 1214 | if (!value_str.empty()) { |
| 1215 | StringList string_list; |
| 1216 | string_list.SplitIntoLines(value_str); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1217 | return LLDB_RECORD_RESULT(SBStringList(&string_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1218 | } |
| 1219 | } |
| 1220 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1221 | return LLDB_RECORD_RESULT(SBStringList()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | uint32_t SBDebugger::GetTerminalWidth() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1225 | LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDebugger, GetTerminalWidth); |
| 1226 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1227 | return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); |
| 1228 | } |
| 1229 | |
| 1230 | void SBDebugger::SetTerminalWidth(uint32_t term_width) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1231 | LLDB_RECORD_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t), |
| 1232 | term_width); |
| 1233 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1234 | if (m_opaque_sp) |
| 1235 | m_opaque_sp->SetTerminalWidth(term_width); |
| 1236 | } |
| 1237 | |
| 1238 | const char *SBDebugger::GetPrompt() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1239 | LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetPrompt); |
| 1240 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1241 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 1242 | |
| 1243 | if (log) |
| 1244 | log->Printf("SBDebugger(%p)::GetPrompt () => \"%s\"", |
| 1245 | static_cast<void *>(m_opaque_sp.get()), |
Zachary Turner | 514d8cd | 2016-09-23 18:06:53 +0000 | [diff] [blame] | 1246 | (m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : "")); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1247 | |
Zachary Turner | 514d8cd | 2016-09-23 18:06:53 +0000 | [diff] [blame] | 1248 | return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString() |
| 1249 | : nullptr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | void SBDebugger::SetPrompt(const char *prompt) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1253 | LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); |
| 1254 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1255 | if (m_opaque_sp) |
Zachary Turner | 514d8cd | 2016-09-23 18:06:53 +0000 | [diff] [blame] | 1256 | m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
Jonas Devlieghere | 9e046f0 | 2018-11-13 19:18:16 +0000 | [diff] [blame] | 1259 | const char *SBDebugger::GetReproducerPath() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1260 | LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetReproducerPath); |
| 1261 | |
Jonas Devlieghere | 9e046f0 | 2018-11-13 19:18:16 +0000 | [diff] [blame] | 1262 | return (m_opaque_sp |
| 1263 | ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString() |
| 1264 | : nullptr); |
| 1265 | } |
| 1266 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1267 | ScriptLanguage SBDebugger::GetScriptLanguage() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1268 | LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ScriptLanguage, SBDebugger, |
| 1269 | GetScriptLanguage); |
| 1270 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1271 | return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); |
| 1272 | } |
| 1273 | |
| 1274 | void SBDebugger::SetScriptLanguage(ScriptLanguage script_lang) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1275 | LLDB_RECORD_METHOD(void, SBDebugger, SetScriptLanguage, |
| 1276 | (lldb::ScriptLanguage), script_lang); |
| 1277 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1278 | if (m_opaque_sp) { |
| 1279 | m_opaque_sp->SetScriptLanguage(script_lang); |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | bool SBDebugger::SetUseExternalEditor(bool value) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1284 | LLDB_RECORD_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool), value); |
| 1285 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1286 | return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false); |
| 1287 | } |
| 1288 | |
| 1289 | bool SBDebugger::GetUseExternalEditor() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1290 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetUseExternalEditor); |
| 1291 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1292 | return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false); |
| 1293 | } |
| 1294 | |
| 1295 | bool SBDebugger::SetUseColor(bool value) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1296 | LLDB_RECORD_METHOD(bool, SBDebugger, SetUseColor, (bool), value); |
| 1297 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1298 | return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false); |
| 1299 | } |
| 1300 | |
| 1301 | bool SBDebugger::GetUseColor() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1302 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseColor); |
| 1303 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1304 | return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); |
| 1305 | } |
| 1306 | |
| 1307 | bool SBDebugger::GetDescription(SBStream &description) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1308 | LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &), |
| 1309 | description); |
| 1310 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1311 | Stream &strm = description.ref(); |
| 1312 | |
| 1313 | if (m_opaque_sp) { |
| 1314 | const char *name = m_opaque_sp->GetInstanceName().AsCString(); |
| 1315 | user_id_t id = m_opaque_sp->GetID(); |
| 1316 | strm.Printf("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id); |
| 1317 | } else |
| 1318 | strm.PutCString("No value"); |
| 1319 | |
| 1320 | return true; |
| 1321 | } |
| 1322 | |
| 1323 | user_id_t SBDebugger::GetID() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1324 | LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBDebugger, GetID); |
| 1325 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1326 | return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID); |
| 1327 | } |
| 1328 | |
| 1329 | SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1330 | LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, |
| 1331 | (const char *), platform_name_cstr); |
| 1332 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1333 | SBError sb_error; |
| 1334 | if (m_opaque_sp) { |
| 1335 | if (platform_name_cstr && platform_name_cstr[0]) { |
| 1336 | ConstString platform_name(platform_name_cstr); |
| 1337 | PlatformSP platform_sp(Platform::Find(platform_name)); |
| 1338 | |
| 1339 | if (platform_sp) { |
| 1340 | // Already have a platform with this name, just select it |
| 1341 | m_opaque_sp->GetPlatformList().SetSelectedPlatform(platform_sp); |
| 1342 | } else { |
| 1343 | // We don't have a platform by this name yet, create one |
| 1344 | platform_sp = Platform::Create(platform_name, sb_error.ref()); |
| 1345 | if (platform_sp) { |
| 1346 | // We created the platform, now append and select it |
| 1347 | bool make_selected = true; |
| 1348 | m_opaque_sp->GetPlatformList().Append(platform_sp, make_selected); |
Greg Clayton | 6920b52 | 2012-08-22 18:39:03 +0000 | [diff] [blame] | 1349 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1350 | } |
| 1351 | } else { |
| 1352 | sb_error.ref().SetErrorString("invalid platform name"); |
Greg Clayton | 6920b52 | 2012-08-22 18:39:03 +0000 | [diff] [blame] | 1353 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1354 | } else { |
| 1355 | sb_error.ref().SetErrorString("invalid debugger"); |
| 1356 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1357 | return LLDB_RECORD_RESULT(sb_error); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 1358 | } |
| 1359 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1360 | bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1361 | LLDB_RECORD_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, |
| 1362 | (const char *), sysroot); |
| 1363 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1364 | Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 1365 | if (m_opaque_sp) { |
| 1366 | PlatformSP platform_sp( |
| 1367 | m_opaque_sp->GetPlatformList().GetSelectedPlatform()); |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1368 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1369 | if (platform_sp) { |
| 1370 | if (log && sysroot) |
| 1371 | log->Printf("SBDebugger::SetCurrentPlatformSDKRoot (\"%s\")", sysroot); |
| 1372 | platform_sp->SetSDKRootDirectory(ConstString(sysroot)); |
| 1373 | return true; |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1374 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1375 | } |
| 1376 | return false; |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1377 | } |
| 1378 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1379 | bool SBDebugger::GetCloseInputOnEOF() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1380 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetCloseInputOnEOF); |
| 1381 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1382 | return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); |
Jim Ingham | e40e421 | 2010-08-30 19:44:40 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1385 | void SBDebugger::SetCloseInputOnEOF(bool b) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1386 | LLDB_RECORD_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool), b); |
| 1387 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1388 | if (m_opaque_sp) |
| 1389 | m_opaque_sp->SetCloseInputOnEOF(b); |
Jim Ingham | e40e421 | 2010-08-30 19:44:40 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1392 | SBTypeCategory SBDebugger::GetCategory(const char *category_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1393 | LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, |
| 1394 | (const char *), category_name); |
| 1395 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1396 | if (!category_name || *category_name == 0) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1397 | return LLDB_RECORD_RESULT(SBTypeCategory()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1398 | |
| 1399 | TypeCategoryImplSP category_sp; |
| 1400 | |
| 1401 | if (DataVisualization::Categories::GetCategory(ConstString(category_name), |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1402 | category_sp, false)) { |
| 1403 | return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); |
| 1404 | } else { |
| 1405 | return LLDB_RECORD_RESULT(SBTypeCategory()); |
| 1406 | } |
Michael Sartain | c3ce7f27 | 2013-05-23 20:47:45 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1409 | SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1410 | LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, |
| 1411 | (lldb::LanguageType), lang_type); |
| 1412 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1413 | TypeCategoryImplSP category_sp; |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1414 | if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) { |
| 1415 | return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); |
| 1416 | } else { |
| 1417 | return LLDB_RECORD_RESULT(SBTypeCategory()); |
| 1418 | } |
Michael Sartain | c3ce7f27 | 2013-05-23 20:47:45 +0000 | [diff] [blame] | 1419 | } |
| 1420 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1421 | SBTypeCategory SBDebugger::CreateCategory(const char *category_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1422 | LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, |
| 1423 | (const char *), category_name); |
| 1424 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1425 | if (!category_name || *category_name == 0) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1426 | return LLDB_RECORD_RESULT(SBTypeCategory()); |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1427 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1428 | TypeCategoryImplSP category_sp; |
| 1429 | |
| 1430 | if (DataVisualization::Categories::GetCategory(ConstString(category_name), |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1431 | category_sp, true)) { |
| 1432 | return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); |
| 1433 | } else { |
| 1434 | return LLDB_RECORD_RESULT(SBTypeCategory()); |
| 1435 | } |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1436 | } |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 1437 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1438 | bool SBDebugger::DeleteCategory(const char *category_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1439 | LLDB_RECORD_METHOD(bool, SBDebugger, DeleteCategory, (const char *), |
| 1440 | category_name); |
| 1441 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1442 | if (!category_name || *category_name == 0) |
| 1443 | return false; |
| 1444 | |
| 1445 | return DataVisualization::Categories::Delete(ConstString(category_name)); |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 1446 | } |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 1447 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1448 | uint32_t SBDebugger::GetNumCategories() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1449 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumCategories); |
| 1450 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1451 | return DataVisualization::Categories::GetCount(); |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 1452 | } |
| 1453 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1454 | SBTypeCategory SBDebugger::GetCategoryAtIndex(uint32_t index) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1455 | LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, |
| 1456 | (uint32_t), index); |
| 1457 | |
| 1458 | return LLDB_RECORD_RESULT( |
| 1459 | SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | SBTypeCategory SBDebugger::GetDefaultCategory() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1463 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeCategory, SBDebugger, |
| 1464 | GetDefaultCategory); |
| 1465 | |
| 1466 | return LLDB_RECORD_RESULT(GetCategory("default")); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1467 | } |
| 1468 | |
| 1469 | SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1470 | LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, |
| 1471 | (lldb::SBTypeNameSpecifier), type_name); |
| 1472 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1473 | SBTypeCategory default_category_sb = GetDefaultCategory(); |
| 1474 | if (default_category_sb.GetEnabled()) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1475 | return LLDB_RECORD_RESULT(default_category_sb.GetFormatForType(type_name)); |
| 1476 | return LLDB_RECORD_RESULT(SBTypeFormat()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1477 | } |
| 1478 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1479 | SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1480 | LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, |
| 1481 | (lldb::SBTypeNameSpecifier), type_name); |
| 1482 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1483 | if (!type_name.IsValid()) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1484 | return LLDB_RECORD_RESULT(SBTypeSummary()); |
| 1485 | return LLDB_RECORD_RESULT( |
| 1486 | SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1487 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1488 | |
| 1489 | SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1490 | LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, |
| 1491 | (lldb::SBTypeNameSpecifier), type_name); |
| 1492 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1493 | if (!type_name.IsValid()) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1494 | return LLDB_RECORD_RESULT(SBTypeFilter()); |
| 1495 | return LLDB_RECORD_RESULT( |
| 1496 | SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1497 | } |
| 1498 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1499 | SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1500 | LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, |
| 1501 | (lldb::SBTypeNameSpecifier), type_name); |
| 1502 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1503 | if (!type_name.IsValid()) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1504 | return LLDB_RECORD_RESULT(SBTypeSynthetic()); |
| 1505 | return LLDB_RECORD_RESULT(SBTypeSynthetic( |
| 1506 | DataVisualization::GetSyntheticForType(type_name.GetSP()))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1507 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1508 | |
Pavel Labath | 5e33690 | 2017-03-01 10:08:40 +0000 | [diff] [blame] | 1509 | static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { |
| 1510 | if (categories == nullptr) |
| 1511 | return {}; |
| 1512 | size_t len = 0; |
| 1513 | while (categories[len] != nullptr) |
| 1514 | ++len; |
| 1515 | return llvm::makeArrayRef(categories, len); |
| 1516 | } |
| 1517 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1518 | bool SBDebugger::EnableLog(const char *channel, const char **categories) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1519 | LLDB_RECORD_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **), |
| 1520 | channel, categories); |
| 1521 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1522 | if (m_opaque_sp) { |
| 1523 | uint32_t log_options = |
| 1524 | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; |
Pavel Labath | 775588c | 2017-03-15 09:06:58 +0000 | [diff] [blame] | 1525 | std::string error; |
| 1526 | llvm::raw_string_ostream error_stream(error); |
Pavel Labath | 5e33690 | 2017-03-01 10:08:40 +0000 | [diff] [blame] | 1527 | return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "", |
Pavel Labath | 775588c | 2017-03-15 09:06:58 +0000 | [diff] [blame] | 1528 | log_options, error_stream); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1529 | } else |
Greg Clayton | f3dd93c | 2011-06-17 03:31:01 +0000 | [diff] [blame] | 1530 | return false; |
| 1531 | } |
| 1532 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1533 | void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, |
| 1534 | void *baton) { |
Jonas Devlieghere | 7bc8356 | 2019-03-11 20:31:21 +0000 | [diff] [blame] | 1535 | LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback, |
| 1536 | (lldb::LogOutputCallback, void *), log_callback, baton); |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 1537 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1538 | if (m_opaque_sp) { |
| 1539 | return m_opaque_sp->SetLoggingCallback(log_callback, baton); |
| 1540 | } |
Jim Ingham | 4f02b22 | 2012-02-22 22:49:20 +0000 | [diff] [blame] | 1541 | } |
Michal Gorny | ae211ec | 2019-03-19 17:13:13 +0000 | [diff] [blame] | 1542 | |
| 1543 | namespace lldb_private { |
| 1544 | namespace repro { |
| 1545 | |
| 1546 | template <> |
| 1547 | void RegisterMethods<SBInputReader>(Registry &R) { |
| 1548 | LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool)); |
| 1549 | LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ()); |
| 1550 | } |
| 1551 | |
| 1552 | static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) { |
| 1553 | // Do nothing. |
| 1554 | } |
| 1555 | |
| 1556 | static bool GetDefaultArchitectureRedirect(char *arch_name, |
| 1557 | size_t arch_name_len) { |
| 1558 | // The function is writing to its argument. Without the redirect it would |
| 1559 | // write into the replay buffer. |
| 1560 | char buffer[1024]; |
| 1561 | return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len); |
| 1562 | } |
| 1563 | |
| 1564 | template <> |
| 1565 | void RegisterMethods<SBDebugger>(Registry &R) { |
| 1566 | // Custom implementation. |
| 1567 | R.Register(&invoke<void (SBDebugger::*)( |
| 1568 | FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit, |
| 1569 | &SetFileHandleRedirect); |
| 1570 | R.Register(&invoke<void (SBDebugger::*)( |
| 1571 | FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit, |
| 1572 | &SetFileHandleRedirect); |
| 1573 | R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>( |
| 1574 | &SBDebugger::GetDefaultArchitecture), |
| 1575 | &GetDefaultArchitectureRedirect); |
| 1576 | |
| 1577 | LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); |
| 1578 | LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); |
| 1579 | LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &)); |
| 1580 | LLDB_REGISTER_METHOD(lldb::SBDebugger &, |
| 1581 | SBDebugger, operator=,(const lldb::SBDebugger &)); |
| 1582 | LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Initialize, ()); |
| 1583 | LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, |
| 1584 | InitializeWithErrorHandling, ()); |
| 1585 | LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Terminate, ()); |
| 1586 | LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ()); |
| 1587 | LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ()); |
| 1588 | LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool)); |
| 1589 | LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, |
| 1590 | (lldb::SBDebugger &)); |
| 1591 | LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ()); |
| 1592 | LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ()); |
| 1593 | LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool, ()); |
| 1594 | LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool)); |
| 1595 | LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ()); |
| 1596 | LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool)); |
| 1597 | LLDB_REGISTER_METHOD(void, SBDebugger, SkipAppInitFiles, (bool)); |
| 1598 | LLDB_REGISTER_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool)); |
| 1599 | LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ()); |
| 1600 | LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ()); |
| 1601 | LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ()); |
| 1602 | LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ()); |
| 1603 | LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ()); |
| 1604 | LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger, |
| 1605 | GetCommandInterpreter, ()); |
| 1606 | LLDB_REGISTER_METHOD(void, SBDebugger, HandleCommand, (const char *)); |
| 1607 | LLDB_REGISTER_METHOD(lldb::SBListener, SBDebugger, GetListener, ()); |
| 1608 | LLDB_REGISTER_METHOD( |
| 1609 | void, SBDebugger, HandleProcessEvent, |
| 1610 | (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *)); |
| 1611 | LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, |
| 1612 | ()); |
| 1613 | LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, |
| 1614 | (const char *)); |
| 1615 | LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, |
| 1616 | (const char *)); |
| 1617 | LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetVersionString, ()); |
| 1618 | LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, StateAsCString, |
| 1619 | (lldb::StateType)); |
| 1620 | LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBDebugger, |
| 1621 | GetBuildConfiguration, ()); |
| 1622 | LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, |
| 1623 | (lldb::StateType)); |
| 1624 | LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, |
| 1625 | (lldb::StateType)); |
| 1626 | LLDB_REGISTER_METHOD( |
| 1627 | lldb::SBTarget, SBDebugger, CreateTarget, |
| 1628 | (const char *, const char *, const char *, bool, lldb::SBError &)); |
| 1629 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, |
| 1630 | CreateTargetWithFileAndTargetTriple, |
| 1631 | (const char *, const char *)); |
| 1632 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, |
| 1633 | CreateTargetWithFileAndArch, |
| 1634 | (const char *, const char *)); |
| 1635 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, |
| 1636 | (const char *)); |
| 1637 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetDummyTarget, ()); |
| 1638 | LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &)); |
| 1639 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, |
| 1640 | (uint32_t)); |
| 1641 | LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, |
| 1642 | (lldb::SBTarget)); |
| 1643 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, |
| 1644 | (lldb::pid_t)); |
| 1645 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, |
| 1646 | (const char *, const char *)); |
| 1647 | LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ()); |
| 1648 | LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ()); |
| 1649 | LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget, |
| 1650 | (lldb::SBTarget &)); |
| 1651 | LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ()); |
| 1652 | LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform, |
| 1653 | (lldb::SBPlatform &)); |
| 1654 | LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumPlatforms, ()); |
| 1655 | LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, |
| 1656 | (uint32_t)); |
| 1657 | LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumAvailablePlatforms, ()); |
| 1658 | LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBDebugger, |
| 1659 | GetAvailablePlatformInfoAtIndex, (uint32_t)); |
| 1660 | LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputInterrupt, ()); |
| 1661 | LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputEndOfFile, ()); |
| 1662 | LLDB_REGISTER_METHOD(void, SBDebugger, PushInputReader, |
| 1663 | (lldb::SBInputReader &)); |
| 1664 | LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool)); |
| 1665 | LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, |
| 1666 | (bool, bool, lldb::SBCommandInterpreterRunOptions &, |
| 1667 | int &, bool &, bool &)); |
| 1668 | LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL, |
| 1669 | (lldb::LanguageType, const char *)); |
| 1670 | LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, |
| 1671 | FindDebuggerWithID, (int)); |
| 1672 | LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ()); |
| 1673 | LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, |
| 1674 | (const char *, const char *, const char *)); |
| 1675 | LLDB_REGISTER_STATIC_METHOD(lldb::SBStringList, SBDebugger, |
| 1676 | GetInternalVariableValue, |
| 1677 | (const char *, const char *)); |
| 1678 | LLDB_REGISTER_METHOD_CONST(uint32_t, SBDebugger, GetTerminalWidth, ()); |
| 1679 | LLDB_REGISTER_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t)); |
| 1680 | LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetPrompt, ()); |
| 1681 | LLDB_REGISTER_METHOD(void, SBDebugger, SetPrompt, (const char *)); |
| 1682 | LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetReproducerPath, ()); |
| 1683 | LLDB_REGISTER_METHOD_CONST(lldb::ScriptLanguage, SBDebugger, |
| 1684 | GetScriptLanguage, ()); |
| 1685 | LLDB_REGISTER_METHOD(void, SBDebugger, SetScriptLanguage, |
| 1686 | (lldb::ScriptLanguage)); |
| 1687 | LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool)); |
| 1688 | LLDB_REGISTER_METHOD(bool, SBDebugger, GetUseExternalEditor, ()); |
| 1689 | LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseColor, (bool)); |
| 1690 | LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetUseColor, ()); |
| 1691 | LLDB_REGISTER_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &)); |
| 1692 | LLDB_REGISTER_METHOD(lldb::user_id_t, SBDebugger, GetID, ()); |
| 1693 | LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, |
| 1694 | (const char *)); |
| 1695 | LLDB_REGISTER_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, |
| 1696 | (const char *)); |
| 1697 | LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetCloseInputOnEOF, ()); |
| 1698 | LLDB_REGISTER_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool)); |
| 1699 | LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, |
| 1700 | (const char *)); |
| 1701 | LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, |
| 1702 | (lldb::LanguageType)); |
| 1703 | LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, |
| 1704 | (const char *)); |
| 1705 | LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteCategory, (const char *)); |
| 1706 | LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumCategories, ()); |
| 1707 | LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, |
| 1708 | (uint32_t)); |
| 1709 | LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetDefaultCategory, |
| 1710 | ()); |
| 1711 | LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, |
| 1712 | (lldb::SBTypeNameSpecifier)); |
| 1713 | LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, |
| 1714 | (lldb::SBTypeNameSpecifier)); |
| 1715 | LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, |
| 1716 | (lldb::SBTypeNameSpecifier)); |
| 1717 | LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, |
| 1718 | (lldb::SBTypeNameSpecifier)); |
| 1719 | LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog, |
| 1720 | (const char *, const char **)); |
| 1721 | } |
| 1722 | |
| 1723 | } |
| 1724 | } |