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