From f21a844f60ae6c74fcf1fddca32461acce3c1ee0 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Wed, 6 Nov 2013 16:48:53 +0000 Subject: Import lldb as of SVN r194122 Sponsored by: DARPA, AFRL --- include/lldb/API/SBHostOS.h | 4 +- include/lldb/API/SBProcess.h | 32 + include/lldb/API/SBTarget.h | 3 + include/lldb/API/SBThread.h | 9 + include/lldb/Breakpoint/Breakpoint.h | 14 +- include/lldb/Breakpoint/BreakpointList.h | 10 +- include/lldb/Breakpoint/BreakpointLocation.h | 5 +- include/lldb/Breakpoint/BreakpointResolver.h | 7 + include/lldb/Breakpoint/BreakpointSiteList.h | 1 + include/lldb/Breakpoint/StoppointLocation.h | 14 +- include/lldb/Core/Address.h | 12 + include/lldb/Core/ArchSpec.h | 4 + include/lldb/Core/ConnectionFileDescriptor.h | 27 +- include/lldb/Core/ConnectionMachPort.h | 3 +- include/lldb/Core/ConstString.h | 6 +- include/lldb/Core/DataExtractor.h | 21 + include/lldb/Core/Debugger.h | 4 +- include/lldb/Core/Disassembler.h | 3 +- include/lldb/Core/EmulateInstruction.h | 6 +- include/lldb/Core/Error.h | 11 +- include/lldb/Core/Flags.h | 1 - include/lldb/Core/Log.h | 3 +- include/lldb/Core/Module.h | 69 +- include/lldb/Core/ModuleList.h | 30 +- include/lldb/Core/ModuleSpec.h | 2 +- include/lldb/Core/Opcode.h | 15 +- include/lldb/Core/PluginManager.h | 18 + include/lldb/Core/RangeMap.h | 61 +- include/lldb/Core/RegularExpression.h | 29 + include/lldb/Core/StreamGDBRemote.h | 54 + include/lldb/Core/UUID.h | 2 + include/lldb/Core/Value.h | 2 +- include/lldb/Core/ValueObject.h | 269 +- include/lldb/Core/ValueObjectDynamicValue.h | 4 + include/lldb/Core/dwarf.h | 1 - .../lldb/DataFormatters/CXXFormatterFunctions.h | 33 + include/lldb/DataFormatters/DataVisualization.h | 43 +- include/lldb/DataFormatters/FormatCache.h | 20 +- include/lldb/DataFormatters/FormatClasses.h | 18 +- include/lldb/DataFormatters/FormatManager.h | 29 +- include/lldb/DataFormatters/FormatNavigator.h | 2 +- include/lldb/DataFormatters/TypeCategory.h | 49 +- include/lldb/DataFormatters/TypeCategoryMap.h | 4 + include/lldb/DataFormatters/TypeSummary.h | 5 +- include/lldb/DataFormatters/TypeSynthetic.h | 14 +- include/lldb/DataFormatters/ValueObjectPrinter.h | 394 ++ include/lldb/Expression/ClangExpressionDeclMap.h | 14 +- include/lldb/Expression/ClangFunction.h | 65 +- include/lldb/Expression/ClangUserExpression.h | 83 +- include/lldb/Expression/DWARFExpression.h | 21 +- include/lldb/Expression/IRExecutionUnit.h | 11 +- include/lldb/Expression/IRForTarget.h | 1 + include/lldb/Host/Condition.h | 6 +- include/lldb/Host/Config.h | 6 +- include/lldb/Host/File.h | 55 +- include/lldb/Host/FileSpec.h | 17 +- include/lldb/Host/Host.h | 56 +- include/lldb/Host/Mutex.h | 6 +- include/lldb/Host/OptionParser.h | 53 + include/lldb/Host/ProcessRunLock.h | 81 +- include/lldb/Host/SocketAddress.h | 9 + include/lldb/Host/Symbols.h | 1 - include/lldb/Host/Terminal.h | 3 + include/lldb/Host/TimeValue.h | 24 +- include/lldb/Interpreter/Args.h | 5 +- include/lldb/Interpreter/CommandObject.h | 2 +- .../Interpreter/OptionGroupValueObjectDisplay.h | 4 +- include/lldb/Interpreter/OptionValueBoolean.h | 2 +- include/lldb/Interpreter/OptionValueEnumeration.h | 2 +- include/lldb/Interpreter/Options.h | 15 +- include/lldb/Interpreter/PythonDataObjects.h | 2 +- include/lldb/Interpreter/ScriptInterpreter.h | 124 +- include/lldb/Interpreter/ScriptInterpreterPython.h | 40 +- include/lldb/Symbol/Block.h | 1 + include/lldb/Symbol/ClangASTImporter.h | 2 + include/lldb/Symbol/ClangASTType.h | 13 +- include/lldb/Symbol/ClangNamespaceDecl.h | 4 +- include/lldb/Symbol/ObjectFile.h | 96 +- include/lldb/Symbol/Symbol.h | 33 +- include/lldb/Symbol/SymbolContext.h | 1 - include/lldb/Symbol/Symtab.h | 4 + include/lldb/Symbol/Type.h | 356 +- include/lldb/Symbol/TypeList.h | 1 + include/lldb/Target/DynamicLoader.h | 20 + include/lldb/Target/ExecutionContext.h | 3 + include/lldb/Target/Platform.h | 363 +- include/lldb/Target/Process.h | 40 +- include/lldb/Target/RegisterContext.h | 5 + include/lldb/Target/StackFrame.h | 368 +- include/lldb/Target/StackFrameList.h | 3 +- include/lldb/Target/StackID.h | 7 +- include/lldb/Target/SystemRuntime.h | 174 + include/lldb/Target/Target.h | 92 +- include/lldb/Target/Thread.h | 38 +- include/lldb/Target/ThreadPlanCallFunction.h | 8 +- include/lldb/Target/ThreadPlanStepOverRange.h | 2 + include/lldb/Utility/RefCounter.h | 56 - include/lldb/Utility/SharingPtr.h | 41 +- include/lldb/lldb-defines.h | 12 + include/lldb/lldb-enumerations.h | 7 +- include/lldb/lldb-forward.h | 10 +- include/lldb/lldb-private-enumerations.h | 13 +- include/lldb/lldb-private-interfaces.h | 1 + include/lldb/lldb-private-log.h | 1 + include/lldb/lldb-private.h | 4 + include/lldb/lldb-types.h | 43 +- include/lldb/lldb-versioning.h | 2 +- source/API/SBCommandInterpreter.cpp | 125 +- source/API/SBData.cpp | 26 +- source/API/SBDebugger.cpp | 4 +- source/API/SBFileSpec.cpp | 2 +- source/API/SBFunction.cpp | 4 +- source/API/SBHostOS.cpp | 4 +- source/API/SBModuleSpec.cpp | 2 +- source/API/SBProcess.cpp | 40 +- source/API/SBSymbol.cpp | 4 +- source/API/SBTarget.cpp | 134 +- source/API/SBThread.cpp | 89 + source/API/SBType.cpp | 84 +- source/API/SBTypeCategory.cpp | 41 +- source/API/SBTypeNameSpecifier.cpp | 2 +- source/API/SBValue.cpp | 174 +- source/Breakpoint/Breakpoint.cpp | 5 +- source/Breakpoint/BreakpointList.cpp | 4 +- source/Breakpoint/BreakpointLocation.cpp | 17 +- source/Breakpoint/BreakpointLocationList.cpp | 2 +- source/Breakpoint/BreakpointResolver.cpp | 144 + source/Breakpoint/BreakpointResolverFileLine.cpp | 144 +- source/Breakpoint/BreakpointResolverFileRegex.cpp | 55 +- source/Breakpoint/BreakpointResolverName.cpp | 12 +- source/Breakpoint/StoppointLocation.cpp | 8 +- source/Commands/CommandCompletions.cpp | 128 +- source/Commands/CommandObjectArgs.cpp | 2 +- source/Commands/CommandObjectBreakpoint.cpp | 131 +- source/Commands/CommandObjectBreakpointCommand.cpp | 8 +- source/Commands/CommandObjectCommands.cpp | 30 +- source/Commands/CommandObjectDisassemble.cpp | 34 +- source/Commands/CommandObjectExpression.cpp | 50 +- source/Commands/CommandObjectExpression.h | 2 + source/Commands/CommandObjectFrame.cpp | 26 +- source/Commands/CommandObjectHelp.cpp | 4 +- source/Commands/CommandObjectLog.cpp | 18 +- source/Commands/CommandObjectMemory.cpp | 65 +- source/Commands/CommandObjectPlatform.cpp | 1777 +++++++- source/Commands/CommandObjectProcess.cpp | 42 +- source/Commands/CommandObjectRegister.cpp | 10 +- source/Commands/CommandObjectSettings.cpp | 2 +- source/Commands/CommandObjectSource.cpp | 20 +- source/Commands/CommandObjectTarget.cpp | 183 +- source/Commands/CommandObjectThread.cpp | 250 +- source/Commands/CommandObjectType.cpp | 466 +- source/Commands/CommandObjectWatchpoint.cpp | 22 +- source/Commands/CommandObjectWatchpointCommand.cpp | 8 +- source/Core/Address.cpp | 58 +- source/Core/ArchSpec.cpp | 143 +- source/Core/Communication.cpp | 4 +- source/Core/ConnectionFileDescriptor.cpp | 155 +- source/Core/ConnectionMachPort.cpp | 1 + source/Core/ConnectionSharedMemory.cpp | 21 +- source/Core/ConstString.cpp | 6 +- source/Core/DataBufferMemoryMap.cpp | 67 +- source/Core/DataExtractor.cpp | 74 +- source/Core/Debugger.cpp | 30 +- source/Core/Disassembler.cpp | 8 +- source/Core/Error.cpp | 17 +- source/Core/FileLineResolver.cpp | 2 +- source/Core/Log.cpp | 6 +- source/Core/Mangled.cpp | 4693 ++++++++++++++++++++ source/Core/Module.cpp | 126 +- source/Core/ModuleList.cpp | 14 +- source/Core/Opcode.cpp | 22 +- source/Core/PluginManager.cpp | 105 + source/Core/SearchFilter.cpp | 4 +- source/Core/SourceManager.cpp | 6 +- source/Core/StreamGDBRemote.cpp | 54 + source/Core/Timer.cpp | 12 +- source/Core/Value.cpp | 32 +- source/Core/ValueObject.cpp | 442 +- source/Core/ValueObjectDynamicValue.cpp | 122 +- source/Core/ValueObjectSyntheticFilter.cpp | 6 +- source/Core/ValueObjectVariable.cpp | 4 + source/DataFormatters/CXXFormatterFunctions.cpp | 8 +- source/DataFormatters/DataVisualization.cpp | 57 +- source/DataFormatters/FormatCache.cpp | 64 +- source/DataFormatters/FormatManager.cpp | 264 +- source/DataFormatters/LibCxxUnorderedMap.cpp | 135 + source/DataFormatters/TypeCategory.cpp | 119 +- source/DataFormatters/TypeCategoryMap.cpp | 26 + source/DataFormatters/TypeFormat.cpp | 2 +- source/DataFormatters/TypeSummary.cpp | 56 +- source/DataFormatters/ValueObjectPrinter.cpp | 623 +++ source/Expression/ClangASTSource.cpp | 47 +- source/Expression/ClangExpressionDeclMap.cpp | 143 +- source/Expression/ClangExpressionParser.cpp | 9 +- source/Expression/ClangFunction.cpp | 15 +- source/Expression/ClangUserExpression.cpp | 96 +- source/Expression/DWARFExpression.cpp | 88 +- source/Expression/IRExecutionUnit.cpp | 8 +- source/Expression/IRForTarget.cpp | 8 +- source/Expression/IRInterpreter.cpp | 50 +- source/Expression/IRMemoryMap.cpp | 6 +- source/Expression/Materializer.cpp | 14 +- source/Host/common/Condition.cpp | 27 +- source/Host/common/File.cpp | 126 + source/Host/common/FileSpec.cpp | 246 +- source/Host/common/Host.cpp | 599 ++- source/Host/common/Mutex.cpp | 26 +- source/Host/common/OptionParser.cpp | 61 + source/Host/common/ProcessRunLock.cpp | 71 + source/Host/common/SocketAddress.cpp | 3 + source/Host/common/Terminal.cpp | 21 +- source/Host/common/TimeValue.cpp | 36 +- source/Host/freebsd/Host.cpp | 139 +- source/Interpreter/Args.cpp | 136 +- source/Interpreter/CommandInterpreter.cpp | 43 +- source/Interpreter/CommandObject.cpp | 5 +- source/Interpreter/OptionGroupArchitecture.cpp | 2 +- source/Interpreter/OptionGroupBoolean.cpp | 4 +- source/Interpreter/OptionGroupFile.cpp | 4 +- source/Interpreter/OptionGroupFormat.cpp | 12 +- source/Interpreter/OptionGroupOutputFile.cpp | 4 +- source/Interpreter/OptionGroupPlatform.cpp | 8 +- source/Interpreter/OptionGroupString.cpp | 2 +- source/Interpreter/OptionGroupUInt64.cpp | 2 +- source/Interpreter/OptionGroupUUID.cpp | 2 +- .../Interpreter/OptionGroupValueObjectDisplay.cpp | 31 +- source/Interpreter/OptionGroupVariable.cpp | 16 +- source/Interpreter/OptionGroupWatchpoint.cpp | 4 +- source/Interpreter/OptionValueFileSpec.cpp | 26 +- source/Interpreter/OptionValueProperties.cpp | 1 + source/Interpreter/Options.cpp | 28 +- source/Interpreter/PythonDataObjects.cpp | 60 +- source/Interpreter/ScriptInterpreter.cpp | 42 +- source/Interpreter/ScriptInterpreterPython.cpp | 232 +- source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 47 +- source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 58 +- source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h | 24 +- source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 157 +- source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h | 6 +- .../Disassembler/llvm/DisassemblerLLVMC.cpp | 36 +- .../Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp | 4 +- .../DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp | 115 +- .../DynamicLoader/POSIX-DYLD/DYLDRendezvous.h | 36 +- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 159 +- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.h | 24 +- .../Instruction/ARM/EmulateInstructionARM.cpp | 2 +- .../Instruction/ARM/EmulateInstructionARM.h | 6 +- source/Plugins/Instruction/ARM/EmulationStateARM.h | 2 +- .../ItaniumABI/ItaniumABILanguageRuntime.cpp | 2 +- .../BSD-Archive/ObjectContainerBSDArchive.cpp | 19 +- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 85 +- source/Plugins/ObjectFile/ELF/ObjectFileELF.h | 5 +- .../Python/OperatingSystemPython.cpp | 2 +- .../Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp | 61 +- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h | 8 + source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 541 +++ source/Plugins/Platform/POSIX/PlatformPOSIX.h | 111 + .../gdb-server/PlatformRemoteGDBServer.cpp | 113 +- .../Platform/gdb-server/PlatformRemoteGDBServer.h | 52 + source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp | 44 +- source/Plugins/Process/FreeBSD/ProcessFreeBSD.h | 3 + source/Plugins/Process/FreeBSD/ProcessMonitor.cpp | 196 +- source/Plugins/Process/FreeBSD/ProcessMonitor.h | 27 +- source/Plugins/Process/POSIX/POSIXThread.cpp | 156 +- source/Plugins/Process/POSIX/POSIXThread.h | 16 +- source/Plugins/Process/POSIX/ProcessMessage.cpp | 6 + source/Plugins/Process/POSIX/ProcessMessage.h | 14 +- source/Plugins/Process/POSIX/ProcessPOSIX.cpp | 103 +- source/Plugins/Process/POSIX/ProcessPOSIX.h | 8 +- .../Process/POSIX/RegisterContextFreeBSD_i386.cpp | 78 + .../Process/POSIX/RegisterContextFreeBSD_i386.h | 29 + .../POSIX/RegisterContextFreeBSD_mips64.cpp | 90 + .../Process/POSIX/RegisterContextFreeBSD_mips64.h | 29 + .../POSIX/RegisterContextFreeBSD_x86_64.cpp | 129 +- .../Process/POSIX/RegisterContextFreeBSD_x86_64.h | 15 +- .../Process/POSIX/RegisterContextLinux_i386.cpp | 96 + .../Process/POSIX/RegisterContextLinux_i386.h | 29 + .../Process/POSIX/RegisterContextLinux_x86_64.cpp | 151 +- .../Process/POSIX/RegisterContextLinux_x86_64.h | 15 +- .../Plugins/Process/POSIX/RegisterContextPOSIX.h | 50 +- .../RegisterContextPOSIXProcessMonitor_mips64.cpp | 318 ++ .../RegisterContextPOSIXProcessMonitor_mips64.h | 95 + .../RegisterContextPOSIXProcessMonitor_x86.cpp | 634 +++ .../POSIX/RegisterContextPOSIXProcessMonitor_x86.h | 95 + .../Process/POSIX/RegisterContextPOSIX_mips64.cpp | 238 + .../Process/POSIX/RegisterContextPOSIX_mips64.h | 138 + .../Process/POSIX/RegisterContextPOSIX_x86.cpp | 666 +++ .../Process/POSIX/RegisterContextPOSIX_x86.h | 462 ++ .../Plugins/Process/POSIX/RegisterContext_i386.cpp | 551 --- .../Plugins/Process/POSIX/RegisterContext_i386.h | 169 - .../Plugins/Process/POSIX/RegisterContext_mips64.h | 104 + source/Plugins/Process/POSIX/RegisterContext_x86.h | 541 ++- .../Process/POSIX/RegisterContext_x86_64.cpp | 1563 ------- .../Plugins/Process/POSIX/RegisterContext_x86_64.h | 347 -- source/Plugins/Process/POSIX/RegisterInfos_i386.h | 207 + .../Plugins/Process/POSIX/RegisterInfos_mips64.h | 74 + .../Plugins/Process/POSIX/RegisterInfos_x86_64.h | 409 ++ .../Process/Utility/DynamicRegisterInfo.cpp | 456 +- .../Plugins/Process/Utility/DynamicRegisterInfo.h | 17 +- .../Plugins/Process/Utility/InferiorCallPOSIX.cpp | 11 + .../Process/Utility/RegisterContextLLDB.cpp | 69 +- .../RegisterContextMacOSXFrameBackchain.cpp | 4 +- source/Plugins/Process/Utility/UnwindLLDB.cpp | 16 +- source/Plugins/Process/elf-core/ProcessElfCore.cpp | 18 +- .../elf-core/RegisterContextCoreFreeBSD_x86_64.cpp | 68 - .../elf-core/RegisterContextCoreFreeBSD_x86_64.h | 47 - .../elf-core/RegisterContextCoreLinux_x86_64.cpp | 68 - .../elf-core/RegisterContextCoreLinux_x86_64.h | 54 - .../elf-core/RegisterContextPOSIXCore_mips64.cpp | 94 + .../elf-core/RegisterContextPOSIXCore_mips64.h | 58 + .../elf-core/RegisterContextPOSIXCore_x86_64.cpp | 92 + .../elf-core/RegisterContextPOSIXCore_x86_64.h | 58 + source/Plugins/Process/elf-core/ThreadElfCore.cpp | 25 +- source/Plugins/Process/elf-core/ThreadElfCore.h | 4 + .../Process/gdb-remote/GDBRemoteCommunication.cpp | 41 +- .../gdb-remote/GDBRemoteCommunicationClient.cpp | 497 ++- .../gdb-remote/GDBRemoteCommunicationClient.h | 70 +- .../gdb-remote/GDBRemoteCommunicationServer.cpp | 623 ++- .../gdb-remote/GDBRemoteCommunicationServer.h | 75 +- .../gdb-remote/GDBRemoteRegisterContext.cpp | 6 +- .../Process/gdb-remote/GDBRemoteRegisterContext.h | 156 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 219 +- .../Plugins/Process/gdb-remote/ProcessGDBRemote.h | 10 +- .../Plugins/Process/gdb-remote/ThreadGDBRemote.cpp | 37 +- .../Plugins/Process/gdb-remote/ThreadGDBRemote.h | 3 + .../DWARF/DWARFAbbreviationDeclaration.cpp | 6 +- .../DWARF/DWARFAbbreviationDeclaration.h | 6 +- source/Plugins/SymbolFile/DWARF/DWARFAttribute.h | 2 +- .../Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | 32 +- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h | 3 +- .../SymbolFile/DWARF/DWARFDataExtractor.cpp | 30 + .../Plugins/SymbolFile/DWARF/DWARFDataExtractor.h | 43 + .../Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp | 6 +- source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h | 4 +- .../SymbolFile/DWARF/DWARFDebugArangeSet.cpp | 6 +- .../Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h | 2 +- .../Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp | 2 +- .../Plugins/SymbolFile/DWARF/DWARFDebugAranges.h | 2 +- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp | 41 +- .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 42 +- .../Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h | 6 +- source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp | 39 +- source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h | 23 +- .../Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp | 2 +- .../Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h | 2 +- .../SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp | 2 +- .../SymbolFile/DWARF/DWARFDebugMacinfoEntry.h | 2 +- .../SymbolFile/DWARF/DWARFDebugPubnames.cpp | 4 +- .../Plugins/SymbolFile/DWARF/DWARFDebugPubnames.h | 2 +- .../SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp | 10 +- .../SymbolFile/DWARF/DWARFDebugPubnamesSet.h | 6 +- .../Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp | 4 +- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h | 2 +- source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h | 2 +- source/Plugins/SymbolFile/DWARF/DWARFDefines.h | 1 - source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp | 12 +- source/Plugins/SymbolFile/DWARF/DWARFFormValue.h | 15 +- .../SymbolFile/DWARF/DWARFLocationDescription.cpp | 6 +- .../SymbolFile/DWARF/DWARFLocationDescription.h | 2 +- .../Plugins/SymbolFile/DWARF/DWARFLocationList.cpp | 8 +- .../Plugins/SymbolFile/DWARF/DWARFLocationList.h | 8 +- source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h | 10 +- .../Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp | 9 +- source/Plugins/SymbolFile/DWARF/NameToDIE.cpp | 1 - .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 150 +- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 64 +- .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 2 +- .../InstEmulation/UnwindAssemblyInstEmulation.cpp | 4 +- .../UnwindAssembly/x86/UnwindAssembly-x86.cpp | 19 +- source/Symbol/ClangASTImporter.cpp | 15 + source/Symbol/ClangASTType.cpp | 122 +- source/Symbol/CompileUnit.cpp | 2 +- source/Symbol/DWARFCallFrameInfo.cpp | 9 +- source/Symbol/FuncUnwinders.cpp | 23 +- source/Symbol/LineEntry.cpp | 6 +- source/Symbol/ObjectFile.cpp | 6 +- source/Symbol/Symbol.cpp | 120 + source/Symbol/SymbolContext.cpp | 12 +- source/Symbol/Symtab.cpp | 11 +- source/Symbol/Type.cpp | 286 +- source/Symbol/UnwindTable.cpp | 2 +- source/Symbol/Variable.cpp | 11 +- source/Target/ExecutionContext.cpp | 10 +- source/Target/LanguageRuntime.cpp | 4 +- source/Target/Platform.cpp | 273 +- source/Target/Process.cpp | 176 +- source/Target/RegisterContext.cpp | 22 + source/Target/StackFrame.cpp | 60 +- source/Target/StackFrameList.cpp | 34 +- source/Target/StopInfo.cpp | 23 +- source/Target/SystemRuntime.cpp | 73 + source/Target/Target.cpp | 106 +- source/Target/TargetList.cpp | 2 +- source/Target/Thread.cpp | 118 +- source/Target/ThreadPlanRunToAddress.cpp | 2 +- source/Target/ThreadPlanStepOut.cpp | 2 +- source/Target/ThreadPlanStepOverRange.cpp | 76 +- source/Target/ThreadPlanStepRange.cpp | 25 +- source/Target/ThreadPlanStepThrough.cpp | 2 +- source/Target/ThreadPlanStepUntil.cpp | 4 +- source/Target/UnixSignals.cpp | 4 +- source/Utility/PseudoTerminal.cpp | 15 + source/Utility/RefCounter.cpp | 25 - source/Utility/SharingPtr.cpp | 12 +- source/Utility/StringExtractor.cpp | 78 +- source/Utility/StringExtractor.h | 13 + source/Utility/StringExtractorGDBRemote.cpp | 45 +- source/Utility/StringExtractorGDBRemote.h | 19 +- source/lldb-log.cpp | 32 +- source/lldb.cpp | 13 +- tools/driver/Driver.cpp | 227 +- tools/driver/Driver.h | 17 +- tools/driver/ELWrapper.cpp | 422 ++ tools/driver/ELWrapper.h | 122 + tools/driver/GetOptWrapper.cpp | 33 + tools/driver/GetOptWrapper.h | 49 + tools/driver/IOChannel.cpp | 121 +- tools/driver/IOChannel.h | 42 +- tools/driver/Platform.cpp | 111 + tools/driver/Platform.h | 113 + tools/lldb-platform/lldb-platform.cpp | 270 ++ 421 files changed, 26776 insertions(+), 8148 deletions(-) create mode 100644 include/lldb/Core/StreamGDBRemote.h create mode 100644 include/lldb/DataFormatters/ValueObjectPrinter.h create mode 100644 include/lldb/Host/OptionParser.h create mode 100644 include/lldb/Target/SystemRuntime.h delete mode 100644 include/lldb/Utility/RefCounter.h create mode 100644 source/Core/StreamGDBRemote.cpp create mode 100644 source/DataFormatters/LibCxxUnorderedMap.cpp create mode 100644 source/DataFormatters/ValueObjectPrinter.cpp create mode 100644 source/Host/common/OptionParser.cpp create mode 100644 source/Host/common/ProcessRunLock.cpp create mode 100644 source/Plugins/Platform/POSIX/PlatformPOSIX.cpp create mode 100644 source/Plugins/Platform/POSIX/PlatformPOSIX.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextFreeBSD_i386.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextFreeBSD_i386.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextFreeBSD_mips64.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextFreeBSD_mips64.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextLinux_i386.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextLinux_i386.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_mips64.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_mips64.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIX_mips64.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIX_mips64.h create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIX_x86.cpp create mode 100644 source/Plugins/Process/POSIX/RegisterContextPOSIX_x86.h delete mode 100644 source/Plugins/Process/POSIX/RegisterContext_i386.cpp delete mode 100644 source/Plugins/Process/POSIX/RegisterContext_i386.h create mode 100644 source/Plugins/Process/POSIX/RegisterContext_mips64.h delete mode 100644 source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp delete mode 100644 source/Plugins/Process/POSIX/RegisterContext_x86_64.h create mode 100644 source/Plugins/Process/POSIX/RegisterInfos_i386.h create mode 100644 source/Plugins/Process/POSIX/RegisterInfos_mips64.h create mode 100644 source/Plugins/Process/POSIX/RegisterInfos_x86_64.h delete mode 100644 source/Plugins/Process/elf-core/RegisterContextCoreFreeBSD_x86_64.cpp delete mode 100644 source/Plugins/Process/elf-core/RegisterContextCoreFreeBSD_x86_64.h delete mode 100644 source/Plugins/Process/elf-core/RegisterContextCoreLinux_x86_64.cpp delete mode 100644 source/Plugins/Process/elf-core/RegisterContextCoreLinux_x86_64.h create mode 100644 source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp create mode 100644 source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h create mode 100644 source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp create mode 100644 source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h create mode 100644 source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp create mode 100644 source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h create mode 100644 source/Target/SystemRuntime.cpp delete mode 100644 source/Utility/RefCounter.cpp create mode 100644 tools/driver/ELWrapper.cpp create mode 100644 tools/driver/ELWrapper.h create mode 100644 tools/driver/GetOptWrapper.cpp create mode 100644 tools/driver/GetOptWrapper.h create mode 100644 tools/driver/Platform.cpp create mode 100644 tools/driver/Platform.h create mode 100644 tools/lldb-platform/lldb-platform.cpp diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h index 52754ea4e829..e5fab6fe7849 100644 --- a/include/lldb/API/SBHostOS.h +++ b/include/lldb/API/SBHostOS.h @@ -30,7 +30,7 @@ public: static lldb::thread_t ThreadCreate (const char *name, - void *(*thread_function)(void *), + thread_func_t thread_function, void *thread_arg, lldb::SBError *err); @@ -43,7 +43,7 @@ public: lldb::SBError *err); static bool ThreadJoin (lldb::thread_t thread, - void **result, + thread_result_t *result, lldb::SBError *err); diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 784f362122a9..4ecaeaa49920 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -269,6 +269,38 @@ public: lldb::SBError UnloadImage (uint32_t image_token); + //------------------------------------------------------------------ + /// Return the number of different thread-origin extended backtraces + /// this process can support. + /// + /// When the process is stopped and you have an SBThread, lldb may be + /// able to show a backtrace of when that thread was originally created, + /// or the work item was enqueued to it (in the case of a libdispatch + /// queue). + /// + /// @return + /// The number of thread-origin extended backtrace types that may be + /// available. + //------------------------------------------------------------------ + uint32_t + GetNumExtendedBacktraceTypes (); + + //------------------------------------------------------------------ + /// Return the name of one of the thread-origin extended backtrace + /// methods. + /// + /// @param [in] idx + /// The index of the name to return. They will be returned in + /// the order that the user will most likely want to see them. + /// e.g. if the type at index 0 is not available for a thread, + /// see if the type at index 1 provides an extended backtrace. + /// + /// @return + /// The name at that index. + //------------------------------------------------------------------ + const char * + GetExtendedBacktraceTypeAtIndex (uint32_t idx); + protected: friend class SBAddress; friend class SBBreakpoint; diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 15aeed4b600c..7bcf91c16d77 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -747,6 +747,9 @@ public: lldb::SBType GetBasicType(lldb::BasicType type); + lldb::SBValue + CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type); + SBSourceManager GetSourceManager(); diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h index 9645f925035e..d062d7121303 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -94,6 +94,9 @@ public: const char * GetQueueName() const; + lldb::queue_id_t + GetQueueID() const; + void StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); @@ -117,6 +120,9 @@ public: lldb::SBFileSpec &file_spec, uint32_t line); + SBError + JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line); + void RunToAddress (lldb::addr_t addr); @@ -195,6 +201,9 @@ public: bool GetStatus (lldb::SBStream &status) const; + SBThread + GetExtendedBacktrace (const char *type); + protected: friend class SBBreakpoint; friend class SBBreakpointLocation; diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index bd11a1c91e21..30cc3314af3a 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -576,6 +576,12 @@ public: InvokeCallback (StoppointCallbackContext *context, lldb::break_id_t bp_loc_id); + bool + IsHardware() const + { + return m_hardware; + } + protected: friend class Target; //------------------------------------------------------------------ @@ -590,7 +596,10 @@ protected: /// variants that make breakpoints for some common cases. //------------------------------------------------------------------ // This is the generic constructor - Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp); + Breakpoint(Target &target, + lldb::SearchFilterSP &filter_sp, + lldb::BreakpointResolverSP &resolver_sp, + bool hardware); friend class BreakpointLocation; // To call the following two when determining whether to stop. @@ -609,12 +618,13 @@ private: // For Breakpoint only //------------------------------------------------------------------ bool m_being_created; + bool m_hardware; // If this breakpoint is required to use a hardware breakpoint Target &m_target; // The target that holds this breakpoint. lldb::SearchFilterSP m_filter_sp; // The filter that constrains the breakpoint's domain. lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint. BreakpointOptions m_options; // Settable breakpoint options BreakpointLocationList m_locations; // The list of locations currently found for this breakpoint. - std::string m_kind_description; + std::string m_kind_description; void SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind); diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h index 97eb2b46bc0c..c6708db118df 100644 --- a/include/lldb/Breakpoint/BreakpointList.h +++ b/include/lldb/Breakpoint/BreakpointList.h @@ -149,11 +149,17 @@ public: /// @param[in] module_list /// The module list that has changed. /// - /// @param[in] added + /// @param[in] load /// \b true if the modules are loaded, \b false if unloaded. + /// + /// @param[in] delete_locations + /// If \a load is \b false, then delete breakpoint locations when + /// when updating breakpoints. //------------------------------------------------------------------ void - UpdateBreakpoints (ModuleList &module_list, bool added); + UpdateBreakpoints (ModuleList &module_list, + bool load, + bool delete_locations); void UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp); diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index 9ab0a79c6844..f4ba21a385f8 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -324,7 +324,6 @@ public: protected: friend class BreakpointLocationList; - friend class CommandObjectBreakpointCommandAdd; friend class Process; //------------------------------------------------------------------ @@ -375,8 +374,8 @@ private: BreakpointLocation (lldb::break_id_t bid, Breakpoint &owner, const Address &addr, - lldb::tid_t tid = LLDB_INVALID_THREAD_ID, - bool hardware = false); + lldb::tid_t tid, + bool hardware); //------------------------------------------------------------------ // Data members: diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 3db3795453e8..184bdc950cbc 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -134,6 +134,13 @@ public: } protected: + //------------------------------------------------------------------ + /// SetSCMatchesByLine - Takes a symbol context list of matches which supposedly represent the same file and + /// line number in a CU, and find the nearest actual line number that matches, and then filter down the + /// matching addresses to unique entries, and skip the prologue if asked to do so, and then set + /// breakpoint locations in this breakpoint for all the resultant addresses. + void SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident); + Breakpoint *m_breakpoint; // This is the breakpoint we add locations to. private: diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h index 0d4dafc4baab..d7bb8fd777ef 100644 --- a/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/include/lldb/Breakpoint/BreakpointSiteList.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointSite.h" diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h index ccedc511951d..452c6388c82d 100644 --- a/include/lldb/Breakpoint/StoppointLocation.h +++ b/include/lldb/Breakpoint/StoppointLocation.h @@ -72,20 +72,20 @@ public: uint32_t GetHardwareIndex () const { - return m_hw_index; + return m_hardware_index; } bool - HardwarePreferred () const + HardwareRequired () const { - return m_hw_preferred; + return m_hardware; } virtual bool IsHardware () const { - return m_hw_index != LLDB_INVALID_INDEX32; + return m_hardware_index != LLDB_INVALID_INDEX32; } @@ -103,7 +103,7 @@ public: void SetHardwareIndex (uint32_t index) { - m_hw_index = index; + m_hardware_index = index; } @@ -120,8 +120,8 @@ protected: lldb::break_id_t m_loc_id; // Stoppoint location ID lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't // store a full Address since that's not needed for the breakpoint sites. - bool m_hw_preferred; // 1 if this point has been requested to be set using hardware (which may fail due to lack of resources) - uint32_t m_hw_index; // The hardware resource index for this breakpoint/watchpoint + bool m_hardware; // True if this point has been is required to use hardware (which may fail due to lack of resources) + uint32_t m_hardware_index; // The hardware resource index for this breakpoint/watchpoint uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length of the trap opcode for // software breakpoints, or the optional length in bytes for // hardware breakpoints, or the length of the watchpoint. diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index 60cd4a86bd4a..da7cc5c03d38 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -540,6 +540,18 @@ protected: //------------------------------------------------------------------ lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL. std::atomic m_offset; ///< Offset into section if \a m_section_wp is valid... + + //------------------------------------------------------------------ + // Returns true if the m_section_wp once had a reference to a valid + // section shared pointer, but no longer does. This can happen if + // we have an address from a module that gets unloaded and deleted. + // This function should only be called if GetSection() returns an + // empty shared pointer and you want to know if this address used to + // have a valid section. + //------------------------------------------------------------------ + bool + SectionWasDeleted() const; + }; diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h index 3bfa96be0cee..7f2fd77a0934 100644 --- a/include/lldb/Core/ArchSpec.h +++ b/include/lldb/Core/ArchSpec.h @@ -41,6 +41,7 @@ public: eCore_arm_armv5e, eCore_arm_armv5t, eCore_arm_armv6, + eCore_arm_armv6m, eCore_arm_armv7, eCore_arm_armv7f, eCore_arm_armv7s, @@ -53,6 +54,7 @@ public: eCore_thumbv5, eCore_thumbv5e, eCore_thumbv6, + eCore_thumbv6m, eCore_thumbv7, eCore_thumbv7f, eCore_thumbv7s, @@ -60,6 +62,8 @@ public: eCore_thumbv7m, eCore_thumbv7em, + eCore_mips64, + eCore_ppc_generic, eCore_ppc_ppc601, eCore_ppc_ppc602, diff --git a/include/lldb/Core/ConnectionFileDescriptor.h b/include/lldb/Core/ConnectionFileDescriptor.h index fe704d4cadf7..3a2f0dd1ed0b 100644 --- a/include/lldb/Core/ConnectionFileDescriptor.h +++ b/include/lldb/Core/ConnectionFileDescriptor.h @@ -11,20 +11,27 @@ #define liblldb_ConnectionFileDescriptor_h_ // C Includes +#ifdef _WIN32 +typedef unsigned short in_port_t; +#else #include #include #include +#endif // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/Core/Connection.h" #include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" -#include "lldb/Host/SocketAddress.h" namespace lldb_private { +class SocketAddress; + class ConnectionFileDescriptor : public Connection { @@ -70,6 +77,13 @@ public: GetWritePort () const; protected: + + typedef enum + { + eFDTypeFile, // Other FD requireing read/write + eFDTypeSocket, // Socket requiring send/recv + eFDTypeSocketUDP // Unconnected UDP socket requiring sendto/recvfrom + } FDType; void OpenCommandPipe (); @@ -96,20 +110,13 @@ protected: NamedSocketConnect (const char *socket_name, Error *error_ptr); lldb::ConnectionStatus - Close (int& fd, Error *error); - - typedef enum - { - eFDTypeFile, // Other FD requireing read/write - eFDTypeSocket, // Socket requiring send/recv - eFDTypeSocketUDP // Unconnected UDP socket requiring sendto/recvfrom - } FDType; + Close (int& fd, FDType type, Error *error); int m_fd_send; int m_fd_recv; FDType m_fd_send_type; FDType m_fd_recv_type; - SocketAddress m_udp_send_sockaddr; + std::unique_ptr m_udp_send_sockaddr; bool m_should_close_fd; // True if this class should close the file descriptor when it goes away. uint32_t m_socket_timeout_usec; int m_pipe_read; // A pipe that we select on the reading end of along with diff --git a/include/lldb/Core/ConnectionMachPort.h b/include/lldb/Core/ConnectionMachPort.h index 5613e7ee8008..04ec7f69136b 100644 --- a/include/lldb/Core/ConnectionMachPort.h +++ b/include/lldb/Core/ConnectionMachPort.h @@ -12,7 +12,8 @@ #define liblldb_ConnectionMachPort_h_ // C Includes -#include +#include +#include // C++ Includes #include diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Core/ConstString.h index e692d3b96e5d..684cc8f921ed 100644 --- a/include/lldb/Core/ConstString.h +++ b/include/lldb/Core/ConstString.h @@ -86,7 +86,7 @@ public: /// @param[in] cstr /// A pointer to the first character in the C string. The C /// string can be NULL terminated in a buffer that contains - /// more characters than the length of the stirng, or the + /// more characters than the length of the string, or the /// string can be part of another string and a new substring /// can be created. /// @@ -148,11 +148,11 @@ public: /// /b True this object contains a valid non-empty C string, \b /// false otherwise. //------------------------------------------------------------------ - operator bool() const + explicit operator bool() const { return m_string && m_string[0]; } - + //------------------------------------------------------------------ /// Assignment operator /// diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Core/DataExtractor.h index a8593043cb15..c9db2dab73d2 100644 --- a/include/lldb/Core/DataExtractor.h +++ b/include/lldb/Core/DataExtractor.h @@ -467,6 +467,27 @@ public: return ptr; } + //------------------------------------------------------------------ + /// Copy \a length bytes from \a *offset, without swapping bytes. + /// + /// @param[in] offset + /// The offset into this data from which to start copying + /// + /// @param[in] length + /// The length of the data to copy from this object + /// + /// @param[out] dst + /// The buffer to place the output data. + /// + /// @return + /// Returns the number of bytes that were copied, or zero if + /// anything goes wrong. + //------------------------------------------------------------------ + lldb::offset_t + CopyData (lldb::offset_t offset, + lldb::offset_t length, + void *dst) const; + //------------------------------------------------------------------ /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied /// data is treated as a value that can be swapped to match the diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index bed93fe02528..671b378df807 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -13,7 +13,6 @@ #include -#include #include @@ -322,6 +321,9 @@ public: uint32_t GetDisassemblyLineCount () const; + bool + GetAutoOneLineSummaries () const; + bool GetNotifyVoid () const; diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index d6e90071dc5b..f434d56943d4 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -270,7 +270,8 @@ public: const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, - const AddressRange &disasm_range); + const AddressRange &disasm_range, + bool prefer_file_cache); static lldb::DisassemblerSP DisassembleBytes (const ArchSpec &arch, diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 08b97e424913..19a3269ae374 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -69,14 +69,14 @@ /// debugging. The current debugging model is "process centric" where /// all threads must be stopped when any thread is stopped; when /// hitting software breakpoints we must disable the breakpoint by -/// restoring the original breakpoint opcde, single stepping and +/// restoring the original breakpoint opcode, single stepping and /// restoring the breakpoint trap. If all threads were allowed to run /// then other threads could miss the breakpoint. /// /// This class centralizes the code that usually is done in separate /// code paths in a debugger (single step prediction, finding save /// restore locations of registers for unwinding stack frame variables) -/// and emulating the intruction is just a bonus. +/// and emulating the instruction is just a bonus. //---------------------------------------------------------------------- namespace lldb_private { @@ -394,7 +394,7 @@ public: // Mandatory overrides //---------------------------------------------------------------------- virtual bool - SupportsEmulatingIntructionsOfType (InstructionType inst_type) = 0; + SupportsEmulatingInstructionsOfType (InstructionType inst_type) = 0; virtual bool SetTargetTriple (const ArchSpec &arch) = 0; diff --git a/include/lldb/Core/Error.h b/include/lldb/Core/Error.h index 9e45d5f555d6..39c67f621c92 100644 --- a/include/lldb/Core/Error.h +++ b/include/lldb/Core/Error.h @@ -11,11 +11,10 @@ #define __DCError_h__ #if defined(__cplusplus) -#if defined (__APPLE__) -#include -#endif -#include -#include +#include "llvm/Support/DataTypes.h" + +#include +#include #include #include "lldb/lldb-private.h" @@ -70,7 +69,7 @@ public: Error (ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric); explicit - Error (const char* err_str); + Error (const char *format, ...) __attribute__ ((format (printf, 2, 3))); Error (const Error &rhs); //------------------------------------------------------------------ diff --git a/include/lldb/Core/Flags.h b/include/lldb/Core/Flags.h index 233f098ead23..5f4f8830456b 100644 --- a/include/lldb/Core/Flags.h +++ b/include/lldb/Core/Flags.h @@ -13,7 +13,6 @@ #include -#include namespace lldb_private { diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h index ced6f2565d9a..b389946e264c 100644 --- a/include/lldb/Core/Log.h +++ b/include/lldb/Core/Log.h @@ -11,11 +11,10 @@ #define liblldb_Log_h_ // C Includes -#include +#include #include #include #include -#include // C++ Includes // Other libraries and framework includes diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 9c135529f453..1473fb90cf85 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -346,6 +346,32 @@ public: bool append, SymbolContextList& sc_list); + //------------------------------------------------------------------ + /// Find addresses by file/line + /// + /// @param[in] target_sp + /// The target the addresses are desired for. + /// + /// @param[in] file + /// Source file to locate. + /// + /// @param[in] line + /// Source line to locate. + /// + /// @param[in] function + /// Optional filter function. Addresses within this function will be + /// added to the 'local' list. All others will be added to the 'extern' list. + /// + /// @param[out] output_local + /// All matching addresses within 'function' + /// + /// @param[out] output_extern + /// All matching addresses not within 'function' + void FindAddressesForLine (const lldb::TargetSP target_sp, + const FileSpec &file, uint32_t line, + Function *function, + std::vector
&output_local, std::vector
&output_extern); + //------------------------------------------------------------------ /// Find global and static variables by name. /// @@ -723,8 +749,49 @@ public: bool ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr); + //------------------------------------------------------------------ + /// Resolve the symbol context for the given address. + /// + /// Tries to resolve the matching symbol context based on a lookup + /// from the current symbol vendor. If the lazy lookup fails, + /// an attempt is made to parse the eh_frame section to handle + /// stripped symbols. If this fails, an attempt is made to resolve + /// the symbol to the previous address to handle the case of a + /// function with a tail call. + /// + /// Use properties of the modified SymbolContext to inspect any + /// resolved target, module, compilation unit, symbol, function, + /// function block or line entry. Use the return value to determine + /// which of these properties have been modified. + /// + /// @param[in] so_addr + /// A load address to resolve. + /// + /// @param[in] resolve_scope + /// The scope that should be resolved (see SymbolContext::Scope). + /// A combination of flags from the enumeration SymbolContextItem + /// requesting a resolution depth. Note that the flags that are + /// actually resolved may be a superset of the requested flags. + /// For instance, eSymbolContextSymbol requires resolution of + /// eSymbolContextModule, and eSymbolContextFunction requires + /// eSymbolContextSymbol. + /// + /// @param[out] sc + /// The SymbolContext that is modified based on symbol resolution. + /// + /// @param[in] resolve_tail_call_address + /// Determines if so_addr should resolve to a symbol in the case + /// of a function whose last instruction is a call. In this case, + /// the PC can be one past the address range of the function. + /// + /// @return + /// The scope that has been resolved (see SymbolContext::Scope). + /// + /// @see SymbolContext::Scope + //------------------------------------------------------------------ uint32_t - ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc); + ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, + SymbolContext& sc, bool resolve_tail_call_address = false); //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index 1198e4196481..f03f79fb00ce 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -439,7 +439,35 @@ public: bool FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const; - + + + //------------------------------------------------------------------ + /// Find addresses by file/line + /// + /// @param[in] target_sp + /// The target the addresses are desired for. + /// + /// @param[in] file + /// Source file to locate. + /// + /// @param[in] line + /// Source line to locate. + /// + /// @param[in] function + /// Optional filter function. Addresses within this function will be + /// added to the 'local' list. All others will be added to the 'extern' list. + /// + /// @param[out] output_local + /// All matching addresses within 'function' + /// + /// @param[out] output_extern + /// All matching addresses not within 'function' + void FindAddressesForLine (const lldb::TargetSP target_sp, + const FileSpec &file, uint32_t line, + Function *function, + std::vector
&output_local, std::vector
&output_extern); + + bool Remove (const lldb::ModuleSP &module_sp); diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index 10e1ea9f17a9..dfeb7b73ca37 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -288,7 +288,7 @@ public: } - operator bool () const + explicit operator bool () const { if (m_file) return true; diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index c07193b62059..fd80231a44e7 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -38,7 +38,7 @@ namespace lldb_private { eType64, eTypeBytes }; - + Opcode () : m_type (eTypeInvalid) { } @@ -78,7 +78,7 @@ namespace lldb_private { { return m_type; } - + uint8_t GetOpcode8 (uint8_t invalid_opcode = UINT8_MAX) const { @@ -91,7 +91,6 @@ namespace lldb_private { case Opcode::eType32: break; case Opcode::eType64: break; case Opcode::eTypeBytes: break; - break; } return invalid_opcode; } @@ -157,7 +156,7 @@ namespace lldb_private { m_type = eType16; m_data.inst16 = inst; } - + void SetOpcode16_2 (uint32_t inst) { @@ -206,7 +205,7 @@ namespace lldb_private { return m_data.inst.bytes; return NULL; } - + uint32_t GetByteSize () const { @@ -222,7 +221,7 @@ namespace lldb_private { } return 0; } - + // Get the opcode exactly as it would be laid out in memory. uint32_t GetData (DataExtractor &data) const; @@ -246,7 +245,7 @@ namespace lldb_private { } return NULL; } - + lldb::ByteOrder GetDataByteOrder () const; @@ -257,7 +256,7 @@ namespace lldb_private { uint16_t inst16; uint32_t inst32; uint64_t inst64; - struct + struct { uint8_t bytes[16]; // This must be big enough to handle any opcode for any supported target. uint8_t length; diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index 91f8fbb997f9..e02f43f4fa8b 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -131,6 +131,24 @@ public: GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name); + //------------------------------------------------------------------ + // SystemRuntime + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + SystemRuntimeCreateInstance create_callback); + + static bool + UnregisterPlugin (SystemRuntimeCreateInstance create_callback); + + static SystemRuntimeCreateInstance + GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx); + + static SystemRuntimeCreateInstance + GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name); + + //------------------------------------------------------------------ // ObjectFile //------------------------------------------------------------------ diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index ee42467c18bf..d78504c7d285 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -592,7 +592,7 @@ namespace lldb_private { void Reserve (typename Collection::size_type size) { - m_entries.resize (size); + m_entries.reserve (size); } bool @@ -1229,16 +1229,11 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + while(pos != begin && pos[-1].Contains(addr)) + --pos; + if (pos != end && pos->Contains(addr)) - { return std::distance (begin, pos); - } - else if (pos != begin) - { - --pos; - if (pos->Contains(addr)) - return std::distance (begin, pos); - } } return UINT32_MAX; } @@ -1257,19 +1252,12 @@ namespace lldb_private { typename Collection::iterator begin = m_entries.begin(); typename Collection::iterator end = m_entries.end(); typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + while(pos != begin && pos[-1].Contains(addr)) + --pos; if (pos != end && pos->Contains(addr)) - { return &(*pos); - } - else if (pos != begin) - { - --pos; - if (pos->Contains(addr)) - { - return &(*pos); - } - } } return NULL; } @@ -1288,18 +1276,11 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); - if (pos != end && pos->Contains(addr)) - { - return &(*pos); - } - else if (pos != begin) - { + while(pos != begin && pos[-1].Contains(addr)) --pos; - if (pos->Contains(addr)) - { - return &(*pos); - } - } + + if (pos != end && pos->Contains(addr)) + return &(*pos); } return NULL; } @@ -1316,18 +1297,11 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); - if (pos != end && pos->Contains(range)) - { - return &(*pos); - } - else if (pos != begin) - { + while(pos != begin && pos[-1].Contains(range)) --pos; - if (pos->Contains(range)) - { - return &(*pos); - } - } + + if (pos != end && pos->Contains(range)) + return &(*pos); } return NULL; } @@ -1501,12 +1475,15 @@ namespace lldb_private { typename Collection::iterator end = m_entries.end(); typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + while(pos != begin && pos[-1].addr == addr) + --pos; + if (pos != end) { if (pos->addr == addr || !exact_match_only) return &(*pos); } - } + } return NULL; } diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Core/RegularExpression.h index eeeb914bfa90..c116d439b94a 100644 --- a/include/lldb/Core/RegularExpression.h +++ b/include/lldb/Core/RegularExpression.h @@ -11,7 +11,36 @@ #define liblldb_DBRegex_h_ #if defined(__cplusplus) +#ifdef _WIN32 +#include "../lib/Support/regex_impl.h" + +typedef llvm_regmatch_t regmatch_t; +typedef llvm_regex_t regex_t; + +inline int regcomp(llvm_regex_t * a, const char *b, int c) +{ + return llvm_regcomp(a, b, c); +} + +inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d) +{ + return llvm_regerror(a, b, c, d); +} + +inline int regexec(const llvm_regex_t * a, const char * b, size_t c, + llvm_regmatch_t d [], int e) +{ + return llvm_regexec(a, b, c, d, e); +} + +inline void regfree(llvm_regex_t * a) +{ + llvm_regfree(a); +} + +#else #include +#endif #include #include diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Core/StreamGDBRemote.h new file mode 100644 index 000000000000..3fdb6f6e7012 --- /dev/null +++ b/include/lldb/Core/StreamGDBRemote.h @@ -0,0 +1,54 @@ +//===-- StreamGDBRemote.h ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_StreamGDBRemote_h_ +#define liblldb_StreamGDBRemote_h_ + +// C Includes +// C++ Includes + +// Other libraries and framework includes +// Project includes + +#include "lldb/Core/StreamString.h" + +namespace lldb_private { + + class StreamGDBRemote : public StreamString + { + public: + StreamGDBRemote (); + + StreamGDBRemote (uint32_t flags, + uint32_t addr_size, + lldb::ByteOrder byte_order); + + virtual + ~StreamGDBRemote (); + + //------------------------------------------------------------------ + /// Output a block of data to the stream performing GDB-remote escaping. + /// + /// @param[in] s + /// A block of data. + /// + /// @param[in] src_len + /// The amount of data to write. + /// + /// @return + /// Number of bytes written. + //------------------------------------------------------------------ + int + PutEscapedBytes (const void* s, + size_t src_len); + }; + +} // namespace lldb_private + +#endif // liblldb_StreamGDBRemote_h_ diff --git a/include/lldb/Core/UUID.h b/include/lldb/Core/UUID.h index fe72b8eb0c70..3bb14421b1e9 100644 --- a/include/lldb/Core/UUID.h +++ b/include/lldb/Core/UUID.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 5461ca73d082..c7d44322333c 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -114,7 +114,7 @@ public: #if defined (ENABLE_128_BIT_SUPPORT) else if (length >= 16) scalar = *(const __uint128_t *)bytes; #else - else if (length >= 16) scalar = *(const __uint64_t *)bytes; + else if (length >= 16) scalar = *(const uint64_t *)bytes; #endif } return scalar; diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index 0d965d6ccc01..1ef421676ee1 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -12,7 +12,6 @@ // C Includes // C++ Includes -#include #include #include // Other libraries and framework includes @@ -217,229 +216,6 @@ public: } }; - - struct DumpValueObjectOptions - { - uint32_t m_max_ptr_depth; - uint32_t m_max_depth; - bool m_show_types; - bool m_show_location; - bool m_use_objc; - lldb::DynamicValueType m_use_dynamic; - bool m_use_synthetic; - bool m_scope_already_checked; - bool m_flat_output; - uint32_t m_omit_summary_depth; - bool m_ignore_cap; - lldb::Format m_format; - lldb::TypeSummaryImplSP m_summary_sp; - std::string m_root_valobj_name; - bool m_hide_root_type; - bool m_hide_name; - bool m_hide_value; - - DumpValueObjectOptions() : - m_max_ptr_depth(0), - m_max_depth(UINT32_MAX), - m_show_types(false), - m_show_location(false), - m_use_objc(false), - m_use_dynamic(lldb::eNoDynamicValues), - m_use_synthetic(true), - m_scope_already_checked(false), - m_flat_output(false), - m_omit_summary_depth(0), - m_ignore_cap(false), - m_format (lldb::eFormatDefault), - m_summary_sp(), - m_root_valobj_name(), - m_hide_root_type(false), // provide a special compact display for "po" - m_hide_name(false), // provide a special compact display for "po" - m_hide_value(false) // provide a special compact display for "po" - {} - - static const DumpValueObjectOptions - DefaultOptions() - { - static DumpValueObjectOptions g_default_options; - - return g_default_options; - } - - DumpValueObjectOptions (const DumpValueObjectOptions& rhs) : - m_max_ptr_depth(rhs.m_max_ptr_depth), - m_max_depth(rhs.m_max_depth), - m_show_types(rhs.m_show_types), - m_show_location(rhs.m_show_location), - m_use_objc(rhs.m_use_objc), - m_use_dynamic(rhs.m_use_dynamic), - m_use_synthetic(rhs.m_use_synthetic), - m_scope_already_checked(rhs.m_scope_already_checked), - m_flat_output(rhs.m_flat_output), - m_omit_summary_depth(rhs.m_omit_summary_depth), - m_ignore_cap(rhs.m_ignore_cap), - m_format(rhs.m_format), - m_summary_sp(rhs.m_summary_sp), - m_root_valobj_name(rhs.m_root_valobj_name), - m_hide_root_type(rhs.m_hide_root_type), - m_hide_name(rhs.m_hide_name), - m_hide_value(rhs.m_hide_value) - {} - - DumpValueObjectOptions& - SetMaximumPointerDepth(uint32_t depth = 0) - { - m_max_ptr_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetMaximumDepth(uint32_t depth = 0) - { - m_max_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetShowTypes(bool show = false) - { - m_show_types = show; - return *this; - } - - DumpValueObjectOptions& - SetShowLocation(bool show = false) - { - m_show_location = show; - return *this; - } - - DumpValueObjectOptions& - SetUseObjectiveC(bool use = false) - { - m_use_objc = use; - return *this; - } - - DumpValueObjectOptions& - SetShowSummary(bool show = true) - { - if (show == false) - SetOmitSummaryDepth(UINT32_MAX); - else - SetOmitSummaryDepth(0); - return *this; - } - - DumpValueObjectOptions& - SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues) - { - m_use_dynamic = dyn; - return *this; - } - - DumpValueObjectOptions& - SetUseSyntheticValue(bool use_synthetic = true) - { - m_use_synthetic = use_synthetic; - return *this; - } - - DumpValueObjectOptions& - SetScopeChecked(bool check = true) - { - m_scope_already_checked = check; - return *this; - } - - DumpValueObjectOptions& - SetFlatOutput(bool flat = false) - { - m_flat_output = flat; - return *this; - } - - DumpValueObjectOptions& - SetOmitSummaryDepth(uint32_t depth = 0) - { - m_omit_summary_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetIgnoreCap(bool ignore = false) - { - m_ignore_cap = ignore; - return *this; - } - - DumpValueObjectOptions& - SetRawDisplay(bool raw = false) - { - if (raw) - { - SetUseSyntheticValue(false); - SetOmitSummaryDepth(UINT32_MAX); - SetIgnoreCap(true); - SetHideName(false); - SetHideValue(false); - } - else - { - SetUseSyntheticValue(true); - SetOmitSummaryDepth(0); - SetIgnoreCap(false); - SetHideName(false); - SetHideValue(false); - } - return *this; - } - - DumpValueObjectOptions& - SetFormat (lldb::Format format = lldb::eFormatDefault) - { - m_format = format; - return *this; - } - - DumpValueObjectOptions& - SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()) - { - m_summary_sp = summary; - return *this; - } - - DumpValueObjectOptions& - SetRootValueObjectName (const char* name = NULL) - { - if (name) - m_root_valobj_name.assign(name); - else - m_root_valobj_name.clear(); - return *this; - } - - DumpValueObjectOptions& - SetHideRootType (bool hide_root_type = false) - { - m_hide_root_type = hide_root_type; - return *this; - } - - DumpValueObjectOptions& - SetHideName (bool hide_name = false) - { - m_hide_name = hide_name; - return *this; - } - - DumpValueObjectOptions& - SetHideValue (bool hide_value = false) - { - m_hide_value = hide_value; - return *this; - } - }; class EvaluationPoint { @@ -598,6 +374,10 @@ public: ClangASTType GetClangType (); + + // this vends a TypeImpl that is useful at the SB API layer + virtual TypeImpl + GetTypeImpl (); //------------------------------------------------------------------ // Sublasses must implement the functions below. @@ -725,6 +505,9 @@ public: virtual uint64_t GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL); + virtual int64_t + GetValueAsSigned (int64_t fail_value, bool *success = NULL); + virtual bool SetValueFromCString (const char *value_str, Error& error); @@ -768,6 +551,23 @@ public: lldb::ValueObjectSP GetChildAtIndexPath (const std::vector< std::pair > &idxs, size_t* index_of_error = NULL); + + // this will always create the children if necessary + lldb::ValueObjectSP + GetChildAtNamePath (const std::initializer_list &names, + ConstString* name_of_error = NULL); + + lldb::ValueObjectSP + GetChildAtNamePath (const std::vector &names, + ConstString* name_of_error = NULL); + + lldb::ValueObjectSP + GetChildAtNamePath (const std::initializer_list< std::pair > &names, + ConstString* name_of_error = NULL); + + lldb::ValueObjectSP + GetChildAtNamePath (const std::vector< std::pair > &names, + ConstString* name_of_error = NULL); virtual lldb::ValueObjectSP GetChildMemberWithName (const ConstString &name, bool can_create); @@ -937,13 +737,12 @@ public: virtual SymbolContextScope * GetSymbolContextScope(); - static void - DumpValueObject (Stream &s, - ValueObject *valobj); - static void - DumpValueObject (Stream &s, - ValueObject *valobj, - const DumpValueObjectOptions& options); + void + Dump (Stream &s); + + void + Dump (Stream &s, + const DumpValueObjectOptions& options); static lldb::ValueObjectSP CreateValueObjectFromExpression (const char* name, @@ -962,13 +761,11 @@ public: const ExecutionContext& exe_ctx, ClangASTType type); - static void - LogValueObject (Log *log, - ValueObject *valobj); + void + LogValueObject (Log *log); - static void + void LogValueObject (Log *log, - ValueObject *valobj, const DumpValueObjectOptions& options); diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h index c0f6baade3fb..68f88c96e545 100644 --- a/include/lldb/Core/ValueObjectDynamicValue.h +++ b/include/lldb/Core/ValueObjectDynamicValue.h @@ -93,6 +93,9 @@ public: virtual bool SetData (DataExtractor &data, Error &error); + virtual TypeImpl + GetTypeImpl (); + protected: virtual bool UpdateValue (); @@ -116,6 +119,7 @@ protected: TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name lldb::ValueObjectSP m_owning_valobj_sp; lldb::DynamicValueType m_use_dynamic; + TypeImpl m_type_impl; private: friend class ValueObject; diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h index bf77125d86a8..91c8dfb9d0da 100644 --- a/include/lldb/Core/dwarf.h +++ b/include/lldb/Core/dwarf.h @@ -11,7 +11,6 @@ #define DebugBase_dwarf_h_ #include -#include // Get the DWARF constant defintions from llvm #include "llvm/Support/Dwarf.h" diff --git a/include/lldb/DataFormatters/CXXFormatterFunctions.h b/include/lldb/DataFormatters/CXXFormatterFunctions.h index 2f56c56810ab..433c2a3c407b 100644 --- a/include/lldb/DataFormatters/CXXFormatterFunctions.h +++ b/include/lldb/DataFormatters/CXXFormatterFunctions.h @@ -868,6 +868,39 @@ namespace lldb_private { SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + class LibcxxStdUnorderedMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd + { + public: + LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); + + virtual size_t + CalculateNumChildren (); + + virtual lldb::ValueObjectSP + GetChildAtIndex (size_t idx); + + virtual bool + Update(); + + virtual bool + MightHaveChildren (); + + virtual size_t + GetIndexOfChildWithName (const ConstString &name); + + virtual + ~LibcxxStdUnorderedMapSyntheticFrontEnd (); + private: + + ValueObject* m_tree; + size_t m_num_elements; + ValueObject* m_next_element; + std::map m_children; + std::vector > m_elements_cache; + }; + + SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + } // namespace formatters } // namespace lldb_private diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index 499e0fe14d93..ca0714c29f84 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -36,40 +36,19 @@ public: static uint32_t GetCurrentRevision (); - class ValueFormats - { - public: - static lldb::TypeFormatImplSP - GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); - - static lldb::TypeFormatImplSP - GetFormat (const ConstString &type); - - static void - Add (const ConstString &type, const lldb::TypeFormatImplSP &entry); - - static bool - Delete (const ConstString &type); - - static void - Clear (); - - static void - LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton); - - static size_t - GetCount (); - - static lldb::TypeNameSpecifierImplSP - GetTypeNameSpecifierForFormatAtIndex (size_t); - - static lldb::TypeFormatImplSP - GetFormatAtIndex (size_t); - }; + static bool + ShouldPrintAsOneLiner (ValueObject& valobj); + + static lldb::TypeFormatImplSP + GetFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + + static lldb::TypeFormatImplSP + GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); static lldb::TypeSummaryImplSP - GetSummaryFormat(ValueObject& valobj, - lldb::DynamicValueType use_dynamic); + GetSummaryFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); static lldb::TypeSummaryImplSP GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index 941b96c1facc..bd9e20ccc9ee 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -27,29 +27,41 @@ private: struct Entry { private: + bool m_format_cached : 1; bool m_summary_cached : 1; bool m_synthetic_cached : 1; + lldb::TypeFormatImplSP m_format_sp; lldb::TypeSummaryImplSP m_summary_sp; lldb::SyntheticChildrenSP m_synthetic_sp; public: Entry (); + Entry (lldb::TypeFormatImplSP); Entry (lldb::TypeSummaryImplSP); Entry (lldb::SyntheticChildrenSP); - Entry (lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP); + Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP); + bool + IsFormatCached (); + bool IsSummaryCached (); bool IsSyntheticCached (); + lldb::TypeFormatImplSP + GetFormat (); + lldb::TypeSummaryImplSP GetSummary (); lldb::SyntheticChildrenSP GetSynthetic (); + void + SetFormat (lldb::TypeFormatImplSP); + void SetSummary (lldb::TypeSummaryImplSP); @@ -69,12 +81,18 @@ private: public: FormatCache (); + bool + GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp); + bool GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp); bool GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp); + void + SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp); + void SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp); diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index 48a8eda4ad43..6d9a50e8f2c5 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -12,7 +12,6 @@ // C Includes #include -#include // C++ Includes #include @@ -61,7 +60,7 @@ public: if (type) { m_type.m_type_name.assign(type->GetName().GetCString()); - m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type)); + m_type.m_type_pair.SetType(type); } } @@ -72,7 +71,7 @@ public: if (type.IsValid()) { m_type.m_type_name.assign(type.GetConstTypeName().GetCString()); - m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type)); + m_type.m_type_pair.SetType(type); } } @@ -87,16 +86,16 @@ public: lldb::TypeSP GetTypeSP () { - if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid()) - return m_type.m_typeimpl_sp->GetTypeSP(); + if (m_type.m_type_pair.IsValid()) + return m_type.m_type_pair.GetTypeSP(); return lldb::TypeSP(); } ClangASTType GetClangASTType () { - if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid()) - return m_type.m_typeimpl_sp->GetClangASTType(); + if (m_type.m_type_pair.IsValid()) + return m_type.m_type_pair.GetClangASTType(); return ClangASTType(); } @@ -109,12 +108,11 @@ public: private: bool m_is_regex; // this works better than TypeAndOrName because the latter only wraps a TypeSP - // whereas TypeImplSP can also be backed by a ClangASTType which is more commonly - // used in LLDB. moreover, TypeImplSP is also what is currently backing SBType + // whereas TypePair can also be backed by a ClangASTType struct TypeOrName { std::string m_type_name; - lldb::TypeImplSP m_typeimpl_sp; + TypePair m_type_pair; }; TypeOrName m_type; diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index 162e25143f27..3c90c993e0c4 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -23,6 +23,8 @@ #include "lldb/DataFormatters/TypeCategory.h" #include "lldb/DataFormatters/TypeCategoryMap.h" +#include + namespace lldb_private { // this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization @@ -32,8 +34,6 @@ namespace lldb_private { class FormatManager : public IFormatChangeListener { - typedef FormatNavigator ValueNavigator; - typedef ValueNavigator::MapType ValueMap; typedef FormatMap NamedSummariesMap; typedef TypeCategoryMap::MapType::iterator CategoryMapIterator; public: @@ -42,12 +42,6 @@ public: FormatManager (); - ValueNavigator& - GetValueNavigator () - { - return m_value_nav; - } - NamedSummariesMap& GetNamedSummaryNavigator () { @@ -124,6 +118,9 @@ public: lldb::TypeCategoryImplSP GetCategory (const ConstString& category_name, bool can_create = true); + + lldb::TypeFormatImplSP + GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); lldb::TypeSummaryImplSP GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); @@ -141,6 +138,10 @@ public: GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp); #endif + lldb::TypeFormatImplSP + GetFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + lldb::TypeSummaryImplSP GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); @@ -188,10 +189,17 @@ public: static lldb::Format GetSingleItemFormat (lldb::Format vector_format); + // this returns true if the ValueObjectPrinter is *highly encouraged* + // to actually represent this ValueObject in one-liner format + // If this object has a summary formatter, however, we should not + // try and do one-lining, just let the summary do the right thing + bool + ShouldPrintAsOneLiner (ValueObject& valobj); + void Changed () { - __sync_add_and_fetch(&m_last_revision, +1); + ++m_last_revision; m_format_cache.Clear (); } @@ -207,9 +215,8 @@ public: private: FormatCache m_format_cache; - ValueNavigator m_value_nav; NamedSummariesMap m_named_summaries_map; - uint32_t m_last_revision; + std::atomic m_last_revision; TypeCategoryMap m_categories_map; ConstString m_default_category_name; diff --git a/include/lldb/DataFormatters/FormatNavigator.h b/include/lldb/DataFormatters/FormatNavigator.h index a738cfd069e7..cd5f6824e199 100644 --- a/include/lldb/DataFormatters/FormatNavigator.h +++ b/include/lldb/DataFormatters/FormatNavigator.h @@ -76,7 +76,7 @@ GetValidTypeName_Impl (const ConstString& type) { int strip_len = 0; - if (type == false) + if ((bool)type == false) return type; const char* type_cstr = type.AsCString(); diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index b76d84f4772f..6461c4e97e4e 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -24,6 +24,8 @@ namespace lldb_private { class TypeCategoryImpl { private: + typedef FormatNavigator ValueNavigator; + typedef FormatNavigator RegexValueNavigator; typedef FormatNavigator SummaryNavigator; typedef FormatNavigator RegexSummaryNavigator; @@ -35,11 +37,16 @@ namespace lldb_private { typedef FormatNavigator SynthNavigator; typedef FormatNavigator RegexSynthNavigator; #endif // #ifndef LLDB_DISABLE_PYTHON - + + typedef ValueNavigator::MapType ValueMap; + typedef RegexValueNavigator::MapType RegexValueMap; + typedef SummaryNavigator::MapType SummaryMap; typedef RegexSummaryNavigator::MapType RegexSummaryMap; + typedef FilterNavigator::MapType FilterMap; typedef RegexFilterNavigator::MapType RegexFilterMap; + #ifndef LLDB_DISABLE_PYTHON typedef SynthNavigator::MapType SynthMap; typedef RegexSynthNavigator::MapType RegexSynthMap; @@ -49,9 +56,13 @@ namespace lldb_private { typedef uint16_t FormatCategoryItems; static const uint16_t ALL_ITEM_TYPES = UINT16_MAX; + + typedef ValueNavigator::SharedPointer ValueNavigatorSP; + typedef RegexValueNavigator::SharedPointer RegexValueNavigatorSP; typedef SummaryNavigator::SharedPointer SummaryNavigatorSP; typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP; + typedef FilterNavigator::SharedPointer FilterNavigatorSP; typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP; #ifndef LLDB_DISABLE_PYTHON @@ -62,6 +73,18 @@ namespace lldb_private { TypeCategoryImpl (IFormatChangeListener* clist, ConstString name); + ValueNavigatorSP + GetValueNavigator () + { + return ValueNavigatorSP(m_value_nav); + } + + RegexValueNavigatorSP + GetRegexValueNavigator () + { + return RegexValueNavigatorSP(m_regex_value_nav); + } + SummaryNavigatorSP GetSummaryNavigator () { @@ -85,6 +108,9 @@ namespace lldb_private { { return RegexFilterNavigatorSP(m_regex_filter_nav); } + + ValueNavigator::MapValueType + GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); SummaryNavigator::MapValueType GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); @@ -97,8 +123,14 @@ namespace lldb_private { GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp); #endif + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForFormatAtIndex (size_t index); + lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForSummaryAtIndex (size_t index); + + ValueNavigator::MapValueType + GetFormatAtIndex (size_t index); SummaryNavigator::MapValueType GetSummaryAtIndex (size_t index); @@ -145,6 +177,13 @@ namespace lldb_private { return m_enabled_position; } + + bool + Get (ValueObject& valobj, + lldb::TypeFormatImplSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason = NULL); + bool Get (ValueObject& valobj, lldb::TypeSummaryImplSP& entry, @@ -183,10 +222,15 @@ namespace lldb_private { typedef std::shared_ptr SharedPointer; private: + ValueNavigator::SharedPointer m_value_nav; + RegexValueNavigator::SharedPointer m_regex_value_nav; + SummaryNavigator::SharedPointer m_summary_nav; RegexSummaryNavigator::SharedPointer m_regex_summary_nav; + FilterNavigator::SharedPointer m_filter_nav; RegexFilterNavigator::SharedPointer m_regex_filter_nav; + #ifndef LLDB_DISABLE_PYTHON SynthNavigator::SharedPointer m_synth_nav; RegexSynthNavigator::SharedPointer m_regex_synth_nav; @@ -213,6 +257,9 @@ namespace lldb_private { friend class TypeCategoryMap; + friend class FormatNavigator; + friend class FormatNavigator; + friend class FormatNavigator; friend class FormatNavigator; diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index c2465ad13aa7..6bed18719893 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -93,6 +93,10 @@ namespace lldb_private { { return m_map.size(); } + + lldb::TypeFormatImplSP + GetFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); lldb::TypeSummaryImplSP GetSummaryFormat (ValueObject& valobj, diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 2183384b9d62..1c195ab2ba4d 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -12,7 +12,6 @@ // C Includes #include -#include // C++ Includes #include @@ -239,7 +238,7 @@ namespace lldb_private { } bool - IsOneliner () const + IsOneLiner () const { return m_flags.GetShowMembersOneLiner(); } @@ -281,7 +280,7 @@ namespace lldb_private { } void - SetIsOneliner (bool value) + SetIsOneLiner (bool value) { m_flags.SetShowMembersOneLiner(value); } diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index a32f4b761175..18b9d011e96a 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -12,7 +12,6 @@ // C Includes #include -#include // C++ Includes #include @@ -533,6 +532,12 @@ namespace lldb_private { FrontEnd (std::string pclass, ValueObject &backend); + bool + IsValid () + { + return m_wrapper_sp.get() != nullptr && m_wrapper_sp->operator bool() && m_interpreter != nullptr; + } + virtual ~FrontEnd (); @@ -582,8 +587,11 @@ namespace lldb_private { virtual SyntheticChildrenFrontEnd::AutoPointer GetFrontEnd(ValueObject &backend) { - return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend)); - } + auto synth_ptr = SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend)); + if (synth_ptr && ((FrontEnd*)synth_ptr.get())->IsValid()) + return synth_ptr; + return NULL; + } private: DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren); diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h new file mode 100644 index 000000000000..4e23ceedcc16 --- /dev/null +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -0,0 +1,394 @@ +//===-- ValueObjectPrinter.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_ValueObjectPrinter_h_ +#define lldb_ValueObjectPrinter_h_ + +// C Includes +// C++ Includes + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/lldb-public.h" + +#include "lldb/Core/Stream.h" +#include "lldb/Core/ValueObject.h" +#include "lldb/DataFormatters/TypeSummary.h" + +namespace lldb_private { + +struct DumpValueObjectOptions +{ + uint32_t m_max_ptr_depth; + uint32_t m_max_depth; + bool m_show_types; + bool m_show_location; + bool m_use_objc; + lldb::DynamicValueType m_use_dynamic; + bool m_use_synthetic; + bool m_scope_already_checked; + bool m_flat_output; + uint32_t m_omit_summary_depth; + bool m_ignore_cap; + lldb::Format m_format; + lldb::TypeSummaryImplSP m_summary_sp; + std::string m_root_valobj_name; + bool m_hide_root_type; + bool m_hide_name; + bool m_hide_value; + bool m_be_raw; + + DumpValueObjectOptions() : + m_max_ptr_depth(0), + m_max_depth(UINT32_MAX), + m_show_types(false), + m_show_location(false), + m_use_objc(false), + m_use_dynamic(lldb::eNoDynamicValues), + m_use_synthetic(true), + m_scope_already_checked(false), + m_flat_output(false), + m_omit_summary_depth(0), + m_ignore_cap(false), + m_format (lldb::eFormatDefault), + m_summary_sp(), + m_root_valobj_name(), + m_hide_root_type(false), // provide a special compact display for "po" + m_hide_name(false), // provide a special compact display for "po" + m_hide_value(false), // provide a special compact display for "po" + m_be_raw(false) + {} + + static const DumpValueObjectOptions + DefaultOptions() + { + static DumpValueObjectOptions g_default_options; + + return g_default_options; + } + + DumpValueObjectOptions (const DumpValueObjectOptions& rhs) : + m_max_ptr_depth(rhs.m_max_ptr_depth), + m_max_depth(rhs.m_max_depth), + m_show_types(rhs.m_show_types), + m_show_location(rhs.m_show_location), + m_use_objc(rhs.m_use_objc), + m_use_dynamic(rhs.m_use_dynamic), + m_use_synthetic(rhs.m_use_synthetic), + m_scope_already_checked(rhs.m_scope_already_checked), + m_flat_output(rhs.m_flat_output), + m_omit_summary_depth(rhs.m_omit_summary_depth), + m_ignore_cap(rhs.m_ignore_cap), + m_format(rhs.m_format), + m_summary_sp(rhs.m_summary_sp), + m_root_valobj_name(rhs.m_root_valobj_name), + m_hide_root_type(rhs.m_hide_root_type), + m_hide_name(rhs.m_hide_name), + m_hide_value(rhs.m_hide_value), + m_be_raw(rhs.m_be_raw) + {} + + DumpValueObjectOptions& + SetMaximumPointerDepth(uint32_t depth = 0) + { + m_max_ptr_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetMaximumDepth(uint32_t depth = 0) + { + m_max_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetShowTypes(bool show = false) + { + m_show_types = show; + return *this; + } + + DumpValueObjectOptions& + SetShowLocation(bool show = false) + { + m_show_location = show; + return *this; + } + + DumpValueObjectOptions& + SetUseObjectiveC(bool use = false) + { + m_use_objc = use; + return *this; + } + + DumpValueObjectOptions& + SetShowSummary(bool show = true) + { + if (show == false) + SetOmitSummaryDepth(UINT32_MAX); + else + SetOmitSummaryDepth(0); + return *this; + } + + DumpValueObjectOptions& + SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues) + { + m_use_dynamic = dyn; + return *this; + } + + DumpValueObjectOptions& + SetUseSyntheticValue(bool use_synthetic = true) + { + m_use_synthetic = use_synthetic; + return *this; + } + + DumpValueObjectOptions& + SetScopeChecked(bool check = true) + { + m_scope_already_checked = check; + return *this; + } + + DumpValueObjectOptions& + SetFlatOutput(bool flat = false) + { + m_flat_output = flat; + return *this; + } + + DumpValueObjectOptions& + SetOmitSummaryDepth(uint32_t depth = 0) + { + m_omit_summary_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetIgnoreCap(bool ignore = false) + { + m_ignore_cap = ignore; + return *this; + } + + DumpValueObjectOptions& + SetRawDisplay(bool raw = false) + { + if (raw) + { + SetUseSyntheticValue(false); + SetOmitSummaryDepth(UINT32_MAX); + SetIgnoreCap(true); + SetHideName(false); + SetHideValue(false); + m_be_raw = true; + } + else + { + SetUseSyntheticValue(true); + SetOmitSummaryDepth(0); + SetIgnoreCap(false); + SetHideName(false); + SetHideValue(false); + m_be_raw = false; + } + return *this; + } + + DumpValueObjectOptions& + SetFormat (lldb::Format format = lldb::eFormatDefault) + { + m_format = format; + return *this; + } + + DumpValueObjectOptions& + SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()) + { + m_summary_sp = summary; + return *this; + } + + DumpValueObjectOptions& + SetRootValueObjectName (const char* name = NULL) + { + if (name) + m_root_valobj_name.assign(name); + else + m_root_valobj_name.clear(); + return *this; + } + + DumpValueObjectOptions& + SetHideRootType (bool hide_root_type = false) + { + m_hide_root_type = hide_root_type; + return *this; + } + + DumpValueObjectOptions& + SetHideName (bool hide_name = false) + { + m_hide_name = hide_name; + return *this; + } + + DumpValueObjectOptions& + SetHideValue (bool hide_value = false) + { + m_hide_value = hide_value; + return *this; + } +}; + +class ValueObjectPrinter +{ +public: + + ValueObjectPrinter (ValueObject* valobj, + Stream* s, + const DumpValueObjectOptions& options); + + ~ValueObjectPrinter () {} + + bool + PrintValueObject (); + + bool + PrintChildrenOneLiner (bool hide_names); + +protected: + + // only this class (and subclasses, if any) should ever be concerned with + // the depth mechanism + ValueObjectPrinter (ValueObject* valobj, + Stream* s, + const DumpValueObjectOptions& options, + uint32_t ptr_depth, + uint32_t curr_depth); + + // we should actually be using delegating constructors here + // but some versions of GCC still have trouble with those + void + Init (ValueObject* valobj, + Stream* s, + const DumpValueObjectOptions& options, + uint32_t ptr_depth, + uint32_t curr_depth); + + bool + GetDynamicValueIfNeeded (); + + const char* + GetDescriptionForDisplay (); + + const char* + GetRootNameForDisplay (const char* if_fail = nullptr); + + bool + ShouldPrintValueObject (); + + bool + IsNil (); + + bool + IsPtr (); + + bool + IsRef (); + + bool + IsAggregate (); + + bool + PrintLocationIfNeeded (); + + bool + PrintTypeIfNeeded (); + + bool + PrintNameIfNeeded (bool show_type); + + bool + CheckScopeIfNeeded (); + + TypeSummaryImpl* + GetSummaryFormatter (); + + void + GetValueSummaryError (std::string& value, + std::string& summary, + std::string& error); + + bool + PrintValueAndSummaryIfNeeded (bool& value_printed, + bool& summary_printed); + + bool + PrintObjectDescriptionIfNeeded (bool value_printed, + bool summary_printed); + + bool + ShouldPrintChildren (bool is_failed_description, + uint32_t& curr_ptr_depth); + + ValueObject* + GetValueObjectForChildrenGeneration (); + + void + PrintChildrenPreamble (); + + void + PrintChildrenPostamble (bool print_dotdotdot); + + void + PrintChild (lldb::ValueObjectSP child_sp, + uint32_t curr_ptr_depth); + + uint32_t + GetMaxNumChildrenToPrint (bool& print_dotdotdot); + + void + PrintChildren (uint32_t curr_ptr_depth); + + void + PrintChildrenIfNeeded (bool value_printed, + bool summary_printed); + +private: + + ValueObject *m_orig_valobj; + ValueObject *m_valobj; + Stream *m_stream; + DumpValueObjectOptions options; + Flags m_type_flags; + ClangASTType m_clang_type; + uint32_t m_ptr_depth; + uint32_t m_curr_depth; + LazyBool m_should_print; + LazyBool m_is_nil; + LazyBool m_is_ptr; + LazyBool m_is_ref; + LazyBool m_is_aggregate; + std::pair m_summary_formatter; + std::string m_value; + std::string m_summary; + std::string m_error; + + DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter); +}; + +} // namespace lldb_private + +#endif // lldb_ValueObjectPrinter_h_ diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h index b2a43e0ac75f..b04e1bd6f116 100644 --- a/include/lldb/Expression/ClangExpressionDeclMap.h +++ b/include/lldb/Expression/ClangExpressionDeclMap.h @@ -291,6 +291,9 @@ public: /// @param[in] name /// The name of the symbol. /// + /// @param[in] module + /// The module to limit the search to. This can be NULL + /// /// @return /// Valid load address for the symbol //------------------------------------------------------------------ @@ -298,7 +301,8 @@ public: GetSymbolAddress (Target &target, Process *process, const ConstString &name, - lldb::SymbolType symbol_type); + lldb::SymbolType symbol_type, + Module *module = NULL); lldb::addr_t GetSymbolAddress (const ConstString &name, @@ -504,12 +508,16 @@ private: /// @param[in] name /// The name as a plain C string. /// + /// @param[in] module + /// The module to limit the search to. This can be NULL + /// /// @return /// The LLDB Symbol found, or NULL if none was found. - //--------------------------------------------------------- + //------------------------------------------------------------------ const Symbol * FindGlobalDataSymbol (Target &target, - const ConstString &name); + const ConstString &name, + Module *module = NULL); //------------------------------------------------------------------ /// Given a target, find a variable that matches the given name and diff --git a/include/lldb/Expression/ClangFunction.h b/include/lldb/Expression/ClangFunction.h index 3f96f7bd3117..9cb22ed15cb5 100644 --- a/include/lldb/Expression/ClangFunction.h +++ b/include/lldb/Expression/ClangFunction.h @@ -67,8 +67,8 @@ class ClangFunction : public ClangExpression { friend class ASTStructExtractor; public: - //------------------------------------------------------------------ - /// Constructor + //------------------------------------------------------------------ + /// Constructor /// /// @param[in] exe_scope /// An execution context scope that gets us at least a target and @@ -84,14 +84,14 @@ public: /// @param[in] arg_value_list /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). - //------------------------------------------------------------------ - ClangFunction (ExecutionContextScope &exe_scope, + //------------------------------------------------------------------ + ClangFunction (ExecutionContextScope &exe_scope, Function &function_ptr, ClangASTContext *ast_context, const ValueList &arg_value_list); //------------------------------------------------------------------ - /// Constructor + /// Constructor /// /// @param[in] exe_scope /// An execution context scope that gets us at least a target and @@ -110,32 +110,32 @@ public: /// @param[in] arg_value_list /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). - //------------------------------------------------------------------ - ClangFunction (ExecutionContextScope &exe_scope, + //------------------------------------------------------------------ + ClangFunction (ExecutionContextScope &exe_scope, const ClangASTType &return_type, const Address& function_address, const ValueList &arg_value_list); //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - virtual + /// Destructor + //------------------------------------------------------------------ + virtual ~ClangFunction(); //------------------------------------------------------------------ - /// Compile the wrapper function + /// Compile the wrapper function /// /// @param[in] errors /// The stream to print parser errors to. /// /// @return /// The number of errors. - //------------------------------------------------------------------ + //------------------------------------------------------------------ unsigned CompileFunction (Stream &errors); //------------------------------------------------------------------ - /// Insert the default function wrapper and its default argument struct + /// Insert the default function wrapper and its default argument struct /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -151,14 +151,14 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool InsertFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors); //------------------------------------------------------------------ - /// Insert the default function wrapper (using the JIT) + /// Insert the default function wrapper (using the JIT) /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -169,12 +169,12 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors); //------------------------------------------------------------------ - /// Insert the default function argument struct + /// Insert the default function argument struct /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -190,13 +190,13 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors); //------------------------------------------------------------------ - /// Insert an argument struct with a non-default function address and + /// Insert an argument struct with a non-default function address and /// non-default argument values /// /// @param[in] exe_ctx @@ -219,7 +219,7 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Address function_address, @@ -227,7 +227,7 @@ public: Stream &errors); //------------------------------------------------------------------ - /// [Static] Execute a function, passing it a single void* parameter. + /// [Static] Execute a function, passing it a single void* parameter. /// ClangFunction uses this to call the wrapper function. /// /// @param[in] exe_ctx @@ -266,7 +266,7 @@ public: /// /// @return /// Returns one of the ExecutionResults enum indicating function call status. - //------------------------------------------------------------------ + //------------------------------------------------------------------ static ExecutionResults ExecuteFunction (ExecutionContext &exe_ctx, lldb::addr_t function_address, @@ -446,7 +446,7 @@ public: /// /// @return /// A ThreadPlan for executing the function. - //------------------------------------------------------------------ + //------------------------------------------------------------------ static ThreadPlan * GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t func_addr, @@ -482,7 +482,7 @@ public: /// /// @return /// A ThreadPlan for executing the function. - //------------------------------------------------------------------ + //------------------------------------------------------------------ ThreadPlan * GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, @@ -514,7 +514,7 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value); @@ -528,7 +528,7 @@ public: /// /// @param[in] args_addr /// The address of the argument struct. - //------------------------------------------------------------------ + //------------------------------------------------------------------ void DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr); @@ -614,9 +614,9 @@ public: return m_arg_values; } private: - //------------------------------------------------------------------ - // For ClangFunction only - //------------------------------------------------------------------ + //------------------------------------------------------------------ + // For ClangFunction only + //------------------------------------------------------------------ std::unique_ptr m_parser; ///< The parser responsible for compiling the function. std::unique_ptr m_execution_unit_ap; @@ -624,17 +624,18 @@ private: Function *m_function_ptr; ///< The function we're going to call. May be NULL if we don't have debug info for the function. Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type. ClangASTType m_function_return_type; ///< The opaque clang qual type for the function return type. - ClangASTContext *m_clang_ast_context; ///< This is the clang_ast_context that we're getting types from the and value, and the function return the function pointer is NULL. std::string m_wrapper_function_name; ///< The name of the wrapper function. std::string m_wrapper_function_text; ///< The contents of the wrapper function. std::string m_wrapper_struct_name; ///< The name of the struct that contains the target function address, arguments, and result. std::list m_wrapper_args_addrs; ///< The addresses of the arguments to the wrapper function. + std::unique_ptr m_struct_extractor; ///< The class that generates the argument struct below. + bool m_struct_valid; ///< True if the ASTStructExtractor has populated the variables below. - //------------------------------------------------------------------ - /// These values are populated by the ASTStructExtractor + //------------------------------------------------------------------ + /// These values are populated by the ASTStructExtractor size_t m_struct_size; ///< The size of the argument struct, in bytes. std::vector m_member_offsets; ///< The offset of each member in the struct, in bytes. uint64_t m_return_size; ///< The size of the result variable, in bytes. diff --git a/include/lldb/Expression/ClangUserExpression.h b/include/lldb/Expression/ClangUserExpression.h index 47bfebb46648..b8c3c128acf4 100644 --- a/include/lldb/Expression/ClangUserExpression.h +++ b/include/lldb/Expression/ClangUserExpression.h @@ -126,13 +126,8 @@ public: /// The execution context to use when looking up entities that /// are needed for parsing (locations of variables, etc.) /// - /// @param[in] unwind_on_error - /// If true, and the execution stops before completion, we unwind the - /// function call, and return the program state to what it was before the - /// execution. If false, we leave the program in the stopped state. - /// - /// @param[in] ignore_breakpoints - /// If true, ignore breakpoints while executing the expression. + /// @param[in] options + /// Expression evaluation options. /// /// @param[in] shared_ptr_to_me /// This is a shared pointer to this ClangUserExpression. This is @@ -145,29 +140,15 @@ public: /// A pointer to direct at the persistent variable in which the /// expression's result is stored. /// - /// @param[in] try_all_threads - /// If true, then we will try to run all threads if the function doesn't complete on - /// one thread. See timeout_usec for the interaction of this variable and - /// the timeout. - /// - /// @param[in] timeout_usec - /// Timeout value (0 for no timeout). If try_all_threads is true, then we - /// will try on one thread for the lesser of .25 sec and half the total timeout. - /// then switch to running all threads, otherwise this will be the total timeout. - /// - /// /// @return /// A Process::Execution results value. //------------------------------------------------------------------ ExecutionResults Execute (Stream &error_stream, ExecutionContext &exe_ctx, - bool unwind_on_error, - bool ignore_breakpoints, + const EvaluateExpressionOptions& options, ClangUserExpressionSP &shared_ptr_to_me, - lldb::ClangExpressionVariableSP &result, - bool try_all_threads, - uint32_t timeout_usec); + lldb::ClangExpressionVariableSP &result); ThreadPlan * GetThreadPlanToExecuteJITExpression (Stream &error_stream, @@ -300,25 +281,8 @@ public: /// @param[in] exe_ctx /// The execution context to use when evaluating the expression. /// - /// @param[in] execution_policy - /// Determines whether or not to try using the IR interpreter to - /// avoid running the expression on the parser. - /// - /// @param[in] language - /// If not eLanguageTypeUnknown, a language to use when parsing - /// the expression. Currently restricted to those languages - /// supported by Clang. - /// - /// @param[in] unwind_on_error - /// True if the thread's state should be restored in the case - /// of an error. - /// - /// @param[in] ignore_breakpoints - /// If true, ignore breakpoints while executing the expression. - /// - /// @param[in] result_type - /// If not eResultTypeAny, the type of the desired result. Will - /// result in parse errors if impossible. + /// @param[in] options + /// Expression evaluation options. /// /// @param[in] expr_cstr /// A C string containing the expression to be evaluated. @@ -330,45 +294,20 @@ public: /// @param[in/out] result_valobj_sp /// If execution is successful, the result valobj is placed here. /// - /// @param[in] try_all_threads - /// If true, then we will try to run all threads if the function doesn't complete on - /// one thread. See timeout_usec for the interaction of this variable and - /// the timeout. - /// - /// @param[in] timeout_usec - /// Timeout value (0 for no timeout). If try_all_threads is true, then we - /// will try on one thread for the lesser of .25 sec and half the total timeout. - /// then switch to running all threads, otherwise this will be the total timeout. + /// @param[out] + /// Filled in with an error in case the expression evaluation + /// fails to parse, run, or evaluated. /// /// @result /// A Process::ExecutionResults value. eExecutionCompleted for success. //------------------------------------------------------------------ static ExecutionResults Evaluate (ExecutionContext &exe_ctx, - lldb_private::ExecutionPolicy execution_policy, - lldb::LanguageType language, - ResultType desired_type, - bool unwind_on_error, - bool ignore_breakpoints, + const EvaluateExpressionOptions& options, const char *expr_cstr, const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp, - bool try_all_threads, - uint32_t timeout_usec); - - static ExecutionResults - EvaluateWithError (ExecutionContext &exe_ctx, - lldb_private::ExecutionPolicy execution_policy, - lldb::LanguageType language, - ResultType desired_type, - bool unwind_on_error, - bool ignore_breakpoints, - const char *expr_cstr, - const char *expr_prefix, - lldb::ValueObjectSP &result_valobj_sp, - Error &error, - bool try_all_threads, - uint32_t timeout_usec); + Error &error); static const Error::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result from the expression. private: diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h index 2692831ecc84..5ecdf7fe9ee5 100644 --- a/include/lldb/Expression/DWARFExpression.h +++ b/include/lldb/Expression/DWARFExpression.h @@ -58,7 +58,8 @@ public: /// @param[in] data_length /// The byte length of the location expression. //------------------------------------------------------------------ - DWARFExpression(const DataExtractor& data, + DWARFExpression(lldb::ModuleSP module, + const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); @@ -172,6 +173,9 @@ public: /// Make the expression parser read its location information from a /// given data source /// + /// @param[in] module_sp + /// The module that defines the DWARF expression. + /// /// @param[in] data /// A data extractor configured to read the DWARF location expression's /// bytecode. @@ -183,7 +187,7 @@ public: /// The byte length of the location expression. //------------------------------------------------------------------ void - SetOpcodeData(const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); + SetOpcodeData(lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); //------------------------------------------------------------------ /// Copy the DWARF location expression into a local buffer. @@ -199,6 +203,9 @@ public: /// the data, it shouldn't amount to that much for the variables we /// end up parsing. /// + /// @param[in] module_sp + /// The module that defines the DWARF expression. + /// /// @param[in] data /// A data extractor configured to read and copy the DWARF /// location expression's bytecode. @@ -210,7 +217,8 @@ public: /// The byte length of the location expression. //------------------------------------------------------------------ void - CopyOpcodeData (const DataExtractor& data, + CopyOpcodeData (lldb::ModuleSP module_sp, + const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); @@ -279,6 +287,9 @@ public: /// expression. The location expression may access the target's /// memory, especially if it comes from the expression parser. /// + /// @param[in] opcode_ctx + /// The module which defined the expression. + /// /// @param[in] opcodes /// This is a static method so the opcodes need to be provided /// explicitly. @@ -332,6 +343,7 @@ public: ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx, + lldb::ModuleSP opcode_ctx, const DataExtractor& opcodes, const lldb::offset_t offset, const lldb::offset_t length, @@ -410,7 +422,8 @@ protected: //------------------------------------------------------------------ /// Classes that inherit from DWARFExpression can see and modify these //------------------------------------------------------------------ - + + lldb::ModuleWP m_module_wp; ///< Module which defined this expression. DataExtractor m_data; ///< A data extractor capable of reading opcode bytes lldb::RegisterKind m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_ lldb::addr_t m_loclist_slide; ///< A value used to slide the location list offsets so that diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index 885b6516b0c6..2820317e108e 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -287,7 +287,8 @@ private: /// Allocated space. //------------------------------------------------------------------ virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID); + unsigned SectionID, + llvm::StringRef SectionName); //------------------------------------------------------------------ /// Allocate space for data, and add it to the m_spaceBlocks map @@ -308,7 +309,9 @@ private: /// Allocated space. //------------------------------------------------------------------ virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID, bool IsReadOnly); + unsigned SectionID, + llvm::StringRef SectionName, + bool IsReadOnly); //------------------------------------------------------------------ /// Allocate space for a global variable, and add it to the @@ -388,6 +391,10 @@ private: return m_default_mm_ap->GetNumStubSlabs(); } + virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { + return m_default_mm_ap->registerEHFrames(Addr, LoadAddr, Size); + } + //------------------------------------------------------------------ /// Passthrough interface stub //------------------------------------------------------------------ diff --git a/include/lldb/Expression/IRForTarget.h b/include/lldb/Expression/IRForTarget.h index 151bf2ab4774..566328772502 100644 --- a/include/lldb/Expression/IRForTarget.h +++ b/include/lldb/Expression/IRForTarget.h @@ -19,6 +19,7 @@ #include "llvm/Pass.h" #include +#include namespace llvm { class BasicBlock; diff --git a/include/lldb/Host/Condition.h b/include/lldb/Host/Condition.h index 98439ee2ebdf..2f1858b75a56 100644 --- a/include/lldb/Host/Condition.h +++ b/include/lldb/Host/Condition.h @@ -12,7 +12,7 @@ #if defined(__cplusplus) -#include +#include "lldb/lldb-types.h" #include "lldb/Host/Mutex.h" namespace lldb_private { @@ -105,7 +105,7 @@ protected: //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ - pthread_cond_t m_condition; ///< The condition variable. + lldb::condition_t m_condition; ///< The condition variable. //------------------------------------------------------------------ /// Get accessor to the pthread condition object. @@ -113,7 +113,7 @@ protected: /// @return /// A pointer to the condition variable owned by this object. //------------------------------------------------------------------ - pthread_cond_t * + lldb::condition_t * GetCondition (); }; diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h index 2d5d39baac3d..80616b747cf5 100644 --- a/include/lldb/Host/Config.h +++ b/include/lldb/Host/Config.h @@ -14,7 +14,7 @@ #include "lldb/Host/macosx/Config.h" -#elif defined(__linux__) +#elif defined(__linux__) || defined(__GNU__) #include "lldb/Host/linux/Config.h" @@ -26,6 +26,10 @@ #include "lldb/Host/mingw/Config.h" +#elif defined(_MSC_VER) + +#include "lldb/Host/msvc/Config.h" + #else #error undefined platform diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index df7fe92cccba..7ca582402b32 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -11,7 +11,9 @@ #define liblldb_File_h_ #if defined(__cplusplus) +#include #include +#include #include "lldb/lldb-private.h" @@ -41,17 +43,20 @@ public: eOpenOptionCanCreateNewOnly = (1u << 6) // Can create file only if it doesn't already exist }; + static mode_t + ConvertOpenOptionsForPOSIXOpen (uint32_t open_options); + enum Permissions { - ePermissionsUserRead = (1u << 0), - ePermissionsUserWrite = (1u << 1), - ePermissionsUserExecute = (1u << 2), - ePermissionsGroupRead = (1u << 3), + ePermissionsUserRead = (1u << 8), + ePermissionsUserWrite = (1u << 7), + ePermissionsUserExecute = (1u << 6), + ePermissionsGroupRead = (1u << 5), ePermissionsGroupWrite = (1u << 4), - ePermissionsGroupExecute = (1u << 5), - ePermissionsWorldRead = (1u << 6), - ePermissionsWorldWrite = (1u << 7), - ePermissionsWorldExecute = (1u << 8), + ePermissionsGroupExecute = (1u << 3), + ePermissionsWorldRead = (1u << 2), + ePermissionsWorldWrite = (1u << 1), + ePermissionsWorldExecute = (1u << 0), ePermissionsUserRW = (ePermissionsUserRead | ePermissionsUserWrite | 0 ), ePermissionsUserRX = (ePermissionsUserRead | 0 | ePermissionsUserExecute ), @@ -117,6 +122,27 @@ public: uint32_t options, uint32_t permissions = ePermissionsDefault); + //------------------------------------------------------------------ + /// Constructor with FileSpec. + /// + /// Takes a FileSpec pointing to a file which can be just a filename, or a full + /// path. If \a path is not NULL or empty, this function will call + /// File::Open (const char *path, uint32_t options, uint32_t permissions). + /// + /// @param[in] path + /// The FileSpec for this file. + /// + /// @param[in] options + /// Options to use when opening (see File::OpenOptions) + /// + /// @param[in] permissions + /// Options to use when opening (see File::Permissions) + /// + /// @see File::Open (const char *path, uint32_t options, uint32_t permissions) + //------------------------------------------------------------------ + File (const FileSpec& filespec, + uint32_t options, + uint32_t permissions = ePermissionsDefault); File (int fd, bool tranfer_ownership) : m_descriptor (fd), @@ -451,6 +477,19 @@ public: //------------------------------------------------------------------ Error Sync (); + + //------------------------------------------------------------------ + /// Get the permissions for a this file. + /// + /// @return + /// Bits logical OR'ed together from the permission bits defined + /// in lldb_private::File::Permissions. + //------------------------------------------------------------------ + uint32_t + GetPermissions(Error &error) const; + + static uint32_t + GetPermissions (const char *path, Error &error); //------------------------------------------------------------------ /// Output printf formatted output to the stream. diff --git a/include/lldb/Host/FileSpec.h b/include/lldb/Host/FileSpec.h index c58be9ec09d5..dfc6b711ae4a 100644 --- a/include/lldb/Host/FileSpec.h +++ b/include/lldb/Host/FileSpec.h @@ -177,7 +177,7 @@ public: /// A pointer to this object if either the directory or filename /// is valid, NULL otherwise. //------------------------------------------------------------------ - operator bool() const; + explicit operator bool() const; //------------------------------------------------------------------ /// Logical NOT operator. @@ -624,6 +624,21 @@ public: static size_t Resolve (const char *src_path, char *dst_path, size_t dst_len); + FileSpec + CopyByAppendingPathComponent (const char *new_path) const; + + FileSpec + CopyByRemovingLastPathComponent () const; + + void + AppendPathComponent (const char *new_path); + + void + RemoveLastPathComponent (); + + const char* + GetLastPathComponent () const; + //------------------------------------------------------------------ /// Resolves the user name at the beginning of \a src_path, and writes the output /// to \a dst_path. Note, \a src_path can contain other path components after the diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h index 547bdd5d637b..1d667dee5a20 100644 --- a/include/lldb/Host/Host.h +++ b/include/lldb/Host/Host.h @@ -18,6 +18,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/StringList.h" +#include "lldb/Host/File.h" namespace lldb_private { @@ -209,6 +210,9 @@ public: static lldb::pid_t GetCurrentProcessID (); + static void + Kill(lldb::pid_t pid, int signo); + //------------------------------------------------------------------ /// Get the thread ID for the calling thread in the current process. /// @@ -264,6 +268,17 @@ public: lldb::thread_result_t *thread_result_ptr, Error *error); + typedef void (*ThreadLocalStorageCleanupCallback) (void *p); + + static lldb::thread_key_t + ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback); + + static void* + ThreadLocalStorageGet(lldb::thread_key_t key); + + static void + ThreadLocalStorageSet(lldb::thread_key_t key, void *value); + //------------------------------------------------------------------ /// Gets the name of a thread in a process. /// @@ -458,7 +473,7 @@ public: int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit std::string *command_output, // Pass NULL if you don't want the command output uint32_t timeout_sec, - const char *shell = "/bin/bash"); + const char *shell = LLDB_DEFAULT_SHELL); static lldb::DataBufferSP GetAuxvData (lldb_private::Process *process); @@ -494,6 +509,45 @@ public: DynamicLibraryGetSymbol (void *dynamic_library_handle, const char *symbol_name, Error &error); + + static uint32_t + MakeDirectory (const char* path, mode_t mode); + + static lldb::user_id_t + OpenFile (const FileSpec& file_spec, + uint32_t flags, + mode_t mode, + Error &error); + + static bool + CloseFile (lldb::user_id_t fd, + Error &error); + + static uint64_t + WriteFile (lldb::user_id_t fd, + uint64_t offset, + const void* src, + uint64_t src_len, + Error &error); + + static uint64_t + ReadFile (lldb::user_id_t fd, + uint64_t offset, + void* dst, + uint64_t dst_len, + Error &error); + + static lldb::user_id_t + GetFileSize (const FileSpec& file_spec); + + static bool + GetFileExists (const FileSpec& file_spec); + + static bool + CalculateMD5 (const FileSpec& file_spec, + uint64_t &low, + uint64_t &high); + }; } // namespace lldb_private diff --git a/include/lldb/Host/Mutex.h b/include/lldb/Host/Mutex.h index 63f759efe366..496dd0496c13 100644 --- a/include/lldb/Host/Mutex.h +++ b/include/lldb/Host/Mutex.h @@ -11,7 +11,7 @@ #define liblldb_Mutex_h_ #if defined(__cplusplus) -#include +#include "lldb/lldb-types.h" #include #ifdef LLDB_CONFIGURATION_DEBUG @@ -238,7 +238,7 @@ protected: //------------------------------------------------------------------ // TODO: Hide the mutex in the implementation file in case we ever need to port to an // architecture that doesn't have pthread mutexes. - pthread_mutex_t m_mutex; ///< The pthread mutex object. + lldb::mutex_t m_mutex; ///< The OS mutex object. private: //------------------------------------------------------------------ @@ -247,7 +247,7 @@ private: /// @return /// A pointer to the pthread mutex object owned by this object. //------------------------------------------------------------------ - pthread_mutex_t * + lldb::mutex_t * GetMutex(); Mutex(const Mutex&); diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h new file mode 100644 index 000000000000..410e4d9f9468 --- /dev/null +++ b/include/lldb/Host/OptionParser.h @@ -0,0 +1,53 @@ +//===-- OptionParser.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_OptionParser_h_ +#define liblldb_OptionParser_h_ + +namespace lldb_private { + +typedef struct Option +{ + // name of long option + const char *name; + // one of no_argument, required_argument, and optional_argument: + // whether option takes an argument + int has_arg; + // if not NULL, set *flag to val when option found + int *flag; + // if flag not NULL, value to set *flag to; else return value + int val; +} Option; + +class OptionParser +{ +public: + enum OptionArgument + { + eNoArgument = 0, + eRequiredArgument, + eOptionalArgument + }; + + static void Prepare(); + + static void EnableError(bool error); + + static int Parse(int argc, char * const argv [], + const char *optstring, + const Option *longopts, int *longindex); + + static char* GetOptionArgument(); + static int GetOptionIndex(); + static int GetOptionErrorCause(); +}; + +} + +#endif // liblldb_OptionParser_h_ diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h index f563be73fce0..eca1ad375fc6 100644 --- a/include/lldb/Host/ProcessRunLock.h +++ b/include/lldb/Host/ProcessRunLock.h @@ -11,9 +11,9 @@ #define liblldb_ProcessRunLock_h_ #if defined(__cplusplus) +#include "lldb/lldb-defines.h" #include "lldb/Host/Mutex.h" #include "lldb/Host/Condition.h" -#include #include #include @@ -32,75 +32,14 @@ namespace lldb_private { class ProcessRunLock { public: - ProcessRunLock () : - m_rwlock(), - m_running(false) - { - int err = ::pthread_rwlock_init(&m_rwlock, NULL); (void)err; -//#if LLDB_CONFIGURATION_DEBUG -// assert(err == 0); -//#endif - } - - ~ProcessRunLock () - { - int err = ::pthread_rwlock_destroy (&m_rwlock); (void)err; -//#if LLDB_CONFIGURATION_DEBUG -// assert(err == 0); -//#endif - } - - bool - ReadTryLock () - { - ::pthread_rwlock_rdlock (&m_rwlock); - if (m_running == false) - { - return true; - } - ::pthread_rwlock_unlock (&m_rwlock); - return false; - } - - bool - ReadUnlock () - { - return ::pthread_rwlock_unlock (&m_rwlock) == 0; - } - - bool - SetRunning() - { - ::pthread_rwlock_wrlock (&m_rwlock); - m_running = true; - ::pthread_rwlock_unlock (&m_rwlock); - return true; - } - - bool - TrySetRunning() - { - bool r; - - if (::pthread_rwlock_trywrlock (&m_rwlock) == 0) - { - r = !m_running; - m_running = true; - ::pthread_rwlock_unlock (&m_rwlock); - return r; - } - return false; - } - - bool - SetStopped () - { - ::pthread_rwlock_wrlock (&m_rwlock); - m_running = false; - ::pthread_rwlock_unlock (&m_rwlock); - return true; - } - + ProcessRunLock(); + ~ProcessRunLock(); + bool ReadTryLock (); + bool ReadUnlock (); + bool SetRunning (); + bool TrySetRunning (); + bool SetStopped (); +public: class ProcessRunLocker { public: @@ -153,7 +92,7 @@ public: }; protected: - pthread_rwlock_t m_rwlock; + lldb::rwlock_t m_rwlock; bool m_running; private: DISALLOW_COPY_AND_ASSIGN(ProcessRunLock); diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h index e63b238c7994..5e79e94fa9ec 100644 --- a/include/lldb/Host/SocketAddress.h +++ b/include/lldb/Host/SocketAddress.h @@ -12,9 +12,18 @@ // C Includes #include + +#ifdef _WIN32 +#include "lldb/Host/windows/windows.h" +#include +#include +typedef ADDRESS_FAMILY sa_family_t; +typedef USHORT in_port_t; +#else #include #include #include +#endif #if defined(__FreeBSD__) #include diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h index 9db68e1ecf15..652a614e6355 100644 --- a/include/lldb/Host/Symbols.h +++ b/include/lldb/Host/Symbols.h @@ -12,7 +12,6 @@ // C Includes #include -#include // C++ Includes // Other libraries and framework includes diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h index b334717c796b..5ea88c515637 100644 --- a/include/lldb/Host/Terminal.h +++ b/include/lldb/Host/Terminal.h @@ -12,6 +12,7 @@ #if defined(__cplusplus) #include "lldb/lldb-private.h" +#include "lldb/Host/Config.h" struct termios; @@ -173,7 +174,9 @@ protected: //------------------------------------------------------------------ Terminal m_tty; ///< A terminal int m_tflags; ///< Cached tflags information. +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED std::unique_ptr m_termios_ap; ///< Cached terminal state information. +#endif lldb::pid_t m_process_group;///< Cached process group information. }; diff --git a/include/lldb/Host/TimeValue.h b/include/lldb/Host/TimeValue.h index 8c43d6d0e5ff..ba230045307f 100644 --- a/include/lldb/Host/TimeValue.h +++ b/include/lldb/Host/TimeValue.h @@ -12,6 +12,7 @@ // C Includes #include +#ifndef _MSC_VER #include // BEGIN: MinGW work around @@ -19,6 +20,7 @@ #include #endif // END: MinGW work around +#endif // C++ Includes // Other libraries and framework includes @@ -40,7 +42,7 @@ public: TimeValue(); TimeValue(const TimeValue& rhs); TimeValue(const struct timespec& ts); - TimeValue(const struct timeval& tv); + explicit TimeValue(uint32_t seconds, uint32_t nanos = 0); ~TimeValue(); //------------------------------------------------------------------ @@ -64,9 +66,6 @@ public: struct timespec GetAsTimeSpec () const; - struct timeval - GetAsTimeVal () const; - bool IsValid () const; @@ -85,6 +84,23 @@ public: void Dump (Stream *s, uint32_t width = 0) const; + /// Returns only the seconds component of the TimeValue. The nanoseconds + /// portion is ignored. No rounding is performed. + /// @brief Retrieve the seconds component + uint32_t seconds() const { return m_nano_seconds / NanoSecPerSec; } + + /// Returns only the nanoseconds component of the TimeValue. The seconds + /// portion is ignored. + /// @brief Retrieve the nanoseconds component. + uint32_t nanoseconds() const { return m_nano_seconds % NanoSecPerSec; } + + /// Returns only the fractional portion of the TimeValue rounded down to the + /// nearest microsecond (divide by one thousand). + /// @brief Retrieve the fractional part as microseconds; + uint32_t microseconds() const { + return (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec; + } + protected: //------------------------------------------------------------------ // Classes that inherit from TimeValue can see and modify these diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h index d06c3e56aecd..27feca63e4ad 100644 --- a/include/lldb/Interpreter/Args.h +++ b/include/lldb/Interpreter/Args.h @@ -11,8 +11,6 @@ #define liblldb_Command_h_ // C Includes -#include - // C++ Includes #include #include @@ -24,6 +22,7 @@ #include "lldb/lldb-private-types.h" #include "lldb/lldb-types.h" #include "lldb/Core/Error.h" +#include "lldb/Host/OptionParser.h" namespace lldb_private { @@ -319,7 +318,7 @@ public: ParseOptions (Options &options); size_t - FindArgumentIndexForOption (struct option *long_options, int long_options_index); + FindArgumentIndexForOption (Option *long_options, int long_options_index); bool IsPositionalArgument (const char *arg); diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index 2bfab0a8ecc4..8544fd9f9c3f 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -42,7 +42,7 @@ public: return (*help_callback)(); } - operator bool() const + explicit operator bool() const { return (help_callback != NULL); } diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index da05e127d5d1..c09528f9f514 100644 --- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -62,8 +62,8 @@ public: ignore_cap == true; } - ValueObject::DumpValueObjectOptions - GetAsDumpOptions (bool objc_is_compact = false, + DumpValueObjectOptions + GetAsDumpOptions (LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityFull, lldb::Format format = lldb::eFormatDefault, lldb::TypeSummaryImplSP summary_sp = lldb::TypeSummaryImplSP()); diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index 2b935e9e03e6..e024f3a0f3db 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -92,7 +92,7 @@ public: /// /b True this object contains a valid namespace decl, \b /// false otherwise. //------------------------------------------------------------------ - operator bool() const + explicit operator bool() const { return m_current_value; } diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 012eeb68ac0e..68beddfce0d0 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -34,7 +34,7 @@ public: const char *description; }; typedef UniqueCStringMap EnumerationMap; - typedef typename EnumerationMap::Entry EnumerationMapEntry; + typedef EnumerationMap::Entry EnumerationMapEntry; OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value); diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index ac4daa8f579a..2b4ac1190557 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -11,7 +11,6 @@ #define liblldb_Options_h_ // C Includes -#include // C++ Includes #include @@ -141,7 +140,7 @@ public: /// @see Args::ParseOptions (Options&) /// @see man getopt_long_only //------------------------------------------------------------------ - struct option * + Option * GetLongOptions (); // This gets passed the short option as an integer... @@ -309,7 +308,7 @@ protected: typedef std::vector OptionSetVector; CommandInterpreter &m_interpreter; - std::vector m_getopt_table; + std::vector