1 //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "lldb/API/SBTarget.h"
14 #include "lldb/lldb-public.h"
16 #include "lldb/API/SBDebugger.h"
17 #include "lldb/API/SBBreakpoint.h"
18 #include "lldb/API/SBExpressionOptions.h"
19 #include "lldb/API/SBFileSpec.h"
20 #include "lldb/API/SBListener.h"
21 #include "lldb/API/SBModule.h"
22 #include "lldb/API/SBModuleSpec.h"
23 #include "lldb/API/SBSourceManager.h"
24 #include "lldb/API/SBProcess.h"
25 #include "lldb/API/SBStream.h"
26 #include "lldb/API/SBSymbolContextList.h"
27 #include "lldb/Breakpoint/BreakpointID.h"
28 #include "lldb/Breakpoint/BreakpointIDList.h"
29 #include "lldb/Breakpoint/BreakpointList.h"
30 #include "lldb/Breakpoint/BreakpointLocation.h"
31 #include "lldb/Core/Address.h"
32 #include "lldb/Core/AddressResolver.h"
33 #include "lldb/Core/AddressResolverName.h"
34 #include "lldb/Core/ArchSpec.h"
35 #include "lldb/Core/Debugger.h"
36 #include "lldb/Core/Disassembler.h"
37 #include "lldb/Core/Log.h"
38 #include "lldb/Core/Module.h"
39 #include "lldb/Core/ModuleSpec.h"
40 #include "lldb/Core/RegularExpression.h"
41 #include "lldb/Core/SearchFilter.h"
42 #include "lldb/Core/Section.h"
43 #include "lldb/Core/STLUtils.h"
44 #include "lldb/Core/ValueObjectConstResult.h"
45 #include "lldb/Core/ValueObjectList.h"
46 #include "lldb/Core/ValueObjectVariable.h"
47 #include "lldb/Host/FileSpec.h"
48 #include "lldb/Host/Host.h"
49 #include "lldb/Interpreter/Args.h"
50 #include "lldb/Symbol/ObjectFile.h"
51 #include "lldb/Symbol/SymbolVendor.h"
52 #include "lldb/Symbol/VariableList.h"
53 #include "lldb/Target/LanguageRuntime.h"
54 #include "lldb/Target/Process.h"
56 #include "lldb/Target/Target.h"
57 #include "lldb/Target/TargetList.h"
59 #include "lldb/Interpreter/CommandReturnObject.h"
60 #include "../source/Commands/CommandObjectBreakpoint.h"
61 #include "llvm/Support/Regex.h"
65 using namespace lldb_private;
67 #define DEFAULT_DISASM_BYTE_SIZE 32
69 SBLaunchInfo::SBLaunchInfo (const char **argv) :
70 m_opaque_sp(new ProcessLaunchInfo())
72 m_opaque_sp->GetFlags().Reset (eLaunchFlagDebug | eLaunchFlagDisableASLR);
74 m_opaque_sp->GetArguments().SetArguments(argv);
77 SBLaunchInfo::~SBLaunchInfo()
81 lldb_private::ProcessLaunchInfo &
89 SBLaunchInfo::GetUserID()
91 return m_opaque_sp->GetUserID();
95 SBLaunchInfo::GetGroupID()
97 return m_opaque_sp->GetGroupID();
101 SBLaunchInfo::UserIDIsValid ()
103 return m_opaque_sp->UserIDIsValid();
107 SBLaunchInfo::GroupIDIsValid ()
109 return m_opaque_sp->GroupIDIsValid();
113 SBLaunchInfo::SetUserID (uint32_t uid)
115 m_opaque_sp->SetUserID (uid);
119 SBLaunchInfo::SetGroupID (uint32_t gid)
121 m_opaque_sp->SetGroupID (gid);
125 SBLaunchInfo::GetExecutableFile ()
127 return SBFileSpec (m_opaque_sp->GetExecutableFile());
131 SBLaunchInfo::SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg)
133 m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg);
137 SBLaunchInfo::GetListener ()
139 return SBListener(m_opaque_sp->GetListener());
143 SBLaunchInfo::SetListener (SBListener &listener)
145 m_opaque_sp->SetListener(listener.GetSP());
149 SBLaunchInfo::GetNumArguments ()
151 return m_opaque_sp->GetArguments().GetArgumentCount();
155 SBLaunchInfo::GetArgumentAtIndex (uint32_t idx)
157 return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx);
161 SBLaunchInfo::SetArguments (const char **argv, bool append)
166 m_opaque_sp->GetArguments().AppendArguments(argv);
171 m_opaque_sp->GetArguments().SetArguments(argv);
173 m_opaque_sp->GetArguments().Clear();
178 SBLaunchInfo::GetNumEnvironmentEntries ()
180 return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount();
184 SBLaunchInfo::GetEnvironmentEntryAtIndex (uint32_t idx)
186 return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx);
190 SBLaunchInfo::SetEnvironmentEntries (const char **envp, bool append)
195 m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp);
200 m_opaque_sp->GetEnvironmentEntries().SetArguments(envp);
202 m_opaque_sp->GetEnvironmentEntries().Clear();
207 SBLaunchInfo::Clear ()
209 m_opaque_sp->Clear();
213 SBLaunchInfo::GetWorkingDirectory () const
215 return m_opaque_sp->GetWorkingDirectory();
219 SBLaunchInfo::SetWorkingDirectory (const char *working_dir)
221 m_opaque_sp->SetWorkingDirectory(working_dir);
225 SBLaunchInfo::GetLaunchFlags ()
227 return m_opaque_sp->GetFlags().Get();
231 SBLaunchInfo::SetLaunchFlags (uint32_t flags)
233 m_opaque_sp->GetFlags().Reset(flags);
237 SBLaunchInfo::GetProcessPluginName ()
239 return m_opaque_sp->GetProcessPluginName();
243 SBLaunchInfo::SetProcessPluginName (const char *plugin_name)
245 return m_opaque_sp->SetProcessPluginName (plugin_name);
249 SBLaunchInfo::GetShell ()
251 // Constify this string so that it is saved in the string pool. Otherwise
252 // it would be freed when this function goes out of scope.
253 ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
254 return shell.AsCString();
258 SBLaunchInfo::SetShell (const char * path)
260 m_opaque_sp->SetShell (FileSpec(path, false));
264 SBLaunchInfo::GetResumeCount ()
266 return m_opaque_sp->GetResumeCount();
270 SBLaunchInfo::SetResumeCount (uint32_t c)
272 m_opaque_sp->SetResumeCount (c);
276 SBLaunchInfo::AddCloseFileAction (int fd)
278 return m_opaque_sp->AppendCloseFileAction(fd);
282 SBLaunchInfo::AddDuplicateFileAction (int fd, int dup_fd)
284 return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd);
288 SBLaunchInfo::AddOpenFileAction (int fd, const char *path, bool read, bool write)
290 return m_opaque_sp->AppendOpenFileAction(fd, path, read, write);
294 SBLaunchInfo::AddSuppressFileAction (int fd, bool read, bool write)
296 return m_opaque_sp->AppendSuppressFileAction(fd, read, write);
300 SBLaunchInfo::SetLaunchEventData (const char *data)
302 m_opaque_sp->SetLaunchEventData (data);
306 SBLaunchInfo::GetLaunchEventData () const
308 return m_opaque_sp->GetLaunchEventData ();
312 SBLaunchInfo::SetDetachOnError (bool enable)
314 m_opaque_sp->SetDetachOnError (enable);
318 SBLaunchInfo::GetDetachOnError () const
320 return m_opaque_sp->GetDetachOnError ();
323 SBAttachInfo::SBAttachInfo () :
324 m_opaque_sp (new ProcessAttachInfo())
328 SBAttachInfo::SBAttachInfo (lldb::pid_t pid) :
329 m_opaque_sp (new ProcessAttachInfo())
331 m_opaque_sp->SetProcessID (pid);
334 SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) :
335 m_opaque_sp (new ProcessAttachInfo())
338 m_opaque_sp->GetExecutableFile().SetFile(path, false);
339 m_opaque_sp->SetWaitForLaunch (wait_for);
342 SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) :
343 m_opaque_sp (new ProcessAttachInfo())
345 *m_opaque_sp = *rhs.m_opaque_sp;
348 SBAttachInfo::~SBAttachInfo()
352 lldb_private::ProcessAttachInfo &
359 SBAttachInfo::operator = (const SBAttachInfo &rhs)
362 *m_opaque_sp = *rhs.m_opaque_sp;
367 SBAttachInfo::GetProcessID ()
369 return m_opaque_sp->GetProcessID();
373 SBAttachInfo::SetProcessID (lldb::pid_t pid)
375 m_opaque_sp->SetProcessID (pid);
380 SBAttachInfo::GetResumeCount ()
382 return m_opaque_sp->GetResumeCount();
386 SBAttachInfo::SetResumeCount (uint32_t c)
388 m_opaque_sp->SetResumeCount (c);
392 SBAttachInfo::GetProcessPluginName ()
394 return m_opaque_sp->GetProcessPluginName();
398 SBAttachInfo::SetProcessPluginName (const char *plugin_name)
400 return m_opaque_sp->SetProcessPluginName (plugin_name);
404 SBAttachInfo::SetExecutable (const char *path)
407 m_opaque_sp->GetExecutableFile().SetFile(path, false);
409 m_opaque_sp->GetExecutableFile().Clear();
413 SBAttachInfo::SetExecutable (SBFileSpec exe_file)
415 if (exe_file.IsValid())
416 m_opaque_sp->GetExecutableFile() = exe_file.ref();
418 m_opaque_sp->GetExecutableFile().Clear();
422 SBAttachInfo::GetWaitForLaunch ()
424 return m_opaque_sp->GetWaitForLaunch();
428 SBAttachInfo::SetWaitForLaunch (bool b)
430 m_opaque_sp->SetWaitForLaunch (b);
434 SBAttachInfo::GetIgnoreExisting ()
436 return m_opaque_sp->GetIgnoreExisting();
440 SBAttachInfo::SetIgnoreExisting (bool b)
442 m_opaque_sp->SetIgnoreExisting (b);
446 SBAttachInfo::GetUserID()
448 return m_opaque_sp->GetUserID();
452 SBAttachInfo::GetGroupID()
454 return m_opaque_sp->GetGroupID();
458 SBAttachInfo::UserIDIsValid ()
460 return m_opaque_sp->UserIDIsValid();
464 SBAttachInfo::GroupIDIsValid ()
466 return m_opaque_sp->GroupIDIsValid();
470 SBAttachInfo::SetUserID (uint32_t uid)
472 m_opaque_sp->SetUserID (uid);
476 SBAttachInfo::SetGroupID (uint32_t gid)
478 m_opaque_sp->SetGroupID (gid);
482 SBAttachInfo::GetEffectiveUserID()
484 return m_opaque_sp->GetEffectiveUserID();
488 SBAttachInfo::GetEffectiveGroupID()
490 return m_opaque_sp->GetEffectiveGroupID();
494 SBAttachInfo::EffectiveUserIDIsValid ()
496 return m_opaque_sp->EffectiveUserIDIsValid();
500 SBAttachInfo::EffectiveGroupIDIsValid ()
502 return m_opaque_sp->EffectiveGroupIDIsValid ();
506 SBAttachInfo::SetEffectiveUserID (uint32_t uid)
508 m_opaque_sp->SetEffectiveUserID(uid);
512 SBAttachInfo::SetEffectiveGroupID (uint32_t gid)
514 m_opaque_sp->SetEffectiveGroupID(gid);
518 SBAttachInfo::GetParentProcessID ()
520 return m_opaque_sp->GetParentProcessID();
524 SBAttachInfo::SetParentProcessID (lldb::pid_t pid)
526 m_opaque_sp->SetParentProcessID (pid);
530 SBAttachInfo::ParentProcessIDIsValid()
532 return m_opaque_sp->ParentProcessIDIsValid();
536 SBAttachInfo::GetListener ()
538 return SBListener(m_opaque_sp->GetListener());
542 SBAttachInfo::SetListener (SBListener &listener)
544 m_opaque_sp->SetListener(listener.GetSP());
547 //----------------------------------------------------------------------
548 // SBTarget constructor
549 //----------------------------------------------------------------------
550 SBTarget::SBTarget () :
555 SBTarget::SBTarget (const SBTarget& rhs) :
556 m_opaque_sp (rhs.m_opaque_sp)
560 SBTarget::SBTarget(const TargetSP& target_sp) :
561 m_opaque_sp (target_sp)
566 SBTarget::operator = (const SBTarget& rhs)
569 m_opaque_sp = rhs.m_opaque_sp;
573 //----------------------------------------------------------------------
575 //----------------------------------------------------------------------
576 SBTarget::~SBTarget()
581 SBTarget::GetBroadcasterClassName ()
583 return Target::GetStaticBroadcasterClass().AsCString();
587 SBTarget::IsValid () const
589 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
593 SBTarget::GetProcess ()
595 SBProcess sb_process;
596 ProcessSP process_sp;
597 TargetSP target_sp(GetSP());
600 process_sp = target_sp->GetProcessSP();
601 sb_process.SetSP (process_sp);
604 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
606 log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
607 static_cast<void*>(target_sp.get()),
608 static_cast<void*>(process_sp.get()));
614 SBTarget::GetPlatform ()
616 TargetSP target_sp(GetSP());
621 platform.m_opaque_sp = target_sp->GetPlatform();
627 SBTarget::GetDebugger () const
630 TargetSP target_sp(GetSP());
632 debugger.reset (target_sp->GetDebugger().shared_from_this());
637 SBTarget::LoadCore (const char *core_file)
639 SBProcess sb_process;
640 TargetSP target_sp(GetSP());
643 FileSpec filespec(core_file, true);
644 ProcessSP process_sp (target_sp->CreateProcess(target_sp->GetDebugger().GetListener(),
649 process_sp->LoadCore();
650 sb_process.SetSP (process_sp);
657 SBTarget::LaunchSimple
661 const char *working_directory
664 char *stdin_path = NULL;
665 char *stdout_path = NULL;
666 char *stderr_path = NULL;
667 uint32_t launch_flags = 0;
668 bool stop_at_entry = false;
670 SBListener listener = GetDebugger().GetListener();
671 return Launch (listener,
687 TargetSP target_sp(GetSP());
690 Mutex::Locker api_locker (target_sp->GetAPIMutex());
691 sb_error.ref() = target_sp->Install(NULL);
699 SBListener &listener,
702 const char *stdin_path,
703 const char *stdout_path,
704 const char *stderr_path,
705 const char *working_directory,
706 uint32_t launch_flags, // See LaunchFlags
711 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
713 SBProcess sb_process;
714 ProcessSP process_sp;
715 TargetSP target_sp(GetSP());
718 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))...",
719 static_cast<void*>(target_sp.get()),
720 static_cast<void*>(argv), static_cast<void*>(envp),
721 stdin_path ? stdin_path : "NULL",
722 stdout_path ? stdout_path : "NULL",
723 stderr_path ? stderr_path : "NULL",
724 working_directory ? working_directory : "NULL",
725 launch_flags, stop_at_entry,
726 static_cast<void*>(error.get()));
730 Mutex::Locker api_locker (target_sp->GetAPIMutex());
732 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
733 launch_flags |= eLaunchFlagDisableASLR;
735 StateType state = eStateInvalid;
736 process_sp = target_sp->GetProcessSP();
739 state = process_sp->GetState();
741 if (process_sp->IsAlive() && state != eStateConnected)
743 if (state == eStateAttaching)
744 error.SetErrorString ("process attach is in progress");
746 error.SetErrorString ("a process is already being debugged");
751 if (state == eStateConnected)
753 // If we are already connected, then we have already specified the
754 // listener, so if a valid listener is supplied, we need to error out
755 // to let the client know.
756 if (listener.IsValid())
758 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
763 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
764 launch_flags |= eLaunchFlagDisableSTDIO;
766 ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags);
768 Module *exe_module = target_sp->GetExecutableModulePointer();
770 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
772 launch_info.GetArguments().AppendArguments (argv);
774 launch_info.GetEnvironmentEntries ().SetArguments (envp);
776 if (listener.IsValid())
777 launch_info.SetListener(listener.GetSP());
779 error.SetError (target_sp->Launch(launch_info, NULL));
781 sb_process.SetSP(target_sp->GetProcessSP());
785 error.SetErrorString ("SBTarget is invalid");
788 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
790 log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)",
791 static_cast<void*>(target_sp.get()),
792 static_cast<void*>(sb_process.GetSP().get()));
798 SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
800 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
802 SBProcess sb_process;
803 TargetSP target_sp(GetSP());
806 log->Printf ("SBTarget(%p)::Launch (launch_info, error)...",
807 static_cast<void*>(target_sp.get()));
811 Mutex::Locker api_locker (target_sp->GetAPIMutex());
812 StateType state = eStateInvalid;
814 ProcessSP process_sp = target_sp->GetProcessSP();
817 state = process_sp->GetState();
819 if (process_sp->IsAlive() && state != eStateConnected)
821 if (state == eStateAttaching)
822 error.SetErrorString ("process attach is in progress");
824 error.SetErrorString ("a process is already being debugged");
830 lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
832 if (!launch_info.GetExecutableFile())
834 Module *exe_module = target_sp->GetExecutableModulePointer();
836 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
839 const ArchSpec &arch_spec = target_sp->GetArchitecture();
840 if (arch_spec.IsValid())
841 launch_info.GetArchitecture () = arch_spec;
843 error.SetError (target_sp->Launch (launch_info, NULL));
844 sb_process.SetSP(target_sp->GetProcessSP());
848 error.SetErrorString ("SBTarget is invalid");
851 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
853 log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)",
854 static_cast<void*>(target_sp.get()),
855 static_cast<void*>(sb_process.GetSP().get()));
861 SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error)
863 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
865 SBProcess sb_process;
866 ProcessSP process_sp;
867 TargetSP target_sp(GetSP());
870 log->Printf ("SBTarget(%p)::Attach (sb_attach_info, error)...",
871 static_cast<void*>(target_sp.get()));
875 Mutex::Locker api_locker (target_sp->GetAPIMutex());
877 StateType state = eStateInvalid;
878 process_sp = target_sp->GetProcessSP();
881 state = process_sp->GetState();
883 if (process_sp->IsAlive() && state != eStateConnected)
885 if (state == eStateAttaching)
886 error.SetErrorString ("process attach is in progress");
888 error.SetErrorString ("a process is already being debugged");
890 log->Printf ("SBTarget(%p)::Attach (...) => error %s",
891 static_cast<void*>(target_sp.get()),
897 if (state != eStateConnected)
898 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL);
902 ProcessAttachInfo &attach_info = sb_attach_info.ref();
903 if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid())
905 PlatformSP platform_sp = target_sp->GetPlatform();
906 // See if we can pre-verify if a process exists or not
907 if (platform_sp && platform_sp->IsConnected())
909 lldb::pid_t attach_pid = attach_info.GetProcessID();
910 ProcessInstanceInfo instance_info;
911 if (platform_sp->GetProcessInfo(attach_pid, instance_info))
913 attach_info.SetUserID(instance_info.GetEffectiveUserID());
917 error.ref().SetErrorStringWithFormat("no process found with process ID %" PRIu64, attach_pid);
920 log->Printf ("SBTarget(%p)::Attach (...) => error %s",
921 static_cast<void*>(target_sp.get()), error.GetCString());
927 error.SetError (process_sp->Attach (attach_info));
930 sb_process.SetSP (process_sp);
931 // If we are doing synchronous mode, then wait for the
933 if (target_sp->GetDebugger().GetAsyncExecution () == false)
934 process_sp->WaitForProcessToStop (NULL);
939 error.SetErrorString ("unable to create lldb_private::Process");
944 error.SetErrorString ("SBTarget is invalid");
948 log->Printf ("SBTarget(%p)::Attach (...) => SBProcess(%p)",
949 static_cast<void*>(target_sp.get()),
950 static_cast<void*>(process_sp.get()));
956 #if defined(__APPLE__)
959 SBTarget::AttachToProcessWithID (SBListener &listener,
961 lldb::SBError& error)
963 return AttachToProcessWithID (listener, (lldb::pid_t)pid, error);
966 #endif // #if defined(__APPLE__)
969 SBTarget::AttachToProcessWithID
971 SBListener &listener,
972 lldb::pid_t pid,// The process ID to attach to
973 SBError& error // An error explaining what went wrong if attach fails
976 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
978 SBProcess sb_process;
979 ProcessSP process_sp;
980 TargetSP target_sp(GetSP());
983 log->Printf ("SBTarget(%p)::AttachToProcessWithID (listener, pid=%" PRId64 ", error)...",
984 static_cast<void*>(target_sp.get()), pid);
988 Mutex::Locker api_locker (target_sp->GetAPIMutex());
990 StateType state = eStateInvalid;
991 process_sp = target_sp->GetProcessSP();
994 state = process_sp->GetState();
996 if (process_sp->IsAlive() && state != eStateConnected)
998 if (state == eStateAttaching)
999 error.SetErrorString ("process attach is in progress");
1001 error.SetErrorString ("a process is already being debugged");
1006 if (state == eStateConnected)
1008 // If we are already connected, then we have already specified the
1009 // listener, so if a valid listener is supplied, we need to error out
1010 // to let the client know.
1011 if (listener.IsValid())
1013 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
1019 if (listener.IsValid())
1020 process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL);
1022 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL);
1026 sb_process.SetSP (process_sp);
1028 ProcessAttachInfo attach_info;
1029 attach_info.SetProcessID (pid);
1031 PlatformSP platform_sp = target_sp->GetPlatform();
1032 ProcessInstanceInfo instance_info;
1033 if (platform_sp->GetProcessInfo(pid, instance_info))
1035 attach_info.SetUserID(instance_info.GetEffectiveUserID());
1037 error.SetError (process_sp->Attach (attach_info));
1038 if (error.Success())
1040 // If we are doing synchronous mode, then wait for the
1042 if (target_sp->GetDebugger().GetAsyncExecution () == false)
1043 process_sp->WaitForProcessToStop (NULL);
1048 error.SetErrorString ("unable to create lldb_private::Process");
1053 error.SetErrorString ("SBTarget is invalid");
1057 log->Printf ("SBTarget(%p)::AttachToProcessWithID (...) => SBProcess(%p)",
1058 static_cast<void*>(target_sp.get()),
1059 static_cast<void*>(process_sp.get()));
1064 SBTarget::AttachToProcessWithName
1066 SBListener &listener,
1067 const char *name, // basename of process to attach to
1068 bool wait_for, // if true wait for a new instance of "name" to be launched
1069 SBError& error // An error explaining what went wrong if attach fails
1072 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1074 SBProcess sb_process;
1075 ProcessSP process_sp;
1076 TargetSP target_sp(GetSP());
1079 log->Printf ("SBTarget(%p)::AttachToProcessWithName (listener, name=%s, wait_for=%s, error)...",
1080 static_cast<void*>(target_sp.get()), name,
1081 wait_for ? "true" : "false");
1083 if (name && target_sp)
1085 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1087 StateType state = eStateInvalid;
1088 process_sp = target_sp->GetProcessSP();
1091 state = process_sp->GetState();
1093 if (process_sp->IsAlive() && state != eStateConnected)
1095 if (state == eStateAttaching)
1096 error.SetErrorString ("process attach is in progress");
1098 error.SetErrorString ("a process is already being debugged");
1103 if (state == eStateConnected)
1105 // If we are already connected, then we have already specified the
1106 // listener, so if a valid listener is supplied, we need to error out
1107 // to let the client know.
1108 if (listener.IsValid())
1110 error.SetErrorString ("process is connected and already has a listener, pass empty listener");
1116 if (listener.IsValid())
1117 process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL);
1119 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL);
1124 sb_process.SetSP (process_sp);
1125 ProcessAttachInfo attach_info;
1126 attach_info.GetExecutableFile().SetFile(name, false);
1127 attach_info.SetWaitForLaunch(wait_for);
1128 error.SetError (process_sp->Attach (attach_info));
1129 if (error.Success())
1131 // If we are doing synchronous mode, then wait for the
1133 if (target_sp->GetDebugger().GetAsyncExecution () == false)
1134 process_sp->WaitForProcessToStop (NULL);
1139 error.SetErrorString ("unable to create lldb_private::Process");
1144 error.SetErrorString ("SBTarget is invalid");
1148 log->Printf ("SBTarget(%p)::AttachToPorcessWithName (...) => SBProcess(%p)",
1149 static_cast<void*>(target_sp.get()),
1150 static_cast<void*>(process_sp.get()));
1155 SBTarget::ConnectRemote
1157 SBListener &listener,
1159 const char *plugin_name,
1163 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1165 SBProcess sb_process;
1166 ProcessSP process_sp;
1167 TargetSP target_sp(GetSP());
1170 log->Printf ("SBTarget(%p)::ConnectRemote (listener, url=%s, plugin_name=%s, error)...",
1171 static_cast<void*>(target_sp.get()), url, plugin_name);
1175 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1176 if (listener.IsValid())
1177 process_sp = target_sp->CreateProcess (listener.ref(), plugin_name, NULL);
1179 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name, NULL);
1183 sb_process.SetSP (process_sp);
1184 error.SetError (process_sp->ConnectRemote (NULL, url));
1188 error.SetErrorString ("unable to create lldb_private::Process");
1193 error.SetErrorString ("SBTarget is invalid");
1197 log->Printf ("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
1198 static_cast<void*>(target_sp.get()),
1199 static_cast<void*>(process_sp.get()));
1204 SBTarget::GetExecutable ()
1207 SBFileSpec exe_file_spec;
1208 TargetSP target_sp(GetSP());
1211 Module *exe_module = target_sp->GetExecutableModulePointer();
1213 exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
1216 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1219 log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
1220 static_cast<void*>(target_sp.get()),
1221 static_cast<const void*>(exe_file_spec.get()));
1224 return exe_file_spec;
1228 SBTarget::operator == (const SBTarget &rhs) const
1230 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
1234 SBTarget::operator != (const SBTarget &rhs) const
1236 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
1240 SBTarget::GetSP () const
1246 SBTarget::SetSP (const lldb::TargetSP& target_sp)
1248 m_opaque_sp = target_sp;
1252 SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
1254 lldb::SBAddress sb_addr;
1255 Address &addr = sb_addr.ref();
1256 TargetSP target_sp(GetSP());
1259 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1260 if (target_sp->ResolveLoadAddress (vm_addr, addr))
1264 // We have a load address that isn't in a section, just return an address
1265 // with the offset filled in (the address) and the section set to NULL
1266 addr.SetRawAddress(vm_addr);
1271 SBTarget::ResolveFileAddress (lldb::addr_t file_addr)
1273 lldb::SBAddress sb_addr;
1274 Address &addr = sb_addr.ref();
1275 TargetSP target_sp(GetSP());
1278 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1279 if (target_sp->ResolveFileAddress (file_addr, addr))
1283 addr.SetRawAddress(file_addr);
1288 SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr)
1290 lldb::SBAddress sb_addr;
1291 Address &addr = sb_addr.ref();
1292 TargetSP target_sp(GetSP());
1295 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1296 if (target_sp->ResolveLoadAddress (vm_addr, addr))
1300 // We have a load address that isn't in a section, just return an address
1301 // with the offset filled in (the address) and the section set to NULL
1302 addr.SetRawAddress(vm_addr);
1307 SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr,
1308 uint32_t resolve_scope)
1313 TargetSP target_sp(GetSP());
1315 target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
1321 SBTarget::ReadMemory (const SBAddress addr,
1324 lldb::SBError &error)
1327 size_t bytes_read = 0;
1328 TargetSP target_sp(GetSP());
1331 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1332 bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
1336 sb_error.SetErrorString("invalid target");
1343 SBTarget::BreakpointCreateByLocation (const char *file,
1346 return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
1350 SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
1353 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1356 TargetSP target_sp(GetSP());
1357 if (target_sp && line != 0)
1359 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1361 const LazyBool check_inlines = eLazyBoolCalculate;
1362 const LazyBool skip_prologue = eLazyBoolCalculate;
1363 const bool internal = false;
1364 const bool hardware = false;
1365 *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal, hardware);
1371 sb_bp.GetDescription (sstr);
1372 char path[PATH_MAX];
1373 sb_file_spec->GetPath (path, sizeof(path));
1374 log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s",
1375 static_cast<void*>(target_sp.get()), path, line,
1376 static_cast<void*>(sb_bp.get()), sstr.GetData());
1383 SBTarget::BreakpointCreateByName (const char *symbol_name,
1384 const char *module_name)
1386 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1389 TargetSP target_sp(GetSP());
1390 if (target_sp.get())
1392 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1394 const bool internal = false;
1395 const bool hardware = false;
1396 const LazyBool skip_prologue = eLazyBoolCalculate;
1397 if (module_name && module_name[0])
1399 FileSpecList module_spec_list;
1400 module_spec_list.Append (FileSpec (module_name, false));
1401 *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
1405 *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
1410 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)",
1411 static_cast<void*>(target_sp.get()), symbol_name,
1412 module_name, static_cast<void*>(sb_bp.get()));
1418 SBTarget::BreakpointCreateByName (const char *symbol_name,
1419 const SBFileSpecList &module_list,
1420 const SBFileSpecList &comp_unit_list)
1422 uint32_t name_type_mask = eFunctionNameTypeAuto;
1423 return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list);
1427 SBTarget::BreakpointCreateByName (const char *symbol_name,
1428 uint32_t name_type_mask,
1429 const SBFileSpecList &module_list,
1430 const SBFileSpecList &comp_unit_list)
1432 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1435 TargetSP target_sp(GetSP());
1436 if (target_sp && symbol_name && symbol_name[0])
1438 const bool internal = false;
1439 const bool hardware = false;
1440 const LazyBool skip_prologue = eLazyBoolCalculate;
1441 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1442 *sb_bp = target_sp->CreateBreakpoint (module_list.get(),
1443 comp_unit_list.get(),
1452 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)",
1453 static_cast<void*>(target_sp.get()), symbol_name,
1454 name_type_mask, static_cast<void*>(sb_bp.get()));
1460 SBTarget::BreakpointCreateByNames (const char *symbol_names[],
1462 uint32_t name_type_mask,
1463 const SBFileSpecList &module_list,
1464 const SBFileSpecList &comp_unit_list)
1466 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1469 TargetSP target_sp(GetSP());
1470 if (target_sp && num_names > 0)
1472 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1473 const bool internal = false;
1474 const bool hardware = false;
1475 const LazyBool skip_prologue = eLazyBoolCalculate;
1476 *sb_bp = target_sp->CreateBreakpoint (module_list.get(),
1477 comp_unit_list.get(),
1488 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbols={",
1489 static_cast<void*>(target_sp.get()));
1490 for (uint32_t i = 0 ; i < num_names; i++)
1493 if (i < num_names - 1)
1497 if (symbol_names[i] != NULL)
1498 log->Printf ("\"%s\"%c ", symbol_names[i], sep);
1500 log->Printf ("\"<NULL>\"%c ", sep);
1502 log->Printf ("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
1503 static_cast<void*>(sb_bp.get()));
1510 SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
1511 const char *module_name)
1513 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1516 TargetSP target_sp(GetSP());
1517 if (target_sp && symbol_name_regex && symbol_name_regex[0])
1519 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1520 RegularExpression regexp(symbol_name_regex);
1521 const bool internal = false;
1522 const bool hardware = false;
1523 const LazyBool skip_prologue = eLazyBoolCalculate;
1525 if (module_name && module_name[0])
1527 FileSpecList module_spec_list;
1528 module_spec_list.Append (FileSpec (module_name, false));
1530 *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal, hardware);
1534 *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal, hardware);
1539 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
1540 static_cast<void*>(target_sp.get()), symbol_name_regex,
1541 module_name, static_cast<void*>(sb_bp.get()));
1547 SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
1548 const SBFileSpecList &module_list,
1549 const SBFileSpecList &comp_unit_list)
1551 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1554 TargetSP target_sp(GetSP());
1555 if (target_sp && symbol_name_regex && symbol_name_regex[0])
1557 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1558 RegularExpression regexp(symbol_name_regex);
1559 const bool internal = false;
1560 const bool hardware = false;
1561 const LazyBool skip_prologue = eLazyBoolCalculate;
1563 *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal, hardware);
1567 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
1568 static_cast<void*>(target_sp.get()), symbol_name_regex,
1569 static_cast<void*>(sb_bp.get()));
1575 SBTarget::BreakpointCreateByAddress (addr_t address)
1577 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1580 TargetSP target_sp(GetSP());
1583 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1584 const bool hardware = false;
1585 *sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
1589 log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)",
1590 static_cast<void*>(target_sp.get()),
1591 static_cast<uint64_t>(address),
1592 static_cast<void*>(sb_bp.get()));
1598 SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
1599 const lldb::SBFileSpec &source_file,
1600 const char *module_name)
1602 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1605 TargetSP target_sp(GetSP());
1606 if (target_sp && source_regex && source_regex[0])
1608 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1609 RegularExpression regexp(source_regex);
1610 FileSpecList source_file_spec_list;
1611 const bool hardware = false;
1612 source_file_spec_list.Append (source_file.ref());
1614 if (module_name && module_name[0])
1616 FileSpecList module_spec_list;
1617 module_spec_list.Append (FileSpec (module_name, false));
1619 *sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false, hardware);
1623 *sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false, hardware);
1629 char path[PATH_MAX];
1630 source_file->GetPath (path, sizeof(path));
1631 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
1632 static_cast<void*>(target_sp.get()), source_regex, path,
1633 module_name, static_cast<void*>(sb_bp.get()));
1640 SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
1641 const SBFileSpecList &module_list,
1642 const lldb::SBFileSpecList &source_file_list)
1644 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1647 TargetSP target_sp(GetSP());
1648 if (target_sp && source_regex && source_regex[0])
1650 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1651 const bool hardware = false;
1652 RegularExpression regexp(source_regex);
1653 *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false, hardware);
1657 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)",
1658 static_cast<void*>(target_sp.get()), source_regex,
1659 static_cast<void*>(sb_bp.get()));
1665 SBTarget::BreakpointCreateForException (lldb::LanguageType language,
1669 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1672 TargetSP target_sp(GetSP());
1675 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1676 const bool hardware = false;
1677 *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware);
1681 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)",
1682 static_cast<void*>(target_sp.get()),
1683 LanguageRuntime::GetNameForLanguageType(language),
1684 catch_bp ? "on" : "off", throw_bp ? "on" : "off",
1685 static_cast<void*>(sb_bp.get()));
1691 SBTarget::GetNumBreakpoints () const
1693 TargetSP target_sp(GetSP());
1696 // The breakpoint list is thread safe, no need to lock
1697 return target_sp->GetBreakpointList().GetSize();
1703 SBTarget::GetBreakpointAtIndex (uint32_t idx) const
1705 SBBreakpoint sb_breakpoint;
1706 TargetSP target_sp(GetSP());
1709 // The breakpoint list is thread safe, no need to lock
1710 *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1712 return sb_breakpoint;
1716 SBTarget::BreakpointDelete (break_id_t bp_id)
1718 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1720 bool result = false;
1721 TargetSP target_sp(GetSP());
1724 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1725 result = target_sp->RemoveBreakpointByID (bp_id);
1729 log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
1730 static_cast<void*>(target_sp.get()),
1731 static_cast<uint32_t>(bp_id), result);
1737 SBTarget::FindBreakpointByID (break_id_t bp_id)
1739 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1741 SBBreakpoint sb_breakpoint;
1742 TargetSP target_sp(GetSP());
1743 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID)
1745 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1746 *sb_breakpoint = target_sp->GetBreakpointByID (bp_id);
1750 log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
1751 static_cast<void*>(target_sp.get()),
1752 static_cast<uint32_t>(bp_id),
1753 static_cast<void*>(sb_breakpoint.get()));
1755 return sb_breakpoint;
1759 SBTarget::EnableAllBreakpoints ()
1761 TargetSP target_sp(GetSP());
1764 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1765 target_sp->EnableAllBreakpoints ();
1772 SBTarget::DisableAllBreakpoints ()
1774 TargetSP target_sp(GetSP());
1777 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1778 target_sp->DisableAllBreakpoints ();
1785 SBTarget::DeleteAllBreakpoints ()
1787 TargetSP target_sp(GetSP());
1790 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1791 target_sp->RemoveAllBreakpoints ();
1798 SBTarget::GetNumWatchpoints () const
1800 TargetSP target_sp(GetSP());
1803 // The watchpoint list is thread safe, no need to lock
1804 return target_sp->GetWatchpointList().GetSize();
1810 SBTarget::GetWatchpointAtIndex (uint32_t idx) const
1812 SBWatchpoint sb_watchpoint;
1813 TargetSP target_sp(GetSP());
1816 // The watchpoint list is thread safe, no need to lock
1817 sb_watchpoint.SetSP (target_sp->GetWatchpointList().GetByIndex(idx));
1819 return sb_watchpoint;
1823 SBTarget::DeleteWatchpoint (watch_id_t wp_id)
1825 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1827 bool result = false;
1828 TargetSP target_sp(GetSP());
1831 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1832 Mutex::Locker locker;
1833 target_sp->GetWatchpointList().GetListMutex(locker);
1834 result = target_sp->RemoveWatchpointByID (wp_id);
1838 log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
1839 static_cast<void*>(target_sp.get()),
1840 static_cast<uint32_t>(wp_id), result);
1846 SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
1848 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1850 SBWatchpoint sb_watchpoint;
1851 lldb::WatchpointSP watchpoint_sp;
1852 TargetSP target_sp(GetSP());
1853 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
1855 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1856 Mutex::Locker locker;
1857 target_sp->GetWatchpointList().GetListMutex(locker);
1858 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1859 sb_watchpoint.SetSP (watchpoint_sp);
1863 log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
1864 static_cast<void*>(target_sp.get()),
1865 static_cast<uint32_t>(wp_id),
1866 static_cast<void*>(watchpoint_sp.get()));
1868 return sb_watchpoint;
1872 SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
1874 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1876 SBWatchpoint sb_watchpoint;
1877 lldb::WatchpointSP watchpoint_sp;
1878 TargetSP target_sp(GetSP());
1879 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0)
1881 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1882 uint32_t watch_type = 0;
1884 watch_type |= LLDB_WATCH_TYPE_READ;
1886 watch_type |= LLDB_WATCH_TYPE_WRITE;
1887 if (watch_type == 0)
1889 error.SetErrorString("Can't create a watchpoint that is neither read nor write.");
1890 return sb_watchpoint;
1893 // Target::CreateWatchpoint() is thread safe.
1895 // This API doesn't take in a type, so we can't figure out what it is.
1896 ClangASTType *type = NULL;
1897 watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1898 error.SetError(cw_error);
1899 sb_watchpoint.SetSP (watchpoint_sp);
1903 log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64 ", 0x%u) => SBWatchpoint(%p)",
1904 static_cast<void*>(target_sp.get()), addr,
1905 static_cast<uint32_t>(size),
1906 static_cast<void*>(watchpoint_sp.get()));
1908 return sb_watchpoint;
1912 SBTarget::EnableAllWatchpoints ()
1914 TargetSP target_sp(GetSP());
1917 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1918 Mutex::Locker locker;
1919 target_sp->GetWatchpointList().GetListMutex(locker);
1920 target_sp->EnableAllWatchpoints ();
1927 SBTarget::DisableAllWatchpoints ()
1929 TargetSP target_sp(GetSP());
1932 Mutex::Locker api_locker (target_sp->GetAPIMutex());
1933 Mutex::Locker locker;
1934 target_sp->GetWatchpointList().GetListMutex(locker);
1935 target_sp->DisableAllWatchpoints ();
1942 SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
1945 lldb::ValueObjectSP new_value_sp;
1946 if (IsValid() && name && *name && addr.IsValid() && type.IsValid())
1948 lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1949 ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
1950 ClangASTType ast_type(type.GetSP()->GetClangASTType(true));
1951 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, exe_ctx, ast_type);
1953 sb_value.SetSP(new_value_sp);
1954 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1958 log->Printf ("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
1959 static_cast<void*>(m_opaque_sp.get()),
1960 new_value_sp->GetName().AsCString());
1962 log->Printf ("SBTarget(%p)::CreateValueFromAddress => NULL",
1963 static_cast<void*>(m_opaque_sp.get()));
1969 SBTarget::CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type)
1972 lldb::ValueObjectSP new_value_sp;
1973 if (IsValid() && name && *name && data.IsValid() && type.IsValid())
1975 DataExtractorSP extractor(*data);
1976 ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
1977 ClangASTType ast_type(type.GetSP()->GetClangASTType(true));
1978 new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, exe_ctx, ast_type);
1980 sb_value.SetSP(new_value_sp);
1981 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1985 log->Printf ("SBTarget(%p)::CreateValueFromData => \"%s\"",
1986 static_cast<void*>(m_opaque_sp.get()),
1987 new_value_sp->GetName().AsCString());
1989 log->Printf ("SBTarget(%p)::CreateValueFromData => NULL",
1990 static_cast<void*>(m_opaque_sp.get()));
1996 SBTarget::CreateValueFromExpression (const char *name, const char* expr)
1999 lldb::ValueObjectSP new_value_sp;
2000 if (IsValid() && name && *name && expr && *expr)
2002 ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
2003 new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
2005 sb_value.SetSP(new_value_sp);
2006 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
2010 log->Printf ("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
2011 static_cast<void*>(m_opaque_sp.get()),
2012 new_value_sp->GetName().AsCString());
2014 log->Printf ("SBTarget(%p)::CreateValueFromExpression => NULL",
2015 static_cast<void*>(m_opaque_sp.get()));
2021 SBTarget::DeleteAllWatchpoints ()
2023 TargetSP target_sp(GetSP());
2026 Mutex::Locker api_locker (target_sp->GetAPIMutex());
2027 Mutex::Locker locker;
2028 target_sp->GetWatchpointList().GetListMutex(locker);
2029 target_sp->RemoveAllWatchpoints ();
2037 SBTarget::AddModule (const char *path,
2039 const char *uuid_cstr)
2041 return AddModule (path, triple, uuid_cstr, NULL);
2045 SBTarget::AddModule (const char *path,
2047 const char *uuid_cstr,
2048 const char *symfile)
2050 lldb::SBModule sb_module;
2051 TargetSP target_sp(GetSP());
2054 ModuleSpec module_spec;
2056 module_spec.GetFileSpec().SetFile(path, false);
2059 module_spec.GetUUID().SetFromCString(uuid_cstr);
2062 module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get());
2064 module_spec.GetArchitecture() = target_sp->GetArchitecture();
2067 module_spec.GetSymbolFileSpec ().SetFile(symfile, false);
2069 sb_module.SetSP(target_sp->GetSharedModule (module_spec));
2075 SBTarget::AddModule (const SBModuleSpec &module_spec)
2077 lldb::SBModule sb_module;
2078 TargetSP target_sp(GetSP());
2080 sb_module.SetSP(target_sp->GetSharedModule (*module_spec.m_opaque_ap));
2085 SBTarget::AddModule (lldb::SBModule &module)
2087 TargetSP target_sp(GetSP());
2090 target_sp->GetImages().AppendIfNeeded (module.GetSP());
2097 SBTarget::GetNumModules () const
2099 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
2102 TargetSP target_sp(GetSP());
2105 // The module list is thread safe, no need to lock
2106 num = target_sp->GetImages().GetSize();
2110 log->Printf ("SBTarget(%p)::GetNumModules () => %d",
2111 static_cast<void*>(target_sp.get()), num);
2119 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
2122 log->Printf ("SBTarget(%p)::Clear ()",
2123 static_cast<void*>(m_opaque_sp.get()));
2125 m_opaque_sp.reset();
2130 SBTarget::FindModule (const SBFileSpec &sb_file_spec)
2133 TargetSP target_sp(GetSP());
2134 if (target_sp && sb_file_spec.IsValid())
2136 ModuleSpec module_spec(*sb_file_spec);
2137 // The module list is thread safe, no need to lock
2138 sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec));
2144 SBTarget::GetByteOrder ()
2146 TargetSP target_sp(GetSP());
2148 return target_sp->GetArchitecture().GetByteOrder();
2149 return eByteOrderInvalid;
2153 SBTarget::GetTriple ()
2155 TargetSP target_sp(GetSP());
2158 std::string triple (target_sp->GetArchitecture().GetTriple().str());
2159 // Unique the string so we don't run into ownership issues since
2160 // the const strings put the string into the string pool once and
2161 // the strings never comes out
2162 ConstString const_triple (triple.c_str());
2163 return const_triple.GetCString();
2169 SBTarget::GetDataByteSize ()
2171 TargetSP target_sp(GetSP());
2174 return target_sp->GetArchitecture().GetDataByteSize() ;
2180 SBTarget::GetCodeByteSize ()
2182 TargetSP target_sp(GetSP());
2185 return target_sp->GetArchitecture().GetCodeByteSize() ;
2191 SBTarget::GetAddressByteSize()
2193 TargetSP target_sp(GetSP());
2195 return target_sp->GetArchitecture().GetAddressByteSize();
2196 return sizeof(void*);
2201 SBTarget::GetModuleAtIndex (uint32_t idx)
2203 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
2207 TargetSP target_sp(GetSP());
2210 // The module list is thread safe, no need to lock
2211 module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
2212 sb_module.SetSP (module_sp);
2216 log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
2217 static_cast<void*>(target_sp.get()), idx,
2218 static_cast<void*>(module_sp.get()));
2224 SBTarget::RemoveModule (lldb::SBModule module)
2226 TargetSP target_sp(GetSP());
2228 return target_sp->GetImages().Remove(module.GetSP());
2234 SBTarget::GetBroadcaster () const
2236 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
2238 TargetSP target_sp(GetSP());
2239 SBBroadcaster broadcaster(target_sp.get(), false);
2242 log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
2243 static_cast<void*>(target_sp.get()),
2244 static_cast<void*>(broadcaster.get()));
2250 SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
2252 Stream &strm = description.ref();
2254 TargetSP target_sp(GetSP());
2257 target_sp->Dump (&strm, description_level);
2260 strm.PutCString ("No value");
2265 lldb::SBSymbolContextList
2266 SBTarget::FindFunctions (const char *name, uint32_t name_type_mask)
2268 lldb::SBSymbolContextList sb_sc_list;
2269 if (name && name[0])
2271 TargetSP target_sp(GetSP());
2274 const bool symbols_ok = true;
2275 const bool inlines_ok = true;
2276 const bool append = true;
2277 target_sp->GetImages().FindFunctions (ConstString(name),
2288 lldb::SBSymbolContextList
2289 SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
2291 lldb::SBSymbolContextList sb_sc_list;
2292 if (name && name[0])
2294 TargetSP target_sp(GetSP());
2297 std::string regexstr;
2300 case eMatchTypeRegex:
2301 target_sp->GetImages().FindFunctions(RegularExpression(name), true, true, true, *sb_sc_list);
2303 case eMatchTypeStartsWith:
2304 regexstr = llvm::Regex::escape(name) + ".*";
2305 target_sp->GetImages().FindFunctions(RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
2308 target_sp->GetImages().FindFunctions(ConstString(name), eFunctionNameTypeAny, true, true, true, *sb_sc_list);
2317 SBTarget::FindFirstType (const char* typename_cstr)
2319 TargetSP target_sp(GetSP());
2320 if (typename_cstr && typename_cstr[0] && target_sp)
2322 ConstString const_typename(typename_cstr);
2324 const bool exact_match = false;
2326 const ModuleList &module_list = target_sp->GetImages();
2327 size_t count = module_list.GetSize();
2328 for (size_t idx = 0; idx < count; idx++)
2330 ModuleSP module_sp (module_list.GetModuleAtIndex(idx));
2333 TypeSP type_sp (module_sp->FindFirstType(sc, const_typename, exact_match));
2335 return SBType(type_sp);
2339 // Didn't find the type in the symbols; try the Objective-C runtime
2340 // if one is installed
2342 ProcessSP process_sp(target_sp->GetProcessSP());
2346 ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
2348 if (objc_language_runtime)
2350 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
2352 if (objc_decl_vendor)
2354 std::vector <clang::NamedDecl *> decls;
2356 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
2358 if (ClangASTType type = ClangASTContext::GetTypeForDecl(decls[0]))
2360 return SBType(type);
2367 // No matches, search for basic typename matches
2368 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
2370 return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename));
2376 SBTarget::GetBasicType(lldb::BasicType type)
2378 TargetSP target_sp(GetSP());
2381 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
2383 return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), type));
2390 SBTarget::FindTypes (const char* typename_cstr)
2392 SBTypeList sb_type_list;
2393 TargetSP target_sp(GetSP());
2394 if (typename_cstr && typename_cstr[0] && target_sp)
2396 ModuleList& images = target_sp->GetImages();
2397 ConstString const_typename(typename_cstr);
2398 bool exact_match = false;
2402 uint32_t num_matches = images.FindTypes (sc,
2408 if (num_matches > 0)
2410 for (size_t idx = 0; idx < num_matches; idx++)
2412 TypeSP type_sp (type_list.GetTypeAtIndex(idx));
2414 sb_type_list.Append(SBType(type_sp));
2418 // Try the Objective-C runtime if one is installed
2420 ProcessSP process_sp(target_sp->GetProcessSP());
2424 ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
2426 if (objc_language_runtime)
2428 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
2430 if (objc_decl_vendor)
2432 std::vector <clang::NamedDecl *> decls;
2434 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
2436 for (clang::NamedDecl *decl : decls)
2438 if (ClangASTType type = ClangASTContext::GetTypeForDecl(decl))
2440 sb_type_list.Append(SBType(type));
2448 if (sb_type_list.GetSize() == 0)
2450 // No matches, search for basic typename matches
2451 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
2453 sb_type_list.Append (SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename)));
2456 return sb_type_list;
2460 SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
2462 SBValueList sb_value_list;
2464 TargetSP target_sp(GetSP());
2465 if (name && target_sp)
2467 VariableList variable_list;
2468 const bool append = true;
2469 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name),
2474 if (match_count > 0)
2476 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
2477 if (exe_scope == NULL)
2478 exe_scope = target_sp.get();
2479 for (uint32_t i=0; i<match_count; ++i)
2481 lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
2483 sb_value_list.Append(SBValue(valobj_sp));
2488 return sb_value_list;
2492 SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype)
2494 SBValueList sb_value_list;
2496 TargetSP target_sp(GetSP());
2497 if (name && target_sp)
2499 VariableList variable_list;
2500 const bool append = true;
2502 std::string regexstr;
2503 uint32_t match_count;
2506 case eMatchTypeNormal:
2507 match_count = target_sp->GetImages().FindGlobalVariables(ConstString(name),
2512 case eMatchTypeRegex:
2513 match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(name),
2518 case eMatchTypeStartsWith:
2519 regexstr = llvm::Regex::escape(name) + ".*";
2520 match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr.c_str()),
2528 if (match_count > 0)
2530 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
2531 if (exe_scope == NULL)
2532 exe_scope = target_sp.get();
2533 for (uint32_t i = 0; i<match_count; ++i)
2535 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(exe_scope, variable_list.GetVariableAtIndex(i)));
2537 sb_value_list.Append(SBValue(valobj_sp));
2542 return sb_value_list;
2547 SBTarget::FindFirstGlobalVariable (const char* name)
2549 SBValueList sb_value_list(FindGlobalVariables(name, 1));
2550 if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
2551 return sb_value_list.GetValueAtIndex(0);
2556 SBTarget::GetSourceManager()
2558 SBSourceManager source_manager (*this);
2559 return source_manager;
2562 lldb::SBInstructionList
2563 SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count)
2565 return ReadInstructions (base_addr, count, NULL);
2568 lldb::SBInstructionList
2569 SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string)
2571 SBInstructionList sb_instructions;
2573 TargetSP target_sp(GetSP());
2576 Address *addr_ptr = base_addr.get();
2580 DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
2581 bool prefer_file_cache = false;
2582 lldb_private::Error error;
2583 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
2584 const size_t bytes_read = target_sp->ReadMemory(*addr_ptr,
2590 const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
2591 sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
2602 return sb_instructions;
2606 lldb::SBInstructionList
2607 SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
2609 return GetInstructionsWithFlavor (base_addr, NULL, buf, size);
2612 lldb::SBInstructionList
2613 SBTarget::GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
2615 SBInstructionList sb_instructions;
2617 TargetSP target_sp(GetSP());
2622 if (base_addr.get())
2623 addr = *base_addr.get();
2625 const bool data_from_file = true;
2627 sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
2637 return sb_instructions;
2640 lldb::SBInstructionList
2641 SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
2643 return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), NULL, buf, size);
2646 lldb::SBInstructionList
2647 SBTarget::GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size)
2649 return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), flavor_string, buf, size);
2653 SBTarget::SetSectionLoadAddress (lldb::SBSection section,
2654 lldb::addr_t section_base_addr)
2657 TargetSP target_sp(GetSP());
2660 if (!section.IsValid())
2662 sb_error.SetErrorStringWithFormat ("invalid section");
2666 SectionSP section_sp (section.GetSP());
2669 if (section_sp->IsThreadSpecific())
2671 sb_error.SetErrorString ("thread specific sections are not yet supported");
2675 ProcessSP process_sp (target_sp->GetProcessSP());
2676 if (target_sp->SetSectionLoadAddress (section_sp, section_base_addr))
2678 // Flush info in the process (stack frames, etc)
2680 process_sp->Flush();
2688 sb_error.SetErrorString ("invalid target");
2694 SBTarget::ClearSectionLoadAddress (lldb::SBSection section)
2698 TargetSP target_sp(GetSP());
2701 if (!section.IsValid())
2703 sb_error.SetErrorStringWithFormat ("invalid section");
2707 ProcessSP process_sp (target_sp->GetProcessSP());
2708 if (target_sp->SetSectionUnloaded (section.GetSP()))
2710 // Flush info in the process (stack frames, etc)
2712 process_sp->Flush();
2718 sb_error.SetErrorStringWithFormat ("invalid target");
2724 SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset)
2728 TargetSP target_sp(GetSP());
2731 ModuleSP module_sp (module.GetSP());
2734 bool changed = false;
2735 if (module_sp->SetLoadAddress (*target_sp, slide_offset, true, changed))
2737 // The load was successful, make sure that at least some sections
2738 // changed before we notify that our module was loaded.
2741 ModuleList module_list;
2742 module_list.Append(module_sp);
2743 target_sp->ModulesDidLoad (module_list);
2744 // Flush info in the process (stack frames, etc)
2745 ProcessSP process_sp (target_sp->GetProcessSP());
2747 process_sp->Flush();
2753 sb_error.SetErrorStringWithFormat ("invalid module");
2759 sb_error.SetErrorStringWithFormat ("invalid target");
2765 SBTarget::ClearModuleLoadAddress (lldb::SBModule module)
2769 char path[PATH_MAX];
2770 TargetSP target_sp(GetSP());
2773 ModuleSP module_sp (module.GetSP());
2776 ObjectFile *objfile = module_sp->GetObjectFile();
2779 SectionList *section_list = objfile->GetSectionList();
2782 ProcessSP process_sp (target_sp->GetProcessSP());
2784 bool changed = false;
2785 const size_t num_sections = section_list->GetSize();
2786 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
2788 SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
2790 changed |= target_sp->SetSectionUnloaded (section_sp);
2794 // Flush info in the process (stack frames, etc)
2795 ProcessSP process_sp (target_sp->GetProcessSP());
2797 process_sp->Flush();
2802 module_sp->GetFileSpec().GetPath (path, sizeof(path));
2803 sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path);
2808 module_sp->GetFileSpec().GetPath (path, sizeof(path));
2809 sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path);
2814 sb_error.SetErrorStringWithFormat ("invalid module");
2819 sb_error.SetErrorStringWithFormat ("invalid target");
2825 lldb::SBSymbolContextList
2826 SBTarget::FindSymbols (const char *name, lldb::SymbolType symbol_type)
2828 SBSymbolContextList sb_sc_list;
2829 if (name && name[0])
2831 TargetSP target_sp(GetSP());
2835 target_sp->GetImages().FindSymbolsWithNameAndType (ConstString(name),
2847 SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
2849 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
2850 Log * expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
2851 SBValue expr_result;
2852 ExpressionResults exe_results = eExpressionSetupError;
2853 ValueObjectSP expr_value_sp;
2854 TargetSP target_sp(GetSP());
2855 StackFrame *frame = NULL;
2858 if (expr == NULL || expr[0] == '\0')
2861 log->Printf ("SBTarget::EvaluateExpression called with an empty expression");
2865 Mutex::Locker api_locker (target_sp->GetAPIMutex());
2866 ExecutionContext exe_ctx (m_opaque_sp.get());
2869 log->Printf ("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
2871 frame = exe_ctx.GetFramePtr();
2872 Target *target = exe_ctx.GetTargetPtr();
2876 #ifdef LLDB_CONFIGURATION_DEBUG
2877 StreamString frame_description;
2879 frame->DumpUsingSettingsFormat (&frame_description);
2880 Host::SetCrashDescriptionWithFormat ("SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
2881 expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
2883 exe_results = target->EvaluateExpression (expr,
2888 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2889 #ifdef LLDB_CONFIGURATION_DEBUG
2890 Host::SetCrashDescription (NULL);
2896 log->Printf ("SBTarget::EvaluateExpression () => error: could not reconstruct frame object for this SBTarget.");
2899 #ifndef LLDB_DISABLE_PYTHON
2901 expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is %s, summary %s **",
2902 expr_result.GetValue(), expr_result.GetSummary());
2905 log->Printf ("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
2906 static_cast<void*>(frame), expr,
2907 static_cast<void*>(expr_value_sp.get()), exe_results);
2915 SBTarget::GetStackRedZoneSize()
2917 TargetSP target_sp(GetSP());
2921 ProcessSP process_sp (target_sp->GetProcessSP());
2923 abi_sp = process_sp->GetABI();
2925 abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
2927 return abi_sp->GetRedZoneSize();