summaryrefslogtreecommitdiff
path: root/source/lldb.cpp
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-07-03 16:57:06 +0000
committerEd Maste <emaste@FreeBSD.org>2015-07-03 16:57:06 +0000
commit5e95aa85bb660d45e9905ef1d7180b2678280660 (patch)
tree3c2e41c3be19b7fc7666ed45a5f91ec3b6e35f2a /source/lldb.cpp
parent12bd4897ff0678fa663e09d78ebc22dd255ceb86 (diff)
downloadsrc-test2-5e95aa85bb660d45e9905ef1d7180b2678280660.tar.gz
src-test2-5e95aa85bb660d45e9905ef1d7180b2678280660.zip
Notes
Diffstat (limited to 'source/lldb.cpp')
-rw-r--r--source/lldb.cpp402
1 files changed, 2 insertions, 400 deletions
diff --git a/source/lldb.cpp b/source/lldb.cpp
index 2ac8296b4d04..89bb485a612e 100644
--- a/source/lldb.cpp
+++ b/source/lldb.cpp
@@ -7,315 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/lldb-private.h"
-#include "lldb/lldb-private-log.h"
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/TargetSelect.h"
-
-#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
-#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
-#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
-#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
-#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
-#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
-#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
-#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
-#include "Plugins/Platform/Linux/PlatformLinux.h"
-#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
-#include "Plugins/Platform/Windows/PlatformWindows.h"
-#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
-#include "Plugins/Process/elf-core/ProcessElfCore.h"
-#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
-#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
-#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
-
-#ifndef LLDB_DISABLE_PYTHON
-#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
-#endif
-#if defined (__APPLE__)
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
-#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
-#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
-#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
-#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
-#endif
-
-#include "Plugins/Process/mach-core/ProcessMachCore.h"
-
-
-#if defined (__linux__)
-#include "Plugins/Process/Linux/ProcessLinux.h"
-#endif
-
-#if defined (_WIN32)
-#include "lldb/Host/windows/windows.h"
-#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
-#include "Plugins/Process/Windows/ProcessWindows.h"
-#endif
-
-#if defined (__FreeBSD__)
-#include "Plugins/Process/POSIX/ProcessPOSIX.h"
-#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
-#endif
-
-#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
-#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
-#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
using namespace lldb;
using namespace lldb_private;
-static void fatal_error_handler(void *user_data, const std::string& reason,
- bool gen_crash_diag) {
- Host::SetCrashDescription(reason.c_str());
- ::abort();
-}
-
-void
-lldb_private::Initialize ()
-{
- // Make sure we inialize only once
- static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
- static bool g_inited = false;
-
- Mutex::Locker locker(g_inited_mutex);
- if (!g_inited)
- {
- g_inited = true;
-
-#if defined(_MSC_VER)
- const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
- if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true"))
- {
- // This will prevent Windows from displaying a dialog box requiring user interaction when
- // LLDB crashes. This is mostly useful when automating LLDB, for example via the test
- // suite, so that a crash in LLDB does not prevent completion of the test suite.
- ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
-
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- }
-#endif
-
- Log::Initialize();
- HostInfo::Initialize();
- Timer::Initialize ();
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- // Initialize LLVM and Clang
- llvm::InitializeAllTargets();
- llvm::InitializeAllAsmPrinters();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllDisassemblers();
- llvm::install_fatal_error_handler(fatal_error_handler, 0);
-
- // Initialize plug-ins
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
- ABIMacOSX_arm64::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
- DisassemblerLLVMC::Initialize();
- ObjectContainerBSDArchive::Initialize();
- ObjectFileELF::Initialize();
- SymbolVendorELF::Initialize();
- SymbolFileDWARF::Initialize();
- SymbolFileSymtab::Initialize();
- UnwindAssemblyInstEmulation::Initialize();
- UnwindAssembly_x86::Initialize();
- EmulateInstructionARM::Initialize ();
- EmulateInstructionARM64::Initialize ();
- ObjectFilePECOFF::Initialize ();
- DynamicLoaderPOSIXDYLD::Initialize ();
- PlatformFreeBSD::Initialize();
- PlatformLinux::Initialize();
- PlatformWindows::Initialize();
- PlatformKalimba::Initialize();
- SymbolFileDWARFDebugMap::Initialize();
- ItaniumABILanguageRuntime::Initialize();
-#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::InitializePrivate();
- OperatingSystemPython::Initialize();
-#endif
- JITLoaderGDB::Initialize();
- ProcessElfCore::Initialize();
- MemoryHistoryASan::Initialize();
- AddressSanitizerRuntime::Initialize();
-
-#if defined (__APPLE__)
- //----------------------------------------------------------------------
- // Apple/Darwin hosted plugins
- //----------------------------------------------------------------------
- DynamicLoaderMacOSXDYLD::Initialize();
- DynamicLoaderDarwinKernel::Initialize();
- AppleObjCRuntimeV2::Initialize();
- AppleObjCRuntimeV1::Initialize();
- ObjectContainerUniversalMachO::Initialize();
- ObjectFileMachO::Initialize();
- ProcessKDP::Initialize();
- ProcessMachCore::Initialize();
- SymbolVendorMacOSX::Initialize();
- PlatformDarwinKernel::Initialize();
- PlatformRemoteiOS::Initialize();
- PlatformMacOSX::Initialize();
- PlatformiOSSimulator::Initialize();
- SystemRuntimeMacOSX::Initialize();
-#endif
-#if defined (__linux__)
- //----------------------------------------------------------------------
- // Linux hosted plugins
- //----------------------------------------------------------------------
- ProcessLinux::Initialize();
-#endif
-#if defined(_WIN32)
- DynamicLoaderWindows::Initialize();
- ProcessWindows::Initialize();
-#endif
-#if defined (__FreeBSD__)
- ProcessFreeBSD::Initialize();
-#endif
-
- //----------------------------------------------------------------------
- // Platform agnostic plugins
- //----------------------------------------------------------------------
- PlatformRemoteGDBServer::Initialize ();
- ProcessGDBRemote::Initialize();
- DynamicLoaderStatic::Initialize();
-
- // Scan for any system or user LLDB plug-ins
- PluginManager::Initialize();
-
- // The process settings need to know about installed plug-ins, so the Settings must be initialized
- // AFTER PluginManager::Initialize is called.
-
- Debugger::SettingsInitialize();
- }
-}
-
-void
-lldb_private::WillTerminate()
-{
- Host::WillTerminate();
-}
-
-void
-lldb_private::Terminate ()
-{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- // Terminate and unload and loaded system or user LLDB plug-ins
- PluginManager::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
- ABIMacOSX_arm64::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
- DisassemblerLLVMC::Terminate();
- ObjectContainerBSDArchive::Terminate();
- ObjectFileELF::Terminate();
- SymbolVendorELF::Terminate();
- SymbolFileDWARF::Terminate();
- SymbolFileSymtab::Terminate();
- UnwindAssembly_x86::Terminate();
- UnwindAssemblyInstEmulation::Terminate();
- EmulateInstructionARM::Terminate ();
- EmulateInstructionARM64::Terminate ();
- ObjectFilePECOFF::Terminate ();
- DynamicLoaderPOSIXDYLD::Terminate ();
- PlatformFreeBSD::Terminate();
- PlatformLinux::Terminate();
- PlatformWindows::Terminate();
- PlatformKalimba::Terminate();
- SymbolFileDWARFDebugMap::Terminate();
- ItaniumABILanguageRuntime::Terminate();
-#ifndef LLDB_DISABLE_PYTHON
- OperatingSystemPython::Terminate();
-#endif
- JITLoaderGDB::Terminate();
- ProcessElfCore::Terminate();
- MemoryHistoryASan::Terminate();
- AddressSanitizerRuntime::Terminate();
-
-#if defined (__APPLE__)
- DynamicLoaderMacOSXDYLD::Terminate();
- DynamicLoaderDarwinKernel::Terminate();
- AppleObjCRuntimeV2::Terminate();
- AppleObjCRuntimeV1::Terminate();
- ObjectContainerUniversalMachO::Terminate();
- ObjectFileMachO::Terminate();
- ProcessMachCore::Terminate();
- ProcessKDP::Terminate();
- SymbolVendorMacOSX::Terminate();
- PlatformMacOSX::Terminate();
- PlatformDarwinKernel::Terminate();
- PlatformRemoteiOS::Terminate();
- PlatformiOSSimulator::Terminate();
- SystemRuntimeMacOSX::Terminate();
-#endif
-
- Debugger::SettingsTerminate ();
-
-#if defined (_WIN32)
- DynamicLoaderWindows::Terminate();
-#endif
-
-#if defined (__linux__)
- ProcessLinux::Terminate();
-#endif
-
-#if defined (__FreeBSD__)
- ProcessFreeBSD::Terminate();
-#endif
-
- ProcessGDBRemote::Terminate();
- DynamicLoaderStatic::Terminate();
-
- Log::Terminate();
-}
-
#if defined (__APPLE__)
extern "C" const unsigned char liblldb_coreVersionString[];
#else
@@ -360,13 +56,13 @@ lldb_private::GetVersion ()
const char *newline_loc = strchr(version_string, '\n');
- size_t version_len = sizeof(g_version_string);
+ size_t version_len = sizeof(g_version_string) - 1;
if (newline_loc &&
(newline_loc - version_string < static_cast<ptrdiff_t>(version_len)))
version_len = newline_loc - version_string;
- ::strncpy(g_version_string, version_string, version_len);
+ ::snprintf(g_version_string, version_len + 1, "%s", version_string);
}
return g_version_string;
@@ -409,97 +105,3 @@ lldb_private::GetVersion ()
return g_version_str.c_str();
#endif
}
-
-const char *
-lldb_private::GetVoteAsCString (Vote vote)
-{
- switch (vote)
- {
- case eVoteNo: return "no";
- case eVoteNoOpinion: return "no opinion";
- case eVoteYes: return "yes";
- }
- return "invalid";
-}
-
-
-const char *
-lldb_private::GetSectionTypeAsCString (SectionType sect_type)
-{
- switch (sect_type)
- {
- case eSectionTypeInvalid: return "invalid";
- case eSectionTypeCode: return "code";
- case eSectionTypeContainer: return "container";
- case eSectionTypeData: return "data";
- case eSectionTypeDataCString: return "data-cstr";
- case eSectionTypeDataCStringPointers: return "data-cstr-ptr";
- case eSectionTypeDataSymbolAddress: return "data-symbol-addr";
- case eSectionTypeData4: return "data-4-byte";
- case eSectionTypeData8: return "data-8-byte";
- case eSectionTypeData16: return "data-16-byte";
- case eSectionTypeDataPointers: return "data-ptrs";
- case eSectionTypeDebug: return "debug";
- case eSectionTypeZeroFill: return "zero-fill";
- case eSectionTypeDataObjCMessageRefs: return "objc-message-refs";
- case eSectionTypeDataObjCCFStrings: return "objc-cfstrings";
- case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev";
- case eSectionTypeDWARFDebugAranges: return "dwarf-aranges";
- case eSectionTypeDWARFDebugFrame: return "dwarf-frame";
- case eSectionTypeDWARFDebugInfo: return "dwarf-info";
- case eSectionTypeDWARFDebugLine: return "dwarf-line";
- case eSectionTypeDWARFDebugLoc: return "dwarf-loc";
- case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo";
- case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames";
- case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes";
- case eSectionTypeDWARFDebugRanges: return "dwarf-ranges";
- case eSectionTypeDWARFDebugStr: return "dwarf-str";
- case eSectionTypeELFSymbolTable: return "elf-symbol-table";
- case eSectionTypeELFDynamicSymbols: return "elf-dynamic-symbols";
- case eSectionTypeELFRelocationEntries: return "elf-relocation-entries";
- case eSectionTypeELFDynamicLinkInfo: return "elf-dynamic-link-info";
- case eSectionTypeDWARFAppleNames: return "apple-names";
- case eSectionTypeDWARFAppleTypes: return "apple-types";
- case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces";
- case eSectionTypeDWARFAppleObjC: return "apple-objc";
- case eSectionTypeEHFrame: return "eh-frame";
- case eSectionTypeCompactUnwind: return "compact-unwind";
- case eSectionTypeOther: return "regular";
- }
- return "unknown";
-
-}
-
-bool
-lldb_private::NameMatches (const char *name,
- NameMatchType match_type,
- const char *match)
-{
- if (match_type == eNameMatchIgnore)
- return true;
-
- if (name == match)
- return true;
-
- if (name && match)
- {
- llvm::StringRef name_sref(name);
- llvm::StringRef match_sref(match);
- switch (match_type)
- {
- case eNameMatchIgnore: // This case cannot occur: tested before
- return true;
- case eNameMatchEquals: return name_sref == match_sref;
- case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos;
- case eNameMatchStartsWith: return name_sref.startswith (match_sref);
- case eNameMatchEndsWith: return name_sref.endswith (match_sref);
- case eNameMatchRegularExpression:
- {
- RegularExpression regex (match);
- return regex.Execute (name);
- }
- break;
- }
- }
- return false;
-}