SBDebugger SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBDebugger debugger; debugger.reset(Debugger::CreateInstance(callback, baton)); if (log) { SBStream sstr; debugger.GetDescription (sstr); log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData()); } SBCommandInterpreter interp = debugger.GetCommandInterpreter(); if (source_init_files) { interp.get()->SkipLLDBInitFiles(false); interp.get()->SkipAppInitFiles (false); SBCommandReturnObject result; interp.SourceInitFileInHomeDirectory(result); } else { interp.get()->SkipLLDBInitFiles(true); interp.get()->SkipAppInitFiles (true); } return debugger; }
SBDebugger SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton) { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBDebugger debugger; // Currently we have issues if this function is called simultaneously on two different // threads. The issues mainly revolve around the fact that the lldb_private::FormatManager // uses global collections and having two threads parsing the .lldbinit files can cause // mayhem. So to get around this for now we need to use a mutex to prevent bad things // from happening. static Mutex g_mutex(Mutex::eMutexTypeRecursive); Mutex::Locker locker(g_mutex); debugger.reset(Debugger::CreateInstance(callback, baton)); if (log) { SBStream sstr; debugger.GetDescription (sstr); log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", static_cast<void*>(debugger.m_opaque_sp.get()), sstr.GetData()); } SBCommandInterpreter interp = debugger.GetCommandInterpreter(); if (source_init_files) { interp.get()->SkipLLDBInitFiles(false); interp.get()->SkipAppInitFiles (false); SBCommandReturnObject result; interp.SourceInitFileInHomeDirectory(result); } else { interp.get()->SkipLLDBInitFiles(true); interp.get()->SkipAppInitFiles (true); } return debugger; }