Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBTarget.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 | |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 9 | #include "lldb/API/SBTarget.h" |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 10 | #include "SBReproducerPrivate.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 11 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 12 | #include "lldb/lldb-public.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBBreakpoint.h" |
Ilia K | eb2c19a | 2015-03-10 21:59:55 +0000 | [diff] [blame] | 15 | #include "lldb/API/SBDebugger.h" |
| 16 | #include "lldb/API/SBEvent.h" |
Greg Clayton | 4b63a5c | 2013-01-04 18:10:18 +0000 | [diff] [blame] | 17 | #include "lldb/API/SBExpressionOptions.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "lldb/API/SBFileSpec.h" |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 19 | #include "lldb/API/SBListener.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/API/SBModule.h" |
Greg Clayton | 226cce2 | 2013-07-08 22:22:41 +0000 | [diff] [blame] | 21 | #include "lldb/API/SBModuleSpec.h" |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 22 | #include "lldb/API/SBProcess.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 23 | #include "lldb/API/SBSourceManager.h" |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 24 | #include "lldb/API/SBStream.h" |
Jim Ingham | 76bb8d6 | 2016-04-28 01:40:57 +0000 | [diff] [blame] | 25 | #include "lldb/API/SBStringList.h" |
Davide Italiano | 4a6a2b1 | 2018-04-16 22:55:34 +0000 | [diff] [blame] | 26 | #include "lldb/API/SBStructuredData.h" |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 27 | #include "lldb/API/SBSymbolContextList.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | #include "lldb/Breakpoint/BreakpointID.h" |
| 29 | #include "lldb/Breakpoint/BreakpointIDList.h" |
| 30 | #include "lldb/Breakpoint/BreakpointList.h" |
| 31 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 32 | #include "lldb/Core/Address.h" |
| 33 | #include "lldb/Core/AddressResolver.h" |
| 34 | #include "lldb/Core/AddressResolverName.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | #include "lldb/Core/Debugger.h" |
| 36 | #include "lldb/Core/Disassembler.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 37 | #include "lldb/Core/Module.h" |
| 38 | #include "lldb/Core/ModuleSpec.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 39 | #include "lldb/Core/STLUtils.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 40 | #include "lldb/Core/SearchFilter.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 41 | #include "lldb/Core/Section.h" |
Davide Italiano | 4a6a2b1 | 2018-04-16 22:55:34 +0000 | [diff] [blame] | 42 | #include "lldb/Core/StructuredDataImpl.h" |
Enrico Granata | 347c2aa | 2013-10-08 21:49:02 +0000 | [diff] [blame] | 43 | #include "lldb/Core/ValueObjectConstResult.h" |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 44 | #include "lldb/Core/ValueObjectList.h" |
| 45 | #include "lldb/Core/ValueObjectVariable.h" |
Greg Clayton | 7fb56d0 | 2011-02-01 01:31:41 +0000 | [diff] [blame] | 46 | #include "lldb/Host/Host.h" |
Zachary Turner | a78bd7f | 2015-03-03 23:11:11 +0000 | [diff] [blame] | 47 | #include "lldb/Symbol/ClangASTContext.h" |
| 48 | #include "lldb/Symbol/DeclVendor.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 49 | #include "lldb/Symbol/ObjectFile.h" |
Greg Clayton | ae088e5 | 2016-02-10 21:28:13 +0000 | [diff] [blame] | 50 | #include "lldb/Symbol/SymbolFile.h" |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 51 | #include "lldb/Symbol/SymbolVendor.h" |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 52 | #include "lldb/Symbol/VariableList.h" |
Zachary Turner | 32abc6e | 2015-03-03 19:23:09 +0000 | [diff] [blame] | 53 | #include "lldb/Target/ABI.h" |
Jim Ingham | 0e0984e | 2015-09-02 01:06:46 +0000 | [diff] [blame] | 54 | #include "lldb/Target/Language.h" |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 55 | #include "lldb/Target/LanguageRuntime.h" |
Zachary Turner | a78bd7f | 2015-03-03 23:11:11 +0000 | [diff] [blame] | 56 | #include "lldb/Target/ObjCLanguageRuntime.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 57 | #include "lldb/Target/Process.h" |
Enrico Granata | b10e003 | 2015-03-04 21:33:45 +0000 | [diff] [blame] | 58 | #include "lldb/Target/StackFrame.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | #include "lldb/Target/Target.h" |
| 60 | #include "lldb/Target/TargetList.h" |
Pavel Labath | 5f19b90 | 2017-11-13 16:16:33 +0000 | [diff] [blame] | 61 | #include "lldb/Utility/ArchSpec.h" |
Pavel Labath | 145d95c | 2018-04-17 18:53:35 +0000 | [diff] [blame] | 62 | #include "lldb/Utility/Args.h" |
Zachary Turner | 5713a05 | 2017-03-22 18:40:07 +0000 | [diff] [blame] | 63 | #include "lldb/Utility/FileSpec.h" |
Zachary Turner | 805e710 | 2019-03-04 21:51:03 +0000 | [diff] [blame] | 64 | #include "lldb/Utility/ProcessInfo.h" |
Zachary Turner | bf9a773 | 2017-02-02 21:39:50 +0000 | [diff] [blame] | 65 | #include "lldb/Utility/RegularExpression.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 66 | |
James Y Knight | 2ad4821 | 2018-05-22 22:53:50 +0000 | [diff] [blame] | 67 | #include "Commands/CommandObjectBreakpoint.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 68 | #include "lldb/Interpreter/CommandReturnObject.h" |
Sean Callanan | 237c3ed | 2016-12-14 21:31:31 +0000 | [diff] [blame] | 69 | #include "llvm/Support/PrettyStackTrace.h" |
Carlo Kok | 0fd6fd4 | 2014-09-19 19:38:19 +0000 | [diff] [blame] | 70 | #include "llvm/Support/Regex.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 71 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 72 | using namespace lldb; |
| 73 | using namespace lldb_private; |
| 74 | |
| 75 | #define DEFAULT_DISASM_BYTE_SIZE 32 |
| 76 | |
Oleksiy Vyalov | 3738614 | 2015-02-10 22:49:57 +0000 | [diff] [blame] | 77 | namespace { |
| 78 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 79 | Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 80 | std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex()); |
Oleksiy Vyalov | 3738614 | 2015-02-10 22:49:57 +0000 | [diff] [blame] | 81 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 82 | auto process_sp = target.GetProcessSP(); |
| 83 | if (process_sp) { |
| 84 | const auto state = process_sp->GetState(); |
| 85 | if (process_sp->IsAlive() && state == eStateConnected) { |
| 86 | // If we are already connected, then we have already specified the |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 87 | // listener, so if a valid listener is supplied, we need to error out to |
| 88 | // let the client know. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 89 | if (attach_info.GetListener()) |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 90 | return Status("process is connected and already has a listener, pass " |
| 91 | "empty listener"); |
Oleksiy Vyalov | 3738614 | 2015-02-10 22:49:57 +0000 | [diff] [blame] | 92 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 93 | } |
Oleksiy Vyalov | 3738614 | 2015-02-10 22:49:57 +0000 | [diff] [blame] | 94 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 95 | return target.Attach(attach_info, nullptr); |
Oleksiy Vyalov | 3738614 | 2015-02-10 22:49:57 +0000 | [diff] [blame] | 96 | } |
| 97 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 98 | } // namespace |
Oleksiy Vyalov | 3738614 | 2015-02-10 22:49:57 +0000 | [diff] [blame] | 99 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 100 | // SBTarget constructor |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 101 | SBTarget::SBTarget() : m_opaque_sp() { |
| 102 | LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget); |
| 103 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 105 | SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) { |
| 106 | LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs); |
| 107 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 109 | SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) { |
| 110 | LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp); |
| 111 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 112 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 113 | const SBTarget &SBTarget::operator=(const SBTarget &rhs) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 114 | LLDB_RECORD_METHOD(const lldb::SBTarget &, |
| 115 | SBTarget, operator=,(const lldb::SBTarget &), rhs); |
| 116 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 117 | if (this != &rhs) |
| 118 | m_opaque_sp = rhs.m_opaque_sp; |
Jonas Devlieghere | 306809f | 2019-04-03 21:31:22 +0000 | [diff] [blame] | 119 | return LLDB_RECORD_RESULT(*this); |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 122 | // Destructor |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 123 | SBTarget::~SBTarget() {} |
| 124 | |
| 125 | bool SBTarget::EventIsTargetEvent(const SBEvent &event) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 126 | LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, |
| 127 | (const lldb::SBEvent &), event); |
| 128 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 129 | return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 132 | SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 133 | LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, |
| 134 | (const lldb::SBEvent &), event); |
| 135 | |
| 136 | return LLDB_RECORD_RESULT( |
| 137 | Target::TargetEventData::GetTargetFromEvent(event.get())); |
Ilia K | eb2c19a | 2015-03-10 21:59:55 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 140 | uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 141 | LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, |
| 142 | (const lldb::SBEvent &), event); |
| 143 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 144 | const ModuleList module_list = |
| 145 | Target::TargetEventData::GetModuleListFromEvent(event.get()); |
| 146 | return module_list.GetSize(); |
Ilia K | eb2c19a | 2015-03-10 21:59:55 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 149 | SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx, |
| 150 | const SBEvent &event) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 151 | LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent, |
| 152 | (const uint32_t, const lldb::SBEvent &), idx, |
| 153 | event); |
| 154 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 155 | const ModuleList module_list = |
| 156 | Target::TargetEventData::GetModuleListFromEvent(event.get()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 157 | return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx))); |
Ilia K | eb2c19a | 2015-03-10 21:59:55 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 160 | const char *SBTarget::GetBroadcasterClassName() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 161 | LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget, |
| 162 | GetBroadcasterClassName); |
| 163 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 164 | return Target::GetStaticBroadcasterClass().AsCString(); |
Ilia K | eb2c19a | 2015-03-10 21:59:55 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 167 | bool SBTarget::IsValid() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 168 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid); |
Pavel Labath | 7f5237b | 2019-03-11 13:58:46 +0000 | [diff] [blame] | 169 | return this->operator bool(); |
| 170 | } |
| 171 | SBTarget::operator bool() const { |
| 172 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 173 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 174 | return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid(); |
Jim Ingham | 4bddaeb | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 177 | SBProcess SBTarget::GetProcess() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 178 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess); |
| 179 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 180 | SBProcess sb_process; |
| 181 | ProcessSP process_sp; |
| 182 | TargetSP target_sp(GetSP()); |
| 183 | if (target_sp) { |
| 184 | process_sp = target_sp->GetProcessSP(); |
| 185 | sb_process.SetSP(process_sp); |
| 186 | } |
| 187 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 188 | return LLDB_RECORD_RESULT(sb_process); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 191 | SBPlatform SBTarget::GetPlatform() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 192 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform); |
| 193 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 194 | TargetSP target_sp(GetSP()); |
| 195 | if (!target_sp) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 196 | return LLDB_RECORD_RESULT(SBPlatform()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 197 | |
| 198 | SBPlatform platform; |
| 199 | platform.m_opaque_sp = target_sp->GetPlatform(); |
| 200 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 201 | return LLDB_RECORD_RESULT(platform); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | SBDebugger SBTarget::GetDebugger() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 205 | LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger); |
| 206 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 207 | SBDebugger debugger; |
| 208 | TargetSP target_sp(GetSP()); |
| 209 | if (target_sp) |
| 210 | debugger.reset(target_sp->GetDebugger().shared_from_this()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 211 | return LLDB_RECORD_RESULT(debugger); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 212 | } |
| 213 | |
Davide Italiano | 4a6a2b1 | 2018-04-16 22:55:34 +0000 | [diff] [blame] | 214 | SBStructuredData SBTarget::GetStatistics() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 215 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics); |
| 216 | |
Davide Italiano | 4a6a2b1 | 2018-04-16 22:55:34 +0000 | [diff] [blame] | 217 | SBStructuredData data; |
| 218 | TargetSP target_sp(GetSP()); |
| 219 | if (!target_sp) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 220 | return LLDB_RECORD_RESULT(data); |
Davide Italiano | 4a6a2b1 | 2018-04-16 22:55:34 +0000 | [diff] [blame] | 221 | |
| 222 | auto stats_up = llvm::make_unique<StructuredData::Dictionary>(); |
| 223 | int i = 0; |
| 224 | for (auto &Entry : target_sp->GetStatistics()) { |
| 225 | std::string Desc = lldb_private::GetStatDescription( |
| 226 | static_cast<lldb_private::StatisticKind>(i)); |
| 227 | stats_up->AddIntegerItem(Desc, Entry); |
| 228 | i += 1; |
| 229 | } |
| 230 | |
| 231 | data.m_impl_up->SetObjectSP(std::move(stats_up)); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 232 | return LLDB_RECORD_RESULT(data); |
Davide Italiano | 4a6a2b1 | 2018-04-16 22:55:34 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Davide Italiano | e174746 | 2018-09-28 23:27:54 +0000 | [diff] [blame] | 235 | void SBTarget::SetCollectingStats(bool v) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 236 | LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v); |
| 237 | |
Davide Italiano | e174746 | 2018-09-28 23:27:54 +0000 | [diff] [blame] | 238 | TargetSP target_sp(GetSP()); |
| 239 | if (!target_sp) |
| 240 | return; |
| 241 | return target_sp->SetCollectingStats(v); |
| 242 | } |
| 243 | |
| 244 | bool SBTarget::GetCollectingStats() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 245 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats); |
| 246 | |
Davide Italiano | e174746 | 2018-09-28 23:27:54 +0000 | [diff] [blame] | 247 | TargetSP target_sp(GetSP()); |
| 248 | if (!target_sp) |
| 249 | return false; |
| 250 | return target_sp->GetCollectingStats(); |
| 251 | } |
| 252 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 253 | SBProcess SBTarget::LoadCore(const char *core_file) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 254 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *), |
| 255 | core_file); |
| 256 | |
Leonard Mosescu | e1bb517 | 2018-06-11 21:19:26 +0000 | [diff] [blame] | 257 | lldb::SBError error; // Ignored |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 258 | return LLDB_RECORD_RESULT(LoadCore(core_file, error)); |
Leonard Mosescu | e1bb517 | 2018-06-11 21:19:26 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 262 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, |
| 263 | (const char *, lldb::SBError &), core_file, error); |
| 264 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 265 | SBProcess sb_process; |
| 266 | TargetSP target_sp(GetSP()); |
| 267 | if (target_sp) { |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 268 | FileSpec filespec(core_file); |
| 269 | FileSystem::Instance().Resolve(filespec); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 270 | ProcessSP process_sp(target_sp->CreateProcess( |
Zachary Turner | 3165945 | 2016-11-17 21:15:14 +0000 | [diff] [blame] | 271 | target_sp->GetDebugger().GetListener(), "", &filespec)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 272 | if (process_sp) { |
Leonard Mosescu | e1bb517 | 2018-06-11 21:19:26 +0000 | [diff] [blame] | 273 | error.SetError(process_sp->LoadCore()); |
| 274 | if (error.Success()) |
| 275 | sb_process.SetSP(process_sp); |
| 276 | } else { |
| 277 | error.SetErrorString("Failed to create the process"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 278 | } |
Leonard Mosescu | e1bb517 | 2018-06-11 21:19:26 +0000 | [diff] [blame] | 279 | } else { |
| 280 | error.SetErrorString("SBTarget is invalid"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 281 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 282 | return LLDB_RECORD_RESULT(sb_process); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, |
| 286 | const char *working_directory) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 287 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, |
| 288 | (const char **, const char **, const char *), argv, envp, |
| 289 | working_directory); |
| 290 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 291 | char *stdin_path = nullptr; |
| 292 | char *stdout_path = nullptr; |
| 293 | char *stderr_path = nullptr; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 294 | uint32_t launch_flags = 0; |
| 295 | bool stop_at_entry = false; |
| 296 | SBError error; |
| 297 | SBListener listener = GetDebugger().GetListener(); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 298 | return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path, |
| 299 | stdout_path, stderr_path, working_directory, |
| 300 | launch_flags, stop_at_entry, error)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | SBError SBTarget::Install() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 304 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install); |
| 305 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 306 | SBError sb_error; |
| 307 | TargetSP target_sp(GetSP()); |
| 308 | if (target_sp) { |
| 309 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 310 | sb_error.ref() = target_sp->Install(nullptr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 311 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 312 | return LLDB_RECORD_RESULT(sb_error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | SBProcess SBTarget::Launch(SBListener &listener, char const **argv, |
| 316 | char const **envp, const char *stdin_path, |
| 317 | const char *stdout_path, const char *stderr_path, |
| 318 | const char *working_directory, |
| 319 | uint32_t launch_flags, // See LaunchFlags |
| 320 | bool stop_at_entry, lldb::SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 321 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, |
| 322 | (lldb::SBListener &, const char **, const char **, |
| 323 | const char *, const char *, const char *, const char *, |
| 324 | uint32_t, bool, lldb::SBError &), |
| 325 | listener, argv, envp, stdin_path, stdout_path, stderr_path, |
| 326 | working_directory, launch_flags, stop_at_entry, error); |
| 327 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 328 | SBProcess sb_process; |
| 329 | ProcessSP process_sp; |
| 330 | TargetSP target_sp(GetSP()); |
| 331 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 332 | if (target_sp) { |
| 333 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 334 | |
| 335 | if (stop_at_entry) |
| 336 | launch_flags |= eLaunchFlagStopAtEntry; |
| 337 | |
| 338 | if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR")) |
| 339 | launch_flags |= eLaunchFlagDisableASLR; |
| 340 | |
| 341 | StateType state = eStateInvalid; |
| 342 | process_sp = target_sp->GetProcessSP(); |
| 343 | if (process_sp) { |
| 344 | state = process_sp->GetState(); |
| 345 | |
| 346 | if (process_sp->IsAlive() && state != eStateConnected) { |
| 347 | if (state == eStateAttaching) |
| 348 | error.SetErrorString("process attach is in progress"); |
| 349 | else |
| 350 | error.SetErrorString("a process is already being debugged"); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 351 | return LLDB_RECORD_RESULT(sb_process); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 352 | } |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 353 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 354 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 355 | if (state == eStateConnected) { |
| 356 | // If we are already connected, then we have already specified the |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 357 | // listener, so if a valid listener is supplied, we need to error out to |
| 358 | // let the client know. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 359 | if (listener.IsValid()) { |
| 360 | error.SetErrorString("process is connected and already has a listener, " |
| 361 | "pass empty listener"); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 362 | return LLDB_RECORD_RESULT(sb_process); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 363 | } |
| 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 (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) |
| 367 | launch_flags |= eLaunchFlagDisableSTDIO; |
| 368 | |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 369 | ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path), |
| 370 | FileSpec(stderr_path), |
| 371 | FileSpec(working_directory), launch_flags); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 372 | |
| 373 | Module *exe_module = target_sp->GetExecutableModulePointer(); |
| 374 | if (exe_module) |
| 375 | launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); |
| 376 | if (argv) |
| 377 | launch_info.GetArguments().AppendArguments(argv); |
| 378 | if (envp) |
Pavel Labath | 62930e5 | 2018-01-10 11:57:31 +0000 | [diff] [blame] | 379 | launch_info.GetEnvironment() = Environment(envp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 380 | |
| 381 | if (listener.IsValid()) |
| 382 | launch_info.SetListener(listener.GetSP()); |
| 383 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 384 | error.SetError(target_sp->Launch(launch_info, nullptr)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 385 | |
| 386 | sb_process.SetSP(target_sp->GetProcessSP()); |
| 387 | } else { |
| 388 | error.SetErrorString("SBTarget is invalid"); |
| 389 | } |
| 390 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 391 | return LLDB_RECORD_RESULT(sb_process); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 394 | SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 395 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, |
| 396 | (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info, |
| 397 | error); |
| 398 | |
Matthew Gardiner | c928de3 | 2014-10-22 07:22:56 +0000 | [diff] [blame] | 399 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 400 | SBProcess sb_process; |
| 401 | TargetSP target_sp(GetSP()); |
Matthew Gardiner | c928de3 | 2014-10-22 07:22:56 +0000 | [diff] [blame] | 402 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 403 | if (target_sp) { |
| 404 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 405 | StateType state = eStateInvalid; |
Greg Clayton | 4d8ad55 | 2013-03-25 22:40:51 +0000 | [diff] [blame] | 406 | { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 407 | ProcessSP process_sp = target_sp->GetProcessSP(); |
| 408 | if (process_sp) { |
| 409 | state = process_sp->GetState(); |
| 410 | |
| 411 | if (process_sp->IsAlive() && state != eStateConnected) { |
| 412 | if (state == eStateAttaching) |
| 413 | error.SetErrorString("process attach is in progress"); |
| 414 | else |
| 415 | error.SetErrorString("a process is already being debugged"); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 416 | return LLDB_RECORD_RESULT(sb_process); |
Greg Clayton | 4d8ad55 | 2013-03-25 22:40:51 +0000 | [diff] [blame] | 417 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 418 | } |
Greg Clayton | 4d8ad55 | 2013-03-25 22:40:51 +0000 | [diff] [blame] | 419 | } |
Greg Clayton | 4d8ad55 | 2013-03-25 22:40:51 +0000 | [diff] [blame] | 420 | |
Pavel Labath | 62930e5 | 2018-01-10 11:57:31 +0000 | [diff] [blame] | 421 | lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref(); |
Greg Clayton | bd82a5d | 2011-01-23 05:56:20 +0000 | [diff] [blame] | 422 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 423 | if (!launch_info.GetExecutableFile()) { |
| 424 | Module *exe_module = target_sp->GetExecutableModulePointer(); |
| 425 | if (exe_module) |
| 426 | launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 427 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 428 | |
| 429 | const ArchSpec &arch_spec = target_sp->GetArchitecture(); |
| 430 | if (arch_spec.IsValid()) |
| 431 | launch_info.GetArchitecture() = arch_spec; |
| 432 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 433 | error.SetError(target_sp->Launch(launch_info, nullptr)); |
Pavel Labath | 62930e5 | 2018-01-10 11:57:31 +0000 | [diff] [blame] | 434 | sb_launch_info.set_ref(launch_info); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 435 | sb_process.SetSP(target_sp->GetProcessSP()); |
| 436 | } else { |
| 437 | error.SetErrorString("SBTarget is invalid"); |
| 438 | } |
| 439 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 440 | return LLDB_RECORD_RESULT(sb_process); |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 441 | } |
| 442 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 443 | lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 444 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach, |
| 445 | (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info, |
| 446 | error); |
| 447 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 448 | SBProcess sb_process; |
| 449 | TargetSP target_sp(GetSP()); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 450 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 451 | if (target_sp) { |
| 452 | ProcessAttachInfo &attach_info = sb_attach_info.ref(); |
| 453 | if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) { |
| 454 | PlatformSP platform_sp = target_sp->GetPlatform(); |
| 455 | // See if we can pre-verify if a process exists or not |
| 456 | if (platform_sp && platform_sp->IsConnected()) { |
| 457 | lldb::pid_t attach_pid = attach_info.GetProcessID(); |
| 458 | ProcessInstanceInfo instance_info; |
| 459 | if (platform_sp->GetProcessInfo(attach_pid, instance_info)) { |
| 460 | attach_info.SetUserID(instance_info.GetEffectiveUserID()); |
| 461 | } else { |
| 462 | error.ref().SetErrorStringWithFormat( |
| 463 | "no process found with process ID %" PRIu64, attach_pid); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 464 | return LLDB_RECORD_RESULT(sb_process); |
Greg Clayton | 931180e | 2011-01-27 06:44:37 +0000 | [diff] [blame] | 465 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 466 | } |
Greg Clayton | 524e60b | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 467 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 468 | error.SetError(AttachToProcess(attach_info, *target_sp)); |
| 469 | if (error.Success()) |
| 470 | sb_process.SetSP(target_sp->GetProcessSP()); |
| 471 | } else { |
| 472 | error.SetErrorString("SBTarget is invalid"); |
| 473 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 474 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 475 | return LLDB_RECORD_RESULT(sb_process); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 476 | } |
| 477 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 478 | lldb::SBProcess SBTarget::AttachToProcessWithID( |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 479 | SBListener &listener, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 480 | lldb::pid_t pid, // The process ID to attach to |
| 481 | SBError &error // An error explaining what went wrong if attach fails |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 482 | ) { |
| 483 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, |
| 484 | (lldb::SBListener &, lldb::pid_t, lldb::SBError &), |
| 485 | listener, pid, error); |
| 486 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 487 | SBProcess sb_process; |
| 488 | TargetSP target_sp(GetSP()); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 489 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 490 | if (target_sp) { |
| 491 | ProcessAttachInfo attach_info; |
| 492 | attach_info.SetProcessID(pid); |
| 493 | if (listener.IsValid()) |
| 494 | attach_info.SetListener(listener.GetSP()); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 495 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 496 | ProcessInstanceInfo instance_info; |
| 497 | if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info)) |
| 498 | attach_info.SetUserID(instance_info.GetEffectiveUserID()); |
| 499 | |
| 500 | error.SetError(AttachToProcess(attach_info, *target_sp)); |
| 501 | if (error.Success()) |
| 502 | sb_process.SetSP(target_sp->GetProcessSP()); |
| 503 | } else |
| 504 | error.SetErrorString("SBTarget is invalid"); |
| 505 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 506 | return LLDB_RECORD_RESULT(sb_process); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | lldb::SBProcess SBTarget::AttachToProcessWithName( |
| 510 | SBListener &listener, |
| 511 | const char *name, // basename of process to attach to |
| 512 | bool wait_for, // if true wait for a new instance of "name" to be launched |
| 513 | SBError &error // An error explaining what went wrong if attach fails |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 514 | ) { |
| 515 | LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName, |
| 516 | (lldb::SBListener &, const char *, bool, lldb::SBError &), |
| 517 | listener, name, wait_for, error); |
| 518 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 519 | SBProcess sb_process; |
| 520 | TargetSP target_sp(GetSP()); |
| 521 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 522 | if (name && target_sp) { |
| 523 | ProcessAttachInfo attach_info; |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 524 | attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 525 | attach_info.SetWaitForLaunch(wait_for); |
| 526 | if (listener.IsValid()) |
| 527 | attach_info.SetListener(listener.GetSP()); |
| 528 | |
| 529 | error.SetError(AttachToProcess(attach_info, *target_sp)); |
| 530 | if (error.Success()) |
| 531 | sb_process.SetSP(target_sp->GetProcessSP()); |
| 532 | } else |
| 533 | error.SetErrorString("SBTarget is invalid"); |
| 534 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 535 | return LLDB_RECORD_RESULT(sb_process); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, |
| 539 | const char *plugin_name, |
| 540 | SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 541 | LLDB_RECORD_METHOD( |
| 542 | lldb::SBProcess, SBTarget, ConnectRemote, |
| 543 | (lldb::SBListener &, const char *, const char *, lldb::SBError &), |
| 544 | listener, url, plugin_name, error); |
| 545 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 546 | SBProcess sb_process; |
| 547 | ProcessSP process_sp; |
| 548 | TargetSP target_sp(GetSP()); |
| 549 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 550 | if (target_sp) { |
| 551 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 552 | if (listener.IsValid()) |
| 553 | process_sp = |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 554 | target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 555 | else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 556 | process_sp = target_sp->CreateProcess( |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 557 | target_sp->GetDebugger().GetListener(), plugin_name, nullptr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 558 | |
| 559 | if (process_sp) { |
| 560 | sb_process.SetSP(process_sp); |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 561 | error.SetError(process_sp->ConnectRemote(nullptr, url)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 562 | } else { |
| 563 | error.SetErrorString("unable to create lldb_private::Process"); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 564 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 565 | } else { |
| 566 | error.SetErrorString("SBTarget is invalid"); |
| 567 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 568 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 569 | return LLDB_RECORD_RESULT(sb_process); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 570 | } |
| 571 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 572 | SBFileSpec SBTarget::GetExecutable() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 573 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 574 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 575 | SBFileSpec exe_file_spec; |
| 576 | TargetSP target_sp(GetSP()); |
| 577 | if (target_sp) { |
| 578 | Module *exe_module = target_sp->GetExecutableModulePointer(); |
| 579 | if (exe_module) |
| 580 | exe_file_spec.SetFileSpec(exe_module->GetFileSpec()); |
| 581 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 582 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 583 | return LLDB_RECORD_RESULT(exe_file_spec); |
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 | bool SBTarget::operator==(const SBTarget &rhs) const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 587 | LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &), |
| 588 | rhs); |
| 589 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 590 | return m_opaque_sp.get() == rhs.m_opaque_sp.get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 591 | } |
| 592 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 593 | bool SBTarget::operator!=(const SBTarget &rhs) const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 594 | LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &), |
| 595 | rhs); |
| 596 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 597 | return m_opaque_sp.get() != rhs.m_opaque_sp.get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 600 | lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; } |
| 601 | |
| 602 | void SBTarget::SetSP(const lldb::TargetSP &target_sp) { |
| 603 | m_opaque_sp = target_sp; |
Greg Clayton | 9a37766 | 2011-10-01 02:59:24 +0000 | [diff] [blame] | 604 | } |
| 605 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 606 | lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 607 | LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, |
| 608 | (lldb::addr_t), vm_addr); |
| 609 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 610 | lldb::SBAddress sb_addr; |
| 611 | Address &addr = sb_addr.ref(); |
| 612 | TargetSP target_sp(GetSP()); |
| 613 | if (target_sp) { |
| 614 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 615 | if (target_sp->ResolveLoadAddress(vm_addr, addr)) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 616 | return LLDB_RECORD_RESULT(sb_addr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | // We have a load address that isn't in a section, just return an address |
| 620 | // with the offset filled in (the address) and the section set to NULL |
| 621 | addr.SetRawAddress(vm_addr); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 622 | return LLDB_RECORD_RESULT(sb_addr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 623 | } |
| 624 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 625 | lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 626 | LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, |
| 627 | (lldb::addr_t), file_addr); |
| 628 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 629 | lldb::SBAddress sb_addr; |
| 630 | Address &addr = sb_addr.ref(); |
| 631 | TargetSP target_sp(GetSP()); |
| 632 | if (target_sp) { |
| 633 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 634 | if (target_sp->ResolveFileAddress(file_addr, addr)) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 635 | return LLDB_RECORD_RESULT(sb_addr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 636 | } |
Greg Clayton | ac2eb9b | 2010-12-12 19:25:26 +0000 | [diff] [blame] | 637 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 638 | addr.SetRawAddress(file_addr); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 639 | return LLDB_RECORD_RESULT(sb_addr); |
Greg Clayton | ac2eb9b | 2010-12-12 19:25:26 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 642 | lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id, |
| 643 | lldb::addr_t vm_addr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 644 | LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, |
| 645 | (uint32_t, lldb::addr_t), stop_id, vm_addr); |
| 646 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 647 | lldb::SBAddress sb_addr; |
| 648 | Address &addr = sb_addr.ref(); |
| 649 | TargetSP target_sp(GetSP()); |
| 650 | if (target_sp) { |
| 651 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 652 | if (target_sp->ResolveLoadAddress(vm_addr, addr)) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 653 | return LLDB_RECORD_RESULT(sb_addr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 654 | } |
Matthew Gardiner | c928de3 | 2014-10-22 07:22:56 +0000 | [diff] [blame] | 655 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 656 | // We have a load address that isn't in a section, just return an address |
| 657 | // with the offset filled in (the address) and the section set to NULL |
| 658 | addr.SetRawAddress(vm_addr); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 659 | return LLDB_RECORD_RESULT(sb_addr); |
Greg Clayton | d5944cd | 2013-12-06 01:12:00 +0000 | [diff] [blame] | 660 | } |
| 661 | |
Greg Clayton | 5f2a4f9 | 2011-03-02 21:34:46 +0000 | [diff] [blame] | 662 | SBSymbolContext |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 663 | SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, |
| 664 | uint32_t resolve_scope) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 665 | LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget, |
| 666 | ResolveSymbolContextForAddress, |
| 667 | (const lldb::SBAddress &, uint32_t), addr, resolve_scope); |
| 668 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 669 | SBSymbolContext sc; |
Zachary Turner | 991e445 | 2018-10-25 20:45:19 +0000 | [diff] [blame] | 670 | SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 671 | if (addr.IsValid()) { |
Matthew Gardiner | c928de3 | 2014-10-22 07:22:56 +0000 | [diff] [blame] | 672 | TargetSP target_sp(GetSP()); |
| 673 | if (target_sp) |
Zachary Turner | 991e445 | 2018-10-25 20:45:19 +0000 | [diff] [blame] | 674 | target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope, |
| 675 | sc.ref()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 676 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 677 | return LLDB_RECORD_RESULT(sc); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 678 | } |
Matthew Gardiner | c928de3 | 2014-10-22 07:22:56 +0000 | [diff] [blame] | 679 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 680 | size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, |
| 681 | lldb::SBError &error) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 682 | LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory, |
| 683 | (const lldb::SBAddress, void *, size_t, lldb::SBError &), |
| 684 | addr, buf, size, error); |
| 685 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 686 | SBError sb_error; |
| 687 | size_t bytes_read = 0; |
| 688 | TargetSP target_sp(GetSP()); |
| 689 | if (target_sp) { |
| 690 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 691 | bytes_read = |
| 692 | target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref()); |
| 693 | } else { |
| 694 | sb_error.SetErrorString("invalid target"); |
| 695 | } |
| 696 | |
| 697 | return bytes_read; |
| 698 | } |
| 699 | |
| 700 | SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file, |
| 701 | uint32_t line) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 702 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, |
| 703 | (const char *, uint32_t), file, line); |
| 704 | |
| 705 | return LLDB_RECORD_RESULT( |
| 706 | SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line))); |
Matthew Gardiner | c928de3 | 2014-10-22 07:22:56 +0000 | [diff] [blame] | 707 | } |
Greg Clayton | 5f2a4f9 | 2011-03-02 21:34:46 +0000 | [diff] [blame] | 708 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 709 | SBBreakpoint |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 710 | SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, |
| 711 | uint32_t line) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 712 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, |
| 713 | (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line); |
| 714 | |
| 715 | return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | SBBreakpoint |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 719 | SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, |
| 720 | uint32_t line, lldb::addr_t offset) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 721 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, |
| 722 | (const lldb::SBFileSpec &, uint32_t, lldb::addr_t), |
| 723 | sb_file_spec, line, offset); |
| 724 | |
Jim Ingham | 92d1960 | 2016-09-20 22:54:49 +0000 | [diff] [blame] | 725 | SBFileSpecList empty_list; |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 726 | return LLDB_RECORD_RESULT( |
| 727 | BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list)); |
Jim Ingham | 92d1960 | 2016-09-20 22:54:49 +0000 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | SBBreakpoint |
| 731 | SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, |
| 732 | uint32_t line, lldb::addr_t offset, |
| 733 | SBFileSpecList &sb_module_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 734 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, |
| 735 | (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, |
| 736 | lldb::SBFileSpecList &), |
| 737 | sb_file_spec, line, offset, sb_module_list); |
| 738 | |
| 739 | return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0, |
| 740 | offset, sb_module_list)); |
Adrian Prantl | 431b158 | 2018-08-30 15:11:00 +0000 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | SBBreakpoint SBTarget::BreakpointCreateByLocation( |
| 744 | const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column, |
| 745 | lldb::addr_t offset, SBFileSpecList &sb_module_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 746 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, |
| 747 | (const lldb::SBFileSpec &, uint32_t, uint32_t, |
| 748 | lldb::addr_t, lldb::SBFileSpecList &), |
| 749 | sb_file_spec, line, column, offset, sb_module_list); |
| 750 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 751 | SBBreakpoint sb_bp; |
| 752 | TargetSP target_sp(GetSP()); |
| 753 | if (target_sp && line != 0) { |
| 754 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 755 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 756 | const LazyBool check_inlines = eLazyBoolCalculate; |
| 757 | const LazyBool skip_prologue = eLazyBoolCalculate; |
| 758 | const bool internal = false; |
| 759 | const bool hardware = false; |
| 760 | const LazyBool move_to_nearest_code = eLazyBoolCalculate; |
Jim Ingham | 92d1960 | 2016-09-20 22:54:49 +0000 | [diff] [blame] | 761 | const FileSpecList *module_list = nullptr; |
| 762 | if (sb_module_list.GetSize() > 0) { |
| 763 | module_list = sb_module_list.get(); |
| 764 | } |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 765 | sb_bp = target_sp->CreateBreakpoint( |
Adrian Prantl | 431b158 | 2018-08-30 15:11:00 +0000 | [diff] [blame] | 766 | module_list, *sb_file_spec, line, column, offset, check_inlines, |
| 767 | skip_prologue, internal, hardware, move_to_nearest_code); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 768 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 769 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 770 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, |
| 774 | const char *module_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 775 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 776 | (const char *, const char *), symbol_name, module_name); |
| 777 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 778 | SBBreakpoint sb_bp; |
| 779 | TargetSP target_sp(GetSP()); |
| 780 | if (target_sp.get()) { |
| 781 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 782 | |
| 783 | const bool internal = false; |
| 784 | const bool hardware = false; |
| 785 | const LazyBool skip_prologue = eLazyBoolCalculate; |
| 786 | const lldb::addr_t offset = 0; |
| 787 | if (module_name && module_name[0]) { |
| 788 | FileSpecList module_spec_list; |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 789 | module_spec_list.Append(FileSpec(module_name)); |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 790 | sb_bp = target_sp->CreateBreakpoint( |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 791 | &module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 792 | eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); |
| 793 | } else { |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 794 | sb_bp = target_sp->CreateBreakpoint( |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 795 | nullptr, nullptr, symbol_name, eFunctionNameTypeAuto, |
| 796 | eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 797 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 798 | } |
| 799 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 800 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | lldb::SBBreakpoint |
| 804 | SBTarget::BreakpointCreateByName(const char *symbol_name, |
| 805 | const SBFileSpecList &module_list, |
| 806 | const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 807 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 808 | (const char *, const lldb::SBFileSpecList &, |
| 809 | const lldb::SBFileSpecList &), |
| 810 | symbol_name, module_list, comp_unit_list); |
| 811 | |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 812 | lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto; |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 813 | return LLDB_RECORD_RESULT( |
| 814 | BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, |
| 815 | module_list, comp_unit_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | lldb::SBBreakpoint SBTarget::BreakpointCreateByName( |
| 819 | const char *symbol_name, uint32_t name_type_mask, |
| 820 | const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 821 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 822 | (const char *, uint32_t, const lldb::SBFileSpecList &, |
| 823 | const lldb::SBFileSpecList &), |
| 824 | symbol_name, name_type_mask, module_list, comp_unit_list); |
| 825 | |
| 826 | return LLDB_RECORD_RESULT( |
| 827 | BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, |
| 828 | module_list, comp_unit_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | lldb::SBBreakpoint SBTarget::BreakpointCreateByName( |
| 832 | const char *symbol_name, uint32_t name_type_mask, |
| 833 | LanguageType symbol_language, const SBFileSpecList &module_list, |
| 834 | const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 835 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 836 | (const char *, uint32_t, lldb::LanguageType, |
| 837 | const lldb::SBFileSpecList &, |
| 838 | const lldb::SBFileSpecList &), |
| 839 | symbol_name, name_type_mask, symbol_language, module_list, |
| 840 | comp_unit_list); |
| 841 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 842 | SBBreakpoint sb_bp; |
| 843 | TargetSP target_sp(GetSP()); |
| 844 | if (target_sp && symbol_name && symbol_name[0]) { |
| 845 | const bool internal = false; |
| 846 | const bool hardware = false; |
| 847 | const LazyBool skip_prologue = eLazyBoolCalculate; |
| 848 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 849 | FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); |
| 850 | sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(), |
| 851 | symbol_name, mask, symbol_language, 0, |
| 852 | skip_prologue, internal, hardware); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 853 | } |
| 854 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 855 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( |
| 859 | const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, |
| 860 | const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 861 | LLDB_RECORD_METHOD( |
| 862 | lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, |
| 863 | (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &, |
| 864 | const lldb::SBFileSpecList &), |
| 865 | symbol_names, num_names, name_type_mask, module_list, comp_unit_list); |
| 866 | |
| 867 | return LLDB_RECORD_RESULT(BreakpointCreateByNames( |
| 868 | symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, |
| 869 | module_list, comp_unit_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( |
| 873 | const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, |
| 874 | LanguageType symbol_language, const SBFileSpecList &module_list, |
| 875 | const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 876 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, |
| 877 | (const char **, uint32_t, uint32_t, lldb::LanguageType, |
| 878 | const lldb::SBFileSpecList &, |
| 879 | const lldb::SBFileSpecList &), |
| 880 | symbol_names, num_names, name_type_mask, symbol_language, |
| 881 | module_list, comp_unit_list); |
| 882 | |
| 883 | return LLDB_RECORD_RESULT(BreakpointCreateByNames( |
| 884 | symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, |
| 885 | module_list, comp_unit_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( |
| 889 | const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, |
| 890 | LanguageType symbol_language, lldb::addr_t offset, |
| 891 | const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 892 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, |
| 893 | (const char **, uint32_t, uint32_t, lldb::LanguageType, |
| 894 | lldb::addr_t, const lldb::SBFileSpecList &, |
| 895 | const lldb::SBFileSpecList &), |
| 896 | symbol_names, num_names, name_type_mask, symbol_language, |
| 897 | offset, module_list, comp_unit_list); |
| 898 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 899 | SBBreakpoint sb_bp; |
| 900 | TargetSP target_sp(GetSP()); |
| 901 | if (target_sp && num_names > 0) { |
| 902 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 903 | const bool internal = false; |
| 904 | const bool hardware = false; |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 905 | FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 906 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 907 | sb_bp = target_sp->CreateBreakpoint( |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 908 | module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask, |
| 909 | symbol_language, offset, skip_prologue, internal, hardware); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 910 | } |
| 911 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 912 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, |
| 916 | const char *module_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 917 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, |
| 918 | (const char *, const char *), symbol_name_regex, |
| 919 | module_name); |
| 920 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 921 | SBFileSpecList module_spec_list; |
| 922 | SBFileSpecList comp_unit_list; |
| 923 | if (module_name && module_name[0]) { |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 924 | module_spec_list.Append(FileSpec(module_name)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 925 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 926 | return LLDB_RECORD_RESULT( |
| 927 | BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, |
| 928 | module_spec_list, comp_unit_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | lldb::SBBreakpoint |
| 932 | SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, |
| 933 | const SBFileSpecList &module_list, |
| 934 | const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 935 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, |
| 936 | (const char *, const lldb::SBFileSpecList &, |
| 937 | const lldb::SBFileSpecList &), |
| 938 | symbol_name_regex, module_list, comp_unit_list); |
| 939 | |
| 940 | return LLDB_RECORD_RESULT(BreakpointCreateByRegex( |
| 941 | symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( |
| 945 | const char *symbol_name_regex, LanguageType symbol_language, |
| 946 | const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 947 | LLDB_RECORD_METHOD( |
| 948 | lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, |
| 949 | (const char *, lldb::LanguageType, const lldb::SBFileSpecList &, |
| 950 | const lldb::SBFileSpecList &), |
| 951 | symbol_name_regex, symbol_language, module_list, comp_unit_list); |
| 952 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 953 | |
| 954 | SBBreakpoint sb_bp; |
| 955 | TargetSP target_sp(GetSP()); |
| 956 | if (target_sp && symbol_name_regex && symbol_name_regex[0]) { |
| 957 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Zachary Turner | 95eae42 | 2016-09-21 16:01:28 +0000 | [diff] [blame] | 958 | RegularExpression regexp((llvm::StringRef(symbol_name_regex))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 959 | const bool internal = false; |
| 960 | const bool hardware = false; |
| 961 | const LazyBool skip_prologue = eLazyBoolCalculate; |
| 962 | |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 963 | sb_bp = target_sp->CreateFuncRegexBreakpoint( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 964 | module_list.get(), comp_unit_list.get(), regexp, symbol_language, |
| 965 | skip_prologue, internal, hardware); |
| 966 | } |
| 967 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 968 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 972 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress, |
| 973 | (lldb::addr_t), address); |
| 974 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 975 | SBBreakpoint sb_bp; |
| 976 | TargetSP target_sp(GetSP()); |
| 977 | if (target_sp) { |
| 978 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 979 | const bool hardware = false; |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 980 | sb_bp = target_sp->CreateBreakpoint(address, false, hardware); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 981 | } |
| 982 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 983 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 987 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress, |
| 988 | (lldb::SBAddress &), sb_address); |
| 989 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 990 | SBBreakpoint sb_bp; |
| 991 | TargetSP target_sp(GetSP()); |
| 992 | if (!sb_address.IsValid()) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 993 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | if (target_sp) { |
| 997 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 998 | const bool hardware = false; |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 999 | sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1000 | } |
| 1001 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1002 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | lldb::SBBreakpoint |
| 1006 | SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, |
| 1007 | const lldb::SBFileSpec &source_file, |
| 1008 | const char *module_name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1009 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, |
| 1010 | BreakpointCreateBySourceRegex, |
| 1011 | (const char *, const lldb::SBFileSpec &, const char *), |
| 1012 | source_regex, source_file, module_name); |
| 1013 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1014 | SBFileSpecList module_spec_list; |
| 1015 | |
| 1016 | if (module_name && module_name[0]) { |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 1017 | module_spec_list.Append(FileSpec(module_name)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | SBFileSpecList source_file_list; |
| 1021 | if (source_file.IsValid()) { |
| 1022 | source_file_list.Append(source_file); |
| 1023 | } |
| 1024 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1025 | return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( |
| 1026 | source_regex, module_spec_list, source_file_list)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( |
| 1030 | const char *source_regex, const SBFileSpecList &module_list, |
| 1031 | const lldb::SBFileSpecList &source_file_list) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1032 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, |
| 1033 | BreakpointCreateBySourceRegex, |
| 1034 | (const char *, const lldb::SBFileSpecList &, |
| 1035 | const lldb::SBFileSpecList &), |
| 1036 | source_regex, module_list, source_file_list); |
| 1037 | |
| 1038 | return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( |
| 1039 | source_regex, module_list, source_file_list, SBStringList())); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( |
| 1043 | const char *source_regex, const SBFileSpecList &module_list, |
| 1044 | const lldb::SBFileSpecList &source_file_list, |
| 1045 | const SBStringList &func_names) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1046 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, |
| 1047 | BreakpointCreateBySourceRegex, |
| 1048 | (const char *, const lldb::SBFileSpecList &, |
| 1049 | const lldb::SBFileSpecList &, const lldb::SBStringList &), |
| 1050 | source_regex, module_list, source_file_list, func_names); |
| 1051 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1052 | SBBreakpoint sb_bp; |
| 1053 | TargetSP target_sp(GetSP()); |
| 1054 | if (target_sp && source_regex && source_regex[0]) { |
| 1055 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1056 | const bool hardware = false; |
| 1057 | const LazyBool move_to_nearest_code = eLazyBoolCalculate; |
Zachary Turner | 95eae42 | 2016-09-21 16:01:28 +0000 | [diff] [blame] | 1058 | RegularExpression regexp((llvm::StringRef(source_regex))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1059 | std::unordered_set<std::string> func_names_set; |
| 1060 | for (size_t i = 0; i < func_names.GetSize(); i++) { |
| 1061 | func_names_set.insert(func_names.GetStringAtIndex(i)); |
| 1062 | } |
| 1063 | |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 1064 | sb_bp = target_sp->CreateSourceRegexBreakpoint( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1065 | module_list.get(), source_file_list.get(), func_names_set, regexp, |
| 1066 | false, hardware, move_to_nearest_code); |
| 1067 | } |
| 1068 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1069 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1070 | } |
| 1071 | |
| 1072 | lldb::SBBreakpoint |
| 1073 | SBTarget::BreakpointCreateForException(lldb::LanguageType language, |
| 1074 | bool catch_bp, bool throw_bp) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1075 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException, |
| 1076 | (lldb::LanguageType, bool, bool), language, catch_bp, |
| 1077 | throw_bp); |
| 1078 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1079 | SBBreakpoint sb_bp; |
| 1080 | TargetSP target_sp(GetSP()); |
| 1081 | if (target_sp) { |
| 1082 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1083 | const bool hardware = false; |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 1084 | sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1085 | hardware); |
| 1086 | } |
| 1087 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1088 | return LLDB_RECORD_RESULT(sb_bp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1089 | } |
| 1090 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1091 | lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript( |
| 1092 | const char *class_name, SBStructuredData &extra_args, |
| 1093 | const SBFileSpecList &module_list, const SBFileSpecList &file_list, |
| 1094 | bool request_hardware) { |
| 1095 | LLDB_RECORD_METHOD( |
| 1096 | lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, |
| 1097 | (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, |
| 1098 | const lldb::SBFileSpecList &, bool), |
| 1099 | class_name, extra_args, module_list, file_list, request_hardware); |
| 1100 | |
Jim Ingham | 3815e70 | 2018-09-13 21:35:32 +0000 | [diff] [blame] | 1101 | SBBreakpoint sb_bp; |
| 1102 | TargetSP target_sp(GetSP()); |
| 1103 | if (target_sp) { |
| 1104 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1105 | Status error; |
Jonas Devlieghere | 581af8b | 2019-03-07 22:47:13 +0000 | [diff] [blame] | 1106 | |
Jim Ingham | 3815e70 | 2018-09-13 21:35:32 +0000 | [diff] [blame] | 1107 | StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP(); |
| 1108 | sb_bp = |
| 1109 | target_sp->CreateScriptedBreakpoint(class_name, |
| 1110 | module_list.get(), |
| 1111 | file_list.get(), |
| 1112 | false, /* internal */ |
| 1113 | request_hardware, |
| 1114 | obj_sp, |
| 1115 | &error); |
| 1116 | } |
Jim Ingham | 3815e70 | 2018-09-13 21:35:32 +0000 | [diff] [blame] | 1117 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1118 | return LLDB_RECORD_RESULT(sb_bp); |
Jim Ingham | 3815e70 | 2018-09-13 21:35:32 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1121 | uint32_t SBTarget::GetNumBreakpoints() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1122 | LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints); |
| 1123 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1124 | TargetSP target_sp(GetSP()); |
| 1125 | if (target_sp) { |
| 1126 | // The breakpoint list is thread safe, no need to lock |
| 1127 | return target_sp->GetBreakpointList().GetSize(); |
| 1128 | } |
| 1129 | return 0; |
| 1130 | } |
| 1131 | |
| 1132 | SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1133 | LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex, |
| 1134 | (uint32_t), idx); |
| 1135 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1136 | SBBreakpoint sb_breakpoint; |
| 1137 | TargetSP target_sp(GetSP()); |
| 1138 | if (target_sp) { |
| 1139 | // The breakpoint list is thread safe, no need to lock |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 1140 | sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1141 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1142 | return LLDB_RECORD_RESULT(sb_breakpoint); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | bool SBTarget::BreakpointDelete(break_id_t bp_id) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1146 | LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t), |
| 1147 | bp_id); |
| 1148 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1149 | bool result = false; |
| 1150 | TargetSP target_sp(GetSP()); |
| 1151 | if (target_sp) { |
| 1152 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1153 | result = target_sp->RemoveBreakpointByID(bp_id); |
| 1154 | } |
| 1155 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1156 | return result; |
| 1157 | } |
| 1158 | |
| 1159 | SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1160 | LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, |
| 1161 | (lldb::break_id_t), bp_id); |
| 1162 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1163 | SBBreakpoint sb_breakpoint; |
| 1164 | TargetSP target_sp(GetSP()); |
| 1165 | if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) { |
| 1166 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Pavel Labath | 6ac8403 | 2017-02-27 11:05:34 +0000 | [diff] [blame] | 1167 | sb_breakpoint = target_sp->GetBreakpointByID(bp_id); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1170 | return LLDB_RECORD_RESULT(sb_breakpoint); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1171 | } |
| 1172 | |
Jim Ingham | ff9a91e | 2016-09-21 01:21:19 +0000 | [diff] [blame] | 1173 | bool SBTarget::FindBreakpointsByName(const char *name, |
| 1174 | SBBreakpointList &bkpts) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1175 | LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName, |
| 1176 | (const char *, lldb::SBBreakpointList &), name, bkpts); |
| 1177 | |
Jim Ingham | ff9a91e | 2016-09-21 01:21:19 +0000 | [diff] [blame] | 1178 | TargetSP target_sp(GetSP()); |
| 1179 | if (target_sp) { |
| 1180 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1181 | BreakpointList bkpt_list(false); |
| 1182 | bool is_valid = |
| 1183 | target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list); |
| 1184 | if (!is_valid) |
| 1185 | return false; |
| 1186 | for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) { |
| 1187 | bkpts.AppendByID(bkpt_sp->GetID()); |
| 1188 | } |
| 1189 | } |
| 1190 | return true; |
| 1191 | } |
| 1192 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1193 | void SBTarget::GetBreakpointNames(SBStringList &names) { |
| 1194 | LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &), |
| 1195 | names); |
| 1196 | |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1197 | names.Clear(); |
| 1198 | |
| 1199 | TargetSP target_sp(GetSP()); |
| 1200 | if (target_sp) { |
| 1201 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1202 | |
| 1203 | std::vector<std::string> name_vec; |
| 1204 | target_sp->GetBreakpointNames(name_vec); |
| 1205 | for (auto name : name_vec) |
| 1206 | names.AppendString(name.c_str()); |
| 1207 | } |
| 1208 | } |
| 1209 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1210 | void SBTarget::DeleteBreakpointName(const char *name) { |
| 1211 | LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *), |
| 1212 | name); |
| 1213 | |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1214 | TargetSP target_sp(GetSP()); |
| 1215 | if (target_sp) { |
| 1216 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1217 | target_sp->DeleteBreakpointName(ConstString(name)); |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1218 | } |
| 1219 | } |
| 1220 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1221 | bool SBTarget::EnableAllBreakpoints() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1222 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints); |
| 1223 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1224 | TargetSP target_sp(GetSP()); |
| 1225 | if (target_sp) { |
| 1226 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1227 | target_sp->EnableAllowedBreakpoints(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1228 | return true; |
| 1229 | } |
| 1230 | return false; |
| 1231 | } |
| 1232 | |
| 1233 | bool SBTarget::DisableAllBreakpoints() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1234 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints); |
| 1235 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1236 | TargetSP target_sp(GetSP()); |
| 1237 | if (target_sp) { |
| 1238 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1239 | target_sp->DisableAllowedBreakpoints(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1240 | return true; |
| 1241 | } |
| 1242 | return false; |
| 1243 | } |
| 1244 | |
| 1245 | bool SBTarget::DeleteAllBreakpoints() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1246 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints); |
| 1247 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1248 | TargetSP target_sp(GetSP()); |
| 1249 | if (target_sp) { |
| 1250 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame] | 1251 | target_sp->RemoveAllowedBreakpoints(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1252 | return true; |
| 1253 | } |
| 1254 | return false; |
| 1255 | } |
| 1256 | |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1257 | lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, |
| 1258 | SBBreakpointList &new_bps) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1259 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, |
| 1260 | (lldb::SBFileSpec &, lldb::SBBreakpointList &), |
| 1261 | source_file, new_bps); |
| 1262 | |
Jim Ingham | 3acdf38 | 2016-09-22 22:20:28 +0000 | [diff] [blame] | 1263 | SBStringList empty_name_list; |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1264 | return LLDB_RECORD_RESULT( |
| 1265 | BreakpointsCreateFromFile(source_file, empty_name_list, new_bps)); |
Jim Ingham | 3acdf38 | 2016-09-22 22:20:28 +0000 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, |
| 1269 | SBStringList &matching_names, |
| 1270 | SBBreakpointList &new_bps) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1271 | LLDB_RECORD_METHOD( |
| 1272 | lldb::SBError, SBTarget, BreakpointsCreateFromFile, |
| 1273 | (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &), |
| 1274 | source_file, matching_names, new_bps); |
| 1275 | |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1276 | SBError sberr; |
| 1277 | TargetSP target_sp(GetSP()); |
| 1278 | if (!target_sp) { |
| 1279 | sberr.SetErrorString( |
| 1280 | "BreakpointCreateFromFile called with invalid target."); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1281 | return LLDB_RECORD_RESULT(sberr); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1282 | } |
| 1283 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1284 | |
| 1285 | BreakpointIDList bp_ids; |
Jim Ingham | 3acdf38 | 2016-09-22 22:20:28 +0000 | [diff] [blame] | 1286 | |
| 1287 | std::vector<std::string> name_vector; |
| 1288 | size_t num_names = matching_names.GetSize(); |
| 1289 | for (size_t i = 0; i < num_names; i++) |
| 1290 | name_vector.push_back(matching_names.GetStringAtIndex(i)); |
| 1291 | |
| 1292 | sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(), |
| 1293 | name_vector, bp_ids); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1294 | if (sberr.Fail()) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1295 | return LLDB_RECORD_RESULT(sberr); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1296 | |
| 1297 | size_t num_bkpts = bp_ids.GetSize(); |
| 1298 | for (size_t i = 0; i < num_bkpts; i++) { |
| 1299 | BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i); |
| 1300 | new_bps.AppendByID(bp_id.GetBreakpointID()); |
| 1301 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1302 | return LLDB_RECORD_RESULT(sberr); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1306 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, |
| 1307 | (lldb::SBFileSpec &), dest_file); |
| 1308 | |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1309 | SBError sberr; |
| 1310 | TargetSP target_sp(GetSP()); |
| 1311 | if (!target_sp) { |
| 1312 | sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1313 | return LLDB_RECORD_RESULT(sberr); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1314 | } |
| 1315 | SBBreakpointList bkpt_list(*this); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1316 | return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list)); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, |
Jim Ingham | 2d3628e | 2016-09-22 23:42:42 +0000 | [diff] [blame] | 1320 | SBBreakpointList &bkpt_list, |
| 1321 | bool append) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1322 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, |
| 1323 | (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool), |
| 1324 | dest_file, bkpt_list, append); |
| 1325 | |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1326 | SBError sberr; |
| 1327 | TargetSP target_sp(GetSP()); |
| 1328 | if (!target_sp) { |
| 1329 | sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1330 | return LLDB_RECORD_RESULT(sberr); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1331 | } |
| 1332 | |
| 1333 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1334 | BreakpointIDList bp_id_list; |
| 1335 | bkpt_list.CopyToBreakpointIDList(bp_id_list); |
Jim Ingham | 2d3628e | 2016-09-22 23:42:42 +0000 | [diff] [blame] | 1336 | sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(), |
| 1337 | bp_id_list, append); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1338 | return LLDB_RECORD_RESULT(sberr); |
Jim Ingham | 01f1666 | 2016-09-14 19:07:35 +0000 | [diff] [blame] | 1339 | } |
| 1340 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1341 | uint32_t SBTarget::GetNumWatchpoints() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1342 | LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints); |
| 1343 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1344 | TargetSP target_sp(GetSP()); |
| 1345 | if (target_sp) { |
| 1346 | // The watchpoint list is thread safe, no need to lock |
| 1347 | return target_sp->GetWatchpointList().GetSize(); |
| 1348 | } |
| 1349 | return 0; |
| 1350 | } |
| 1351 | |
| 1352 | SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1353 | LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex, |
| 1354 | (uint32_t), idx); |
| 1355 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1356 | SBWatchpoint sb_watchpoint; |
| 1357 | TargetSP target_sp(GetSP()); |
| 1358 | if (target_sp) { |
| 1359 | // The watchpoint list is thread safe, no need to lock |
| 1360 | sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx)); |
| 1361 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1362 | return LLDB_RECORD_RESULT(sb_watchpoint); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1366 | LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t), |
| 1367 | wp_id); |
| 1368 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1369 | |
| 1370 | bool result = false; |
| 1371 | TargetSP target_sp(GetSP()); |
| 1372 | if (target_sp) { |
| 1373 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1374 | std::unique_lock<std::recursive_mutex> lock; |
| 1375 | target_sp->GetWatchpointList().GetListMutex(lock); |
| 1376 | result = target_sp->RemoveWatchpointByID(wp_id); |
| 1377 | } |
| 1378 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1379 | return result; |
| 1380 | } |
| 1381 | |
| 1382 | SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1383 | LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, |
| 1384 | (lldb::watch_id_t), wp_id); |
| 1385 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1386 | |
| 1387 | SBWatchpoint sb_watchpoint; |
| 1388 | lldb::WatchpointSP watchpoint_sp; |
| 1389 | TargetSP target_sp(GetSP()); |
| 1390 | if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) { |
| 1391 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1392 | std::unique_lock<std::recursive_mutex> lock; |
| 1393 | target_sp->GetWatchpointList().GetListMutex(lock); |
| 1394 | watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id); |
| 1395 | sb_watchpoint.SetSP(watchpoint_sp); |
| 1396 | } |
| 1397 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1398 | return LLDB_RECORD_RESULT(sb_watchpoint); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, |
| 1402 | bool read, bool write, |
| 1403 | SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1404 | LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, |
| 1405 | (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr, |
| 1406 | size, read, write, error); |
| 1407 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1408 | SBWatchpoint sb_watchpoint; |
| 1409 | lldb::WatchpointSP watchpoint_sp; |
| 1410 | TargetSP target_sp(GetSP()); |
| 1411 | if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && |
| 1412 | size > 0) { |
| 1413 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1414 | uint32_t watch_type = 0; |
| 1415 | if (read) |
| 1416 | watch_type |= LLDB_WATCH_TYPE_READ; |
| 1417 | if (write) |
| 1418 | watch_type |= LLDB_WATCH_TYPE_WRITE; |
| 1419 | if (watch_type == 0) { |
| 1420 | error.SetErrorString( |
| 1421 | "Can't create a watchpoint that is neither read nor write."); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1422 | return LLDB_RECORD_RESULT(sb_watchpoint); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | // Target::CreateWatchpoint() is thread safe. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 1426 | Status cw_error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1427 | // This API doesn't take in a type, so we can't figure out what it is. |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 1428 | CompilerType *type = nullptr; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1429 | watchpoint_sp = |
| 1430 | target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error); |
| 1431 | error.SetError(cw_error); |
| 1432 | sb_watchpoint.SetSP(watchpoint_sp); |
| 1433 | } |
| 1434 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1435 | return LLDB_RECORD_RESULT(sb_watchpoint); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | bool SBTarget::EnableAllWatchpoints() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1439 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints); |
| 1440 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1441 | TargetSP target_sp(GetSP()); |
| 1442 | if (target_sp) { |
| 1443 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1444 | std::unique_lock<std::recursive_mutex> lock; |
| 1445 | target_sp->GetWatchpointList().GetListMutex(lock); |
| 1446 | target_sp->EnableAllWatchpoints(); |
| 1447 | return true; |
| 1448 | } |
| 1449 | return false; |
| 1450 | } |
| 1451 | |
| 1452 | bool SBTarget::DisableAllWatchpoints() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1453 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints); |
| 1454 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1455 | TargetSP target_sp(GetSP()); |
| 1456 | if (target_sp) { |
| 1457 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1458 | std::unique_lock<std::recursive_mutex> lock; |
| 1459 | target_sp->GetWatchpointList().GetListMutex(lock); |
| 1460 | target_sp->DisableAllWatchpoints(); |
| 1461 | return true; |
| 1462 | } |
| 1463 | return false; |
| 1464 | } |
| 1465 | |
| 1466 | SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr, |
| 1467 | SBType type) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1468 | LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, |
| 1469 | (const char *, lldb::SBAddress, lldb::SBType), name, addr, |
| 1470 | type); |
| 1471 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1472 | SBValue sb_value; |
| 1473 | lldb::ValueObjectSP new_value_sp; |
| 1474 | if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) { |
| 1475 | lldb::addr_t load_addr(addr.GetLoadAddress(*this)); |
| 1476 | ExecutionContext exe_ctx( |
| 1477 | ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false))); |
| 1478 | CompilerType ast_type(type.GetSP()->GetCompilerType(true)); |
| 1479 | new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, |
| 1480 | exe_ctx, ast_type); |
| 1481 | } |
| 1482 | sb_value.SetSP(new_value_sp); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1483 | return LLDB_RECORD_RESULT(sb_value); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1484 | } |
| 1485 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1486 | lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data, |
| 1487 | lldb::SBType type) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1488 | LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, |
| 1489 | (const char *, lldb::SBData, lldb::SBType), name, data, |
| 1490 | type); |
| 1491 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1492 | SBValue sb_value; |
| 1493 | lldb::ValueObjectSP new_value_sp; |
| 1494 | if (IsValid() && name && *name && data.IsValid() && type.IsValid()) { |
| 1495 | DataExtractorSP extractor(*data); |
| 1496 | ExecutionContext exe_ctx( |
| 1497 | ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false))); |
| 1498 | CompilerType ast_type(type.GetSP()->GetCompilerType(true)); |
| 1499 | new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, |
| 1500 | exe_ctx, ast_type); |
| 1501 | } |
| 1502 | sb_value.SetSP(new_value_sp); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1503 | return LLDB_RECORD_RESULT(sb_value); |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 1504 | } |
| 1505 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1506 | lldb::SBValue SBTarget::CreateValueFromExpression(const char *name, |
| 1507 | const char *expr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1508 | LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, |
| 1509 | (const char *, const char *), name, expr); |
| 1510 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1511 | SBValue sb_value; |
| 1512 | lldb::ValueObjectSP new_value_sp; |
| 1513 | if (IsValid() && name && *name && expr && *expr) { |
| 1514 | ExecutionContext exe_ctx( |
| 1515 | ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false))); |
| 1516 | new_value_sp = |
| 1517 | ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx); |
| 1518 | } |
| 1519 | sb_value.SetSP(new_value_sp); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1520 | return LLDB_RECORD_RESULT(sb_value); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | bool SBTarget::DeleteAllWatchpoints() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1524 | LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints); |
| 1525 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1526 | TargetSP target_sp(GetSP()); |
| 1527 | if (target_sp) { |
| 1528 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 1529 | std::unique_lock<std::recursive_mutex> lock; |
| 1530 | target_sp->GetWatchpointList().GetListMutex(lock); |
| 1531 | target_sp->RemoveAllWatchpoints(); |
| 1532 | return true; |
| 1533 | } |
| 1534 | return false; |
| 1535 | } |
| 1536 | |
Alexander Polyakov | 3e7b9db | 2018-08-07 20:23:57 +0000 | [diff] [blame] | 1537 | void SBTarget::AppendImageSearchPath(const char *from, const char *to, |
| 1538 | lldb::SBError &error) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1539 | LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath, |
| 1540 | (const char *, const char *, lldb::SBError &), from, to, |
| 1541 | error); |
| 1542 | |
Alexander Polyakov | 3e7b9db | 2018-08-07 20:23:57 +0000 | [diff] [blame] | 1543 | TargetSP target_sp(GetSP()); |
| 1544 | if (!target_sp) |
| 1545 | return error.SetErrorString("invalid target"); |
| 1546 | |
| 1547 | const ConstString csFrom(from), csTo(to); |
| 1548 | if (!csFrom) |
| 1549 | return error.SetErrorString("<from> path can't be empty"); |
| 1550 | if (!csTo) |
| 1551 | return error.SetErrorString("<to> path can't be empty"); |
| 1552 | |
Alexander Polyakov | 3e7b9db | 2018-08-07 20:23:57 +0000 | [diff] [blame] | 1553 | target_sp->GetImageSearchPathList().Append(csFrom, csTo, true); |
| 1554 | } |
| 1555 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1556 | lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, |
| 1557 | const char *uuid_cstr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1558 | LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, |
| 1559 | (const char *, const char *, const char *), path, triple, |
| 1560 | uuid_cstr); |
| 1561 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 1562 | return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, |
| 1566 | const char *uuid_cstr, const char *symfile) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1567 | LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, |
| 1568 | (const char *, const char *, const char *, const char *), |
| 1569 | path, triple, uuid_cstr, symfile); |
| 1570 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1571 | lldb::SBModule sb_module; |
| 1572 | TargetSP target_sp(GetSP()); |
| 1573 | if (target_sp) { |
| 1574 | ModuleSpec module_spec; |
| 1575 | if (path) |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 1576 | module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1577 | |
| 1578 | if (uuid_cstr) |
Pavel Labath | a174bcb | 2018-06-21 15:24:39 +0000 | [diff] [blame] | 1579 | module_spec.GetUUID().SetFromStringRef(uuid_cstr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1580 | |
| 1581 | if (triple) |
Pavel Labath | 7263f1b | 2017-10-31 10:56:03 +0000 | [diff] [blame] | 1582 | module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec( |
| 1583 | target_sp->GetPlatform().get(), triple); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1584 | else |
| 1585 | module_spec.GetArchitecture() = target_sp->GetArchitecture(); |
| 1586 | |
| 1587 | if (symfile) |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 1588 | module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1589 | |
Jason Molenda | 1724a17 | 2019-04-08 23:03:02 +0000 | [diff] [blame] | 1590 | sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1591 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1592 | return LLDB_RECORD_RESULT(sb_module); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1593 | } |
| 1594 | |
| 1595 | lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1596 | LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, |
| 1597 | (const lldb::SBModuleSpec &), module_spec); |
| 1598 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1599 | lldb::SBModule sb_module; |
| 1600 | TargetSP target_sp(GetSP()); |
| 1601 | if (target_sp) |
Jason Molenda | 1724a17 | 2019-04-08 23:03:02 +0000 | [diff] [blame] | 1602 | sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up, |
| 1603 | true /* notify */)); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1604 | return LLDB_RECORD_RESULT(sb_module); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | bool SBTarget::AddModule(lldb::SBModule &module) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1608 | LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module); |
| 1609 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1610 | TargetSP target_sp(GetSP()); |
| 1611 | if (target_sp) { |
| 1612 | target_sp->GetImages().AppendIfNeeded(module.GetSP()); |
| 1613 | return true; |
| 1614 | } |
| 1615 | return false; |
| 1616 | } |
| 1617 | |
| 1618 | uint32_t SBTarget::GetNumModules() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1619 | LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules); |
| 1620 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1621 | uint32_t num = 0; |
| 1622 | TargetSP target_sp(GetSP()); |
| 1623 | if (target_sp) { |
| 1624 | // The module list is thread safe, no need to lock |
| 1625 | num = target_sp->GetImages().GetSize(); |
| 1626 | } |
| 1627 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1628 | return num; |
| 1629 | } |
| 1630 | |
| 1631 | void SBTarget::Clear() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1632 | LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear); |
| 1633 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1634 | m_opaque_sp.reset(); |
| 1635 | } |
| 1636 | |
| 1637 | SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1638 | LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule, |
| 1639 | (const lldb::SBFileSpec &), sb_file_spec); |
| 1640 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1641 | SBModule sb_module; |
| 1642 | TargetSP target_sp(GetSP()); |
| 1643 | if (target_sp && sb_file_spec.IsValid()) { |
| 1644 | ModuleSpec module_spec(*sb_file_spec); |
| 1645 | // The module list is thread safe, no need to lock |
| 1646 | sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec)); |
| 1647 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1648 | return LLDB_RECORD_RESULT(sb_module); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1649 | } |
| 1650 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1651 | SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { |
| 1652 | LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, |
| 1653 | (const lldb::SBFileSpec &), sb_file_spec); |
| 1654 | |
Alexander Polyakov | da0c081 | 2018-07-03 14:22:44 +0000 | [diff] [blame] | 1655 | SBSymbolContextList sb_sc_list; |
| 1656 | const TargetSP target_sp(GetSP()); |
| 1657 | if (target_sp && sb_file_spec.IsValid()) { |
| 1658 | const bool append = true; |
| 1659 | target_sp->GetImages().FindCompileUnits(*sb_file_spec, |
| 1660 | append, *sb_sc_list); |
| 1661 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1662 | return LLDB_RECORD_RESULT(sb_sc_list); |
Alexander Polyakov | da0c081 | 2018-07-03 14:22:44 +0000 | [diff] [blame] | 1663 | } |
| 1664 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1665 | lldb::ByteOrder SBTarget::GetByteOrder() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1666 | LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder); |
| 1667 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1668 | TargetSP target_sp(GetSP()); |
| 1669 | if (target_sp) |
| 1670 | return target_sp->GetArchitecture().GetByteOrder(); |
| 1671 | return eByteOrderInvalid; |
| 1672 | } |
| 1673 | |
| 1674 | const char *SBTarget::GetTriple() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1675 | LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple); |
| 1676 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1677 | TargetSP target_sp(GetSP()); |
| 1678 | if (target_sp) { |
| 1679 | std::string triple(target_sp->GetArchitecture().GetTriple().str()); |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 1680 | // Unique the string so we don't run into ownership issues since the const |
| 1681 | // strings put the string into the string pool once and the strings never |
| 1682 | // comes out |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1683 | ConstString const_triple(triple.c_str()); |
| 1684 | return const_triple.GetCString(); |
| 1685 | } |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 1686 | return nullptr; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1687 | } |
| 1688 | |
| 1689 | uint32_t SBTarget::GetDataByteSize() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1690 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize); |
| 1691 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1692 | TargetSP target_sp(GetSP()); |
| 1693 | if (target_sp) { |
| 1694 | return target_sp->GetArchitecture().GetDataByteSize(); |
| 1695 | } |
| 1696 | return 0; |
| 1697 | } |
| 1698 | |
| 1699 | uint32_t SBTarget::GetCodeByteSize() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1700 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize); |
| 1701 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1702 | TargetSP target_sp(GetSP()); |
| 1703 | if (target_sp) { |
| 1704 | return target_sp->GetArchitecture().GetCodeByteSize(); |
| 1705 | } |
| 1706 | return 0; |
| 1707 | } |
| 1708 | |
| 1709 | uint32_t SBTarget::GetAddressByteSize() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1710 | LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize); |
| 1711 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1712 | TargetSP target_sp(GetSP()); |
| 1713 | if (target_sp) |
| 1714 | return target_sp->GetArchitecture().GetAddressByteSize(); |
| 1715 | return sizeof(void *); |
| 1716 | } |
| 1717 | |
| 1718 | SBModule SBTarget::GetModuleAtIndex(uint32_t idx) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1719 | LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t), |
| 1720 | idx); |
| 1721 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1722 | SBModule sb_module; |
| 1723 | ModuleSP module_sp; |
| 1724 | TargetSP target_sp(GetSP()); |
| 1725 | if (target_sp) { |
| 1726 | // The module list is thread safe, no need to lock |
| 1727 | module_sp = target_sp->GetImages().GetModuleAtIndex(idx); |
| 1728 | sb_module.SetSP(module_sp); |
| 1729 | } |
| 1730 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1731 | return LLDB_RECORD_RESULT(sb_module); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | bool SBTarget::RemoveModule(lldb::SBModule module) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1735 | LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module); |
| 1736 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1737 | TargetSP target_sp(GetSP()); |
| 1738 | if (target_sp) |
| 1739 | return target_sp->GetImages().Remove(module.GetSP()); |
| 1740 | return false; |
| 1741 | } |
| 1742 | |
| 1743 | SBBroadcaster SBTarget::GetBroadcaster() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1744 | LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget, |
| 1745 | GetBroadcaster); |
| 1746 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1747 | |
| 1748 | TargetSP target_sp(GetSP()); |
| 1749 | SBBroadcaster broadcaster(target_sp.get(), false); |
| 1750 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1751 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1752 | return LLDB_RECORD_RESULT(broadcaster); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1753 | } |
| 1754 | |
| 1755 | bool SBTarget::GetDescription(SBStream &description, |
| 1756 | lldb::DescriptionLevel description_level) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1757 | LLDB_RECORD_METHOD(bool, SBTarget, GetDescription, |
| 1758 | (lldb::SBStream &, lldb::DescriptionLevel), description, |
| 1759 | description_level); |
| 1760 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1761 | Stream &strm = description.ref(); |
| 1762 | |
| 1763 | TargetSP target_sp(GetSP()); |
| 1764 | if (target_sp) { |
| 1765 | target_sp->Dump(&strm, description_level); |
| 1766 | } else |
| 1767 | strm.PutCString("No value"); |
| 1768 | |
| 1769 | return true; |
| 1770 | } |
| 1771 | |
| 1772 | lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, |
| 1773 | uint32_t name_type_mask) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1774 | LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, |
| 1775 | (const char *, uint32_t), name, name_type_mask); |
| 1776 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1777 | lldb::SBSymbolContextList sb_sc_list; |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 1778 | if (!name | !name[0]) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1779 | return LLDB_RECORD_RESULT(sb_sc_list); |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 1780 | |
| 1781 | TargetSP target_sp(GetSP()); |
| 1782 | if (!target_sp) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1783 | return LLDB_RECORD_RESULT(sb_sc_list); |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 1784 | |
| 1785 | const bool symbols_ok = true; |
| 1786 | const bool inlines_ok = true; |
| 1787 | const bool append = true; |
| 1788 | FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); |
| 1789 | target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok, |
| 1790 | inlines_ok, append, *sb_sc_list); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1791 | return LLDB_RECORD_RESULT(sb_sc_list); |
Jim Ingham | 763b2b2 | 2015-07-07 22:12:17 +0000 | [diff] [blame] | 1792 | } |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 1793 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1794 | lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, |
| 1795 | uint32_t max_matches, |
| 1796 | MatchType matchtype) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1797 | LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions, |
| 1798 | (const char *, uint32_t, lldb::MatchType), name, |
| 1799 | max_matches, matchtype); |
| 1800 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1801 | lldb::SBSymbolContextList sb_sc_list; |
| 1802 | if (name && name[0]) { |
Zachary Turner | 95eae42 | 2016-09-21 16:01:28 +0000 | [diff] [blame] | 1803 | llvm::StringRef name_ref(name); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1804 | TargetSP target_sp(GetSP()); |
| 1805 | if (target_sp) { |
| 1806 | std::string regexstr; |
| 1807 | switch (matchtype) { |
| 1808 | case eMatchTypeRegex: |
Zachary Turner | 95eae42 | 2016-09-21 16:01:28 +0000 | [diff] [blame] | 1809 | target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1810 | true, true, *sb_sc_list); |
| 1811 | break; |
| 1812 | case eMatchTypeStartsWith: |
| 1813 | regexstr = llvm::Regex::escape(name) + ".*"; |
Zachary Turner | 95eae42 | 2016-09-21 16:01:28 +0000 | [diff] [blame] | 1814 | target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true, |
| 1815 | true, true, *sb_sc_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1816 | break; |
| 1817 | default: |
| 1818 | target_sp->GetImages().FindFunctions(ConstString(name), |
| 1819 | eFunctionNameTypeAny, true, true, |
| 1820 | true, *sb_sc_list); |
| 1821 | break; |
| 1822 | } |
| 1823 | } |
| 1824 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1825 | return LLDB_RECORD_RESULT(sb_sc_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1826 | } |
| 1827 | |
| 1828 | lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1829 | LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *), |
| 1830 | typename_cstr); |
| 1831 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1832 | TargetSP target_sp(GetSP()); |
| 1833 | if (typename_cstr && typename_cstr[0] && target_sp) { |
| 1834 | ConstString const_typename(typename_cstr); |
| 1835 | SymbolContext sc; |
| 1836 | const bool exact_match = false; |
| 1837 | |
| 1838 | const ModuleList &module_list = target_sp->GetImages(); |
| 1839 | size_t count = module_list.GetSize(); |
| 1840 | for (size_t idx = 0; idx < count; idx++) { |
| 1841 | ModuleSP module_sp(module_list.GetModuleAtIndex(idx)); |
| 1842 | if (module_sp) { |
| 1843 | TypeSP type_sp( |
| 1844 | module_sp->FindFirstType(sc, const_typename, exact_match)); |
| 1845 | if (type_sp) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1846 | return LLDB_RECORD_RESULT(SBType(type_sp)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1847 | } |
| 1848 | } |
| 1849 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 1850 | // Didn't find the type in the symbols; try the Objective-C runtime if one |
| 1851 | // is installed |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1852 | |
| 1853 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 1854 | |
| 1855 | if (process_sp) { |
| 1856 | ObjCLanguageRuntime *objc_language_runtime = |
Alex Langford | e823bbe | 2019-06-10 20:53:23 +0000 | [diff] [blame^] | 1857 | ObjCLanguageRuntime::Get(*process_sp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1858 | |
| 1859 | if (objc_language_runtime) { |
| 1860 | DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); |
| 1861 | |
| 1862 | if (objc_decl_vendor) { |
| 1863 | std::vector<clang::NamedDecl *> decls; |
| 1864 | |
| 1865 | if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { |
| 1866 | if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1867 | return LLDB_RECORD_RESULT(SBType(type)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1868 | } |
| 1869 | } |
| 1870 | } |
| 1871 | } |
| 1872 | } |
| 1873 | |
| 1874 | // No matches, search for basic typename matches |
| 1875 | ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); |
| 1876 | if (clang_ast) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1877 | return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType( |
| 1878 | clang_ast->getASTContext(), const_typename))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1879 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1880 | return LLDB_RECORD_RESULT(SBType()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | SBType SBTarget::GetBasicType(lldb::BasicType type) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1884 | LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType), |
| 1885 | type); |
| 1886 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1887 | TargetSP target_sp(GetSP()); |
| 1888 | if (target_sp) { |
| 1889 | ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); |
| 1890 | if (clang_ast) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1891 | return LLDB_RECORD_RESULT(SBType( |
| 1892 | ClangASTContext::GetBasicType(clang_ast->getASTContext(), type))); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1893 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1894 | return LLDB_RECORD_RESULT(SBType()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1895 | } |
| 1896 | |
| 1897 | lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1898 | LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *), |
| 1899 | typename_cstr); |
| 1900 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1901 | SBTypeList sb_type_list; |
| 1902 | TargetSP target_sp(GetSP()); |
| 1903 | if (typename_cstr && typename_cstr[0] && target_sp) { |
| 1904 | ModuleList &images = target_sp->GetImages(); |
| 1905 | ConstString const_typename(typename_cstr); |
| 1906 | bool exact_match = false; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1907 | TypeList type_list; |
| 1908 | llvm::DenseSet<SymbolFile *> searched_symbol_files; |
| 1909 | uint32_t num_matches = |
Zachary Turner | 576495e | 2019-01-14 22:41:21 +0000 | [diff] [blame] | 1910 | images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1911 | searched_symbol_files, type_list); |
| 1912 | |
| 1913 | if (num_matches > 0) { |
| 1914 | for (size_t idx = 0; idx < num_matches; idx++) { |
| 1915 | TypeSP type_sp(type_list.GetTypeAtIndex(idx)); |
| 1916 | if (type_sp) |
| 1917 | sb_type_list.Append(SBType(type_sp)); |
| 1918 | } |
| 1919 | } |
| 1920 | |
| 1921 | // Try the Objective-C runtime if one is installed |
| 1922 | |
| 1923 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 1924 | |
| 1925 | if (process_sp) { |
| 1926 | ObjCLanguageRuntime *objc_language_runtime = |
Alex Langford | e823bbe | 2019-06-10 20:53:23 +0000 | [diff] [blame^] | 1927 | ObjCLanguageRuntime::Get(*process_sp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1928 | |
| 1929 | if (objc_language_runtime) { |
| 1930 | DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); |
| 1931 | |
| 1932 | if (objc_decl_vendor) { |
| 1933 | std::vector<clang::NamedDecl *> decls; |
| 1934 | |
| 1935 | if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { |
| 1936 | for (clang::NamedDecl *decl : decls) { |
| 1937 | if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) { |
| 1938 | sb_type_list.Append(SBType(type)); |
| 1939 | } |
| 1940 | } |
| 1941 | } |
| 1942 | } |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | if (sb_type_list.GetSize() == 0) { |
| 1947 | // No matches, search for basic typename matches |
| 1948 | ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); |
| 1949 | if (clang_ast) |
| 1950 | sb_type_list.Append(SBType(ClangASTContext::GetBasicType( |
| 1951 | clang_ast->getASTContext(), const_typename))); |
| 1952 | } |
| 1953 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1954 | return LLDB_RECORD_RESULT(sb_type_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1955 | } |
| 1956 | |
| 1957 | SBValueList SBTarget::FindGlobalVariables(const char *name, |
| 1958 | uint32_t max_matches) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1959 | LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, |
| 1960 | (const char *, uint32_t), name, max_matches); |
| 1961 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1962 | SBValueList sb_value_list; |
| 1963 | |
| 1964 | TargetSP target_sp(GetSP()); |
| 1965 | if (name && target_sp) { |
| 1966 | VariableList variable_list; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1967 | const uint32_t match_count = target_sp->GetImages().FindGlobalVariables( |
Pavel Labath | 34cda14 | 2018-05-31 09:46:26 +0000 | [diff] [blame] | 1968 | ConstString(name), max_matches, variable_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1969 | |
| 1970 | if (match_count > 0) { |
| 1971 | ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 1972 | if (exe_scope == nullptr) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1973 | exe_scope = target_sp.get(); |
| 1974 | for (uint32_t i = 0; i < match_count; ++i) { |
| 1975 | lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create( |
| 1976 | exe_scope, variable_list.GetVariableAtIndex(i))); |
| 1977 | if (valobj_sp) |
| 1978 | sb_value_list.Append(SBValue(valobj_sp)); |
| 1979 | } |
| 1980 | } |
| 1981 | } |
| 1982 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1983 | return LLDB_RECORD_RESULT(sb_value_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1984 | } |
| 1985 | |
| 1986 | SBValueList SBTarget::FindGlobalVariables(const char *name, |
| 1987 | uint32_t max_matches, |
| 1988 | MatchType matchtype) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 1989 | LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, |
| 1990 | (const char *, uint32_t, lldb::MatchType), name, |
| 1991 | max_matches, matchtype); |
| 1992 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1993 | SBValueList sb_value_list; |
| 1994 | |
| 1995 | TargetSP target_sp(GetSP()); |
| 1996 | if (name && target_sp) { |
Zachary Turner | 95eae42 | 2016-09-21 16:01:28 +0000 | [diff] [blame] | 1997 | llvm::StringRef name_ref(name); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1998 | VariableList variable_list; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1999 | |
| 2000 | std::string regexstr; |
| 2001 | uint32_t match_count; |
| 2002 | switch (matchtype) { |
| 2003 | case eMatchTypeNormal: |
| 2004 | match_count = target_sp->GetImages().FindGlobalVariables( |
Pavel Labath | 34cda14 | 2018-05-31 09:46:26 +0000 | [diff] [blame] | 2005 | ConstString(name), max_matches, variable_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2006 | break; |
| 2007 | case eMatchTypeRegex: |
| 2008 | match_count = target_sp->GetImages().FindGlobalVariables( |
Pavel Labath | 34cda14 | 2018-05-31 09:46:26 +0000 | [diff] [blame] | 2009 | RegularExpression(name_ref), max_matches, variable_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2010 | break; |
| 2011 | case eMatchTypeStartsWith: |
| 2012 | regexstr = llvm::Regex::escape(name) + ".*"; |
| 2013 | match_count = target_sp->GetImages().FindGlobalVariables( |
Pavel Labath | 34cda14 | 2018-05-31 09:46:26 +0000 | [diff] [blame] | 2014 | RegularExpression(regexstr), max_matches, variable_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2015 | break; |
| 2016 | } |
| 2017 | |
| 2018 | if (match_count > 0) { |
| 2019 | ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2020 | if (exe_scope == nullptr) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2021 | exe_scope = target_sp.get(); |
| 2022 | for (uint32_t i = 0; i < match_count; ++i) { |
| 2023 | lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create( |
| 2024 | exe_scope, variable_list.GetVariableAtIndex(i))); |
| 2025 | if (valobj_sp) |
| 2026 | sb_value_list.Append(SBValue(valobj_sp)); |
| 2027 | } |
| 2028 | } |
| 2029 | } |
| 2030 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2031 | return LLDB_RECORD_RESULT(sb_value_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2035 | LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, |
| 2036 | (const char *), name); |
| 2037 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2038 | SBValueList sb_value_list(FindGlobalVariables(name, 1)); |
| 2039 | if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2040 | return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); |
| 2041 | return LLDB_RECORD_RESULT(SBValue()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2042 | } |
| 2043 | |
| 2044 | SBSourceManager SBTarget::GetSourceManager() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2045 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager); |
| 2046 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2047 | SBSourceManager source_manager(*this); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2048 | return LLDB_RECORD_RESULT(source_manager); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2049 | } |
| 2050 | |
| 2051 | lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, |
| 2052 | uint32_t count) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2053 | LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, |
| 2054 | (lldb::SBAddress, uint32_t), base_addr, count); |
| 2055 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2056 | return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2057 | } |
| 2058 | |
| 2059 | lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, |
| 2060 | uint32_t count, |
| 2061 | const char *flavor_string) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2062 | LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, |
| 2063 | (lldb::SBAddress, uint32_t, const char *), base_addr, |
| 2064 | count, flavor_string); |
| 2065 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2066 | SBInstructionList sb_instructions; |
| 2067 | |
| 2068 | TargetSP target_sp(GetSP()); |
| 2069 | if (target_sp) { |
| 2070 | Address *addr_ptr = base_addr.get(); |
| 2071 | |
| 2072 | if (addr_ptr) { |
| 2073 | DataBufferHeap data( |
| 2074 | target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0); |
| 2075 | bool prefer_file_cache = false; |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 2076 | lldb_private::Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2077 | lldb::addr_t load_addr = LLDB_INVALID_ADDRESS; |
| 2078 | const size_t bytes_read = |
| 2079 | target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), |
| 2080 | data.GetByteSize(), error, &load_addr); |
| 2081 | const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS; |
| 2082 | sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2083 | target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2084 | data.GetBytes(), bytes_read, count, data_from_file)); |
| 2085 | } |
| 2086 | } |
| 2087 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2088 | return LLDB_RECORD_RESULT(sb_instructions); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2089 | } |
| 2090 | |
| 2091 | lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr, |
| 2092 | const void *buf, |
| 2093 | size_t size) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 2094 | LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, |
| 2095 | (lldb::SBAddress, const void *, size_t), base_addr, buf, |
| 2096 | size); |
| 2097 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2098 | return GetInstructionsWithFlavor(base_addr, nullptr, buf, size); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2099 | } |
| 2100 | |
| 2101 | lldb::SBInstructionList |
| 2102 | SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, |
| 2103 | const char *flavor_string, const void *buf, |
| 2104 | size_t size) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 2105 | LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, |
| 2106 | GetInstructionsWithFlavor, |
| 2107 | (lldb::SBAddress, const char *, const void *, size_t), |
| 2108 | base_addr, flavor_string, buf, size); |
| 2109 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2110 | SBInstructionList sb_instructions; |
| 2111 | |
| 2112 | TargetSP target_sp(GetSP()); |
| 2113 | if (target_sp) { |
| 2114 | Address addr; |
| 2115 | |
| 2116 | if (base_addr.get()) |
| 2117 | addr = *base_addr.get(); |
| 2118 | |
| 2119 | const bool data_from_file = true; |
| 2120 | |
| 2121 | sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2122 | target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2123 | UINT32_MAX, data_from_file)); |
| 2124 | } |
| 2125 | |
| 2126 | return sb_instructions; |
| 2127 | } |
| 2128 | |
| 2129 | lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr, |
| 2130 | const void *buf, |
| 2131 | size_t size) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 2132 | LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, |
| 2133 | (lldb::addr_t, const void *, size_t), base_addr, buf, size); |
| 2134 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2135 | return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2136 | size); |
| 2137 | } |
| 2138 | |
| 2139 | lldb::SBInstructionList |
| 2140 | SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr, |
| 2141 | const char *flavor_string, const void *buf, |
| 2142 | size_t size) { |
Jonas Devlieghere | 0d7b0c9 | 2019-03-08 19:09:27 +0000 | [diff] [blame] | 2143 | LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, |
| 2144 | GetInstructionsWithFlavor, |
| 2145 | (lldb::addr_t, const char *, const void *, size_t), |
| 2146 | base_addr, flavor_string, buf, size); |
| 2147 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2148 | return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string, |
| 2149 | buf, size); |
| 2150 | } |
| 2151 | |
| 2152 | SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, |
| 2153 | lldb::addr_t section_base_addr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2154 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, |
| 2155 | (lldb::SBSection, lldb::addr_t), section, |
| 2156 | section_base_addr); |
| 2157 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2158 | SBError sb_error; |
| 2159 | TargetSP target_sp(GetSP()); |
| 2160 | if (target_sp) { |
| 2161 | if (!section.IsValid()) { |
| 2162 | sb_error.SetErrorStringWithFormat("invalid section"); |
| 2163 | } else { |
| 2164 | SectionSP section_sp(section.GetSP()); |
| 2165 | if (section_sp) { |
| 2166 | if (section_sp->IsThreadSpecific()) { |
| 2167 | sb_error.SetErrorString( |
| 2168 | "thread specific sections are not yet supported"); |
| 2169 | } else { |
| 2170 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 2171 | if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) { |
| 2172 | ModuleSP module_sp(section_sp->GetModule()); |
| 2173 | if (module_sp) { |
| 2174 | ModuleList module_list; |
| 2175 | module_list.Append(module_sp); |
| 2176 | target_sp->ModulesDidLoad(module_list); |
| 2177 | } |
| 2178 | // Flush info in the process (stack frames, etc) |
| 2179 | if (process_sp) |
| 2180 | process_sp->Flush(); |
| 2181 | } |
| 2182 | } |
| 2183 | } |
| 2184 | } |
| 2185 | } else { |
| 2186 | sb_error.SetErrorString("invalid target"); |
| 2187 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2188 | return LLDB_RECORD_RESULT(sb_error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2189 | } |
| 2190 | |
| 2191 | SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2192 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, |
| 2193 | (lldb::SBSection), section); |
| 2194 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2195 | SBError sb_error; |
| 2196 | |
| 2197 | TargetSP target_sp(GetSP()); |
| 2198 | if (target_sp) { |
| 2199 | if (!section.IsValid()) { |
| 2200 | sb_error.SetErrorStringWithFormat("invalid section"); |
| 2201 | } else { |
| 2202 | SectionSP section_sp(section.GetSP()); |
| 2203 | if (section_sp) { |
| 2204 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 2205 | if (target_sp->SetSectionUnloaded(section_sp)) { |
| 2206 | ModuleSP module_sp(section_sp->GetModule()); |
| 2207 | if (module_sp) { |
| 2208 | ModuleList module_list; |
| 2209 | module_list.Append(module_sp); |
| 2210 | target_sp->ModulesDidUnload(module_list, false); |
| 2211 | } |
| 2212 | // Flush info in the process (stack frames, etc) |
| 2213 | if (process_sp) |
| 2214 | process_sp->Flush(); |
| 2215 | } |
| 2216 | } else { |
| 2217 | sb_error.SetErrorStringWithFormat("invalid section"); |
| 2218 | } |
| 2219 | } |
| 2220 | } else { |
| 2221 | sb_error.SetErrorStringWithFormat("invalid target"); |
| 2222 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2223 | return LLDB_RECORD_RESULT(sb_error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module, |
| 2227 | int64_t slide_offset) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2228 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, |
| 2229 | (lldb::SBModule, int64_t), module, slide_offset); |
| 2230 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2231 | SBError sb_error; |
| 2232 | |
| 2233 | TargetSP target_sp(GetSP()); |
| 2234 | if (target_sp) { |
| 2235 | ModuleSP module_sp(module.GetSP()); |
| 2236 | if (module_sp) { |
| 2237 | bool changed = false; |
| 2238 | if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) { |
| 2239 | // The load was successful, make sure that at least some sections |
| 2240 | // changed before we notify that our module was loaded. |
| 2241 | if (changed) { |
| 2242 | ModuleList module_list; |
| 2243 | module_list.Append(module_sp); |
| 2244 | target_sp->ModulesDidLoad(module_list); |
| 2245 | // Flush info in the process (stack frames, etc) |
| 2246 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 2247 | if (process_sp) |
| 2248 | process_sp->Flush(); |
| 2249 | } |
| 2250 | } |
| 2251 | } else { |
| 2252 | sb_error.SetErrorStringWithFormat("invalid module"); |
| 2253 | } |
| 2254 | |
| 2255 | } else { |
| 2256 | sb_error.SetErrorStringWithFormat("invalid target"); |
| 2257 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2258 | return LLDB_RECORD_RESULT(sb_error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2259 | } |
| 2260 | |
| 2261 | SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2262 | LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, |
| 2263 | (lldb::SBModule), module); |
| 2264 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2265 | SBError sb_error; |
| 2266 | |
| 2267 | char path[PATH_MAX]; |
| 2268 | TargetSP target_sp(GetSP()); |
| 2269 | if (target_sp) { |
| 2270 | ModuleSP module_sp(module.GetSP()); |
| 2271 | if (module_sp) { |
| 2272 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| 2273 | if (objfile) { |
| 2274 | SectionList *section_list = objfile->GetSectionList(); |
| 2275 | if (section_list) { |
| 2276 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 2277 | |
| 2278 | bool changed = false; |
| 2279 | const size_t num_sections = section_list->GetSize(); |
| 2280 | for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) { |
| 2281 | SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); |
| 2282 | if (section_sp) |
| 2283 | changed |= target_sp->SetSectionUnloaded(section_sp); |
| 2284 | } |
| 2285 | if (changed) { |
| 2286 | ModuleList module_list; |
| 2287 | module_list.Append(module_sp); |
| 2288 | target_sp->ModulesDidUnload(module_list, false); |
| 2289 | // Flush info in the process (stack frames, etc) |
| 2290 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 2291 | if (process_sp) |
| 2292 | process_sp->Flush(); |
| 2293 | } |
| 2294 | } else { |
| 2295 | module_sp->GetFileSpec().GetPath(path, sizeof(path)); |
| 2296 | sb_error.SetErrorStringWithFormat("no sections in object file '%s'", |
| 2297 | path); |
| 2298 | } |
| 2299 | } else { |
| 2300 | module_sp->GetFileSpec().GetPath(path, sizeof(path)); |
| 2301 | sb_error.SetErrorStringWithFormat("no object file for module '%s'", |
| 2302 | path); |
| 2303 | } |
| 2304 | } else { |
| 2305 | sb_error.SetErrorStringWithFormat("invalid module"); |
| 2306 | } |
| 2307 | } else { |
| 2308 | sb_error.SetErrorStringWithFormat("invalid target"); |
| 2309 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2310 | return LLDB_RECORD_RESULT(sb_error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
| 2313 | lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, |
| 2314 | lldb::SymbolType symbol_type) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2315 | LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, |
| 2316 | (const char *, lldb::SymbolType), name, symbol_type); |
| 2317 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2318 | SBSymbolContextList sb_sc_list; |
| 2319 | if (name && name[0]) { |
| 2320 | TargetSP target_sp(GetSP()); |
| 2321 | if (target_sp) { |
| 2322 | bool append = true; |
| 2323 | target_sp->GetImages().FindSymbolsWithNameAndType( |
| 2324 | ConstString(name), symbol_type, *sb_sc_list, append); |
| 2325 | } |
| 2326 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2327 | return LLDB_RECORD_RESULT(sb_sc_list); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2328 | } |
| 2329 | |
| 2330 | lldb::SBValue SBTarget::EvaluateExpression(const char *expr) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2331 | LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, |
| 2332 | (const char *), expr); |
| 2333 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2334 | TargetSP target_sp(GetSP()); |
| 2335 | if (!target_sp) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2336 | return LLDB_RECORD_RESULT(SBValue()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2337 | |
| 2338 | SBExpressionOptions options; |
| 2339 | lldb::DynamicValueType fetch_dynamic_value = |
| 2340 | target_sp->GetPreferDynamicValue(); |
| 2341 | options.SetFetchDynamicValue(fetch_dynamic_value); |
| 2342 | options.SetUnwindOnError(true); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2343 | return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2344 | } |
| 2345 | |
| 2346 | lldb::SBValue SBTarget::EvaluateExpression(const char *expr, |
| 2347 | const SBExpressionOptions &options) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2348 | LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, |
| 2349 | (const char *, const lldb::SBExpressionOptions &), expr, |
| 2350 | options); |
| 2351 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2352 | Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2353 | SBValue expr_result; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2354 | ValueObjectSP expr_value_sp; |
| 2355 | TargetSP target_sp(GetSP()); |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2356 | StackFrame *frame = nullptr; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2357 | if (target_sp) { |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2358 | if (expr == nullptr || expr[0] == '\0') { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2359 | return LLDB_RECORD_RESULT(expr_result); |
Greg Clayton | 4b63a5c | 2013-01-04 18:10:18 +0000 | [diff] [blame] | 2360 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2361 | |
| 2362 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
| 2363 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 2364 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2365 | |
| 2366 | frame = exe_ctx.GetFramePtr(); |
| 2367 | Target *target = exe_ctx.GetTargetPtr(); |
| 2368 | |
| 2369 | if (target) { |
| 2370 | #ifdef LLDB_CONFIGURATION_DEBUG |
| 2371 | StreamString frame_description; |
| 2372 | if (frame) |
| 2373 | frame->DumpUsingSettingsFormat(&frame_description); |
Jim Ingham | 8f7db52 | 2016-12-15 00:30:30 +0000 | [diff] [blame] | 2374 | llvm::PrettyStackTraceFormat stack_trace( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2375 | "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = " |
| 2376 | "%u) %s", |
| 2377 | expr, options.GetFetchDynamicValue(), |
Zachary Turner | c156427 | 2016-11-16 21:15:24 +0000 | [diff] [blame] | 2378 | frame_description.GetString().str().c_str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2379 | #endif |
Pavel Labath | 370e5db | 2019-03-18 16:04:46 +0000 | [diff] [blame] | 2380 | target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2381 | |
| 2382 | expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2383 | } |
| 2384 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2385 | if (expr_log) |
| 2386 | expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is " |
| 2387 | "%s, summary %s **", |
| 2388 | expr_result.GetValue(), expr_result.GetSummary()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2389 | return LLDB_RECORD_RESULT(expr_result); |
Greg Clayton | 4b63a5c | 2013-01-04 18:10:18 +0000 | [diff] [blame] | 2390 | } |
| 2391 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2392 | lldb::addr_t SBTarget::GetStackRedZoneSize() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2393 | LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize); |
| 2394 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2395 | TargetSP target_sp(GetSP()); |
| 2396 | if (target_sp) { |
| 2397 | ABISP abi_sp; |
| 2398 | ProcessSP process_sp(target_sp->GetProcessSP()); |
| 2399 | if (process_sp) |
| 2400 | abi_sp = process_sp->GetABI(); |
| 2401 | else |
Jason Molenda | 43294c9 | 2017-06-29 02:57:03 +0000 | [diff] [blame] | 2402 | abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2403 | if (abi_sp) |
| 2404 | return abi_sp->GetRedZoneSize(); |
| 2405 | } |
| 2406 | return 0; |
Greg Clayton | 13fbb99 | 2013-02-01 00:47:49 +0000 | [diff] [blame] | 2407 | } |
Ilia K | 8f37ca5 | 2015-02-13 14:31:06 +0000 | [diff] [blame] | 2408 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2409 | lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2410 | LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo); |
| 2411 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 2412 | lldb::SBLaunchInfo launch_info(nullptr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2413 | TargetSP target_sp(GetSP()); |
| 2414 | if (target_sp) |
Pavel Labath | 62930e5 | 2018-01-10 11:57:31 +0000 | [diff] [blame] | 2415 | launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2416 | return LLDB_RECORD_RESULT(launch_info); |
Ilia K | 8f37ca5 | 2015-02-13 14:31:06 +0000 | [diff] [blame] | 2417 | } |
| 2418 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2419 | void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 2420 | LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo, |
| 2421 | (const lldb::SBLaunchInfo &), launch_info); |
| 2422 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 2423 | TargetSP target_sp(GetSP()); |
| 2424 | if (target_sp) |
| 2425 | m_opaque_sp->SetProcessLaunchInfo(launch_info.ref()); |
Ilia K | 8f37ca5 | 2015-02-13 14:31:06 +0000 | [diff] [blame] | 2426 | } |
Michal Gorny | ae211ec | 2019-03-19 17:13:13 +0000 | [diff] [blame] | 2427 | |
| 2428 | namespace lldb_private { |
| 2429 | namespace repro { |
| 2430 | |
| 2431 | template <> |
| 2432 | void RegisterMethods<SBTarget>(Registry &R) { |
| 2433 | LLDB_REGISTER_CONSTRUCTOR(SBTarget, ()); |
| 2434 | LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &)); |
| 2435 | LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &)); |
| 2436 | LLDB_REGISTER_METHOD(const lldb::SBTarget &, |
| 2437 | SBTarget, operator=,(const lldb::SBTarget &)); |
| 2438 | LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, |
| 2439 | (const lldb::SBEvent &)); |
| 2440 | LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, |
| 2441 | (const lldb::SBEvent &)); |
| 2442 | LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, |
| 2443 | (const lldb::SBEvent &)); |
| 2444 | LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget, |
| 2445 | GetModuleAtIndexFromEvent, |
| 2446 | (const uint32_t, const lldb::SBEvent &)); |
| 2447 | LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName, |
| 2448 | ()); |
| 2449 | LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ()); |
| 2450 | LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ()); |
| 2451 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ()); |
| 2452 | LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ()); |
| 2453 | LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ()); |
| 2454 | LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ()); |
| 2455 | LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool)); |
| 2456 | LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ()); |
| 2457 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *)); |
| 2458 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, |
| 2459 | (const char *, lldb::SBError &)); |
| 2460 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, |
| 2461 | (const char **, const char **, const char *)); |
| 2462 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ()); |
| 2463 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, |
| 2464 | (lldb::SBListener &, const char **, const char **, |
| 2465 | const char *, const char *, const char *, |
| 2466 | const char *, uint32_t, bool, lldb::SBError &)); |
| 2467 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, |
| 2468 | (lldb::SBLaunchInfo &, lldb::SBError &)); |
| 2469 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach, |
| 2470 | (lldb::SBAttachInfo &, lldb::SBError &)); |
| 2471 | LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, |
| 2472 | (lldb::SBListener &, lldb::pid_t, lldb::SBError &)); |
| 2473 | LLDB_REGISTER_METHOD( |
| 2474 | lldb::SBProcess, SBTarget, AttachToProcessWithName, |
| 2475 | (lldb::SBListener &, const char *, bool, lldb::SBError &)); |
| 2476 | LLDB_REGISTER_METHOD( |
| 2477 | lldb::SBProcess, SBTarget, ConnectRemote, |
| 2478 | (lldb::SBListener &, const char *, const char *, lldb::SBError &)); |
| 2479 | LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ()); |
| 2480 | LLDB_REGISTER_METHOD_CONST(bool, |
| 2481 | SBTarget, operator==,(const lldb::SBTarget &)); |
| 2482 | LLDB_REGISTER_METHOD_CONST(bool, |
| 2483 | SBTarget, operator!=,(const lldb::SBTarget &)); |
| 2484 | LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, |
| 2485 | (lldb::addr_t)); |
| 2486 | LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, |
| 2487 | (lldb::addr_t)); |
| 2488 | LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, |
| 2489 | (uint32_t, lldb::addr_t)); |
| 2490 | LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget, |
| 2491 | ResolveSymbolContextForAddress, |
| 2492 | (const lldb::SBAddress &, uint32_t)); |
| 2493 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2494 | BreakpointCreateByLocation, (const char *, uint32_t)); |
| 2495 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2496 | BreakpointCreateByLocation, |
| 2497 | (const lldb::SBFileSpec &, uint32_t)); |
| 2498 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2499 | BreakpointCreateByLocation, |
| 2500 | (const lldb::SBFileSpec &, uint32_t, lldb::addr_t)); |
| 2501 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2502 | BreakpointCreateByLocation, |
| 2503 | (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, |
| 2504 | lldb::SBFileSpecList &)); |
| 2505 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2506 | BreakpointCreateByLocation, |
| 2507 | (const lldb::SBFileSpec &, uint32_t, uint32_t, |
| 2508 | lldb::addr_t, lldb::SBFileSpecList &)); |
| 2509 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 2510 | (const char *, const char *)); |
| 2511 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 2512 | (const char *, const lldb::SBFileSpecList &, |
| 2513 | const lldb::SBFileSpecList &)); |
| 2514 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 2515 | (const char *, uint32_t, const lldb::SBFileSpecList &, |
| 2516 | const lldb::SBFileSpecList &)); |
| 2517 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, |
| 2518 | (const char *, uint32_t, lldb::LanguageType, |
| 2519 | const lldb::SBFileSpecList &, |
| 2520 | const lldb::SBFileSpecList &)); |
| 2521 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, |
| 2522 | (const char **, uint32_t, uint32_t, |
| 2523 | const lldb::SBFileSpecList &, |
| 2524 | const lldb::SBFileSpecList &)); |
| 2525 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, |
| 2526 | (const char **, uint32_t, uint32_t, lldb::LanguageType, |
| 2527 | const lldb::SBFileSpecList &, |
| 2528 | const lldb::SBFileSpecList &)); |
| 2529 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, |
| 2530 | (const char **, uint32_t, uint32_t, lldb::LanguageType, |
| 2531 | lldb::addr_t, const lldb::SBFileSpecList &, |
| 2532 | const lldb::SBFileSpecList &)); |
| 2533 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, |
| 2534 | (const char *, const char *)); |
| 2535 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, |
| 2536 | (const char *, const lldb::SBFileSpecList &, |
| 2537 | const lldb::SBFileSpecList &)); |
| 2538 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, |
| 2539 | (const char *, lldb::LanguageType, |
| 2540 | const lldb::SBFileSpecList &, |
| 2541 | const lldb::SBFileSpecList &)); |
| 2542 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2543 | BreakpointCreateByAddress, (lldb::addr_t)); |
| 2544 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2545 | BreakpointCreateBySBAddress, (lldb::SBAddress &)); |
| 2546 | LLDB_REGISTER_METHOD( |
| 2547 | lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, |
| 2548 | (const char *, const lldb::SBFileSpec &, const char *)); |
| 2549 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2550 | BreakpointCreateBySourceRegex, |
| 2551 | (const char *, const lldb::SBFileSpecList &, |
| 2552 | const lldb::SBFileSpecList &)); |
| 2553 | LLDB_REGISTER_METHOD( |
| 2554 | lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, |
| 2555 | (const char *, const lldb::SBFileSpecList &, |
| 2556 | const lldb::SBFileSpecList &, const lldb::SBStringList &)); |
| 2557 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, |
| 2558 | BreakpointCreateForException, |
| 2559 | (lldb::LanguageType, bool, bool)); |
| 2560 | LLDB_REGISTER_METHOD( |
| 2561 | lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, |
| 2562 | (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, |
| 2563 | const lldb::SBFileSpecList &, bool)); |
| 2564 | LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ()); |
| 2565 | LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget, |
| 2566 | GetBreakpointAtIndex, (uint32_t)); |
| 2567 | LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t)); |
| 2568 | LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, |
| 2569 | (lldb::break_id_t)); |
| 2570 | LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName, |
| 2571 | (const char *, lldb::SBBreakpointList &)); |
| 2572 | LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames, |
| 2573 | (lldb::SBStringList &)); |
| 2574 | LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *)); |
| 2575 | LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ()); |
| 2576 | LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ()); |
| 2577 | LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ()); |
| 2578 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, |
| 2579 | (lldb::SBFileSpec &, lldb::SBBreakpointList &)); |
| 2580 | LLDB_REGISTER_METHOD( |
| 2581 | lldb::SBError, SBTarget, BreakpointsCreateFromFile, |
| 2582 | (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &)); |
| 2583 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, |
| 2584 | (lldb::SBFileSpec &)); |
| 2585 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, |
| 2586 | (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool)); |
| 2587 | LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ()); |
| 2588 | LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget, |
| 2589 | GetWatchpointAtIndex, (uint32_t)); |
| 2590 | LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t)); |
| 2591 | LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, |
| 2592 | (lldb::watch_id_t)); |
| 2593 | LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, |
| 2594 | (lldb::addr_t, size_t, bool, bool, lldb::SBError &)); |
| 2595 | LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ()); |
| 2596 | LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ()); |
| 2597 | LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, |
| 2598 | (const char *, lldb::SBAddress, lldb::SBType)); |
| 2599 | LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, |
| 2600 | (const char *, lldb::SBData, lldb::SBType)); |
| 2601 | LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, |
| 2602 | (const char *, const char *)); |
| 2603 | LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ()); |
| 2604 | LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath, |
| 2605 | (const char *, const char *, lldb::SBError &)); |
| 2606 | LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, |
| 2607 | (const char *, const char *, const char *)); |
| 2608 | LLDB_REGISTER_METHOD( |
| 2609 | lldb::SBModule, SBTarget, AddModule, |
| 2610 | (const char *, const char *, const char *, const char *)); |
| 2611 | LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, |
| 2612 | (const lldb::SBModuleSpec &)); |
| 2613 | LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &)); |
| 2614 | LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ()); |
| 2615 | LLDB_REGISTER_METHOD(void, SBTarget, Clear, ()); |
| 2616 | LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule, |
| 2617 | (const lldb::SBFileSpec &)); |
| 2618 | LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, |
| 2619 | (const lldb::SBFileSpec &)); |
| 2620 | LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ()); |
| 2621 | LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ()); |
| 2622 | LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ()); |
| 2623 | LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ()); |
| 2624 | LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ()); |
| 2625 | LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, |
| 2626 | (uint32_t)); |
| 2627 | LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule)); |
| 2628 | LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster, |
| 2629 | ()); |
| 2630 | LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription, |
| 2631 | (lldb::SBStream &, lldb::DescriptionLevel)); |
| 2632 | LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, |
| 2633 | (const char *, uint32_t)); |
| 2634 | LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, |
| 2635 | FindGlobalFunctions, |
| 2636 | (const char *, uint32_t, lldb::MatchType)); |
| 2637 | LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *)); |
| 2638 | LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType, |
| 2639 | (lldb::BasicType)); |
| 2640 | LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *)); |
| 2641 | LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, |
| 2642 | (const char *, uint32_t)); |
| 2643 | LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, |
| 2644 | (const char *, uint32_t, lldb::MatchType)); |
| 2645 | LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, |
| 2646 | (const char *)); |
| 2647 | LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ()); |
| 2648 | LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, |
| 2649 | (lldb::SBAddress, uint32_t)); |
| 2650 | LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, |
| 2651 | (lldb::SBAddress, uint32_t, const char *)); |
| 2652 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, |
| 2653 | (lldb::SBSection, lldb::addr_t)); |
| 2654 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, |
| 2655 | (lldb::SBSection)); |
| 2656 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, |
| 2657 | (lldb::SBModule, int64_t)); |
| 2658 | LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, |
| 2659 | (lldb::SBModule)); |
| 2660 | LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, |
| 2661 | (const char *, lldb::SymbolType)); |
| 2662 | LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, |
| 2663 | (const char *)); |
| 2664 | LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, |
| 2665 | (const char *, const lldb::SBExpressionOptions &)); |
| 2666 | LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ()); |
| 2667 | LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ()); |
| 2668 | LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo, |
| 2669 | (const lldb::SBLaunchInfo &)); |
| 2670 | } |
| 2671 | |
| 2672 | } |
| 2673 | } |