1 //===-- SBDebugger.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/SBDebugger.h"
14 #include "lldb/lldb-private.h"
16 #include "lldb/API/SBListener.h"
17 #include "lldb/API/SBBroadcaster.h"
18 #include "lldb/API/SBCommandInterpreter.h"
19 #include "lldb/API/SBCommandReturnObject.h"
20 #include "lldb/API/SBError.h"
21 #include "lldb/API/SBEvent.h"
22 #include "lldb/API/SBFrame.h"
23 #include "lldb/API/SBInputReader.h"
24 #include "lldb/API/SBProcess.h"
25 #include "lldb/API/SBSourceManager.h"
26 #include "lldb/API/SBStream.h"
27 #include "lldb/API/SBStringList.h"
28 #include "lldb/API/SBTarget.h"
29 #include "lldb/API/SBThread.h"
30 #include "lldb/API/SBTypeCategory.h"
31 #include "lldb/API/SBTypeFormat.h"
32 #include "lldb/API/SBTypeFilter.h"
33 #include "lldb/API/SBTypeNameSpecifier.h"
34 #include "lldb/API/SBTypeSummary.h"
35 #include "lldb/API/SBTypeSynthetic.h"
38 #include "lldb/Core/Debugger.h"
39 #include "lldb/Core/State.h"
40 #include "lldb/DataFormatters/DataVisualization.h"
41 #include "lldb/Interpreter/Args.h"
42 #include "lldb/Interpreter/CommandInterpreter.h"
43 #include "lldb/Interpreter/OptionGroupPlatform.h"
44 #include "lldb/Target/Process.h"
45 #include "lldb/Target/TargetList.h"
48 using namespace lldb_private;
51 SBDebugger::Initialize ()
53 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
56 log->Printf ("SBDebugger::Initialize ()");
58 SBCommandInterpreter::InitializeSWIG ();
60 Debugger::Initialize();
64 SBDebugger::Terminate ()
66 Debugger::Terminate();
72 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
75 log->Printf ("SBDebugger(%p)::Clear ()", m_opaque_sp.get());
78 m_opaque_sp->CleanUpInputReaders ();
86 return SBDebugger::Create(false, NULL, NULL);
90 SBDebugger::Create(bool source_init_files)
92 return SBDebugger::Create (source_init_files, NULL, NULL);
96 SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton)
99 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
102 debugger.reset(Debugger::CreateInstance(callback, baton));
107 debugger.GetDescription (sstr);
108 log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData());
111 SBCommandInterpreter interp = debugger.GetCommandInterpreter();
112 if (source_init_files)
114 interp.get()->SkipLLDBInitFiles(false);
115 interp.get()->SkipAppInitFiles (false);
116 SBCommandReturnObject result;
117 interp.SourceInitFileInHomeDirectory(result);
121 interp.get()->SkipLLDBInitFiles(true);
122 interp.get()->SkipAppInitFiles (true);
128 SBDebugger::Destroy (SBDebugger &debugger)
130 Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
135 debugger.GetDescription (sstr);
136 log->Printf ("SBDebugger::Destroy () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData());
139 Debugger::Destroy (debugger.m_opaque_sp);
141 if (debugger.m_opaque_sp.get() != NULL)
142 debugger.m_opaque_sp.reset();
146 SBDebugger::MemoryPressureDetected ()
148 // Since this function can be call asynchronously, we allow it to be
149 // non-mandatory. We have seen deadlocks with this function when called
150 // so we need to safeguard against this until we can determine what is
151 // causing the deadlocks.
152 Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
154 const bool mandatory = false;
157 log->Printf ("SBDebugger::MemoryPressureDetected (), mandatory = %d", mandatory);
160 ModuleList::RemoveOrphanSharedModules(mandatory);
163 SBDebugger::SBDebugger () :
168 SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) :
169 m_opaque_sp(debugger_sp)
173 SBDebugger::SBDebugger(const SBDebugger &rhs) :
174 m_opaque_sp (rhs.m_opaque_sp)
179 SBDebugger::operator = (const SBDebugger &rhs)
183 m_opaque_sp = rhs.m_opaque_sp;
188 SBDebugger::~SBDebugger ()
193 SBDebugger::IsValid() const
195 return m_opaque_sp.get() != NULL;
200 SBDebugger::SetAsync (bool b)
203 m_opaque_sp->SetAsyncExecution(b);
207 SBDebugger::GetAsync ()
210 return m_opaque_sp->GetAsyncExecution();
216 SBDebugger::SkipLLDBInitFiles (bool b)
219 m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b);
223 SBDebugger::SkipAppInitFiles (bool b)
226 m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles (b);
229 // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users
230 // trying to switch modes in the middle of a debugging session.
232 SBDebugger::SetInputFileHandle (FILE *fh, bool transfer_ownership)
234 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
237 log->Printf ("SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(),
238 fh, transfer_ownership);
241 m_opaque_sp->SetInputFileHandle (fh, transfer_ownership);
245 SBDebugger::SetOutputFileHandle (FILE *fh, bool transfer_ownership)
247 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
251 log->Printf ("SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(),
252 fh, transfer_ownership);
255 m_opaque_sp->SetOutputFileHandle (fh, transfer_ownership);
259 SBDebugger::SetErrorFileHandle (FILE *fh, bool transfer_ownership)
261 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
265 log->Printf ("SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(),
266 fh, transfer_ownership);
269 m_opaque_sp->SetErrorFileHandle (fh, transfer_ownership);
273 SBDebugger::GetInputFileHandle ()
276 return m_opaque_sp->GetInputFile().GetStream();
281 SBDebugger::GetOutputFileHandle ()
284 return m_opaque_sp->GetOutputFile().GetStream();
289 SBDebugger::GetErrorFileHandle ()
292 return m_opaque_sp->GetErrorFile().GetStream();
297 SBDebugger::SaveInputTerminalState()
300 m_opaque_sp->SaveInputTerminalState();
304 SBDebugger::RestoreInputTerminalState()
307 m_opaque_sp->RestoreInputTerminalState();
311 SBDebugger::GetCommandInterpreter ()
313 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
315 SBCommandInterpreter sb_interpreter;
317 sb_interpreter.reset (&m_opaque_sp->GetCommandInterpreter());
320 log->Printf ("SBDebugger(%p)::GetCommandInterpreter () => SBCommandInterpreter(%p)",
321 m_opaque_sp.get(), sb_interpreter.get());
323 return sb_interpreter;
327 SBDebugger::HandleCommand (const char *command)
331 TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
332 Mutex::Locker api_locker;
334 api_locker.Lock(target_sp->GetAPIMutex());
336 SBCommandInterpreter sb_interpreter(GetCommandInterpreter ());
337 SBCommandReturnObject result;
339 sb_interpreter.HandleCommand (command, result, false);
341 if (GetErrorFileHandle() != NULL)
342 result.PutError (GetErrorFileHandle());
343 if (GetOutputFileHandle() != NULL)
344 result.PutOutput (GetOutputFileHandle());
346 if (m_opaque_sp->GetAsyncExecution() == false)
348 SBProcess process(GetCommandInterpreter().GetProcess ());
349 ProcessSP process_sp (process.GetSP());
353 Listener &lldb_listener = m_opaque_sp->GetListener();
354 while (lldb_listener.GetNextEventForBroadcaster (process_sp.get(), event_sp))
356 SBEvent event(event_sp);
357 HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle());
365 SBDebugger::GetListener ()
367 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
369 SBListener sb_listener;
371 sb_listener.reset(&m_opaque_sp->GetListener(), false);
374 log->Printf ("SBDebugger(%p)::GetListener () => SBListener(%p)", m_opaque_sp.get(),
381 SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, FILE *out, FILE *err)
383 if (!process.IsValid())
386 TargetSP target_sp (process.GetTarget().GetSP());
390 const uint32_t event_type = event.GetType();
391 char stdio_buffer[1024];
394 Mutex::Locker api_locker (target_sp->GetAPIMutex());
396 if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged))
398 // Drain stdout when we stop just in case we have any bytes
399 while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
401 ::fwrite (stdio_buffer, 1, len, out);
404 if (event_type & (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged))
406 // Drain stderr when we stop just in case we have any bytes
407 while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
409 ::fwrite (stdio_buffer, 1, len, err);
412 if (event_type & Process::eBroadcastBitStateChanged)
414 StateType event_state = SBProcess::GetStateFromEvent (event);
416 if (event_state == eStateInvalid)
419 bool is_stopped = StateIsStoppedState (event_state);
421 process.ReportEventState (event, out);
426 SBDebugger::GetSourceManager ()
428 SBSourceManager sb_source_manager (*this);
429 return sb_source_manager;
434 SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len)
436 if (arch_name && arch_name_len)
438 ArchSpec default_arch = Target::GetDefaultArchitecture ();
440 if (default_arch.IsValid())
442 const std::string &triple_str = default_arch.GetTriple().str();
443 if (!triple_str.empty())
444 ::snprintf (arch_name, arch_name_len, "%s", triple_str.c_str());
446 ::snprintf (arch_name, arch_name_len, "%s", default_arch.GetArchitectureName());
450 if (arch_name && arch_name_len)
457 SBDebugger::SetDefaultArchitecture (const char *arch_name)
461 ArchSpec arch (arch_name);
464 Target::SetDefaultArchitecture (arch);
472 SBDebugger::GetScriptingLanguage (const char *script_language_name)
475 return Args::StringToScriptLanguage (script_language_name,
476 eScriptLanguageDefault,
481 SBDebugger::GetVersionString ()
483 return lldb_private::GetVersion();
487 SBDebugger::StateAsCString (StateType state)
489 return lldb_private::StateAsCString (state);
493 SBDebugger::StateIsRunningState (StateType state)
495 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
497 const bool result = lldb_private::StateIsRunningState (state);
499 log->Printf ("SBDebugger::StateIsRunningState (state=%s) => %i",
500 StateAsCString (state), result);
506 SBDebugger::StateIsStoppedState (StateType state)
508 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
510 const bool result = lldb_private::StateIsStoppedState (state, false);
512 log->Printf ("SBDebugger::StateIsStoppedState (state=%s) => %i",
513 StateAsCString (state), result);
519 SBDebugger::CreateTarget (const char *filename,
520 const char *target_triple,
521 const char *platform_name,
522 bool add_dependent_modules,
523 lldb::SBError& sb_error)
530 OptionGroupPlatform platform_options (false);
531 platform_options.SetPlatformName (platform_name);
533 sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
536 add_dependent_modules,
540 if (sb_error.Success())
541 sb_target.SetSP (target_sp);
545 sb_error.SetErrorString("invalid target");
548 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
551 log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, platform_name=%s, add_dependent_modules=%u, error=%s) => SBTarget(%p)",
556 add_dependent_modules,
557 sb_error.GetCString(),
565 SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename,
566 const char *target_triple)
572 const bool add_dependent_modules = true;
573 Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
576 add_dependent_modules,
579 sb_target.SetSP (target_sp);
582 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
585 log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndTargetTriple (filename=\"%s\", triple=%s) => SBTarget(%p)",
586 m_opaque_sp.get(), filename, target_triple, target_sp.get());
593 SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *arch_cstr)
595 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
602 const bool add_dependent_modules = true;
604 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
607 add_dependent_modules,
613 m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get());
614 sb_target.SetSP (target_sp);
620 log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", arch=%s) => SBTarget(%p)",
621 m_opaque_sp.get(), filename, arch_cstr, target_sp.get());
628 SBDebugger::CreateTarget (const char *filename)
634 ArchSpec arch = Target::GetDefaultArchitecture ();
636 const bool add_dependent_modules = true;
638 PlatformSP platform_sp(m_opaque_sp->GetPlatformList().GetSelectedPlatform());
639 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
642 add_dependent_modules,
648 m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get());
649 sb_target.SetSP (target_sp);
652 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
655 log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
656 m_opaque_sp.get(), filename, target_sp.get());
662 SBDebugger::DeleteTarget (lldb::SBTarget &target)
667 TargetSP target_sp(target.GetSP());
670 // No need to lock, the target list is thread safe
671 result = m_opaque_sp->GetTargetList().DeleteTarget (target_sp);
672 target_sp->Destroy();
674 const bool mandatory = true;
675 ModuleList::RemoveOrphanSharedModules(mandatory);
679 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
682 log->Printf ("SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i", m_opaque_sp.get(), target.m_opaque_sp.get(), result);
688 SBDebugger::GetTargetAtIndex (uint32_t idx)
693 // No need to lock, the target list is thread safe
694 sb_target.SetSP (m_opaque_sp->GetTargetList().GetTargetAtIndex (idx));
700 SBDebugger::GetIndexOfTarget (lldb::SBTarget target)
703 lldb::TargetSP target_sp = target.GetSP();
710 return m_opaque_sp->GetTargetList().GetIndexOfTarget (target.GetSP());
714 SBDebugger::FindTargetWithProcessID (lldb::pid_t pid)
719 // No need to lock, the target list is thread safe
720 sb_target.SetSP (m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid));
726 SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_name)
729 if (m_opaque_sp && filename && filename[0])
731 // No need to lock, the target list is thread safe
732 ArchSpec arch (arch_name, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get());
733 TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL));
734 sb_target.SetSP (target_sp);
740 SBDebugger::FindTargetWithLLDBProcess (const ProcessSP &process_sp)
745 // No need to lock, the target list is thread safe
746 sb_target.SetSP (m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get()));
753 SBDebugger::GetNumTargets ()
757 // No need to lock, the target list is thread safe
758 return m_opaque_sp->GetTargetList().GetNumTargets ();
764 SBDebugger::GetSelectedTarget ()
766 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
772 // No need to lock, the target list is thread safe
773 target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget ();
774 sb_target.SetSP (target_sp);
780 sb_target.GetDescription (sstr, eDescriptionLevelBrief);
781 log->Printf ("SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s", m_opaque_sp.get(),
782 target_sp.get(), sstr.GetData());
789 SBDebugger::SetSelectedTarget (SBTarget &sb_target)
791 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
793 TargetSP target_sp (sb_target.GetSP());
796 m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get());
801 sb_target.GetDescription (sstr, eDescriptionLevelBrief);
802 log->Printf ("SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s", m_opaque_sp.get(),
803 target_sp.get(), sstr.GetData());
808 SBDebugger::DispatchInput (void* baton, const void *data, size_t data_len)
810 DispatchInput (data,data_len);
814 SBDebugger::DispatchInput (const void *data, size_t data_len)
816 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
819 log->Printf ("SBDebugger(%p)::DispatchInput (data=\"%.*s\", size_t=%" PRIu64 ")",
826 m_opaque_sp->DispatchInput ((const char *) data, data_len);
830 SBDebugger::DispatchInputInterrupt ()
833 m_opaque_sp->DispatchInputInterrupt ();
837 SBDebugger::DispatchInputEndOfFile ()
840 m_opaque_sp->DispatchInputEndOfFile ();
844 SBDebugger::InputReaderIsTopReader (const lldb::SBInputReader &reader)
846 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
849 log->Printf ("SBDebugger(%p)::InputReaderIsTopReader (SBInputReader(%p))", m_opaque_sp.get(), &reader);
851 if (m_opaque_sp && reader.IsValid())
853 InputReaderSP reader_sp (*reader);
854 return m_opaque_sp->InputReaderIsTopReader (reader_sp);
862 SBDebugger::PushInputReader (SBInputReader &reader)
864 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
867 log->Printf ("SBDebugger(%p)::PushInputReader (SBInputReader(%p))", m_opaque_sp.get(), &reader);
869 if (m_opaque_sp && reader.IsValid())
871 TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
872 Mutex::Locker api_locker;
874 api_locker.Lock(target_sp->GetAPIMutex());
875 InputReaderSP reader_sp(*reader);
876 m_opaque_sp->PushInputReader (reader_sp);
881 SBDebugger::NotifyTopInputReader (InputReaderAction notification)
883 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
886 log->Printf ("SBDebugger(%p)::NotifyTopInputReader (%d)", m_opaque_sp.get(), notification);
889 m_opaque_sp->NotifyTopInputReader (notification);
893 SBDebugger::reset (const DebuggerSP &debugger_sp)
895 m_opaque_sp = debugger_sp;
899 SBDebugger::get () const
901 return m_opaque_sp.get();
905 SBDebugger::ref () const
907 assert (m_opaque_sp.get());
911 const lldb::DebuggerSP &
912 SBDebugger::get_sp () const
918 SBDebugger::FindDebuggerWithID (int id)
920 // No need to lock, the debugger list is thread safe
921 SBDebugger sb_debugger;
922 DebuggerSP debugger_sp = Debugger::FindDebuggerWithID (id);
924 sb_debugger.reset (debugger_sp);
929 SBDebugger::GetInstanceName()
932 return m_opaque_sp->GetInstanceName().AsCString();
938 SBDebugger::SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name)
941 DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName (ConstString(debugger_instance_name)));
945 ExecutionContext exe_ctx (debugger_sp->GetCommandInterpreter().GetExecutionContext());
946 error = debugger_sp->SetPropertyValue (&exe_ctx,
947 eVarSetOperationAssign,
953 error.SetErrorStringWithFormat ("invalid debugger instance name '%s'", debugger_instance_name);
956 sb_error.SetError(error);
961 SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger_instance_name)
963 SBStringList ret_value;
964 DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName (ConstString(debugger_instance_name)));
968 ExecutionContext exe_ctx (debugger_sp->GetCommandInterpreter().GetExecutionContext());
969 lldb::OptionValueSP value_sp (debugger_sp->GetPropertyValue (&exe_ctx,
975 StreamString value_strm;
976 value_sp->DumpValue (&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
977 const std::string &value_str = value_strm.GetString();
978 if (!value_str.empty())
980 StringList string_list;
981 string_list.SplitIntoLines(value_str.c_str(), value_str.size());
982 return SBStringList(&string_list);
986 return SBStringList();
990 SBDebugger::GetTerminalWidth () const
993 return m_opaque_sp->GetTerminalWidth ();
998 SBDebugger::SetTerminalWidth (uint32_t term_width)
1001 m_opaque_sp->SetTerminalWidth (term_width);
1005 SBDebugger::GetPrompt() const
1007 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1010 log->Printf ("SBDebugger(%p)::GetPrompt () => \"%s\"", m_opaque_sp.get(),
1011 (m_opaque_sp ? m_opaque_sp->GetPrompt() : ""));
1014 return m_opaque_sp->GetPrompt ();
1019 SBDebugger::SetPrompt (const char *prompt)
1022 m_opaque_sp->SetPrompt (prompt);
1027 SBDebugger::GetScriptLanguage() const
1030 return m_opaque_sp->GetScriptLanguage ();
1031 return eScriptLanguageNone;
1035 SBDebugger::SetScriptLanguage (ScriptLanguage script_lang)
1039 m_opaque_sp->SetScriptLanguage (script_lang);
1044 SBDebugger::SetUseExternalEditor (bool value)
1047 return m_opaque_sp->SetUseExternalEditor (value);
1052 SBDebugger::GetUseExternalEditor ()
1055 return m_opaque_sp->GetUseExternalEditor ();
1060 SBDebugger::SetUseColor (bool value)
1063 return m_opaque_sp->SetUseColor (value);
1068 SBDebugger::GetUseColor () const
1071 return m_opaque_sp->GetUseColor ();
1076 SBDebugger::GetDescription (SBStream &description)
1078 Stream &strm = description.ref();
1082 const char *name = m_opaque_sp->GetInstanceName().AsCString();
1083 user_id_t id = m_opaque_sp->GetID();
1084 strm.Printf ("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id);
1087 strm.PutCString ("No value");
1096 return m_opaque_sp->GetID();
1097 return LLDB_INVALID_UID;
1102 SBDebugger::SetCurrentPlatform (const char *platform_name)
1107 PlatformSP platform_sp (Platform::Create (platform_name, sb_error.ref()));
1111 bool make_selected = true;
1112 m_opaque_sp->GetPlatformList().Append (platform_sp, make_selected);
1119 SBDebugger::SetCurrentPlatformSDKRoot (const char *sysroot)
1123 PlatformSP platform_sp (m_opaque_sp->GetPlatformList().GetSelectedPlatform());
1127 platform_sp->SetSDKRootDirectory (ConstString (sysroot));
1135 SBDebugger::GetCloseInputOnEOF () const
1138 return m_opaque_sp->GetCloseInputOnEOF ();
1143 SBDebugger::SetCloseInputOnEOF (bool b)
1146 m_opaque_sp->SetCloseInputOnEOF (b);
1150 SBDebugger::GetCategory (const char* category_name)
1152 if (!category_name || *category_name == 0)
1153 return SBTypeCategory();
1155 TypeCategoryImplSP category_sp;
1157 if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, false))
1158 return SBTypeCategory(category_sp);
1160 return SBTypeCategory();
1164 SBDebugger::CreateCategory (const char* category_name)
1166 if (!category_name || *category_name == 0)
1167 return SBTypeCategory();
1169 TypeCategoryImplSP category_sp;
1171 if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, true))
1172 return SBTypeCategory(category_sp);
1174 return SBTypeCategory();
1178 SBDebugger::DeleteCategory (const char* category_name)
1180 if (!category_name || *category_name == 0)
1183 return DataVisualization::Categories::Delete(ConstString(category_name));
1187 SBDebugger::GetNumCategories()
1189 return DataVisualization::Categories::GetCount();
1193 SBDebugger::GetCategoryAtIndex (uint32_t index)
1195 return SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index));
1199 SBDebugger::GetDefaultCategory()
1201 return GetCategory("default");
1205 SBDebugger::GetFormatForType (SBTypeNameSpecifier type_name)
1207 SBTypeCategory default_category_sb = GetDefaultCategory();
1208 if (default_category_sb.GetEnabled())
1209 return default_category_sb.GetFormatForType(type_name);
1210 return SBTypeFormat();
1213 #ifndef LLDB_DISABLE_PYTHON
1215 SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name)
1217 if (type_name.IsValid() == false)
1218 return SBTypeSummary();
1219 return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()));
1221 #endif // LLDB_DISABLE_PYTHON
1224 SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name)
1226 if (type_name.IsValid() == false)
1227 return SBTypeFilter();
1228 return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()));
1231 #ifndef LLDB_DISABLE_PYTHON
1233 SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name)
1235 if (type_name.IsValid() == false)
1236 return SBTypeSynthetic();
1237 return SBTypeSynthetic(DataVisualization::GetSyntheticForType(type_name.GetSP()));
1239 #endif // LLDB_DISABLE_PYTHON
1242 SBDebugger::EnableLog (const char *channel, const char **categories)
1246 uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
1247 StreamString errors;
1248 return m_opaque_sp->EnableLog (channel, categories, NULL, log_options, errors);
1256 SBDebugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton)
1260 return m_opaque_sp->SetLoggingCallback (log_callback, baton);