blob: 0367d65c9fb9ed0b88a18d8c861a80e075171bf7 [file] [log] [blame]
Chris Lattner24943d22010-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 Friedman7a62c8b2010-06-09 07:44:37 +000010#include "lldb/API/SBTarget.h"
Chris Lattner24943d22010-06-08 16:52:24 +000011
Greg Claytonb3448432011-03-24 21:19:54 +000012#include "lldb/lldb-public.h"
Chris Lattner24943d22010-06-08 16:52:24 +000013
Greg Clayton917c0002011-06-29 22:09:02 +000014#include "lldb/API/SBDebugger.h"
15#include "lldb/API/SBBreakpoint.h"
Chris Lattner24943d22010-06-08 16:52:24 +000016#include "lldb/API/SBFileSpec.h"
Greg Clayton917c0002011-06-29 22:09:02 +000017#include "lldb/API/SBListener.h"
Chris Lattner24943d22010-06-08 16:52:24 +000018#include "lldb/API/SBModule.h"
Greg Clayton917c0002011-06-29 22:09:02 +000019#include "lldb/API/SBProcess.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000020#include "lldb/API/SBStream.h"
Greg Clayton4ed315f2011-06-21 01:34:41 +000021#include "lldb/API/SBSymbolContextList.h"
Chris Lattner24943d22010-06-08 16:52:24 +000022#include "lldb/Breakpoint/BreakpointID.h"
23#include "lldb/Breakpoint/BreakpointIDList.h"
24#include "lldb/Breakpoint/BreakpointList.h"
25#include "lldb/Breakpoint/BreakpointLocation.h"
26#include "lldb/Core/Address.h"
27#include "lldb/Core/AddressResolver.h"
28#include "lldb/Core/AddressResolverName.h"
Chris Lattner24943d22010-06-08 16:52:24 +000029#include "lldb/Core/ArchSpec.h"
30#include "lldb/Core/Debugger.h"
31#include "lldb/Core/Disassembler.h"
Caroline Tice7826c882010-10-26 03:11:13 +000032#include "lldb/Core/Log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000033#include "lldb/Core/RegularExpression.h"
34#include "lldb/Core/SearchFilter.h"
35#include "lldb/Core/STLUtils.h"
Greg Clayton917c0002011-06-29 22:09:02 +000036#include "lldb/Core/ValueObjectList.h"
37#include "lldb/Core/ValueObjectVariable.h"
38#include "lldb/Host/FileSpec.h"
Greg Claytoncd548032011-02-01 01:31:41 +000039#include "lldb/Host/Host.h"
Greg Clayton917c0002011-06-29 22:09:02 +000040#include "lldb/Interpreter/Args.h"
Enrico Granata979e20d2011-07-29 19:53:35 +000041#include "lldb/Symbol/SymbolVendor.h"
Greg Clayton917c0002011-06-29 22:09:02 +000042#include "lldb/Symbol/VariableList.h"
Chris Lattner24943d22010-06-08 16:52:24 +000043#include "lldb/Target/Process.h"
44#include "lldb/Target/Target.h"
45#include "lldb/Target/TargetList.h"
46
47#include "lldb/Interpreter/CommandReturnObject.h"
48#include "../source/Commands/CommandObjectBreakpoint.h"
49
Chris Lattner24943d22010-06-08 16:52:24 +000050
51using namespace lldb;
52using namespace lldb_private;
53
54#define DEFAULT_DISASM_BYTE_SIZE 32
55
56//----------------------------------------------------------------------
57// SBTarget constructor
58//----------------------------------------------------------------------
Greg Claytonc3b61d22010-12-15 05:08:08 +000059SBTarget::SBTarget () :
60 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000061{
62}
63
64SBTarget::SBTarget (const SBTarget& rhs) :
Greg Clayton63094e02010-06-23 01:19:29 +000065 m_opaque_sp (rhs.m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000066{
67}
68
69SBTarget::SBTarget(const TargetSP& target_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000070 m_opaque_sp (target_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000071{
72}
73
Greg Clayton538eb822010-11-05 23:17:00 +000074const SBTarget&
75SBTarget::operator = (const SBTarget& rhs)
76{
77 if (this != &rhs)
78 m_opaque_sp = rhs.m_opaque_sp;
79 return *this;
80}
81
Chris Lattner24943d22010-06-08 16:52:24 +000082//----------------------------------------------------------------------
83// Destructor
84//----------------------------------------------------------------------
85SBTarget::~SBTarget()
86{
87}
88
89bool
90SBTarget::IsValid () const
91{
Greg Clayton63094e02010-06-23 01:19:29 +000092 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000093}
94
95SBProcess
96SBTarget::GetProcess ()
97{
Caroline Tice7826c882010-10-26 03:11:13 +000098
Chris Lattner24943d22010-06-08 16:52:24 +000099 SBProcess sb_process;
Greg Clayton63094e02010-06-23 01:19:29 +0000100 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000101 {
102 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000103 sb_process.SetProcess (m_opaque_sp->GetProcessSP());
Greg Claytonbdcda462010-12-20 20:49:23 +0000104 }
Caroline Tice7826c882010-10-26 03:11:13 +0000105
Greg Claytone005f2c2010-11-06 01:53:30 +0000106 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000107 if (log)
108 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000109 log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
110 m_opaque_sp.get(), sb_process.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000111 }
112
Chris Lattner24943d22010-06-08 16:52:24 +0000113 return sb_process;
114}
115
Greg Clayton63094e02010-06-23 01:19:29 +0000116SBDebugger
117SBTarget::GetDebugger () const
118{
119 SBDebugger debugger;
120 if (m_opaque_sp)
121 debugger.reset (m_opaque_sp->GetDebugger().GetSP());
122 return debugger;
123}
124
Jim Inghamb5871fe2011-03-31 00:01:24 +0000125SBProcess
126SBTarget::LaunchSimple
127(
128 char const **argv,
129 char const **envp,
130 const char *working_directory
131)
132{
133 char *stdin_path = NULL;
134 char *stdout_path = NULL;
135 char *stderr_path = NULL;
136 uint32_t launch_flags = 0;
137 bool stop_at_entry = false;
138 SBError error;
139 SBListener listener = GetDebugger().GetListener();
140 return Launch (listener,
141 argv,
142 envp,
143 stdin_path,
144 stdout_path,
145 stderr_path,
146 working_directory,
147 launch_flags,
148 stop_at_entry,
149 error);
150}
Greg Claytonde915be2011-01-23 05:56:20 +0000151
152SBProcess
153SBTarget::Launch
154(
Greg Clayton271a5db2011-02-03 21:28:34 +0000155 SBListener &listener,
Greg Claytonde915be2011-01-23 05:56:20 +0000156 char const **argv,
157 char const **envp,
158 const char *stdin_path,
159 const char *stdout_path,
160 const char *stderr_path,
161 const char *working_directory,
162 uint32_t launch_flags, // See LaunchFlags
163 bool stop_at_entry,
164 lldb::SBError& error
165)
166{
Greg Claytone005f2c2010-11-06 01:53:30 +0000167 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000168
169 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000170 {
Greg Claytonde915be2011-01-23 05:56:20 +0000171 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))...",
172 m_opaque_sp.get(),
173 argv,
174 envp,
175 stdin_path ? stdin_path : "NULL",
176 stdout_path ? stdout_path : "NULL",
177 stderr_path ? stderr_path : "NULL",
178 working_directory ? working_directory : "NULL",
179 launch_flags,
180 stop_at_entry,
181 error.get());
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000182 }
Greg Clayton1a3083a2010-10-06 03:53:16 +0000183 SBProcess sb_process;
184 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000185 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000186 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton1a3083a2010-10-06 03:53:16 +0000187
Greg Clayton7c330d62011-01-27 01:01:10 +0000188 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
189 launch_flags |= eLaunchFlagDisableASLR;
190
Greg Clayton180546b2011-04-30 01:09:13 +0000191 StateType state = eStateInvalid;
192 sb_process.SetProcess (m_opaque_sp->GetProcessSP());
193 if (sb_process.IsValid())
Greg Clayton28d5fcc2011-01-27 06:44:37 +0000194 {
Greg Clayton180546b2011-04-30 01:09:13 +0000195 state = sb_process->GetState();
196
197 if (sb_process->IsAlive() && state != eStateConnected)
198 {
199 if (state == eStateAttaching)
200 error.SetErrorString ("process attach is in progress");
201 else
202 error.SetErrorString ("a process is already being debugged");
203 sb_process.Clear();
204 return sb_process;
205 }
Greg Clayton28d5fcc2011-01-27 06:44:37 +0000206 }
207
Greg Clayton180546b2011-04-30 01:09:13 +0000208 if (state == eStateConnected)
209 {
210 // If we are already connected, then we have already specified the
211 // listener, so if a valid listener is supplied, we need to error out
212 // to let the client know.
213 if (listener.IsValid())
214 {
215 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
216 sb_process.Clear();
217 return sb_process;
218 }
219 }
220 else
Greg Claytonc5f728c2010-10-06 22:10:17 +0000221 {
Greg Clayton271a5db2011-02-03 21:28:34 +0000222 if (listener.IsValid())
223 sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref()));
224 else
225 sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
Greg Clayton180546b2011-04-30 01:09:13 +0000226 }
Greg Clayton7c330d62011-01-27 01:01:10 +0000227
Greg Clayton180546b2011-04-30 01:09:13 +0000228 if (sb_process.IsValid())
229 {
230 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
231 launch_flags |= eLaunchFlagDisableSTDIO;
232
233 error.SetError (sb_process->Launch (argv, envp, launch_flags, stdin_path, stdout_path, stderr_path, working_directory));
234 if (error.Success())
Greg Clayton7c330d62011-01-27 01:01:10 +0000235 {
Greg Clayton180546b2011-04-30 01:09:13 +0000236 // We we are stopping at the entry point, we can return now!
237 if (stop_at_entry)
238 return sb_process;
Greg Clayton7c330d62011-01-27 01:01:10 +0000239
Greg Clayton180546b2011-04-30 01:09:13 +0000240 // Make sure we are stopped at the entry
241 StateType state = sb_process->WaitForProcessToStop (NULL);
242 if (state == eStateStopped)
Greg Clayton7c330d62011-01-27 01:01:10 +0000243 {
Greg Clayton180546b2011-04-30 01:09:13 +0000244 // resume the process to skip the entry point
245 error.SetError (sb_process->Resume());
246 if (error.Success())
Greg Clayton7c330d62011-01-27 01:01:10 +0000247 {
Greg Clayton180546b2011-04-30 01:09:13 +0000248 // If we are doing synchronous mode, then wait for the
249 // process to stop yet again!
250 if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false)
251 sb_process->WaitForProcessToStop (NULL);
Greg Clayton7c330d62011-01-27 01:01:10 +0000252 }
253 }
254 }
Greg Clayton180546b2011-04-30 01:09:13 +0000255 }
256 else
257 {
258 error.SetErrorString ("unable to create lldb_private::Process");
Greg Claytonc5f728c2010-10-06 22:10:17 +0000259 }
260 }
261 else
262 {
263 error.SetErrorString ("SBTarget is invalid");
Chris Lattner24943d22010-06-08 16:52:24 +0000264 }
Caroline Tice7826c882010-10-26 03:11:13 +0000265
Caroline Tice926060e2010-10-29 21:48:37 +0000266 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
Caroline Tice7826c882010-10-26 03:11:13 +0000267 if (log)
268 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000269 log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)",
270 m_opaque_sp.get(), sb_process.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000271 }
272
Greg Clayton1a3083a2010-10-06 03:53:16 +0000273 return sb_process;
Chris Lattner24943d22010-06-08 16:52:24 +0000274}
275
Greg Claytonc5f728c2010-10-06 22:10:17 +0000276
277lldb::SBProcess
Greg Claytond8c62532010-10-07 04:19:01 +0000278SBTarget::AttachToProcessWithID
Greg Claytonc5f728c2010-10-06 22:10:17 +0000279(
Greg Clayton271a5db2011-02-03 21:28:34 +0000280 SBListener &listener,
Greg Claytonc5f728c2010-10-06 22:10:17 +0000281 lldb::pid_t pid,// The process ID to attach to
282 SBError& error // An error explaining what went wrong if attach fails
283)
284{
285 SBProcess sb_process;
286 if (m_opaque_sp)
287 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000288 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Claytonde1dd812011-06-24 03:21:43 +0000289
290 StateType state = eStateInvalid;
291 sb_process.SetProcess (m_opaque_sp->GetProcessSP());
292 if (sb_process.IsValid())
293 {
294 state = sb_process->GetState();
295
296 if (sb_process->IsAlive() && state != eStateConnected)
297 {
298 if (state == eStateAttaching)
299 error.SetErrorString ("process attach is in progress");
300 else
301 error.SetErrorString ("a process is already being debugged");
302 sb_process.Clear();
303 return sb_process;
304 }
305 }
306
307 if (state == eStateConnected)
308 {
309 // If we are already connected, then we have already specified the
310 // listener, so if a valid listener is supplied, we need to error out
311 // to let the client know.
312 if (listener.IsValid())
313 {
314 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
315 sb_process.Clear();
316 return sb_process;
317 }
318 }
Greg Clayton271a5db2011-02-03 21:28:34 +0000319 else
Greg Claytonde1dd812011-06-24 03:21:43 +0000320 {
321 if (listener.IsValid())
322 sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref()));
323 else
324 sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
325 }
Greg Claytonc5f728c2010-10-06 22:10:17 +0000326
327 if (sb_process.IsValid())
328 {
329 error.SetError (sb_process->Attach (pid));
Johnny Chen535960e2011-06-17 00:51:15 +0000330 // If we are doing synchronous mode, then wait for the
331 // process to stop!
332 if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false)
333 sb_process->WaitForProcessToStop (NULL);
Greg Claytonc5f728c2010-10-06 22:10:17 +0000334 }
335 else
336 {
337 error.SetErrorString ("unable to create lldb_private::Process");
338 }
339 }
340 else
341 {
342 error.SetErrorString ("SBTarget is invalid");
343 }
344 return sb_process;
345
346}
347
348lldb::SBProcess
Greg Claytond8c62532010-10-07 04:19:01 +0000349SBTarget::AttachToProcessWithName
Greg Claytonc5f728c2010-10-06 22:10:17 +0000350(
Greg Clayton271a5db2011-02-03 21:28:34 +0000351 SBListener &listener,
Greg Claytonc5f728c2010-10-06 22:10:17 +0000352 const char *name, // basename of process to attach to
353 bool wait_for, // if true wait for a new instance of "name" to be launched
354 SBError& error // An error explaining what went wrong if attach fails
355)
356{
357 SBProcess sb_process;
358 if (m_opaque_sp)
359 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000360 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
361
Greg Claytonde1dd812011-06-24 03:21:43 +0000362 StateType state = eStateInvalid;
363 sb_process.SetProcess (m_opaque_sp->GetProcessSP());
364 if (sb_process.IsValid())
365 {
366 state = sb_process->GetState();
367
368 if (sb_process->IsAlive() && state != eStateConnected)
369 {
370 if (state == eStateAttaching)
371 error.SetErrorString ("process attach is in progress");
372 else
373 error.SetErrorString ("a process is already being debugged");
374 sb_process.Clear();
375 return sb_process;
376 }
377 }
378
379 if (state == eStateConnected)
380 {
381 // If we are already connected, then we have already specified the
382 // listener, so if a valid listener is supplied, we need to error out
383 // to let the client know.
384 if (listener.IsValid())
385 {
386 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
387 sb_process.Clear();
388 return sb_process;
389 }
390 }
Greg Clayton271a5db2011-02-03 21:28:34 +0000391 else
Greg Claytonde1dd812011-06-24 03:21:43 +0000392 {
393 if (listener.IsValid())
394 sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref()));
395 else
396 sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
397 }
Greg Claytonc5f728c2010-10-06 22:10:17 +0000398
399 if (sb_process.IsValid())
400 {
401 error.SetError (sb_process->Attach (name, wait_for));
Johnny Chen58d02ff2011-06-17 19:21:30 +0000402 // If we are doing synchronous mode, then wait for the
403 // process to stop!
404 if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false)
405 sb_process->WaitForProcessToStop (NULL);
Greg Claytonc5f728c2010-10-06 22:10:17 +0000406 }
407 else
408 {
409 error.SetErrorString ("unable to create lldb_private::Process");
410 }
411 }
412 else
413 {
414 error.SetErrorString ("SBTarget is invalid");
415 }
416 return sb_process;
417
418}
419
James McIlree38093402011-03-04 00:31:13 +0000420lldb::SBProcess
421SBTarget::ConnectRemote
422(
423 SBListener &listener,
424 const char *url,
425 const char *plugin_name,
426 SBError& error
427)
428{
429 SBProcess sb_process;
430 if (m_opaque_sp)
431 {
432 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
433 if (listener.IsValid())
434 sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref(), plugin_name));
435 else
436 sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener(), plugin_name));
437
438
439 if (sb_process.IsValid())
440 {
441 error.SetError (sb_process->ConnectRemote (url));
442 }
443 else
444 {
445 error.SetErrorString ("unable to create lldb_private::Process");
446 }
447 }
448 else
449 {
450 error.SetErrorString ("SBTarget is invalid");
451 }
452 return sb_process;
453}
454
Chris Lattner24943d22010-06-08 16:52:24 +0000455SBFileSpec
456SBTarget::GetExecutable ()
457{
Caroline Tice7826c882010-10-26 03:11:13 +0000458
Chris Lattner24943d22010-06-08 16:52:24 +0000459 SBFileSpec exe_file_spec;
Greg Clayton63094e02010-06-23 01:19:29 +0000460 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000461 {
Greg Clayton63094e02010-06-23 01:19:29 +0000462 ModuleSP exe_module_sp (m_opaque_sp->GetExecutableModule ());
Chris Lattner24943d22010-06-08 16:52:24 +0000463 if (exe_module_sp)
464 exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec());
465 }
Caroline Tice7826c882010-10-26 03:11:13 +0000466
Greg Claytone005f2c2010-11-06 01:53:30 +0000467 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000468 if (log)
469 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000470 log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
471 m_opaque_sp.get(), exe_file_spec.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000472 }
473
Chris Lattner24943d22010-06-08 16:52:24 +0000474 return exe_file_spec;
475}
476
Chris Lattner24943d22010-06-08 16:52:24 +0000477bool
Chris Lattner24943d22010-06-08 16:52:24 +0000478SBTarget::operator == (const SBTarget &rhs) const
479{
Greg Clayton63094e02010-06-23 01:19:29 +0000480 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000481}
482
483bool
484SBTarget::operator != (const SBTarget &rhs) const
485{
Greg Clayton63094e02010-06-23 01:19:29 +0000486 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000487}
488
489lldb_private::Target *
Greg Clayton63094e02010-06-23 01:19:29 +0000490SBTarget::operator ->() const
Chris Lattner24943d22010-06-08 16:52:24 +0000491{
Greg Clayton63094e02010-06-23 01:19:29 +0000492 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000493}
Greg Clayton63094e02010-06-23 01:19:29 +0000494
495lldb_private::Target *
496SBTarget::get() const
Chris Lattner24943d22010-06-08 16:52:24 +0000497{
Greg Clayton63094e02010-06-23 01:19:29 +0000498 return m_opaque_sp.get();
499}
500
501void
502SBTarget::reset (const lldb::TargetSP& target_sp)
503{
504 m_opaque_sp = target_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000505}
506
Greg Claytona3955062011-07-22 16:46:35 +0000507lldb::SBAddress
508SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
Greg Claytonea49cc72010-12-12 19:25:26 +0000509{
Greg Claytona3955062011-07-22 16:46:35 +0000510 lldb::SBAddress sb_addr;
511 Address &addr = sb_addr.ref();
512 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000513 {
514 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Claytona3955062011-07-22 16:46:35 +0000515 if (m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr))
516 return sb_addr;
Greg Claytonbdcda462010-12-20 20:49:23 +0000517 }
Greg Claytonea49cc72010-12-12 19:25:26 +0000518
Greg Claytona3955062011-07-22 16:46:35 +0000519 // We have a load address that isn't in a section, just return an address
520 // with the offset filled in (the address) and the section set to NULL
521 addr.SetSection(NULL);
522 addr.SetOffset(vm_addr);
523 return sb_addr;
Greg Claytonea49cc72010-12-12 19:25:26 +0000524}
525
Greg Claytonafb81862011-03-02 21:34:46 +0000526SBSymbolContext
527SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope)
528{
529 SBSymbolContext sc;
Johnny Chene657fbc2011-06-29 00:05:40 +0000530 if (m_opaque_sp && addr.IsValid())
Greg Claytona3955062011-07-22 16:46:35 +0000531 m_opaque_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
Greg Claytonafb81862011-03-02 21:34:46 +0000532 return sc;
533}
534
535
Chris Lattner24943d22010-06-08 16:52:24 +0000536SBBreakpoint
537SBTarget::BreakpointCreateByLocation (const char *file, uint32_t line)
538{
Greg Claytond6d806c2010-11-08 00:28:40 +0000539 return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
Chris Lattner24943d22010-06-08 16:52:24 +0000540}
541
542SBBreakpoint
543SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line)
544{
Greg Claytone005f2c2010-11-06 01:53:30 +0000545 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000546
Chris Lattner24943d22010-06-08 16:52:24 +0000547 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000548 if (m_opaque_sp.get() && line != 0)
Greg Claytonbdcda462010-12-20 20:49:23 +0000549 {
550 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000551 *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false);
Greg Claytonbdcda462010-12-20 20:49:23 +0000552 }
Caroline Tice7826c882010-10-26 03:11:13 +0000553
554 if (log)
555 {
556 SBStream sstr;
557 sb_bp.GetDescription (sstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000558 char path[PATH_MAX];
559 sb_file_spec->GetPath (path, sizeof(path));
560 log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s",
Greg Claytona66ba462010-10-30 04:51:46 +0000561 m_opaque_sp.get(),
Greg Clayton49ce6822010-10-31 03:01:06 +0000562 path,
Greg Claytona66ba462010-10-30 04:51:46 +0000563 line,
Greg Clayton49ce6822010-10-31 03:01:06 +0000564 sb_bp.get(),
Caroline Tice7826c882010-10-26 03:11:13 +0000565 sstr.GetData());
566 }
567
Chris Lattner24943d22010-06-08 16:52:24 +0000568 return sb_bp;
569}
570
571SBBreakpoint
572SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name)
573{
Greg Claytone005f2c2010-11-06 01:53:30 +0000574 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000575
Chris Lattner24943d22010-06-08 16:52:24 +0000576 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000577 if (m_opaque_sp.get() && symbol_name && symbol_name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000578 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000579 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Chris Lattner24943d22010-06-08 16:52:24 +0000580 if (module_name && module_name[0])
581 {
Greg Clayton537a7a82010-10-20 20:54:39 +0000582 FileSpec module_file_spec(module_name, false);
Jim Ingham7ec03bd2010-09-30 21:21:43 +0000583 *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000584 }
585 else
586 {
Jim Ingham7ec03bd2010-09-30 21:21:43 +0000587 *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000588 }
589 }
Caroline Tice7826c882010-10-26 03:11:13 +0000590
591 if (log)
592 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000593 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)",
594 m_opaque_sp.get(), symbol_name, module_name, sb_bp.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000595 }
596
Chris Lattner24943d22010-06-08 16:52:24 +0000597 return sb_bp;
598}
599
600SBBreakpoint
601SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name)
602{
Greg Claytone005f2c2010-11-06 01:53:30 +0000603 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000604
Chris Lattner24943d22010-06-08 16:52:24 +0000605 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000606 if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000607 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000608 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Chris Lattner24943d22010-06-08 16:52:24 +0000609 RegularExpression regexp(symbol_name_regex);
610
611 if (module_name && module_name[0])
612 {
Greg Clayton537a7a82010-10-20 20:54:39 +0000613 FileSpec module_file_spec(module_name, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000614
Greg Clayton63094e02010-06-23 01:19:29 +0000615 *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000616 }
617 else
618 {
Greg Clayton63094e02010-06-23 01:19:29 +0000619 *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, regexp, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000620 }
621 }
Caroline Tice7826c882010-10-26 03:11:13 +0000622
623 if (log)
624 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000625 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
626 m_opaque_sp.get(), symbol_name_regex, module_name, sb_bp.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000627 }
628
Chris Lattner24943d22010-06-08 16:52:24 +0000629 return sb_bp;
630}
631
632
633
634SBBreakpoint
635SBTarget::BreakpointCreateByAddress (addr_t address)
636{
Greg Claytone005f2c2010-11-06 01:53:30 +0000637 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000638
Chris Lattner24943d22010-06-08 16:52:24 +0000639 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000640 if (m_opaque_sp.get())
Greg Claytonbdcda462010-12-20 20:49:23 +0000641 {
642 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000643 *sb_bp = m_opaque_sp->CreateBreakpoint (address, false);
Greg Claytonbdcda462010-12-20 20:49:23 +0000644 }
Caroline Tice7826c882010-10-26 03:11:13 +0000645
646 if (log)
647 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000648 log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (%p, address=%p) => SBBreakpoint(%p)", m_opaque_sp.get(), address, sb_bp.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000649 }
650
Chris Lattner24943d22010-06-08 16:52:24 +0000651 return sb_bp;
652}
653
Chris Lattner24943d22010-06-08 16:52:24 +0000654SBBreakpoint
655SBTarget::FindBreakpointByID (break_id_t bp_id)
656{
Greg Claytone005f2c2010-11-06 01:53:30 +0000657 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000658
Chris Lattner24943d22010-06-08 16:52:24 +0000659 SBBreakpoint sb_breakpoint;
Greg Clayton63094e02010-06-23 01:19:29 +0000660 if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID)
Greg Claytonbdcda462010-12-20 20:49:23 +0000661 {
662 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000663 *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id);
Greg Claytonbdcda462010-12-20 20:49:23 +0000664 }
Caroline Tice7826c882010-10-26 03:11:13 +0000665
666 if (log)
667 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000668 log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
669 m_opaque_sp.get(), (uint32_t) bp_id, sb_breakpoint.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000670 }
671
Chris Lattner24943d22010-06-08 16:52:24 +0000672 return sb_breakpoint;
673}
674
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000675uint32_t
676SBTarget::GetNumBreakpoints () const
677{
678 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000679 {
680 // The breakpoint list is thread safe, no need to lock
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000681 return m_opaque_sp->GetBreakpointList().GetSize();
Greg Claytonbdcda462010-12-20 20:49:23 +0000682 }
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000683 return 0;
684}
685
686SBBreakpoint
687SBTarget::GetBreakpointAtIndex (uint32_t idx) const
688{
689 SBBreakpoint sb_breakpoint;
690 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000691 {
692 // The breakpoint list is thread safe, no need to lock
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000693 *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
Greg Claytonbdcda462010-12-20 20:49:23 +0000694 }
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000695 return sb_breakpoint;
696}
Chris Lattner24943d22010-06-08 16:52:24 +0000697
698bool
699SBTarget::BreakpointDelete (break_id_t bp_id)
700{
Greg Claytone005f2c2010-11-06 01:53:30 +0000701 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000702
Caroline Tice7826c882010-10-26 03:11:13 +0000703 bool result = false;
Greg Clayton63094e02010-06-23 01:19:29 +0000704 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000705 {
706 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Caroline Tice7826c882010-10-26 03:11:13 +0000707 result = m_opaque_sp->RemoveBreakpointByID (bp_id);
Greg Claytonbdcda462010-12-20 20:49:23 +0000708 }
Caroline Tice7826c882010-10-26 03:11:13 +0000709
710 if (log)
711 {
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000712 log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) bp_id, result);
Caroline Tice7826c882010-10-26 03:11:13 +0000713 }
714
715 return result;
Chris Lattner24943d22010-06-08 16:52:24 +0000716}
717
718bool
719SBTarget::EnableAllBreakpoints ()
720{
Greg Clayton63094e02010-06-23 01:19:29 +0000721 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000722 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000723 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000724 m_opaque_sp->EnableAllBreakpoints ();
Chris Lattner24943d22010-06-08 16:52:24 +0000725 return true;
726 }
727 return false;
728}
729
730bool
731SBTarget::DisableAllBreakpoints ()
732{
Greg Clayton63094e02010-06-23 01:19:29 +0000733 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000734 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000735 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000736 m_opaque_sp->DisableAllBreakpoints ();
Chris Lattner24943d22010-06-08 16:52:24 +0000737 return true;
738 }
739 return false;
740}
741
742bool
743SBTarget::DeleteAllBreakpoints ()
744{
Greg Clayton63094e02010-06-23 01:19:29 +0000745 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000746 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000747 Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000748 m_opaque_sp->RemoveAllBreakpoints ();
Chris Lattner24943d22010-06-08 16:52:24 +0000749 return true;
750 }
751 return false;
752}
753
754
755uint32_t
756SBTarget::GetNumModules () const
757{
Greg Claytone005f2c2010-11-06 01:53:30 +0000758 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000759
Caroline Tice7826c882010-10-26 03:11:13 +0000760 uint32_t num = 0;
Greg Clayton63094e02010-06-23 01:19:29 +0000761 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000762 {
763 // The module list is thread safe, no need to lock
764 num = m_opaque_sp->GetImages().GetSize();
765 }
Caroline Tice7826c882010-10-26 03:11:13 +0000766
767 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000768 log->Printf ("SBTarget(%p)::GetNumModules () => %d", m_opaque_sp.get(), num);
Caroline Tice7826c882010-10-26 03:11:13 +0000769
770 return num;
Chris Lattner24943d22010-06-08 16:52:24 +0000771}
772
Greg Clayton43490d12010-07-30 20:12:55 +0000773void
774SBTarget::Clear ()
775{
Greg Claytone005f2c2010-11-06 01:53:30 +0000776 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000777
778 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000779 log->Printf ("SBTarget(%p)::Clear ()", m_opaque_sp.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000780
Greg Clayton43490d12010-07-30 20:12:55 +0000781 m_opaque_sp.reset();
782}
783
784
Chris Lattner24943d22010-06-08 16:52:24 +0000785SBModule
786SBTarget::FindModule (const SBFileSpec &sb_file_spec)
787{
788 SBModule sb_module;
Greg Clayton63094e02010-06-23 01:19:29 +0000789 if (m_opaque_sp && sb_file_spec.IsValid())
Greg Claytonbdcda462010-12-20 20:49:23 +0000790 {
791 // The module list is thread safe, no need to lock
Greg Clayton24bc5d92011-03-30 18:16:51 +0000792 sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL, NULL));
Greg Claytonbdcda462010-12-20 20:49:23 +0000793 }
Chris Lattner24943d22010-06-08 16:52:24 +0000794 return sb_module;
795}
796
797SBModule
798SBTarget::GetModuleAtIndex (uint32_t idx)
799{
Greg Claytone005f2c2010-11-06 01:53:30 +0000800 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000801
Chris Lattner24943d22010-06-08 16:52:24 +0000802 SBModule sb_module;
Greg Clayton63094e02010-06-23 01:19:29 +0000803 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000804 {
805 // The module list is thread safe, no need to lock
Greg Clayton63094e02010-06-23 01:19:29 +0000806 sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx));
Greg Claytonbdcda462010-12-20 20:49:23 +0000807 }
Caroline Tice7826c882010-10-26 03:11:13 +0000808
809 if (log)
810 {
Greg Clayton49ce6822010-10-31 03:01:06 +0000811 log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
812 m_opaque_sp.get(), idx, sb_module.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000813 }
814
Chris Lattner24943d22010-06-08 16:52:24 +0000815 return sb_module;
816}
817
818
819SBBroadcaster
820SBTarget::GetBroadcaster () const
821{
Greg Claytone005f2c2010-11-06 01:53:30 +0000822 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000823
Greg Clayton63094e02010-06-23 01:19:29 +0000824 SBBroadcaster broadcaster(m_opaque_sp.get(), false);
Caroline Tice7826c882010-10-26 03:11:13 +0000825
826 if (log)
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000827 log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000828 m_opaque_sp.get(), broadcaster.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000829
Chris Lattner24943d22010-06-08 16:52:24 +0000830 return broadcaster;
831}
832
Caroline Tice98f930f2010-09-20 05:20:02 +0000833
834bool
Caroline Tice7826c882010-10-26 03:11:13 +0000835SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
Caroline Tice98f930f2010-09-20 05:20:02 +0000836{
837 if (m_opaque_sp)
Caroline Ticee7a566e2010-09-20 16:21:41 +0000838 {
Caroline Ticee49ec182010-09-22 23:01:29 +0000839 description.ref();
Caroline Tice7826c882010-10-26 03:11:13 +0000840 m_opaque_sp->Dump (description.get(), description_level);
841 }
842 else
843 description.Printf ("No value");
844
845 return true;
846}
847
848bool
849SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level) const
850{
851 if (m_opaque_sp)
852 {
853 description.ref();
854 m_opaque_sp->Dump (description.get(), description_level);
Caroline Ticee7a566e2010-09-20 16:21:41 +0000855 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000856 else
857 description.Printf ("No value");
858
859 return true;
860}
Greg Clayton4ed315f2011-06-21 01:34:41 +0000861
862
863uint32_t
864SBTarget::FindFunctions (const char *name,
865 uint32_t name_type_mask,
866 bool append,
867 lldb::SBSymbolContextList& sc_list)
868{
869 if (!append)
870 sc_list.Clear();
871 if (m_opaque_sp)
872 {
873 const bool symbols_ok = true;
874 return m_opaque_sp->GetImages().FindFunctions (ConstString(name),
875 name_type_mask,
876 symbols_ok,
877 append,
878 *sc_list);
879 }
880 return 0;
881}
882
Enrico Granata979e20d2011-07-29 19:53:35 +0000883lldb::SBType
884SBTarget::FindFirstType (const char* type)
885{
886 if (m_opaque_sp)
887 {
888 size_t count = m_opaque_sp->GetImages().GetSize();
889 for (size_t idx = 0; idx < count; idx++)
890 {
891 SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type);
892
893 if (found_at_idx.IsValid())
894 return found_at_idx;
895 }
896 }
897 return SBType();
898}
899
900lldb::SBTypeList
901SBTarget::FindTypes (const char* type)
902{
903
904 SBTypeList retval;
905
906 if (m_opaque_sp)
907 {
908 ModuleList& images = m_opaque_sp->GetImages();
909 ConstString name_const(type);
910 SymbolContext sc;
911 TypeList type_list;
912
913 uint32_t num_matches = images.FindTypes(sc,
914 name_const,
915 true,
916 UINT32_MAX,
917 type_list);
918
919 for (size_t idx = 0; idx < num_matches; idx++)
920 {
Greg Clayton0fb0bcc2011-08-03 22:57:10 +0000921 TypeSP type_sp (type_list.GetTypeAtIndex(idx));
922 if (type_sp)
923 retval.Append(SBType(type_sp));
Enrico Granata979e20d2011-07-29 19:53:35 +0000924 }
925 }
926 return retval;
927}
928
Greg Clayton917c0002011-06-29 22:09:02 +0000929SBValueList
930SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
931{
932 SBValueList sb_value_list;
933
934 if (m_opaque_sp)
935 {
936 VariableList variable_list;
937 const bool append = true;
938 const uint32_t match_count = m_opaque_sp->GetImages().FindGlobalVariables (ConstString (name),
939 append,
940 max_matches,
941 variable_list);
942
943 if (match_count > 0)
944 {
945 ExecutionContextScope *exe_scope = m_opaque_sp->GetProcessSP().get();
946 if (exe_scope == NULL)
947 exe_scope = m_opaque_sp.get();
948 ValueObjectList &value_object_list = sb_value_list.ref();
949 for (uint32_t i=0; i<match_count; ++i)
950 {
951 lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
952 if (valobj_sp)
953 value_object_list.Append(valobj_sp);
954 }
955 }
956 }
957
958 return sb_value_list;
959}
960