blob: 2ef8bcdf39a858e2864714d8d806f4eed9d40494 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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 Friedman4c5de692010-06-09 07:44:37 +000010#include "lldb/API/SBTarget.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000011
Greg Claytone0d378b2011-03-24 21:19:54 +000012#include "lldb/lldb-public.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000013
Greg Claytondea8cb42011-06-29 22:09:02 +000014#include "lldb/API/SBBreakpoint.h"
Ilia Keb2c19a2015-03-10 21:59:55 +000015#include "lldb/API/SBDebugger.h"
16#include "lldb/API/SBEvent.h"
Greg Clayton4b63a5c2013-01-04 18:10:18 +000017#include "lldb/API/SBExpressionOptions.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include "lldb/API/SBFileSpec.h"
Greg Claytondea8cb42011-06-29 22:09:02 +000019#include "lldb/API/SBListener.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020#include "lldb/API/SBModule.h"
Greg Clayton226cce22013-07-08 22:22:41 +000021#include "lldb/API/SBModuleSpec.h"
Jim Inghame37d6052011-09-13 00:29:56 +000022#include "lldb/API/SBSourceManager.h"
Greg Claytondea8cb42011-06-29 22:09:02 +000023#include "lldb/API/SBProcess.h"
Caroline Ticedde9cff2010-09-20 05:20:02 +000024#include "lldb/API/SBStream.h"
Greg Claytonfe356d32011-06-21 01:34:41 +000025#include "lldb/API/SBSymbolContextList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Breakpoint/BreakpointID.h"
27#include "lldb/Breakpoint/BreakpointIDList.h"
28#include "lldb/Breakpoint/BreakpointList.h"
29#include "lldb/Breakpoint/BreakpointLocation.h"
30#include "lldb/Core/Address.h"
31#include "lldb/Core/AddressResolver.h"
32#include "lldb/Core/AddressResolverName.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000033#include "lldb/Core/ArchSpec.h"
34#include "lldb/Core/Debugger.h"
35#include "lldb/Core/Disassembler.h"
Caroline Ticeceb6b132010-10-26 03:11:13 +000036#include "lldb/Core/Log.h"
Greg Clayton1f746072012-08-29 21:13:06 +000037#include "lldb/Core/Module.h"
38#include "lldb/Core/ModuleSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039#include "lldb/Core/RegularExpression.h"
40#include "lldb/Core/SearchFilter.h"
Greg Clayton1f746072012-08-29 21:13:06 +000041#include "lldb/Core/Section.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000042#include "lldb/Core/STLUtils.h"
Enrico Granata347c2aa2013-10-08 21:49:02 +000043#include "lldb/Core/ValueObjectConstResult.h"
Greg Claytondea8cb42011-06-29 22:09:02 +000044#include "lldb/Core/ValueObjectList.h"
45#include "lldb/Core/ValueObjectVariable.h"
46#include "lldb/Host/FileSpec.h"
Greg Clayton7fb56d02011-02-01 01:31:41 +000047#include "lldb/Host/Host.h"
Greg Claytondea8cb42011-06-29 22:09:02 +000048#include "lldb/Interpreter/Args.h"
Zachary Turnera78bd7f2015-03-03 23:11:11 +000049#include "lldb/Symbol/ClangASTContext.h"
50#include "lldb/Symbol/DeclVendor.h"
Greg Clayton1f746072012-08-29 21:13:06 +000051#include "lldb/Symbol/ObjectFile.h"
Greg Claytonae088e52016-02-10 21:28:13 +000052#include "lldb/Symbol/SymbolFile.h"
Enrico Granata6f3533f2011-07-29 19:53:35 +000053#include "lldb/Symbol/SymbolVendor.h"
Greg Claytondea8cb42011-06-29 22:09:02 +000054#include "lldb/Symbol/VariableList.h"
Zachary Turner32abc6e2015-03-03 19:23:09 +000055#include "lldb/Target/ABI.h"
Jim Ingham0e0984e2015-09-02 01:06:46 +000056#include "lldb/Target/Language.h"
Jim Inghamfab10e82012-03-06 00:37:27 +000057#include "lldb/Target/LanguageRuntime.h"
Zachary Turnera78bd7f2015-03-03 23:11:11 +000058#include "lldb/Target/ObjCLanguageRuntime.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000059#include "lldb/Target/Process.h"
Enrico Granatab10e0032015-03-04 21:33:45 +000060#include "lldb/Target/StackFrame.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000061#include "lldb/Target/Target.h"
62#include "lldb/Target/TargetList.h"
63
64#include "lldb/Interpreter/CommandReturnObject.h"
65#include "../source/Commands/CommandObjectBreakpoint.h"
Carlo Kok0fd6fd42014-09-19 19:38:19 +000066#include "llvm/Support/Regex.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000067
Chris Lattner30fdc8d2010-06-08 16:52:24 +000068
69using namespace lldb;
70using namespace lldb_private;
71
72#define DEFAULT_DISASM_BYTE_SIZE 32
73
Oleksiy Vyalov37386142015-02-10 22:49:57 +000074namespace {
75
76Error
77AttachToProcess (ProcessAttachInfo &attach_info, Target &target)
78{
79 Mutex::Locker api_locker (target.GetAPIMutex ());
80
81 auto process_sp = target.GetProcessSP ();
82 if (process_sp)
83 {
84 const auto state = process_sp->GetState ();
85 if (process_sp->IsAlive () && state == eStateConnected)
86 {
87 // If we are already connected, then we have already specified the
88 // listener, so if a valid listener is supplied, we need to error out
89 // to let the client know.
90 if (attach_info.GetListener ())
91 return Error ("process is connected and already has a listener, pass empty listener");
92 }
93 }
94
95 return target.Attach (attach_info, nullptr);
96}
97
98} // namespace
99
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000100//----------------------------------------------------------------------
101// SBTarget constructor
102//----------------------------------------------------------------------
Greg Clayton54979cd2010-12-15 05:08:08 +0000103SBTarget::SBTarget () :
104 m_opaque_sp ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000105{
106}
107
108SBTarget::SBTarget (const SBTarget& rhs) :
Greg Clayton66111032010-06-23 01:19:29 +0000109 m_opaque_sp (rhs.m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000110{
111}
112
113SBTarget::SBTarget(const TargetSP& target_sp) :
Greg Clayton66111032010-06-23 01:19:29 +0000114 m_opaque_sp (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000115{
116}
117
Greg Claytonefabb122010-11-05 23:17:00 +0000118const SBTarget&
119SBTarget::operator = (const SBTarget& rhs)
120{
121 if (this != &rhs)
122 m_opaque_sp = rhs.m_opaque_sp;
123 return *this;
124}
125
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000126//----------------------------------------------------------------------
127// Destructor
128//----------------------------------------------------------------------
129SBTarget::~SBTarget()
130{
131}
132
Ilia Keb2c19a2015-03-10 21:59:55 +0000133bool
134SBTarget::EventIsTargetEvent (const SBEvent &event)
135{
136 return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
137}
138
139SBTarget
140SBTarget::GetTargetFromEvent (const SBEvent &event)
141{
142 return Target::TargetEventData::GetTargetFromEvent (event.get());
143}
144
145uint32_t
146SBTarget::GetNumModulesFromEvent (const SBEvent &event)
147{
148 const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent (event.get());
149 return module_list.GetSize();
150}
151
152SBModule
153SBTarget::GetModuleAtIndexFromEvent (const uint32_t idx, const SBEvent &event)
154{
155 const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent (event.get());
156 return SBModule(module_list.GetModuleAtIndex(idx));
157}
158
Jim Ingham4bddaeb2012-02-16 06:50:00 +0000159const char *
160SBTarget::GetBroadcasterClassName ()
161{
162 return Target::GetStaticBroadcasterClass().AsCString();
163}
164
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000165bool
166SBTarget::IsValid () const
167{
Filipe Cabecinhas721ba3f2012-05-19 09:59:08 +0000168 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000169}
170
171SBProcess
172SBTarget::GetProcess ()
173{
174 SBProcess sb_process;
Greg Claytonb9556ac2012-01-30 07:41:31 +0000175 ProcessSP process_sp;
Greg Claytonacdbe812012-01-30 09:04:36 +0000176 TargetSP target_sp(GetSP());
177 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000178 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000179 process_sp = target_sp->GetProcessSP();
Greg Claytonb9556ac2012-01-30 07:41:31 +0000180 sb_process.SetSP (process_sp);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000181 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000182
Greg Clayton5160ce52013-03-27 23:08:40 +0000183 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000184 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000185 log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
186 static_cast<void*>(target_sp.get()),
187 static_cast<void*>(process_sp.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000188
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000189 return sb_process;
190}
191
Matthew Gardinerc928de32014-10-22 07:22:56 +0000192SBPlatform
193SBTarget::GetPlatform ()
194{
195 TargetSP target_sp(GetSP());
196 if (!target_sp)
197 return SBPlatform();
198
199 SBPlatform platform;
200 platform.m_opaque_sp = target_sp->GetPlatform();
201
202 return platform;
203}
204
Greg Clayton66111032010-06-23 01:19:29 +0000205SBDebugger
206SBTarget::GetDebugger () const
207{
208 SBDebugger debugger;
Greg Claytonacdbe812012-01-30 09:04:36 +0000209 TargetSP target_sp(GetSP());
210 if (target_sp)
211 debugger.reset (target_sp->GetDebugger().shared_from_this());
Greg Clayton66111032010-06-23 01:19:29 +0000212 return debugger;
213}
214
Jim Ingham270684d2011-03-31 00:01:24 +0000215SBProcess
Greg Clayton4d8ad552013-03-25 22:40:51 +0000216SBTarget::LoadCore (const char *core_file)
217{
218 SBProcess sb_process;
219 TargetSP target_sp(GetSP());
220 if (target_sp)
221 {
222 FileSpec filespec(core_file, true);
223 ProcessSP process_sp (target_sp->CreateProcess(target_sp->GetDebugger().GetListener(),
224 NULL,
225 &filespec));
226 if (process_sp)
227 {
228 process_sp->LoadCore();
229 sb_process.SetSP (process_sp);
230 }
231 }
232 return sb_process;
233}
234
235SBProcess
Jim Ingham270684d2011-03-31 00:01:24 +0000236SBTarget::LaunchSimple
237(
238 char const **argv,
239 char const **envp,
240 const char *working_directory
241)
242{
243 char *stdin_path = NULL;
244 char *stdout_path = NULL;
245 char *stderr_path = NULL;
246 uint32_t launch_flags = 0;
247 bool stop_at_entry = false;
248 SBError error;
249 SBListener listener = GetDebugger().GetListener();
250 return Launch (listener,
251 argv,
252 envp,
253 stdin_path,
254 stdout_path,
255 stderr_path,
256 working_directory,
257 launch_flags,
258 stop_at_entry,
259 error);
260}
Greg Claytonbd82a5d2011-01-23 05:56:20 +0000261
Greg Claytonfbb76342013-11-20 21:07:01 +0000262SBError
263SBTarget::Install()
264{
265 SBError sb_error;
266 TargetSP target_sp(GetSP());
267 if (target_sp)
268 {
269 Mutex::Locker api_locker (target_sp->GetAPIMutex());
270 sb_error.ref() = target_sp->Install(NULL);
271 }
272 return sb_error;
273}
274
Greg Claytonbd82a5d2011-01-23 05:56:20 +0000275SBProcess
276SBTarget::Launch
277(
Greg Clayton4b045622011-02-03 21:28:34 +0000278 SBListener &listener,
Greg Claytonbd82a5d2011-01-23 05:56:20 +0000279 char const **argv,
280 char const **envp,
281 const char *stdin_path,
282 const char *stdout_path,
283 const char *stderr_path,
284 const char *working_directory,
285 uint32_t launch_flags, // See LaunchFlags
286 bool stop_at_entry,
287 lldb::SBError& error
288)
289{
Greg Clayton5160ce52013-03-27 23:08:40 +0000290 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000291
Greg Claytonacdbe812012-01-30 09:04:36 +0000292 SBProcess sb_process;
293 ProcessSP process_sp;
294 TargetSP target_sp(GetSP());
295
Caroline Ticeceb6b132010-10-26 03:11:13 +0000296 if (log)
Greg Claytonbd82a5d2011-01-23 05:56:20 +0000297 log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000298 static_cast<void*>(target_sp.get()),
299 static_cast<void*>(argv), static_cast<void*>(envp),
300 stdin_path ? stdin_path : "NULL",
301 stdout_path ? stdout_path : "NULL",
302 stderr_path ? stderr_path : "NULL",
Greg Claytonbd82a5d2011-01-23 05:56:20 +0000303 working_directory ? working_directory : "NULL",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000304 launch_flags, stop_at_entry,
305 static_cast<void*>(error.get()));
Greg Claytonacdbe812012-01-30 09:04:36 +0000306
307 if (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000308 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000309 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Clayton5d5028b2010-10-06 03:53:16 +0000310
Zachary Turner6fd3f342015-02-02 18:50:01 +0000311 if (stop_at_entry)
312 launch_flags |= eLaunchFlagStopAtEntry;
313
Greg Clayton645bf542011-01-27 01:01:10 +0000314 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
315 launch_flags |= eLaunchFlagDisableASLR;
316
Greg Clayton2289fa42011-04-30 01:09:13 +0000317 StateType state = eStateInvalid;
Greg Claytonacdbe812012-01-30 09:04:36 +0000318 process_sp = target_sp->GetProcessSP();
Greg Claytonb9556ac2012-01-30 07:41:31 +0000319 if (process_sp)
Greg Clayton931180e2011-01-27 06:44:37 +0000320 {
Greg Claytonb9556ac2012-01-30 07:41:31 +0000321 state = process_sp->GetState();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000322
Greg Claytonb9556ac2012-01-30 07:41:31 +0000323 if (process_sp->IsAlive() && state != eStateConnected)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000324 {
Greg Clayton2289fa42011-04-30 01:09:13 +0000325 if (state == eStateAttaching)
326 error.SetErrorString ("process attach is in progress");
327 else
328 error.SetErrorString ("a process is already being debugged");
Greg Clayton2289fa42011-04-30 01:09:13 +0000329 return sb_process;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000330 }
Greg Clayton931180e2011-01-27 06:44:37 +0000331 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000332
Greg Clayton2289fa42011-04-30 01:09:13 +0000333 if (state == eStateConnected)
334 {
335 // If we are already connected, then we have already specified the
336 // listener, so if a valid listener is supplied, we need to error out
337 // to let the client know.
338 if (listener.IsValid())
339 {
340 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
Greg Clayton2289fa42011-04-30 01:09:13 +0000341 return sb_process;
342 }
343 }
Greg Claytonb09c5382013-12-13 17:20:18 +0000344
345 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
346 launch_flags |= eLaunchFlagDisableSTDIO;
347
Chaoren Lind3173f32015-05-29 19:52:29 +0000348 ProcessLaunchInfo launch_info(FileSpec{stdin_path, false},
349 FileSpec{stdout_path, false},
350 FileSpec{stderr_path, false},
351 FileSpec{working_directory, false},
352 launch_flags);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000353
Greg Claytonb09c5382013-12-13 17:20:18 +0000354 Module *exe_module = target_sp->GetExecutableModulePointer();
355 if (exe_module)
356 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
357 if (argv)
358 launch_info.GetArguments().AppendArguments (argv);
359 if (envp)
360 launch_info.GetEnvironmentEntries ().SetArguments (envp);
361
362 if (listener.IsValid())
Greg Clayton8012cad2014-11-17 19:39:20 +0000363 launch_info.SetListener(listener.GetSP());
364
365 error.SetError (target_sp->Launch(launch_info, NULL));
Greg Clayton645bf542011-01-27 01:01:10 +0000366
Greg Claytonb09c5382013-12-13 17:20:18 +0000367 sb_process.SetSP(target_sp->GetProcessSP());
Greg Clayton524e60b2010-10-06 22:10:17 +0000368 }
369 else
370 {
371 error.SetErrorString ("SBTarget is invalid");
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000372 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000373
Caroline Tice20ad3c42010-10-29 21:48:37 +0000374 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
Caroline Ticeceb6b132010-10-26 03:11:13 +0000375 if (log)
Pavel Labathd2474ff2016-02-02 15:16:20 +0000376 log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p), SBError(%s)", static_cast<void *>(target_sp.get()),
377 static_cast<void *>(sb_process.GetSP().get()), error.GetCString());
Caroline Ticeceb6b132010-10-26 03:11:13 +0000378
Greg Clayton5d5028b2010-10-06 03:53:16 +0000379 return sb_process;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000380}
381
Greg Clayton0e615682012-02-24 05:03:03 +0000382SBProcess
383SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
384{
Greg Clayton5160ce52013-03-27 23:08:40 +0000385 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000386
Greg Clayton0e615682012-02-24 05:03:03 +0000387 SBProcess sb_process;
Greg Clayton0e615682012-02-24 05:03:03 +0000388 TargetSP target_sp(GetSP());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000389
Greg Clayton0e615682012-02-24 05:03:03 +0000390 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000391 log->Printf ("SBTarget(%p)::Launch (launch_info, error)...",
392 static_cast<void*>(target_sp.get()));
393
Greg Clayton0e615682012-02-24 05:03:03 +0000394 if (target_sp)
395 {
396 Mutex::Locker api_locker (target_sp->GetAPIMutex());
397 StateType state = eStateInvalid;
Greg Claytonb09c5382013-12-13 17:20:18 +0000398 {
Greg Clayton3e32ad62014-05-07 20:16:06 +0000399 ProcessSP process_sp = target_sp->GetProcessSP();
400 if (process_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000401 {
Greg Clayton3e32ad62014-05-07 20:16:06 +0000402 state = process_sp->GetState();
403
404 if (process_sp->IsAlive() && state != eStateConnected)
405 {
406 if (state == eStateAttaching)
407 error.SetErrorString ("process attach is in progress");
408 else
409 error.SetErrorString ("a process is already being debugged");
410 return sb_process;
411 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000412 }
Greg Clayton0e615682012-02-24 05:03:03 +0000413 }
Greg Claytonb09c5382013-12-13 17:20:18 +0000414
415 lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
416
Greg Clayton3e32ad62014-05-07 20:16:06 +0000417 if (!launch_info.GetExecutableFile())
418 {
419 Module *exe_module = target_sp->GetExecutableModulePointer();
420 if (exe_module)
421 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
422 }
Greg Claytonb09c5382013-12-13 17:20:18 +0000423
424 const ArchSpec &arch_spec = target_sp->GetArchitecture();
425 if (arch_spec.IsValid())
426 launch_info.GetArchitecture () = arch_spec;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000427
Greg Clayton8012cad2014-11-17 19:39:20 +0000428 error.SetError (target_sp->Launch (launch_info, NULL));
Greg Claytonb09c5382013-12-13 17:20:18 +0000429 sb_process.SetSP(target_sp->GetProcessSP());
Greg Clayton0e615682012-02-24 05:03:03 +0000430 }
431 else
432 {
433 error.SetErrorString ("SBTarget is invalid");
434 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000435
Greg Clayton0e615682012-02-24 05:03:03 +0000436 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
437 if (log)
Greg Claytonb09c5382013-12-13 17:20:18 +0000438 log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000439 static_cast<void*>(target_sp.get()),
440 static_cast<void*>(sb_process.GetSP().get()));
441
Greg Clayton0e615682012-02-24 05:03:03 +0000442 return sb_process;
443}
444
445lldb::SBProcess
446SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error)
447{
Greg Clayton5160ce52013-03-27 23:08:40 +0000448 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000449
Greg Clayton0e615682012-02-24 05:03:03 +0000450 SBProcess sb_process;
Greg Clayton0e615682012-02-24 05:03:03 +0000451 TargetSP target_sp(GetSP());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000452
Sean Callanan575a4542012-10-20 00:21:31 +0000453 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000454 log->Printf ("SBTarget(%p)::Attach (sb_attach_info, error)...",
455 static_cast<void*>(target_sp.get()));
456
Greg Clayton0e615682012-02-24 05:03:03 +0000457 if (target_sp)
458 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000459 ProcessAttachInfo &attach_info = sb_attach_info.ref();
460 if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid())
Greg Clayton0e615682012-02-24 05:03:03 +0000461 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000462 PlatformSP platform_sp = target_sp->GetPlatform();
463 // See if we can pre-verify if a process exists or not
464 if (platform_sp && platform_sp->IsConnected())
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000465 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000466 lldb::pid_t attach_pid = attach_info.GetProcessID();
467 ProcessInstanceInfo instance_info;
468 if (platform_sp->GetProcessInfo(attach_pid, instance_info))
Han Ming Ongcec8c902012-02-29 00:12:56 +0000469 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000470 attach_info.SetUserID(instance_info.GetEffectiveUserID());
471 }
472 else
473 {
474 error.ref().SetErrorStringWithFormat("no process found with process ID %" PRIu64, attach_pid);
475 if (log)
Greg Clayton91e407e2012-09-27 00:03:39 +0000476 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000477 log->Printf ("SBTarget(%p)::Attach (...) => error %s",
478 static_cast<void*>(target_sp.get()), error.GetCString());
Greg Clayton91e407e2012-09-27 00:03:39 +0000479 }
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000480 return sb_process;
Han Ming Ongcec8c902012-02-29 00:12:56 +0000481 }
482 }
Greg Clayton0e615682012-02-24 05:03:03 +0000483 }
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000484 error.SetError(AttachToProcess(attach_info, *target_sp));
485 if (error.Success())
486 sb_process.SetSP(target_sp->GetProcessSP());
Greg Clayton0e615682012-02-24 05:03:03 +0000487 }
488 else
489 {
490 error.SetErrorString ("SBTarget is invalid");
491 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000492
Sean Callanan575a4542012-10-20 00:21:31 +0000493 if (log)
Sean Callanan575a4542012-10-20 00:21:31 +0000494 log->Printf ("SBTarget(%p)::Attach (...) => SBProcess(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000495 static_cast<void*>(target_sp.get()),
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000496 static_cast<void*>(sb_process.GetSP().get()));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000497
Greg Clayton0e615682012-02-24 05:03:03 +0000498 return sb_process;
499}
500
501
Greg Clayton1ba6cfd2011-12-02 02:10:57 +0000502#if defined(__APPLE__)
503
504lldb::SBProcess
505SBTarget::AttachToProcessWithID (SBListener &listener,
506 ::pid_t pid,
507 lldb::SBError& error)
508{
509 return AttachToProcessWithID (listener, (lldb::pid_t)pid, error);
510}
511
512#endif // #if defined(__APPLE__)
Greg Clayton524e60b2010-10-06 22:10:17 +0000513
514lldb::SBProcess
Greg Clayton05faeb72010-10-07 04:19:01 +0000515SBTarget::AttachToProcessWithID
Greg Clayton524e60b2010-10-06 22:10:17 +0000516(
Greg Clayton4b045622011-02-03 21:28:34 +0000517 SBListener &listener,
Greg Clayton524e60b2010-10-06 22:10:17 +0000518 lldb::pid_t pid,// The process ID to attach to
519 SBError& error // An error explaining what went wrong if attach fails
520)
521{
Greg Clayton5160ce52013-03-27 23:08:40 +0000522 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Sean Callanan575a4542012-10-20 00:21:31 +0000523
Greg Clayton524e60b2010-10-06 22:10:17 +0000524 SBProcess sb_process;
Greg Claytonacdbe812012-01-30 09:04:36 +0000525 TargetSP target_sp(GetSP());
Sean Callanan575a4542012-10-20 00:21:31 +0000526
527 if (log)
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000528 log->Printf ("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...",
529 static_cast<void*>(target_sp.get()),
530 __FUNCTION__,
531 pid);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000532
Greg Claytonacdbe812012-01-30 09:04:36 +0000533 if (target_sp)
Greg Clayton524e60b2010-10-06 22:10:17 +0000534 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000535 ProcessAttachInfo attach_info;
536 attach_info.SetProcessID (pid);
537 if (listener.IsValid())
538 attach_info.SetListener(listener.GetSP());
Greg Clayton0c74e782011-06-24 03:21:43 +0000539
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000540 ProcessInstanceInfo instance_info;
541 if (target_sp->GetPlatform ()->GetProcessInfo (pid, instance_info))
542 attach_info.SetUserID (instance_info.GetEffectiveUserID ());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000543
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000544 error.SetError (AttachToProcess (attach_info, *target_sp));
545 if (error.Success ())
546 sb_process.SetSP (target_sp->GetProcessSP ());
Greg Clayton524e60b2010-10-06 22:10:17 +0000547 }
548 else
Greg Clayton524e60b2010-10-06 22:10:17 +0000549 error.SetErrorString ("SBTarget is invalid");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000550
Sean Callanan575a4542012-10-20 00:21:31 +0000551 if (log)
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000552 log->Printf ("SBTarget(%p)::%s (...) => SBProcess(%p)",
553 static_cast<void*>(target_sp.get ()),
554 __FUNCTION__,
555 static_cast<void*>(sb_process.GetSP().get ()));
Greg Clayton524e60b2010-10-06 22:10:17 +0000556 return sb_process;
Greg Clayton524e60b2010-10-06 22:10:17 +0000557}
558
559lldb::SBProcess
Greg Clayton05faeb72010-10-07 04:19:01 +0000560SBTarget::AttachToProcessWithName
Greg Clayton524e60b2010-10-06 22:10:17 +0000561(
Greg Clayton4b045622011-02-03 21:28:34 +0000562 SBListener &listener,
Greg Clayton524e60b2010-10-06 22:10:17 +0000563 const char *name, // basename of process to attach to
564 bool wait_for, // if true wait for a new instance of "name" to be launched
565 SBError& error // An error explaining what went wrong if attach fails
566)
567{
Greg Clayton5160ce52013-03-27 23:08:40 +0000568 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000569
Greg Clayton524e60b2010-10-06 22:10:17 +0000570 SBProcess sb_process;
Greg Claytonacdbe812012-01-30 09:04:36 +0000571 TargetSP target_sp(GetSP());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000572
Sean Callanan575a4542012-10-20 00:21:31 +0000573 if (log)
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000574 log->Printf ("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...",
575 static_cast<void*>(target_sp.get()),
576 __FUNCTION__,
577 name,
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000578 wait_for ? "true" : "false");
579
Greg Claytonacdbe812012-01-30 09:04:36 +0000580 if (name && target_sp)
Greg Clayton524e60b2010-10-06 22:10:17 +0000581 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000582 ProcessAttachInfo attach_info;
583 attach_info.GetExecutableFile().SetFile(name, false);
584 attach_info.SetWaitForLaunch(wait_for);
585 if (listener.IsValid())
586 attach_info.SetListener(listener.GetSP());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000587
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000588 error.SetError (AttachToProcess (attach_info, *target_sp));
589 if (error.Success ())
590 sb_process.SetSP (target_sp->GetProcessSP ());
Greg Clayton524e60b2010-10-06 22:10:17 +0000591 }
592 else
Greg Clayton524e60b2010-10-06 22:10:17 +0000593 error.SetErrorString ("SBTarget is invalid");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000594
Sean Callanan575a4542012-10-20 00:21:31 +0000595 if (log)
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000596 log->Printf ("SBTarget(%p)::%s (...) => SBProcess(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000597 static_cast<void*>(target_sp.get()),
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000598 __FUNCTION__,
599 static_cast<void*>(sb_process.GetSP().get()));
Greg Clayton524e60b2010-10-06 22:10:17 +0000600 return sb_process;
Greg Clayton524e60b2010-10-06 22:10:17 +0000601}
602
James McIlree9631aae2011-03-04 00:31:13 +0000603lldb::SBProcess
604SBTarget::ConnectRemote
605(
606 SBListener &listener,
607 const char *url,
608 const char *plugin_name,
609 SBError& error
610)
611{
Greg Clayton5160ce52013-03-27 23:08:40 +0000612 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Sean Callanan575a4542012-10-20 00:21:31 +0000613
James McIlree9631aae2011-03-04 00:31:13 +0000614 SBProcess sb_process;
Greg Claytonb9556ac2012-01-30 07:41:31 +0000615 ProcessSP process_sp;
Greg Claytonacdbe812012-01-30 09:04:36 +0000616 TargetSP target_sp(GetSP());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000617
Sean Callanan575a4542012-10-20 00:21:31 +0000618 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000619 log->Printf ("SBTarget(%p)::ConnectRemote (listener, url=%s, plugin_name=%s, error)...",
620 static_cast<void*>(target_sp.get()), url, plugin_name);
621
Greg Claytonacdbe812012-01-30 09:04:36 +0000622 if (target_sp)
James McIlree9631aae2011-03-04 00:31:13 +0000623 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000624 Mutex::Locker api_locker (target_sp->GetAPIMutex());
James McIlree9631aae2011-03-04 00:31:13 +0000625 if (listener.IsValid())
Jim Ingham583bbb12016-03-07 21:50:25 +0000626 process_sp = target_sp->CreateProcess (listener.m_opaque_sp, plugin_name, NULL);
James McIlree9631aae2011-03-04 00:31:13 +0000627 else
Greg Claytonc3776bf2012-02-09 06:16:32 +0000628 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name, NULL);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000629
Greg Claytonb9556ac2012-01-30 07:41:31 +0000630 if (process_sp)
James McIlree9631aae2011-03-04 00:31:13 +0000631 {
Greg Claytonb9556ac2012-01-30 07:41:31 +0000632 sb_process.SetSP (process_sp);
Jason Molenda4bd4e7e2012-09-29 04:02:01 +0000633 error.SetError (process_sp->ConnectRemote (NULL, url));
James McIlree9631aae2011-03-04 00:31:13 +0000634 }
635 else
636 {
637 error.SetErrorString ("unable to create lldb_private::Process");
638 }
639 }
640 else
641 {
642 error.SetErrorString ("SBTarget is invalid");
643 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000644
Sean Callanan575a4542012-10-20 00:21:31 +0000645 if (log)
Sean Callanan575a4542012-10-20 00:21:31 +0000646 log->Printf ("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000647 static_cast<void*>(target_sp.get()),
648 static_cast<void*>(process_sp.get()));
James McIlree9631aae2011-03-04 00:31:13 +0000649 return sb_process;
650}
651
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000652SBFileSpec
653SBTarget::GetExecutable ()
654{
Caroline Ticeceb6b132010-10-26 03:11:13 +0000655
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000656 SBFileSpec exe_file_spec;
Greg Claytonacdbe812012-01-30 09:04:36 +0000657 TargetSP target_sp(GetSP());
658 if (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000659 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000660 Module *exe_module = target_sp->GetExecutableModulePointer();
Greg Claytonaa149cb2011-08-11 02:48:45 +0000661 if (exe_module)
662 exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000663 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000664
Greg Clayton5160ce52013-03-27 23:08:40 +0000665 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000666 if (log)
667 {
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000668 log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
669 static_cast<void*>(target_sp.get()),
670 static_cast<const void*>(exe_file_spec.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000671 }
672
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000673 return exe_file_spec;
674}
675
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000676bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000677SBTarget::operator == (const SBTarget &rhs) const
678{
Greg Clayton66111032010-06-23 01:19:29 +0000679 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000680}
681
682bool
683SBTarget::operator != (const SBTarget &rhs) const
684{
Greg Clayton66111032010-06-23 01:19:29 +0000685 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000686}
687
Greg Claytonb9556ac2012-01-30 07:41:31 +0000688lldb::TargetSP
689SBTarget::GetSP () const
Greg Clayton9a377662011-10-01 02:59:24 +0000690{
691 return m_opaque_sp;
692}
693
Greg Clayton66111032010-06-23 01:19:29 +0000694void
Greg Claytonb9556ac2012-01-30 07:41:31 +0000695SBTarget::SetSP (const lldb::TargetSP& target_sp)
Greg Clayton66111032010-06-23 01:19:29 +0000696{
697 m_opaque_sp = target_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000698}
699
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000700lldb::SBAddress
701SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
Greg Claytonac2eb9b2010-12-12 19:25:26 +0000702{
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000703 lldb::SBAddress sb_addr;
704 Address &addr = sb_addr.ref();
Greg Claytonacdbe812012-01-30 09:04:36 +0000705 TargetSP target_sp(GetSP());
706 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000707 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000708 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Claytond5944cd2013-12-06 01:12:00 +0000709 if (target_sp->ResolveLoadAddress (vm_addr, addr))
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000710 return sb_addr;
Greg Claytonaf67cec2010-12-20 20:49:23 +0000711 }
Greg Claytonac2eb9b2010-12-12 19:25:26 +0000712
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000713 // We have a load address that isn't in a section, just return an address
714 // with the offset filled in (the address) and the section set to NULL
Greg Claytone72dfb32012-02-24 01:59:29 +0000715 addr.SetRawAddress(vm_addr);
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000716 return sb_addr;
Greg Claytonac2eb9b2010-12-12 19:25:26 +0000717}
718
Matthew Gardinerc928de32014-10-22 07:22:56 +0000719lldb::SBAddress
720SBTarget::ResolveFileAddress (lldb::addr_t file_addr)
721{
722 lldb::SBAddress sb_addr;
723 Address &addr = sb_addr.ref();
724 TargetSP target_sp(GetSP());
725 if (target_sp)
726 {
727 Mutex::Locker api_locker (target_sp->GetAPIMutex());
728 if (target_sp->ResolveFileAddress (file_addr, addr))
729 return sb_addr;
730 }
731
732 addr.SetRawAddress(file_addr);
733 return sb_addr;
734}
Greg Claytond5944cd2013-12-06 01:12:00 +0000735
736lldb::SBAddress
737SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr)
738{
739 lldb::SBAddress sb_addr;
740 Address &addr = sb_addr.ref();
741 TargetSP target_sp(GetSP());
742 if (target_sp)
743 {
744 Mutex::Locker api_locker (target_sp->GetAPIMutex());
745 if (target_sp->ResolveLoadAddress (vm_addr, addr))
746 return sb_addr;
747 }
748
749 // We have a load address that isn't in a section, just return an address
750 // with the offset filled in (the address) and the section set to NULL
751 addr.SetRawAddress(vm_addr);
752 return sb_addr;
753}
754
Greg Clayton5f2a4f92011-03-02 21:34:46 +0000755SBSymbolContext
Greg Claytoneb023e72013-10-11 19:48:25 +0000756SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr,
757 uint32_t resolve_scope)
Greg Clayton5f2a4f92011-03-02 21:34:46 +0000758{
759 SBSymbolContext sc;
Greg Claytonacdbe812012-01-30 09:04:36 +0000760 if (addr.IsValid())
761 {
762 TargetSP target_sp(GetSP());
763 if (target_sp)
764 target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
765 }
Greg Clayton5f2a4f92011-03-02 21:34:46 +0000766 return sc;
767}
768
Matthew Gardinerc928de32014-10-22 07:22:56 +0000769size_t
770SBTarget::ReadMemory (const SBAddress addr,
771 void *buf,
772 size_t size,
773 lldb::SBError &error)
774{
775 SBError sb_error;
776 size_t bytes_read = 0;
777 TargetSP target_sp(GetSP());
778 if (target_sp)
779 {
780 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Clayton8691dc52014-11-04 00:56:30 +0000781 bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
782 }
783 else
784 {
785 sb_error.SetErrorString("invalid target");
Matthew Gardinerc928de32014-10-22 07:22:56 +0000786 }
787
788 return bytes_read;
789}
Greg Clayton5f2a4f92011-03-02 21:34:46 +0000790
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000791SBBreakpoint
Greg Claytoneb023e72013-10-11 19:48:25 +0000792SBTarget::BreakpointCreateByLocation (const char *file,
793 uint32_t line)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000794{
Greg Clayton7481c202010-11-08 00:28:40 +0000795 return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000796}
797
798SBBreakpoint
Greg Claytoneb023e72013-10-11 19:48:25 +0000799SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
800 uint32_t line)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000801{
Jim Ingham24111672016-03-09 18:59:13 +0000802 return BreakpointCreateByLocation(sb_file_spec, line, 0);
803}
804
805SBBreakpoint
806SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
807 uint32_t line,
808 lldb::addr_t offset)
809{
Greg Clayton5160ce52013-03-27 23:08:40 +0000810 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000811
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000812 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +0000813 TargetSP target_sp(GetSP());
814 if (target_sp && line != 0)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000815 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000816 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000817
Greg Clayton1f746072012-08-29 21:13:06 +0000818 const LazyBool check_inlines = eLazyBoolCalculate;
Jim Inghama8558b62012-05-22 00:12:20 +0000819 const LazyBool skip_prologue = eLazyBoolCalculate;
Greg Clayton1f746072012-08-29 21:13:06 +0000820 const bool internal = false;
Greg Claytoneb023e72013-10-11 19:48:25 +0000821 const bool hardware = false;
Ilia K055ad9b2015-05-18 13:41:01 +0000822 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
Jim Ingham24111672016-03-09 18:59:13 +0000823 *sb_bp = target_sp->CreateBreakpoint (NULL,
824 *sb_file_spec,
825 line,
826 offset,
827 check_inlines,
828 skip_prologue,
829 internal,
830 hardware,
831 move_to_nearest_code);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000832 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000833
834 if (log)
835 {
836 SBStream sstr;
837 sb_bp.GetDescription (sstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000838 char path[PATH_MAX];
839 sb_file_spec->GetPath (path, sizeof(path));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000840 log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s",
841 static_cast<void*>(target_sp.get()), path, line,
842 static_cast<void*>(sb_bp.get()), sstr.GetData());
Caroline Ticeceb6b132010-10-26 03:11:13 +0000843 }
844
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000845 return sb_bp;
846}
847
848SBBreakpoint
Greg Claytoneb023e72013-10-11 19:48:25 +0000849SBTarget::BreakpointCreateByName (const char *symbol_name,
850 const char *module_name)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000851{
Greg Clayton5160ce52013-03-27 23:08:40 +0000852 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000853
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000854 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +0000855 TargetSP target_sp(GetSP());
856 if (target_sp.get())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000857 {
Greg Claytonacdbe812012-01-30 09:04:36 +0000858 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000859
Jim Inghama8558b62012-05-22 00:12:20 +0000860 const bool internal = false;
Greg Claytoneb023e72013-10-11 19:48:25 +0000861 const bool hardware = false;
Jim Inghama8558b62012-05-22 00:12:20 +0000862 const LazyBool skip_prologue = eLazyBoolCalculate;
Jim Ingham24111672016-03-09 18:59:13 +0000863 const lldb::addr_t offset = 0;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000864 if (module_name && module_name[0])
865 {
Jim Ingham969795f2011-09-21 01:17:13 +0000866 FileSpecList module_spec_list;
867 module_spec_list.Append (FileSpec (module_name, false));
Jim Ingham24111672016-03-09 18:59:13 +0000868 *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000869 }
870 else
871 {
Jim Ingham24111672016-03-09 18:59:13 +0000872 *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000873 }
874 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000875
Caroline Ticeceb6b132010-10-26 03:11:13 +0000876 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000877 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)",
878 static_cast<void*>(target_sp.get()), symbol_name,
879 module_name, static_cast<void*>(sb_bp.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000880
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000881 return sb_bp;
882}
883
Jim Ingham87df91b2011-09-23 00:54:11 +0000884lldb::SBBreakpoint
885SBTarget::BreakpointCreateByName (const char *symbol_name,
Greg Claytoneb023e72013-10-11 19:48:25 +0000886 const SBFileSpecList &module_list,
887 const SBFileSpecList &comp_unit_list)
Jim Ingham87df91b2011-09-23 00:54:11 +0000888{
Jim Ingham2dd7f7f2011-10-11 01:18:55 +0000889 uint32_t name_type_mask = eFunctionNameTypeAuto;
Jim Ingham0fcdac32015-11-06 22:48:59 +0000890 return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
Jim Ingham2dd7f7f2011-10-11 01:18:55 +0000891}
892
893lldb::SBBreakpoint
894SBTarget::BreakpointCreateByName (const char *symbol_name,
Greg Claytoneb023e72013-10-11 19:48:25 +0000895 uint32_t name_type_mask,
896 const SBFileSpecList &module_list,
897 const SBFileSpecList &comp_unit_list)
Jim Ingham2dd7f7f2011-10-11 01:18:55 +0000898{
Jim Ingham0fcdac32015-11-06 22:48:59 +0000899 return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
900}
901
902lldb::SBBreakpoint
903SBTarget::BreakpointCreateByName (const char *symbol_name,
904 uint32_t name_type_mask,
905 LanguageType symbol_language,
906 const SBFileSpecList &module_list,
907 const SBFileSpecList &comp_unit_list)
908{
Greg Clayton5160ce52013-03-27 23:08:40 +0000909 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham87df91b2011-09-23 00:54:11 +0000910
911 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +0000912 TargetSP target_sp(GetSP());
913 if (target_sp && symbol_name && symbol_name[0])
Jim Ingham87df91b2011-09-23 00:54:11 +0000914 {
Jim Inghama8558b62012-05-22 00:12:20 +0000915 const bool internal = false;
Greg Claytoneb023e72013-10-11 19:48:25 +0000916 const bool hardware = false;
Jim Inghama8558b62012-05-22 00:12:20 +0000917 const LazyBool skip_prologue = eLazyBoolCalculate;
Greg Claytonacdbe812012-01-30 09:04:36 +0000918 Mutex::Locker api_locker (target_sp->GetAPIMutex());
919 *sb_bp = target_sp->CreateBreakpoint (module_list.get(),
Greg Claytoneb023e72013-10-11 19:48:25 +0000920 comp_unit_list.get(),
921 symbol_name,
922 name_type_mask,
Jim Ingham0fcdac32015-11-06 22:48:59 +0000923 symbol_language,
Jim Ingham24111672016-03-09 18:59:13 +0000924 0,
Greg Claytoneb023e72013-10-11 19:48:25 +0000925 skip_prologue,
926 internal,
927 hardware);
Jim Ingham87df91b2011-09-23 00:54:11 +0000928 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000929
Jim Ingham87df91b2011-09-23 00:54:11 +0000930 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000931 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)",
932 static_cast<void*>(target_sp.get()), symbol_name,
933 name_type_mask, static_cast<void*>(sb_bp.get()));
Jim Ingham87df91b2011-09-23 00:54:11 +0000934
935 return sb_bp;
936}
937
Jim Inghamfab10e82012-03-06 00:37:27 +0000938lldb::SBBreakpoint
939SBTarget::BreakpointCreateByNames (const char *symbol_names[],
940 uint32_t num_names,
941 uint32_t name_type_mask,
942 const SBFileSpecList &module_list,
943 const SBFileSpecList &comp_unit_list)
944{
Jim Ingham0fcdac32015-11-06 22:48:59 +0000945 return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
946}
947
948lldb::SBBreakpoint
949SBTarget::BreakpointCreateByNames (const char *symbol_names[],
950 uint32_t num_names,
951 uint32_t name_type_mask,
952 LanguageType symbol_language,
953 const SBFileSpecList &module_list,
954 const SBFileSpecList &comp_unit_list)
955{
Jim Ingham24111672016-03-09 18:59:13 +0000956 return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, module_list, comp_unit_list);
957}
958
959lldb::SBBreakpoint
960SBTarget::BreakpointCreateByNames (const char *symbol_names[],
961 uint32_t num_names,
962 uint32_t name_type_mask,
963 LanguageType symbol_language,
964 lldb::addr_t offset,
965 const SBFileSpecList &module_list,
966 const SBFileSpecList &comp_unit_list)
967{
Greg Clayton5160ce52013-03-27 23:08:40 +0000968 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Inghamfab10e82012-03-06 00:37:27 +0000969
970 SBBreakpoint sb_bp;
971 TargetSP target_sp(GetSP());
972 if (target_sp && num_names > 0)
973 {
974 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Jim Inghama8558b62012-05-22 00:12:20 +0000975 const bool internal = false;
Greg Claytoneb023e72013-10-11 19:48:25 +0000976 const bool hardware = false;
Jim Inghama8558b62012-05-22 00:12:20 +0000977 const LazyBool skip_prologue = eLazyBoolCalculate;
Jim Inghamfab10e82012-03-06 00:37:27 +0000978 *sb_bp = target_sp->CreateBreakpoint (module_list.get(),
Jim Ingham0fcdac32015-11-06 22:48:59 +0000979 comp_unit_list.get(),
980 symbol_names,
981 num_names,
Jim Ingham24111672016-03-09 18:59:13 +0000982 name_type_mask,
Jim Ingham0fcdac32015-11-06 22:48:59 +0000983 symbol_language,
Jim Ingham24111672016-03-09 18:59:13 +0000984 offset,
Jim Ingham0fcdac32015-11-06 22:48:59 +0000985 skip_prologue,
986 internal,
987 hardware);
Jim Inghamfab10e82012-03-06 00:37:27 +0000988 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000989
Jim Inghamfab10e82012-03-06 00:37:27 +0000990 if (log)
991 {
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000992 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbols={",
993 static_cast<void*>(target_sp.get()));
Jim Inghamfab10e82012-03-06 00:37:27 +0000994 for (uint32_t i = 0 ; i < num_names; i++)
995 {
996 char sep;
997 if (i < num_names - 1)
998 sep = ',';
999 else
1000 sep = '}';
1001 if (symbol_names[i] != NULL)
1002 log->Printf ("\"%s\"%c ", symbol_names[i], sep);
1003 else
1004 log->Printf ("\"<NULL>\"%c ", sep);
Jim Inghamfab10e82012-03-06 00:37:27 +00001005 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001006 log->Printf ("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
1007 static_cast<void*>(sb_bp.get()));
Jim Inghamfab10e82012-03-06 00:37:27 +00001008 }
1009
1010 return sb_bp;
1011}
Jim Ingham87df91b2011-09-23 00:54:11 +00001012
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001013SBBreakpoint
Greg Claytoneb023e72013-10-11 19:48:25 +00001014SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
1015 const char *module_name)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001016{
Jim Ingham0fcdac32015-11-06 22:48:59 +00001017 SBFileSpecList module_spec_list;
1018 SBFileSpecList comp_unit_list;
1019 if (module_name && module_name[0])
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001020 {
Jim Ingham0fcdac32015-11-06 22:48:59 +00001021 module_spec_list.Append (FileSpec (module_name, false));
1022
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001023 }
Jim Ingham0fcdac32015-11-06 22:48:59 +00001024 return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_spec_list, comp_unit_list);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001025}
1026
Jim Ingham87df91b2011-09-23 00:54:11 +00001027lldb::SBBreakpoint
1028SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
Greg Claytoneb023e72013-10-11 19:48:25 +00001029 const SBFileSpecList &module_list,
1030 const SBFileSpecList &comp_unit_list)
Jim Ingham87df91b2011-09-23 00:54:11 +00001031{
Jim Ingham0fcdac32015-11-06 22:48:59 +00001032 return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list);
1033}
1034
1035lldb::SBBreakpoint
1036SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
1037 LanguageType symbol_language,
1038 const SBFileSpecList &module_list,
1039 const SBFileSpecList &comp_unit_list)
1040{
Greg Clayton5160ce52013-03-27 23:08:40 +00001041 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001042
Jim Ingham87df91b2011-09-23 00:54:11 +00001043 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +00001044 TargetSP target_sp(GetSP());
1045 if (target_sp && symbol_name_regex && symbol_name_regex[0])
Jim Ingham87df91b2011-09-23 00:54:11 +00001046 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001047 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Jim Ingham87df91b2011-09-23 00:54:11 +00001048 RegularExpression regexp(symbol_name_regex);
Jim Inghama8558b62012-05-22 00:12:20 +00001049 const bool internal = false;
Greg Claytoneb023e72013-10-11 19:48:25 +00001050 const bool hardware = false;
Jim Inghama8558b62012-05-22 00:12:20 +00001051 const LazyBool skip_prologue = eLazyBoolCalculate;
Jim Ingham0fcdac32015-11-06 22:48:59 +00001052
1053 *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, symbol_language, skip_prologue, internal, hardware);
Jim Ingham87df91b2011-09-23 00:54:11 +00001054 }
1055
1056 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001057 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
1058 static_cast<void*>(target_sp.get()), symbol_name_regex,
1059 static_cast<void*>(sb_bp.get()));
Jim Ingham87df91b2011-09-23 00:54:11 +00001060
1061 return sb_bp;
1062}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001063
1064SBBreakpoint
1065SBTarget::BreakpointCreateByAddress (addr_t address)
1066{
Greg Clayton5160ce52013-03-27 23:08:40 +00001067 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001068
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001069 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +00001070 TargetSP target_sp(GetSP());
1071 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001072 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001073 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Claytoneb023e72013-10-11 19:48:25 +00001074 const bool hardware = false;
1075 *sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
Greg Claytonaf67cec2010-12-20 20:49:23 +00001076 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001077
Caroline Ticeceb6b132010-10-26 03:11:13 +00001078 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001079 log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)",
1080 static_cast<void*>(target_sp.get()),
1081 static_cast<uint64_t>(address),
1082 static_cast<void*>(sb_bp.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001083
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001084 return sb_bp;
1085}
1086
Jim Ingham055a08a2015-11-17 03:39:13 +00001087SBBreakpoint
1088SBTarget::BreakpointCreateBySBAddress (SBAddress &sb_address)
1089{
1090 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1091
1092 SBBreakpoint sb_bp;
1093 TargetSP target_sp(GetSP());
1094 if (!sb_address.IsValid())
1095 {
1096 if (log)
1097 log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress called with invalid address",
1098 static_cast<void*>(target_sp.get()));
1099 return sb_bp;
1100 }
1101
1102 if (target_sp)
1103 {
1104 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1105 const bool hardware = false;
1106 *sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware);
1107 }
1108
1109 if (log)
1110 {
1111 SBStream s;
1112 sb_address.GetDescription(s);
1113 log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => SBBreakpoint(%p)",
1114 static_cast<void*>(target_sp.get()),
1115 s.GetData(),
1116 static_cast<void*>(sb_bp.get()));
1117 }
1118
1119 return sb_bp;
1120}
1121
Jim Ingham969795f2011-09-21 01:17:13 +00001122lldb::SBBreakpoint
Greg Claytoneb023e72013-10-11 19:48:25 +00001123SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
1124 const lldb::SBFileSpec &source_file,
1125 const char *module_name)
Jim Ingham969795f2011-09-21 01:17:13 +00001126{
Greg Clayton5160ce52013-03-27 23:08:40 +00001127 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham969795f2011-09-21 01:17:13 +00001128
1129 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +00001130 TargetSP target_sp(GetSP());
1131 if (target_sp && source_regex && source_regex[0])
Jim Ingham969795f2011-09-21 01:17:13 +00001132 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001133 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Jim Ingham969795f2011-09-21 01:17:13 +00001134 RegularExpression regexp(source_regex);
Jim Ingham87df91b2011-09-23 00:54:11 +00001135 FileSpecList source_file_spec_list;
Greg Claytoneb023e72013-10-11 19:48:25 +00001136 const bool hardware = false;
Ilia K055ad9b2015-05-18 13:41:01 +00001137 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
Jim Ingham87df91b2011-09-23 00:54:11 +00001138 source_file_spec_list.Append (source_file.ref());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001139
Jim Ingham969795f2011-09-21 01:17:13 +00001140 if (module_name && module_name[0])
1141 {
1142 FileSpecList module_spec_list;
1143 module_spec_list.Append (FileSpec (module_name, false));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001144
Ilia K055ad9b2015-05-18 13:41:01 +00001145 *sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false, hardware, move_to_nearest_code);
Jim Ingham969795f2011-09-21 01:17:13 +00001146 }
1147 else
1148 {
Ilia K055ad9b2015-05-18 13:41:01 +00001149 *sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false, hardware, move_to_nearest_code);
Jim Ingham969795f2011-09-21 01:17:13 +00001150 }
1151 }
1152
1153 if (log)
1154 {
1155 char path[PATH_MAX];
1156 source_file->GetPath (path, sizeof(path));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001157 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
1158 static_cast<void*>(target_sp.get()), source_regex, path,
1159 module_name, static_cast<void*>(sb_bp.get()));
Jim Ingham969795f2011-09-21 01:17:13 +00001160 }
1161
1162 return sb_bp;
1163}
1164
Jim Ingham87df91b2011-09-23 00:54:11 +00001165lldb::SBBreakpoint
Jim Inghame7320522015-02-12 17:37:46 +00001166SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
1167 const SBFileSpecList &module_list,
1168 const lldb::SBFileSpecList &source_file_list)
Jim Ingham87df91b2011-09-23 00:54:11 +00001169{
Greg Clayton5160ce52013-03-27 23:08:40 +00001170 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham87df91b2011-09-23 00:54:11 +00001171
1172 SBBreakpoint sb_bp;
Greg Claytonacdbe812012-01-30 09:04:36 +00001173 TargetSP target_sp(GetSP());
1174 if (target_sp && source_regex && source_regex[0])
Jim Ingham87df91b2011-09-23 00:54:11 +00001175 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001176 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Claytoneb023e72013-10-11 19:48:25 +00001177 const bool hardware = false;
Ilia K055ad9b2015-05-18 13:41:01 +00001178 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
Jim Ingham87df91b2011-09-23 00:54:11 +00001179 RegularExpression regexp(source_regex);
Ilia K055ad9b2015-05-18 13:41:01 +00001180 *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false, hardware, move_to_nearest_code);
Jim Ingham87df91b2011-09-23 00:54:11 +00001181 }
1182
1183 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001184 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)",
1185 static_cast<void*>(target_sp.get()), source_regex,
1186 static_cast<void*>(sb_bp.get()));
Jim Ingham87df91b2011-09-23 00:54:11 +00001187
1188 return sb_bp;
1189}
Jim Ingham969795f2011-09-21 01:17:13 +00001190
Jim Inghamfab10e82012-03-06 00:37:27 +00001191lldb::SBBreakpoint
1192SBTarget::BreakpointCreateForException (lldb::LanguageType language,
Greg Claytoneb023e72013-10-11 19:48:25 +00001193 bool catch_bp,
1194 bool throw_bp)
Jim Inghamfab10e82012-03-06 00:37:27 +00001195{
Greg Clayton5160ce52013-03-27 23:08:40 +00001196 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Inghamfab10e82012-03-06 00:37:27 +00001197
1198 SBBreakpoint sb_bp;
1199 TargetSP target_sp(GetSP());
1200 if (target_sp)
1201 {
1202 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Claytoneb023e72013-10-11 19:48:25 +00001203 const bool hardware = false;
1204 *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware);
Jim Inghamfab10e82012-03-06 00:37:27 +00001205 }
1206
1207 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001208 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)",
1209 static_cast<void*>(target_sp.get()),
Jim Ingham0e0984e2015-09-02 01:06:46 +00001210 Language::GetNameForLanguageType(language),
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001211 catch_bp ? "on" : "off", throw_bp ? "on" : "off",
1212 static_cast<void*>(sb_bp.get()));
Jim Inghamfab10e82012-03-06 00:37:27 +00001213
1214 return sb_bp;
1215}
1216
Greg Clayton9fed0d82010-07-23 23:33:17 +00001217uint32_t
1218SBTarget::GetNumBreakpoints () const
1219{
Greg Claytonacdbe812012-01-30 09:04:36 +00001220 TargetSP target_sp(GetSP());
1221 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001222 {
1223 // The breakpoint list is thread safe, no need to lock
Greg Claytonacdbe812012-01-30 09:04:36 +00001224 return target_sp->GetBreakpointList().GetSize();
Greg Claytonaf67cec2010-12-20 20:49:23 +00001225 }
Greg Clayton9fed0d82010-07-23 23:33:17 +00001226 return 0;
1227}
1228
1229SBBreakpoint
1230SBTarget::GetBreakpointAtIndex (uint32_t idx) const
1231{
1232 SBBreakpoint sb_breakpoint;
Greg Claytonacdbe812012-01-30 09:04:36 +00001233 TargetSP target_sp(GetSP());
1234 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001235 {
1236 // The breakpoint list is thread safe, no need to lock
Greg Claytonacdbe812012-01-30 09:04:36 +00001237 *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
Greg Claytonaf67cec2010-12-20 20:49:23 +00001238 }
Greg Clayton9fed0d82010-07-23 23:33:17 +00001239 return sb_breakpoint;
1240}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001241
1242bool
1243SBTarget::BreakpointDelete (break_id_t bp_id)
1244{
Greg Clayton5160ce52013-03-27 23:08:40 +00001245 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001246
Caroline Ticeceb6b132010-10-26 03:11:13 +00001247 bool result = false;
Greg Claytonacdbe812012-01-30 09:04:36 +00001248 TargetSP target_sp(GetSP());
1249 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001250 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001251 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1252 result = target_sp->RemoveBreakpointByID (bp_id);
Greg Claytonaf67cec2010-12-20 20:49:23 +00001253 }
Caroline Ticeceb6b132010-10-26 03:11:13 +00001254
1255 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001256 log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
1257 static_cast<void*>(target_sp.get()),
1258 static_cast<uint32_t>(bp_id), result);
Caroline Ticeceb6b132010-10-26 03:11:13 +00001259
1260 return result;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001261}
1262
Johnny Chen5d043462011-09-26 22:40:50 +00001263SBBreakpoint
1264SBTarget::FindBreakpointByID (break_id_t bp_id)
1265{
Greg Clayton5160ce52013-03-27 23:08:40 +00001266 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Johnny Chen5d043462011-09-26 22:40:50 +00001267
1268 SBBreakpoint sb_breakpoint;
Greg Claytonacdbe812012-01-30 09:04:36 +00001269 TargetSP target_sp(GetSP());
1270 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID)
Johnny Chen5d043462011-09-26 22:40:50 +00001271 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001272 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1273 *sb_breakpoint = target_sp->GetBreakpointByID (bp_id);
Johnny Chen5d043462011-09-26 22:40:50 +00001274 }
1275
1276 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001277 log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
1278 static_cast<void*>(target_sp.get()),
1279 static_cast<uint32_t>(bp_id),
1280 static_cast<void*>(sb_breakpoint.get()));
Johnny Chen5d043462011-09-26 22:40:50 +00001281
1282 return sb_breakpoint;
1283}
1284
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001285bool
1286SBTarget::EnableAllBreakpoints ()
1287{
Greg Claytonacdbe812012-01-30 09:04:36 +00001288 TargetSP target_sp(GetSP());
1289 if (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001290 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001291 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1292 target_sp->EnableAllBreakpoints ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001293 return true;
1294 }
1295 return false;
1296}
1297
1298bool
1299SBTarget::DisableAllBreakpoints ()
1300{
Greg Claytonacdbe812012-01-30 09:04:36 +00001301 TargetSP target_sp(GetSP());
1302 if (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001303 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001304 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1305 target_sp->DisableAllBreakpoints ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001306 return true;
1307 }
1308 return false;
1309}
1310
1311bool
1312SBTarget::DeleteAllBreakpoints ()
1313{
Greg Claytonacdbe812012-01-30 09:04:36 +00001314 TargetSP target_sp(GetSP());
1315 if (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001316 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001317 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1318 target_sp->RemoveAllBreakpoints ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001319 return true;
1320 }
1321 return false;
1322}
1323
Johnny Chen5d043462011-09-26 22:40:50 +00001324uint32_t
Greg Clayton1b282f92011-10-13 18:08:26 +00001325SBTarget::GetNumWatchpoints () const
Johnny Chen5d043462011-09-26 22:40:50 +00001326{
Greg Claytonacdbe812012-01-30 09:04:36 +00001327 TargetSP target_sp(GetSP());
1328 if (target_sp)
Johnny Chen5d043462011-09-26 22:40:50 +00001329 {
Johnny Chen01a67862011-10-14 00:42:25 +00001330 // The watchpoint list is thread safe, no need to lock
Greg Claytonacdbe812012-01-30 09:04:36 +00001331 return target_sp->GetWatchpointList().GetSize();
Johnny Chen5d043462011-09-26 22:40:50 +00001332 }
1333 return 0;
1334}
1335
Greg Clayton1b282f92011-10-13 18:08:26 +00001336SBWatchpoint
1337SBTarget::GetWatchpointAtIndex (uint32_t idx) const
Johnny Chen9d954d82011-09-27 20:29:45 +00001338{
Johnny Chen01a67862011-10-14 00:42:25 +00001339 SBWatchpoint sb_watchpoint;
Greg Claytonacdbe812012-01-30 09:04:36 +00001340 TargetSP target_sp(GetSP());
1341 if (target_sp)
Johnny Chen5d043462011-09-26 22:40:50 +00001342 {
Johnny Chen01a67862011-10-14 00:42:25 +00001343 // The watchpoint list is thread safe, no need to lock
Greg Clayton81e871e2012-02-04 02:27:34 +00001344 sb_watchpoint.SetSP (target_sp->GetWatchpointList().GetByIndex(idx));
Johnny Chen5d043462011-09-26 22:40:50 +00001345 }
Johnny Chen01a67862011-10-14 00:42:25 +00001346 return sb_watchpoint;
Johnny Chen5d043462011-09-26 22:40:50 +00001347}
1348
1349bool
Greg Clayton1b282f92011-10-13 18:08:26 +00001350SBTarget::DeleteWatchpoint (watch_id_t wp_id)
Johnny Chen5d043462011-09-26 22:40:50 +00001351{
Greg Clayton5160ce52013-03-27 23:08:40 +00001352 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Johnny Chen5d043462011-09-26 22:40:50 +00001353
1354 bool result = false;
Greg Claytonacdbe812012-01-30 09:04:36 +00001355 TargetSP target_sp(GetSP());
1356 if (target_sp)
Johnny Chen5d043462011-09-26 22:40:50 +00001357 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001358 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Johnny Chen7385a5a2012-05-31 22:56:36 +00001359 Mutex::Locker locker;
1360 target_sp->GetWatchpointList().GetListMutex(locker);
Greg Claytonacdbe812012-01-30 09:04:36 +00001361 result = target_sp->RemoveWatchpointByID (wp_id);
Johnny Chen5d043462011-09-26 22:40:50 +00001362 }
1363
1364 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001365 log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
1366 static_cast<void*>(target_sp.get()),
1367 static_cast<uint32_t>(wp_id), result);
Johnny Chen5d043462011-09-26 22:40:50 +00001368
1369 return result;
1370}
1371
Greg Clayton1b282f92011-10-13 18:08:26 +00001372SBWatchpoint
1373SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
Johnny Chen5d043462011-09-26 22:40:50 +00001374{
Greg Clayton5160ce52013-03-27 23:08:40 +00001375 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Johnny Chen5d043462011-09-26 22:40:50 +00001376
Greg Clayton1b282f92011-10-13 18:08:26 +00001377 SBWatchpoint sb_watchpoint;
Greg Clayton81e871e2012-02-04 02:27:34 +00001378 lldb::WatchpointSP watchpoint_sp;
Greg Claytonacdbe812012-01-30 09:04:36 +00001379 TargetSP target_sp(GetSP());
1380 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
Johnny Chen5d043462011-09-26 22:40:50 +00001381 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001382 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Johnny Chen7385a5a2012-05-31 22:56:36 +00001383 Mutex::Locker locker;
1384 target_sp->GetWatchpointList().GetListMutex(locker);
Greg Clayton81e871e2012-02-04 02:27:34 +00001385 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1386 sb_watchpoint.SetSP (watchpoint_sp);
Johnny Chen5d043462011-09-26 22:40:50 +00001387 }
1388
1389 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001390 log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
1391 static_cast<void*>(target_sp.get()),
1392 static_cast<uint32_t>(wp_id),
1393 static_cast<void*>(watchpoint_sp.get()));
Johnny Chen5d043462011-09-26 22:40:50 +00001394
Greg Clayton1b282f92011-10-13 18:08:26 +00001395 return sb_watchpoint;
1396}
1397
1398lldb::SBWatchpoint
Johnny Chenb90827e2012-06-04 23:19:54 +00001399SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
Greg Clayton1b282f92011-10-13 18:08:26 +00001400{
Greg Clayton5160ce52013-03-27 23:08:40 +00001401 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001402
Greg Clayton1b282f92011-10-13 18:08:26 +00001403 SBWatchpoint sb_watchpoint;
Greg Clayton81e871e2012-02-04 02:27:34 +00001404 lldb::WatchpointSP watchpoint_sp;
Greg Claytonacdbe812012-01-30 09:04:36 +00001405 TargetSP target_sp(GetSP());
Greg Clayton81e871e2012-02-04 02:27:34 +00001406 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0)
Greg Clayton1b282f92011-10-13 18:08:26 +00001407 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001408 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Greg Clayton81e871e2012-02-04 02:27:34 +00001409 uint32_t watch_type = 0;
1410 if (read)
1411 watch_type |= LLDB_WATCH_TYPE_READ;
1412 if (write)
1413 watch_type |= LLDB_WATCH_TYPE_WRITE;
Jim Inghamc6462312013-06-18 21:52:48 +00001414 if (watch_type == 0)
1415 {
1416 error.SetErrorString("Can't create a watchpoint that is neither read nor write.");
1417 return sb_watchpoint;
1418 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001419
Johnny Chen7385a5a2012-05-31 22:56:36 +00001420 // Target::CreateWatchpoint() is thread safe.
Johnny Chenb90827e2012-06-04 23:19:54 +00001421 Error cw_error;
Jim Inghama7dfb662012-10-23 07:20:06 +00001422 // This API doesn't take in a type, so we can't figure out what it is.
Greg Claytona1e5dc82015-08-11 22:53:00 +00001423 CompilerType *type = NULL;
Jim Inghama7dfb662012-10-23 07:20:06 +00001424 watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
Johnny Chenb90827e2012-06-04 23:19:54 +00001425 error.SetError(cw_error);
Greg Clayton81e871e2012-02-04 02:27:34 +00001426 sb_watchpoint.SetSP (watchpoint_sp);
Greg Clayton1b282f92011-10-13 18:08:26 +00001427 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001428
Greg Clayton1b282f92011-10-13 18:08:26 +00001429 if (log)
Daniel Malead01b2952012-11-29 21:49:15 +00001430 log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64 ", 0x%u) => SBWatchpoint(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001431 static_cast<void*>(target_sp.get()), addr,
1432 static_cast<uint32_t>(size),
1433 static_cast<void*>(watchpoint_sp.get()));
1434
Greg Clayton1b282f92011-10-13 18:08:26 +00001435 return sb_watchpoint;
Johnny Chen5d043462011-09-26 22:40:50 +00001436}
1437
1438bool
Greg Clayton1b282f92011-10-13 18:08:26 +00001439SBTarget::EnableAllWatchpoints ()
Johnny Chen5d043462011-09-26 22:40:50 +00001440{
Greg Claytonacdbe812012-01-30 09:04:36 +00001441 TargetSP target_sp(GetSP());
1442 if (target_sp)
Johnny Chen5d043462011-09-26 22:40:50 +00001443 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001444 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Johnny Chen7385a5a2012-05-31 22:56:36 +00001445 Mutex::Locker locker;
1446 target_sp->GetWatchpointList().GetListMutex(locker);
Greg Claytonacdbe812012-01-30 09:04:36 +00001447 target_sp->EnableAllWatchpoints ();
Johnny Chen5d043462011-09-26 22:40:50 +00001448 return true;
1449 }
1450 return false;
1451}
1452
1453bool
Greg Clayton1b282f92011-10-13 18:08:26 +00001454SBTarget::DisableAllWatchpoints ()
Johnny Chen5d043462011-09-26 22:40:50 +00001455{
Greg Claytonacdbe812012-01-30 09:04:36 +00001456 TargetSP target_sp(GetSP());
1457 if (target_sp)
Johnny Chen5d043462011-09-26 22:40:50 +00001458 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001459 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Johnny Chen7385a5a2012-05-31 22:56:36 +00001460 Mutex::Locker locker;
1461 target_sp->GetWatchpointList().GetListMutex(locker);
Greg Claytonacdbe812012-01-30 09:04:36 +00001462 target_sp->DisableAllWatchpoints ();
Johnny Chen5d043462011-09-26 22:40:50 +00001463 return true;
1464 }
1465 return false;
1466}
1467
Enrico Granata347c2aa2013-10-08 21:49:02 +00001468SBValue
1469SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
1470{
1471 SBValue sb_value;
1472 lldb::ValueObjectSP new_value_sp;
1473 if (IsValid() && name && *name && addr.IsValid() && type.IsValid())
1474 {
Enrico Granata972be532014-12-17 21:18:43 +00001475 lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1476 ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
Greg Claytona1e5dc82015-08-11 22:53:00 +00001477 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
Enrico Granata972be532014-12-17 21:18:43 +00001478 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, exe_ctx, ast_type);
Enrico Granata347c2aa2013-10-08 21:49:02 +00001479 }
1480 sb_value.SetSP(new_value_sp);
1481 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1482 if (log)
1483 {
1484 if (new_value_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001485 log->Printf ("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
1486 static_cast<void*>(m_opaque_sp.get()),
1487 new_value_sp->GetName().AsCString());
Enrico Granata347c2aa2013-10-08 21:49:02 +00001488 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001489 log->Printf ("SBTarget(%p)::CreateValueFromAddress => NULL",
1490 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata347c2aa2013-10-08 21:49:02 +00001491 }
1492 return sb_value;
1493}
1494
Enrico Granata972be532014-12-17 21:18:43 +00001495lldb::SBValue
1496SBTarget::CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type)
1497{
1498 SBValue sb_value;
1499 lldb::ValueObjectSP new_value_sp;
1500 if (IsValid() && name && *name && data.IsValid() && type.IsValid())
1501 {
1502 DataExtractorSP extractor(*data);
1503 ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
Greg Claytona1e5dc82015-08-11 22:53:00 +00001504 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
Enrico Granata972be532014-12-17 21:18:43 +00001505 new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, exe_ctx, ast_type);
1506 }
1507 sb_value.SetSP(new_value_sp);
1508 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1509 if (log)
1510 {
1511 if (new_value_sp)
1512 log->Printf ("SBTarget(%p)::CreateValueFromData => \"%s\"",
1513 static_cast<void*>(m_opaque_sp.get()),
1514 new_value_sp->GetName().AsCString());
1515 else
1516 log->Printf ("SBTarget(%p)::CreateValueFromData => NULL",
1517 static_cast<void*>(m_opaque_sp.get()));
1518 }
1519 return sb_value;
1520}
1521
1522lldb::SBValue
1523SBTarget::CreateValueFromExpression (const char *name, const char* expr)
1524{
1525 SBValue sb_value;
1526 lldb::ValueObjectSP new_value_sp;
1527 if (IsValid() && name && *name && expr && *expr)
1528 {
1529 ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
1530 new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1531 }
1532 sb_value.SetSP(new_value_sp);
1533 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1534 if (log)
1535 {
1536 if (new_value_sp)
1537 log->Printf ("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
1538 static_cast<void*>(m_opaque_sp.get()),
1539 new_value_sp->GetName().AsCString());
1540 else
1541 log->Printf ("SBTarget(%p)::CreateValueFromExpression => NULL",
1542 static_cast<void*>(m_opaque_sp.get()));
1543 }
1544 return sb_value;
1545}
1546
Johnny Chen5d043462011-09-26 22:40:50 +00001547bool
Greg Clayton1b282f92011-10-13 18:08:26 +00001548SBTarget::DeleteAllWatchpoints ()
Johnny Chen5d043462011-09-26 22:40:50 +00001549{
Greg Claytonacdbe812012-01-30 09:04:36 +00001550 TargetSP target_sp(GetSP());
1551 if (target_sp)
Johnny Chen5d043462011-09-26 22:40:50 +00001552 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001553 Mutex::Locker api_locker (target_sp->GetAPIMutex());
Johnny Chen7385a5a2012-05-31 22:56:36 +00001554 Mutex::Locker locker;
1555 target_sp->GetWatchpointList().GetListMutex(locker);
Greg Claytonacdbe812012-01-30 09:04:36 +00001556 target_sp->RemoveAllWatchpoints ();
Johnny Chen5d043462011-09-26 22:40:50 +00001557 return true;
1558 }
1559 return false;
1560}
1561
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001562
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001563lldb::SBModule
1564SBTarget::AddModule (const char *path,
1565 const char *triple,
1566 const char *uuid_cstr)
1567{
Greg Claytonb210aec2012-04-23 20:23:39 +00001568 return AddModule (path, triple, uuid_cstr, NULL);
1569}
1570
1571lldb::SBModule
1572SBTarget::AddModule (const char *path,
1573 const char *triple,
1574 const char *uuid_cstr,
1575 const char *symfile)
1576{
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001577 lldb::SBModule sb_module;
Greg Claytonacdbe812012-01-30 09:04:36 +00001578 TargetSP target_sp(GetSP());
1579 if (target_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001580 {
Greg Claytonb9a01b32012-02-26 05:51:37 +00001581 ModuleSpec module_spec;
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001582 if (path)
Greg Claytonb9a01b32012-02-26 05:51:37 +00001583 module_spec.GetFileSpec().SetFile(path, false);
Greg Claytonb210aec2012-04-23 20:23:39 +00001584
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001585 if (uuid_cstr)
Greg Claytonb5f0fea2012-09-27 22:26:11 +00001586 module_spec.GetUUID().SetFromCString(uuid_cstr);
Greg Claytonb210aec2012-04-23 20:23:39 +00001587
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001588 if (triple)
Greg Claytonb9a01b32012-02-26 05:51:37 +00001589 module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get());
Jason Molendab019cd92013-09-11 21:25:46 +00001590 else
1591 module_spec.GetArchitecture() = target_sp->GetArchitecture();
Greg Claytonb210aec2012-04-23 20:23:39 +00001592
1593 if (symfile)
1594 module_spec.GetSymbolFileSpec ().SetFile(symfile, false);
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001595
Greg Claytonb9a01b32012-02-26 05:51:37 +00001596 sb_module.SetSP(target_sp->GetSharedModule (module_spec));
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001597 }
1598 return sb_module;
1599}
1600
Greg Clayton226cce22013-07-08 22:22:41 +00001601lldb::SBModule
1602SBTarget::AddModule (const SBModuleSpec &module_spec)
1603{
1604 lldb::SBModule sb_module;
1605 TargetSP target_sp(GetSP());
1606 if (target_sp)
1607 sb_module.SetSP(target_sp->GetSharedModule (*module_spec.m_opaque_ap));
1608 return sb_module;
1609}
1610
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001611bool
1612SBTarget::AddModule (lldb::SBModule &module)
1613{
Greg Claytonacdbe812012-01-30 09:04:36 +00001614 TargetSP target_sp(GetSP());
1615 if (target_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001616 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001617 target_sp->GetImages().AppendIfNeeded (module.GetSP());
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001618 return true;
1619 }
1620 return false;
1621}
1622
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001623uint32_t
1624SBTarget::GetNumModules () const
1625{
Greg Clayton5160ce52013-03-27 23:08:40 +00001626 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001627
Caroline Ticeceb6b132010-10-26 03:11:13 +00001628 uint32_t num = 0;
Greg Claytonacdbe812012-01-30 09:04:36 +00001629 TargetSP target_sp(GetSP());
1630 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001631 {
1632 // The module list is thread safe, no need to lock
Greg Claytonacdbe812012-01-30 09:04:36 +00001633 num = target_sp->GetImages().GetSize();
Greg Claytonaf67cec2010-12-20 20:49:23 +00001634 }
Caroline Ticeceb6b132010-10-26 03:11:13 +00001635
1636 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001637 log->Printf ("SBTarget(%p)::GetNumModules () => %d",
1638 static_cast<void*>(target_sp.get()), num);
Caroline Ticeceb6b132010-10-26 03:11:13 +00001639
1640 return num;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001641}
1642
Greg Clayton48e42542010-07-30 20:12:55 +00001643void
1644SBTarget::Clear ()
1645{
Greg Clayton5160ce52013-03-27 23:08:40 +00001646 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001647
1648 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001649 log->Printf ("SBTarget(%p)::Clear ()",
1650 static_cast<void*>(m_opaque_sp.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001651
Greg Clayton48e42542010-07-30 20:12:55 +00001652 m_opaque_sp.reset();
1653}
1654
1655
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001656SBModule
1657SBTarget::FindModule (const SBFileSpec &sb_file_spec)
1658{
1659 SBModule sb_module;
Greg Claytonacdbe812012-01-30 09:04:36 +00001660 TargetSP target_sp(GetSP());
1661 if (target_sp && sb_file_spec.IsValid())
Greg Claytonaf67cec2010-12-20 20:49:23 +00001662 {
Greg Claytonb9a01b32012-02-26 05:51:37 +00001663 ModuleSpec module_spec(*sb_file_spec);
Greg Claytonaf67cec2010-12-20 20:49:23 +00001664 // The module list is thread safe, no need to lock
Greg Claytonb9a01b32012-02-26 05:51:37 +00001665 sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec));
Greg Claytonaf67cec2010-12-20 20:49:23 +00001666 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001667 return sb_module;
1668}
1669
Greg Clayton13d19502012-01-29 06:07:39 +00001670lldb::ByteOrder
1671SBTarget::GetByteOrder ()
1672{
Greg Claytonacdbe812012-01-30 09:04:36 +00001673 TargetSP target_sp(GetSP());
1674 if (target_sp)
1675 return target_sp->GetArchitecture().GetByteOrder();
Greg Clayton13d19502012-01-29 06:07:39 +00001676 return eByteOrderInvalid;
1677}
1678
1679const char *
1680SBTarget::GetTriple ()
1681{
Greg Claytonacdbe812012-01-30 09:04:36 +00001682 TargetSP target_sp(GetSP());
1683 if (target_sp)
Greg Clayton13d19502012-01-29 06:07:39 +00001684 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001685 std::string triple (target_sp->GetArchitecture().GetTriple().str());
Greg Clayton13d19502012-01-29 06:07:39 +00001686 // Unique the string so we don't run into ownership issues since
1687 // the const strings put the string into the string pool once and
1688 // the strings never comes out
1689 ConstString const_triple (triple.c_str());
1690 return const_triple.GetCString();
1691 }
1692 return NULL;
1693}
1694
1695uint32_t
Matthew Gardinerc928de32014-10-22 07:22:56 +00001696SBTarget::GetDataByteSize ()
1697{
1698 TargetSP target_sp(GetSP());
1699 if (target_sp)
1700 {
1701 return target_sp->GetArchitecture().GetDataByteSize() ;
1702 }
1703 return 0;
1704}
1705
1706uint32_t
1707SBTarget::GetCodeByteSize ()
1708{
1709 TargetSP target_sp(GetSP());
1710 if (target_sp)
1711 {
1712 return target_sp->GetArchitecture().GetCodeByteSize() ;
1713 }
1714 return 0;
1715}
1716
1717uint32_t
Greg Clayton13d19502012-01-29 06:07:39 +00001718SBTarget::GetAddressByteSize()
1719{
Greg Claytonacdbe812012-01-30 09:04:36 +00001720 TargetSP target_sp(GetSP());
1721 if (target_sp)
1722 return target_sp->GetArchitecture().GetAddressByteSize();
Greg Clayton13d19502012-01-29 06:07:39 +00001723 return sizeof(void*);
1724}
1725
1726
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001727SBModule
1728SBTarget::GetModuleAtIndex (uint32_t idx)
1729{
Greg Clayton5160ce52013-03-27 23:08:40 +00001730 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001731
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001732 SBModule sb_module;
Greg Claytonacdbe812012-01-30 09:04:36 +00001733 ModuleSP module_sp;
1734 TargetSP target_sp(GetSP());
1735 if (target_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001736 {
1737 // The module list is thread safe, no need to lock
Greg Claytonacdbe812012-01-30 09:04:36 +00001738 module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
1739 sb_module.SetSP (module_sp);
Greg Claytonaf67cec2010-12-20 20:49:23 +00001740 }
Caroline Ticeceb6b132010-10-26 03:11:13 +00001741
1742 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001743 log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
1744 static_cast<void*>(target_sp.get()), idx,
1745 static_cast<void*>(module_sp.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001746
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001747 return sb_module;
1748}
1749
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001750bool
1751SBTarget::RemoveModule (lldb::SBModule module)
1752{
Greg Claytonacdbe812012-01-30 09:04:36 +00001753 TargetSP target_sp(GetSP());
1754 if (target_sp)
1755 return target_sp->GetImages().Remove(module.GetSP());
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001756 return false;
1757}
1758
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001759
1760SBBroadcaster
1761SBTarget::GetBroadcaster () const
1762{
Greg Clayton5160ce52013-03-27 23:08:40 +00001763 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001764
Greg Claytonacdbe812012-01-30 09:04:36 +00001765 TargetSP target_sp(GetSP());
1766 SBBroadcaster broadcaster(target_sp.get(), false);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001767
Caroline Ticeceb6b132010-10-26 03:11:13 +00001768 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001769 log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
1770 static_cast<void*>(target_sp.get()),
1771 static_cast<void*>(broadcaster.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001772
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001773 return broadcaster;
1774}
1775
Caroline Ticedde9cff2010-09-20 05:20:02 +00001776bool
Caroline Ticeceb6b132010-10-26 03:11:13 +00001777SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
Caroline Ticedde9cff2010-09-20 05:20:02 +00001778{
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001779 Stream &strm = description.ref();
1780
Greg Claytonacdbe812012-01-30 09:04:36 +00001781 TargetSP target_sp(GetSP());
1782 if (target_sp)
Caroline Tice201a8852010-09-20 16:21:41 +00001783 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001784 target_sp->Dump (&strm, description_level);
Caroline Ticeceb6b132010-10-26 03:11:13 +00001785 }
1786 else
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001787 strm.PutCString ("No value");
Caroline Ticeceb6b132010-10-26 03:11:13 +00001788
1789 return true;
1790}
1791
Greg Clayton5569e642012-02-06 01:44:54 +00001792lldb::SBSymbolContextList
1793SBTarget::FindFunctions (const char *name, uint32_t name_type_mask)
Greg Claytonfe356d32011-06-21 01:34:41 +00001794{
Greg Clayton5569e642012-02-06 01:44:54 +00001795 lldb::SBSymbolContextList sb_sc_list;
Greg Claytonacdbe812012-01-30 09:04:36 +00001796 if (name && name[0])
Greg Claytonfe356d32011-06-21 01:34:41 +00001797 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001798 TargetSP target_sp(GetSP());
1799 if (target_sp)
1800 {
1801 const bool symbols_ok = true;
Sean Callanan9df05fb2012-02-10 22:52:19 +00001802 const bool inlines_ok = true;
Greg Clayton5569e642012-02-06 01:44:54 +00001803 const bool append = true;
1804 target_sp->GetImages().FindFunctions (ConstString(name),
1805 name_type_mask,
Sean Callanan9df05fb2012-02-10 22:52:19 +00001806 symbols_ok,
1807 inlines_ok,
Greg Clayton5569e642012-02-06 01:44:54 +00001808 append,
1809 *sb_sc_list);
Greg Claytonacdbe812012-01-30 09:04:36 +00001810 }
Greg Claytonfe356d32011-06-21 01:34:41 +00001811 }
Greg Clayton5569e642012-02-06 01:44:54 +00001812 return sb_sc_list;
Greg Claytonfe356d32011-06-21 01:34:41 +00001813}
1814
Carlo Kok0fd6fd42014-09-19 19:38:19 +00001815lldb::SBSymbolContextList
1816SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
1817{
1818 lldb::SBSymbolContextList sb_sc_list;
1819 if (name && name[0])
1820 {
1821 TargetSP target_sp(GetSP());
1822 if (target_sp)
1823 {
1824 std::string regexstr;
1825 switch (matchtype)
1826 {
1827 case eMatchTypeRegex:
1828 target_sp->GetImages().FindFunctions(RegularExpression(name), true, true, true, *sb_sc_list);
1829 break;
1830 case eMatchTypeStartsWith:
1831 regexstr = llvm::Regex::escape(name) + ".*";
1832 target_sp->GetImages().FindFunctions(RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
1833 break;
1834 default:
1835 target_sp->GetImages().FindFunctions(ConstString(name), eFunctionNameTypeAny, true, true, true, *sb_sc_list);
1836 break;
1837 }
1838 }
1839 }
1840 return sb_sc_list;
1841}
1842
Enrico Granata6f3533f2011-07-29 19:53:35 +00001843lldb::SBType
Greg Claytonb43165b2012-12-05 21:24:42 +00001844SBTarget::FindFirstType (const char* typename_cstr)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001845{
Greg Claytonacdbe812012-01-30 09:04:36 +00001846 TargetSP target_sp(GetSP());
Greg Claytonb43165b2012-12-05 21:24:42 +00001847 if (typename_cstr && typename_cstr[0] && target_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001848 {
Greg Claytonb43165b2012-12-05 21:24:42 +00001849 ConstString const_typename(typename_cstr);
1850 SymbolContext sc;
1851 const bool exact_match = false;
1852
1853 const ModuleList &module_list = target_sp->GetImages();
1854 size_t count = module_list.GetSize();
Enrico Granata6f3533f2011-07-29 19:53:35 +00001855 for (size_t idx = 0; idx < count; idx++)
1856 {
Greg Claytonb43165b2012-12-05 21:24:42 +00001857 ModuleSP module_sp (module_list.GetModuleAtIndex(idx));
1858 if (module_sp)
1859 {
1860 TypeSP type_sp (module_sp->FindFirstType(sc, const_typename, exact_match));
1861 if (type_sp)
1862 return SBType(type_sp);
1863 }
Enrico Granata6f3533f2011-07-29 19:53:35 +00001864 }
Sean Callanan7be70e82012-12-19 23:05:01 +00001865
1866 // Didn't find the type in the symbols; try the Objective-C runtime
1867 // if one is installed
1868
1869 ProcessSP process_sp(target_sp->GetProcessSP());
1870
1871 if (process_sp)
1872 {
1873 ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
1874
1875 if (objc_language_runtime)
1876 {
Sean Callanan9998acd2014-12-05 01:21:59 +00001877 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
Sean Callanan7be70e82012-12-19 23:05:01 +00001878
Sean Callanan9998acd2014-12-05 01:21:59 +00001879 if (objc_decl_vendor)
Sean Callanan7be70e82012-12-19 23:05:01 +00001880 {
Sean Callanan9998acd2014-12-05 01:21:59 +00001881 std::vector <clang::NamedDecl *> decls;
Sean Callanan7be70e82012-12-19 23:05:01 +00001882
Sean Callanan9998acd2014-12-05 01:21:59 +00001883 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
1884 {
Greg Claytona1e5dc82015-08-11 22:53:00 +00001885 if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0]))
Sean Callanan9998acd2014-12-05 01:21:59 +00001886 {
1887 return SBType(type);
1888 }
1889 }
Sean Callanan7be70e82012-12-19 23:05:01 +00001890 }
1891 }
1892 }
Greg Claytonb43165b2012-12-05 21:24:42 +00001893
1894 // No matches, search for basic typename matches
1895 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1896 if (clang_ast)
Greg Clayton57ee3062013-07-11 22:46:58 +00001897 return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001898 }
1899 return SBType();
1900}
1901
Greg Claytonb43165b2012-12-05 21:24:42 +00001902SBType
1903SBTarget::GetBasicType(lldb::BasicType type)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001904{
Greg Claytonacdbe812012-01-30 09:04:36 +00001905 TargetSP target_sp(GetSP());
Greg Claytonb43165b2012-12-05 21:24:42 +00001906 if (target_sp)
1907 {
1908 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1909 if (clang_ast)
Greg Clayton57ee3062013-07-11 22:46:58 +00001910 return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), type));
Greg Claytonb43165b2012-12-05 21:24:42 +00001911 }
1912 return SBType();
1913}
1914
1915
1916lldb::SBTypeList
1917SBTarget::FindTypes (const char* typename_cstr)
1918{
1919 SBTypeList sb_type_list;
1920 TargetSP target_sp(GetSP());
1921 if (typename_cstr && typename_cstr[0] && target_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001922 {
Greg Claytonacdbe812012-01-30 09:04:36 +00001923 ModuleList& images = target_sp->GetImages();
Greg Claytonb43165b2012-12-05 21:24:42 +00001924 ConstString const_typename(typename_cstr);
Greg Clayton84db9102012-03-26 23:03:23 +00001925 bool exact_match = false;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001926 SymbolContext sc;
1927 TypeList type_list;
Greg Claytonae088e52016-02-10 21:28:13 +00001928 llvm::DenseSet<SymbolFile *> searched_symbol_files;
Greg Clayton29399a22012-04-06 17:41:13 +00001929 uint32_t num_matches = images.FindTypes (sc,
Greg Claytonb43165b2012-12-05 21:24:42 +00001930 const_typename,
Greg Clayton84db9102012-03-26 23:03:23 +00001931 exact_match,
1932 UINT32_MAX,
Greg Claytonae088e52016-02-10 21:28:13 +00001933 searched_symbol_files,
Greg Clayton84db9102012-03-26 23:03:23 +00001934 type_list);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001935
Greg Claytonb43165b2012-12-05 21:24:42 +00001936 if (num_matches > 0)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001937 {
Greg Claytonb43165b2012-12-05 21:24:42 +00001938 for (size_t idx = 0; idx < num_matches; idx++)
1939 {
1940 TypeSP type_sp (type_list.GetTypeAtIndex(idx));
1941 if (type_sp)
1942 sb_type_list.Append(SBType(type_sp));
1943 }
1944 }
Sean Callanan7be70e82012-12-19 23:05:01 +00001945
1946 // Try the Objective-C runtime if one is installed
1947
1948 ProcessSP process_sp(target_sp->GetProcessSP());
1949
1950 if (process_sp)
1951 {
1952 ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
1953
1954 if (objc_language_runtime)
1955 {
Sean Callanan9998acd2014-12-05 01:21:59 +00001956 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
Sean Callanan7be70e82012-12-19 23:05:01 +00001957
Sean Callanan9998acd2014-12-05 01:21:59 +00001958 if (objc_decl_vendor)
Sean Callanan7be70e82012-12-19 23:05:01 +00001959 {
Sean Callanan9998acd2014-12-05 01:21:59 +00001960 std::vector <clang::NamedDecl *> decls;
Sean Callanan7be70e82012-12-19 23:05:01 +00001961
Sean Callanan9998acd2014-12-05 01:21:59 +00001962 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
Sean Callanan7be70e82012-12-19 23:05:01 +00001963 {
Sean Callanan9998acd2014-12-05 01:21:59 +00001964 for (clang::NamedDecl *decl : decls)
Sean Callanan7be70e82012-12-19 23:05:01 +00001965 {
Greg Claytona1e5dc82015-08-11 22:53:00 +00001966 if (CompilerType type = ClangASTContext::GetTypeForDecl(decl))
Sean Callanan9998acd2014-12-05 01:21:59 +00001967 {
1968 sb_type_list.Append(SBType(type));
1969 }
Sean Callanan7be70e82012-12-19 23:05:01 +00001970 }
1971 }
1972 }
1973 }
1974 }
1975
1976 if (sb_type_list.GetSize() == 0)
Greg Claytonb43165b2012-12-05 21:24:42 +00001977 {
1978 // No matches, search for basic typename matches
1979 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1980 if (clang_ast)
Greg Clayton57ee3062013-07-11 22:46:58 +00001981 sb_type_list.Append (SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename)));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001982 }
1983 }
Greg Claytonb43165b2012-12-05 21:24:42 +00001984 return sb_type_list;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001985}
1986
Greg Claytondea8cb42011-06-29 22:09:02 +00001987SBValueList
1988SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
1989{
1990 SBValueList sb_value_list;
1991
Greg Claytonacdbe812012-01-30 09:04:36 +00001992 TargetSP target_sp(GetSP());
1993 if (name && target_sp)
Greg Claytondea8cb42011-06-29 22:09:02 +00001994 {
1995 VariableList variable_list;
1996 const bool append = true;
Greg Claytonacdbe812012-01-30 09:04:36 +00001997 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name),
1998 append,
1999 max_matches,
2000 variable_list);
Greg Claytondea8cb42011-06-29 22:09:02 +00002001
2002 if (match_count > 0)
2003 {
Greg Claytonacdbe812012-01-30 09:04:36 +00002004 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
Greg Claytondea8cb42011-06-29 22:09:02 +00002005 if (exe_scope == NULL)
Greg Claytonacdbe812012-01-30 09:04:36 +00002006 exe_scope = target_sp.get();
Greg Claytondea8cb42011-06-29 22:09:02 +00002007 for (uint32_t i=0; i<match_count; ++i)
2008 {
2009 lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
2010 if (valobj_sp)
Enrico Granata85425d72013-02-07 18:23:56 +00002011 sb_value_list.Append(SBValue(valobj_sp));
Greg Claytondea8cb42011-06-29 22:09:02 +00002012 }
2013 }
2014 }
2015
2016 return sb_value_list;
2017}
2018
Carlo Kok0fd6fd42014-09-19 19:38:19 +00002019SBValueList
2020SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype)
2021{
2022 SBValueList sb_value_list;
2023
2024 TargetSP target_sp(GetSP());
2025 if (name && target_sp)
2026 {
2027 VariableList variable_list;
2028 const bool append = true;
2029
2030 std::string regexstr;
2031 uint32_t match_count;
2032 switch (matchtype)
2033 {
2034 case eMatchTypeNormal:
2035 match_count = target_sp->GetImages().FindGlobalVariables(ConstString(name),
2036 append,
2037 max_matches,
2038 variable_list);
2039 break;
2040 case eMatchTypeRegex:
2041 match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(name),
2042 append,
2043 max_matches,
2044 variable_list);
2045 break;
2046 case eMatchTypeStartsWith:
2047 regexstr = llvm::Regex::escape(name) + ".*";
2048 match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr.c_str()),
2049 append,
2050 max_matches,
2051 variable_list);
2052 break;
2053 }
2054
2055
2056 if (match_count > 0)
2057 {
2058 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
2059 if (exe_scope == NULL)
2060 exe_scope = target_sp.get();
2061 for (uint32_t i = 0; i<match_count; ++i)
2062 {
2063 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(exe_scope, variable_list.GetVariableAtIndex(i)));
2064 if (valobj_sp)
2065 sb_value_list.Append(SBValue(valobj_sp));
2066 }
2067 }
2068 }
2069
2070 return sb_value_list;
2071}
2072
2073
Enrico Granatabcd80b42013-01-16 18:53:52 +00002074lldb::SBValue
2075SBTarget::FindFirstGlobalVariable (const char* name)
2076{
2077 SBValueList sb_value_list(FindGlobalVariables(name, 1));
2078 if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
2079 return sb_value_list.GetValueAtIndex(0);
2080 return SBValue();
2081}
2082
Jim Inghame37d6052011-09-13 00:29:56 +00002083SBSourceManager
2084SBTarget::GetSourceManager()
2085{
2086 SBSourceManager source_manager (*this);
2087 return source_manager;
2088}
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002089
Sean Callanan50952e92011-12-14 23:49:37 +00002090lldb::SBInstructionList
Greg Clayton9c766112012-03-06 22:24:44 +00002091SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count)
2092{
Jim Ingham0f063ba2013-03-02 00:26:47 +00002093 return ReadInstructions (base_addr, count, NULL);
2094}
2095
2096lldb::SBInstructionList
2097SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string)
2098{
Greg Clayton9c766112012-03-06 22:24:44 +00002099 SBInstructionList sb_instructions;
2100
2101 TargetSP target_sp(GetSP());
2102 if (target_sp)
2103 {
2104 Address *addr_ptr = base_addr.get();
2105
2106 if (addr_ptr)
2107 {
2108 DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
2109 bool prefer_file_cache = false;
2110 lldb_private::Error error;
Greg Clayton3faf47c2013-03-28 23:42:53 +00002111 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
2112 const size_t bytes_read = target_sp->ReadMemory(*addr_ptr,
2113 prefer_file_cache,
2114 data.GetBytes(),
2115 data.GetByteSize(),
2116 error,
2117 &load_addr);
2118 const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
Greg Clayton9c766112012-03-06 22:24:44 +00002119 sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
2120 NULL,
Jim Ingham0f063ba2013-03-02 00:26:47 +00002121 flavor_string,
Greg Clayton9c766112012-03-06 22:24:44 +00002122 *addr_ptr,
2123 data.GetBytes(),
2124 bytes_read,
Greg Clayton3faf47c2013-03-28 23:42:53 +00002125 count,
2126 data_from_file));
Greg Clayton9c766112012-03-06 22:24:44 +00002127 }
2128 }
2129
2130 return sb_instructions;
2131
2132}
2133
2134lldb::SBInstructionList
Sean Callanan50952e92011-12-14 23:49:37 +00002135SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
2136{
Jim Ingham0f063ba2013-03-02 00:26:47 +00002137 return GetInstructionsWithFlavor (base_addr, NULL, buf, size);
2138}
2139
2140lldb::SBInstructionList
2141SBTarget::GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
2142{
Sean Callanan50952e92011-12-14 23:49:37 +00002143 SBInstructionList sb_instructions;
2144
Greg Claytonacdbe812012-01-30 09:04:36 +00002145 TargetSP target_sp(GetSP());
2146 if (target_sp)
Sean Callanan50952e92011-12-14 23:49:37 +00002147 {
2148 Address addr;
2149
2150 if (base_addr.get())
2151 addr = *base_addr.get();
2152
Greg Clayton3faf47c2013-03-28 23:42:53 +00002153 const bool data_from_file = true;
2154
Greg Claytonacdbe812012-01-30 09:04:36 +00002155 sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
Sean Callanan50952e92011-12-14 23:49:37 +00002156 NULL,
Jim Ingham0f063ba2013-03-02 00:26:47 +00002157 flavor_string,
Sean Callanan50952e92011-12-14 23:49:37 +00002158 addr,
2159 buf,
Greg Clayton3faf47c2013-03-28 23:42:53 +00002160 size,
2161 UINT32_MAX,
2162 data_from_file));
Sean Callanan50952e92011-12-14 23:49:37 +00002163 }
2164
2165 return sb_instructions;
2166}
2167
2168lldb::SBInstructionList
2169SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
2170{
Jim Ingham0f063ba2013-03-02 00:26:47 +00002171 return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), NULL, buf, size);
2172}
2173
2174lldb::SBInstructionList
2175SBTarget::GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size)
2176{
2177 return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), flavor_string, buf, size);
Sean Callanan50952e92011-12-14 23:49:37 +00002178}
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002179
2180SBError
2181SBTarget::SetSectionLoadAddress (lldb::SBSection section,
2182 lldb::addr_t section_base_addr)
2183{
2184 SBError sb_error;
Greg Claytonacdbe812012-01-30 09:04:36 +00002185 TargetSP target_sp(GetSP());
2186 if (target_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002187 {
2188 if (!section.IsValid())
2189 {
2190 sb_error.SetErrorStringWithFormat ("invalid section");
2191 }
2192 else
2193 {
Greg Clayton741f3f92012-03-27 21:10:07 +00002194 SectionSP section_sp (section.GetSP());
2195 if (section_sp)
2196 {
2197 if (section_sp->IsThreadSpecific())
2198 {
2199 sb_error.SetErrorString ("thread specific sections are not yet supported");
2200 }
2201 else
2202 {
Greg Claytond5944cd2013-12-06 01:12:00 +00002203 ProcessSP process_sp (target_sp->GetProcessSP());
Greg Claytond5944cd2013-12-06 01:12:00 +00002204 if (target_sp->SetSectionLoadAddress (section_sp, section_base_addr))
Greg Clayton3c947372013-01-29 01:17:09 +00002205 {
2206 // Flush info in the process (stack frames, etc)
Greg Clayton3c947372013-01-29 01:17:09 +00002207 if (process_sp)
2208 process_sp->Flush();
2209 }
Greg Clayton741f3f92012-03-27 21:10:07 +00002210 }
2211 }
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002212 }
2213 }
2214 else
2215 {
Greg Clayton741f3f92012-03-27 21:10:07 +00002216 sb_error.SetErrorString ("invalid target");
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002217 }
2218 return sb_error;
2219}
2220
2221SBError
2222SBTarget::ClearSectionLoadAddress (lldb::SBSection section)
2223{
2224 SBError sb_error;
2225
Greg Claytonacdbe812012-01-30 09:04:36 +00002226 TargetSP target_sp(GetSP());
2227 if (target_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002228 {
2229 if (!section.IsValid())
2230 {
2231 sb_error.SetErrorStringWithFormat ("invalid section");
2232 }
2233 else
2234 {
Greg Claytond5944cd2013-12-06 01:12:00 +00002235 ProcessSP process_sp (target_sp->GetProcessSP());
Greg Claytond5944cd2013-12-06 01:12:00 +00002236 if (target_sp->SetSectionUnloaded (section.GetSP()))
Greg Clayton3c947372013-01-29 01:17:09 +00002237 {
2238 // Flush info in the process (stack frames, etc)
Greg Clayton3c947372013-01-29 01:17:09 +00002239 if (process_sp)
2240 process_sp->Flush();
2241 }
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002242 }
2243 }
2244 else
2245 {
2246 sb_error.SetErrorStringWithFormat ("invalid target");
2247 }
2248 return sb_error;
2249}
2250
2251SBError
2252SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset)
2253{
2254 SBError sb_error;
2255
Greg Claytonacdbe812012-01-30 09:04:36 +00002256 TargetSP target_sp(GetSP());
2257 if (target_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002258 {
Greg Claytonacdbe812012-01-30 09:04:36 +00002259 ModuleSP module_sp (module.GetSP());
2260 if (module_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002261 {
Greg Clayton741f3f92012-03-27 21:10:07 +00002262 bool changed = false;
Greg Clayton751caf62014-02-07 22:54:47 +00002263 if (module_sp->SetLoadAddress (*target_sp, slide_offset, true, changed))
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002264 {
Greg Clayton741f3f92012-03-27 21:10:07 +00002265 // The load was successful, make sure that at least some sections
2266 // changed before we notify that our module was loaded.
2267 if (changed)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002268 {
Greg Clayton741f3f92012-03-27 21:10:07 +00002269 ModuleList module_list;
2270 module_list.Append(module_sp);
2271 target_sp->ModulesDidLoad (module_list);
Greg Clayton3c947372013-01-29 01:17:09 +00002272 // Flush info in the process (stack frames, etc)
2273 ProcessSP process_sp (target_sp->GetProcessSP());
2274 if (process_sp)
2275 process_sp->Flush();
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002276 }
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002277 }
2278 }
Greg Claytonacdbe812012-01-30 09:04:36 +00002279 else
2280 {
2281 sb_error.SetErrorStringWithFormat ("invalid module");
2282 }
2283
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002284 }
2285 else
2286 {
2287 sb_error.SetErrorStringWithFormat ("invalid target");
2288 }
2289 return sb_error;
2290}
2291
2292SBError
2293SBTarget::ClearModuleLoadAddress (lldb::SBModule module)
2294{
2295 SBError sb_error;
2296
2297 char path[PATH_MAX];
Greg Claytonacdbe812012-01-30 09:04:36 +00002298 TargetSP target_sp(GetSP());
2299 if (target_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002300 {
Greg Claytonacdbe812012-01-30 09:04:36 +00002301 ModuleSP module_sp (module.GetSP());
2302 if (module_sp)
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002303 {
Greg Claytonacdbe812012-01-30 09:04:36 +00002304 ObjectFile *objfile = module_sp->GetObjectFile();
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002305 if (objfile)
2306 {
2307 SectionList *section_list = objfile->GetSectionList();
2308 if (section_list)
2309 {
Greg Claytond5944cd2013-12-06 01:12:00 +00002310 ProcessSP process_sp (target_sp->GetProcessSP());
Greg Claytond5944cd2013-12-06 01:12:00 +00002311
Greg Clayton3c947372013-01-29 01:17:09 +00002312 bool changed = false;
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002313 const size_t num_sections = section_list->GetSize();
2314 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
2315 {
2316 SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
2317 if (section_sp)
Zachary Turner40411162014-07-16 20:28:24 +00002318 changed |= target_sp->SetSectionUnloaded (section_sp);
Greg Clayton3c947372013-01-29 01:17:09 +00002319 }
2320 if (changed)
2321 {
2322 // Flush info in the process (stack frames, etc)
2323 ProcessSP process_sp (target_sp->GetProcessSP());
2324 if (process_sp)
2325 process_sp->Flush();
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002326 }
2327 }
2328 else
2329 {
Greg Claytonacdbe812012-01-30 09:04:36 +00002330 module_sp->GetFileSpec().GetPath (path, sizeof(path));
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002331 sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path);
2332 }
2333 }
2334 else
2335 {
Greg Claytonacdbe812012-01-30 09:04:36 +00002336 module_sp->GetFileSpec().GetPath (path, sizeof(path));
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002337 sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path);
2338 }
2339 }
Greg Claytonacdbe812012-01-30 09:04:36 +00002340 else
2341 {
2342 sb_error.SetErrorStringWithFormat ("invalid module");
2343 }
Greg Claytoncac9c5f2011-09-24 00:52:29 +00002344 }
2345 else
2346 {
2347 sb_error.SetErrorStringWithFormat ("invalid target");
2348 }
2349 return sb_error;
2350}
2351
2352
Greg Claytone14e1922012-12-04 02:22:16 +00002353lldb::SBSymbolContextList
2354SBTarget::FindSymbols (const char *name, lldb::SymbolType symbol_type)
2355{
2356 SBSymbolContextList sb_sc_list;
2357 if (name && name[0])
2358 {
2359 TargetSP target_sp(GetSP());
2360 if (target_sp)
2361 {
2362 bool append = true;
2363 target_sp->GetImages().FindSymbolsWithNameAndType (ConstString(name),
2364 symbol_type,
2365 *sb_sc_list,
2366 append);
2367 }
2368 }
2369 return sb_sc_list;
2370
2371}
2372
Jim Ingham763b2b22015-07-07 22:12:17 +00002373lldb::SBValue
2374SBTarget::EvaluateExpression (const char *expr)
2375{
2376 TargetSP target_sp(GetSP());
2377 if (!target_sp)
2378 return SBValue();
2379
2380 SBExpressionOptions options;
2381 lldb::DynamicValueType fetch_dynamic_value = target_sp->GetPreferDynamicValue();
2382 options.SetFetchDynamicValue (fetch_dynamic_value);
2383 options.SetUnwindOnError (true);
2384 return EvaluateExpression(expr, options);
2385}
Greg Claytone14e1922012-12-04 02:22:16 +00002386
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002387lldb::SBValue
2388SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
2389{
Greg Clayton5160ce52013-03-27 23:08:40 +00002390 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool6010f972016-04-22 23:08:34 +00002391#if !defined(LLDB_DISABLE_PYTHON)
Greg Clayton5160ce52013-03-27 23:08:40 +00002392 Log * expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Saleem Abdulrasool6010f972016-04-22 23:08:34 +00002393#endif
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002394 SBValue expr_result;
Jim Ingham8646d3c2014-05-05 02:47:44 +00002395 ExpressionResults exe_results = eExpressionSetupError;
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002396 ValueObjectSP expr_value_sp;
2397 TargetSP target_sp(GetSP());
Jason Molendab57e4a12013-11-04 09:33:30 +00002398 StackFrame *frame = NULL;
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002399 if (target_sp)
2400 {
2401 if (expr == NULL || expr[0] == '\0')
2402 {
2403 if (log)
2404 log->Printf ("SBTarget::EvaluateExpression called with an empty expression");
2405 return expr_result;
2406 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002407
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002408 Mutex::Locker api_locker (target_sp->GetAPIMutex());
2409 ExecutionContext exe_ctx (m_opaque_sp.get());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002410
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002411 if (log)
2412 log->Printf ("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002413
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002414 frame = exe_ctx.GetFramePtr();
2415 Target *target = exe_ctx.GetTargetPtr();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002416
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002417 if (target)
2418 {
2419#ifdef LLDB_CONFIGURATION_DEBUG
2420 StreamString frame_description;
2421 if (frame)
2422 frame->DumpUsingSettingsFormat (&frame_description);
2423 Host::SetCrashDescriptionWithFormat ("SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
2424 expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
2425#endif
2426 exe_results = target->EvaluateExpression (expr,
2427 frame,
2428 expr_value_sp,
2429 options.ref());
2430
2431 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2432#ifdef LLDB_CONFIGURATION_DEBUG
2433 Host::SetCrashDescription (NULL);
2434#endif
2435 }
2436 else
2437 {
2438 if (log)
2439 log->Printf ("SBTarget::EvaluateExpression () => error: could not reconstruct frame object for this SBTarget.");
2440 }
2441 }
2442#ifndef LLDB_DISABLE_PYTHON
2443 if (expr_log)
2444 expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is %s, summary %s **",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002445 expr_result.GetValue(), expr_result.GetSummary());
2446
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002447 if (log)
2448 log->Printf ("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002449 static_cast<void*>(frame), expr,
2450 static_cast<void*>(expr_value_sp.get()), exe_results);
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002451#endif
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00002452
Greg Clayton4b63a5c2013-01-04 18:10:18 +00002453 return expr_result;
2454}
2455
Greg Clayton13fbb992013-02-01 00:47:49 +00002456
2457lldb::addr_t
2458SBTarget::GetStackRedZoneSize()
2459{
2460 TargetSP target_sp(GetSP());
2461 if (target_sp)
2462 {
2463 ABISP abi_sp;
2464 ProcessSP process_sp (target_sp->GetProcessSP());
2465 if (process_sp)
2466 abi_sp = process_sp->GetABI();
2467 else
2468 abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
2469 if (abi_sp)
2470 return abi_sp->GetRedZoneSize();
2471 }
2472 return 0;
2473}
Ilia K8f37ca52015-02-13 14:31:06 +00002474
2475lldb::SBLaunchInfo
2476SBTarget::GetLaunchInfo () const
2477{
2478 lldb::SBLaunchInfo launch_info(NULL);
2479 TargetSP target_sp(GetSP());
2480 if (target_sp)
2481 launch_info.ref() = m_opaque_sp->GetProcessLaunchInfo();
2482 return launch_info;
2483}
2484
2485void
2486SBTarget::SetLaunchInfo (const lldb::SBLaunchInfo &launch_info)
2487{
2488 TargetSP target_sp(GetSP());
2489 if (target_sp)
2490 m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
2491}