From johnny.chen at apple.com Mon Apr 25 12:40:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Apr 2011 17:40:47 -0000 Subject: [Lldb-commits] [lldb] r130133 - /lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Message-ID: <20110425174047.846012A6C12E@llvm.org> Author: johnny Date: Mon Apr 25 12:40:47 2011 New Revision: 130133 URL: http://llvm.org/viewvc/llvm-project?rev=130133&view=rev Log: Update startstr argument of self.expect() to "a.out`sum(int, int)" to respond to recent change. Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=130133&r1=130132&r2=130133&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Mon Apr 25 12:40:47 2011 @@ -132,7 +132,7 @@ # ARCH, if not specified, defaults to x86_64. if self.getArchitecture() in ["", 'x86_64', 'i386']: self.expect("dis -f", - startstr = "a.out`sum(int, int):", + startstr = "a.out`sum(int, int)", substrs = [' push', ' mov', ' addl ', From johnny.chen at apple.com Mon Apr 25 13:20:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Apr 2011 18:20:52 -0000 Subject: [Lldb-commits] [lldb] r130134 - /lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Message-ID: <20110425182052.DF8902A6C12D@llvm.org> Author: johnny Date: Mon Apr 25 13:20:52 2011 New Revision: 130134 URL: http://llvm.org/viewvc/llvm-project?rev=130134&view=rev Log: Fix test failure for '-A i386'. Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=130134&r1=130133&r2=130134&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (original) +++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Mon Apr 25 13:20:52 2011 @@ -93,7 +93,7 @@ # Create a target from the debugger. - target = self.dbg.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT) + target = self.dbg.CreateTarget (exe) self.assertTrue(target.IsValid(), VALID_TARGET) # Set up our breakpoints: From gclayton at apple.com Mon Apr 25 13:36:37 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 25 Apr 2011 18:36:37 -0000 Subject: [Lldb-commits] [lldb] r130135 - in /lldb/trunk: include/lldb/Target/ include/lldb/Utility/ lldb.xcodeproj/ source/ source/Plugins/ArchDefaultUnwindPlan/ source/Plugins/ArchVolatileRegs/ source/Plugins/Process/Utility/ source/Plugins/UnwindAssembly/ source/Symbol/ source/Target/ source/Utility/ tools/debugserver/debugserver.xcodeproj/ Message-ID: <20110425183637.4B19A2A6C12D@llvm.org> Author: gclayton Date: Mon Apr 25 13:36:36 2011 New Revision: 130135 URL: http://llvm.org/viewvc/llvm-project?rev=130135&view=rev Log: Put plug-ins into the correct directories as they were incorrectly located in a Utility directory. Added: lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h - copied, changed from r130129, lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/Target/ArchVolatileRegs.h - copied, changed from r130129, lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h - copied, changed from r130129, lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp - copied, changed from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h - copied, changed from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/ArchVolatileRegs/ lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp - copied, changed from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h - copied, changed from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h lldb/trunk/source/Plugins/UnwindAssembly/ lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp - copied, changed from r130129, lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h - copied, changed from r130129, lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp - copied, changed from r130129, lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp lldb/trunk/source/Target/ArchVolatileRegs.cpp - copied, changed from r130129, lldb/trunk/source/Utility/ArchVolatileRegs.cpp lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp - copied, changed from r130129, lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp Removed: lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp lldb/trunk/source/Utility/ArchVolatileRegs.cpp lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Symbol/FuncUnwinders.cpp lldb/trunk/source/Symbol/UnwindTable.cpp lldb/trunk/source/lldb.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Copied: lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h (from r130129, lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h?p2=lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h&p1=lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h (original) +++ lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h Mon Apr 25 13:36:36 2011 @@ -1,4 +1,4 @@ -//===---------------------ArchDefaultUnwindPlan.h ---------------*- C++ -*-===// +//===-- ArchDefaultUnwindPlan.h ---------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Copied: lldb/trunk/include/lldb/Target/ArchVolatileRegs.h (from r130129, lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ArchVolatileRegs.h?p2=lldb/trunk/include/lldb/Target/ArchVolatileRegs.h&p1=lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h (original) +++ lldb/trunk/include/lldb/Target/ArchVolatileRegs.h Mon Apr 25 13:36:36 2011 @@ -1,4 +1,4 @@ -//===---------------------ArchVolatileRegs.h----- ---------------*- C++ -*-===// +//===-- ArchVolatileRegs.h --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Copied: lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h (from r130129, lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h?p2=lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h&p1=lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h (original) +++ lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h Mon Apr 25 13:36:36 2011 @@ -1,4 +1,4 @@ -//===---------------------UnwindAssemblyProfiler.h --------------------------*- C++ -*-===// +//===-- UnwindAssemblyProfiler.h --------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -19,22 +19,28 @@ public PluginInterface { public: + static UnwindAssemblyProfiler* + FindPlugin (const ArchSpec &arch); virtual ~UnwindAssemblyProfiler(); virtual bool - GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func, Thread& thread, lldb_private::UnwindPlan& unwind_plan) = 0; + GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, + Thread& thread, + UnwindPlan& unwind_plan) = 0; virtual bool - GetFastUnwindPlan (lldb_private::AddressRange& func, Thread& thread, lldb_private::UnwindPlan &unwind_plan) = 0; + GetFastUnwindPlan (AddressRange& func, + Thread& thread, + UnwindPlan &unwind_plan) = 0; // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). virtual bool - FirstNonPrologueInsn (lldb_private::AddressRange& func, Target& target, Thread* thread, lldb_private::Address& first_non_prologue_insn) = 0; - - static UnwindAssemblyProfiler* - FindPlugin (const ArchSpec &arch); + FirstNonPrologueInsn (AddressRange& func, + Target& target, + Thread* thread, + Address& first_non_prologue_insn) = 0; protected: UnwindAssemblyProfiler(); Removed: lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h?rev=130134&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h (original) +++ lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h (removed) @@ -1,42 +0,0 @@ -//===---------------------ArchDefaultUnwindPlan.h ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_ArchDefaultUnwindPlan_h_ -#define utility_ArchDefaultUnwindPlan_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginInterface.h" - -namespace lldb_private { - -class ArchDefaultUnwindPlan : - public PluginInterface -{ -public: - - virtual - ~ArchDefaultUnwindPlan(); - - virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) = 0; - - static lldb::ArchDefaultUnwindPlanSP - FindPlugin (const ArchSpec &arch); - -protected: - ArchDefaultUnwindPlan(); -private: - DISALLOW_COPY_AND_ASSIGN (ArchDefaultUnwindPlan); -}; - -} // namespace lldb_private - -#endif //utility_ArchDefaultUnwindPlan_h_ - - Removed: lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h?rev=130134&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h (original) +++ lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h (removed) @@ -1,53 +0,0 @@ -//===---------------------ArchVolatileRegs.h----- ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_ArchVolatileRegs_h_ -#define utility_ArchVolatileRegs_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginInterface.h" - -namespace lldb_private { - -class ArchVolatileRegs : - public PluginInterface -{ -public: - - virtual - ~ArchVolatileRegs(); - - // Given a register number (in the eRegisterKindLLDB register numbering - // scheme), returns true if the register is defined to be "volatile" in - // this architecture -- that is, a function is not required to preserve - // the contents of the register. - // If r8 is defined to be volatile, it means that a function can put - // values in that register without saving the previous contents. - // If r8 is defined to be non-volatile (preseved), a function must save - // the value in the register before it is used. - - // The thread reference is needed to get a RegisterContext to look up by - // register names. - - virtual bool - RegisterIsVolatile (lldb_private::Thread& thread, uint32_t regnum) = 0; - - static ArchVolatileRegs* - FindPlugin (const ArchSpec &arch); - -protected: - ArchVolatileRegs(); -private: - DISALLOW_COPY_AND_ASSIGN (ArchVolatileRegs); -}; - -} // namespace lldb_private - -#endif //utility_ArchVolatileRegs_h_ - Removed: lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h?rev=130134&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h (original) +++ lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h (removed) @@ -1,49 +0,0 @@ -//===---------------------UnwindAssemblyProfiler.h --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_UnwindAssemblyProfiler_h_ -#define utility_UnwindAssemblyProfiler_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginInterface.h" - -namespace lldb_private { - -class UnwindAssemblyProfiler : - public PluginInterface -{ -public: - - virtual - ~UnwindAssemblyProfiler(); - - virtual bool - GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func, Thread& thread, lldb_private::UnwindPlan& unwind_plan) = 0; - - virtual bool - GetFastUnwindPlan (lldb_private::AddressRange& func, Thread& thread, lldb_private::UnwindPlan &unwind_plan) = 0; - - // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). - virtual bool - FirstNonPrologueInsn (lldb_private::AddressRange& func, Target& target, Thread* thread, lldb_private::Address& first_non_prologue_insn) = 0; - - static UnwindAssemblyProfiler* - FindPlugin (const ArchSpec &arch); - -protected: - UnwindAssemblyProfiler(); -private: - DISALLOW_COPY_AND_ASSIGN (UnwindAssemblyProfiler); -}; - -} // namespace lldb_private - -#endif //utility_UnwindAssemblyProfiler_h_ - - Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Apr 25 13:36:36 2011 @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -11,6 +11,9 @@ 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; + 2630BFA91365F28C0070C534 /* UnwindAssemblyProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFA81365F28C0070C534 /* UnwindAssemblyProfiler.cpp */; }; + 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */; }; + 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */; }; 26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; }; 26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; }; 264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A97BD133918BC0017F0BE /* PlatformRemoteGDBServer.cpp */; }; @@ -243,9 +246,6 @@ 268900AE13353E5000698AC0 /* ThreadMacOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89AF10F57C5600BB2B04 /* ThreadMacOSX.cpp */; }; 268900AF13353E5000698AC0 /* UnwindLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */; }; 268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */; }; - 268900B113353E5000698AC0 /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */; }; - 268900B213353E5000698AC0 /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */; }; - 268900B313353E5000698AC0 /* UnwindAssemblyProfiler-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */; }; 268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */; }; 268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2615DBC81208B5FC0021781D /* StopInfoMachException.cpp */; }; 268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */; }; @@ -335,9 +335,6 @@ 2689010A13353E6F00698AC0 /* ThreadPlanTracer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CC2A148128C73ED001531C4 /* ThreadPlanTracer.cpp */; }; 2689010B13353E6F00698AC0 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; 2689010C13353E6F00698AC0 /* UnixSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00987011500B4300F316B0 /* UnixSignals.cpp */; }; - 2689010D13353E8200698AC0 /* ArchVolatileRegs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */; }; - 2689010E13353E8200698AC0 /* ArchDefaultUnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */; }; - 2689010F13353E8200698AC0 /* UnwindAssemblyProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */; }; 2689011013353E8200698AC0 /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; }; 2689011113353E8200698AC0 /* StringExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2660D9F611922A1300958FBD /* StringExtractor.cpp */; }; 2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */; }; @@ -368,6 +365,9 @@ 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; 2697A54E133A6305004E4240 /* PlatformDarwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2697A54C133A6305004E4240 /* PlatformDarwin.h */; }; 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; }; + 26AC3F471365F43F0065C7EF /* UnwindAssemblyProfiler-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26AC3F451365F4390065C7EF /* UnwindAssemblyProfiler-x86.cpp */; }; + 26AC3F4B1365F4EC0065C7EF /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26AC3F491365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.cpp */; }; + 26AC3F4F1365F53B0065C7EF /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26AC3F4D1365F5380065C7EF /* ArchVolatileRegs-x86.cpp */; }; 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; 26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; 26B1FCB913381071002886E2 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; @@ -632,6 +632,12 @@ 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingPtr.h; path = include/lldb/Utility/SharingPtr.h; sourceTree = ""; }; 26217930133BC8640083B112 /* lldb-private-types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-types.h"; path = "include/lldb/lldb-private-types.h"; sourceTree = ""; }; 26217932133BCB850083B112 /* lldb-private-enumerations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-enumerations.h"; path = "include/lldb/lldb-private-enumerations.h"; sourceTree = ""; }; + 2630BFA81365F28C0070C534 /* UnwindAssemblyProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindAssemblyProfiler.cpp; path = source/Target/UnwindAssemblyProfiler.cpp; sourceTree = ""; }; + 2630BFAA1365F2BA0070C534 /* UnwindAssemblyProfiler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UnwindAssemblyProfiler.h; path = include/lldb/Target/UnwindAssemblyProfiler.h; sourceTree = ""; }; + 2630BFAB1365F3140070C534 /* ArchDefaultUnwindPlan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArchDefaultUnwindPlan.h; path = include/lldb/Target/ArchDefaultUnwindPlan.h; sourceTree = ""; }; + 2630BFAC1365F3140070C534 /* ArchVolatileRegs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArchVolatileRegs.h; path = include/lldb/Target/ArchVolatileRegs.h; sourceTree = ""; }; + 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchDefaultUnwindPlan.cpp; path = source/Target/ArchDefaultUnwindPlan.cpp; sourceTree = ""; }; + 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchVolatileRegs.cpp; path = source/Target/ArchVolatileRegs.cpp; sourceTree = ""; }; 263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; }; 263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; }; 26368A3B126B697600E8659F /* darwin-debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "darwin-debug.cpp"; path = "tools/darwin-debug/darwin-debug.cpp"; sourceTree = ""; }; @@ -714,6 +720,12 @@ 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLDBWrapPython.cpp; path = source/LLDBWrapPython.cpp; sourceTree = ""; }; 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NamedOptionValue.cpp; path = source/Interpreter/NamedOptionValue.cpp; sourceTree = ""; }; 26A7A036135E6E5300FB369E /* NamedOptionValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NamedOptionValue.h; path = include/lldb/Interpreter/NamedOptionValue.h; sourceTree = ""; }; + 26AC3F451365F4390065C7EF /* UnwindAssemblyProfiler-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "UnwindAssemblyProfiler-x86.cpp"; path = "source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp"; sourceTree = SOURCE_ROOT; }; + 26AC3F461365F4390065C7EF /* UnwindAssemblyProfiler-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UnwindAssemblyProfiler-x86.h"; path = "source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h"; sourceTree = SOURCE_ROOT; }; + 26AC3F491365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchDefaultUnwindPlan-x86.cpp"; path = "ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; + 26AC3F4A1365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "ArchDefaultUnwindPlan-x86.h"; path = "ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; + 26AC3F4D1365F5380065C7EF /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchVolatileRegs-x86.cpp"; path = "ArchVolatileRegs/ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; + 26AC3F4E1365F5380065C7EF /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "ArchVolatileRegs-x86.h"; path = "ArchVolatileRegs/ArchVolatileRegs-x86.h"; sourceTree = ""; }; 26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeValue.h; path = include/lldb/Core/ThreadSafeValue.h; sourceTree = ""; }; 26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = ""; }; 26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = ""; }; @@ -1142,15 +1154,6 @@ 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FuncUnwinders.cpp; path = source/Symbol/FuncUnwinders.cpp; sourceTree = ""; }; 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindPlan.cpp; path = source/Symbol/UnwindPlan.cpp; sourceTree = ""; }; 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindTable.cpp; path = source/Symbol/UnwindTable.cpp; sourceTree = ""; }; - 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindAssemblyProfiler.cpp; path = source/Utility/UnwindAssemblyProfiler.cpp; sourceTree = ""; }; - 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "UnwindAssemblyProfiler-x86.cpp"; path = "Utility/UnwindAssemblyProfiler-x86.cpp"; sourceTree = ""; }; - 961FABE91235F26800F93A47 /* UnwindAssemblyProfiler-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UnwindAssemblyProfiler-x86.h"; path = "Utility/UnwindAssemblyProfiler-x86.h"; sourceTree = ""; }; - 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchDefaultUnwindPlan.cpp; path = source/Utility/ArchDefaultUnwindPlan.cpp; sourceTree = ""; }; - 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchDefaultUnwindPlan-x86.cpp"; path = "Utility/ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; - 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ArchDefaultUnwindPlan-x86.h"; path = "Utility/ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; - 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchVolatileRegs.cpp; path = source/Utility/ArchVolatileRegs.cpp; sourceTree = ""; }; - 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchVolatileRegs-x86.cpp"; path = "Utility/ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; - 96A6D9C81249D98800250B38 /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ArchVolatileRegs-x86.h"; path = "Utility/ArchVolatileRegs-x86.h"; sourceTree = ""; }; 9A19A6A51163BB7E00E0D453 /* SBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBValue.h; path = include/lldb/API/SBValue.h; sourceTree = ""; }; 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBValue.cpp; path = source/API/SBValue.cpp; sourceTree = ""; }; 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulateInstructionARM.cpp; sourceTree = ""; }; @@ -1341,6 +1344,8 @@ 260C897110F57C5600BB2B04 /* Plugins */ = { isa = PBXGroup; children = ( + 26AC3F481365F4620065C7EF /* ArchDefaultUnwindPlan */, + 26AC3F4C1365F5260065C7EF /* ArchVolatileRegs */, 493C63D711891A8000914D5E /* ABI */, 260C897210F57C5600BB2B04 /* Disassembler */, 260C897810F57C5600BB2B04 /* DynamicLoader */, @@ -1352,6 +1357,7 @@ 260C898A10F57C5600BB2B04 /* Process */, 260C89B110F57C5600BB2B04 /* SymbolFile */, 260C89E010F57C5600BB2B04 /* SymbolVendor */, + 26AC3F441365F40E0065C7EF /* UnwindAssembly */, ); name = Plugins; path = source/Plugins; @@ -1746,9 +1752,6 @@ 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( - 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */, - 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */, - 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */, 264723A511FA076E00DE380C /* CleanUp.h */, 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */, 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */, @@ -1783,6 +1786,34 @@ path = "BSD-Archive"; sourceTree = ""; }; + 26AC3F441365F40E0065C7EF /* UnwindAssembly */ = { + isa = PBXGroup; + children = ( + 26AC3F451365F4390065C7EF /* UnwindAssemblyProfiler-x86.cpp */, + 26AC3F461365F4390065C7EF /* UnwindAssemblyProfiler-x86.h */, + ); + name = UnwindAssembly; + path = Process; + sourceTree = ""; + }; + 26AC3F481365F4620065C7EF /* ArchDefaultUnwindPlan */ = { + isa = PBXGroup; + children = ( + 26AC3F491365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.cpp */, + 26AC3F4A1365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.h */, + ); + name = ArchDefaultUnwindPlan; + sourceTree = ""; + }; + 26AC3F4C1365F5260065C7EF /* ArchVolatileRegs */ = { + isa = PBXGroup; + children = ( + 26AC3F4D1365F5380065C7EF /* ArchVolatileRegs-x86.cpp */, + 26AC3F4E1365F5380065C7EF /* ArchVolatileRegs-x86.h */, + ); + name = ArchVolatileRegs; + sourceTree = ""; + }; 26B4666E11A2080F00CF6220 /* Utility */ = { isa = PBXGroup; children = ( @@ -1793,12 +1824,6 @@ AF68D3301255A110002FF25B /* UnwindLLDB.h */, AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */, AF68D2551255416E002FF25B /* RegisterContextLLDB.h */, - 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */, - 96A6D9C81249D98800250B38 /* ArchVolatileRegs-x86.h */, - 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */, - 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */, - 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */, - 961FABE91235F26800F93A47 /* UnwindAssemblyProfiler-x86.h */, 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */, 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */, 2615DBC91208B5FC0021781D /* StopInfoMachException.h */, @@ -2200,6 +2225,10 @@ children = ( 497E7B331188ED300065CCA1 /* ABI.h */, 497E7B9D1188F6690065CCA1 /* ABI.cpp */, + 2630BFAB1365F3140070C534 /* ArchDefaultUnwindPlan.h */, + 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */, + 2630BFAC1365F3140070C534 /* ArchVolatileRegs.h */, + 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */, 4CB443BB1249920C00C13DC2 /* CPPLanguageRuntime.h */, 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */, 26BC7DF110F1B81A00F91463 /* DynamicLoader.h */, @@ -2274,6 +2303,8 @@ 4C00986F11500B4300F316B0 /* UnixSignals.h */, 4C00987011500B4300F316B0 /* UnixSignals.cpp */, 26E3EEBD11A9870400FBADB6 /* Unwind.h */, + 2630BFAA1365F2BA0070C534 /* UnwindAssemblyProfiler.h */, + 2630BFA81365F28C0070C534 /* UnwindAssemblyProfiler.cpp */, ); name = Target; sourceTree = ""; @@ -2694,8 +2725,11 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( @@ -3043,9 +3077,6 @@ 268900AE13353E5000698AC0 /* ThreadMacOSX.cpp in Sources */, 268900AF13353E5000698AC0 /* UnwindLLDB.cpp in Sources */, 268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */, - 268900B113353E5000698AC0 /* ArchVolatileRegs-x86.cpp in Sources */, - 268900B213353E5000698AC0 /* ArchDefaultUnwindPlan-x86.cpp in Sources */, - 268900B313353E5000698AC0 /* UnwindAssemblyProfiler-x86.cpp in Sources */, 268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */, 268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */, 268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */, @@ -3135,9 +3166,6 @@ 2689010A13353E6F00698AC0 /* ThreadPlanTracer.cpp in Sources */, 2689010B13353E6F00698AC0 /* ThreadSpec.cpp in Sources */, 2689010C13353E6F00698AC0 /* UnixSignals.cpp in Sources */, - 2689010D13353E8200698AC0 /* ArchVolatileRegs.cpp in Sources */, - 2689010E13353E8200698AC0 /* ArchDefaultUnwindPlan.cpp in Sources */, - 2689010F13353E8200698AC0 /* UnwindAssemblyProfiler.cpp in Sources */, 2689011013353E8200698AC0 /* SharingPtr.cpp in Sources */, 2689011113353E8200698AC0 /* StringExtractor.cpp in Sources */, 2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */, @@ -3158,6 +3186,12 @@ 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */, 9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */, 9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */, + 2630BFA91365F28C0070C534 /* UnwindAssemblyProfiler.cpp in Sources */, + 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */, + 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */, + 26AC3F471365F43F0065C7EF /* UnwindAssemblyProfiler-x86.cpp in Sources */, + 26AC3F4B1365F4EC0065C7EF /* ArchDefaultUnwindPlan-x86.cpp in Sources */, + 26AC3F4F1365F53B0065C7EF /* ArchVolatileRegs-x86.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3283,7 +3317,6 @@ LLVM_BUILD_DIR_ARCH = ""; LLVM_CONFIGURATION = Release; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; - PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; name = Release; @@ -3309,7 +3342,6 @@ COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = /System/Library/PrivateFrameworks; - GCC_ENABLE_FIX_AND_CONTINUE = NO; INSTALL_PATH = /Developer/usr/bin; ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "darwin-debug"; @@ -3322,7 +3354,6 @@ ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = /System/Library/PrivateFrameworks; - GCC_ENABLE_FIX_AND_CONTINUE = YES; INSTALL_PATH = /Developer/usr/bin; ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "darwin-debug"; @@ -3580,7 +3611,6 @@ LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/"; LLVM_CONFIGURATION = Release; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; - PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; name = BuildAndIntegration; Copied: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp (from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp?p2=lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp&p1=lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp Mon Apr 25 13:36:36 2011 @@ -10,7 +10,7 @@ #include "ArchDefaultUnwindPlan-x86.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" +#include "lldb/Target/ArchDefaultUnwindPlan.h" using namespace lldb; using namespace lldb_private; Copied: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h (from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h?p2=lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h&p1=lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h Mon Apr 25 13:36:36 2011 @@ -11,7 +11,7 @@ #define liblldb_ArchDefaultUnwindPlan_x86_h_ #include "lldb/lldb-private.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" +#include "lldb/Target/ArchDefaultUnwindPlan.h" #include "lldb/Target/Thread.h" #include "lldb/Symbol/UnwindPlan.h" Copied: lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp (from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp?p2=lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp&p1=lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp (original) +++ lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp Mon Apr 25 13:36:36 2011 @@ -8,15 +8,17 @@ //===----------------------------------------------------------------------===// #include "ArchVolatileRegs-x86.h" + +#include + #include "llvm/Support/MachO.h" -#include "lldb/lldb-private.h" -#include "lldb/Utility/ArchVolatileRegs.h" + #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/lldb-enumerations.h" +#include "lldb/Target/ArchVolatileRegs.h" #include "lldb/Target/Thread.h" #include "lldb/Target/RegisterContext.h" -#include + using namespace lldb; using namespace lldb_private; Copied: lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h (from r130129, lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h?p2=lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h&p1=lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h (original) +++ lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h Mon Apr 25 13:36:36 2011 @@ -12,7 +12,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Utility/ArchVolatileRegs.h" +#include "lldb/Target/ArchVolatileRegs.h" #include namespace lldb_private { Removed: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (removed) @@ -1,192 +0,0 @@ -//===-- ArchDefaultUnwindPlan-x86.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ArchDefaultUnwindPlan-x86.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" - -using namespace lldb; -using namespace lldb_private; - -lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch) -{ - if (arch.GetMachine () == llvm::Triple::x86_64) - return new ArchDefaultUnwindPlan_x86_64 (); - return NULL; -} - -ArchDefaultUnwindPlan_x86_64::ArchDefaultUnwindPlan_x86_64() : - lldb_private::ArchDefaultUnwindPlan(), - m_unwind_plan_sp (new UnwindPlan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation regloc; - - m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); - row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 8); - row.SetOffset (0); - - regloc.SetAtCFAPlusOffset (2 * -8); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -8); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); - regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - - m_unwind_plan_sp->AppendRow (row); - m_unwind_plan_sp->SetSourceName ("x86_64 architectural default"); -} - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -ArchDefaultUnwindPlan_x86_64::GetPluginName() -{ - return "ArchDefaultUnwindPlan_x86_64"; -} - -const char * -ArchDefaultUnwindPlan_x86_64::GetShortPluginName() -{ - return "lldb.arch-default-unwind-plan.x86-64"; -} - - -uint32_t -ArchDefaultUnwindPlan_x86_64::GetPluginVersion() -{ - return 1; -} -void -ArchDefaultUnwindPlan_x86_64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -ArchDefaultUnwindPlan_x86_64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -ArchDefaultUnwindPlan_x86_64::GetPluginNameStatic() -{ - return "ArchDefaultUnwindPlan_x86_64"; -} - -const char * -ArchDefaultUnwindPlan_x86_64::GetPluginDescriptionStatic() -{ - return "x86_64 architecture default unwind plan assembly plugin."; -} - -UnwindPlanSP -ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) -{ - return m_unwind_plan_sp; -} - - - -lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch) -{ - if (arch.GetMachine () == llvm::Triple::x86) - return new ArchDefaultUnwindPlan_i386 (); - return NULL; -} - -ArchDefaultUnwindPlan_i386::ArchDefaultUnwindPlan_i386() : - lldb_private::ArchDefaultUnwindPlan(), - m_unwind_plan_sp (new UnwindPlan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation regloc; - - m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); - row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 4); - row.SetOffset (0); - - regloc.SetAtCFAPlusOffset (2 * -4); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -4); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); - regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - - m_unwind_plan_sp->AppendRow (row); - m_unwind_plan_sp->SetSourceName ("i386 architectural default"); -} - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -ArchDefaultUnwindPlan_i386::GetPluginName() -{ - return "ArchDefaultUnwindPlan_i386"; -} - -const char * -ArchDefaultUnwindPlan_i386::GetShortPluginName() -{ - return "archdefaultunwindplan.x86"; -} - - -uint32_t -ArchDefaultUnwindPlan_i386::GetPluginVersion() -{ - return 1; -} - -void -ArchDefaultUnwindPlan_i386::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -ArchDefaultUnwindPlan_i386::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -ArchDefaultUnwindPlan_i386::GetPluginNameStatic() -{ - return "ArchDefaultUnwindPlan_i386"; -} - -const char * -ArchDefaultUnwindPlan_i386::GetPluginDescriptionStatic() -{ - return "i386 architecture default unwind plan assembly plugin."; -} - -UnwindPlanSP -ArchDefaultUnwindPlan_i386::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) -{ - return m_unwind_plan_sp; -} - Removed: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h (removed) @@ -1,107 +0,0 @@ -//===-- ArchDefaultUnwindPlan-x86.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_ArchDefaultUnwindPlan_x86_h_ -#define liblldb_ArchDefaultUnwindPlan_x86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" -#include "lldb/Target/Thread.h" -#include "lldb/Symbol/UnwindPlan.h" - -namespace lldb_private { - -class ArchDefaultUnwindPlan_x86_64 : public lldb_private::ArchDefaultUnwindPlan -{ -public: - - ~ArchDefaultUnwindPlan_x86_64 () { } - - virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); - - static lldb_private::ArchDefaultUnwindPlan * - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - ArchDefaultUnwindPlan_x86_64(); // Call CreateInstance instead. - - lldb::UnwindPlanSP m_unwind_plan_sp; -}; - -class ArchDefaultUnwindPlan_i386 : public lldb_private::ArchDefaultUnwindPlan -{ -public: - - ~ArchDefaultUnwindPlan_i386 () { } - - virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); - - static lldb_private::ArchDefaultUnwindPlan * - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - ArchDefaultUnwindPlan_i386(); // Call CreateInstance instead. - - lldb::UnwindPlanSP m_unwind_plan_sp; -}; - - -} // namespace lldb_private - -#endif // liblldb_UnwindAssemblyProfiler_x86_h_ Removed: lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp (removed) @@ -1,148 +0,0 @@ -//===-- ArchVolatileRegs-x86.cpp --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ArchVolatileRegs-x86.h" -#include "llvm/Support/MachO.h" -#include "lldb/lldb-private.h" -#include "lldb/Utility/ArchVolatileRegs.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/lldb-enumerations.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/RegisterContext.h" -#include - -using namespace lldb; -using namespace lldb_private; - -bool -ArchVolatileRegs_x86::RegisterIsVolatile (Thread& thread, uint32_t regnum) -{ - initialize_regset (thread); - if (m_non_volatile_regs.find (regnum) == m_non_volatile_regs.end()) - return true; - else - return false; -} - -lldb_private::ArchVolatileRegs * -ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch) -{ - llvm::Triple::ArchType cpu = arch.GetMachine (); - if (cpu == llvm::Triple::x86 || cpu == llvm::Triple::x86_64) - return new ArchVolatileRegs_x86 (cpu); - return NULL; -} - -ArchVolatileRegs_x86::ArchVolatileRegs_x86(llvm::Triple::ArchType cpu) : - lldb_private::ArchVolatileRegs(), - m_cpu(cpu), - m_non_volatile_regs() -{ -} - -void -ArchVolatileRegs_x86::initialize_regset(Thread& thread) -{ - if (m_non_volatile_regs.size() > 0) - return; - - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - const RegisterInfo *ri; - - const char *x86_64_regnames[] = { "rbx", - "rsp", - "rbp", - "r12", - "r13", - "r14", - "r15", - "rip" }; - - const char *i386_regnames[] = { "ebx", - "ebp", - "esi", - "edi", - "esp", - "eip" }; - - - const char **names; - int namecount; - if (m_cpu == llvm::Triple::x86_64) - { - names = x86_64_regnames; - namecount = sizeof (x86_64_regnames) / sizeof (char *); - } - else - { - assert (m_cpu == llvm::Triple::x86); - names = i386_regnames; - namecount = sizeof (i386_regnames) / sizeof (char *); - } - - for (int i = 0; i < namecount; i++) - { - ri = reg_ctx->GetRegisterInfoByName (names[i]); - if (ri) - m_non_volatile_regs.insert (ri->kinds[eRegisterKindLLDB]); - } -} - - -//------------------------------------------------------------------ -// PluginInterface protocol in ArchVolatileRegs_x86 -//------------------------------------------------------------------ - -const char * -ArchVolatileRegs_x86::GetPluginName() -{ - return "ArchVolatileRegs_x86"; -} - -const char * -ArchVolatileRegs_x86::GetShortPluginName() -{ - return "archvolatileregs.x86"; -} - - -uint32_t -ArchVolatileRegs_x86::GetPluginVersion() -{ - return 1; -} - -void -ArchVolatileRegs_x86::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -ArchVolatileRegs_x86::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -ArchVolatileRegs_x86::GetPluginNameStatic() -{ - return "ArchVolatileRegs_x86"; -} - -const char * -ArchVolatileRegs_x86::GetPluginDescriptionStatic() -{ - return "i386 and x86_64 architecture volatile register information."; -} Removed: lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h (removed) @@ -1,68 +0,0 @@ -//===-- ArchVolatileRegs-x86.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_ArchVolatileRegs_x86_h_ -#define liblldb_ArchVolatileRegs_x86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Utility/ArchVolatileRegs.h" -#include - -namespace lldb_private { - -class ArchVolatileRegs_x86 : public lldb_private::ArchVolatileRegs -{ -public: - - ~ArchVolatileRegs_x86 () { } - - bool - RegisterIsVolatile (lldb_private::Thread& thread, uint32_t regnum); - - static lldb_private::ArchVolatileRegs * - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - ArchVolatileRegs_x86(llvm::Triple::ArchType cpu); // Call CreateInstance instead. - - void initialize_regset(lldb_private::Thread& thread); - - llvm::Triple::ArchType m_cpu; - std::set m_non_volatile_regs; -}; - - -} // namespace lldb_private - -#endif // liblldb_ArchVolatileRegs_x86_h_ Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Apr 25 13:36:36 2011 @@ -7,25 +7,26 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-private.h" #include "RegisterContextLLDB.h" -#include "lldb/Target/Thread.h" -#include "lldb/Symbol/Function.h" -#include "lldb/Symbol/SymbolContext.h" -#include "lldb/Symbol/Symbol.h" + +#include "lldb/lldb-private.h" #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Process.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" -#include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Core/DataBufferHeap.h" -#include "lldb/Utility/ArchVolatileRegs.h" #include "lldb/Core/Log.h" -#include "lldb/Expression/DWARFExpression.h" #include "lldb/Core/Value.h" +#include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/Symbol.h" +#include "lldb/Expression/DWARFExpression.h" +#include "lldb/Target/ArchDefaultUnwindPlan.h" +#include "lldb/Target/ArchVolatileRegs.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; Removed: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (removed) @@ -1,907 +0,0 @@ -//===-- UnwindAssemblyProfiler-x86.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "UnwindAssemblyProfiler-x86.h" - -#include "lldb/lldb-private.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" -#include "lldb/Core/Address.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/Target.h" -#include "lldb/Symbol/UnwindPlan.h" - -#include "lldb/lldb-enumerations.h" -#include "llvm-c/EnhancedDisassembly.h" - -#include "UnwindAssemblyProfiler-x86.h" - - -using namespace lldb; -using namespace lldb_private; - -enum CPU { - k_i386, - k_x86_64 -}; - -enum i386_register_numbers { - k_machine_eax = 0, - k_machine_ecx = 1, - k_machine_edx = 2, - k_machine_ebx = 3, - k_machine_esp = 4, - k_machine_ebp = 5, - k_machine_esi = 6, - k_machine_edi = 7, - k_machine_eip = 8 -}; - -enum x86_64_register_numbers { - k_machine_rax = 0, - k_machine_rcx = 1, - k_machine_rdx = 2, - k_machine_rbx = 3, - k_machine_rsp = 4, - k_machine_rbp = 5, - k_machine_rsi = 6, - k_machine_rdi = 7, - k_machine_r8 = 8, - k_machine_r9 = 9, - k_machine_r10 = 10, - k_machine_r11 = 11, - k_machine_r12 = 12, - k_machine_r13 = 13, - k_machine_r14 = 14, - k_machine_r15 = 15, - k_machine_rip = 16 -}; - -struct regmap_ent { - const char *name; - int machine_regno; - int lldb_regno; -}; - -static struct regmap_ent i386_register_map[] = { - {"eax", k_machine_eax, -1}, - {"ecx", k_machine_ecx, -1}, - {"edx", k_machine_edx, -1}, - {"ebx", k_machine_ebx, -1}, - {"esp", k_machine_esp, -1}, - {"ebp", k_machine_ebp, -1}, - {"esi", k_machine_esi, -1}, - {"edi", k_machine_edi, -1}, - {"eip", k_machine_eip, -1} -}; - -const int size_of_i386_register_map = sizeof (i386_register_map) / sizeof (struct regmap_ent); - -static int i386_register_map_initialized = 0; - -static struct regmap_ent x86_64_register_map[] = { - {"rax", k_machine_rax, -1}, - {"rcx", k_machine_rcx, -1}, - {"rdx", k_machine_rdx, -1}, - {"rbx", k_machine_rbx, -1}, - {"rsp", k_machine_rsp, -1}, - {"rbp", k_machine_rbp, -1}, - {"rsi", k_machine_rsi, -1}, - {"rdi", k_machine_rdi, -1}, - {"r8", k_machine_r8, -1}, - {"r9", k_machine_r9, -1}, - {"r10", k_machine_r10, -1}, - {"r11", k_machine_r11, -1}, - {"r12", k_machine_r12, -1}, - {"r13", k_machine_r13, -1}, - {"r14", k_machine_r14, -1}, - {"r15", k_machine_r15, -1}, - {"rip", k_machine_rip, -1} -}; - -const int size_of_x86_64_register_map = sizeof (x86_64_register_map) / sizeof (struct regmap_ent); - -static int x86_64_register_map_initialized = 0; - -//----------------------------------------------------------------------------------------------- -// AssemblyParse_x86 local-file class definition & implementation functions -//----------------------------------------------------------------------------------------------- - -class AssemblyParse_x86 { -public: - - AssemblyParse_x86 (Target &target, Thread *thread, int cpu, AddressRange func); - - bool get_non_call_site_unwind_plan (UnwindPlan &unwind_plan); - - bool get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_plan); - - bool find_first_non_prologue_insn (Address &address); - -private: - enum { kMaxInstructionByteSize = 32 }; - - bool nonvolatile_reg_p (int machine_regno); - bool push_rbp_pattern_p (); - bool push_0_pattern_p (); - bool mov_rsp_rbp_pattern_p (); - bool sub_rsp_pattern_p (int& amount); - bool push_reg_p (int& regno); - bool mov_reg_to_local_stack_frame_p (int& regno, int& fp_offset); - bool ret_pattern_p (); - uint32_t extract_4 (uint8_t *b); - bool machine_regno_to_lldb_regno (int machine_regno, uint32_t& lldb_regno); - bool instruction_length (Address addr, int &length); - - Target &m_target; - Thread* m_thread; - - AddressRange m_func_bounds; - - Address m_cur_insn; - uint8_t m_cur_insn_bytes[kMaxInstructionByteSize]; - - int m_machine_ip_regnum; - int m_machine_sp_regnum; - int m_machine_fp_regnum; - - int m_lldb_ip_regnum; - int m_lldb_sp_regnum; - int m_lldb_fp_regnum; - - int m_wordsize; - int m_cpu; - - DISALLOW_COPY_AND_ASSIGN (AssemblyParse_x86); -}; - -AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : - m_target (target), m_thread (thread), m_func_bounds(func), m_cur_insn (), - m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1), - m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1), - m_wordsize (-1), m_cpu(cpu) -{ - int *initialized_flag = NULL; - m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; - if (cpu == k_i386) - { - m_machine_ip_regnum = k_machine_eip; - m_machine_sp_regnum = k_machine_esp; - m_machine_fp_regnum = k_machine_ebp; - m_wordsize = 4; - initialized_flag = &i386_register_map_initialized; - } - else - { - m_machine_ip_regnum = k_machine_rip; - m_machine_sp_regnum = k_machine_rsp; - m_machine_fp_regnum = k_machine_rbp; - m_wordsize = 8; - initialized_flag = &x86_64_register_map_initialized; - } - - // we only look at prologue - it will be complete earlier than 512 bytes into func - if (m_func_bounds.GetByteSize() == 0) - m_func_bounds.SetByteSize(512); - - if (m_thread && *initialized_flag == 0) - { - RegisterContext *reg_ctx = m_thread->GetRegisterContext().get(); - if (reg_ctx) - { - struct regmap_ent *ent; - int count, i; - if (cpu == k_i386) - { - ent = i386_register_map; - count = size_of_i386_register_map; - } - else - { - ent = x86_64_register_map; - count = size_of_x86_64_register_map; - } - for (i = 0; i < count; i++, ent++) - { - const RegisterInfo *ri = reg_ctx->GetRegisterInfoByName (ent->name); - if (ri) - ent->lldb_regno = ri->kinds[eRegisterKindLLDB]; - } - *initialized_flag = 1; - } - } - - // on initial construction we may not have a Thread so these have to remain - // uninitialized until we can get a RegisterContext to set up the register map table - if (*initialized_flag == 1) - { - uint32_t lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_sp_regnum, lldb_regno)) - m_lldb_sp_regnum = lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_fp_regnum, lldb_regno)) - m_lldb_fp_regnum = lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_ip_regnum, lldb_regno)) - m_lldb_ip_regnum = lldb_regno; - } -} - - -// This function expects an x86 native register number (i.e. the bits stripped out of the -// actual instruction), not an lldb register number. - -bool -AssemblyParse_x86::nonvolatile_reg_p (int machine_regno) -{ - if (m_cpu == k_i386) - { - switch (machine_regno) { - case k_machine_ebx: - case k_machine_ebp: // not actually a nonvolatile but often treated as such by convention - case k_machine_esi: - case k_machine_edi: - case k_machine_esp: - return true; - default: - return false; - } - } - if (m_cpu == k_x86_64) - { - switch (machine_regno) { - case k_machine_rbx: - case k_machine_rsp: - case k_machine_rbp: // not actually a nonvolatile but often treated as such by convention - case k_machine_r12: - case k_machine_r13: - case k_machine_r14: - case k_machine_r15: - return true; - default: - return false; - } - } - return false; -} - - -// Macro to detect if this is a REX mode prefix byte. -#define REX_W_PREFIX_P(opcode) (((opcode) & (~0x5)) == 0x48) - -// The high bit which should be added to the source register number (the "R" bit) -#define REX_W_SRCREG(opcode) (((opcode) & 0x4) >> 2) - -// The high bit which should be added to the destination register number (the "B" bit) -#define REX_W_DSTREG(opcode) ((opcode) & 0x1) - -// pushq %rbp [0x55] -bool AssemblyParse_x86::push_rbp_pattern_p () { - uint8_t *p = m_cur_insn_bytes; - if (*p == 0x55) - return true; - return false; -} - -// pushq $0 ; the first instruction in start() [0x6a 0x00] -bool AssemblyParse_x86::push_0_pattern_p () -{ - uint8_t *p = m_cur_insn_bytes; - if (*p == 0x6a && *(p + 1) == 0x0) - return true; - return false; -} - -// movq %rsp, %rbp [0x48 0x8b 0xec] or [0x48 0x89 0xe5] -// movl %esp, %ebp [0x8b 0xec] or [0x89 0xe5] -bool AssemblyParse_x86::mov_rsp_rbp_pattern_p () { - uint8_t *p = m_cur_insn_bytes; - if (m_wordsize == 8 && *p == 0x48) - p++; - if (*(p) == 0x8b && *(p + 1) == 0xec) - return true; - if (*(p) == 0x89 && *(p + 1) == 0xe5) - return true; - return false; -} - -// subq $0x20, %rsp -bool AssemblyParse_x86::sub_rsp_pattern_p (int& amount) { - uint8_t *p = m_cur_insn_bytes; - if (m_wordsize == 8 && *p == 0x48) - p++; - // 8-bit immediate operand - if (*p == 0x83 && *(p + 1) == 0xec) { - amount = (int8_t) *(p + 2); - return true; - } - // 32-bit immediate operand - if (*p == 0x81 && *(p + 1) == 0xec) { - amount = (int32_t) extract_4 (p + 2); - return true; - } - // Not handled: [0x83 0xc4] for imm8 with neg values - // [0x81 0xc4] for imm32 with neg values - return false; -} - -// pushq %rbx -// pushl $ebx -bool AssemblyParse_x86::push_reg_p (int& regno) { - uint8_t *p = m_cur_insn_bytes; - int regno_prefix_bit = 0; - // If we have a rex prefix byte, check to see if a B bit is set - if (m_wordsize == 8 && *p == 0x41) { - regno_prefix_bit = 1 << 3; - p++; - } - if (*p >= 0x50 && *p <= 0x57) { - regno = (*p - 0x50) | regno_prefix_bit; - return true; - } - return false; -} - -// Look for an instruction sequence storing a nonvolatile register -// on to the stack frame. - -// movq %rax, -0x10(%rbp) [0x48 0x89 0x45 0xf0] -// movl %eax, -0xc(%ebp) [0x89 0x45 0xf4] -bool AssemblyParse_x86::mov_reg_to_local_stack_frame_p (int& regno, int& rbp_offset) { - uint8_t *p = m_cur_insn_bytes; - int src_reg_prefix_bit = 0; - int target_reg_prefix_bit = 0; - - if (m_wordsize == 8 && REX_W_PREFIX_P (*p)) { - src_reg_prefix_bit = REX_W_SRCREG (*p) << 3; - target_reg_prefix_bit = REX_W_DSTREG (*p) << 3; - if (target_reg_prefix_bit == 1) { - // rbp/ebp don't need a prefix bit - we know this isn't the - // reg we care about. - return false; - } - p++; - } - - if (*p == 0x89) { - /* Mask off the 3-5 bits which indicate the destination register - if this is a ModR/M byte. */ - int opcode_destreg_masked_out = *(p + 1) & (~0x38); - - /* Is this a ModR/M byte with Mod bits 01 and R/M bits 101 - and three bits between them, e.g. 01nnn101 - We're looking for a destination of ebp-disp8 or ebp-disp32. */ - int immsize; - if (opcode_destreg_masked_out == 0x45) - immsize = 2; - else if (opcode_destreg_masked_out == 0x85) - immsize = 4; - else - return false; - - int offset = 0; - if (immsize == 2) - offset = (int8_t) *(p + 2); - if (immsize == 4) - offset = (uint32_t) extract_4 (p + 2); - if (offset > 0) - return false; - - regno = ((*(p + 1) >> 3) & 0x7) | src_reg_prefix_bit; - rbp_offset = offset > 0 ? offset : -offset; - return true; - } - return false; -} - -// ret [0xc9] or [0xc2 imm8] or [0xca imm8] -bool -AssemblyParse_x86::ret_pattern_p () -{ - uint8_t *p = m_cur_insn_bytes; - if (*p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3) - return true; - return false; -} - -uint32_t -AssemblyParse_x86::extract_4 (uint8_t *b) -{ - uint32_t v = 0; - for (int i = 3; i >= 0; i--) - v = (v << 8) | b[i]; - return v; -} - -bool -AssemblyParse_x86::machine_regno_to_lldb_regno (int machine_regno, uint32_t &lldb_regno) -{ - struct regmap_ent *ent; - int count, i; - if (m_cpu == k_i386) - { - ent = i386_register_map; - count = size_of_i386_register_map; - } - else - { - ent = x86_64_register_map; - count = size_of_x86_64_register_map; - } - for (i = 0; i < count; i++, ent++) - { - if (ent->machine_regno == machine_regno) - if (ent->lldb_regno != -1) - { - lldb_regno = ent->lldb_regno; - return true; - } - } - return false; -} - -struct edis_byte_read_token -{ - Address *address; - Target *target; -}; - - -static int -read_byte_for_edis (uint8_t *buf, uint64_t offset_address, void *arg) -{ - if (arg == 0) - return -1; - struct edis_byte_read_token *tok = (edis_byte_read_token *) arg; - Address *base_address = tok->address; - Target *target = tok->target; - - Address read_addr = *base_address; - read_addr.SetOffset (offset_address); - - uint8_t onebyte_buf[1]; - Error error; - const bool prefer_file_cache = true; - if (target->ReadMemory (read_addr, prefer_file_cache, onebyte_buf, 1, error) != -1) - { - *buf = onebyte_buf[0]; - return 0; - } - return -1; -} - - -bool -AssemblyParse_x86::instruction_length (Address addr, int &length) -{ - const char *triple; - - if (!addr.IsValid()) - return false; - - // FIXME should probably pass down the ArchSpec and work from that to make a portable triple - if (m_cpu == k_i386) - triple = "i386-unknown-unknown"; - else - triple = "x86_64-unknown-unknown"; - - EDDisassemblerRef disasm; - EDInstRef cur_insn; - - if (EDGetDisassembler (&disasm, triple, kEDAssemblySyntaxX86ATT) != 0) - { - return false; - } - - uint64_t addr_offset = addr.GetOffset(); - struct edis_byte_read_token arg; - arg.address = &addr; - arg.target = &m_target; - if (EDCreateInsts (&cur_insn, 1, disasm, read_byte_for_edis, addr_offset, &arg) != 1) - { - return false; - } - length = EDInstByteSize (cur_insn); - EDReleaseInst (cur_insn); - return true; -} - - -bool -AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) -{ - UnwindPlan::Row row; - int non_prologue_insn_count = 0; - m_cur_insn = m_func_bounds.GetBaseAddress (); - int current_func_text_offset = 0; - int current_sp_bytes_offset_from_cfa = 0; - UnwindPlan::Row::RegisterLocation initial_regloc; - Error error; - - if (!m_cur_insn.IsValid()) - { - return false; - } - - unwind_plan.SetPlanValidAddressRange (m_func_bounds); - unwind_plan.SetRegisterKind (eRegisterKindLLDB); - - // At the start of the function, find the CFA by adding wordsize to the SP register - row.SetOffset (current_func_text_offset); - row.SetCFARegister (m_lldb_sp_regnum); - row.SetCFAOffset (m_wordsize); - - // caller's stack pointer value before the call insn is the CFA address - initial_regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, initial_regloc); - - // saved instruction pointer can be found at CFA - wordsize. - current_sp_bytes_offset_from_cfa = m_wordsize; - initial_regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (m_lldb_ip_regnum, initial_regloc); - - unwind_plan.AppendRow (row); - const bool prefer_file_cache = true; - - while (m_func_bounds.ContainsFileAddress (m_cur_insn) && non_prologue_insn_count < 10) - { - int stack_offset, insn_len; - int machine_regno; // register numbers masked directly out of instructions - uint32_t lldb_regno; // register numbers in lldb's eRegisterKindLLDB numbering scheme - - if (!instruction_length (m_cur_insn, insn_len) || insn_len == 0 || insn_len > kMaxInstructionByteSize) - { - // An unrecognized/junk instruction - break; - } - if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1) - { - // Error reading the instruction out of the file, stop scanning - break; - } - - if (push_rbp_pattern_p ()) - { - row.SetOffset (current_func_text_offset + insn_len); - current_sp_bytes_offset_from_cfa += m_wordsize; - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); - row.SetRegisterInfo (m_lldb_fp_regnum, regloc); - unwind_plan.AppendRow (row); - goto loopnext; - } - - if (mov_rsp_rbp_pattern_p ()) - { - row.SetOffset (current_func_text_offset + insn_len); - row.SetCFARegister (m_lldb_fp_regnum); - unwind_plan.AppendRow (row); - goto loopnext; - } - - // This is the start() function (or a pthread equivalent), it starts with a pushl $0x0 which puts the - // saved pc value of 0 on the stack. In this case we want to pretend we didn't see a stack movement at all -- - // normally the saved pc value is already on the stack by the time the function starts executing. - if (push_0_pattern_p ()) - { - goto loopnext; - } - - if (push_reg_p (machine_regno)) - { - current_sp_bytes_offset_from_cfa += m_wordsize; - if (nonvolatile_reg_p (machine_regno) && machine_regno_to_lldb_regno (machine_regno, lldb_regno)) - { - row.SetOffset (current_func_text_offset + insn_len); - if (row.GetCFARegister() == m_lldb_sp_regnum) - { - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - } - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (lldb_regno, regloc); - unwind_plan.AppendRow (row); - } - goto loopnext; - } - - if (mov_reg_to_local_stack_frame_p (machine_regno, stack_offset) && nonvolatile_reg_p (machine_regno)) - { - if (machine_regno_to_lldb_regno (machine_regno, lldb_regno)) - { - row.SetOffset (current_func_text_offset + insn_len); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); - row.SetRegisterInfo (lldb_regno, regloc); - unwind_plan.AppendRow (row); - goto loopnext; - } - } - - if (sub_rsp_pattern_p (stack_offset)) - { - current_sp_bytes_offset_from_cfa += stack_offset; - if (row.GetCFARegister() == m_lldb_sp_regnum) - { - row.SetOffset (current_func_text_offset + insn_len); - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - unwind_plan.AppendRow (row); - } - goto loopnext; - } - - if (ret_pattern_p ()) - { - // we know where the end of the function is; set the limit on the PlanValidAddressRange - // in case our initial "high pc" value was overly large - // int original_size = m_func_bounds.GetByteSize(); - // int calculated_size = m_cur_insn.GetOffset() - m_func_bounds.GetBaseAddress().GetOffset() + insn_len + 1; - // m_func_bounds.SetByteSize (calculated_size); - // unwind_plan.SetPlanValidAddressRange (m_func_bounds); - break; - } - - // FIXME recognize the i386 picbase setup instruction sequence, - // 0x1f16: call 0x1f1b ; main + 11 at /private/tmp/a.c:3 - // 0x1f1b: popl %eax - // and record the temporary stack movements if the CFA is not expressed in terms of ebp. - - non_prologue_insn_count++; -loopnext: - m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); - current_func_text_offset += insn_len; - } - - // Now look at the byte at the end of the AddressRange for a limited attempt at describing the - // epilogue. If this function is built -fomit-frame-pointer (so the CFA is defined in terms of the - // stack pointer) we'd need to profile every instruction which causes rsp to change to backtrace - // all the time. But assuming the CFA is in terms of rbp most of the time, this one additional Row - // will be sufficient. - - if (m_func_bounds.GetByteSize() > 2) - { - Address last_insn (m_func_bounds.GetBaseAddress()); - last_insn.SetOffset (last_insn.GetOffset() + m_func_bounds.GetByteSize() - 1); - uint8_t bytebuf[1]; - if (m_target.ReadMemory (last_insn, prefer_file_cache, bytebuf, 1, error) != -1) - { - if (bytebuf[0] == 0xc3) // ret aka retq - { - // Create a fresh, empty Row and RegisterLocation - don't mention any other registers - UnwindPlan::Row epi_row; - UnwindPlan::Row::RegisterLocation epi_regloc; - - // When the ret instruction is about to be executed, here's our state - epi_row.SetOffset (m_func_bounds.GetByteSize() - 1); - epi_row.SetCFARegister (m_lldb_sp_regnum); - epi_row.SetCFAOffset (m_wordsize); - - // caller's stack pointer value before the call insn is the CFA address - epi_regloc.SetIsCFAPlusOffset (0); - epi_row.SetRegisterInfo (m_lldb_sp_regnum, epi_regloc); - - // saved instruction pointer can be found at CFA - wordsize - epi_regloc.SetAtCFAPlusOffset (-m_wordsize); - epi_row.SetRegisterInfo (m_lldb_ip_regnum, epi_regloc); - - unwind_plan.AppendRow (epi_row); - } - } - } - - unwind_plan.SetSourceName ("assembly insn profiling"); - - return true; -} - -/* The "fast unwind plan" is valid for functions that follow the usual convention of - using the frame pointer register (ebp, rbp), i.e. the function prologue looks like - push %rbp [0x55] - mov %rsp,%rbp [0x48 0x89 0xe5] (this is a 2-byte insn seq on i386) -*/ - -bool -AssemblyParse_x86::get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_plan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation pc_reginfo; - UnwindPlan::Row::RegisterLocation sp_reginfo; - UnwindPlan::Row::RegisterLocation fp_reginfo; - unwind_plan.SetRegisterKind (eRegisterKindLLDB); - - if (!func.GetBaseAddress().IsValid()) - return false; - - uint8_t bytebuf[4]; - Error error; - const bool prefer_file_cache = true; - if (m_target.ReadMemory (func.GetBaseAddress(), prefer_file_cache, bytebuf, sizeof (bytebuf), error) == -1) - return false; - - uint8_t i386_prologue[] = {0x55, 0x89, 0xe5}; - uint8_t x86_64_prologue[] = {0x55, 0x48, 0x89, 0xe5}; - int prologue_size; - - if (memcmp (bytebuf, i386_prologue, sizeof (i386_prologue)) == 0) - { - prologue_size = sizeof (i386_prologue); - } - else if (memcmp (bytebuf, x86_64_prologue, sizeof (x86_64_prologue)) == 0) - { - prologue_size = sizeof (x86_64_prologue); - } - else - { - return false; - } - - pc_reginfo.SetAtCFAPlusOffset (-m_wordsize); - row.SetRegisterInfo (m_lldb_ip_regnum, pc_reginfo); - - sp_reginfo.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, sp_reginfo); - - // Zero instructions into the function - row.SetCFARegister (m_lldb_sp_regnum); - row.SetCFAOffset (m_wordsize); - row.SetOffset (0); - unwind_plan.AppendRow (row); - - // push %rbp has executed - stack moved, rbp now saved - row.SetCFAOffset (2 * m_wordsize); - fp_reginfo.SetAtCFAPlusOffset (2 * -m_wordsize); - row.SetRegisterInfo (m_lldb_fp_regnum, fp_reginfo); - row.SetOffset (1); - unwind_plan.AppendRow (row); - - // mov %rsp, %rbp has executed - row.SetCFARegister (m_lldb_fp_regnum); - row.SetCFAOffset (2 * m_wordsize); - row.SetOffset (prologue_size); /// 3 or 4 bytes depending on arch - unwind_plan.AppendRow (row); - - unwind_plan.SetPlanValidAddressRange (func); - return true; -} - -bool -AssemblyParse_x86::find_first_non_prologue_insn (Address &address) -{ - m_cur_insn = m_func_bounds.GetBaseAddress (); - if (!m_cur_insn.IsValid()) - { - return false; - } - - const bool prefer_file_cache = true; - while (m_func_bounds.ContainsFileAddress (m_cur_insn)) - { - Error error; - int insn_len, offset, regno; - if (!instruction_length (m_cur_insn, insn_len) || insn_len > kMaxInstructionByteSize || insn_len == 0) - { - // An error parsing the instruction, i.e. probably data/garbage - stop scanning - break; - } - if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1) - { - // Error reading the instruction out of the file, stop scanning - break; - } - - if (push_rbp_pattern_p () || mov_rsp_rbp_pattern_p () || sub_rsp_pattern_p (offset) - || push_reg_p (regno) || mov_reg_to_local_stack_frame_p (regno, offset)) - { - m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); - continue; - } - - // Unknown non-prologue instruction - stop scanning - break; - } - - address = m_cur_insn; - return true; -} - - - - - - -//----------------------------------------------------------------------------------------------- -// UnwindAssemblyParser_x86 method definitions -//----------------------------------------------------------------------------------------------- - -bool -UnwindAssemblyProfiler_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) -{ - AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); - return asm_parse.get_non_call_site_unwind_plan (unwind_plan); -} - -bool -UnwindAssemblyProfiler_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) -{ - AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); - return asm_parse.get_fast_unwind_plan (func, unwind_plan); -} - -bool -UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) -{ - AssemblyParse_x86 asm_parse(target, thread, m_cpu, func); - return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); -} - -UnwindAssemblyProfiler * -UnwindAssemblyProfiler_x86::CreateInstance (const ArchSpec &arch) -{ - const llvm::Triple::ArchType cpu = arch.GetMachine (); - if (cpu == llvm::Triple::x86) - return new UnwindAssemblyProfiler_x86 (k_i386); - else if (cpu == llvm::Triple::x86_64) - return new UnwindAssemblyProfiler_x86 (k_x86_64); - return NULL; -} - - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -UnwindAssemblyProfiler_x86::GetPluginName() -{ - return "UnwindAssemblyProfiler_x86"; -} - -const char * -UnwindAssemblyProfiler_x86::GetShortPluginName() -{ - return "unwindassemblyprofiler.x86"; -} - - -uint32_t -UnwindAssemblyProfiler_x86::GetPluginVersion() -{ - return 1; -} - -void -UnwindAssemblyProfiler_x86::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -UnwindAssemblyProfiler_x86::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -UnwindAssemblyProfiler_x86::GetPluginNameStatic() -{ - return "UnwindAssemblyProfiler_x86"; -} - -const char * -UnwindAssemblyProfiler_x86::GetPluginDescriptionStatic() -{ - return "i386 and x86_64 assembly language profiler plugin."; -} Removed: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h (removed) @@ -1,73 +0,0 @@ -//===-- UnwindAssemblyProfiler-x86.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_UnwindAssemblyProfiler_x86_h_ -#define liblldb_UnwindAssemblyProfiler_x86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" -#include "lldb/Target/Thread.h" - -namespace lldb_private { - -class UnwindAssemblyProfiler_x86 : public lldb_private::UnwindAssemblyProfiler -{ -public: - - ~UnwindAssemblyProfiler_x86 () { } - - virtual bool - GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, lldb_private::Thread& thread, UnwindPlan& unwind_plan); - - virtual bool - GetFastUnwindPlan (AddressRange& func, lldb_private::Thread& thread, UnwindPlan &unwind_plan); - - // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). - virtual bool - FirstNonPrologueInsn (AddressRange& func, lldb_private::Target& target, lldb_private::Thread* thread, Address& first_non_prologue_insn); - - static lldb_private::UnwindAssemblyProfiler * - CreateInstance (const lldb_private::ArchSpec &arch); - - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - UnwindAssemblyProfiler_x86(int cpu) : - lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) { } // Call CreateInstance instead. - - int m_cpu; -}; - - -} // namespace lldb_private - -#endif // liblldb_UnwindAssemblyProfiler_x86_h_ Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Mon Apr 25 13:36:36 2011 @@ -7,16 +7,16 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/Thread.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/RegisterContext.h" #include "lldb/Core/Module.h" +#include "lldb/Core/Log.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/Function.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Core/Log.h" +#include "lldb/Target/ArchDefaultUnwindPlan.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" #include "UnwindLLDB.h" #include "RegisterContextLLDB.h" Copied: lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp (from r130129, lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp?p2=lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp&p1=lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp Mon Apr 25 13:36:36 2011 @@ -9,24 +9,19 @@ #include "UnwindAssemblyProfiler-x86.h" -#include "lldb/lldb-private.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "llvm-c/EnhancedDisassembly.h" + #include "lldb/Core/Address.h" #include "lldb/Core/Error.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" -#include "lldb/Symbol/UnwindPlan.h" - -#include "lldb/lldb-enumerations.h" -#include "llvm-c/EnhancedDisassembly.h" - -#include "UnwindAssemblyProfiler-x86.h" - +#include "lldb/Target/UnwindAssemblyProfiler.h" using namespace lldb; using namespace lldb_private; Copied: lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h (from r130129, lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h?p2=lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h&p1=lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h Mon Apr 25 13:36:36 2011 @@ -11,7 +11,7 @@ #define liblldb_UnwindAssemblyProfiler_x86_h_ #include "lldb/lldb-private.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssemblyProfiler.h" #include "lldb/Target/Thread.h" namespace lldb_private { Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original) +++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Mon Apr 25 13:36:36 2011 @@ -7,18 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-private.h" +#include "lldb/Core/AddressRange.h" +#include "lldb/Core/Address.h" #include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Core/AddressRange.h" -#include "lldb/Core/Address.h" #include "lldb/Symbol/UnwindTable.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" -#include "lldb/Symbol/DWARFCallFrameInfo.h" +#include "lldb/Target/ArchDefaultUnwindPlan.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" +#include "lldb/Target/UnwindAssemblyProfiler.h" using namespace lldb; using namespace lldb_private; Modified: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (original) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Mon Apr 25 13:36:36 2011 @@ -1,4 +1,4 @@ -//===-- UnwindTable.cpp ----------------------------------*- C++ -*-===// +//===-- UnwindTable.cpp -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,16 +11,13 @@ #include -#include "lldb/lldb-forward.h" - #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" -//#include "lldb/Core/StreamFile.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssemblyProfiler.h" // There is one UnwindTable object per ObjectFile. // It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile. Copied: lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp (from r130129, lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp?p2=lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp&p1=lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp (original) +++ lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp Mon Apr 25 13:36:36 2011 @@ -14,7 +14,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Host/Mutex.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" +#include "lldb/Target/ArchDefaultUnwindPlan.h" using namespace lldb; using namespace lldb_private; Copied: lldb/trunk/source/Target/ArchVolatileRegs.cpp (from r130129, lldb/trunk/source/Utility/ArchVolatileRegs.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ArchVolatileRegs.cpp?p2=lldb/trunk/source/Target/ArchVolatileRegs.cpp&p1=lldb/trunk/source/Utility/ArchVolatileRegs.cpp&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Utility/ArchVolatileRegs.cpp (original) +++ lldb/trunk/source/Target/ArchVolatileRegs.cpp Mon Apr 25 13:36:36 2011 @@ -10,7 +10,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/ArchVolatileRegs.h" +#include "lldb/Target/ArchVolatileRegs.h" using namespace lldb; using namespace lldb_private; Copied: lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp (from r130129, lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp?p2=lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp&p1=lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp&r1=130129&r2=130135&rev=130135&view=diff ============================================================================== --- lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp (original) +++ lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp Mon Apr 25 13:36:36 2011 @@ -10,7 +10,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssemblyProfiler.h" using namespace lldb; using namespace lldb_private; Removed: lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp (original) +++ lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp (removed) @@ -1,54 +0,0 @@ -//===-- ArchDefaultUnwindPlan.cpp -------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Core/PluginManager.h" - -#include - -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginInterface.h" -#include "lldb/Host/Mutex.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" - -using namespace lldb; -using namespace lldb_private; - -ArchDefaultUnwindPlanSP -ArchDefaultUnwindPlan::FindPlugin (const ArchSpec &arch) -{ - ArchDefaultUnwindPlanCreateInstance create_callback; - typedef std::map ArchDefaultUnwindPlanMap; - static ArchDefaultUnwindPlanMap g_plugin_map; - static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive); - Mutex::Locker locker (g_plugin_map_mutex); - ArchDefaultUnwindPlanMap::iterator pos = g_plugin_map.find (arch); - if (pos != g_plugin_map.end()) - return pos->second; - - for (uint32_t idx = 0; - (create_callback = PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex(idx)) != NULL; - ++idx) - { - ArchDefaultUnwindPlanSP default_unwind_plan_sp (create_callback (arch)); - if (default_unwind_plan_sp) - { - g_plugin_map[arch] = default_unwind_plan_sp; - return default_unwind_plan_sp; - } - } - return ArchDefaultUnwindPlanSP(); -} - -ArchDefaultUnwindPlan::ArchDefaultUnwindPlan () -{ -} - -ArchDefaultUnwindPlan::~ArchDefaultUnwindPlan () -{ -} Removed: lldb/trunk/source/Utility/ArchVolatileRegs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchVolatileRegs.cpp?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Utility/ArchVolatileRegs.cpp (original) +++ lldb/trunk/source/Utility/ArchVolatileRegs.cpp (removed) @@ -1,40 +0,0 @@ -//===-- ArchVolatileRegs.cpp ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/ArchVolatileRegs.h" - -using namespace lldb; -using namespace lldb_private; - -ArchVolatileRegs* -ArchVolatileRegs::FindPlugin (const ArchSpec &arch) -{ - ArchVolatileRegsCreateInstance create_callback; - - for (uint32_t idx = 0; - (create_callback = PluginManager::GetArchVolatileRegsCreateCallbackAtIndex(idx)) != NULL; - ++idx) - { - std::auto_ptr default_volatile_regs_ap (create_callback (arch)); - if (default_volatile_regs_ap.get ()) - return default_volatile_regs_ap.release (); - } - return NULL; -} - -ArchVolatileRegs::ArchVolatileRegs () -{ -} - -ArchVolatileRegs::~ArchVolatileRegs () -{ -} Removed: lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp?rev=130134&view=auto ============================================================================== --- lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp (original) +++ lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp (removed) @@ -1,40 +0,0 @@ -//===-- UnwindAssemblyProfiler.cpp ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" - -using namespace lldb; -using namespace lldb_private; - -UnwindAssemblyProfiler* -UnwindAssemblyProfiler::FindPlugin (const ArchSpec &arch) -{ - UnwindAssemblyProfilerCreateInstance create_callback; - - for (uint32_t idx = 0; - (create_callback = PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex(idx)) != NULL; - ++idx) - { - std::auto_ptr assembly_profiler_ap (create_callback (arch)); - if (assembly_profiler_ap.get ()) - return assembly_profiler_ap.release (); - } - return NULL; -} - -UnwindAssemblyProfiler::UnwindAssemblyProfiler () -{ -} - -UnwindAssemblyProfiler::~UnwindAssemblyProfiler () -{ -} Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Apr 25 13:36:36 2011 @@ -30,9 +30,9 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" -#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" -#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" -#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" +#include "Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h" +#include "Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h" +#include "Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h" #if defined (__APPLE__) #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=130135&r1=130134&r2=130135&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Apr 25 13:36:36 2011 @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -374,8 +374,11 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( From johnny.chen at apple.com Mon Apr 25 15:23:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Apr 2011 20:23:05 -0000 Subject: [Lldb-commits] [lldb] r130147 - in /lldb/trunk: include/lldb/API/SBBreakpointLocation.h scripts/Python/python-extensions.swig source/API/SBBreakpointLocation.cpp test/lldbutil.py test/python_api/target/TestTargetAPI.py Message-ID: <20110425202305.A22C42A6C12D@llvm.org> Author: johnny Date: Mon Apr 25 15:23:05 2011 New Revision: 130147 URL: http://llvm.org/viewvc/llvm-project?rev=130147&view=rev Log: Make SBBreakpointLocation::GetDescription() API to be consistent with SBTarget, i.e., with 'SBStream &description' first, followed by 'DescriptionLevel level'. Modify lldbutil.py so that get_description() for a target or breakpoint location can just take the lldb object itself without specifying an option to mean option lldb.eDescriptionLevelBrief. Modify TestTargetAPI.py to exercise this logic path. Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/scripts/Python/python-extensions.swig lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/target/TestTargetAPI.py Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=130147&r1=130146&r2=130147&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Apr 25 15:23:05 2011 @@ -82,7 +82,7 @@ IsResolved (); bool - GetDescription (DescriptionLevel level, lldb::SBStream &description); + GetDescription (lldb::SBStream &description, DescriptionLevel level); SBBreakpoint GetBreakpoint (); Modified: lldb/trunk/scripts/Python/python-extensions.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=130147&r1=130146&r2=130147&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-extensions.swig (original) +++ lldb/trunk/scripts/Python/python-extensions.swig Mon Apr 25 15:23:05 2011 @@ -23,7 +23,7 @@ %extend lldb::SBBreakpointLocation { PyObject *lldb::SBBreakpointLocation::__repr__ (){ lldb::SBStream description; - $self->GetDescription (lldb::eDescriptionLevelFull, description); + $self->GetDescription (description, lldb::eDescriptionLevelFull); return PyString_FromString (description.GetData()); } } Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=130147&r1=130146&r2=130147&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Apr 25 15:23:05 2011 @@ -40,7 +40,7 @@ if (log) { SBStream sstr; - GetDescription (lldb::eDescriptionLevelBrief, sstr); + GetDescription (sstr, lldb::eDescriptionLevelBrief); log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp" "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData()); } @@ -263,7 +263,7 @@ } bool -SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description) +SBBreakpointLocation::GetDescription (SBStream &description, DescriptionLevel level) { if (m_opaque_sp) { Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130147&r1=130146&r2=130147&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Mon Apr 25 15:23:05 2011 @@ -171,11 +171,22 @@ # ============================================================== # Get the description of an lldb object or None if not available # ============================================================== -def get_description(lldb_obj, option=None): - """Calls lldb_obj.GetDescription() and returns a string, or None.""" - method = getattr(lldb_obj, 'GetDescription') +def get_description(obj, option=None): + """Calls lldb_obj.GetDescription() and returns a string, or None. + + For SBTarget and SBBreakpointLocation lldb objects, an extra option can be + passed in to describe the detailed level of description desired: + o lldb.eDescriptionLevelBrief + o lldb.eDescriptionLevelFull + o lldb.eDescriptionLevelVerbose + """ + method = getattr(obj, 'GetDescription') if not method: return None + if isinstance(obj, lldb.SBTarget) or isinstance(obj, lldb.SBBreakpointLocation): + if option is None: + option = lldb.eDescriptionLevelBrief + stream = lldb.SBStream() if option is None: success = method(stream) Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=130147&r1=130146&r2=130147&view=diff ============================================================================== --- lldb/trunk/test/python_api/target/TestTargetAPI.py (original) +++ lldb/trunk/test/python_api/target/TestTargetAPI.py Mon Apr 25 15:23:05 2011 @@ -67,7 +67,10 @@ self.assertTrue(target.IsValid(), VALID_TARGET) from lldbutil import get_description - desc = get_description(target, option=lldb.eDescriptionLevelBrief) + + # get_description() allows no option to mean lldb.eDescriptionLevelBrief. + desc = get_description(target) + #desc = get_description(target, option=lldb.eDescriptionLevelBrief) if not desc: self.fail("SBTarget.GetDescription() failed") self.expect(desc, exe=False, From gclayton at apple.com Mon Apr 25 16:05:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 25 Apr 2011 21:05:07 -0000 Subject: [Lldb-commits] [lldb] r130154 - in /lldb/trunk: lldb.xcodeproj/ source/ source/Plugins/ArchDefaultUnwindPlan/ source/Plugins/ArchDefaultUnwindPlan/x86/ source/Plugins/ArchVolatileRegs/ source/Plugins/ArchVolatileRegs/x86/ source/Plugins/UnwindAssembly/ source/Plugins/UnwindAssembly/InstEmulation/ source/Plugins/UnwindAssembly/x86/ Message-ID: <20110425210507.E8A022A6C12D@llvm.org> Author: gclayton Date: Mon Apr 25 16:05:07 2011 New Revision: 130154 URL: http://llvm.org/viewvc/llvm-project?rev=130154&view=rev Log: More moving things around for the unwind plan and assembly unwind plug-ins. Added: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.cpp - copied unchanged from r130146, lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h - copied unchanged from r130146, lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.cpp - copied unchanged from r130146, lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h - copied unchanged from r130146, lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/trunk/source/Plugins/UnwindAssembly/x86/ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp - copied, changed from r130146, lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h - copied, changed from r130146, lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h Removed: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/lldb.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130154&r1=130153&r2=130154&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Apr 25 16:05:07 2011 @@ -362,12 +362,15 @@ 2689FFFF13353DB600698AC0 /* BreakpointResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1210F1B83100F91463 /* BreakpointResolver.cpp */; }; 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; + 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; + 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */; }; + 2692BA1A136611CD00F9E14D /* UnwindAssemblyx86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA18136611CD00F9E14D /* UnwindAssemblyx86.cpp */; }; + 2692BA1B136611CD00F9E14D /* UnwindAssemblyx86.h in Headers */ = {isa = PBXBuildFile; fileRef = 2692BA19136611CD00F9E14D /* UnwindAssemblyx86.h */; }; + 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */; }; + 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */; }; 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; 2697A54E133A6305004E4240 /* PlatformDarwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2697A54C133A6305004E4240 /* PlatformDarwin.h */; }; 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; }; - 26AC3F471365F43F0065C7EF /* UnwindAssemblyProfiler-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26AC3F451365F4390065C7EF /* UnwindAssemblyProfiler-x86.cpp */; }; - 26AC3F4B1365F4EC0065C7EF /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26AC3F491365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.cpp */; }; - 26AC3F4F1365F53B0065C7EF /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26AC3F4D1365F5380065C7EF /* ArchVolatileRegs-x86.cpp */; }; 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; 26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; 26B1FCB913381071002886E2 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; @@ -706,6 +709,14 @@ 268DA873130095ED00C9483A /* Terminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Terminal.cpp; sourceTree = ""; }; 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContextList.h; path = include/lldb/API/SBSymbolContextList.h; sourceTree = ""; }; 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = ""; }; + 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnwindAssemblyInstEmulation.cpp; sourceTree = ""; }; + 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; }; + 2692BA18136611CD00F9E14D /* UnwindAssemblyx86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnwindAssemblyx86.cpp; sourceTree = ""; }; + 2692BA19136611CD00F9E14D /* UnwindAssemblyx86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyx86.h; sourceTree = ""; }; + 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; + 2692BA1E136614D000F9E14D /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; + 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; + 2692BA22136614FC00F9E14D /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArchVolatileRegs-x86.h"; sourceTree = ""; }; 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; }; 269416AE119A024800FF2715 /* CommandObjectTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTarget.h; path = source/Commands/CommandObjectTarget.h; sourceTree = ""; }; 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformDarwin.cpp; sourceTree = ""; }; @@ -720,12 +731,6 @@ 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLDBWrapPython.cpp; path = source/LLDBWrapPython.cpp; sourceTree = ""; }; 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NamedOptionValue.cpp; path = source/Interpreter/NamedOptionValue.cpp; sourceTree = ""; }; 26A7A036135E6E5300FB369E /* NamedOptionValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NamedOptionValue.h; path = include/lldb/Interpreter/NamedOptionValue.h; sourceTree = ""; }; - 26AC3F451365F4390065C7EF /* UnwindAssemblyProfiler-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "UnwindAssemblyProfiler-x86.cpp"; path = "source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp"; sourceTree = SOURCE_ROOT; }; - 26AC3F461365F4390065C7EF /* UnwindAssemblyProfiler-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UnwindAssemblyProfiler-x86.h"; path = "source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h"; sourceTree = SOURCE_ROOT; }; - 26AC3F491365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchDefaultUnwindPlan-x86.cpp"; path = "ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; - 26AC3F4A1365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "ArchDefaultUnwindPlan-x86.h"; path = "ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; - 26AC3F4D1365F5380065C7EF /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchVolatileRegs-x86.cpp"; path = "ArchVolatileRegs/ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; - 26AC3F4E1365F5380065C7EF /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "ArchVolatileRegs-x86.h"; path = "ArchVolatileRegs/ArchVolatileRegs-x86.h"; sourceTree = ""; }; 26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeValue.h; path = include/lldb/Core/ThreadSafeValue.h; sourceTree = ""; }; 26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = ""; }; 26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = ""; }; @@ -1777,6 +1782,42 @@ path = Static; sourceTree = ""; }; + 2692BA12136610C100F9E14D /* InstEmulation */ = { + isa = PBXGroup; + children = ( + 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */, + 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */, + ); + path = InstEmulation; + sourceTree = ""; + }; + 2692BA17136611CD00F9E14D /* x86 */ = { + isa = PBXGroup; + children = ( + 2692BA18136611CD00F9E14D /* UnwindAssemblyx86.cpp */, + 2692BA19136611CD00F9E14D /* UnwindAssemblyx86.h */, + ); + path = x86; + sourceTree = ""; + }; + 2692BA1C136614D000F9E14D /* x86 */ = { + isa = PBXGroup; + children = ( + 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */, + 2692BA1E136614D000F9E14D /* ArchDefaultUnwindPlan-x86.h */, + ); + path = x86; + sourceTree = ""; + }; + 2692BA20136614FC00F9E14D /* x86 */ = { + isa = PBXGroup; + children = ( + 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */, + 2692BA22136614FC00F9E14D /* ArchVolatileRegs-x86.h */, + ); + path = x86; + sourceTree = ""; + }; 26A3B4AB1181454800381BC2 /* BSD-Archive */ = { isa = PBXGroup; children = ( @@ -1789,29 +1830,26 @@ 26AC3F441365F40E0065C7EF /* UnwindAssembly */ = { isa = PBXGroup; children = ( - 26AC3F451365F4390065C7EF /* UnwindAssemblyProfiler-x86.cpp */, - 26AC3F461365F4390065C7EF /* UnwindAssemblyProfiler-x86.h */, + 2692BA12136610C100F9E14D /* InstEmulation */, + 2692BA17136611CD00F9E14D /* x86 */, ); - name = UnwindAssembly; - path = Process; + path = UnwindAssembly; sourceTree = ""; }; 26AC3F481365F4620065C7EF /* ArchDefaultUnwindPlan */ = { isa = PBXGroup; children = ( - 26AC3F491365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.cpp */, - 26AC3F4A1365F4E90065C7EF /* ArchDefaultUnwindPlan-x86.h */, + 2692BA1C136614D000F9E14D /* x86 */, ); - name = ArchDefaultUnwindPlan; + path = ArchDefaultUnwindPlan; sourceTree = ""; }; 26AC3F4C1365F5260065C7EF /* ArchVolatileRegs */ = { isa = PBXGroup; children = ( - 26AC3F4D1365F5380065C7EF /* ArchVolatileRegs-x86.cpp */, - 26AC3F4E1365F5380065C7EF /* ArchVolatileRegs-x86.h */, + 2692BA20136614FC00F9E14D /* x86 */, ); - name = ArchVolatileRegs; + path = ArchVolatileRegs; sourceTree = ""; }; 26B4666E11A2080F00CF6220 /* Utility */ = { @@ -2619,6 +2657,8 @@ 4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */, 4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */, 4C2FAE2F135E3A70001EDE44 /* SharedCluster.h in Headers */, + 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */, + 2692BA1B136611CD00F9E14D /* UnwindAssemblyx86.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3189,9 +3229,10 @@ 2630BFA91365F28C0070C534 /* UnwindAssemblyProfiler.cpp in Sources */, 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */, 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */, - 26AC3F471365F43F0065C7EF /* UnwindAssemblyProfiler-x86.cpp in Sources */, - 26AC3F4B1365F4EC0065C7EF /* ArchDefaultUnwindPlan-x86.cpp in Sources */, - 26AC3F4F1365F53B0065C7EF /* ArchVolatileRegs-x86.cpp in Sources */, + 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */, + 2692BA1A136611CD00F9E14D /* UnwindAssemblyx86.cpp in Sources */, + 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */, + 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Removed: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp?rev=130153&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.cpp (removed) @@ -1,192 +0,0 @@ -//===-- ArchDefaultUnwindPlan-x86.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ArchDefaultUnwindPlan-x86.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Target/ArchDefaultUnwindPlan.h" - -using namespace lldb; -using namespace lldb_private; - -lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch) -{ - if (arch.GetMachine () == llvm::Triple::x86_64) - return new ArchDefaultUnwindPlan_x86_64 (); - return NULL; -} - -ArchDefaultUnwindPlan_x86_64::ArchDefaultUnwindPlan_x86_64() : - lldb_private::ArchDefaultUnwindPlan(), - m_unwind_plan_sp (new UnwindPlan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation regloc; - - m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); - row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 8); - row.SetOffset (0); - - regloc.SetAtCFAPlusOffset (2 * -8); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -8); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); - regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - - m_unwind_plan_sp->AppendRow (row); - m_unwind_plan_sp->SetSourceName ("x86_64 architectural default"); -} - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -ArchDefaultUnwindPlan_x86_64::GetPluginName() -{ - return "ArchDefaultUnwindPlan_x86_64"; -} - -const char * -ArchDefaultUnwindPlan_x86_64::GetShortPluginName() -{ - return "lldb.arch-default-unwind-plan.x86-64"; -} - - -uint32_t -ArchDefaultUnwindPlan_x86_64::GetPluginVersion() -{ - return 1; -} -void -ArchDefaultUnwindPlan_x86_64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -ArchDefaultUnwindPlan_x86_64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -ArchDefaultUnwindPlan_x86_64::GetPluginNameStatic() -{ - return "ArchDefaultUnwindPlan_x86_64"; -} - -const char * -ArchDefaultUnwindPlan_x86_64::GetPluginDescriptionStatic() -{ - return "x86_64 architecture default unwind plan assembly plugin."; -} - -UnwindPlanSP -ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) -{ - return m_unwind_plan_sp; -} - - - -lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch) -{ - if (arch.GetMachine () == llvm::Triple::x86) - return new ArchDefaultUnwindPlan_i386 (); - return NULL; -} - -ArchDefaultUnwindPlan_i386::ArchDefaultUnwindPlan_i386() : - lldb_private::ArchDefaultUnwindPlan(), - m_unwind_plan_sp (new UnwindPlan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation regloc; - - m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); - row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 4); - row.SetOffset (0); - - regloc.SetAtCFAPlusOffset (2 * -4); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -4); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); - regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - - m_unwind_plan_sp->AppendRow (row); - m_unwind_plan_sp->SetSourceName ("i386 architectural default"); -} - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -ArchDefaultUnwindPlan_i386::GetPluginName() -{ - return "ArchDefaultUnwindPlan_i386"; -} - -const char * -ArchDefaultUnwindPlan_i386::GetShortPluginName() -{ - return "archdefaultunwindplan.x86"; -} - - -uint32_t -ArchDefaultUnwindPlan_i386::GetPluginVersion() -{ - return 1; -} - -void -ArchDefaultUnwindPlan_i386::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -ArchDefaultUnwindPlan_i386::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -ArchDefaultUnwindPlan_i386::GetPluginNameStatic() -{ - return "ArchDefaultUnwindPlan_i386"; -} - -const char * -ArchDefaultUnwindPlan_i386::GetPluginDescriptionStatic() -{ - return "i386 architecture default unwind plan assembly plugin."; -} - -UnwindPlanSP -ArchDefaultUnwindPlan_i386::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) -{ - return m_unwind_plan_sp; -} - Removed: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h?rev=130153&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h (removed) @@ -1,107 +0,0 @@ -//===-- ArchDefaultUnwindPlan-x86.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_ArchDefaultUnwindPlan_x86_h_ -#define liblldb_ArchDefaultUnwindPlan_x86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Target/ArchDefaultUnwindPlan.h" -#include "lldb/Target/Thread.h" -#include "lldb/Symbol/UnwindPlan.h" - -namespace lldb_private { - -class ArchDefaultUnwindPlan_x86_64 : public lldb_private::ArchDefaultUnwindPlan -{ -public: - - ~ArchDefaultUnwindPlan_x86_64 () { } - - virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); - - static lldb_private::ArchDefaultUnwindPlan * - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - ArchDefaultUnwindPlan_x86_64(); // Call CreateInstance instead. - - lldb::UnwindPlanSP m_unwind_plan_sp; -}; - -class ArchDefaultUnwindPlan_i386 : public lldb_private::ArchDefaultUnwindPlan -{ -public: - - ~ArchDefaultUnwindPlan_i386 () { } - - virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); - - static lldb_private::ArchDefaultUnwindPlan * - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - ArchDefaultUnwindPlan_i386(); // Call CreateInstance instead. - - lldb::UnwindPlanSP m_unwind_plan_sp; -}; - - -} // namespace lldb_private - -#endif // liblldb_UnwindAssemblyProfiler_x86_h_ Removed: lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp?rev=130153&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp (original) +++ lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.cpp (removed) @@ -1,150 +0,0 @@ -//===-- ArchVolatileRegs-x86.cpp --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ArchVolatileRegs-x86.h" - -#include - -#include "llvm/Support/MachO.h" - -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Target/ArchVolatileRegs.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/RegisterContext.h" - - -using namespace lldb; -using namespace lldb_private; - -bool -ArchVolatileRegs_x86::RegisterIsVolatile (Thread& thread, uint32_t regnum) -{ - initialize_regset (thread); - if (m_non_volatile_regs.find (regnum) == m_non_volatile_regs.end()) - return true; - else - return false; -} - -lldb_private::ArchVolatileRegs * -ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch) -{ - llvm::Triple::ArchType cpu = arch.GetMachine (); - if (cpu == llvm::Triple::x86 || cpu == llvm::Triple::x86_64) - return new ArchVolatileRegs_x86 (cpu); - return NULL; -} - -ArchVolatileRegs_x86::ArchVolatileRegs_x86(llvm::Triple::ArchType cpu) : - lldb_private::ArchVolatileRegs(), - m_cpu(cpu), - m_non_volatile_regs() -{ -} - -void -ArchVolatileRegs_x86::initialize_regset(Thread& thread) -{ - if (m_non_volatile_regs.size() > 0) - return; - - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - const RegisterInfo *ri; - - const char *x86_64_regnames[] = { "rbx", - "rsp", - "rbp", - "r12", - "r13", - "r14", - "r15", - "rip" }; - - const char *i386_regnames[] = { "ebx", - "ebp", - "esi", - "edi", - "esp", - "eip" }; - - - const char **names; - int namecount; - if (m_cpu == llvm::Triple::x86_64) - { - names = x86_64_regnames; - namecount = sizeof (x86_64_regnames) / sizeof (char *); - } - else - { - assert (m_cpu == llvm::Triple::x86); - names = i386_regnames; - namecount = sizeof (i386_regnames) / sizeof (char *); - } - - for (int i = 0; i < namecount; i++) - { - ri = reg_ctx->GetRegisterInfoByName (names[i]); - if (ri) - m_non_volatile_regs.insert (ri->kinds[eRegisterKindLLDB]); - } -} - - -//------------------------------------------------------------------ -// PluginInterface protocol in ArchVolatileRegs_x86 -//------------------------------------------------------------------ - -const char * -ArchVolatileRegs_x86::GetPluginName() -{ - return "ArchVolatileRegs_x86"; -} - -const char * -ArchVolatileRegs_x86::GetShortPluginName() -{ - return "archvolatileregs.x86"; -} - - -uint32_t -ArchVolatileRegs_x86::GetPluginVersion() -{ - return 1; -} - -void -ArchVolatileRegs_x86::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -ArchVolatileRegs_x86::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -ArchVolatileRegs_x86::GetPluginNameStatic() -{ - return "ArchVolatileRegs_x86"; -} - -const char * -ArchVolatileRegs_x86::GetPluginDescriptionStatic() -{ - return "i386 and x86_64 architecture volatile register information."; -} Removed: lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h?rev=130153&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h (original) +++ lldb/trunk/source/Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h (removed) @@ -1,68 +0,0 @@ -//===-- ArchVolatileRegs-x86.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_ArchVolatileRegs_x86_h_ -#define liblldb_ArchVolatileRegs_x86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Target/ArchVolatileRegs.h" -#include - -namespace lldb_private { - -class ArchVolatileRegs_x86 : public lldb_private::ArchVolatileRegs -{ -public: - - ~ArchVolatileRegs_x86 () { } - - bool - RegisterIsVolatile (lldb_private::Thread& thread, uint32_t regnum); - - static lldb_private::ArchVolatileRegs * - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - ArchVolatileRegs_x86(llvm::Triple::ArchType cpu); // Call CreateInstance instead. - - void initialize_regset(lldb_private::Thread& thread); - - llvm::Triple::ArchType m_cpu; - std::set m_non_volatile_regs; -}; - - -} // namespace lldb_private - -#endif // liblldb_ArchVolatileRegs_x86_h_ Added: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=130154&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (added) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Mon Apr 25 16:05:07 2011 @@ -0,0 +1,108 @@ +//===-- UnwindAssemblyInstEmulation.cpp --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "UnwindAssemblyInstEmulation.h" + +#include "llvm-c/EnhancedDisassembly.h" + +#include "lldb/Core/Address.h" +#include "lldb/Core/Error.h" +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/UnwindAssemblyProfiler.h" + +using namespace lldb; +using namespace lldb_private; + + + +//----------------------------------------------------------------------------------------------- +// UnwindAssemblyParser_x86 method definitions +//----------------------------------------------------------------------------------------------- + +bool +UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) +{ + return false; +} + +bool +UnwindAssemblyInstEmulation::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) +{ + return false; +} + +bool +UnwindAssemblyInstEmulation::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) +{ + return false; +} + +UnwindAssemblyProfiler * +UnwindAssemblyInstEmulation::CreateInstance (const ArchSpec &arch) +{ + return NULL; +} + + +//------------------------------------------------------------------ +// PluginInterface protocol in UnwindAssemblyParser_x86 +//------------------------------------------------------------------ + +const char * +UnwindAssemblyInstEmulation::GetPluginName() +{ + return "UnwindAssemblyInstEmulation"; +} + +const char * +UnwindAssemblyInstEmulation::GetShortPluginName() +{ + return "unwindassembly.inst-emulation"; +} + + +uint32_t +UnwindAssemblyInstEmulation::GetPluginVersion() +{ + return 1; +} + +void +UnwindAssemblyInstEmulation::Initialize() +{ + PluginManager::RegisterPlugin (GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); +} + +void +UnwindAssemblyInstEmulation::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + + +const char * +UnwindAssemblyInstEmulation::GetPluginNameStatic() +{ + return "UnwindAssemblyInstEmulation"; +} + +const char * +UnwindAssemblyInstEmulation::GetPluginDescriptionStatic() +{ + return "Instruction emulation based unwind information."; +} Added: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=130154&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (added) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Mon Apr 25 16:05:07 2011 @@ -0,0 +1,82 @@ +//===-- UnwindAssemblyInstEmulation.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_UnwindAssemblyInstEmulation_h_ +#define liblldb_UnwindAssemblyInstEmulation_h_ + +#include "lldb/lldb-private.h" +#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/Thread.h" + +class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssemblyProfiler +{ +public: + + virtual + ~UnwindAssemblyInstEmulation () + { + } + + virtual bool + GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func, + lldb_private::Thread& thread, + lldb_private::UnwindPlan& unwind_plan); + + virtual bool + GetFastUnwindPlan (lldb_private::AddressRange& func, + lldb_private::Thread& thread, + lldb_private::UnwindPlan &unwind_plan); + + // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). + virtual bool + FirstNonPrologueInsn (lldb_private::AddressRange& func, + lldb_private::Target& target, + lldb_private::Thread* thread, + lldb_private::Address& first_non_prologue_insn); + + static lldb_private::UnwindAssemblyProfiler * + CreateInstance (const lldb_private::ArchSpec &arch); + + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + +private: + + // Call CreateInstance to get an instance of this class + UnwindAssemblyInstEmulation(int cpu) : + lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) + { + } + + int m_cpu; +}; + +#endif // liblldb_UnwindAssemblyInstEmulation_h_ Removed: lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp?rev=130153&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp (removed) @@ -1,902 +0,0 @@ -//===-- UnwindAssemblyProfiler-x86.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "UnwindAssemblyProfiler-x86.h" - -#include "llvm-c/EnhancedDisassembly.h" - -#include "lldb/Core/Address.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" - -using namespace lldb; -using namespace lldb_private; - -enum CPU { - k_i386, - k_x86_64 -}; - -enum i386_register_numbers { - k_machine_eax = 0, - k_machine_ecx = 1, - k_machine_edx = 2, - k_machine_ebx = 3, - k_machine_esp = 4, - k_machine_ebp = 5, - k_machine_esi = 6, - k_machine_edi = 7, - k_machine_eip = 8 -}; - -enum x86_64_register_numbers { - k_machine_rax = 0, - k_machine_rcx = 1, - k_machine_rdx = 2, - k_machine_rbx = 3, - k_machine_rsp = 4, - k_machine_rbp = 5, - k_machine_rsi = 6, - k_machine_rdi = 7, - k_machine_r8 = 8, - k_machine_r9 = 9, - k_machine_r10 = 10, - k_machine_r11 = 11, - k_machine_r12 = 12, - k_machine_r13 = 13, - k_machine_r14 = 14, - k_machine_r15 = 15, - k_machine_rip = 16 -}; - -struct regmap_ent { - const char *name; - int machine_regno; - int lldb_regno; -}; - -static struct regmap_ent i386_register_map[] = { - {"eax", k_machine_eax, -1}, - {"ecx", k_machine_ecx, -1}, - {"edx", k_machine_edx, -1}, - {"ebx", k_machine_ebx, -1}, - {"esp", k_machine_esp, -1}, - {"ebp", k_machine_ebp, -1}, - {"esi", k_machine_esi, -1}, - {"edi", k_machine_edi, -1}, - {"eip", k_machine_eip, -1} -}; - -const int size_of_i386_register_map = sizeof (i386_register_map) / sizeof (struct regmap_ent); - -static int i386_register_map_initialized = 0; - -static struct regmap_ent x86_64_register_map[] = { - {"rax", k_machine_rax, -1}, - {"rcx", k_machine_rcx, -1}, - {"rdx", k_machine_rdx, -1}, - {"rbx", k_machine_rbx, -1}, - {"rsp", k_machine_rsp, -1}, - {"rbp", k_machine_rbp, -1}, - {"rsi", k_machine_rsi, -1}, - {"rdi", k_machine_rdi, -1}, - {"r8", k_machine_r8, -1}, - {"r9", k_machine_r9, -1}, - {"r10", k_machine_r10, -1}, - {"r11", k_machine_r11, -1}, - {"r12", k_machine_r12, -1}, - {"r13", k_machine_r13, -1}, - {"r14", k_machine_r14, -1}, - {"r15", k_machine_r15, -1}, - {"rip", k_machine_rip, -1} -}; - -const int size_of_x86_64_register_map = sizeof (x86_64_register_map) / sizeof (struct regmap_ent); - -static int x86_64_register_map_initialized = 0; - -//----------------------------------------------------------------------------------------------- -// AssemblyParse_x86 local-file class definition & implementation functions -//----------------------------------------------------------------------------------------------- - -class AssemblyParse_x86 { -public: - - AssemblyParse_x86 (Target &target, Thread *thread, int cpu, AddressRange func); - - bool get_non_call_site_unwind_plan (UnwindPlan &unwind_plan); - - bool get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_plan); - - bool find_first_non_prologue_insn (Address &address); - -private: - enum { kMaxInstructionByteSize = 32 }; - - bool nonvolatile_reg_p (int machine_regno); - bool push_rbp_pattern_p (); - bool push_0_pattern_p (); - bool mov_rsp_rbp_pattern_p (); - bool sub_rsp_pattern_p (int& amount); - bool push_reg_p (int& regno); - bool mov_reg_to_local_stack_frame_p (int& regno, int& fp_offset); - bool ret_pattern_p (); - uint32_t extract_4 (uint8_t *b); - bool machine_regno_to_lldb_regno (int machine_regno, uint32_t& lldb_regno); - bool instruction_length (Address addr, int &length); - - Target &m_target; - Thread* m_thread; - - AddressRange m_func_bounds; - - Address m_cur_insn; - uint8_t m_cur_insn_bytes[kMaxInstructionByteSize]; - - int m_machine_ip_regnum; - int m_machine_sp_regnum; - int m_machine_fp_regnum; - - int m_lldb_ip_regnum; - int m_lldb_sp_regnum; - int m_lldb_fp_regnum; - - int m_wordsize; - int m_cpu; - - DISALLOW_COPY_AND_ASSIGN (AssemblyParse_x86); -}; - -AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : - m_target (target), m_thread (thread), m_func_bounds(func), m_cur_insn (), - m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1), - m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1), - m_wordsize (-1), m_cpu(cpu) -{ - int *initialized_flag = NULL; - m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; - if (cpu == k_i386) - { - m_machine_ip_regnum = k_machine_eip; - m_machine_sp_regnum = k_machine_esp; - m_machine_fp_regnum = k_machine_ebp; - m_wordsize = 4; - initialized_flag = &i386_register_map_initialized; - } - else - { - m_machine_ip_regnum = k_machine_rip; - m_machine_sp_regnum = k_machine_rsp; - m_machine_fp_regnum = k_machine_rbp; - m_wordsize = 8; - initialized_flag = &x86_64_register_map_initialized; - } - - // we only look at prologue - it will be complete earlier than 512 bytes into func - if (m_func_bounds.GetByteSize() == 0) - m_func_bounds.SetByteSize(512); - - if (m_thread && *initialized_flag == 0) - { - RegisterContext *reg_ctx = m_thread->GetRegisterContext().get(); - if (reg_ctx) - { - struct regmap_ent *ent; - int count, i; - if (cpu == k_i386) - { - ent = i386_register_map; - count = size_of_i386_register_map; - } - else - { - ent = x86_64_register_map; - count = size_of_x86_64_register_map; - } - for (i = 0; i < count; i++, ent++) - { - const RegisterInfo *ri = reg_ctx->GetRegisterInfoByName (ent->name); - if (ri) - ent->lldb_regno = ri->kinds[eRegisterKindLLDB]; - } - *initialized_flag = 1; - } - } - - // on initial construction we may not have a Thread so these have to remain - // uninitialized until we can get a RegisterContext to set up the register map table - if (*initialized_flag == 1) - { - uint32_t lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_sp_regnum, lldb_regno)) - m_lldb_sp_regnum = lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_fp_regnum, lldb_regno)) - m_lldb_fp_regnum = lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_ip_regnum, lldb_regno)) - m_lldb_ip_regnum = lldb_regno; - } -} - - -// This function expects an x86 native register number (i.e. the bits stripped out of the -// actual instruction), not an lldb register number. - -bool -AssemblyParse_x86::nonvolatile_reg_p (int machine_regno) -{ - if (m_cpu == k_i386) - { - switch (machine_regno) { - case k_machine_ebx: - case k_machine_ebp: // not actually a nonvolatile but often treated as such by convention - case k_machine_esi: - case k_machine_edi: - case k_machine_esp: - return true; - default: - return false; - } - } - if (m_cpu == k_x86_64) - { - switch (machine_regno) { - case k_machine_rbx: - case k_machine_rsp: - case k_machine_rbp: // not actually a nonvolatile but often treated as such by convention - case k_machine_r12: - case k_machine_r13: - case k_machine_r14: - case k_machine_r15: - return true; - default: - return false; - } - } - return false; -} - - -// Macro to detect if this is a REX mode prefix byte. -#define REX_W_PREFIX_P(opcode) (((opcode) & (~0x5)) == 0x48) - -// The high bit which should be added to the source register number (the "R" bit) -#define REX_W_SRCREG(opcode) (((opcode) & 0x4) >> 2) - -// The high bit which should be added to the destination register number (the "B" bit) -#define REX_W_DSTREG(opcode) ((opcode) & 0x1) - -// pushq %rbp [0x55] -bool AssemblyParse_x86::push_rbp_pattern_p () { - uint8_t *p = m_cur_insn_bytes; - if (*p == 0x55) - return true; - return false; -} - -// pushq $0 ; the first instruction in start() [0x6a 0x00] -bool AssemblyParse_x86::push_0_pattern_p () -{ - uint8_t *p = m_cur_insn_bytes; - if (*p == 0x6a && *(p + 1) == 0x0) - return true; - return false; -} - -// movq %rsp, %rbp [0x48 0x8b 0xec] or [0x48 0x89 0xe5] -// movl %esp, %ebp [0x8b 0xec] or [0x89 0xe5] -bool AssemblyParse_x86::mov_rsp_rbp_pattern_p () { - uint8_t *p = m_cur_insn_bytes; - if (m_wordsize == 8 && *p == 0x48) - p++; - if (*(p) == 0x8b && *(p + 1) == 0xec) - return true; - if (*(p) == 0x89 && *(p + 1) == 0xe5) - return true; - return false; -} - -// subq $0x20, %rsp -bool AssemblyParse_x86::sub_rsp_pattern_p (int& amount) { - uint8_t *p = m_cur_insn_bytes; - if (m_wordsize == 8 && *p == 0x48) - p++; - // 8-bit immediate operand - if (*p == 0x83 && *(p + 1) == 0xec) { - amount = (int8_t) *(p + 2); - return true; - } - // 32-bit immediate operand - if (*p == 0x81 && *(p + 1) == 0xec) { - amount = (int32_t) extract_4 (p + 2); - return true; - } - // Not handled: [0x83 0xc4] for imm8 with neg values - // [0x81 0xc4] for imm32 with neg values - return false; -} - -// pushq %rbx -// pushl $ebx -bool AssemblyParse_x86::push_reg_p (int& regno) { - uint8_t *p = m_cur_insn_bytes; - int regno_prefix_bit = 0; - // If we have a rex prefix byte, check to see if a B bit is set - if (m_wordsize == 8 && *p == 0x41) { - regno_prefix_bit = 1 << 3; - p++; - } - if (*p >= 0x50 && *p <= 0x57) { - regno = (*p - 0x50) | regno_prefix_bit; - return true; - } - return false; -} - -// Look for an instruction sequence storing a nonvolatile register -// on to the stack frame. - -// movq %rax, -0x10(%rbp) [0x48 0x89 0x45 0xf0] -// movl %eax, -0xc(%ebp) [0x89 0x45 0xf4] -bool AssemblyParse_x86::mov_reg_to_local_stack_frame_p (int& regno, int& rbp_offset) { - uint8_t *p = m_cur_insn_bytes; - int src_reg_prefix_bit = 0; - int target_reg_prefix_bit = 0; - - if (m_wordsize == 8 && REX_W_PREFIX_P (*p)) { - src_reg_prefix_bit = REX_W_SRCREG (*p) << 3; - target_reg_prefix_bit = REX_W_DSTREG (*p) << 3; - if (target_reg_prefix_bit == 1) { - // rbp/ebp don't need a prefix bit - we know this isn't the - // reg we care about. - return false; - } - p++; - } - - if (*p == 0x89) { - /* Mask off the 3-5 bits which indicate the destination register - if this is a ModR/M byte. */ - int opcode_destreg_masked_out = *(p + 1) & (~0x38); - - /* Is this a ModR/M byte with Mod bits 01 and R/M bits 101 - and three bits between them, e.g. 01nnn101 - We're looking for a destination of ebp-disp8 or ebp-disp32. */ - int immsize; - if (opcode_destreg_masked_out == 0x45) - immsize = 2; - else if (opcode_destreg_masked_out == 0x85) - immsize = 4; - else - return false; - - int offset = 0; - if (immsize == 2) - offset = (int8_t) *(p + 2); - if (immsize == 4) - offset = (uint32_t) extract_4 (p + 2); - if (offset > 0) - return false; - - regno = ((*(p + 1) >> 3) & 0x7) | src_reg_prefix_bit; - rbp_offset = offset > 0 ? offset : -offset; - return true; - } - return false; -} - -// ret [0xc9] or [0xc2 imm8] or [0xca imm8] -bool -AssemblyParse_x86::ret_pattern_p () -{ - uint8_t *p = m_cur_insn_bytes; - if (*p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3) - return true; - return false; -} - -uint32_t -AssemblyParse_x86::extract_4 (uint8_t *b) -{ - uint32_t v = 0; - for (int i = 3; i >= 0; i--) - v = (v << 8) | b[i]; - return v; -} - -bool -AssemblyParse_x86::machine_regno_to_lldb_regno (int machine_regno, uint32_t &lldb_regno) -{ - struct regmap_ent *ent; - int count, i; - if (m_cpu == k_i386) - { - ent = i386_register_map; - count = size_of_i386_register_map; - } - else - { - ent = x86_64_register_map; - count = size_of_x86_64_register_map; - } - for (i = 0; i < count; i++, ent++) - { - if (ent->machine_regno == machine_regno) - if (ent->lldb_regno != -1) - { - lldb_regno = ent->lldb_regno; - return true; - } - } - return false; -} - -struct edis_byte_read_token -{ - Address *address; - Target *target; -}; - - -static int -read_byte_for_edis (uint8_t *buf, uint64_t offset_address, void *arg) -{ - if (arg == 0) - return -1; - struct edis_byte_read_token *tok = (edis_byte_read_token *) arg; - Address *base_address = tok->address; - Target *target = tok->target; - - Address read_addr = *base_address; - read_addr.SetOffset (offset_address); - - uint8_t onebyte_buf[1]; - Error error; - const bool prefer_file_cache = true; - if (target->ReadMemory (read_addr, prefer_file_cache, onebyte_buf, 1, error) != -1) - { - *buf = onebyte_buf[0]; - return 0; - } - return -1; -} - - -bool -AssemblyParse_x86::instruction_length (Address addr, int &length) -{ - const char *triple; - - if (!addr.IsValid()) - return false; - - // FIXME should probably pass down the ArchSpec and work from that to make a portable triple - if (m_cpu == k_i386) - triple = "i386-unknown-unknown"; - else - triple = "x86_64-unknown-unknown"; - - EDDisassemblerRef disasm; - EDInstRef cur_insn; - - if (EDGetDisassembler (&disasm, triple, kEDAssemblySyntaxX86ATT) != 0) - { - return false; - } - - uint64_t addr_offset = addr.GetOffset(); - struct edis_byte_read_token arg; - arg.address = &addr; - arg.target = &m_target; - if (EDCreateInsts (&cur_insn, 1, disasm, read_byte_for_edis, addr_offset, &arg) != 1) - { - return false; - } - length = EDInstByteSize (cur_insn); - EDReleaseInst (cur_insn); - return true; -} - - -bool -AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) -{ - UnwindPlan::Row row; - int non_prologue_insn_count = 0; - m_cur_insn = m_func_bounds.GetBaseAddress (); - int current_func_text_offset = 0; - int current_sp_bytes_offset_from_cfa = 0; - UnwindPlan::Row::RegisterLocation initial_regloc; - Error error; - - if (!m_cur_insn.IsValid()) - { - return false; - } - - unwind_plan.SetPlanValidAddressRange (m_func_bounds); - unwind_plan.SetRegisterKind (eRegisterKindLLDB); - - // At the start of the function, find the CFA by adding wordsize to the SP register - row.SetOffset (current_func_text_offset); - row.SetCFARegister (m_lldb_sp_regnum); - row.SetCFAOffset (m_wordsize); - - // caller's stack pointer value before the call insn is the CFA address - initial_regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, initial_regloc); - - // saved instruction pointer can be found at CFA - wordsize. - current_sp_bytes_offset_from_cfa = m_wordsize; - initial_regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (m_lldb_ip_regnum, initial_regloc); - - unwind_plan.AppendRow (row); - const bool prefer_file_cache = true; - - while (m_func_bounds.ContainsFileAddress (m_cur_insn) && non_prologue_insn_count < 10) - { - int stack_offset, insn_len; - int machine_regno; // register numbers masked directly out of instructions - uint32_t lldb_regno; // register numbers in lldb's eRegisterKindLLDB numbering scheme - - if (!instruction_length (m_cur_insn, insn_len) || insn_len == 0 || insn_len > kMaxInstructionByteSize) - { - // An unrecognized/junk instruction - break; - } - if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1) - { - // Error reading the instruction out of the file, stop scanning - break; - } - - if (push_rbp_pattern_p ()) - { - row.SetOffset (current_func_text_offset + insn_len); - current_sp_bytes_offset_from_cfa += m_wordsize; - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); - row.SetRegisterInfo (m_lldb_fp_regnum, regloc); - unwind_plan.AppendRow (row); - goto loopnext; - } - - if (mov_rsp_rbp_pattern_p ()) - { - row.SetOffset (current_func_text_offset + insn_len); - row.SetCFARegister (m_lldb_fp_regnum); - unwind_plan.AppendRow (row); - goto loopnext; - } - - // This is the start() function (or a pthread equivalent), it starts with a pushl $0x0 which puts the - // saved pc value of 0 on the stack. In this case we want to pretend we didn't see a stack movement at all -- - // normally the saved pc value is already on the stack by the time the function starts executing. - if (push_0_pattern_p ()) - { - goto loopnext; - } - - if (push_reg_p (machine_regno)) - { - current_sp_bytes_offset_from_cfa += m_wordsize; - if (nonvolatile_reg_p (machine_regno) && machine_regno_to_lldb_regno (machine_regno, lldb_regno)) - { - row.SetOffset (current_func_text_offset + insn_len); - if (row.GetCFARegister() == m_lldb_sp_regnum) - { - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - } - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (lldb_regno, regloc); - unwind_plan.AppendRow (row); - } - goto loopnext; - } - - if (mov_reg_to_local_stack_frame_p (machine_regno, stack_offset) && nonvolatile_reg_p (machine_regno)) - { - if (machine_regno_to_lldb_regno (machine_regno, lldb_regno)) - { - row.SetOffset (current_func_text_offset + insn_len); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); - row.SetRegisterInfo (lldb_regno, regloc); - unwind_plan.AppendRow (row); - goto loopnext; - } - } - - if (sub_rsp_pattern_p (stack_offset)) - { - current_sp_bytes_offset_from_cfa += stack_offset; - if (row.GetCFARegister() == m_lldb_sp_regnum) - { - row.SetOffset (current_func_text_offset + insn_len); - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - unwind_plan.AppendRow (row); - } - goto loopnext; - } - - if (ret_pattern_p ()) - { - // we know where the end of the function is; set the limit on the PlanValidAddressRange - // in case our initial "high pc" value was overly large - // int original_size = m_func_bounds.GetByteSize(); - // int calculated_size = m_cur_insn.GetOffset() - m_func_bounds.GetBaseAddress().GetOffset() + insn_len + 1; - // m_func_bounds.SetByteSize (calculated_size); - // unwind_plan.SetPlanValidAddressRange (m_func_bounds); - break; - } - - // FIXME recognize the i386 picbase setup instruction sequence, - // 0x1f16: call 0x1f1b ; main + 11 at /private/tmp/a.c:3 - // 0x1f1b: popl %eax - // and record the temporary stack movements if the CFA is not expressed in terms of ebp. - - non_prologue_insn_count++; -loopnext: - m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); - current_func_text_offset += insn_len; - } - - // Now look at the byte at the end of the AddressRange for a limited attempt at describing the - // epilogue. If this function is built -fomit-frame-pointer (so the CFA is defined in terms of the - // stack pointer) we'd need to profile every instruction which causes rsp to change to backtrace - // all the time. But assuming the CFA is in terms of rbp most of the time, this one additional Row - // will be sufficient. - - if (m_func_bounds.GetByteSize() > 2) - { - Address last_insn (m_func_bounds.GetBaseAddress()); - last_insn.SetOffset (last_insn.GetOffset() + m_func_bounds.GetByteSize() - 1); - uint8_t bytebuf[1]; - if (m_target.ReadMemory (last_insn, prefer_file_cache, bytebuf, 1, error) != -1) - { - if (bytebuf[0] == 0xc3) // ret aka retq - { - // Create a fresh, empty Row and RegisterLocation - don't mention any other registers - UnwindPlan::Row epi_row; - UnwindPlan::Row::RegisterLocation epi_regloc; - - // When the ret instruction is about to be executed, here's our state - epi_row.SetOffset (m_func_bounds.GetByteSize() - 1); - epi_row.SetCFARegister (m_lldb_sp_regnum); - epi_row.SetCFAOffset (m_wordsize); - - // caller's stack pointer value before the call insn is the CFA address - epi_regloc.SetIsCFAPlusOffset (0); - epi_row.SetRegisterInfo (m_lldb_sp_regnum, epi_regloc); - - // saved instruction pointer can be found at CFA - wordsize - epi_regloc.SetAtCFAPlusOffset (-m_wordsize); - epi_row.SetRegisterInfo (m_lldb_ip_regnum, epi_regloc); - - unwind_plan.AppendRow (epi_row); - } - } - } - - unwind_plan.SetSourceName ("assembly insn profiling"); - - return true; -} - -/* The "fast unwind plan" is valid for functions that follow the usual convention of - using the frame pointer register (ebp, rbp), i.e. the function prologue looks like - push %rbp [0x55] - mov %rsp,%rbp [0x48 0x89 0xe5] (this is a 2-byte insn seq on i386) -*/ - -bool -AssemblyParse_x86::get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_plan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation pc_reginfo; - UnwindPlan::Row::RegisterLocation sp_reginfo; - UnwindPlan::Row::RegisterLocation fp_reginfo; - unwind_plan.SetRegisterKind (eRegisterKindLLDB); - - if (!func.GetBaseAddress().IsValid()) - return false; - - uint8_t bytebuf[4]; - Error error; - const bool prefer_file_cache = true; - if (m_target.ReadMemory (func.GetBaseAddress(), prefer_file_cache, bytebuf, sizeof (bytebuf), error) == -1) - return false; - - uint8_t i386_prologue[] = {0x55, 0x89, 0xe5}; - uint8_t x86_64_prologue[] = {0x55, 0x48, 0x89, 0xe5}; - int prologue_size; - - if (memcmp (bytebuf, i386_prologue, sizeof (i386_prologue)) == 0) - { - prologue_size = sizeof (i386_prologue); - } - else if (memcmp (bytebuf, x86_64_prologue, sizeof (x86_64_prologue)) == 0) - { - prologue_size = sizeof (x86_64_prologue); - } - else - { - return false; - } - - pc_reginfo.SetAtCFAPlusOffset (-m_wordsize); - row.SetRegisterInfo (m_lldb_ip_regnum, pc_reginfo); - - sp_reginfo.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, sp_reginfo); - - // Zero instructions into the function - row.SetCFARegister (m_lldb_sp_regnum); - row.SetCFAOffset (m_wordsize); - row.SetOffset (0); - unwind_plan.AppendRow (row); - - // push %rbp has executed - stack moved, rbp now saved - row.SetCFAOffset (2 * m_wordsize); - fp_reginfo.SetAtCFAPlusOffset (2 * -m_wordsize); - row.SetRegisterInfo (m_lldb_fp_regnum, fp_reginfo); - row.SetOffset (1); - unwind_plan.AppendRow (row); - - // mov %rsp, %rbp has executed - row.SetCFARegister (m_lldb_fp_regnum); - row.SetCFAOffset (2 * m_wordsize); - row.SetOffset (prologue_size); /// 3 or 4 bytes depending on arch - unwind_plan.AppendRow (row); - - unwind_plan.SetPlanValidAddressRange (func); - return true; -} - -bool -AssemblyParse_x86::find_first_non_prologue_insn (Address &address) -{ - m_cur_insn = m_func_bounds.GetBaseAddress (); - if (!m_cur_insn.IsValid()) - { - return false; - } - - const bool prefer_file_cache = true; - while (m_func_bounds.ContainsFileAddress (m_cur_insn)) - { - Error error; - int insn_len, offset, regno; - if (!instruction_length (m_cur_insn, insn_len) || insn_len > kMaxInstructionByteSize || insn_len == 0) - { - // An error parsing the instruction, i.e. probably data/garbage - stop scanning - break; - } - if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1) - { - // Error reading the instruction out of the file, stop scanning - break; - } - - if (push_rbp_pattern_p () || mov_rsp_rbp_pattern_p () || sub_rsp_pattern_p (offset) - || push_reg_p (regno) || mov_reg_to_local_stack_frame_p (regno, offset)) - { - m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); - continue; - } - - // Unknown non-prologue instruction - stop scanning - break; - } - - address = m_cur_insn; - return true; -} - - - - - - -//----------------------------------------------------------------------------------------------- -// UnwindAssemblyParser_x86 method definitions -//----------------------------------------------------------------------------------------------- - -bool -UnwindAssemblyProfiler_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) -{ - AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); - return asm_parse.get_non_call_site_unwind_plan (unwind_plan); -} - -bool -UnwindAssemblyProfiler_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) -{ - AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); - return asm_parse.get_fast_unwind_plan (func, unwind_plan); -} - -bool -UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) -{ - AssemblyParse_x86 asm_parse(target, thread, m_cpu, func); - return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); -} - -UnwindAssemblyProfiler * -UnwindAssemblyProfiler_x86::CreateInstance (const ArchSpec &arch) -{ - const llvm::Triple::ArchType cpu = arch.GetMachine (); - if (cpu == llvm::Triple::x86) - return new UnwindAssemblyProfiler_x86 (k_i386); - else if (cpu == llvm::Triple::x86_64) - return new UnwindAssemblyProfiler_x86 (k_x86_64); - return NULL; -} - - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -UnwindAssemblyProfiler_x86::GetPluginName() -{ - return "UnwindAssemblyProfiler_x86"; -} - -const char * -UnwindAssemblyProfiler_x86::GetShortPluginName() -{ - return "unwindassemblyprofiler.x86"; -} - - -uint32_t -UnwindAssemblyProfiler_x86::GetPluginVersion() -{ - return 1; -} - -void -UnwindAssemblyProfiler_x86::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -UnwindAssemblyProfiler_x86::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -UnwindAssemblyProfiler_x86::GetPluginNameStatic() -{ - return "UnwindAssemblyProfiler_x86"; -} - -const char * -UnwindAssemblyProfiler_x86::GetPluginDescriptionStatic() -{ - return "i386 and x86_64 assembly language profiler plugin."; -} Removed: lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h?rev=130153&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h (removed) @@ -1,73 +0,0 @@ -//===-- UnwindAssemblyProfiler-x86.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_UnwindAssemblyProfiler_x86_h_ -#define liblldb_UnwindAssemblyProfiler_x86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" -#include "lldb/Target/Thread.h" - -namespace lldb_private { - -class UnwindAssemblyProfiler_x86 : public lldb_private::UnwindAssemblyProfiler -{ -public: - - ~UnwindAssemblyProfiler_x86 () { } - - virtual bool - GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, lldb_private::Thread& thread, UnwindPlan& unwind_plan); - - virtual bool - GetFastUnwindPlan (AddressRange& func, lldb_private::Thread& thread, UnwindPlan &unwind_plan); - - // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). - virtual bool - FirstNonPrologueInsn (AddressRange& func, lldb_private::Target& target, lldb_private::Thread* thread, Address& first_non_prologue_insn); - - static lldb_private::UnwindAssemblyProfiler * - CreateInstance (const lldb_private::ArchSpec &arch); - - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - UnwindAssemblyProfiler_x86(int cpu) : - lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) { } // Call CreateInstance instead. - - int m_cpu; -}; - - -} // namespace lldb_private - -#endif // liblldb_UnwindAssemblyProfiler_x86_h_ Copied: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp (from r130146, lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp?p2=lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp&p1=lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp&r1=130146&r2=130154&rev=130154&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp Mon Apr 25 16:05:07 2011 @@ -1,4 +1,4 @@ -//===-- UnwindAssemblyProfiler-x86.cpp --------------------------*- C++ -*-===// +//===-- UnwindAssemblyx86.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "UnwindAssemblyProfiler-x86.h" +#include "UnwindAssemblyx86.h" #include "llvm-c/EnhancedDisassembly.h" @@ -819,34 +819,34 @@ //----------------------------------------------------------------------------------------------- bool -UnwindAssemblyProfiler_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) +UnwindAssembly_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) { AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); return asm_parse.get_non_call_site_unwind_plan (unwind_plan); } bool -UnwindAssemblyProfiler_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) +UnwindAssembly_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) { AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); return asm_parse.get_fast_unwind_plan (func, unwind_plan); } bool -UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) +UnwindAssembly_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) { AssemblyParse_x86 asm_parse(target, thread, m_cpu, func); return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); } UnwindAssemblyProfiler * -UnwindAssemblyProfiler_x86::CreateInstance (const ArchSpec &arch) +UnwindAssembly_x86::CreateInstance (const ArchSpec &arch) { const llvm::Triple::ArchType cpu = arch.GetMachine (); if (cpu == llvm::Triple::x86) - return new UnwindAssemblyProfiler_x86 (k_i386); + return new UnwindAssembly_x86 (k_i386); else if (cpu == llvm::Triple::x86_64) - return new UnwindAssemblyProfiler_x86 (k_x86_64); + return new UnwindAssembly_x86 (k_x86_64); return NULL; } @@ -856,26 +856,26 @@ //------------------------------------------------------------------ const char * -UnwindAssemblyProfiler_x86::GetPluginName() +UnwindAssembly_x86::GetPluginName() { - return "UnwindAssemblyProfiler_x86"; + return "UnwindAssembly_x86"; } const char * -UnwindAssemblyProfiler_x86::GetShortPluginName() +UnwindAssembly_x86::GetShortPluginName() { - return "unwindassemblyprofiler.x86"; + return "unwindassembly.x86"; } uint32_t -UnwindAssemblyProfiler_x86::GetPluginVersion() +UnwindAssembly_x86::GetPluginVersion() { return 1; } void -UnwindAssemblyProfiler_x86::Initialize() +UnwindAssembly_x86::Initialize() { PluginManager::RegisterPlugin (GetPluginNameStatic(), GetPluginDescriptionStatic(), @@ -883,20 +883,20 @@ } void -UnwindAssemblyProfiler_x86::Terminate() +UnwindAssembly_x86::Terminate() { PluginManager::UnregisterPlugin (CreateInstance); } const char * -UnwindAssemblyProfiler_x86::GetPluginNameStatic() +UnwindAssembly_x86::GetPluginNameStatic() { - return "UnwindAssemblyProfiler_x86"; + return "UnwindAssembly_x86"; } const char * -UnwindAssemblyProfiler_x86::GetPluginDescriptionStatic() +UnwindAssembly_x86::GetPluginDescriptionStatic() { return "i386 and x86_64 assembly language profiler plugin."; } Copied: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h (from r130146, lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h?p2=lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h&p1=lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h&r1=130146&r2=130154&rev=130154&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h Mon Apr 25 16:05:07 2011 @@ -1,4 +1,4 @@ -//===-- UnwindAssemblyProfiler-x86.h ----------------------------*- C++ -*-===// +//===-- UnwindAssemblyx86.h -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UnwindAssemblyProfiler_x86_h_ -#define liblldb_UnwindAssemblyProfiler_x86_h_ +#ifndef liblldb_UnwindAssemblyx86_h_ +#define liblldb_UnwindAssemblyx86_h_ #include "lldb/lldb-private.h" #include "lldb/Target/UnwindAssemblyProfiler.h" @@ -16,11 +16,11 @@ namespace lldb_private { -class UnwindAssemblyProfiler_x86 : public lldb_private::UnwindAssemblyProfiler +class UnwindAssembly_x86 : public lldb_private::UnwindAssemblyProfiler { public: - ~UnwindAssemblyProfiler_x86 () { } + ~UnwindAssembly_x86 () { } virtual bool GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, lldb_private::Thread& thread, UnwindPlan& unwind_plan); @@ -61,7 +61,7 @@ GetPluginVersion(); private: - UnwindAssemblyProfiler_x86(int cpu) : + UnwindAssembly_x86(int cpu) : lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) { } // Call CreateInstance instead. int m_cpu; @@ -70,4 +70,4 @@ } // namespace lldb_private -#endif // liblldb_UnwindAssemblyProfiler_x86_h_ +#endif // liblldb_UnwindAssemblyx86_h_ Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=130154&r1=130153&r2=130154&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Apr 25 16:05:07 2011 @@ -30,9 +30,10 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" -#include "Plugins/UnwindAssembly/UnwindAssemblyProfiler-x86.h" -#include "Plugins/ArchDefaultUnwindPlan/ArchDefaultUnwindPlan-x86.h" -#include "Plugins/ArchVolatileRegs/ArchVolatileRegs-x86.h" +#include "Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h" +#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" +#include "Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h" +#include "Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h" #if defined (__APPLE__) #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" @@ -82,7 +83,8 @@ ObjectFileELF::Initialize(); SymbolFileDWARF::Initialize(); SymbolFileSymtab::Initialize(); - UnwindAssemblyProfiler_x86::Initialize(); + UnwindAssembly_x86::Initialize(); + UnwindAssemblyInstEmulation::Initialize(); ArchDefaultUnwindPlan_x86_64::Initialize(); ArchDefaultUnwindPlan_i386::Initialize(); ArchVolatileRegs_x86::Initialize(); @@ -150,7 +152,8 @@ ObjectFileELF::Terminate(); SymbolFileDWARF::Terminate(); SymbolFileSymtab::Terminate(); - UnwindAssemblyProfiler_x86::Terminate(); + UnwindAssembly_x86::Terminate(); + UnwindAssemblyInstEmulation::Terminate(); ArchDefaultUnwindPlan_i386::Terminate(); ArchDefaultUnwindPlan_x86_64::Terminate(); ArchVolatileRegs_x86::Terminate(); From gclayton at apple.com Mon Apr 25 16:07:40 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 25 Apr 2011 21:07:40 -0000 Subject: [Lldb-commits] [lldb] r130155 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h source/lldb.cpp Message-ID: <20110425210741.12B942A6C12D@llvm.org> Author: gclayton Date: Mon Apr 25 16:07:40 2011 New Revision: 130155 URL: http://llvm.org/viewvc/llvm-project?rev=130155&view=rev Log: Even more renaming. Added: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp - copied, changed from r130154, lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h - copied, changed from r130154, lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h Removed: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/lldb.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130155&r1=130154&r2=130155&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Apr 25 16:07:40 2011 @@ -16,6 +16,7 @@ 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */; }; 26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; }; 26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; }; + 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; }; 264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A97BD133918BC0017F0BE /* PlatformRemoteGDBServer.cpp */; }; 264A97C0133918BC0017F0BE /* PlatformRemoteGDBServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 264A97BE133918BC0017F0BE /* PlatformRemoteGDBServer.h */; }; 265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; @@ -364,8 +365,6 @@ 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */; }; - 2692BA1A136611CD00F9E14D /* UnwindAssemblyx86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA18136611CD00F9E14D /* UnwindAssemblyx86.cpp */; }; - 2692BA1B136611CD00F9E14D /* UnwindAssemblyx86.h in Headers */ = {isa = PBXBuildFile; fileRef = 2692BA19136611CD00F9E14D /* UnwindAssemblyx86.h */; }; 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */; }; 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */; }; 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; @@ -644,6 +643,8 @@ 263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; }; 263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; }; 26368A3B126B697600E8659F /* darwin-debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "darwin-debug.cpp"; path = "tools/darwin-debug/darwin-debug.cpp"; sourceTree = ""; }; + 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "UnwindAssembly-x86.cpp"; sourceTree = ""; }; + 263E949E13661AE400E7D1CE /* UnwindAssembly-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UnwindAssembly-x86.h"; sourceTree = ""; }; 263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeSTLMap.h; path = include/lldb/Core/ThreadSafeSTLMap.h; sourceTree = ""; }; 26424E3C125986CB0016D82C /* ValueObjectConstResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectConstResult.cpp; path = source/Core/ValueObjectConstResult.cpp; sourceTree = ""; }; 26424E3E125986D30016D82C /* ValueObjectConstResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResult.h; path = include/lldb/Core/ValueObjectConstResult.h; sourceTree = ""; }; @@ -711,8 +712,6 @@ 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = ""; }; 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnwindAssemblyInstEmulation.cpp; sourceTree = ""; }; 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; }; - 2692BA18136611CD00F9E14D /* UnwindAssemblyx86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnwindAssemblyx86.cpp; sourceTree = ""; }; - 2692BA19136611CD00F9E14D /* UnwindAssemblyx86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyx86.h; sourceTree = ""; }; 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; 2692BA1E136614D000F9E14D /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; @@ -1794,8 +1793,8 @@ 2692BA17136611CD00F9E14D /* x86 */ = { isa = PBXGroup; children = ( - 2692BA18136611CD00F9E14D /* UnwindAssemblyx86.cpp */, - 2692BA19136611CD00F9E14D /* UnwindAssemblyx86.h */, + 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */, + 263E949E13661AE400E7D1CE /* UnwindAssembly-x86.h */, ); path = x86; sourceTree = ""; @@ -2658,7 +2657,6 @@ 4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */, 4C2FAE2F135E3A70001EDE44 /* SharedCluster.h in Headers */, 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */, - 2692BA1B136611CD00F9E14D /* UnwindAssemblyx86.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3230,9 +3228,9 @@ 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */, 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */, 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */, - 2692BA1A136611CD00F9E14D /* UnwindAssemblyx86.cpp in Sources */, 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */, 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */, + 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Copied: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp (from r130154, lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp?p2=lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp&p1=lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp&r1=130154&r2=130155&rev=130155&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Mon Apr 25 16:07:40 2011 @@ -1,4 +1,4 @@ -//===-- UnwindAssemblyx86.cpp -----------------------------------*- C++ -*-===// +//===-- UnwindAssembly-x86.cpp ----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "UnwindAssemblyx86.h" +#include "UnwindAssembly-x86.h" #include "llvm-c/EnhancedDisassembly.h" Copied: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h (from r130154, lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h?p2=lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h&p1=lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h&r1=130154&r2=130155&rev=130155&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h Mon Apr 25 16:07:40 2011 @@ -1,4 +1,4 @@ -//===-- UnwindAssemblyx86.h -------------------------------------*- C++ -*-===// +//===-- UnwindAssembly-x86.h -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UnwindAssemblyx86_h_ -#define liblldb_UnwindAssemblyx86_h_ +#ifndef liblldb_UnwindAssembly_x86_h_ +#define liblldb_UnwindAssembly_x86_h_ #include "lldb/lldb-private.h" #include "lldb/Target/UnwindAssemblyProfiler.h" @@ -70,4 +70,4 @@ } // namespace lldb_private -#endif // liblldb_UnwindAssemblyx86_h_ +#endif // liblldb_UnwindAssembly_x86_h_ Removed: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp?rev=130154&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.cpp (removed) @@ -1,902 +0,0 @@ -//===-- UnwindAssemblyx86.cpp -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "UnwindAssemblyx86.h" - -#include "llvm-c/EnhancedDisassembly.h" - -#include "lldb/Core/Address.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" - -using namespace lldb; -using namespace lldb_private; - -enum CPU { - k_i386, - k_x86_64 -}; - -enum i386_register_numbers { - k_machine_eax = 0, - k_machine_ecx = 1, - k_machine_edx = 2, - k_machine_ebx = 3, - k_machine_esp = 4, - k_machine_ebp = 5, - k_machine_esi = 6, - k_machine_edi = 7, - k_machine_eip = 8 -}; - -enum x86_64_register_numbers { - k_machine_rax = 0, - k_machine_rcx = 1, - k_machine_rdx = 2, - k_machine_rbx = 3, - k_machine_rsp = 4, - k_machine_rbp = 5, - k_machine_rsi = 6, - k_machine_rdi = 7, - k_machine_r8 = 8, - k_machine_r9 = 9, - k_machine_r10 = 10, - k_machine_r11 = 11, - k_machine_r12 = 12, - k_machine_r13 = 13, - k_machine_r14 = 14, - k_machine_r15 = 15, - k_machine_rip = 16 -}; - -struct regmap_ent { - const char *name; - int machine_regno; - int lldb_regno; -}; - -static struct regmap_ent i386_register_map[] = { - {"eax", k_machine_eax, -1}, - {"ecx", k_machine_ecx, -1}, - {"edx", k_machine_edx, -1}, - {"ebx", k_machine_ebx, -1}, - {"esp", k_machine_esp, -1}, - {"ebp", k_machine_ebp, -1}, - {"esi", k_machine_esi, -1}, - {"edi", k_machine_edi, -1}, - {"eip", k_machine_eip, -1} -}; - -const int size_of_i386_register_map = sizeof (i386_register_map) / sizeof (struct regmap_ent); - -static int i386_register_map_initialized = 0; - -static struct regmap_ent x86_64_register_map[] = { - {"rax", k_machine_rax, -1}, - {"rcx", k_machine_rcx, -1}, - {"rdx", k_machine_rdx, -1}, - {"rbx", k_machine_rbx, -1}, - {"rsp", k_machine_rsp, -1}, - {"rbp", k_machine_rbp, -1}, - {"rsi", k_machine_rsi, -1}, - {"rdi", k_machine_rdi, -1}, - {"r8", k_machine_r8, -1}, - {"r9", k_machine_r9, -1}, - {"r10", k_machine_r10, -1}, - {"r11", k_machine_r11, -1}, - {"r12", k_machine_r12, -1}, - {"r13", k_machine_r13, -1}, - {"r14", k_machine_r14, -1}, - {"r15", k_machine_r15, -1}, - {"rip", k_machine_rip, -1} -}; - -const int size_of_x86_64_register_map = sizeof (x86_64_register_map) / sizeof (struct regmap_ent); - -static int x86_64_register_map_initialized = 0; - -//----------------------------------------------------------------------------------------------- -// AssemblyParse_x86 local-file class definition & implementation functions -//----------------------------------------------------------------------------------------------- - -class AssemblyParse_x86 { -public: - - AssemblyParse_x86 (Target &target, Thread *thread, int cpu, AddressRange func); - - bool get_non_call_site_unwind_plan (UnwindPlan &unwind_plan); - - bool get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_plan); - - bool find_first_non_prologue_insn (Address &address); - -private: - enum { kMaxInstructionByteSize = 32 }; - - bool nonvolatile_reg_p (int machine_regno); - bool push_rbp_pattern_p (); - bool push_0_pattern_p (); - bool mov_rsp_rbp_pattern_p (); - bool sub_rsp_pattern_p (int& amount); - bool push_reg_p (int& regno); - bool mov_reg_to_local_stack_frame_p (int& regno, int& fp_offset); - bool ret_pattern_p (); - uint32_t extract_4 (uint8_t *b); - bool machine_regno_to_lldb_regno (int machine_regno, uint32_t& lldb_regno); - bool instruction_length (Address addr, int &length); - - Target &m_target; - Thread* m_thread; - - AddressRange m_func_bounds; - - Address m_cur_insn; - uint8_t m_cur_insn_bytes[kMaxInstructionByteSize]; - - int m_machine_ip_regnum; - int m_machine_sp_regnum; - int m_machine_fp_regnum; - - int m_lldb_ip_regnum; - int m_lldb_sp_regnum; - int m_lldb_fp_regnum; - - int m_wordsize; - int m_cpu; - - DISALLOW_COPY_AND_ASSIGN (AssemblyParse_x86); -}; - -AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : - m_target (target), m_thread (thread), m_func_bounds(func), m_cur_insn (), - m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1), - m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1), - m_wordsize (-1), m_cpu(cpu) -{ - int *initialized_flag = NULL; - m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; - if (cpu == k_i386) - { - m_machine_ip_regnum = k_machine_eip; - m_machine_sp_regnum = k_machine_esp; - m_machine_fp_regnum = k_machine_ebp; - m_wordsize = 4; - initialized_flag = &i386_register_map_initialized; - } - else - { - m_machine_ip_regnum = k_machine_rip; - m_machine_sp_regnum = k_machine_rsp; - m_machine_fp_regnum = k_machine_rbp; - m_wordsize = 8; - initialized_flag = &x86_64_register_map_initialized; - } - - // we only look at prologue - it will be complete earlier than 512 bytes into func - if (m_func_bounds.GetByteSize() == 0) - m_func_bounds.SetByteSize(512); - - if (m_thread && *initialized_flag == 0) - { - RegisterContext *reg_ctx = m_thread->GetRegisterContext().get(); - if (reg_ctx) - { - struct regmap_ent *ent; - int count, i; - if (cpu == k_i386) - { - ent = i386_register_map; - count = size_of_i386_register_map; - } - else - { - ent = x86_64_register_map; - count = size_of_x86_64_register_map; - } - for (i = 0; i < count; i++, ent++) - { - const RegisterInfo *ri = reg_ctx->GetRegisterInfoByName (ent->name); - if (ri) - ent->lldb_regno = ri->kinds[eRegisterKindLLDB]; - } - *initialized_flag = 1; - } - } - - // on initial construction we may not have a Thread so these have to remain - // uninitialized until we can get a RegisterContext to set up the register map table - if (*initialized_flag == 1) - { - uint32_t lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_sp_regnum, lldb_regno)) - m_lldb_sp_regnum = lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_fp_regnum, lldb_regno)) - m_lldb_fp_regnum = lldb_regno; - if (machine_regno_to_lldb_regno (m_machine_ip_regnum, lldb_regno)) - m_lldb_ip_regnum = lldb_regno; - } -} - - -// This function expects an x86 native register number (i.e. the bits stripped out of the -// actual instruction), not an lldb register number. - -bool -AssemblyParse_x86::nonvolatile_reg_p (int machine_regno) -{ - if (m_cpu == k_i386) - { - switch (machine_regno) { - case k_machine_ebx: - case k_machine_ebp: // not actually a nonvolatile but often treated as such by convention - case k_machine_esi: - case k_machine_edi: - case k_machine_esp: - return true; - default: - return false; - } - } - if (m_cpu == k_x86_64) - { - switch (machine_regno) { - case k_machine_rbx: - case k_machine_rsp: - case k_machine_rbp: // not actually a nonvolatile but often treated as such by convention - case k_machine_r12: - case k_machine_r13: - case k_machine_r14: - case k_machine_r15: - return true; - default: - return false; - } - } - return false; -} - - -// Macro to detect if this is a REX mode prefix byte. -#define REX_W_PREFIX_P(opcode) (((opcode) & (~0x5)) == 0x48) - -// The high bit which should be added to the source register number (the "R" bit) -#define REX_W_SRCREG(opcode) (((opcode) & 0x4) >> 2) - -// The high bit which should be added to the destination register number (the "B" bit) -#define REX_W_DSTREG(opcode) ((opcode) & 0x1) - -// pushq %rbp [0x55] -bool AssemblyParse_x86::push_rbp_pattern_p () { - uint8_t *p = m_cur_insn_bytes; - if (*p == 0x55) - return true; - return false; -} - -// pushq $0 ; the first instruction in start() [0x6a 0x00] -bool AssemblyParse_x86::push_0_pattern_p () -{ - uint8_t *p = m_cur_insn_bytes; - if (*p == 0x6a && *(p + 1) == 0x0) - return true; - return false; -} - -// movq %rsp, %rbp [0x48 0x8b 0xec] or [0x48 0x89 0xe5] -// movl %esp, %ebp [0x8b 0xec] or [0x89 0xe5] -bool AssemblyParse_x86::mov_rsp_rbp_pattern_p () { - uint8_t *p = m_cur_insn_bytes; - if (m_wordsize == 8 && *p == 0x48) - p++; - if (*(p) == 0x8b && *(p + 1) == 0xec) - return true; - if (*(p) == 0x89 && *(p + 1) == 0xe5) - return true; - return false; -} - -// subq $0x20, %rsp -bool AssemblyParse_x86::sub_rsp_pattern_p (int& amount) { - uint8_t *p = m_cur_insn_bytes; - if (m_wordsize == 8 && *p == 0x48) - p++; - // 8-bit immediate operand - if (*p == 0x83 && *(p + 1) == 0xec) { - amount = (int8_t) *(p + 2); - return true; - } - // 32-bit immediate operand - if (*p == 0x81 && *(p + 1) == 0xec) { - amount = (int32_t) extract_4 (p + 2); - return true; - } - // Not handled: [0x83 0xc4] for imm8 with neg values - // [0x81 0xc4] for imm32 with neg values - return false; -} - -// pushq %rbx -// pushl $ebx -bool AssemblyParse_x86::push_reg_p (int& regno) { - uint8_t *p = m_cur_insn_bytes; - int regno_prefix_bit = 0; - // If we have a rex prefix byte, check to see if a B bit is set - if (m_wordsize == 8 && *p == 0x41) { - regno_prefix_bit = 1 << 3; - p++; - } - if (*p >= 0x50 && *p <= 0x57) { - regno = (*p - 0x50) | regno_prefix_bit; - return true; - } - return false; -} - -// Look for an instruction sequence storing a nonvolatile register -// on to the stack frame. - -// movq %rax, -0x10(%rbp) [0x48 0x89 0x45 0xf0] -// movl %eax, -0xc(%ebp) [0x89 0x45 0xf4] -bool AssemblyParse_x86::mov_reg_to_local_stack_frame_p (int& regno, int& rbp_offset) { - uint8_t *p = m_cur_insn_bytes; - int src_reg_prefix_bit = 0; - int target_reg_prefix_bit = 0; - - if (m_wordsize == 8 && REX_W_PREFIX_P (*p)) { - src_reg_prefix_bit = REX_W_SRCREG (*p) << 3; - target_reg_prefix_bit = REX_W_DSTREG (*p) << 3; - if (target_reg_prefix_bit == 1) { - // rbp/ebp don't need a prefix bit - we know this isn't the - // reg we care about. - return false; - } - p++; - } - - if (*p == 0x89) { - /* Mask off the 3-5 bits which indicate the destination register - if this is a ModR/M byte. */ - int opcode_destreg_masked_out = *(p + 1) & (~0x38); - - /* Is this a ModR/M byte with Mod bits 01 and R/M bits 101 - and three bits between them, e.g. 01nnn101 - We're looking for a destination of ebp-disp8 or ebp-disp32. */ - int immsize; - if (opcode_destreg_masked_out == 0x45) - immsize = 2; - else if (opcode_destreg_masked_out == 0x85) - immsize = 4; - else - return false; - - int offset = 0; - if (immsize == 2) - offset = (int8_t) *(p + 2); - if (immsize == 4) - offset = (uint32_t) extract_4 (p + 2); - if (offset > 0) - return false; - - regno = ((*(p + 1) >> 3) & 0x7) | src_reg_prefix_bit; - rbp_offset = offset > 0 ? offset : -offset; - return true; - } - return false; -} - -// ret [0xc9] or [0xc2 imm8] or [0xca imm8] -bool -AssemblyParse_x86::ret_pattern_p () -{ - uint8_t *p = m_cur_insn_bytes; - if (*p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3) - return true; - return false; -} - -uint32_t -AssemblyParse_x86::extract_4 (uint8_t *b) -{ - uint32_t v = 0; - for (int i = 3; i >= 0; i--) - v = (v << 8) | b[i]; - return v; -} - -bool -AssemblyParse_x86::machine_regno_to_lldb_regno (int machine_regno, uint32_t &lldb_regno) -{ - struct regmap_ent *ent; - int count, i; - if (m_cpu == k_i386) - { - ent = i386_register_map; - count = size_of_i386_register_map; - } - else - { - ent = x86_64_register_map; - count = size_of_x86_64_register_map; - } - for (i = 0; i < count; i++, ent++) - { - if (ent->machine_regno == machine_regno) - if (ent->lldb_regno != -1) - { - lldb_regno = ent->lldb_regno; - return true; - } - } - return false; -} - -struct edis_byte_read_token -{ - Address *address; - Target *target; -}; - - -static int -read_byte_for_edis (uint8_t *buf, uint64_t offset_address, void *arg) -{ - if (arg == 0) - return -1; - struct edis_byte_read_token *tok = (edis_byte_read_token *) arg; - Address *base_address = tok->address; - Target *target = tok->target; - - Address read_addr = *base_address; - read_addr.SetOffset (offset_address); - - uint8_t onebyte_buf[1]; - Error error; - const bool prefer_file_cache = true; - if (target->ReadMemory (read_addr, prefer_file_cache, onebyte_buf, 1, error) != -1) - { - *buf = onebyte_buf[0]; - return 0; - } - return -1; -} - - -bool -AssemblyParse_x86::instruction_length (Address addr, int &length) -{ - const char *triple; - - if (!addr.IsValid()) - return false; - - // FIXME should probably pass down the ArchSpec and work from that to make a portable triple - if (m_cpu == k_i386) - triple = "i386-unknown-unknown"; - else - triple = "x86_64-unknown-unknown"; - - EDDisassemblerRef disasm; - EDInstRef cur_insn; - - if (EDGetDisassembler (&disasm, triple, kEDAssemblySyntaxX86ATT) != 0) - { - return false; - } - - uint64_t addr_offset = addr.GetOffset(); - struct edis_byte_read_token arg; - arg.address = &addr; - arg.target = &m_target; - if (EDCreateInsts (&cur_insn, 1, disasm, read_byte_for_edis, addr_offset, &arg) != 1) - { - return false; - } - length = EDInstByteSize (cur_insn); - EDReleaseInst (cur_insn); - return true; -} - - -bool -AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) -{ - UnwindPlan::Row row; - int non_prologue_insn_count = 0; - m_cur_insn = m_func_bounds.GetBaseAddress (); - int current_func_text_offset = 0; - int current_sp_bytes_offset_from_cfa = 0; - UnwindPlan::Row::RegisterLocation initial_regloc; - Error error; - - if (!m_cur_insn.IsValid()) - { - return false; - } - - unwind_plan.SetPlanValidAddressRange (m_func_bounds); - unwind_plan.SetRegisterKind (eRegisterKindLLDB); - - // At the start of the function, find the CFA by adding wordsize to the SP register - row.SetOffset (current_func_text_offset); - row.SetCFARegister (m_lldb_sp_regnum); - row.SetCFAOffset (m_wordsize); - - // caller's stack pointer value before the call insn is the CFA address - initial_regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, initial_regloc); - - // saved instruction pointer can be found at CFA - wordsize. - current_sp_bytes_offset_from_cfa = m_wordsize; - initial_regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (m_lldb_ip_regnum, initial_regloc); - - unwind_plan.AppendRow (row); - const bool prefer_file_cache = true; - - while (m_func_bounds.ContainsFileAddress (m_cur_insn) && non_prologue_insn_count < 10) - { - int stack_offset, insn_len; - int machine_regno; // register numbers masked directly out of instructions - uint32_t lldb_regno; // register numbers in lldb's eRegisterKindLLDB numbering scheme - - if (!instruction_length (m_cur_insn, insn_len) || insn_len == 0 || insn_len > kMaxInstructionByteSize) - { - // An unrecognized/junk instruction - break; - } - if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1) - { - // Error reading the instruction out of the file, stop scanning - break; - } - - if (push_rbp_pattern_p ()) - { - row.SetOffset (current_func_text_offset + insn_len); - current_sp_bytes_offset_from_cfa += m_wordsize; - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); - row.SetRegisterInfo (m_lldb_fp_regnum, regloc); - unwind_plan.AppendRow (row); - goto loopnext; - } - - if (mov_rsp_rbp_pattern_p ()) - { - row.SetOffset (current_func_text_offset + insn_len); - row.SetCFARegister (m_lldb_fp_regnum); - unwind_plan.AppendRow (row); - goto loopnext; - } - - // This is the start() function (or a pthread equivalent), it starts with a pushl $0x0 which puts the - // saved pc value of 0 on the stack. In this case we want to pretend we didn't see a stack movement at all -- - // normally the saved pc value is already on the stack by the time the function starts executing. - if (push_0_pattern_p ()) - { - goto loopnext; - } - - if (push_reg_p (machine_regno)) - { - current_sp_bytes_offset_from_cfa += m_wordsize; - if (nonvolatile_reg_p (machine_regno) && machine_regno_to_lldb_regno (machine_regno, lldb_regno)) - { - row.SetOffset (current_func_text_offset + insn_len); - if (row.GetCFARegister() == m_lldb_sp_regnum) - { - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - } - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (lldb_regno, regloc); - unwind_plan.AppendRow (row); - } - goto loopnext; - } - - if (mov_reg_to_local_stack_frame_p (machine_regno, stack_offset) && nonvolatile_reg_p (machine_regno)) - { - if (machine_regno_to_lldb_regno (machine_regno, lldb_regno)) - { - row.SetOffset (current_func_text_offset + insn_len); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); - row.SetRegisterInfo (lldb_regno, regloc); - unwind_plan.AppendRow (row); - goto loopnext; - } - } - - if (sub_rsp_pattern_p (stack_offset)) - { - current_sp_bytes_offset_from_cfa += stack_offset; - if (row.GetCFARegister() == m_lldb_sp_regnum) - { - row.SetOffset (current_func_text_offset + insn_len); - row.SetCFAOffset (current_sp_bytes_offset_from_cfa); - unwind_plan.AppendRow (row); - } - goto loopnext; - } - - if (ret_pattern_p ()) - { - // we know where the end of the function is; set the limit on the PlanValidAddressRange - // in case our initial "high pc" value was overly large - // int original_size = m_func_bounds.GetByteSize(); - // int calculated_size = m_cur_insn.GetOffset() - m_func_bounds.GetBaseAddress().GetOffset() + insn_len + 1; - // m_func_bounds.SetByteSize (calculated_size); - // unwind_plan.SetPlanValidAddressRange (m_func_bounds); - break; - } - - // FIXME recognize the i386 picbase setup instruction sequence, - // 0x1f16: call 0x1f1b ; main + 11 at /private/tmp/a.c:3 - // 0x1f1b: popl %eax - // and record the temporary stack movements if the CFA is not expressed in terms of ebp. - - non_prologue_insn_count++; -loopnext: - m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); - current_func_text_offset += insn_len; - } - - // Now look at the byte at the end of the AddressRange for a limited attempt at describing the - // epilogue. If this function is built -fomit-frame-pointer (so the CFA is defined in terms of the - // stack pointer) we'd need to profile every instruction which causes rsp to change to backtrace - // all the time. But assuming the CFA is in terms of rbp most of the time, this one additional Row - // will be sufficient. - - if (m_func_bounds.GetByteSize() > 2) - { - Address last_insn (m_func_bounds.GetBaseAddress()); - last_insn.SetOffset (last_insn.GetOffset() + m_func_bounds.GetByteSize() - 1); - uint8_t bytebuf[1]; - if (m_target.ReadMemory (last_insn, prefer_file_cache, bytebuf, 1, error) != -1) - { - if (bytebuf[0] == 0xc3) // ret aka retq - { - // Create a fresh, empty Row and RegisterLocation - don't mention any other registers - UnwindPlan::Row epi_row; - UnwindPlan::Row::RegisterLocation epi_regloc; - - // When the ret instruction is about to be executed, here's our state - epi_row.SetOffset (m_func_bounds.GetByteSize() - 1); - epi_row.SetCFARegister (m_lldb_sp_regnum); - epi_row.SetCFAOffset (m_wordsize); - - // caller's stack pointer value before the call insn is the CFA address - epi_regloc.SetIsCFAPlusOffset (0); - epi_row.SetRegisterInfo (m_lldb_sp_regnum, epi_regloc); - - // saved instruction pointer can be found at CFA - wordsize - epi_regloc.SetAtCFAPlusOffset (-m_wordsize); - epi_row.SetRegisterInfo (m_lldb_ip_regnum, epi_regloc); - - unwind_plan.AppendRow (epi_row); - } - } - } - - unwind_plan.SetSourceName ("assembly insn profiling"); - - return true; -} - -/* The "fast unwind plan" is valid for functions that follow the usual convention of - using the frame pointer register (ebp, rbp), i.e. the function prologue looks like - push %rbp [0x55] - mov %rsp,%rbp [0x48 0x89 0xe5] (this is a 2-byte insn seq on i386) -*/ - -bool -AssemblyParse_x86::get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_plan) -{ - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation pc_reginfo; - UnwindPlan::Row::RegisterLocation sp_reginfo; - UnwindPlan::Row::RegisterLocation fp_reginfo; - unwind_plan.SetRegisterKind (eRegisterKindLLDB); - - if (!func.GetBaseAddress().IsValid()) - return false; - - uint8_t bytebuf[4]; - Error error; - const bool prefer_file_cache = true; - if (m_target.ReadMemory (func.GetBaseAddress(), prefer_file_cache, bytebuf, sizeof (bytebuf), error) == -1) - return false; - - uint8_t i386_prologue[] = {0x55, 0x89, 0xe5}; - uint8_t x86_64_prologue[] = {0x55, 0x48, 0x89, 0xe5}; - int prologue_size; - - if (memcmp (bytebuf, i386_prologue, sizeof (i386_prologue)) == 0) - { - prologue_size = sizeof (i386_prologue); - } - else if (memcmp (bytebuf, x86_64_prologue, sizeof (x86_64_prologue)) == 0) - { - prologue_size = sizeof (x86_64_prologue); - } - else - { - return false; - } - - pc_reginfo.SetAtCFAPlusOffset (-m_wordsize); - row.SetRegisterInfo (m_lldb_ip_regnum, pc_reginfo); - - sp_reginfo.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, sp_reginfo); - - // Zero instructions into the function - row.SetCFARegister (m_lldb_sp_regnum); - row.SetCFAOffset (m_wordsize); - row.SetOffset (0); - unwind_plan.AppendRow (row); - - // push %rbp has executed - stack moved, rbp now saved - row.SetCFAOffset (2 * m_wordsize); - fp_reginfo.SetAtCFAPlusOffset (2 * -m_wordsize); - row.SetRegisterInfo (m_lldb_fp_regnum, fp_reginfo); - row.SetOffset (1); - unwind_plan.AppendRow (row); - - // mov %rsp, %rbp has executed - row.SetCFARegister (m_lldb_fp_regnum); - row.SetCFAOffset (2 * m_wordsize); - row.SetOffset (prologue_size); /// 3 or 4 bytes depending on arch - unwind_plan.AppendRow (row); - - unwind_plan.SetPlanValidAddressRange (func); - return true; -} - -bool -AssemblyParse_x86::find_first_non_prologue_insn (Address &address) -{ - m_cur_insn = m_func_bounds.GetBaseAddress (); - if (!m_cur_insn.IsValid()) - { - return false; - } - - const bool prefer_file_cache = true; - while (m_func_bounds.ContainsFileAddress (m_cur_insn)) - { - Error error; - int insn_len, offset, regno; - if (!instruction_length (m_cur_insn, insn_len) || insn_len > kMaxInstructionByteSize || insn_len == 0) - { - // An error parsing the instruction, i.e. probably data/garbage - stop scanning - break; - } - if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1) - { - // Error reading the instruction out of the file, stop scanning - break; - } - - if (push_rbp_pattern_p () || mov_rsp_rbp_pattern_p () || sub_rsp_pattern_p (offset) - || push_reg_p (regno) || mov_reg_to_local_stack_frame_p (regno, offset)) - { - m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); - continue; - } - - // Unknown non-prologue instruction - stop scanning - break; - } - - address = m_cur_insn; - return true; -} - - - - - - -//----------------------------------------------------------------------------------------------- -// UnwindAssemblyParser_x86 method definitions -//----------------------------------------------------------------------------------------------- - -bool -UnwindAssembly_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) -{ - AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); - return asm_parse.get_non_call_site_unwind_plan (unwind_plan); -} - -bool -UnwindAssembly_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) -{ - AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); - return asm_parse.get_fast_unwind_plan (func, unwind_plan); -} - -bool -UnwindAssembly_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) -{ - AssemblyParse_x86 asm_parse(target, thread, m_cpu, func); - return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); -} - -UnwindAssemblyProfiler * -UnwindAssembly_x86::CreateInstance (const ArchSpec &arch) -{ - const llvm::Triple::ArchType cpu = arch.GetMachine (); - if (cpu == llvm::Triple::x86) - return new UnwindAssembly_x86 (k_i386); - else if (cpu == llvm::Triple::x86_64) - return new UnwindAssembly_x86 (k_x86_64); - return NULL; -} - - -//------------------------------------------------------------------ -// PluginInterface protocol in UnwindAssemblyParser_x86 -//------------------------------------------------------------------ - -const char * -UnwindAssembly_x86::GetPluginName() -{ - return "UnwindAssembly_x86"; -} - -const char * -UnwindAssembly_x86::GetShortPluginName() -{ - return "unwindassembly.x86"; -} - - -uint32_t -UnwindAssembly_x86::GetPluginVersion() -{ - return 1; -} - -void -UnwindAssembly_x86::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -UnwindAssembly_x86::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -UnwindAssembly_x86::GetPluginNameStatic() -{ - return "UnwindAssembly_x86"; -} - -const char * -UnwindAssembly_x86::GetPluginDescriptionStatic() -{ - return "i386 and x86_64 assembly language profiler plugin."; -} Removed: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h?rev=130154&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h (removed) @@ -1,73 +0,0 @@ -//===-- UnwindAssemblyx86.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_UnwindAssemblyx86_h_ -#define liblldb_UnwindAssemblyx86_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" -#include "lldb/Target/Thread.h" - -namespace lldb_private { - -class UnwindAssembly_x86 : public lldb_private::UnwindAssemblyProfiler -{ -public: - - ~UnwindAssembly_x86 () { } - - virtual bool - GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, lldb_private::Thread& thread, UnwindPlan& unwind_plan); - - virtual bool - GetFastUnwindPlan (AddressRange& func, lldb_private::Thread& thread, UnwindPlan &unwind_plan); - - // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). - virtual bool - FirstNonPrologueInsn (AddressRange& func, lldb_private::Target& target, lldb_private::Thread* thread, Address& first_non_prologue_insn); - - static lldb_private::UnwindAssemblyProfiler * - CreateInstance (const lldb_private::ArchSpec &arch); - - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -private: - UnwindAssembly_x86(int cpu) : - lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) { } // Call CreateInstance instead. - - int m_cpu; -}; - - -} // namespace lldb_private - -#endif // liblldb_UnwindAssemblyx86_h_ Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=130155&r1=130154&r2=130155&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Apr 25 16:07:40 2011 @@ -30,7 +30,7 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" -#include "Plugins/UnwindAssembly/x86/UnwindAssemblyx86.h" +#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" #include "Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h" #include "Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h" From gclayton at apple.com Mon Apr 25 16:14:26 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 25 Apr 2011 21:14:26 -0000 Subject: [Lldb-commits] [lldb] r130156 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ source/Core/ source/Plugins/ArchDefaultUnwindPlan/x86/ source/Plugins/UnwindAssembly/InstEmulation/ source/Plugins/UnwindAssembly/x86/ source/Symbol/ source/Target/ Message-ID: <20110425211427.0540A2A6C12D@llvm.org> Author: gclayton Date: Mon Apr 25 16:14:26 2011 New Revision: 130156 URL: http://llvm.org/viewvc/llvm-project?rev=130156&view=rev Log: Renamed UnwindAssemblyProfiler to UnwindAssembly along with its source files. Added: lldb/trunk/include/lldb/Target/UnwindAssembly.h - copied, changed from r130146, lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h lldb/trunk/source/Target/UnwindAssembly.cpp - copied, changed from r130146, lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp Removed: lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp Modified: lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Symbol/FuncUnwinders.h lldb/trunk/include/lldb/Symbol/UnwindTable.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h lldb/trunk/source/Symbol/FuncUnwinders.cpp lldb/trunk/source/Symbol/UnwindTable.cpp Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Mon Apr 25 16:14:26 2011 @@ -254,21 +254,21 @@ GetSymbolVendorCreateCallbackForPluginName (const char *name); //------------------------------------------------------------------ - // UnwindAssemblyProfiler + // UnwindAssembly //------------------------------------------------------------------ static bool RegisterPlugin (const char *name, const char *description, - UnwindAssemblyProfilerCreateInstance create_callback); + UnwindAssemblyCreateInstance create_callback); static bool - UnregisterPlugin (UnwindAssemblyProfilerCreateInstance create_callback); + UnregisterPlugin (UnwindAssemblyCreateInstance create_callback); - static UnwindAssemblyProfilerCreateInstance - GetUnwindAssemblyProfilerCreateCallbackAtIndex (uint32_t idx); + static UnwindAssemblyCreateInstance + GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx); - static UnwindAssemblyProfilerCreateInstance - GetUnwindAssemblyProfilerCreateCallbackForPluginName (const char *name); + static UnwindAssemblyCreateInstance + GetUnwindAssemblyCreateCallbackForPluginName (const char *name); //------------------------------------------------------------------ // ArchDefaultUnwindPlan Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original) +++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Mon Apr 25 16:14:26 2011 @@ -34,7 +34,7 @@ // instructions are finished for migrating breakpoints past the // stack frame setup instructions when we don't have line table information. - FuncUnwinders (lldb_private::UnwindTable& unwind_table, lldb_private::UnwindAssemblyProfiler *assembly_profiler, AddressRange range); + FuncUnwinders (lldb_private::UnwindTable& unwind_table, lldb_private::UnwindAssembly *assembly_profiler, AddressRange range); ~FuncUnwinders (); @@ -70,7 +70,7 @@ private: UnwindTable& m_unwind_table; - UnwindAssemblyProfiler *m_assembly_profiler; + UnwindAssembly *m_assembly_profiler; AddressRange m_range; Mutex m_mutex; Modified: lldb/trunk/include/lldb/Symbol/UnwindTable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindTable.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindTable.h (original) +++ lldb/trunk/include/lldb/Symbol/UnwindTable.h Mon Apr 25 16:14:26 2011 @@ -48,7 +48,7 @@ bool m_initialized; // delay some initialization until ObjectFile is set up - UnwindAssemblyProfiler* m_assembly_profiler; + UnwindAssembly* m_assembly_profiler; DWARFCallFrameInfo* m_eh_frame; Copied: lldb/trunk/include/lldb/Target/UnwindAssembly.h (from r130146, lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/UnwindAssembly.h?p2=lldb/trunk/include/lldb/Target/UnwindAssembly.h&p1=lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h&r1=130146&r2=130156&rev=130156&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h (original) +++ lldb/trunk/include/lldb/Target/UnwindAssembly.h Mon Apr 25 16:14:26 2011 @@ -1,4 +1,4 @@ -//===-- UnwindAssemblyProfiler.h --------------------------------*- C++ -*-===// +//===-- UnwindAssembly.h --------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,23 +7,23 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_UnwindAssemblyProfiler_h_ -#define utility_UnwindAssemblyProfiler_h_ +#ifndef utility_UnwindAssembly_h_ +#define utility_UnwindAssembly_h_ #include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { -class UnwindAssemblyProfiler : +class UnwindAssembly : public PluginInterface { public: - static UnwindAssemblyProfiler* + static UnwindAssembly* FindPlugin (const ArchSpec &arch); virtual - ~UnwindAssemblyProfiler(); + ~UnwindAssembly(); virtual bool GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, @@ -43,13 +43,13 @@ Address& first_non_prologue_insn) = 0; protected: - UnwindAssemblyProfiler(); + UnwindAssembly(); private: - DISALLOW_COPY_AND_ASSIGN (UnwindAssemblyProfiler); + DISALLOW_COPY_AND_ASSIGN (UnwindAssembly); }; } // namespace lldb_private -#endif //utility_UnwindAssemblyProfiler_h_ +#endif //utility_UnwindAssembly_h_ Removed: lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h?rev=130155&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h (original) +++ lldb/trunk/include/lldb/Target/UnwindAssemblyProfiler.h (removed) @@ -1,55 +0,0 @@ -//===-- UnwindAssemblyProfiler.h --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_UnwindAssemblyProfiler_h_ -#define utility_UnwindAssemblyProfiler_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginInterface.h" - -namespace lldb_private { - -class UnwindAssemblyProfiler : - public PluginInterface -{ -public: - static UnwindAssemblyProfiler* - FindPlugin (const ArchSpec &arch); - - virtual - ~UnwindAssemblyProfiler(); - - virtual bool - GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, - Thread& thread, - UnwindPlan& unwind_plan) = 0; - - virtual bool - GetFastUnwindPlan (AddressRange& func, - Thread& thread, - UnwindPlan &unwind_plan) = 0; - - // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). - virtual bool - FirstNonPrologueInsn (AddressRange& func, - Target& target, - Thread* thread, - Address& first_non_prologue_insn) = 0; - -protected: - UnwindAssemblyProfiler(); -private: - DISALLOW_COPY_AND_ASSIGN (UnwindAssemblyProfiler); -}; - -} // namespace lldb_private - -#endif //utility_UnwindAssemblyProfiler_h_ - - Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Apr 25 16:14:26 2011 @@ -158,7 +158,7 @@ class TypeList; class UUID; class Unwind; -class UnwindAssemblyProfiler; +class UnwindAssembly; class UnwindPlan; class UnwindTable; class UserSettingsController; Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Mon Apr 25 16:14:26 2011 @@ -31,7 +31,7 @@ typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id, uint32_t type); typedef ThreadPlan * (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, void *baton); - typedef UnwindAssemblyProfiler* (*UnwindAssemblyProfilerCreateInstance) (const ArchSpec &arch); + typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch); typedef ArchDefaultUnwindPlan* (*ArchDefaultUnwindPlanCreateInstance) (const ArchSpec &arch); typedef ArchVolatileRegs* (*ArchVolatileRegsCreateInstance) (const ArchSpec &arch); typedef int (*ComparisonFunction)(const void *, const void *); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Apr 25 16:14:26 2011 @@ -11,7 +11,6 @@ 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; - 2630BFA91365F28C0070C534 /* UnwindAssemblyProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFA81365F28C0070C534 /* UnwindAssemblyProfiler.cpp */; }; 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */; }; 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */; }; 26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; }; @@ -19,6 +18,7 @@ 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; }; 264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A97BD133918BC0017F0BE /* PlatformRemoteGDBServer.cpp */; }; 264A97C0133918BC0017F0BE /* PlatformRemoteGDBServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 264A97BE133918BC0017F0BE /* PlatformRemoteGDBServer.h */; }; + 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */; }; 265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; 26651A16133BF9CD005B64B7 /* Opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A15133BF9CC005B64B7 /* Opcode.h */; }; 26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26651A17133BF9DF005B64B7 /* Opcode.cpp */; }; @@ -634,8 +634,6 @@ 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingPtr.h; path = include/lldb/Utility/SharingPtr.h; sourceTree = ""; }; 26217930133BC8640083B112 /* lldb-private-types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-types.h"; path = "include/lldb/lldb-private-types.h"; sourceTree = ""; }; 26217932133BCB850083B112 /* lldb-private-enumerations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-enumerations.h"; path = "include/lldb/lldb-private-enumerations.h"; sourceTree = ""; }; - 2630BFA81365F28C0070C534 /* UnwindAssemblyProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindAssemblyProfiler.cpp; path = source/Target/UnwindAssemblyProfiler.cpp; sourceTree = ""; }; - 2630BFAA1365F2BA0070C534 /* UnwindAssemblyProfiler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UnwindAssemblyProfiler.h; path = include/lldb/Target/UnwindAssemblyProfiler.h; sourceTree = ""; }; 2630BFAB1365F3140070C534 /* ArchDefaultUnwindPlan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArchDefaultUnwindPlan.h; path = include/lldb/Target/ArchDefaultUnwindPlan.h; sourceTree = ""; }; 2630BFAC1365F3140070C534 /* ArchVolatileRegs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArchVolatileRegs.h; path = include/lldb/Target/ArchVolatileRegs.h; sourceTree = ""; }; 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchDefaultUnwindPlan.cpp; path = source/Target/ArchDefaultUnwindPlan.cpp; sourceTree = ""; }; @@ -657,6 +655,8 @@ 264A97BE133918BC0017F0BE /* PlatformRemoteGDBServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformRemoteGDBServer.h; path = "gdb-server/PlatformRemoteGDBServer.h"; sourceTree = ""; }; 264AD83711095BA600E0B039 /* CommandObjectLog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectLog.cpp; path = source/Commands/CommandObjectLog.cpp; sourceTree = ""; }; 264AD83911095BBD00E0B039 /* CommandObjectLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectLog.h; path = source/Commands/CommandObjectLog.h; sourceTree = ""; }; + 264D8D4E13661BCC003A368F /* UnwindAssembly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UnwindAssembly.h; path = include/lldb/Target/UnwindAssembly.h; sourceTree = ""; }; + 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindAssembly.cpp; path = source/Target/UnwindAssembly.cpp; sourceTree = ""; }; 26579F68126A25920007C5CB /* darwin-debug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "darwin-debug"; sourceTree = BUILT_PRODUCTS_DIR; }; 265ABF6210F42EE900531910 /* DebugSymbols.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DebugSymbols.framework; path = /System/Library/PrivateFrameworks/DebugSymbols.framework; sourceTree = ""; }; 265E9BE1115C2BAA00D0DCCB /* debugserver.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = debugserver.xcodeproj; path = tools/debugserver/debugserver.xcodeproj; sourceTree = ""; }; @@ -2340,8 +2340,8 @@ 4C00986F11500B4300F316B0 /* UnixSignals.h */, 4C00987011500B4300F316B0 /* UnixSignals.cpp */, 26E3EEBD11A9870400FBADB6 /* Unwind.h */, - 2630BFAA1365F2BA0070C534 /* UnwindAssemblyProfiler.h */, - 2630BFA81365F28C0070C534 /* UnwindAssemblyProfiler.cpp */, + 264D8D4E13661BCC003A368F /* UnwindAssembly.h */, + 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */, ); name = Target; sourceTree = ""; @@ -3224,13 +3224,13 @@ 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */, 9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */, 9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */, - 2630BFA91365F28C0070C534 /* UnwindAssemblyProfiler.cpp in Sources */, 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */, 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */, 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */, 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */, 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */, 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */, + 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Mon Apr 25 16:14:26 2011 @@ -1558,11 +1558,11 @@ } -#pragma mark UnwindAssemblyProfiler +#pragma mark UnwindAssembly -struct UnwindAssemblyProfilerInstance +struct UnwindAssemblyInstance { - UnwindAssemblyProfilerInstance() : + UnwindAssemblyInstance() : name(), description(), create_callback(NULL) @@ -1571,22 +1571,22 @@ std::string name; std::string description; - UnwindAssemblyProfilerCreateInstance create_callback; + UnwindAssemblyCreateInstance create_callback; }; -typedef std::vector UnwindAssemblyProfilerInstances; +typedef std::vector UnwindAssemblyInstances; static Mutex & -GetUnwindAssemblyProfilerMutex () +GetUnwindAssemblyMutex () { static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); return g_instances_mutex; } -static UnwindAssemblyProfilerInstances & -GetUnwindAssemblyProfilerInstances () +static UnwindAssemblyInstances & +GetUnwindAssemblyInstances () { - static UnwindAssemblyProfilerInstances g_instances; + static UnwindAssemblyInstances g_instances; return g_instances; } @@ -1595,32 +1595,32 @@ ( const char *name, const char *description, - UnwindAssemblyProfilerCreateInstance create_callback + UnwindAssemblyCreateInstance create_callback ) { if (create_callback) { - UnwindAssemblyProfilerInstance instance; + UnwindAssemblyInstance instance; assert (name && name[0]); instance.name = name; if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); - GetUnwindAssemblyProfilerInstances ().push_back (instance); + Mutex::Locker locker (GetUnwindAssemblyMutex ()); + GetUnwindAssemblyInstances ().push_back (instance); } return false; } bool -PluginManager::UnregisterPlugin (UnwindAssemblyProfilerCreateInstance create_callback) +PluginManager::UnregisterPlugin (UnwindAssemblyCreateInstance create_callback) { if (create_callback) { - Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); - UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances (); + Mutex::Locker locker (GetUnwindAssemblyMutex ()); + UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); - UnwindAssemblyProfilerInstances::iterator pos, end = instances.end(); + UnwindAssemblyInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { if (pos->create_callback == create_callback) @@ -1633,27 +1633,27 @@ return false; } -UnwindAssemblyProfilerCreateInstance -PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex (uint32_t idx) +UnwindAssemblyCreateInstance +PluginManager::GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); - UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances (); + Mutex::Locker locker (GetUnwindAssemblyMutex ()); + UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); if (idx < instances.size()) return instances[idx].create_callback; return NULL; } -UnwindAssemblyProfilerCreateInstance -PluginManager::GetUnwindAssemblyProfilerCreateCallbackForPluginName (const char *name) +UnwindAssemblyCreateInstance +PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name) { if (name && name[0]) { llvm::StringRef name_sref(name); - Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); - UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances (); + Mutex::Locker locker (GetUnwindAssemblyMutex ()); + UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); - UnwindAssemblyProfilerInstances::iterator pos, end = instances.end(); + UnwindAssemblyInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { if (name_sref.equals (pos->name)) Modified: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h Mon Apr 25 16:14:26 2011 @@ -104,4 +104,4 @@ } // namespace lldb_private -#endif // liblldb_UnwindAssemblyProfiler_x86_h_ +#endif // liblldb_UnwindAssembly_x86_h_ Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Mon Apr 25 16:14:26 2011 @@ -21,7 +21,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" using namespace lldb; using namespace lldb_private; @@ -50,7 +50,7 @@ return false; } -UnwindAssemblyProfiler * +UnwindAssembly * UnwindAssemblyInstEmulation::CreateInstance (const ArchSpec &arch) { return NULL; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Mon Apr 25 16:14:26 2011 @@ -11,10 +11,10 @@ #define liblldb_UnwindAssemblyInstEmulation_h_ #include "lldb/lldb-private.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" #include "lldb/Target/Thread.h" -class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssemblyProfiler +class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly { public: @@ -40,7 +40,7 @@ lldb_private::Thread* thread, lldb_private::Address& first_non_prologue_insn); - static lldb_private::UnwindAssemblyProfiler * + static lldb_private::UnwindAssembly * CreateInstance (const lldb_private::ArchSpec &arch); @@ -72,7 +72,7 @@ // Call CreateInstance to get an instance of this class UnwindAssemblyInstEmulation(int cpu) : - lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) + lldb_private::UnwindAssembly(), m_cpu(cpu) { } Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Mon Apr 25 16:14:26 2011 @@ -21,7 +21,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" using namespace lldb; using namespace lldb_private; @@ -839,7 +839,7 @@ return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); } -UnwindAssemblyProfiler * +UnwindAssembly * UnwindAssembly_x86::CreateInstance (const ArchSpec &arch) { const llvm::Triple::ArchType cpu = arch.GetMachine (); Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h Mon Apr 25 16:14:26 2011 @@ -11,12 +11,12 @@ #define liblldb_UnwindAssembly_x86_h_ #include "lldb/lldb-private.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" #include "lldb/Target/Thread.h" namespace lldb_private { -class UnwindAssembly_x86 : public lldb_private::UnwindAssemblyProfiler +class UnwindAssembly_x86 : public lldb_private::UnwindAssembly { public: @@ -32,7 +32,7 @@ virtual bool FirstNonPrologueInsn (AddressRange& func, lldb_private::Target& target, lldb_private::Thread* thread, Address& first_non_prologue_insn); - static lldb_private::UnwindAssemblyProfiler * + static lldb_private::UnwindAssembly * CreateInstance (const lldb_private::ArchSpec &arch); @@ -62,7 +62,7 @@ private: UnwindAssembly_x86(int cpu) : - lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) { } // Call CreateInstance instead. + lldb_private::UnwindAssembly(), m_cpu(cpu) { } // Call CreateInstance instead. int m_cpu; }; Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original) +++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Mon Apr 25 16:14:26 2011 @@ -17,7 +17,7 @@ #include "lldb/Target/ArchDefaultUnwindPlan.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" using namespace lldb; using namespace lldb_private; @@ -26,7 +26,7 @@ FuncUnwinders::FuncUnwinders ( UnwindTable& unwind_table, - UnwindAssemblyProfiler *assembly_profiler, + UnwindAssembly *assembly_profiler, AddressRange range ) : m_unwind_table(unwind_table), Modified: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=130156&r1=130155&r2=130156&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (original) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Mon Apr 25 16:14:26 2011 @@ -17,7 +17,7 @@ #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" // There is one UnwindTable object per ObjectFile. // It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile. @@ -57,7 +57,7 @@ ArchSpec arch; if (m_object_file.GetArchitecture (arch)) { - m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch); + m_assembly_profiler = UnwindAssembly::FindPlugin (arch); m_initialized = true; } } Copied: lldb/trunk/source/Target/UnwindAssembly.cpp (from r130146, lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnwindAssembly.cpp?p2=lldb/trunk/source/Target/UnwindAssembly.cpp&p1=lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp&r1=130146&r2=130156&rev=130156&view=diff ============================================================================== --- lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp (original) +++ lldb/trunk/source/Target/UnwindAssembly.cpp Mon Apr 25 16:14:26 2011 @@ -1,4 +1,4 @@ -//===-- UnwindAssemblyProfiler.cpp ------------------------------*- C++ -*-===// +//===-- UnwindAssembly.cpp ------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,31 +10,31 @@ #include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" +#include "lldb/Target/UnwindAssembly.h" using namespace lldb; using namespace lldb_private; -UnwindAssemblyProfiler* -UnwindAssemblyProfiler::FindPlugin (const ArchSpec &arch) +UnwindAssembly* +UnwindAssembly::FindPlugin (const ArchSpec &arch) { - UnwindAssemblyProfilerCreateInstance create_callback; + UnwindAssemblyCreateInstance create_callback; for (uint32_t idx = 0; - (create_callback = PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex(idx)) != NULL; + (create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(idx)) != NULL; ++idx) { - std::auto_ptr assembly_profiler_ap (create_callback (arch)); + std::auto_ptr assembly_profiler_ap (create_callback (arch)); if (assembly_profiler_ap.get ()) return assembly_profiler_ap.release (); } return NULL; } -UnwindAssemblyProfiler::UnwindAssemblyProfiler () +UnwindAssembly::UnwindAssembly () { } -UnwindAssemblyProfiler::~UnwindAssemblyProfiler () +UnwindAssembly::~UnwindAssembly () { } Removed: lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp?rev=130155&view=auto ============================================================================== --- lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp (original) +++ lldb/trunk/source/Target/UnwindAssemblyProfiler.cpp (removed) @@ -1,40 +0,0 @@ -//===-- UnwindAssemblyProfiler.cpp ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Core/PluginInterface.h" -#include "lldb/Target/UnwindAssemblyProfiler.h" - -using namespace lldb; -using namespace lldb_private; - -UnwindAssemblyProfiler* -UnwindAssemblyProfiler::FindPlugin (const ArchSpec &arch) -{ - UnwindAssemblyProfilerCreateInstance create_callback; - - for (uint32_t idx = 0; - (create_callback = PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex(idx)) != NULL; - ++idx) - { - std::auto_ptr assembly_profiler_ap (create_callback (arch)); - if (assembly_profiler_ap.get ()) - return assembly_profiler_ap.release (); - } - return NULL; -} - -UnwindAssemblyProfiler::UnwindAssemblyProfiler () -{ -} - -UnwindAssemblyProfiler::~UnwindAssemblyProfiler () -{ -} From johnny.chen at apple.com Mon Apr 25 17:04:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Apr 2011 22:04:05 -0000 Subject: [Lldb-commits] [lldb] r130158 - /lldb/trunk/test/lldbutil.py Message-ID: <20110425220406.0176D2A6C12D@llvm.org> Author: johnny Date: Mon Apr 25 17:04:05 2011 New Revision: 130158 URL: http://llvm.org/viewvc/llvm-project?rev=130158&view=rev Log: Move two functions around. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130158&r1=130157&r2=130158&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Mon Apr 25 17:04:05 2011 @@ -128,46 +128,6 @@ return unpacked[0] -# =========================================================== -# Returns the list of stopped thread(s) given an lldb process -# =========================================================== - -def get_stopped_threads(process, reason): - """Returns the thread(s) with the specified stop reason in a list.""" - threads = [] - for t in lldb_iter(process, 'GetNumThreads', 'GetThreadAtIndex'): - if t.GetStopReason() == reason: - threads.append(t) - return threads - -def get_stopped_thread(process, reason): - """A convenience function which returns the first thread with the given stop - reason or None. - - Example usages: - - 1. Get the stopped thread due to a breakpoint condition - - ... - from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) - self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") - ... - - 2. Get the thread stopped due to a breakpoint - - ... - from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") - ... - - """ - threads = get_stopped_threads(process, reason) - if len(threads) == 0: - return None - return threads[0] - # ============================================================== # Get the description of an lldb object or None if not available # ============================================================== @@ -277,6 +237,42 @@ # Utility functions related to Threads and Processes # ================================================== +def get_stopped_threads(process, reason): + """Returns the thread(s) with the specified stop reason in a list.""" + threads = [] + for t in lldb_iter(process, 'GetNumThreads', 'GetThreadAtIndex'): + if t.GetStopReason() == reason: + threads.append(t) + return threads + +def get_stopped_thread(process, reason): + """A convenience function which returns the first thread with the given stop + reason or None. + + Example usages: + + 1. Get the stopped thread due to a breakpoint condition + + ... + from lldbutil import get_stopped_thread + thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") + ... + + 2. Get the thread stopped due to a breakpoint + + ... + from lldbutil import get_stopped_thread + thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") + ... + + """ + threads = get_stopped_threads(process, reason) + if len(threads) == 0: + return None + return threads[0] + def get_caller_symbol(thread): """ Returns the symbol name for the call site of the leaf function. From ctice at apple.com Mon Apr 25 17:05:51 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 25 Apr 2011 22:05:51 -0000 Subject: [Lldb-commits] [lldb] r130159 - /lldb/trunk/source/API/SBDebugger.cpp Message-ID: <20110425220551.AA4B02A6C12D@llvm.org> Author: ctice Date: Mon Apr 25 17:05:51 2011 New Revision: 130159 URL: http://llvm.org/viewvc/llvm-project?rev=130159&view=rev Log: Add 'lldb_private' namespace where necessary to prevent ambiguity and resulting infinite loops. Modified: lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=130159&r1=130158&r2=130159&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Apr 25 17:05:51 2011 @@ -390,7 +390,7 @@ const char * SBDebugger::StateAsCString (StateType state) { - return StateAsCString (state); + return lldb_private::StateAsCString (state); } bool @@ -398,7 +398,7 @@ { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const bool result = StateIsRunningState (state); + const bool result = lldb_private::StateIsRunningState (state); if (log) log->Printf ("SBDebugger::StateIsRunningState (state=%s) => %i", StateAsCString (state), result); @@ -411,7 +411,7 @@ { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const bool result = StateIsStoppedState (state); + const bool result = lldb_private::StateIsStoppedState (state); if (log) log->Printf ("SBDebugger::StateIsStoppedState (state=%s) => %i", StateAsCString (state), result); From johnny.chen at apple.com Mon Apr 25 18:38:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Apr 2011 23:38:13 -0000 Subject: [Lldb-commits] [lldb] r130174 - in /lldb/trunk/test: breakpoint_ignore_count/TestBreakpointIgnoreCount.py class_types/TestClassTypes.py conditional_break/TestConditionalBreak.py conditional_break/conditional_break.py cpp/dynamic-value/TestDynamicValue.py expression_command/test/TestExprs.py inferior-crashing/TestInferiorCrashing.py lldbutil.py python_api/lldbutil/TestPrintStackTraces.py Message-ID: <20110425233813.4CEF72A6C12D@llvm.org> Author: johnny Date: Mon Apr 25 18:38:13 2011 New Revision: 130174 URL: http://llvm.org/viewvc/llvm-project?rev=130174&view=rev Log: For lldbutil.py, Change a bunch of function names to all lower case formats to be consistent. And modify the test cases accordingly. Modified: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/conditional_break/conditional_break.py lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py lldb/trunk/test/expression_command/test/TestExprs.py lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py Modified: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original) +++ lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Mon Apr 25 18:38:13 2011 @@ -108,7 +108,7 @@ # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and # frame#2 should be on main.c:48. - #lldbutil.PrintStackTraces(self.process) + #lldbutil.print_stacktraces(self.process) from lldbutil import get_stopped_thread thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Mon Apr 25 18:38:13 2011 @@ -140,8 +140,8 @@ # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. - self.expect("%s:%d" % (lldbutil.GetFilenames(thread)[0], - lldbutil.GetLineNumbers(thread)[0]), + self.expect("%s:%d" % (lldbutil.get_filenames(thread)[0], + lldbutil.get_line_numbers(thread)[0]), "Break correctly at main.cpp:%d" % self.line, exe=False, startstr = "main.cpp:") ### clang compiled code reported main.cpp:94? Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Mon Apr 25 18:38:13 2011 @@ -79,7 +79,7 @@ name0 = frame0.GetFunction().GetName() frame1 = thread.GetFrameAtIndex(1) name1 = frame1.GetFunction().GetName() - #lldbutil.PrintStackTrace(thread) + #lldbutil.print_stacktrace(thread) self.assertTrue(name0 == "c", "Break on function c()") if (name1 == "a"): # By design, we know that a() calls c() only from main.c:27. Modified: lldb/trunk/test/conditional_break/conditional_break.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/conditional_break.py (original) +++ lldb/trunk/test/conditional_break/conditional_break.py Mon Apr 25 18:38:13 2011 @@ -19,9 +19,9 @@ # command interpreter to continue execution. #print >> sys.stdout, "Checking call frames..." - #lldbutil.PrintStackTrace(thread) + #lldbutil.print_stacktrace(thread) if thread.GetNumFrames() >= 2: - funcs = lldbutil.GetFunctionNames(thread) + funcs = lldbutil.get_function_names(thread) #print >> sys.stdout, funcs[0], "called from", funcs[1] if (funcs[0] == 'c' and funcs[1] == 'a'): #print >> sys.stdout, "Stopped at c() with immediate caller as a()." Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (original) +++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Mon Apr 25 18:38:13 2011 @@ -119,7 +119,7 @@ self.assertTrue(self.process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.GetThreadsStoppedAtBreakpoint (self.process, first_call_bpt) + threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, first_call_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -141,7 +141,7 @@ # Okay now run to doSomething: - threads = lldbutil.ContinueToBreakpoint (self.process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -194,7 +194,7 @@ # Okay, now continue again, and when we hit the second breakpoint in main - threads = lldbutil.ContinueToBreakpoint (self.process, second_call_bpt) + threads = lldbutil.continue_to_breakpoint (self.process, second_call_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -206,7 +206,7 @@ # Finally continue to doSomething again, and make sure we get the right value for anotherA, # which this time around is just an "A". - threads = lldbutil.ContinueToBreakpoint (self.process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) self.assertTrue(len(threads) == 1) thread = threads[0] Modified: lldb/trunk/test/expression_command/test/TestExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/expression_command/test/TestExprs.py (original) +++ lldb/trunk/test/expression_command/test/TestExprs.py Mon Apr 25 18:38:13 2011 @@ -119,10 +119,10 @@ StopReasonString(thread.GetStopReason())) # The filename of frame #0 should be 'main.cpp' and function is main. - self.expect(lldbutil.GetFilenames(thread)[0], + self.expect(lldbutil.get_filenames(thread)[0], "Break correctly at main.cpp", exe=False, startstr = "main.cpp") - self.expect(lldbutil.GetFunctionNames(thread)[0], + self.expect(lldbutil.get_function_names(thread)[0], "Break correctly at main()", exe=False, startstr = "main") Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Mon Apr 25 18:38:13 2011 @@ -71,7 +71,7 @@ self.fail("Fail to stop the thread upon bad access exception") if self.TraceOn(): - lldbutil.PrintStackTrace(thread) + lldbutil.print_stacktrace(thread) if __name__ == '__main__': import atexit Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Mon Apr 25 18:38:13 2011 @@ -273,6 +273,32 @@ return None return threads[0] +def get_threads_stopped_at_breakpoint (process, bkpt): + """ For a stopped process returns the thread stopped at the breakpoint passed in bkpt""" + stopped_threads = [] + threads = [] + + stopped_threads = get_stopped_threads (process, lldb.eStopReasonBreakpoint) + + if len(stopped_threads) == 0: + return threads + + for thread in stopped_threads: + # Make sure we've hit our breakpoint... + break_id = thread.GetStopReasonDataAtIndex (0) + if break_id == bkpt.GetID(): + threads.append(thread) + + return threads + +def continue_to_breakpoint (process, bkpt): + """ Continues the process, if it stops, returns the threads stopped at bkpt; otherwise, returns None""" + process.Continue() + if process.GetState() != lldb.eStateStopped: + return None + else: + return get_threads_stopped_at_breakpoint (process, bkpt) + def get_caller_symbol(thread): """ Returns the symbol name for the call site of the leaf function. @@ -287,7 +313,7 @@ return None -def GetFunctionNames(thread): +def get_function_names(thread): """ Returns a sequence of function names from the stack frames of this thread. """ @@ -297,7 +323,7 @@ return map(GetFuncName, range(thread.GetNumFrames())) -def GetSymbolNames(thread): +def get_symbol_names(thread): """ Returns a sequence of symbols for this thread. """ @@ -307,7 +333,7 @@ return map(GetSymbol, range(thread.GetNumFrames())) -def GetPCAddresses(thread): +def get_pc_addresses(thread): """ Returns a sequence of pc addresses for this thread. """ @@ -317,7 +343,7 @@ return map(GetPCAddress, range(thread.GetNumFrames())) -def GetFilenames(thread): +def get_filenames(thread): """ Returns a sequence of file names from the stack frames of this thread. """ @@ -327,7 +353,7 @@ return map(GetFilename, range(thread.GetNumFrames())) -def GetLineNumbers(thread): +def get_line_numbers(thread): """ Returns a sequence of line numbers from the stack frames of this thread. """ @@ -337,7 +363,7 @@ return map(GetLineNumber, range(thread.GetNumFrames())) -def GetModuleNames(thread): +def get_module_names(thread): """ Returns a sequence of module names from the stack frames of this thread. """ @@ -347,7 +373,7 @@ return map(GetModuleName, range(thread.GetNumFrames())) -def GetStackFrames(thread): +def get_stack_frames(thread): """ Returns a sequence of stack frames for this thread. """ @@ -357,7 +383,7 @@ return map(GetStackFrame, range(thread.GetNumFrames())) -def PrintStackTrace(thread, string_buffer = False): +def print_stacktrace(thread, string_buffer = False): """Prints a simple stack trace of this thread.""" output = StringIO.StringIO() if string_buffer else sys.stdout @@ -365,12 +391,12 @@ depth = thread.GetNumFrames() - mods = GetModuleNames(thread) - funcs = GetFunctionNames(thread) - symbols = GetSymbolNames(thread) - files = GetFilenames(thread) - lines = GetLineNumbers(thread) - addrs = GetPCAddresses(thread) + mods = get_module_names(thread) + funcs = get_function_names(thread) + symbols = get_symbol_names(thread) + files = get_filenames(thread) + lines = get_line_numbers(thread) + addrs = get_pc_addresses(thread) if thread.GetStopReason() != lldb.eStopReasonInvalid: desc = "stop reason=" + StopReasonString(thread.GetStopReason()) @@ -396,7 +422,7 @@ return output.getvalue() -def PrintStackTraces(process, string_buffer = False): +def print_stacktraces(process, string_buffer = False): """Prints the stack traces of all the threads.""" output = StringIO.StringIO() if string_buffer else sys.stdout @@ -404,34 +430,7 @@ print >> output, "Stack traces for " + repr(process) for i in range(process.GetNumThreads()): - print >> output, PrintStackTrace(process.GetThreadAtIndex(i), string_buffer=True) + print >> output, print_stacktrace(process.GetThreadAtIndex(i), string_buffer=True) if string_buffer: return output.getvalue() - -def GetThreadsStoppedAtBreakpoint (process, bkpt): - """ For a stopped process returns the thread stopped at the breakpoint passed in bkpt""" - stopped_threads = [] - threads = [] - - stopped_threads = get_stopped_threads (process, lldb.eStopReasonBreakpoint) - - if len(stopped_threads) == 0: - return threads - - for thread in stopped_threads: - # Make sure we've hit our breakpoint... - break_id = thread.GetStopReasonDataAtIndex (0) - if break_id == bkpt.GetID(): - threads.append(thread) - - return threads - -def ContinueToBreakpoint (process, bkpt): - """ Continues the process, if it stops, returns the threads stopped at bkpt; otherwise, returns None""" - process.Continue() - if process.GetState() != lldb.eStateStopped: - return None - else: - return GetThreadsStoppedAtBreakpoint (process, bkpt) - Modified: lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py?rev=130174&r1=130173&r2=130174&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py Mon Apr 25 18:38:13 2011 @@ -47,7 +47,7 @@ lldbutil.StateTypeString(self.process.GetState())) if self.TraceOn(): - lldbutil.PrintStackTraces(self.process) + lldbutil.print_stacktraces(self.process) if __name__ == '__main__': From gclayton at apple.com Mon Apr 25 23:39:09 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 26 Apr 2011 04:39:09 -0000 Subject: [Lldb-commits] [lldb] r130189 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ lldb.xcodeproj/xcshareddata/xcschemes/ source/ source/API/ source/Core/ source/Plugins/ArchDefaultUnwindPlan/x86/ source/Plugins/ArchVolatileRegs/x86/ source/Plugins/Instruction/ARM/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Plugins/UnwindAssembly/InstEmulation/ source/Plugins/UnwindAssembly/x86/ source/Target/ source/Utility/ Message-ID: <20110426043909.9DEDD2A6C12D@llvm.org> Author: gclayton Date: Mon Apr 25 23:39:08 2011 New Revision: 130189 URL: http://llvm.org/viewvc/llvm-project?rev=130189&view=rev Log: Changed the emulate instruction function to take emulate options which are defined as enumerations. Current bits include: eEmulateInstructionOptionAutoAdvancePC eEmulateInstructionOptionIgnoreConditions Modified the EmulateInstruction class to have a few more pure virtuals that can help clients understand how many instructions the emulator can handle: virtual bool SupportsEmulatingIntructionsOfType (InstructionType inst_type) = 0; Where instruction types are defined as: //------------------------------------------------------------------ /// Instruction types //------------------------------------------------------------------ typedef enum InstructionType { eInstructionTypeAny, // Support for any instructions at all (at least one) eInstructionTypePrologueEpilogue, // All prologue and epilogue instructons that push and pop register values and modify sp/fp eInstructionTypePCModifying, // Any instruction that modifies the program counter/instruction pointer eInstructionTypeAll // All instructions of any kind } InstructionType; This allows use to tell what an emulator can do and also allows us to request these abilities when we are finding the plug-in interface. Added the ability for an EmulateInstruction class to get the register names for any registers that are part of the emulation. This helps with being able to dump and log effectively. The UnwindAssembly class now stores the architecture it was created with in case it is needed later in the unwinding process. Added a function that can tell us DWARF register names for ARM that goes along with the source/Utility/ARM_DWARF_Registers.h file: source/Utility/ARM_DWARF_Registers.c Took some of plug-ins out of the lldb_private namespace. Added: lldb/trunk/source/Utility/ARM_DWARF_Registers.c Modified: lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/Target/UnwindAssembly.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-private-enumerations.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/API/SBInstruction.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h lldb/trunk/source/Target/ExecutionContext.cpp lldb/trunk/source/Target/UnwindAssembly.cpp lldb/trunk/source/Utility/ARM_DWARF_Registers.h lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Mon Apr 25 23:39:08 2011 @@ -53,7 +53,7 @@ GetDescription (lldb::SBStream &description); bool - EmulateWithFrame (lldb::SBFrame &frame, bool auto_advance_pc); + EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options); bool DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'arm-apple-darwin' Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Mon Apr 25 23:39:08 2011 @@ -86,7 +86,7 @@ bool Emulate (const ArchSpec &arch, - bool auto_advance_pc, + uint32_t evaluate_options, void *baton, EmulateInstruction::ReadMemory read_mem_callback, EmulateInstruction::WriteMemory write_mem_calback, Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Mon Apr 25 23:39:08 2011 @@ -86,7 +86,9 @@ public: static EmulateInstruction* - FindPlugin (const ArchSpec &arch, const char *plugin_name); + FindPlugin (const ArchSpec &arch, + InstructionType supported_inst_type, + const char *plugin_name); enum ContextType { @@ -366,45 +368,43 @@ static void PrintContext (const char *context_type, const Context &context); - typedef size_t (*ReadMemory) (void *baton, + typedef size_t (*ReadMemory) (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length); - typedef size_t (*WriteMemory) (void *baton, + typedef size_t (*WriteMemory) (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length); - typedef bool (*ReadRegister) (void *baton, + typedef bool (*ReadRegister) (EmulateInstruction *instruction, + void *baton, uint32_t reg_kind, uint32_t reg_num, uint64_t ®_value); - typedef bool (*WriteRegister) (void *baton, + typedef bool (*WriteRegister) (EmulateInstruction *instruction, + void *baton, const Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value); - EmulateInstruction (lldb::ByteOrder byte_order, - uint32_t addr_byte_size, - const ArchSpec &arch, - void *baton, - ReadMemory read_mem_callback, - WriteMemory write_mem_callback, - ReadRegister read_reg_callback, - WriteRegister write_reg_callback); - - EmulateInstruction (lldb::ByteOrder byte_order, - uint32_t addr_byte_size, - const ArchSpec &arch); + EmulateInstruction (const ArchSpec &arch); virtual ~EmulateInstruction() { } + //---------------------------------------------------------------------- + // Mandatory overrides + //---------------------------------------------------------------------- + virtual bool + SupportsEmulatingIntructionsOfType (InstructionType inst_type) = 0; virtual bool SetTargetTriple (const ArchSpec &arch) = 0; @@ -413,21 +413,20 @@ ReadInstruction () = 0; virtual bool - SetInstruction (const Opcode &insn_opcode, const Address &inst_addr) = 0; - - virtual bool - EvaluateInstruction () = 0; + EvaluateInstruction (uint32_t evaluate_options) = 0; virtual bool TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0; + + virtual const char * + GetRegisterName (uint32_t reg_kind, uint32_t reg_num) = 0; + //---------------------------------------------------------------------- + // Optional overrides + //---------------------------------------------------------------------- + virtual bool + SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target); - bool - GetAdvancePC () { return m_advance_pc; } - - void - SetAdvancePC (bool value) { m_advance_pc = value; } - - static void + static const char * TranslateRegister (uint32_t reg_kind, uint32_t reg_num, std::string ®_name); uint64_t @@ -458,13 +457,13 @@ uint32_t GetAddressByteSize () const { - return m_addr_byte_size; + return m_arch.GetAddressByteSize(); } lldb::ByteOrder GetByteOrder () const { - return m_byte_order; + return m_arch.GetByteOrder(); } const Opcode & @@ -472,59 +471,73 @@ { return m_opcode; } + + const ArchSpec & + GetArchitecture () const + { + return m_arch; + } static size_t - ReadMemoryFrame (void *baton, + ReadMemoryFrame (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length); static size_t - WriteMemoryFrame (void *baton, + WriteMemoryFrame (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length); static bool - ReadRegisterFrame (void *baton, + ReadRegisterFrame (EmulateInstruction *instruction, + void *baton, uint32_t reg_kind, uint32_t reg_num, uint64_t ®_value); static bool - WriteRegisterFrame (void *baton, + WriteRegisterFrame (EmulateInstruction *instruction, + void *baton, const Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value); static size_t - ReadMemoryDefault (void *baton, + ReadMemoryDefault (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length); static size_t - WriteMemoryDefault (void *baton, + WriteMemoryDefault (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length); static bool - ReadRegisterDefault (void *baton, + ReadRegisterDefault (EmulateInstruction *instruction, + void *baton, uint32_t reg_kind, uint32_t reg_num, uint64_t ®_value); static bool - WriteRegisterDefault (void *baton, + WriteRegisterDefault (EmulateInstruction *instruction, + void *baton, const Context &context, uint32_t reg_kind, uint32_t reg_num, @@ -553,8 +566,6 @@ protected: - lldb::ByteOrder m_byte_order; - uint32_t m_addr_byte_size; ArchSpec m_arch; void * m_baton; ReadMemory m_read_mem_callback; @@ -563,7 +574,6 @@ WriteRegister m_write_reg_callback; lldb::addr_t m_opcode_pc; Opcode m_opcode; - bool m_advance_pc; //------------------------------------------------------------------ // For EmulateInstruction only //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h (original) +++ lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h Mon Apr 25 23:39:08 2011 @@ -24,7 +24,8 @@ ~ArchDefaultUnwindPlan(); virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) = 0; + GetArchDefaultUnwindPlan (Thread& thread, + const Address ¤t_pc) = 0; static lldb::ArchDefaultUnwindPlanSP FindPlugin (const ArchSpec &arch); Modified: lldb/trunk/include/lldb/Target/UnwindAssembly.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/UnwindAssembly.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/UnwindAssembly.h (original) +++ lldb/trunk/include/lldb/Target/UnwindAssembly.h Mon Apr 25 23:39:08 2011 @@ -11,6 +11,7 @@ #define utility_UnwindAssembly_h_ #include "lldb/lldb-private.h" +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { @@ -43,8 +44,11 @@ Address& first_non_prologue_insn) = 0; protected: - UnwindAssembly(); + UnwindAssembly (const ArchSpec &arch); + ArchSpec m_arch; + private: + UnwindAssembly(); // Outlaw default constructor DISALLOW_COPY_AND_ASSIGN (UnwindAssembly); }; Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Apr 25 23:39:08 2011 @@ -457,6 +457,13 @@ } SectionType; + typedef enum EmulateInstructionOptions + { + eEmulateInstructionOptionNone = (0u), + eEmulateInstructionOptionAutoAdvancePC = (1u << 0), + eEmulateInstructionOptionIgnoreConditions = (1u << 1) + } EmulateInstructionOptions; + } // namespace lldb Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-private-enumerations.h Mon Apr 25 23:39:08 2011 @@ -204,6 +204,19 @@ } NameMatchType; +//------------------------------------------------------------------ +/// Instruction types +//------------------------------------------------------------------ +typedef enum InstructionType +{ + eInstructionTypeAny, // Support for any instructions at all (at least one) + eInstructionTypePrologueEpilogue, // All prologue and epilogue instructons that push and pop register values and modify sp/fp + eInstructionTypePCModifying, // Any instruction that modifies the program counter/instruction pointer + eInstructionTypeAll // All instructions of any kind + +} InstructionType; + + } // namespace lldb Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Mon Apr 25 23:39:08 2011 @@ -22,7 +22,7 @@ typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length); typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length); typedef LogChannel* (*LogChannelCreateInstance) (); - typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch); + typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type); typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language); typedef Platform* (*PlatformCreateInstance) (); typedef Process* (*ProcessCreateInstance) (Target &target, Listener &listener); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Apr 25 23:39:08 2011 @@ -404,6 +404,7 @@ 26DE20611161902700A093E2 /* SBBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20601161902600A093E2 /* SBBlock.cpp */; }; 26DE20631161904200A093E2 /* SBLineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20621161904200A093E2 /* SBLineEntry.cpp */; }; 26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; }; + 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.c in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.c */; }; 26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; }; 26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; }; 26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; }; @@ -1043,6 +1044,7 @@ 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMacOSXFrameBackchain.h; path = Utility/RegisterContextMacOSXFrameBackchain.h; sourceTree = ""; }; 26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCallbacks.h; path = include/lldb/Symbol/ClangExternalASTSourceCallbacks.h; sourceTree = ""; }; 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCallbacks.cpp; path = source/Symbol/ClangExternalASTSourceCallbacks.cpp; sourceTree = ""; }; + 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ARM_DWARF_Registers.c; path = source/Utility/ARM_DWARF_Registers.c; sourceTree = ""; }; 26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; }; 26F5C27210F3D9E4009D5894 /* lldb-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "lldb-Info.plist"; path = "tools/driver/lldb-Info.plist"; sourceTree = ""; }; 26F5C27310F3D9E4009D5894 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = tools/driver/Driver.cpp; sourceTree = ""; }; @@ -1761,6 +1763,7 @@ 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */, 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */, 26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */, + 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.c */, 26F996A8119B79C300412154 /* ARM_GCC_Registers.h */, 2660D9F611922A1300958FBD /* StringExtractor.cpp */, 2660D9F711922A1300958FBD /* StringExtractor.h */, @@ -3231,6 +3234,7 @@ 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */, 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */, 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */, + 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Mon Apr 25 23:39:08 2011 @@ -74,8 +74,6 @@ GetArchitecture(); return m_opaque_sp->Emulate (arch, - auto_advance_pc, + evaluate_options, (void *) frame.get(), &lldb_private::EmulateInstruction::ReadMemoryFrame, &lldb_private::EmulateInstruction::WriteMemoryFrame, Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Mon Apr 25 23:39:08 2011 @@ -503,11 +503,11 @@ bool Instruction::DumpEmulation (const ArchSpec &arch) { - std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, NULL)); + std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL)); if (insn_emulator_ap.get()) { - insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress()); - return insn_emulator_ap->EvaluateInstruction (); + insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL); + return insn_emulator_ap->EvaluateInstruction (0); } return false; @@ -766,7 +766,7 @@ arch.SetTriple (llvm::Triple (value_sp->GetStringValue())); bool success = false; - std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, NULL)); + std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL)); if (insn_emulator_ap.get()) success = insn_emulator_ap->TestEmulation (out_stream, arch, data_dictionary); @@ -780,21 +780,20 @@ bool Instruction::Emulate (const ArchSpec &arch, - bool auto_advance_pc, + uint32_t evaluate_options, void *baton, EmulateInstruction::ReadMemory read_mem_callback, EmulateInstruction::WriteMemory write_mem_callback, EmulateInstruction::ReadRegister read_reg_callback, EmulateInstruction::WriteRegister write_reg_callback) { - std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, NULL)); + std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL)); if (insn_emulator_ap.get()) { insn_emulator_ap->SetBaton (baton); insn_emulator_ap->SetCallbacks (read_mem_callback, write_mem_callback, read_reg_callback, write_reg_callback); - insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress()); - insn_emulator_ap->SetAdvancePC (auto_advance_pc); - return insn_emulator_ap->EvaluateInstruction (); + insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL); + return insn_emulator_ap->EvaluateInstruction (evaluate_options); } return false; Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Mon Apr 25 23:39:08 2011 @@ -9,6 +9,7 @@ #include "lldb/Core/EmulateInstruction.h" +#include "lldb/Core/Address.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Error.h" @@ -17,6 +18,7 @@ #include "lldb/Host/Endian.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" @@ -25,7 +27,7 @@ using namespace lldb_private; EmulateInstruction* -EmulateInstruction::FindPlugin (const ArchSpec &arch, const char *plugin_name) +EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name) { EmulateInstructionCreateInstance create_callback = NULL; if (plugin_name) @@ -33,7 +35,7 @@ create_callback = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (plugin_name); if (create_callback) { - EmulateInstruction *emulate_insn_ptr = create_callback(arch); + EmulateInstruction *emulate_insn_ptr = create_callback(arch, supported_inst_type); if (emulate_insn_ptr) return emulate_insn_ptr; } @@ -42,7 +44,7 @@ { for (uint32_t idx = 0; (create_callback = PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) != NULL; ++idx) { - EmulateInstruction *emulate_insn_ptr = create_callback(arch); + EmulateInstruction *emulate_insn_ptr = create_callback(arch, supported_inst_type); if (emulate_insn_ptr) return emulate_insn_ptr; } @@ -50,47 +52,14 @@ return NULL; } -EmulateInstruction::EmulateInstruction -( - lldb::ByteOrder byte_order, - uint32_t addr_byte_size, - const ArchSpec &arch, - void *baton, - ReadMemory read_mem_callback, - WriteMemory write_mem_callback, - ReadRegister read_reg_callback, - WriteRegister write_reg_callback -) : - m_byte_order (endian::InlHostByteOrder()), - m_addr_byte_size (addr_byte_size), - m_arch (arch), - m_baton (baton), - m_read_mem_callback (read_mem_callback), - m_write_mem_callback (write_mem_callback), - m_read_reg_callback (read_reg_callback), - m_write_reg_callback (write_reg_callback), - m_opcode_pc (LLDB_INVALID_ADDRESS), - m_opcode (), - m_advance_pc (false) -{ -} - -EmulateInstruction::EmulateInstruction -( - lldb::ByteOrder byte_order, - uint32_t addr_byte_size, - const ArchSpec &arch -) : - m_byte_order (endian::InlHostByteOrder()), - m_addr_byte_size (addr_byte_size), +EmulateInstruction::EmulateInstruction (const ArchSpec &arch) : m_arch (arch), m_baton (NULL), m_read_mem_callback (&ReadMemoryDefault), m_write_mem_callback (&WriteMemoryDefault), m_read_reg_callback (&ReadRegisterDefault), m_write_reg_callback (&WriteRegisterDefault), - m_opcode_pc (LLDB_INVALID_ADDRESS), - m_advance_pc (false) + m_opcode_pc (LLDB_INVALID_ADDRESS) { ::memset (&m_opcode, 0, sizeof (m_opcode)); } @@ -99,7 +68,7 @@ EmulateInstruction::ReadRegisterUnsigned (uint32_t reg_kind, uint32_t reg_num, uint64_t fail_value, bool *success_ptr) { uint64_t uval64 = 0; - bool success = m_read_reg_callback (m_baton, reg_kind, reg_num, uval64); + bool success = m_read_reg_callback (this, m_baton, reg_kind, reg_num, uval64); if (success_ptr) *success_ptr = success; if (!success) @@ -110,7 +79,7 @@ bool EmulateInstruction::WriteRegisterUnsigned (const Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value) { - return m_write_reg_callback (m_baton, context, reg_kind, reg_num, reg_value); + return m_write_reg_callback (this, m_baton, context, reg_kind, reg_num, reg_value); } uint64_t @@ -121,11 +90,11 @@ if (byte_size <= 8) { uint8_t buf[sizeof(uint64_t)]; - size_t bytes_read = m_read_mem_callback (m_baton, context, addr, buf, byte_size); + size_t bytes_read = m_read_mem_callback (this, m_baton, context, addr, buf, byte_size); if (bytes_read == byte_size) { uint32_t offset = 0; - DataExtractor data (buf, byte_size, m_byte_order, m_addr_byte_size); + DataExtractor data (buf, byte_size, GetByteOrder(), GetAddressByteSize()); uval64 = data.GetMaxU64 (&offset, byte_size); success = true; } @@ -149,7 +118,7 @@ StreamString strm(Stream::eBinary, GetAddressByteSize(), GetByteOrder()); strm.PutMaxHex64 (uval, uval_byte_size); - size_t bytes_written = m_write_mem_callback (m_baton, context, addr, strm.GetData(), uval_byte_size); + size_t bytes_written = m_write_mem_callback (this, m_baton, context, addr, strm.GetData(), uval_byte_size); if (bytes_written == uval_byte_size) return true; return false; @@ -208,7 +177,8 @@ // size_t -EmulateInstruction::ReadMemoryFrame (void *baton, +EmulateInstruction::ReadMemoryFrame (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, void *dst, @@ -233,7 +203,8 @@ } size_t -EmulateInstruction::WriteMemoryFrame (void *baton, +EmulateInstruction::WriteMemoryFrame (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, const void *dst, @@ -262,7 +233,8 @@ } bool -EmulateInstruction::ReadRegisterFrame (void *baton, +EmulateInstruction::ReadRegisterFrame (EmulateInstruction *instruction, + void *baton, uint32_t reg_kind, uint32_t reg_num, uint64_t ®_value) @@ -289,7 +261,8 @@ } bool -EmulateInstruction::WriteRegisterFrame (void *baton, +EmulateInstruction::WriteRegisterFrame (EmulateInstruction *instruction, + void *baton, const Context &context, uint32_t reg_kind, uint32_t reg_num, @@ -310,7 +283,8 @@ } size_t -EmulateInstruction::ReadMemoryDefault (void *baton, +EmulateInstruction::ReadMemoryDefault (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, void *dst, @@ -324,7 +298,8 @@ } size_t -EmulateInstruction::WriteMemoryDefault (void *baton, +EmulateInstruction::WriteMemoryDefault (EmulateInstruction *instruction, + void *baton, const Context &context, lldb::addr_t addr, const void *dst, @@ -336,7 +311,8 @@ } bool -EmulateInstruction::ReadRegisterDefault (void *baton, +EmulateInstruction::ReadRegisterDefault (EmulateInstruction *instruction, + void *baton, uint32_t reg_kind, uint32_t reg_num, uint64_t ®_value) @@ -350,7 +326,8 @@ } bool -EmulateInstruction::WriteRegisterDefault (void *baton, +EmulateInstruction::WriteRegisterDefault (EmulateInstruction *instruction, + void *baton, const Context &context, uint32_t reg_kind, uint32_t reg_num, @@ -601,54 +578,69 @@ } } -void -EmulateInstruction::TranslateRegister (uint32_t kind, uint32_t num, std::string &name) +bool +EmulateInstruction::SetInstruction (const Opcode &opcode, const Address &inst_addr, Target *target) { - if (kind == eRegisterKindDWARF) + m_opcode = opcode; + m_opcode_pc = LLDB_INVALID_ADDRESS; + if (inst_addr.IsValid()) { - if (num == 13) //dwarf_sp NOTE: This is ARM-SPECIFIC - name = "sp"; - else if (num == 14) //dwarf_lr NOTE: This is ARM-SPECIFIC - name = "lr"; - else if (num == 15) //dwarf_pc NOTE: This is ARM-SPECIFIC - name = "pc"; - else if (num == 16) //dwarf_cpsr NOTE: This is ARM-SPECIFIC - name = "cpsr"; - else - { - StreamString sstr; - - sstr.Printf ("r%d", num); - name = sstr.GetData(); - } - + if (target) + m_opcode_pc = inst_addr.GetLoadAddress (target); + if (m_opcode_pc == LLDB_INVALID_ADDRESS) + m_opcode_pc = inst_addr.GetFileAddress (); } - else if (kind == eRegisterKindGeneric) + return true; +} + + +const char * +EmulateInstruction::TranslateRegister (uint32_t kind, uint32_t num, std::string &name) +{ + if (kind == eRegisterKindGeneric) { - if (num == LLDB_REGNUM_GENERIC_SP) - name = "sp"; - else if (num == LLDB_REGNUM_GENERIC_FLAGS) - name = "cpsr"; - else if (num == LLDB_REGNUM_GENERIC_PC) - name = "pc"; - else if (num == LLDB_REGNUM_GENERIC_RA) - name = "lr"; - else + switch (num) { - StreamString sstr; - - sstr.Printf ("r%d", num); - name = sstr.GetData(); + case LLDB_REGNUM_GENERIC_PC: name = "pc"; break; + case LLDB_REGNUM_GENERIC_SP: name = "sp"; break; + case LLDB_REGNUM_GENERIC_FP: name = "fp"; break; + case LLDB_REGNUM_GENERIC_RA: name = "ra"; break; + case LLDB_REGNUM_GENERIC_FLAGS: name = "flags"; break; + default: name.clear(); break; } + if (!name.empty()) + return name.c_str(); } - else + const char *kind_cstr = NULL; + + switch (kind) { - StreamString sstr; + case eRegisterKindGCC: // the register numbers seen in eh_frame + kind_cstr = "gcc"; + break; + + case eRegisterKindDWARF: // the register numbers seen DWARF + kind_cstr = "dwarf"; + break; - sstr.Printf ("r%d", num); - name = sstr.GetData(); + case eRegisterKindGeneric: // insn ptr reg, stack ptr reg, etc not specific to any particular target + kind_cstr = "generic"; + break; + + case eRegisterKindGDB: // the register numbers gdb uses (matches stabs numbers?) + kind_cstr = "gdb"; + break; + + case eRegisterKindLLDB: // lldb's internal register numbers + kind_cstr = "lldb"; + break; } + + + StreamString sstr; + sstr.Printf ("%s(%u)", kind_cstr, num); + name.swap (sstr.GetString()); + return name.c_str(); } - Modified: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.cpp Mon Apr 25 23:39:08 2011 @@ -15,8 +15,8 @@ using namespace lldb; using namespace lldb_private; -lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch) +ArchDefaultUnwindPlan * +ArchDefaultUnwindPlan_x86_64::CreateInstance (const ArchSpec &arch) { if (arch.GetMachine () == llvm::Triple::x86_64) return new ArchDefaultUnwindPlan_x86_64 (); @@ -24,7 +24,7 @@ } ArchDefaultUnwindPlan_x86_64::ArchDefaultUnwindPlan_x86_64() : - lldb_private::ArchDefaultUnwindPlan(), + ArchDefaultUnwindPlan(), m_unwind_plan_sp (new UnwindPlan) { UnwindPlan::Row row; @@ -96,15 +96,16 @@ } UnwindPlanSP -ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) +ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, + const Address ¤t_pc) { return m_unwind_plan_sp; } -lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch) +ArchDefaultUnwindPlan * +ArchDefaultUnwindPlan_i386::CreateInstance (const ArchSpec &arch) { if (arch.GetMachine () == llvm::Triple::x86) return new ArchDefaultUnwindPlan_i386 (); @@ -112,7 +113,7 @@ } ArchDefaultUnwindPlan_i386::ArchDefaultUnwindPlan_i386() : - lldb_private::ArchDefaultUnwindPlan(), + ArchDefaultUnwindPlan(), m_unwind_plan_sp (new UnwindPlan) { UnwindPlan::Row row; @@ -185,7 +186,7 @@ } UnwindPlanSP -ArchDefaultUnwindPlan_i386::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) +ArchDefaultUnwindPlan_i386::GetArchDefaultUnwindPlan (Thread& thread, const Address ¤t_pc) { return m_unwind_plan_sp; } Modified: lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h Mon Apr 25 23:39:08 2011 @@ -15,8 +15,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Symbol/UnwindPlan.h" -namespace lldb_private { - class ArchDefaultUnwindPlan_x86_64 : public lldb_private::ArchDefaultUnwindPlan { public: @@ -24,7 +22,8 @@ ~ArchDefaultUnwindPlan_x86_64 () { } virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); + GetArchDefaultUnwindPlan (lldb_private::Thread& thread, + const lldb_private::Address ¤t_pc); static lldb_private::ArchDefaultUnwindPlan * CreateInstance (const lldb_private::ArchSpec &arch); @@ -66,7 +65,8 @@ ~ArchDefaultUnwindPlan_i386 () { } virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); + GetArchDefaultUnwindPlan (lldb_private::Thread& thread, + const lldb_private::Address& current_pc); static lldb_private::ArchDefaultUnwindPlan * CreateInstance (const lldb_private::ArchSpec &arch); @@ -101,7 +101,4 @@ lldb::UnwindPlanSP m_unwind_plan_sp; }; - -} // namespace lldb_private - #endif // liblldb_UnwindAssembly_x86_h_ Modified: lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h (original) +++ lldb/trunk/source/Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h Mon Apr 25 23:39:08 2011 @@ -15,8 +15,6 @@ #include "lldb/Target/ArchVolatileRegs.h" #include -namespace lldb_private { - class ArchVolatileRegs_x86 : public lldb_private::ArchVolatileRegs { public: @@ -62,7 +60,4 @@ std::set m_non_volatile_regs; }; - -} // namespace lldb_private - #endif // liblldb_ArchVolatileRegs_x86_h_ Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Apr 25 23:39:08 2011 @@ -181,21 +181,24 @@ } EmulateInstruction * -EmulateInstructionARM::CreateInstance (const ArchSpec &arch) +EmulateInstructionARM::CreateInstance (const ArchSpec &arch, InstructionType inst_type) { - if (arch.GetTriple().getArch() == llvm::Triple::arm) - { - std::auto_ptr emulate_insn_ap (new EmulateInstructionARM (arch)); - - if (emulate_insn_ap.get()) - return emulate_insn_ap.release(); - } - else if (arch.GetTriple().getArch() == llvm::Triple::thumb) + if (EmulateInstructionARM::SupportsEmulatingIntructionsOfTypeStatic(inst_type)) { - std::auto_ptr emulate_insn_ap (new EmulateInstructionARM (arch)); - - if (emulate_insn_ap.get()) - return emulate_insn_ap.release(); + if (arch.GetTriple().getArch() == llvm::Triple::arm) + { + std::auto_ptr emulate_insn_ap (new EmulateInstructionARM (arch)); + + if (emulate_insn_ap.get()) + return emulate_insn_ap.release(); + } + else if (arch.GetTriple().getArch() == llvm::Triple::thumb) + { + std::auto_ptr emulate_insn_ap (new EmulateInstructionARM (arch)); + + if (emulate_insn_ap.get()) + return emulate_insn_ap.release(); + } } return NULL; @@ -340,7 +343,7 @@ Register dwarf_reg; dwarf_reg.SetRegister (eRegisterKindDWARF, 0); Register sp_reg; - sp_reg.SetRegister (eRegisterKindDWARF, dwarf_sp); + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); for (i=0; i<15; ++i) { if (BitIsSet (registers, i)) @@ -1247,7 +1250,7 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextAdjustStackPointer; Register sp_reg; - sp_reg.SetRegister (eRegisterKindDWARF, dwarf_sp); + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); context.SetRegisterPlusOffset (sp_reg, sp_offset); if (d == 15) @@ -1312,7 +1315,7 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextAddition; Register sp_reg; - sp_reg.SetRegister (eRegisterKindDWARF, dwarf_sp); + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); Register other_reg; other_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); context.SetRegisterRegisterOperands (sp_reg, other_reg); @@ -1849,7 +1852,7 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextPushRegisterOnStack; Register sp_reg; - sp_reg.SetRegister (eRegisterKindDWARF, dwarf_sp); + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); context.SetRegisterPlusOffset (sp_reg, addr - sp); if (Rt != 15) { @@ -1952,7 +1955,7 @@ Register dwarf_reg; dwarf_reg.SetRegister (eRegisterKindDWARF, 0); Register sp_reg; - sp_reg.SetRegister (eRegisterKindDWARF, dwarf_sp); + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); for (i=0; ivariants != ARMvAll) - return false; - break; - - case ARMv4T: - if ((opcode_data->variants!= ARMvAll) - && (opcode_data->variants != ARMV4T_ABOVE)) - return false; - break; - - case ARMv5T: - case ARMv5TE: - if ((opcode_data->variants != ARMvAll) - && (opcode_data->variants != ARMV4T_ABOVE) - && (opcode_data->variants != ARMV5_ABOVE)) - return false; - break; - - case ARMv5TEJ: - if ((opcode_data->variants != ARMvAll) - && (opcode_data->variants != ARMV4T_ABOVE) - && (opcode_data->variants != ARMV5_ABOVE) - && (opcode_data->variants != ARMV5J_ABOVE)) - return false; - break; - - case ARMv6: - case ARMv6K: - if ((opcode_data->variants != ARMvAll) - && (opcode_data->variants != ARMV4T_ABOVE) - && (opcode_data->variants != ARMV5_ABOVE) - && (opcode_data->variants != ARMV5J_ABOVE) - && (opcode_data->variants != ARMV6_ABOVE)) - return false; - break; - - case ARMv6T2: - case ARMv7: - case ARMv8: - if ((opcode_data->variants != ARMvAll) - && (opcode_data->variants != ARMV4T_ABOVE) - && (opcode_data->variants != ARMV5_ABOVE) - && (opcode_data->variants != ARMV5J_ABOVE) - && (opcode_data->variants != ARMV6_ABOVE) - && (opcode_data->variants != ARMV6T2_ABOVE)) - return false; - break; - - default: -// if (opcode_data->variants != ARMvAll) -// return false; - break; + m_opcode_cpsr = ReadRegisterUnsigned (eRegisterKindDWARF, + dwarf_cpsr, + 0, + &success); } + + // Only return false if we are unable to read the CPSR if we care about conditions + if (success == false && m_ignore_conditions == false) + return false; - // Just for now, for testing purposes. - if (m_baton == NULL) - fprintf (stdout, "\nEvaluateInstruction, opcode (0x%x), found = '%s'\n", m_opcode.GetOpcode32(), - opcode_data->name); - - bool success; - if (m_baton) + uint32_t orig_pc_value = 0; + if (auto_advance_pc) { - uint32_t cpsr_value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_cpsr, 0, &success); - if (success) - m_opcode_cpsr = cpsr_value; + orig_pc_value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc, 0, &success); + if (!success) + return false; } - uint32_t orig_pc_value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc, 0, &success); - if (!success) - return false; - - success = (this->*opcode_data->callback) (m_opcode.GetOpcode32(), opcode_data->encoding); // Call the Emulate... function. + // Call the Emulate... function. + success = (this->*opcode_data->callback) (m_opcode.GetOpcode32(), opcode_data->encoding); if (!success) return false; - uint32_t after_pc_value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc, 0, &success); - if (!success) - return false; - - if (m_advance_pc && (after_pc_value == orig_pc_value)) + if (auto_advance_pc) { - if (opcode_data->size == eSize32) - after_pc_value += 4; - else if (opcode_data->size == eSize16) - after_pc_value += 2; - - EmulateInstruction::Context context; - context.type = eContextAdvancePC; - context.SetNoArgs(); - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc, after_pc_value)) + uint32_t after_pc_value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc, 0, &success); + if (!success) return false; + if (auto_advance_pc && (after_pc_value == orig_pc_value)) + { + if (opcode_data->size == eSize32) + after_pc_value += 4; + else if (opcode_data->size == eSize16) + after_pc_value += 2; + + EmulateInstruction::Context context; + context.type = eContextAdvancePC; + context.SetNoArgs(); + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc, after_pc_value)) + return false; + + } } - return true; } @@ -13331,10 +13297,6 @@ } test_opcode = value_sp->GetUInt64Value (); - // If the instruction emulation does not directly update the PC, advance the PC to the next instruction after - // performing the emulation. - SetAdvancePC (true); - if (arch.GetTriple().getArch() == llvm::Triple::arm) { m_opcode_mode = eModeARM; @@ -13392,7 +13354,7 @@ &EmulationStateARM::ReadPseudoRegister, &EmulationStateARM::WritePseudoRegister); - bool success = EvaluateInstruction (); + bool success = EvaluateInstruction (eEmulateInstructionOptionAutoAdvancePC); if (!success) { out_stream->Printf ("TestEmulation: EvaluateInstruction() failed.\n"); @@ -13406,3 +13368,26 @@ return success; } + +const char * +EmulateInstructionARM::GetRegisterName (uint32_t reg_kind, uint32_t reg_num) +{ + if (reg_kind == eRegisterKindGeneric) + { + switch (reg_num) + { + case LLDB_REGNUM_GENERIC_PC: return "pc"; + case LLDB_REGNUM_GENERIC_SP: return "sp"; + case LLDB_REGNUM_GENERIC_FP: return "fp"; + case LLDB_REGNUM_GENERIC_RA: return "lr"; + case LLDB_REGNUM_GENERIC_FLAGS: return "cpsr"; + default: return NULL; + } + } + else if (reg_kind == eRegisterKindDWARF) + { + return GetARMDWARFRegisterName (reg_num); + } + return NULL; +} + Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Apr 25 23:39:08 2011 @@ -75,8 +75,28 @@ GetPluginDescriptionStatic (); static lldb_private::EmulateInstruction * - CreateInstance (const lldb_private::ArchSpec &arch); + CreateInstance (const lldb_private::ArchSpec &arch, + InstructionType inst_type); + static bool + SupportsEmulatingIntructionsOfTypeStatic (InstructionType inst_type) + { + switch (inst_type) + { + case eInstructionTypeAny: + case eInstructionTypePrologueEpilogue: + case eInstructionTypePCModifying: + return true; + + case eInstructionTypeAll: + return false; + + default: + break; + } + return false; + } + virtual const char * GetPluginName() { @@ -106,38 +126,43 @@ }; EmulateInstructionARM (const ArchSpec &arch) : - EmulateInstruction (lldb::eByteOrderLittle, - 4, - arch), + EmulateInstruction (arch), m_arm_isa (0), m_opcode_mode (eModeInvalid), m_opcode_cpsr (0), - m_it_session () + m_it_session (), + m_ignore_conditions (false) { + SetArchitecture (arch); } - EmulateInstructionARM (const ArchSpec &arch, - void *baton, - ReadMemory read_mem_callback, - WriteMemory write_mem_callback, - ReadRegister read_reg_callback, - WriteRegister write_reg_callback) : - EmulateInstruction (lldb::eByteOrderLittle, // Byte order for ARM - 4, // Address size in byte - arch, - baton, - read_mem_callback, - write_mem_callback, - read_reg_callback, - write_reg_callback), - m_arm_isa (0), - m_opcode_mode (eModeInvalid), - m_opcode_cpsr (0), - m_it_session () +// EmulateInstructionARM (const ArchSpec &arch, +// bool ignore_conditions, +// void *baton, +// ReadMemory read_mem_callback, +// WriteMemory write_mem_callback, +// ReadRegister read_reg_callback, +// WriteRegister write_reg_callback) : +// EmulateInstruction (arch, +// ignore_conditions, +// baton, +// read_mem_callback, +// write_mem_callback, +// read_reg_callback, +// write_reg_callback), +// m_arm_isa (0), +// m_opcode_mode (eModeInvalid), +// m_opcode_cpsr (0), +// m_it_session () +// { +// } + + virtual bool + SupportsEmulatingIntructionsOfType (InstructionType inst_type) { + return SupportsEmulatingIntructionsOfTypeStatic (inst_type); } - - + virtual bool SetArchitecture (const ArchSpec &arch); @@ -145,14 +170,17 @@ ReadInstruction (); virtual bool - SetInstruction (const Opcode &insn_opcode, const Address &inst_addr); + SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target); virtual bool - EvaluateInstruction (); + EvaluateInstruction (uint32_t evaluate_options); virtual bool TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data); + virtual const char * + GetRegisterName (uint32_t reg_kind, uint32_t reg_num); + uint32_t ArchVersion(); @@ -340,10 +368,10 @@ static ARMOpcode* - GetARMOpcodeForInstruction (const uint32_t opcode); + GetARMOpcodeForInstruction (const uint32_t opcode, uint32_t isa_mask); static ARMOpcode* - GetThumbOpcodeForInstruction (const uint32_t opcode); + GetThumbOpcodeForInstruction (const uint32_t opcode, uint32_t isa_mask); // A8.6.123 PUSH bool @@ -948,6 +976,7 @@ uint32_t m_opcode_cpsr; uint32_t m_new_inst_cpsr; // This can get updated by the opcode. ITSession m_it_session; + bool m_ignore_conditions; }; } // namespace lldb_private Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Mon Apr 25 23:39:08 2011 @@ -187,11 +187,12 @@ } size_t -EmulationStateARM::ReadPseudoMemory (void *baton, - const EmulateInstruction::Context &context, - lldb::addr_t addr, - void *dst, - size_t length) +EmulationStateARM::ReadPseudoMemory (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + lldb::addr_t addr, + void *dst, + size_t length) { if (!baton) return 0; @@ -230,11 +231,12 @@ } size_t -EmulationStateARM::WritePseudoMemory (void *baton, - const EmulateInstruction::Context &context, - lldb::addr_t addr, - const void *dst, - size_t length) +EmulationStateARM::WritePseudoMemory (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + lldb::addr_t addr, + const void *dst, + size_t length) { if (!baton) return 0; @@ -250,10 +252,11 @@ } bool -EmulationStateARM::ReadPseudoRegister (void *baton, - uint32_t reg_kind, - uint32_t reg_num, - uint64_t ®_value) +EmulationStateARM::ReadPseudoRegister (EmulateInstruction *instruction, + void *baton, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t ®_value) { if (!baton) return false; @@ -284,11 +287,12 @@ } bool -EmulationStateARM::WritePseudoRegister (void *baton, - const EmulateInstruction::Context &context, - uint32_t reg_kind, - uint32_t reg_num, - uint64_t reg_value) +EmulationStateARM::WritePseudoRegister (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t reg_value) { if (!baton) return false; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h Mon Apr 25 23:39:08 2011 @@ -16,8 +16,6 @@ #include "lldb/Core/Opcode.h" #include "lldb/Interpreter/NamedOptionValue.h" -namespace lldb_private { - class EmulationStateARM { public: @@ -45,37 +43,41 @@ ClearPseudoMemory (); bool - LoadPseudoRegistersFromFrame (StackFrame &frame); + LoadPseudoRegistersFromFrame (lldb_private::StackFrame &frame); bool - LoadStateFromDictionary (OptionValueDictionary *test_data); + LoadStateFromDictionary (lldb_private::OptionValueDictionary *test_data); bool CompareState (EmulationStateARM &other_state); static size_t - ReadPseudoMemory (void *baton, - const EmulateInstruction::Context &context, + ReadPseudoMemory (lldb_private::EmulateInstruction *instruction, + void *baton, + const lldb_private::EmulateInstruction::Context &context, lldb::addr_t addr, void *dst, size_t length); static size_t - WritePseudoMemory (void *baton, - const EmulateInstruction::Context &context, + WritePseudoMemory (lldb_private::EmulateInstruction *instruction, + void *baton, + const lldb_private::EmulateInstruction::Context &context, lldb::addr_t addr, const void *dst, size_t length); static bool - ReadPseudoRegister (void *baton, + ReadPseudoRegister (lldb_private::EmulateInstruction *instruction, + void *baton, uint32_t reg_kind, uint32_t reg_num, uint64_t ®_value); static bool - WritePseudoRegister (void *baton, - const EmulateInstruction::Context &context, + WritePseudoRegister (lldb_private::EmulateInstruction *instruction, + void *baton, + const lldb_private::EmulateInstruction::Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value); @@ -97,7 +99,5 @@ DISALLOW_COPY_AND_ASSIGN (EmulationStateARM); }; - -} // namespace lldb_private #endif // lldb_EmulationStateARM_h_ Modified: lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h Mon Apr 25 23:39:08 2011 @@ -79,6 +79,15 @@ #define CPSR_Z_POS 30 #define CPSR_N_POS 31 +// CPSR mode definitions +#define CPSR_MODE_USR 0x10u +#define CPSR_MODE_FIQ 0x11u +#define CPSR_MODE_IRQ 0x12u +#define CPSR_MODE_SVC 0x13u +#define CPSR_MODE_ABT 0x17u +#define CPSR_MODE_UND 0x1bu +#define CPSR_MODE_SYS 0x1fu + // Masks for CPSR #define MASK_CPSR_MODE_MASK (0x0000001fu) #define MASK_CPSR_T (1u << CPSR_T_POS) Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Mon Apr 25 23:39:08 2011 @@ -143,16 +143,21 @@ { const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ()); const llvm::Triple::ArchType machine = target_arch.GetMachine(); - if (machine == llvm::Triple::x86_64 || machine == llvm::Triple::x86) + switch (machine) { - m_unwinder_ap.reset (new UnwindLLDB (*this)); - } + case llvm::Triple::x86_64: + case llvm::Triple::x86: + case llvm::Triple::arm: + case llvm::Triple::thumb: + m_unwinder_ap.reset (new UnwindLLDB (*this)); + break; + + default: #if defined(__APPLE__) - else - { - m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); - } + m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); #endif + break; + } } return m_unwinder_ap.get(); } Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Mon Apr 25 23:39:08 2011 @@ -12,16 +12,16 @@ #include "llvm-c/EnhancedDisassembly.h" #include "lldb/Core/Address.h" -#include "lldb/Core/Error.h" #include "lldb/Core/ArchSpec.h" +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/Error.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" -#include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" -#include "lldb/Target/UnwindAssembly.h" using namespace lldb; using namespace lldb_private; @@ -33,19 +33,108 @@ //----------------------------------------------------------------------------------------------- bool -UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) -{ +UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& range, + Thread& thread, + UnwindPlan& unwind_plan) +{ +#if 0 + UnwindPlan::Row row; + UnwindPlan::Row::RegisterLocation regloc; + + m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); + row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); + row.SetCFAOffset (2 * 8); + row.SetOffset (0); + + regloc.SetAtCFAPlusOffset (2 * -8); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); + regloc.SetAtCFAPlusOffset (1 * -8); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); + regloc.SetIsCFAPlusOffset (0); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); + + m_unwind_plan_sp->AppendRow (row); + m_unwind_plan_sp->SetSourceName ("x86_64 architectural default"); +#endif + + if (range.GetByteSize() > 0 && + range.GetBaseAddress().IsValid() && + m_inst_emulator_ap.get()) + { +#if 0 + Target &target = thread.GetProcess().GetTarget(); + const ArchSpec &target_arch = target.GetArchitecture(); + bool prefer_file_cache = true; + Error error; + DataBufferHeap data_buffer (range.GetByteSize(), 0); + if (target.ReadMemory (range.GetBaseAddress(), + prefer_file_cache, + data_buffer.GetBytes(), + data_buffer.GetByteSize(), + error) == data_buffer.GetByteSize()) + { + DataExtractor data (data_buffer.GetBytes(), + data_buffer.GetByteSize(), + target_arch.GetByteOrder(), + target_arch.GetAddressByteSize()); + } +#endif + StreamFile strm (stdout, false); + + ExecutionContext exe_ctx; + thread.CalculateExecutionContext(exe_ctx); + DisassemblerSP disasm_sp (Disassembler::DisassembleRange (m_arch, + NULL, + exe_ctx, + range)); + if (disasm_sp) + { + + m_range_ptr = ⦥ + m_thread_ptr = &thread; + m_unwind_plan_ptr = &unwind_plan; + + const uint32_t addr_byte_size = m_arch.GetAddressByteSize(); + const bool show_address = true; + const bool show_bytes = true; + const bool raw = false; + // Initialize the stack pointer with a known value. In the 32 bit case + // it will be 0x80000000, and in the 64 bit case 0x8000000000000000. + // We use the address byte size to be safe for any future addresss sizes + SetRegisterValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, (1ull << ((addr_byte_size * 8) - 1))); + + const InstructionList &inst_list = disasm_sp->GetInstructionList (); + const size_t num_instructions = inst_list.GetSize(); + for (size_t idx=0; idxDump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw); + strm.EOL(); + + m_inst_emulator_ap->SetInstruction (inst->GetOpcode(), inst->GetAddress(), exe_ctx.target); + m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions); + } + } + } + } return false; } bool -UnwindAssemblyInstEmulation::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) +UnwindAssemblyInstEmulation::GetFastUnwindPlan (AddressRange& func, + Thread& thread, + UnwindPlan &unwind_plan) { return false; } bool -UnwindAssemblyInstEmulation::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) +UnwindAssemblyInstEmulation::FirstNonPrologueInsn (AddressRange& func, + Target& target, + Thread* thread, + Address& first_non_prologue_insn) { return false; } @@ -53,6 +142,10 @@ UnwindAssembly * UnwindAssemblyInstEmulation::CreateInstance (const ArchSpec &arch) { + std::auto_ptr inst_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypePrologueEpilogue, NULL)); + // Make sure that all prologue instructions are handled + if (inst_emulator_ap.get()) + return new UnwindAssemblyInstEmulation (arch, inst_emulator_ap.release()); return NULL; } @@ -106,3 +199,120 @@ { return "Instruction emulation based unwind information."; } + + + +size_t +UnwindAssemblyInstEmulation::ReadMemory (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + lldb::addr_t addr, + void *dst, + size_t dst_len) +{ + //UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; + printf ("UnwindAssemblyInstEmulation::ReadMemory (context.type = %i, context.info_type = %i, addr = 0x%16.16llx, dst = %p, dst_len = %zu)\n", + context.type, + context.info_type, + addr, + dst, + dst_len); + return dst_len; +} + +size_t +UnwindAssemblyInstEmulation::WriteMemory (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + lldb::addr_t addr, + const void *dst, + size_t dst_len) +{ + // UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; + + DataExtractor data (dst, + dst_len, + instruction->GetArchitecture ().GetByteOrder(), + instruction->GetArchitecture ().GetAddressByteSize()); + StreamFile strm(stdout, false); + + strm.Printf ("UnwindAssemblyInstEmulation::WriteMemory (context.type = %i, context.info_type = %i, ", + context.type, + context.info_type); + data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0); + strm.EOL(); + return dst_len; +} + +bool +UnwindAssemblyInstEmulation::ReadRegister (EmulateInstruction *instruction, + void *baton, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t ®_value) +{ + UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; + const char *reg_name = instruction->GetRegisterName (reg_kind, reg_num); + + reg_value = inst_emulator->GetRegisterValue (reg_kind, reg_num); + + printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => value = 0x%16.16llx\n", reg_name, reg_value); + + return true; +} + +bool +UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t reg_value) +{ + UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; + const char *reg_name = instruction->GetRegisterName (reg_kind, reg_num); + + printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = 0x%16.16llx, context.type = %i, context.info_type = %i)\n", + reg_name, + reg_value, + context.type, + context.info_type); + + inst_emulator->SetRegisterValue (reg_kind, reg_num, reg_value); + + switch (context.type) + { + case EmulateInstruction::eContextInvalid: + case EmulateInstruction::eContextReadOpcode: + case EmulateInstruction::eContextImmediate: + case EmulateInstruction::eContextAdjustBaseRegister: + case EmulateInstruction::eContextRegisterPlusOffset: + case EmulateInstruction::eContextAdjustPC: + case EmulateInstruction::eContextRegisterStore: + case EmulateInstruction::eContextRegisterLoad: + case EmulateInstruction::eContextRelativeBranchImmediate: + case EmulateInstruction::eContextAbsoluteBranchRegister: + case EmulateInstruction::eContextSupervisorCall: + case EmulateInstruction::eContextTableBranchReadMemory: + case EmulateInstruction::eContextWriteRegisterRandomBits: + case EmulateInstruction::eContextWriteMemoryRandomBits: + case EmulateInstruction::eContextMultiplication: + case EmulateInstruction::eContextAddition: + case EmulateInstruction::eContextSubtraction: + case EmulateInstruction::eContextAdvancePC: + case EmulateInstruction::eContextReturnFromException: + break; + + case EmulateInstruction::eContextPushRegisterOnStack: + break; + + case EmulateInstruction::eContextPopRegisterOffStack: + break; + + case EmulateInstruction::eContextAdjustStackPointer: + break; + } + return true; +} + + Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Mon Apr 25 23:39:08 2011 @@ -11,8 +11,8 @@ #define liblldb_UnwindAssemblyInstEmulation_h_ #include "lldb/lldb-private.h" +#include "lldb/Core/EmulateInstruction.h" #include "lldb/Target/UnwindAssembly.h" -#include "lldb/Target/Thread.h" class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly { @@ -43,7 +43,6 @@ static lldb_private::UnwindAssembly * CreateInstance (const lldb_private::ArchSpec &arch); - //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ @@ -69,14 +68,83 @@ GetPluginVersion(); private: + + static size_t + ReadMemory (lldb_private::EmulateInstruction *instruction, + void *baton, + const lldb_private::EmulateInstruction::Context &context, + lldb::addr_t addr, + void *dst, + size_t length); + + static size_t + WriteMemory (lldb_private::EmulateInstruction *instruction, + void *baton, + const lldb_private::EmulateInstruction::Context &context, + lldb::addr_t addr, + const void *dst, + size_t length); + + static bool + ReadRegister (lldb_private::EmulateInstruction *instruction, + void *baton, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t ®_value); + + static bool + WriteRegister (lldb_private::EmulateInstruction *instruction, + void *baton, + const lldb_private::EmulateInstruction::Context &context, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t reg_value); + // Call CreateInstance to get an instance of this class - UnwindAssemblyInstEmulation(int cpu) : - lldb_private::UnwindAssembly(), m_cpu(cpu) + UnwindAssemblyInstEmulation (const lldb_private::ArchSpec &arch, + lldb_private::EmulateInstruction *inst_emulator) : + UnwindAssembly (arch), + m_inst_emulator_ap (inst_emulator), + m_range_ptr (NULL), + m_thread_ptr (NULL), + m_unwind_plan_ptr (NULL) + { + if (m_inst_emulator_ap.get()) + { + m_inst_emulator_ap->SetBaton (this); + m_inst_emulator_ap->SetCallbacks (ReadMemory, WriteMemory, ReadRegister, WriteRegister); + } + } + + static uint64_t + MakeRegisterKindValuePair (uint32_t reg_kind, uint32_t reg_num) + { + return (uint64_t)reg_kind << 32 | reg_num; + } + + void + SetRegisterValue (uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value) + { + m_register_values[MakeRegisterKindValuePair (reg_kind, reg_num)] = reg_value; + } + + uint64_t + GetRegisterValue (uint32_t reg_kind, uint32_t reg_num) { + const uint64_t reg_id = MakeRegisterKindValuePair (reg_kind, reg_num); + RegisterValueMap::const_iterator pos = m_register_values.find(reg_id); + if (pos != m_register_values.end()) + return pos->second; + return (uint64_t)reg_kind << 24 | (uint64_t)reg_num; } - int m_cpu; + std::auto_ptr m_inst_emulator_ap; + lldb_private::AddressRange* m_range_ptr; + lldb_private::Thread* m_thread_ptr; + lldb_private::UnwindPlan* m_unwind_plan_ptr; + typedef std::map RegisterValueMap; + RegisterValueMap m_register_values; }; #endif // liblldb_UnwindAssemblyInstEmulation_h_ Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Mon Apr 25 23:39:08 2011 @@ -818,6 +818,17 @@ // UnwindAssemblyParser_x86 method definitions //----------------------------------------------------------------------------------------------- +UnwindAssembly_x86::UnwindAssembly_x86 (const ArchSpec &arch, int cpu) : + lldb_private::UnwindAssembly(arch), + m_cpu(cpu) +{ +} + + +UnwindAssembly_x86::~UnwindAssembly_x86 () +{ +} + bool UnwindAssembly_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) { @@ -844,9 +855,9 @@ { const llvm::Triple::ArchType cpu = arch.GetMachine (); if (cpu == llvm::Triple::x86) - return new UnwindAssembly_x86 (k_i386); + return new UnwindAssembly_x86 (arch, k_i386); else if (cpu == llvm::Triple::x86_64) - return new UnwindAssembly_x86 (k_x86_64); + return new UnwindAssembly_x86 (arch, k_x86_64); return NULL; } Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h Mon Apr 25 23:39:08 2011 @@ -12,25 +12,29 @@ #include "lldb/lldb-private.h" #include "lldb/Target/UnwindAssembly.h" -#include "lldb/Target/Thread.h" -namespace lldb_private { - class UnwindAssembly_x86 : public lldb_private::UnwindAssembly { public: - ~UnwindAssembly_x86 () { } + ~UnwindAssembly_x86 (); virtual bool - GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, lldb_private::Thread& thread, UnwindPlan& unwind_plan); + GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func, + lldb_private::Thread& thread, + lldb_private::UnwindPlan& unwind_plan); virtual bool - GetFastUnwindPlan (AddressRange& func, lldb_private::Thread& thread, UnwindPlan &unwind_plan); + GetFastUnwindPlan (lldb_private::AddressRange& func, + lldb_private::Thread& thread, + lldb_private::UnwindPlan &unwind_plan); // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). virtual bool - FirstNonPrologueInsn (AddressRange& func, lldb_private::Target& target, lldb_private::Thread* thread, Address& first_non_prologue_insn); + FirstNonPrologueInsn (lldb_private::AddressRange& func, + lldb_private::Target& target, + lldb_private::Thread* thread, + lldb_private::Address& first_non_prologue_insn); static lldb_private::UnwindAssembly * CreateInstance (const lldb_private::ArchSpec &arch); @@ -61,13 +65,10 @@ GetPluginVersion(); private: - UnwindAssembly_x86(int cpu) : - lldb_private::UnwindAssembly(), m_cpu(cpu) { } // Call CreateInstance instead. + UnwindAssembly_x86 (const lldb_private::ArchSpec &arch, int cpu); int m_cpu; }; -} // namespace lldb_private - #endif // liblldb_UnwindAssembly_x86_h_ Modified: lldb/trunk/source/Target/ExecutionContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ExecutionContext.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Target/ExecutionContext.cpp (original) +++ lldb/trunk/source/Target/ExecutionContext.cpp Mon Apr 25 23:39:08 2011 @@ -6,12 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// -// - -// -//===----------------------------------------------------------------------===// - #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ExecutionContextScope.h" Modified: lldb/trunk/source/Target/UnwindAssembly.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnwindAssembly.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Target/UnwindAssembly.cpp (original) +++ lldb/trunk/source/Target/UnwindAssembly.cpp Mon Apr 25 23:39:08 2011 @@ -31,7 +31,8 @@ return NULL; } -UnwindAssembly::UnwindAssembly () +UnwindAssembly::UnwindAssembly (const ArchSpec &arch) : + m_arch (arch) { } Added: lldb/trunk/source/Utility/ARM_DWARF_Registers.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.c?rev=130189&view=auto ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.c (added) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.c Mon Apr 25 23:39:08 2011 @@ -0,0 +1,183 @@ +//===-- ARM_DWARF_Registers.c -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "ARM_DWARF_Registers.h" + +const char * +GetARMDWARFRegisterName (unsigned reg_num) +{ + switch (reg_num) + { + case dwarf_r0: return "r0"; + case dwarf_r1: return "r1"; + case dwarf_r2: return "r2"; + case dwarf_r3: return "r3"; + case dwarf_r4: return "r4"; + case dwarf_r5: return "r5"; + case dwarf_r6: return "r6"; + case dwarf_r7: return "r7"; + case dwarf_r8: return "r8"; + case dwarf_r9: return "r9"; + case dwarf_r10: return "r10"; + case dwarf_r11: return "r11"; + case dwarf_r12: return "r12"; + case dwarf_sp: return "sp"; + case dwarf_lr: return "lr"; + case dwarf_pc: return "pc"; + case dwarf_cpsr:return "cpsr"; + + case dwarf_s0: return "s0"; + case dwarf_s1: return "s1"; + case dwarf_s2: return "s2"; + case dwarf_s3: return "s3"; + case dwarf_s4: return "s4"; + case dwarf_s5: return "s5"; + case dwarf_s6: return "s6"; + case dwarf_s7: return "s7"; + case dwarf_s8: return "s8"; + case dwarf_s9: return "s9"; + case dwarf_s10: return "s10"; + case dwarf_s11: return "s11"; + case dwarf_s12: return "s12"; + case dwarf_s13: return "s13"; + case dwarf_s14: return "s14"; + case dwarf_s15: return "s15"; + case dwarf_s16: return "s16"; + case dwarf_s17: return "s17"; + case dwarf_s18: return "s18"; + case dwarf_s19: return "s19"; + case dwarf_s20: return "s20"; + case dwarf_s21: return "s21"; + case dwarf_s22: return "s22"; + case dwarf_s23: return "s23"; + case dwarf_s24: return "s24"; + case dwarf_s25: return "s25"; + case dwarf_s26: return "s26"; + case dwarf_s27: return "s27"; + case dwarf_s28: return "s28"; + case dwarf_s29: return "s29"; + case dwarf_s30: return "s30"; + case dwarf_s31: return "s31"; + + // FPA Registers 0-7 + case dwarf_f0: return "f0"; + case dwarf_f1: return "f1"; + case dwarf_f2: return "f2"; + case dwarf_f3: return "f3"; + case dwarf_f4: return "f4"; + case dwarf_f5: return "f5"; + case dwarf_f6: return "f6"; + case dwarf_f7: return "f7"; + + // Intel wireless MMX general purpose registers 0???7 + // XScale accumulator register 0???7 (they do overlap with wCGR0 - wCGR7) + case dwarf_wCGR0: return "wCGR0/ACC0"; + case dwarf_wCGR1: return "wCGR1/ACC1"; + case dwarf_wCGR2: return "wCGR2/ACC2"; + case dwarf_wCGR3: return "wCGR3/ACC3"; + case dwarf_wCGR4: return "wCGR4/ACC4"; + case dwarf_wCGR5: return "wCGR5/ACC5"; + case dwarf_wCGR6: return "wCGR6/ACC6"; + case dwarf_wCGR7: return "wCGR7/ACC7"; + + // Intel wireless MMX data registers 0???15 + case dwarf_wR0: return "wR0"; + case dwarf_wR1: return "wR1"; + case dwarf_wR2: return "wR2"; + case dwarf_wR3: return "wR3"; + case dwarf_wR4: return "wR4"; + case dwarf_wR5: return "wR5"; + case dwarf_wR6: return "wR6"; + case dwarf_wR7: return "wR7"; + case dwarf_wR8: return "wR8"; + case dwarf_wR9: return "wR9"; + case dwarf_wR10: return "wR10"; + case dwarf_wR11: return "wR11"; + case dwarf_wR12: return "wR12"; + case dwarf_wR13: return "wR13"; + case dwarf_wR14: return "wR14"; + case dwarf_wR15: return "wR15"; + + case dwarf_spsr: return "spsr"; + case dwarf_spsr_fiq: return "spsr_fiq"; + case dwarf_spsr_irq: return "spsr_irq"; + case dwarf_spsr_abt: return "spsr_abt"; + case dwarf_spsr_und: return "spsr_und"; + case dwarf_spsr_svc: return "spsr_svc"; + + case dwarf_r8_usr: return "r8_usr"; + case dwarf_r9_usr: return "r9_usr"; + case dwarf_r10_usr: return "r10_usr"; + case dwarf_r11_usr: return "r11_usr"; + case dwarf_r12_usr: return "r12_usr"; + case dwarf_r13_usr: return "r13_usr"; + case dwarf_r14_usr: return "r14_usr"; + case dwarf_r8_fiq: return "r8_fiq"; + case dwarf_r9_fiq: return "r9_fiq"; + case dwarf_r10_fiq: return "r10_fiq"; + case dwarf_r11_fiq: return "r11_fiq"; + case dwarf_r12_fiq: return "r12_fiq"; + case dwarf_r13_fiq: return "r13_fiq"; + case dwarf_r14_fiq: return "r14_fiq"; + case dwarf_r13_irq: return "r13_irq"; + case dwarf_r14_irq: return "r14_irq"; + case dwarf_r13_abt: return "r13_abt"; + case dwarf_r14_abt: return "r14_abt"; + case dwarf_r13_und: return "r13_und"; + case dwarf_r14_und: return "r14_und"; + case dwarf_r13_svc: return "r13_svc"; + case dwarf_r14_svc: return "r14_svc"; + + // Intel wireless MMX control register in co-processor 0???7 + case dwarf_wC0: return "wC0"; + case dwarf_wC1: return "wC1"; + case dwarf_wC2: return "wC2"; + case dwarf_wC3: return "wC3"; + case dwarf_wC4: return "wC4"; + case dwarf_wC5: return "wC5"; + case dwarf_wC6: return "wC6"; + case dwarf_wC7: return "wC7"; + + // VFP-v3/Neon + case dwarf_d0: return "d0"; + case dwarf_d1: return "d1"; + case dwarf_d2: return "d2"; + case dwarf_d3: return "d3"; + case dwarf_d4: return "d4"; + case dwarf_d5: return "d5"; + case dwarf_d6: return "d6"; + case dwarf_d7: return "d7"; + case dwarf_d8: return "d8"; + case dwarf_d9: return "d9"; + case dwarf_d10: return "d10"; + case dwarf_d11: return "d11"; + case dwarf_d12: return "d12"; + case dwarf_d13: return "d13"; + case dwarf_d14: return "d14"; + case dwarf_d15: return "d15"; + case dwarf_d16: return "d16"; + case dwarf_d17: return "d17"; + case dwarf_d18: return "d18"; + case dwarf_d19: return "d19"; + case dwarf_d20: return "d20"; + case dwarf_d21: return "d21"; + case dwarf_d22: return "d22"; + case dwarf_d23: return "d23"; + case dwarf_d24: return "d24"; + case dwarf_d25: return "d25"; + case dwarf_d26: return "d26"; + case dwarf_d27: return "d27"; + case dwarf_d28: return "d28"; + case dwarf_d29: return "d29"; + case dwarf_d30: return "d30"; + case dwarf_d31: return "d31"; + } + return 0; +} + Modified: lldb/trunk/source/Utility/ARM_DWARF_Registers.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.h?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.h (original) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.h Mon Apr 25 23:39:08 2011 @@ -186,5 +186,16 @@ dwarf_d31 }; +#if defined(__cplusplus) +extern "C" { +#endif + +const char * +GetARMDWARFRegisterName (unsigned reg_num); + +#if defined(__cplusplus) +} +#endif + #endif // utility_ARM_DWARF_Registers_h_ Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=130189&r1=130188&r2=130189&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Apr 25 23:39:08 2011 @@ -83,8 +83,8 @@ ObjectFileELF::Initialize(); SymbolFileDWARF::Initialize(); SymbolFileSymtab::Initialize(); - UnwindAssembly_x86::Initialize(); UnwindAssemblyInstEmulation::Initialize(); + UnwindAssembly_x86::Initialize(); ArchDefaultUnwindPlan_x86_64::Initialize(); ArchDefaultUnwindPlan_i386::Initialize(); ArchVolatileRegs_x86::Initialize(); From johnny.chen at apple.com Tue Apr 26 13:51:57 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 18:51:57 -0000 Subject: [Lldb-commits] [lldb] r130227 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110426185157.93B142A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 13:51:57 2011 New Revision: 130227 URL: http://llvm.org/viewvc/llvm-project?rev=130227&view=rev Log: Modify EmulateInstructionARM::SetArchitecture() to treat "arm" and "thumb" as wild card architectures for now, in order to fix the test failure for the 'arm_emulation' directory. There might be a better way. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=130227&r1=130226&r2=130227&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Apr 26 13:51:57 2011 @@ -12636,6 +12636,8 @@ else if (0 == ::strcasecmp(arch_cstr, "armv6t2")) m_arm_isa = ARMv6T2; else if (0 == ::strcasecmp(arch_cstr, "armv7")) m_arm_isa = ARMv7; else if (0 == ::strcasecmp(arch_cstr, "armv8")) m_arm_isa = ARMv8; + else if (0 == ::strcasecmp(arch_cstr, "arm")) m_arm_isa = ARMvAll; + else if (0 == ::strcasecmp(arch_cstr, "thumb")) m_arm_isa = ARMvAll; } return m_arm_isa != 0; } From johnny.chen at apple.com Tue Apr 26 15:45:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 20:45:00 -0000 Subject: [Lldb-commits] [lldb] r130240 - /lldb/trunk/test/dotest.py Message-ID: <20110426204500.912342A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 15:45:00 2011 New Revision: 130240 URL: http://llvm.org/viewvc/llvm-project?rev=130240&view=rev Log: Simplify the parsing of ARCH and Compiler specs. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=130240&r1=130239&r2=130240&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Apr 26 15:45:00 2011 @@ -325,22 +325,14 @@ index += 1 if index >= len(sys.argv) or sys.argv[index].startswith('-'): usage() - archSpec = sys.argv[index] - if archSpec.find('^') != -1: - archs = archSpec.split('^') - else: - os.environ["ARCH"] = archSpec + archs = sys.argv[index].split('^') index += 1 elif sys.argv[index].startswith('-C'): # Increment by 1 to fetch the CC spec. index += 1 if index >= len(sys.argv) or sys.argv[index].startswith('-'): usage() - ccSpec = sys.argv[index] - if ccSpec.find('^') != -1: - compilers = ccSpec.split('^') - else: - os.environ["CC"] = ccSpec + compilers = sys.argv[index].split('^') index += 1 elif sys.argv[index].startswith('-D'): dumpSysPath = True From johnny.chen at apple.com Tue Apr 26 17:53:38 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 22:53:38 -0000 Subject: [Lldb-commits] [lldb] r130251 - in /lldb/trunk/test: dotest.py lldbutil.py Message-ID: <20110426225338.54F4A2A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 17:53:38 2011 New Revision: 130251 URL: http://llvm.org/viewvc/llvm-project?rev=130251&view=rev Log: Docstring changees. Modified: lldb/trunk/test/dotest.py lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=130251&r1=130250&r2=130251&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Apr 26 17:53:38 2011 @@ -24,10 +24,11 @@ import unittest2 def is_exe(fpath): + """Return true if fpath is an executable.""" return os.path.isfile(fpath) and os.access(fpath, os.X_OK) -# Find the full path to a program, or return None. def which(program): + """Find the full path to a program; return None otherwise.""" fpath, fname = os.path.split(program) if fpath: if is_exe(program): Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130251&r1=130250&r2=130251&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue Apr 26 17:53:38 2011 @@ -6,11 +6,16 @@ import os, sys import StringIO +# ==================================================== +# Utilities for locating/checking executable programs. +# ==================================================== + def is_exe(fpath): + """Return true if fpath is an executable.""" return os.path.isfile(fpath) and os.access(fpath, os.X_OK) def which(program): - """Find the full path to a program, or return None.""" + """Find the full path to a program; return None otherwise.""" fpath, fname = os.path.split(program) if fpath: if is_exe(program): From johnny.chen at apple.com Tue Apr 26 18:07:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 23:07:40 -0000 Subject: [Lldb-commits] [lldb] r130252 - /lldb/trunk/test/lldbutil.py Message-ID: <20110426230740.51C062A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 18:07:40 2011 New Revision: 130252 URL: http://llvm.org/viewvc/llvm-project?rev=130252&view=rev Log: Update comment. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130252&r1=130251&r2=130252&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue Apr 26 18:07:40 2011 @@ -6,9 +6,9 @@ import os, sys import StringIO -# ==================================================== -# Utilities for locating/checking executable programs. -# ==================================================== +# =================================================== +# Utilities for locating/checking executable programs +# =================================================== def is_exe(fpath): """Return true if fpath is an executable.""" From johnny.chen at apple.com Tue Apr 26 18:10:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 23:10:15 -0000 Subject: [Lldb-commits] [lldb] r130253 - /lldb/trunk/test/lldbutil.py Message-ID: <20110426231015.E8D8D2A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 18:10:15 2011 New Revision: 130253 URL: http://llvm.org/viewvc/llvm-project?rev=130253&view=rev Log: Docstring. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130253&r1=130252&r2=130253&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue Apr 26 18:10:15 2011 @@ -11,11 +11,11 @@ # =================================================== def is_exe(fpath): - """Return true if fpath is an executable.""" + """Returns True if fpath is an executable.""" return os.path.isfile(fpath) and os.access(fpath, os.X_OK) def which(program): - """Find the full path to a program; return None otherwise.""" + """Returns the full path to a program; None otherwise.""" fpath, fname = os.path.split(program) if fpath: if is_exe(program): From johnny.chen at apple.com Tue Apr 26 18:10:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 23:10:52 -0000 Subject: [Lldb-commits] [lldb] r130254 - /lldb/trunk/test/dotest.py Message-ID: <20110426231052.189BE2A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 18:10:51 2011 New Revision: 130254 URL: http://llvm.org/viewvc/llvm-project?rev=130254&view=rev Log: Docstring. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=130254&r1=130253&r2=130254&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Apr 26 18:10:51 2011 @@ -24,11 +24,11 @@ import unittest2 def is_exe(fpath): - """Return true if fpath is an executable.""" + """Returns true if fpath is an executable.""" return os.path.isfile(fpath) and os.access(fpath, os.X_OK) def which(program): - """Find the full path to a program; return None otherwise.""" + """Returns the full path to a program; None otherwise.""" fpath, fname = os.path.split(program) if fpath: if is_exe(program): From gclayton at apple.com Tue Apr 26 18:48:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 26 Apr 2011 23:48:45 -0000 Subject: [Lldb-commits] [lldb] r130256 - in /lldb/trunk: include/lldb/Core/ include/lldb/Symbol/ lldb.xcodeproj/ source/Core/ source/Plugins/Instruction/ARM/ source/Plugins/Process/gdb-remote/ source/Plugins/UnwindAssembly/InstEmulation/ source/Symbol/ source/Utility/ Message-ID: <20110426234846.4F4AD2A6C12D@llvm.org> Author: gclayton Date: Tue Apr 26 18:48:45 2011 New Revision: 130256 URL: http://llvm.org/viewvc/llvm-project?rev=130256&view=rev Log: Got the EmulateInstruction CFI code a lot closer to producing CFI data. Switch the EmulateInstruction to use the standard RegisterInfo structure that is defined in the lldb private types intead of passing the reg kind and reg num everywhere. EmulateInstruction subclasses also need to provide RegisterInfo structs given a reg kind and reg num. This eliminates the need for the GetRegisterName() virtual function and allows more complete information to be passed around in the read/write register callbacks. Subclasses should always provide RegiterInfo structs with the generic register info filled in as well as at least one kind of register number in the RegisterInfo.kinds[] array. Added: lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp - copied, changed from r130203, lldb/trunk/source/Utility/ARM_DWARF_Registers.c Removed: lldb/trunk/source/Utility/ARM_DWARF_Registers.c Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/include/lldb/Symbol/UnwindPlan.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/trunk/source/Symbol/UnwindPlan.cpp lldb/trunk/source/Utility/ARM_DWARF_Registers.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Apr 26 18:48:45 2011 @@ -12,6 +12,7 @@ #include +#include "lldb/lldb-private.h" #include "lldb/lldb-public.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" @@ -145,11 +146,7 @@ // Used when random bits are written to memory eContextWriteMemoryRandomBits, - eContextMultiplication, - - eContextAddition, - - eContextSubtraction, + eContextArithmetic, eContextAdvancePC, @@ -167,26 +164,12 @@ eInfoTypeImmediate, eInfoTypeImmediateSigned, eInfoTypeAddress, - eInfoTypeModeAndImmediate, - eInfoTypeModeAndImmediateSigned, - eInfoTypeMode, + eInfoTypeISAAndImmediate, + eInfoTypeISAAndImmediateSigned, + eInfoTypeISA, eInfoTypeNoArgs } InfoType; - - struct Register - { - uint32_t kind; - uint32_t num; - - void - SetRegister (uint32_t reg_kind, uint32_t reg_num) - { - kind = reg_kind; - num = reg_num; - } - }; - struct Context { ContextType type; @@ -195,64 +178,63 @@ { struct RegisterPlusOffset { - Register reg; // base register + RegisterInfo reg; // base register int64_t signed_offset; // signed offset added to base register } RegisterPlusOffset; struct RegisterPlusIndirectOffset { - Register base_reg; // base register number - Register offset_reg; // offset register kind + RegisterInfo base_reg; // base register number + RegisterInfo offset_reg; // offset register kind } RegisterPlusIndirectOffset; struct RegisterToRegisterPlusOffset { - Register data_reg; // source/target register for data - Register base_reg; // base register for address calculation - int64_t offset; // offset for address calculation + RegisterInfo data_reg; // source/target register for data + RegisterInfo base_reg; // base register for address calculation + int64_t offset; // offset for address calculation } RegisterToRegisterPlusOffset; struct RegisterToRegisterPlusIndirectOffset { - Register base_reg; // base register for address calculation - Register offset_reg; // offset register for address calculation - Register data_reg; // source/target register for data + RegisterInfo base_reg; // base register for address calculation + RegisterInfo offset_reg; // offset register for address calculation + RegisterInfo data_reg; // source/target register for data } RegisterToRegisterPlusIndirectOffset; struct RegisterRegisterOperands { - Register operand1; // register containing first operand for binary op - Register operand2; // register containing second operand for binary op + RegisterInfo operand1; // register containing first operand for binary op + RegisterInfo operand2; // register containing second operand for binary op } RegisterRegisterOperands; - int64_t signed_offset; // signed offset by which to adjust self (for registers only) - - Register reg; // plain register + int64_t signed_offset; // signed offset by which to adjust self (for registers only) - uint64_t immediate; // immediate value + RegisterInfo reg; // plain register - int64_t signed_immediate; // signed immediate value + uint64_t unsigned_immediate;// unsigned immediate value + int64_t signed_immediate; // signed immediate value - lldb::addr_t address; // direct address + lldb::addr_t address; // direct address - struct ModeAndImmediate + struct ISAAndImmediate { - uint32_t mode; // eModeARM or eModeThumb - uint32_t data_value; // immdiate data - } ModeAndImmediate; + uint32_t isa; + uint32_t unsigned_data32; // immdiate data + } ISAAndImmediate; - struct ModeAndImmediateSigned + struct ISAAndImmediateSigned { - uint32_t mode; // eModeARM or eModeThumb - int32_t signed_data_value; // signed immdiate data - } ModeAndImmediateSigned; + uint32_t isa; + int32_t signed_data32; // signed immdiate data + } ISAAndImmediateSigned; - uint32_t mode; // eModeARM or eModeThumb + uint32_t isa; } info; void - SetRegisterPlusOffset (Register base_reg, + SetRegisterPlusOffset (RegisterInfo base_reg, int64_t signed_offset) { info_type = eInfoTypeRegisterPlusOffset; @@ -261,8 +243,8 @@ } void - SetRegisterPlusIndirectOffset (Register base_reg, - Register offset_reg) + SetRegisterPlusIndirectOffset (RegisterInfo base_reg, + RegisterInfo offset_reg) { info_type = eInfoTypeRegisterPlusIndirectOffset; info.RegisterPlusIndirectOffset.base_reg = base_reg; @@ -270,8 +252,8 @@ } void - SetRegisterToRegisterPlusOffset (Register data_reg, - Register base_reg, + SetRegisterToRegisterPlusOffset (RegisterInfo data_reg, + RegisterInfo base_reg, int64_t offset) { info_type = eInfoTypeRegisterToRegisterPlusOffset; @@ -281,9 +263,9 @@ } void - SetRegisterToRegisterPlusIndirectOffset (Register base_reg, - Register offset_reg, - Register data_reg) + SetRegisterToRegisterPlusIndirectOffset (RegisterInfo base_reg, + RegisterInfo offset_reg, + RegisterInfo data_reg) { info_type = eInfoTypeRegisterToRegisterPlusIndirectOffset; info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg; @@ -292,8 +274,8 @@ } void - SetRegisterRegisterOperands (Register op1_reg, - Register op2_reg) + SetRegisterRegisterOperands (RegisterInfo op1_reg, + RegisterInfo op2_reg) { info_type = eInfoTypeRegisterRegisterOperands; info.RegisterRegisterOperands.operand1 = op1_reg; @@ -308,7 +290,7 @@ } void - SetRegister (Register reg) + SetRegister (RegisterInfo reg) { info_type = eInfoTypeRegister; info.reg = reg; @@ -318,7 +300,7 @@ SetImmediate (uint64_t immediate) { info_type = eInfoTypeImmediate; - info.immediate = immediate; + info.unsigned_immediate = immediate; } void @@ -335,26 +317,26 @@ info.address = address; } void - SetModeAndImmediate (uint32_t mode, uint32_t data_value) + SetISAAndImmediate (uint32_t isa, uint32_t data) { - info_type = eInfoTypeModeAndImmediate; - info.ModeAndImmediate.mode = mode; - info.ModeAndImmediate.data_value = data_value; + info_type = eInfoTypeISAAndImmediate; + info.ISAAndImmediate.isa = isa; + info.ISAAndImmediate.unsigned_data32 = data; } void - SetModeAndImmediateSigned (uint32_t mode, int32_t signed_data_value) + SetISAAndImmediateSigned (uint32_t isa, int32_t data) { - info_type = eInfoTypeModeAndImmediateSigned; - info.ModeAndImmediateSigned.mode = mode; - info.ModeAndImmediateSigned.signed_data_value = signed_data_value; + info_type = eInfoTypeISAAndImmediateSigned; + info.ISAAndImmediateSigned.isa = isa; + info.ISAAndImmediateSigned.signed_data32 = data; } void - SetMode (uint32_t mode) + SetISA (uint32_t isa) { - info_type = eInfoTypeMode; - info.mode = mode; + info_type = eInfoTypeISA; + info.isa = isa; } void @@ -362,12 +344,13 @@ { info_type = eInfoTypeNoArgs; } - + + void + Dump (FILE *fh, + EmulateInstruction *instruction) const; + }; - static void - PrintContext (const char *context_type, const Context &context); - typedef size_t (*ReadMemory) (EmulateInstruction *instruction, void *baton, const Context &context, @@ -384,15 +367,13 @@ typedef bool (*ReadRegister) (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value); typedef bool (*WriteRegister) (EmulateInstruction *instruction, void *baton, const Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value); EmulateInstruction (const ArchSpec &arch); @@ -418,14 +399,18 @@ virtual bool TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0; - virtual const char * - GetRegisterName (uint32_t reg_kind, uint32_t reg_num) = 0; + virtual bool + GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num, RegisterInfo ®_info) = 0; + //---------------------------------------------------------------------- // Optional overrides //---------------------------------------------------------------------- virtual bool SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target); - + + virtual bool + CreateFunctionEntryUnwind (UnwindPlan &unwind_plan); + static const char * TranslateRegister (uint32_t reg_kind, uint32_t reg_num, std::string ®_name); @@ -435,10 +420,20 @@ uint64_t fail_value, bool *success_ptr); + uint64_t + ReadRegisterUnsigned (const RegisterInfo ®_info, + uint64_t fail_value, + bool *success_ptr); + bool WriteRegisterUnsigned (const Context &context, uint32_t reg_kind, - uint32_t reg_num, + uint32_t reg_num, + uint64_t reg_value); + + bool + WriteRegisterUnsigned (const Context &context, + const RegisterInfo ®_info, uint64_t reg_value); uint64_t @@ -498,8 +493,7 @@ static bool ReadRegisterFrame (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value); @@ -507,8 +501,7 @@ WriteRegisterFrame (EmulateInstruction *instruction, void *baton, const Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value); static size_t @@ -530,8 +523,7 @@ static bool ReadRegisterDefault (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value); @@ -539,8 +531,7 @@ WriteRegisterDefault (EmulateInstruction *instruction, void *baton, const Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value); void @@ -563,7 +554,15 @@ void SetWriteRegCallback (WriteRegister write_reg_callback); - + + static bool + GetBestRegisterKindAndNumber (const RegisterInfo ®_info, + uint32_t ®_kind, + uint32_t ®_num); + + static uint32_t + GetInternalRegisterNumber (RegisterContext *reg_ctx, + const RegisterInfo ®_info); protected: ArchSpec m_arch; @@ -574,6 +573,9 @@ WriteRegister m_write_reg_callback; lldb::addr_t m_opcode_pc; Opcode m_opcode; + + +private: //------------------------------------------------------------------ // For EmulateInstruction only //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Symbol/UnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindPlan.h?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindPlan.h (original) +++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h Tue Apr 26 18:48:45 2011 @@ -59,7 +59,11 @@ isDWARFExpression // reg = eval(dwarf_expr) }; - RegisterLocation() : m_type(unspecified), m_location() { } + RegisterLocation() : + m_type(unspecified), + m_location() + { + } bool operator == (const RegisterLocation& rhs) const; @@ -259,6 +263,15 @@ int GetRowCount () const; + void + Clear() + { + m_row_list.clear(); + m_plan_valid_address_range.Clear(); + m_register_kind = UINT32_MAX; + m_source_name.Clear(); + } + private: typedef std::vector collection; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Apr 26 18:48:45 2011 @@ -404,7 +404,7 @@ 26DE20611161902700A093E2 /* SBBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20601161902600A093E2 /* SBBlock.cpp */; }; 26DE20631161904200A093E2 /* SBLineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20621161904200A093E2 /* SBLineEntry.cpp */; }; 26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; }; - 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.c in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.c */; }; + 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */; }; 26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; }; 26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; }; 26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; }; @@ -1044,7 +1044,7 @@ 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMacOSXFrameBackchain.h; path = Utility/RegisterContextMacOSXFrameBackchain.h; sourceTree = ""; }; 26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCallbacks.h; path = include/lldb/Symbol/ClangExternalASTSourceCallbacks.h; sourceTree = ""; }; 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCallbacks.cpp; path = source/Symbol/ClangExternalASTSourceCallbacks.cpp; sourceTree = ""; }; - 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ARM_DWARF_Registers.c; path = source/Utility/ARM_DWARF_Registers.c; sourceTree = ""; }; + 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ARM_DWARF_Registers.cpp; path = source/Utility/ARM_DWARF_Registers.cpp; sourceTree = ""; }; 26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; }; 26F5C27210F3D9E4009D5894 /* lldb-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "lldb-Info.plist"; path = "tools/driver/lldb-Info.plist"; sourceTree = ""; }; 26F5C27310F3D9E4009D5894 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = tools/driver/Driver.cpp; sourceTree = ""; }; @@ -1763,7 +1763,7 @@ 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */, 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */, 26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */, - 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.c */, + 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */, 26F996A8119B79C300412154 /* ARM_GCC_Registers.h */, 2660D9F611922A1300958FBD /* StringExtractor.cpp */, 2660D9F711922A1300958FBD /* StringExtractor.h */, @@ -3234,7 +3234,7 @@ 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */, 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */, 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */, - 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.c in Sources */, + 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Tue Apr 26 18:48:45 2011 @@ -16,13 +16,12 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/Endian.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" -#include "Plugins/Instruction/ARM/EmulateInstructionARM.h" - using namespace lldb; using namespace lldb_private; @@ -64,11 +63,23 @@ ::memset (&m_opcode, 0, sizeof (m_opcode)); } + uint64_t EmulateInstruction::ReadRegisterUnsigned (uint32_t reg_kind, uint32_t reg_num, uint64_t fail_value, bool *success_ptr) { + RegisterInfo reg_info; + if (GetRegisterInfo(reg_kind, reg_num, reg_info)) + return ReadRegisterUnsigned (reg_info, fail_value, success_ptr); + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +uint64_t +EmulateInstruction::ReadRegisterUnsigned (const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr) +{ uint64_t uval64 = 0; - bool success = m_read_reg_callback (this, m_baton, reg_kind, reg_num, uval64); + bool success = m_read_reg_callback (this, m_baton, reg_info, uval64); if (success_ptr) *success_ptr = success; if (!success) @@ -79,7 +90,16 @@ bool EmulateInstruction::WriteRegisterUnsigned (const Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value) { - return m_write_reg_callback (this, m_baton, context, reg_kind, reg_num, reg_value); + RegisterInfo reg_info; + if (GetRegisterInfo(reg_kind, reg_num, reg_info)) + return WriteRegisterUnsigned (context, reg_info, reg_value); + return false; +} + +bool +EmulateInstruction::WriteRegisterUnsigned (const Context &context, const RegisterInfo ®_info, uint64_t reg_value) +{ + return m_write_reg_callback (this, m_baton, context, reg_info, reg_value); } uint64_t @@ -235,28 +255,26 @@ bool EmulateInstruction::ReadRegisterFrame (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value) { if (!baton) return false; StackFrame *frame = (StackFrame *) baton; - RegisterContext *reg_context = frame->GetRegisterContext().get(); + RegisterContext *reg_ctx = frame->GetRegisterContext().get(); Scalar value; - uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (reg_kind, reg_num); + const uint32_t internal_reg_num = GetInternalRegisterNumber (reg_ctx, reg_info); - if (internal_reg_num == LLDB_INVALID_REGNUM) - return false; - - if (reg_context->ReadRegisterValue (internal_reg_num, value)) + if (internal_reg_num != LLDB_INVALID_REGNUM) { - reg_value = value.GetRawBits64 (0); - return true; + if (reg_ctx->ReadRegisterValue (internal_reg_num, value)) + { + reg_value = value.GetRawBits64 (0); + return true; + } } - return false; } @@ -264,22 +282,19 @@ EmulateInstruction::WriteRegisterFrame (EmulateInstruction *instruction, void *baton, const Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value) { if (!baton) return false; StackFrame *frame = (StackFrame *) baton; - RegisterContext *reg_context = frame->GetRegisterContext().get(); + RegisterContext *reg_ctx = frame->GetRegisterContext().get(); Scalar value (reg_value); - - uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (reg_kind, reg_num); + const uint32_t internal_reg_num = GetInternalRegisterNumber (reg_ctx, reg_info); if (internal_reg_num != LLDB_INVALID_REGNUM) - return reg_context->WriteRegisterValue (internal_reg_num, value); - else - return false; + return reg_ctx->WriteRegisterValue (internal_reg_num, value); + return false; } size_t @@ -290,9 +305,8 @@ void *dst, size_t length) { - PrintContext ("Read from memory", context); - fprintf (stdout, " Read from Memory (address = %p, length = %d)\n",(void *) addr, (uint32_t) length); - + fprintf (stdout, " Read from Memory (address = 0x%llx, length = %zu, context = ", addr, (uint32_t) length); + context.Dump (stdout, instruction); *((uint64_t *) dst) = 0xdeadbeef; return length; } @@ -305,23 +319,24 @@ const void *dst, size_t length) { - PrintContext ("Write to memory", context); - fprintf (stdout, " Write to Memory (address = %p, length = %d)\n", (void *) addr, (uint32_t) length); + fprintf (stdout, " Write to Memory (address = 0x%llx, length = %zu, context = ", addr, (uint32_t) length); + context.Dump (stdout, instruction); return length; } bool EmulateInstruction::ReadRegisterDefault (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value) { - std::string reg_name; - TranslateRegister (reg_kind, reg_num, reg_name); - fprintf (stdout, " Read Register (%s)\n", reg_name.c_str()); - - reg_value = 24; + fprintf (stdout, " Read Register (%s)\n", reg_info.name); + uint32_t reg_kind, reg_num; + if (GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) + reg_value = (uint64_t)reg_kind << 24 | reg_num; + else + reg_value = 0; + return true; } @@ -329,252 +344,191 @@ EmulateInstruction::WriteRegisterDefault (EmulateInstruction *instruction, void *baton, const Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value) { - PrintContext ("Write to register", context); - std::string reg_name; - TranslateRegister (reg_kind, reg_num, reg_name); - fprintf (stdout, " Write to Register (%s), value = 0x%llx\n", reg_name.c_str(), reg_value); + fprintf (stdout, " Write to Register (name = %s, value = 0x%llx, context = ", reg_info.name, reg_value); + context.Dump (stdout, instruction); return true; } void -EmulateInstruction::PrintContext (const char *context_type, const Context &context) +EmulateInstruction::Context::Dump (FILE *fh, + EmulateInstruction *instruction) const { - switch (context.type) + switch (type) { case eContextReadOpcode: - fprintf (stdout, " %s context: Reading an Opcode\n", context_type); + fprintf (fh, "reading opcode"); break; case eContextImmediate: - fprintf (stdout, " %s context: Immediate\n", context_type); + fprintf (fh, "immediate"); break; case eContextPushRegisterOnStack: - fprintf (stdout, " %s context: Pushing a register onto the stack.\n", context_type); + fprintf (fh, "push register"); break; case eContextPopRegisterOffStack: - fprintf (stdout, " %s context: Popping a register off the stack.\n", context_type); + fprintf (fh, "pop register"); break; case eContextAdjustStackPointer: - fprintf (stdout, " %s context: Adjusting the stack pointer.\n", context_type); + fprintf (fh, "adjust sp"); break; case eContextAdjustBaseRegister: - fprintf (stdout, " %s context: Adjusting (writing value back to) a base register.\n", context_type); + fprintf (fh, "adjusting (writing value back to) a base register"); break; case eContextRegisterPlusOffset: - fprintf (stdout, " %s context: Register plus offset\n", context_type); + fprintf (fh, "register + offset"); break; case eContextRegisterStore: - fprintf (stdout, " %s context: Storing a register.\n", context_type); + fprintf (fh, "store register"); break; case eContextRegisterLoad: - fprintf (stdout, " %s context: Loading a register.\n", context_type); + fprintf (fh, "load register"); break; case eContextRelativeBranchImmediate: - fprintf (stdout, " %s context: Relative branch immediate\n", context_type); + fprintf (fh, "relative branch immediate"); break; case eContextAbsoluteBranchRegister: - fprintf (stdout, " %s context: Absolute branch register\n", context_type); + fprintf (fh, "absolute branch register"); break; case eContextSupervisorCall: - fprintf (stdout, " %s context: Performing a supervisor call.\n", context_type); + fprintf (fh, "supervisor call"); break; case eContextTableBranchReadMemory: - fprintf (stdout, " %s context: Table branch read memory\n", context_type); + fprintf (fh, "table branch read memory"); break; case eContextWriteRegisterRandomBits: - fprintf (stdout, " %s context: Write random bits to a register\n", context_type); + fprintf (fh, "write random bits to a register"); break; case eContextWriteMemoryRandomBits: - fprintf (stdout, " %s context: Write random bits to a memory address\n", context_type); - break; - - case eContextMultiplication: - fprintf (stdout, " %s context: Performing a multiplication\n", context_type); + fprintf (fh, "write random bits to a memory address"); break; - case eContextAddition: - fprintf (stdout, " %s context: Performing an addition\n", context_type); + case eContextArithmetic: + fprintf (fh, "arithmetic"); break; case eContextReturnFromException: - fprintf (stdout, " %s context: Returning from an exception\n", context_type); + fprintf (fh, "return from exception"); break; default: - fprintf (stdout, " %s context: Unrecognized context.\n", context_type); + fprintf (fh, "unrecognized context."); break; } - switch (context.info_type) + switch (info_type) { - case eInfoTypeRegisterPlusOffset: + case eInfoTypeRegisterPlusOffset: { - std::string reg_name; - TranslateRegister (context.info.RegisterPlusOffset.reg.kind, - context.info.RegisterPlusOffset.reg.num, - reg_name); - fprintf (stdout, " Info type: Register plus offset (%s +/- %lld)\n", reg_name.c_str(), - context.info.RegisterPlusOffset.signed_offset); + fprintf (fh, + " (reg_plus_offset = %s%+lld)\n", + info.RegisterPlusOffset.reg.name, + info.RegisterPlusOffset.signed_offset); } - break; - case eInfoTypeRegisterPlusIndirectOffset: - { - std::string base_reg_name; - std::string offset_reg_name; - TranslateRegister (context.info.RegisterPlusIndirectOffset.base_reg.kind, - context.info.RegisterPlusIndirectOffset.base_reg.num, - base_reg_name); - TranslateRegister (context.info.RegisterPlusIndirectOffset.offset_reg.kind, - context.info.RegisterPlusIndirectOffset.offset_reg.num, - offset_reg_name); - fprintf (stdout, " Info type: Register plus indirect offset (%s +/- %s)\n", - base_reg_name.c_str(), - offset_reg_name.c_str()); - } - break; - case eInfoTypeRegisterToRegisterPlusOffset: - { - std::string base_reg_name; - std::string data_reg_name; - TranslateRegister (context.info.RegisterToRegisterPlusOffset.base_reg.kind, - context.info.RegisterToRegisterPlusOffset.base_reg.num, - base_reg_name); - TranslateRegister (context.info.RegisterToRegisterPlusOffset.data_reg.kind, - context.info.RegisterToRegisterPlusOffset.data_reg.num, - data_reg_name); - fprintf (stdout, " Info type: Register plus offset (%s +/- %lld) and data register (%s)\n", - base_reg_name.c_str(), context.info.RegisterToRegisterPlusOffset.offset, - data_reg_name.c_str()); - } - break; - case eInfoTypeRegisterToRegisterPlusIndirectOffset: - { - std::string base_reg_name; - std::string offset_reg_name; - std::string data_reg_name; - TranslateRegister (context.info.RegisterToRegisterPlusIndirectOffset.base_reg.kind, - context.info.RegisterToRegisterPlusIndirectOffset.base_reg.num, - base_reg_name); - TranslateRegister (context.info.RegisterToRegisterPlusIndirectOffset.offset_reg.kind, - context.info.RegisterToRegisterPlusIndirectOffset.offset_reg.num, - offset_reg_name); - TranslateRegister (context.info.RegisterToRegisterPlusIndirectOffset.data_reg.kind, - context.info.RegisterToRegisterPlusIndirectOffset.data_reg.num, - data_reg_name); - fprintf (stdout, " Info type: Register plus indirect offset (%s +/- %s) and data register (%s)\n", - base_reg_name.c_str(), offset_reg_name.c_str(), data_reg_name.c_str()); - } - break; - - case eInfoTypeRegisterRegisterOperands: - { - std::string op1_reg_name; - std::string op2_reg_name; - TranslateRegister (context.info.RegisterRegisterOperands.operand1.kind, - context.info.RegisterRegisterOperands.operand1.num, - op1_reg_name); - TranslateRegister (context.info.RegisterRegisterOperands.operand2.kind, - context.info.RegisterRegisterOperands.operand2.num, - op2_reg_name); - fprintf (stdout, " Info type: Register operands for binary op (%s, %s)\n", - op1_reg_name.c_str(), - op2_reg_name.c_str()); - } - break; - case eInfoTypeOffset: - fprintf (stdout, " Info type: signed offset (%lld)\n", context.info.signed_offset); - break; - - case eInfoTypeRegister: + break; + + case eInfoTypeRegisterPlusIndirectOffset: { - std::string reg_name; - TranslateRegister (context.info.reg.kind, context.info.reg.num, reg_name); - fprintf (stdout, " Info type: Register (%s)\n", reg_name.c_str()); + fprintf (fh, " (reg_plus_reg = %s + %s)\n", + info.RegisterPlusIndirectOffset.base_reg.name, + info.RegisterPlusIndirectOffset.offset_reg.name); } - break; - - case eInfoTypeImmediate: - fprintf (stdout, " Info type: Immediate (%lld)\n", context.info.immediate); - break; + break; - case eInfoTypeImmediateSigned: - fprintf (stdout, " Info type: Signed immediate (%lld)\n", context.info.signed_immediate); - break; - - case eInfoTypeAddress: - fprintf (stdout, " Info type: Address (%p)\n", (void *) context.info.address); - break; - - case eInfoTypeModeAndImmediate: + case eInfoTypeRegisterToRegisterPlusOffset: { - std::string mode_name; - - if (context.info.ModeAndImmediate.mode == EmulateInstructionARM::eModeARM) - mode_name = "ARM"; - else if (context.info.ModeAndImmediate.mode == EmulateInstructionARM::eModeThumb) - mode_name = "Thumb"; - else - mode_name = "Unknown mode"; - - fprintf (stdout, " Info type: Mode (%s) and immediate (%d)\n", mode_name.c_str(), - context.info.ModeAndImmediate.data_value); + fprintf (fh, " (base_and_imm_offset = %s%+lld, data_reg = %s)\n", + info.RegisterToRegisterPlusOffset.base_reg.name, + info.RegisterToRegisterPlusOffset.offset, + info.RegisterToRegisterPlusOffset.data_reg.name); } - break; - - case eInfoTypeModeAndImmediateSigned: - { - std::string mode_name; - - if (context.info.ModeAndImmediateSigned.mode == EmulateInstructionARM::eModeARM) - mode_name = "ARM"; - else if (context.info.ModeAndImmediateSigned.mode == EmulateInstructionARM::eModeThumb) - mode_name = "Thumb"; - else - mode_name = "Unknown mode"; + break; - fprintf (stdout, " Info type: Mode (%s) and signed immediate (%d)\n", mode_name.c_str(), - context.info.ModeAndImmediateSigned.signed_data_value); + case eInfoTypeRegisterToRegisterPlusIndirectOffset: + { + fprintf (fh, " (base_and_reg_offset = %s + %s, data_reg = %s)\n", + info.RegisterToRegisterPlusIndirectOffset.base_reg.name, + info.RegisterToRegisterPlusIndirectOffset.offset_reg.name, + info.RegisterToRegisterPlusIndirectOffset.data_reg.name); } - break; - - case eInfoTypeMode: + break; + + case eInfoTypeRegisterRegisterOperands: { - std::string mode_name; - - if (context.info.mode == EmulateInstructionARM::eModeARM) - mode_name = "ARM"; - else if (context.info.mode == EmulateInstructionARM::eModeThumb) - mode_name = "Thumb"; - else - mode_name = "Unknown mode"; - - fprintf (stdout, " Info type: Mode (%s)\n", mode_name.c_str()); + fprintf (fh, " (register to register binary op: %s and %s)\n", + info.RegisterRegisterOperands.operand1.name, + info.RegisterRegisterOperands.operand2.name); } - break; - - case eInfoTypeNoArgs: - fprintf (stdout, " Info type: no arguments\n"); - break; + break; - default: - break; + case eInfoTypeOffset: + fprintf (fh, " (signed_offset = %+lld)\n", info.signed_offset); + break; + + case eInfoTypeRegister: + fprintf (fh, " (reg = %s)\n", info.reg.name); + break; + + case eInfoTypeImmediate: + fprintf (fh, + " (unsigned_immediate = %llu (0x%16.16llx))\n", + info.unsigned_immediate, + info.unsigned_immediate); + break; + + case eInfoTypeImmediateSigned: + fprintf (fh, + " (signed_immediate = %+lld (0x%16.16llx))\n", + info.signed_immediate, + info.signed_immediate); + break; + + case eInfoTypeAddress: + fprintf (fh, " (address = 0x%llx)\n", info.address); + break; + + case eInfoTypeISAAndImmediate: + fprintf (fh, + " (isa = %u, unsigned_immediate = %u (0x%8.8x))\n", + info.ISAAndImmediate.isa, + info.ISAAndImmediate.unsigned_data32, + info.ISAAndImmediate.unsigned_data32); + break; + + case eInfoTypeISAAndImmediateSigned: + fprintf (fh, + " (isa = %u, signed_immediate = %i (0x%8.8x))\n", + info.ISAAndImmediateSigned.isa, + info.ISAAndImmediateSigned.signed_data32, + info.ISAAndImmediateSigned.signed_data32); + break; + + case eInfoTypeISA: + fprintf (fh, " (isa = %u)\n", info.isa); + break; + + case eInfoTypeNoArgs: + fprintf (fh, " \n"); + break; + + default: + fprintf (fh, " (unknown )\n"); + break; } } @@ -593,54 +547,65 @@ return true; } - -const char * -EmulateInstruction::TranslateRegister (uint32_t kind, uint32_t num, std::string &name) -{ - if (kind == eRegisterKindGeneric) +bool +EmulateInstruction::GetBestRegisterKindAndNumber (const RegisterInfo ®_info, + uint32_t ®_kind, + uint32_t ®_num) +{ + // Generic and DWARF should be the two most popular register kinds when + // emulating instructions since they are the most platform agnostic... + reg_num = reg_info.kinds[eRegisterKindGeneric]; + if (reg_num != LLDB_INVALID_REGNUM) { - switch (num) - { - case LLDB_REGNUM_GENERIC_PC: name = "pc"; break; - case LLDB_REGNUM_GENERIC_SP: name = "sp"; break; - case LLDB_REGNUM_GENERIC_FP: name = "fp"; break; - case LLDB_REGNUM_GENERIC_RA: name = "ra"; break; - case LLDB_REGNUM_GENERIC_FLAGS: name = "flags"; break; - default: name.clear(); break; - } - if (!name.empty()) - return name.c_str(); + reg_kind = eRegisterKindGeneric; + return true; } - const char *kind_cstr = NULL; - switch (kind) + reg_num = reg_info.kinds[eRegisterKindDWARF]; + if (reg_num != LLDB_INVALID_REGNUM) { - case eRegisterKindGCC: // the register numbers seen in eh_frame - kind_cstr = "gcc"; - break; + reg_kind = eRegisterKindDWARF; + return true; + } - case eRegisterKindDWARF: // the register numbers seen DWARF - kind_cstr = "dwarf"; - break; - - case eRegisterKindGeneric: // insn ptr reg, stack ptr reg, etc not specific to any particular target - kind_cstr = "generic"; - break; - - case eRegisterKindGDB: // the register numbers gdb uses (matches stabs numbers?) - kind_cstr = "gdb"; - break; - - case eRegisterKindLLDB: // lldb's internal register numbers - kind_cstr = "lldb"; - break; + reg_num = reg_info.kinds[eRegisterKindLLDB]; + if (reg_num != LLDB_INVALID_REGNUM) + { + reg_kind = eRegisterKindLLDB; + return true; } - - - StreamString sstr; - sstr.Printf ("%s(%u)", kind_cstr, num); - name.swap (sstr.GetString()); - return name.c_str(); + + reg_num = reg_info.kinds[eRegisterKindGCC]; + if (reg_num != LLDB_INVALID_REGNUM) + { + reg_kind = eRegisterKindGCC; + return true; + } + + reg_num = reg_info.kinds[eRegisterKindGDB]; + if (reg_num != LLDB_INVALID_REGNUM) + { + reg_kind = eRegisterKindGDB; + return true; + } + return false; +} + +uint32_t +EmulateInstruction::GetInternalRegisterNumber (RegisterContext *reg_ctx, const RegisterInfo ®_info) +{ + uint32_t reg_kind, reg_num; + if (reg_ctx && GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) + return reg_ctx->ConvertRegisterKindToRegisterNumber (reg_kind, reg_num); + return LLDB_INVALID_REGNUM; +} + + +bool +EmulateInstruction::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan) +{ + unwind_plan.Clear(); + return false; } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Apr 26 18:48:45 2011 @@ -16,6 +16,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Stream.h" +#include "lldb/Symbol/UnwindPlan.h" #include "Plugins/Process/Utility/ARMDefines.h" #include "Plugins/Process/Utility/ARMUtils.h" @@ -252,6 +253,27 @@ return true; } +bool +EmulateInstructionARM::GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num, RegisterInfo ®_info) +{ + if (reg_kind == eRegisterKindGeneric) + { + switch (reg_num) + { + case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = dwarf_pc; break; + case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sp; break; + case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_r7; break; + case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = dwarf_lr; break; + case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = dwarf_cpsr; break; + default: return false; + } + } + + if (reg_kind == eRegisterKindDWARF) + return GetARMDWARFRegisterInfo(reg_num, reg_info); + return false; +} + // Push Multiple Registers stores multiple registers to the stack, storing to // consecutive memory locations ending just below the address in SP, and updates // SP to point to the start of the stored data. @@ -340,16 +362,15 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextPushRegisterOnStack; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, 0); - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo reg_info; + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); for (i=0; i<15; ++i) { if (BitIsSet (registers, i)) { - dwarf_reg.num = dwarf_r0 + i; - context.SetRegisterToRegisterPlusOffset (dwarf_reg, sp_reg, addr - sp); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, reg_info); + context.SetRegisterToRegisterPlusOffset (reg_info, sp_reg, addr - sp); uint32_t reg_value = ReadCoreReg(i, &success); if (!success) return false; @@ -361,8 +382,8 @@ if (BitIsSet (registers, 15)) { - dwarf_reg.num = dwarf_pc; - context.SetRegisterPlusOffset (dwarf_reg, addr - sp); + GetRegisterInfo (eRegisterKindDWARF, dwarf_pc, reg_info); + context.SetRegisterPlusOffset (reg_info, addr - sp); const uint32_t pc = ReadCoreReg(PC_REG, &success); if (!success) return false; @@ -393,7 +414,7 @@ address = SP; for i = 0 to 14 if registers == '1' then - R[i} = if UnalignedAllowed then MemU[address,4] else MemA[address,4]; address = address + 4; + R[i] = if UnalignedAllowed then MemU[address,4] else MemA[address,4]; address = address + 4; if registers<15> == '1' then if UnalignedAllowed then LoadWritePC(MemU[address,4]); @@ -406,8 +427,7 @@ bool success = false; - if (ConditionPassed(opcode)) - { + if (ConditionPassed(opcode)) { const uint32_t addr_byte_size = GetAddressByteSize(); const addr_t sp = ReadCoreReg (SP_REG, &success); if (!success) @@ -469,20 +489,21 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextPopRegisterOffStack; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, 0); - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); + for (i=0; i<15; ++i) { if (BitIsSet (registers, i)) { - dwarf_reg.num = dwarf_r0 + i; context.SetRegisterPlusOffset (sp_reg, addr - sp); data = MemARead(context, addr, 4, 0, &success); if (!success) return false; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_reg.num, data)) + RegisterInfo reg_info; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, reg_info); + if (!WriteRegisterUnsigned(context, reg_info, data)) return false; addr += addr_byte_size; } @@ -490,7 +511,6 @@ if (BitIsSet (registers, 15)) { - dwarf_reg.num = dwarf_pc; context.SetRegisterPlusOffset (sp_reg, addr - sp); data = MemARead(context, addr, 4, 0, &success); if (!success) @@ -559,8 +579,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextAdjustStackPointer; - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); context.SetRegisterPlusOffset (sp_reg, sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, addr)) @@ -613,8 +633,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); context.SetRegisterPlusOffset (sp_reg, 0); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, sp)) @@ -706,8 +726,8 @@ // The context specifies that Rm is to be moved into Rd. EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterLoad; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rm, dwarf_reg); context.SetRegister (dwarf_reg); if (!WriteCoreRegOptionalFlags(context, result, Rd, setflags)) @@ -922,13 +942,13 @@ uint64_t result = operand1 * operand2; // R[d] = result<31:0>; - Register op1_reg; - Register op2_reg; - op1_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - op2_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo op1_reg; + RegisterInfo op2_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, op1_reg); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, op2_reg); EmulateInstruction::Context context; - context.type = eContextMultiplication; + context.type = eContextArithmetic; context.SetRegisterRegisterOperands (op1_reg, op2_reg); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + d, (0x0000ffff & result))) @@ -1129,8 +1149,8 @@ // PC relative immediate load context EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register pc_reg; - pc_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + RegisterInfo pc_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_pc, pc_reg); context.SetRegisterPlusOffset (pc_reg, 0); uint32_t Rt; // the destination register @@ -1249,8 +1269,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextAdjustStackPointer; - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); context.SetRegisterPlusOffset (sp_reg, sp_offset); if (d == 15) @@ -1313,11 +1333,12 @@ addr_t addr = (int32_t)sp + reg_value; // the adjusted stack pointer value EmulateInstruction::Context context; - context.type = EmulateInstruction::eContextAddition; - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - Register other_reg; - other_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + context.type = eContextArithmetic; + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); + + RegisterInfo other_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rm, other_reg); context.SetRegisterRegisterOperands (sp_reg, other_reg); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr)) @@ -1377,7 +1398,7 @@ uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10 << 12) | (imm11 << 1); imm32 = llvm::SignExtend32<25>(imm25); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 4 + imm32); if (InITBlock() && !LastInITBlock()) return false; break; @@ -1395,7 +1416,7 @@ uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10H << 12) | (imm10L << 2); imm32 = llvm::SignExtend32<25>(imm25); target = Align(pc, 4) + imm32; - context.SetModeAndImmediateSigned (eModeARM, 4 + imm32); + context.SetISAAndImmediateSigned (eModeARM, 4 + imm32); if (InITBlock() && !LastInITBlock()) return false; break; @@ -1404,13 +1425,13 @@ lr = pc - 4; // return address imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2); target = Align(pc, 4) + imm32; - context.SetModeAndImmediateSigned (eModeARM, 8 + imm32); + context.SetISAAndImmediateSigned (eModeARM, 8 + imm32); break; case eEncodingA2: lr = pc - 4; // return address imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2 | Bits32(opcode, 24, 24) << 1); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 8 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 8 + imm32); break; default: return false; @@ -1479,8 +1500,8 @@ addr_t target = ReadCoreReg (Rm, &success); if (!success) return false; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rm, dwarf_reg); context.SetRegister (dwarf_reg); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, lr)) return false; @@ -1524,9 +1545,9 @@ addr_t target = ReadCoreReg (Rm, &success); if (!success) return false; - - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rm, dwarf_reg); context.SetRegister (dwarf_reg); if (!BXWritePC(context, target)) return false; @@ -1583,8 +1604,8 @@ if (!success) return false; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rm, dwarf_reg); context.SetRegister (dwarf_reg); if (!BXWritePC(context, target)) return false; @@ -1634,8 +1655,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r12); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r12, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, -ip_offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r7, addr)) @@ -1686,8 +1707,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, -sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r12, addr)) @@ -1851,8 +1872,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextPushRegisterOnStack; - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); context.SetRegisterPlusOffset (sp_reg, addr - sp); if (Rt != 15) { @@ -1952,16 +1973,15 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextPushRegisterOnStack; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, 0); - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + RegisterInfo dwarf_reg; + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); for (i=0; i(Bits32(opcode, 7, 0) << 1); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 4 + imm32); break; case eEncodingT2: imm32 = llvm::SignExtend32<12>(Bits32(opcode, 10, 0)); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 4 + imm32); break; case eEncodingT3: // The 'cond' field is handled in EmulateInstructionARM::CurrentCond(). @@ -2180,7 +2199,7 @@ uint32_t imm21 = (S << 20) | (J2 << 19) | (J1 << 18) | (imm6 << 12) | (imm11 << 1); imm32 = llvm::SignExtend32<21>(imm21); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 4 + imm32); break; } case eEncodingT4: @@ -2195,13 +2214,13 @@ uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10 << 12) | (imm11 << 1); imm32 = llvm::SignExtend32<25>(imm25); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 4 + imm32); break; } case eEncodingA1: imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeARM, 8 + imm32); + context.SetISAAndImmediateSigned (eModeARM, 8 + imm32); break; default: return false; @@ -2246,7 +2265,7 @@ imm32 = Bit32(opcode, 9) << 6 | Bits32(opcode, 7, 3) << 1; nonzero = BitIsSet(opcode, 11); target = pc + imm32; - context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); + context.SetISAAndImmediateSigned (eModeThumb, 4 + imm32); break; default: return false; @@ -2326,7 +2345,7 @@ // target address addr_t target = pc + offset; context.type = EmulateInstruction::eContextRelativeBranchImmediate; - context.SetModeAndImmediateSigned (eModeThumb, 4 + offset); + context.SetISAAndImmediateSigned (eModeThumb, 4 + offset); if (!BranchWritePC(context, target)) return false; @@ -2427,11 +2446,11 @@ //(result, carry, overflow) = AddWithCarry(R[n], imm32, '0'); AddWithCarryResult res = AddWithCarry (Rn, imm32, 0); - Register reg_n; - reg_n.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo reg_n; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, reg_n); EmulateInstruction::Context context; - context.type = eContextAddition; + context.type = eContextArithmetic; context.SetRegisterPlusOffset (reg_n, imm32); //R[d] = result; @@ -2495,9 +2514,9 @@ AddWithCarryResult res = AddWithCarry(val1, imm32, 0); EmulateInstruction::Context context; - context.type = EmulateInstruction::eContextAddition; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, Rn); + context.type = eContextArithmetic; + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, Rn, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, imm32); if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, res.carry_out, res.overflow)) @@ -2582,11 +2601,11 @@ AddWithCarryResult res = AddWithCarry(val1, shifted, 0); EmulateInstruction::Context context; - context.type = EmulateInstruction::eContextAddition; - Register op1_reg; - Register op2_reg; - op1_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rn); - op2_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + context.type = eContextArithmetic; + RegisterInfo op1_reg; + RegisterInfo op2_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rn, op1_reg); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rm, op2_reg); context.SetRegisterRegisterOperands (op1_reg, op2_reg); if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, res.carry_out, res.overflow)) @@ -3297,8 +3316,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, offset); for (int i = 0; i < 14; ++i) @@ -3414,8 +3433,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, offset); // for i = 0 to 14 @@ -3551,8 +3570,8 @@ addr_t address = Rn - (addr_byte_size * BitCount (registers)); EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, Rn - address); for (int i = 0; i < 14; ++i) @@ -3663,8 +3682,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, dwarf_reg); context.SetRegisterPlusOffset (dwarf_reg, offset); for (int i = 0; i < 14; ++i) @@ -3833,8 +3852,8 @@ address = (index ? offset_addr : base); - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rn); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rn, base_reg); if (wback) { EmulateInstruction::Context ctx; @@ -3966,8 +3985,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); // for i = 0 to 14 int lowest_set_bit = 14; @@ -3989,8 +4008,8 @@ if (!success) return false; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; @@ -4005,8 +4024,8 @@ // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { - Register pc_reg; - pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + RegisterInfo pc_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_pc, pc_reg); context.SetRegisterPlusOffset (pc_reg, 8); const uint32_t pc = ReadCoreReg (PC_REG, &success); if (!success) @@ -4091,8 +4110,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); // for i = 0 to 14 int lowest_bit_set = 14; @@ -4114,8 +4133,8 @@ if (!success) return false; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, Rn - (address + offset)); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; @@ -4130,8 +4149,8 @@ // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { - Register pc_reg; - pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + RegisterInfo pc_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_pc, pc_reg); context.SetRegisterPlusOffset (pc_reg, 8); const uint32_t pc = ReadCoreReg (PC_REG, &success); if (!success) @@ -4242,8 +4261,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); // for i = 0 to 14 uint32_t lowest_set_bit = 14; @@ -4265,8 +4284,8 @@ if (!success) return false; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, Rn - (address + offset)); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; @@ -4281,8 +4300,8 @@ // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { - Register pc_reg; - pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + RegisterInfo pc_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_pc, pc_reg); context.SetRegisterPlusOffset (pc_reg, 8); const uint32_t pc = ReadCoreReg (PC_REG, &success); if (!success) @@ -4367,8 +4386,8 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t lowest_set_bit = 14; // for i = 0 to 14 @@ -4391,8 +4410,8 @@ if (!success) return false; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset + addr_byte_size); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; @@ -4407,8 +4426,8 @@ // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { - Register pc_reg; - pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + RegisterInfo pc_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_pc, pc_reg); context.SetRegisterPlusOffset (pc_reg, 8); const uint32_t pc = ReadCoreReg (PC_REG, &success); if (!success) @@ -4556,8 +4575,8 @@ EmulateInstruction::Context context; context.type = eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); // if UnalignedSupport() || address<1:0> == '00' then if (UnalignedSupport () || (BitIsClear (address, 1) && BitIsClear (address, 0))) @@ -4567,8 +4586,8 @@ if (!success) return false; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); int32_t offset = address - base_address; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); if (!MemUWrite (context, address, data, addr_byte_size)) @@ -4754,11 +4773,11 @@ { // MemU[address,4] = data; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - base_address); if (!MemUWrite (context, address, data, addr_byte_size)) @@ -4884,11 +4903,11 @@ address = base_address; // MemU[address,1] = R[t]<7:0> - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); EmulateInstruction::Context context; context.type = eContextRegisterStore; @@ -5050,10 +5069,10 @@ EmulateInstruction::Context context; context.type = eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register offset_reg; - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); // if UnalignedSupport() || address<0> == '0' then if (UnalignedSupport() || BitIsClear (address, 0)) @@ -5065,12 +5084,12 @@ EmulateInstruction::Context context; context.type = eContextRegisterStore; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register offset_reg; - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); context.SetRegisterToRegisterPlusIndirectOffset (base_reg, offset_reg, data_reg); if (!MemUWrite (context, address, Bits32 (Rt, 15, 0), 2)) @@ -5713,8 +5732,8 @@ // data = MemU[address,4]; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -5916,8 +5935,8 @@ address = Rn; // data = MemU[address,4]; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -6087,10 +6106,10 @@ address = Rn; // R[t] = ZeroExtend(MemU[address,1], 32); - Register base_reg; - Register data_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo base_reg; + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -6323,8 +6342,8 @@ address = Rn; // R[t] = ZeroExtend(MemU[address,1],32); - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -6461,8 +6480,8 @@ address = Rn; // data = MemU[address,2]; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -6575,8 +6594,8 @@ address = base - imm32; // data = MemU[address,2]; - Register base_reg; - base_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -6740,10 +6759,10 @@ address = Rn; // data = MemU[address,2]; - Register base_reg; - Register offset_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo base_reg; + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -6901,8 +6920,8 @@ address = Rn; // R[t] = SignExtend(MemU[address,1], 32); - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7000,8 +7019,8 @@ address = base - imm32; // R[t] = SignExtend(MemU[address,1], 32); - Register base_reg; - base_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7145,10 +7164,10 @@ address = Rn; // R[t] = SignExtend(MemU[address,1], 32); - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register offset_reg; - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7296,8 +7315,8 @@ address = Rn; // data = MemU[address,2]; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7410,8 +7429,8 @@ address = base - imm32; // data = MemU[address,2]; - Register base_reg; - base_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7572,11 +7591,11 @@ address = Rn; // data = MemU[address,2]; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); - Register offset_reg; - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7684,8 +7703,8 @@ // R[d] = SignExtend(rotated<7:0>, 32); int64_t data = llvm::SignExtend64<8>(rotated); - Register source_reg; - source_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo source_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, source_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7764,8 +7783,8 @@ uint64_t rotated = ROR (Rm, rotation); // R[d] = SignExtend(rotated<15:0>, 32); - Register source_reg; - source_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo source_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, source_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7846,8 +7865,8 @@ uint64_t rotated = ROR (Rm, rotation); // R[d] = ZeroExtend(rotated<7:0>, 32); - Register source_reg; - source_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo source_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, source_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -7925,8 +7944,8 @@ uint64_t rotated = ROR (Rm, rotation); // R[d] = ZeroExtend(rotated<15:0>, 32); - Register source_reg; - source_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo source_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, source_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -8043,8 +8062,8 @@ address = address + 4; // CPSRWriteByInstr(MemA[address+4,4], '1111', TRUE); - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextReturnFromException; @@ -9331,11 +9350,11 @@ AddWithCarryResult res = AddWithCarry (sp_val, ~shifted, 1); EmulateInstruction::Context context; - context.type = eContextSubtraction; - Register sp_reg; - sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - Register dwarf_reg; - dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + context.type = eContextArithmetic; + RegisterInfo sp_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, dwarf_reg); context.SetRegisterRegisterOperands (sp_reg, dwarf_reg); if (!WriteCoreRegOptionalFlags(context, res.result, dwarf_r0 + d, setflags, res.carry_out, res.overflow)) @@ -9419,11 +9438,11 @@ // R[d] = result; EmulateInstruction::Context context; - context.type = eContextAddition; - Register reg_n; - reg_n.SetRegister (eRegisterKindDWARF, dwarf_r0 +n); - Register reg_m; - reg_m.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + context.type = eContextArithmetic; + RegisterInfo reg_n; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, reg_n); + RegisterInfo reg_m; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, reg_m); context.SetRegisterRegisterOperands (reg_n, reg_m); @@ -9551,11 +9570,11 @@ // APSR.V = overflow; EmulateInstruction::Context context; - context.type = eContextSubtraction; - Register reg_n; - reg_n.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register reg_m; - reg_m.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + context.type = eContextArithmetic; + RegisterInfo reg_n; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, reg_n); + RegisterInfo reg_m; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, reg_m); context.SetRegisterRegisterOperands (reg_n, reg_m); if (!WriteCoreRegOptionalFlags (context, res.result, dwarf_r0 + d, setflags, res.carry_out, res.overflow)) @@ -9638,10 +9657,10 @@ addr_t address = Rn + imm32; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); EmulateInstruction::Context context; context.type = eContextRegisterStore; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, imm32); @@ -9748,10 +9767,10 @@ if (!success) return false; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); EmulateInstruction::Context context; context.type = eContextRegisterStore; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - Rn); @@ -9838,10 +9857,10 @@ else address = Rn; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); EmulateInstruction::Context context; context.type = eContextRegisterStore; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - Rn); @@ -9986,8 +10005,8 @@ address = Rn; //R[t] = MemA[address,4]; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); EmulateInstruction::Context context; context.type = eContextRegisterLoad; @@ -10093,14 +10112,14 @@ uint32_t Rn = ReadCoreReg (n, &success); if (!success) return false; - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rm = ReadCoreReg (m, &success); if (!success) return false; - Register offset_reg; - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); // offset_addr = if add then (R[n] + R[m]) else (R[n] - R[m]); addr_t offset_addr; @@ -10238,8 +10257,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -10260,8 +10279,8 @@ address = Rn; //MemA[address,4] = R[t]; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); uint32_t data = ReadCoreReg (t, &success); if (!success) @@ -10277,7 +10296,7 @@ return false; //MemA[address+4,4] = R[t2]; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t2); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t2, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, (address + 4) - Rn); data = ReadCoreReg (t2, &success); @@ -10367,12 +10386,11 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - Register offset_reg; - offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); + RegisterInfo offset_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + m, offset_reg); + RegisterInfo data_reg; uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -10402,6 +10420,7 @@ EmulateInstruction::Context context; context.type = eContextRegisterStore; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t, data_reg); context.SetRegisterToRegisterPlusIndirectOffset (base_reg, offset_reg, data_reg); const uint32_t addr_byte_size = GetAddressByteSize(); @@ -10414,7 +10433,7 @@ if (!success) return false; - data_reg.num = dwarf_r0 + t2; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + t2, data_reg); context.SetRegisterToRegisterPlusIndirectOffset (base_reg, offset_reg, data_reg); @@ -10445,7 +10464,7 @@ if ConditionPassed() then EncodingSpecificOperations(); CheckVFPEnabled(TRUE); NullCheckIfThumbEE(n); address = if add then R[n] else R[n]-imm32; - if wback then R[n] = if add then R[n}+imm32 else R[n]-imm32; + if wback then R[n] = if add then R[n]+imm32 else R[n]-imm32; for r = 0 to regs-1 if single_regs then S[d+r] = MemA[address,4]; address = address+4; @@ -10536,8 +10555,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -10550,7 +10569,7 @@ else address = Rn - imm32; - // if wback then R[n] = if add then R[n}+imm32 else R[n]-imm32; + // if wback then R[n] = if add then R[n]+imm32 else R[n]-imm32; EmulateInstruction::Context context; if (wback) @@ -10636,7 +10655,7 @@ if ConditionPassed() then EncodingSpecificOperations(); CheckVFPEnabled(TRUE); NullCheckIfThumbEE(n); address = if add then R[n] else R[n]-imm32; - if wback then R[n] = if add then R[n}+imm32 else R[n]-imm32; + if wback then R[n] = if add then R[n]+imm32 else R[n]-imm32; for r = 0 to regs-1 if single_regs then MemA[address,4] = S[d+r]; address = address+4; @@ -10729,8 +10748,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -10744,7 +10763,7 @@ address = Rn - imm32; EmulateInstruction::Context context; - // if wback then R[n] = if add then R[n}+imm32 else R[n]-imm32; + // if wback then R[n] = if add then R[n]+imm32 else R[n]-imm32; if (wback) { uint32_t value; @@ -10767,16 +10786,16 @@ // for r = 0 to regs-1 for (int r = 0; r < regs; ++r) { - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, 0); + if (single_regs) { // MemA[address,4] = S[d+r]; address = address+4; uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, start_reg + d + r, 0, &success); if (!success) return false; - - data_reg.num = start_reg + d + r; + + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, start_reg + d + r, data_reg); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - Rn); if (!MemAWrite (context, address, data, addr_byte_size)) return false; @@ -10792,7 +10811,8 @@ if (!success) return false; - data_reg.num = start_reg + d + r; + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, start_reg + d + r, data_reg); if (GetByteOrder() == eByteOrderBig) { @@ -10882,8 +10902,8 @@ default: return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -11020,8 +11040,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -11037,8 +11057,8 @@ const uint32_t addr_byte_size = GetAddressByteSize(); uint32_t start_reg = single_reg ? dwarf_s0 : dwarf_d0; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, start_reg + d); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, start_reg + d, data_reg); EmulateInstruction::Context context; context.type = eContextRegisterStore; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - Rn); @@ -11191,8 +11211,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -11359,8 +11379,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -11526,8 +11546,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -11559,13 +11579,12 @@ return false; } + RegisterInfo data_reg; context.type = eContextRegisterStore; - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, 0); // for r = 0 to regs-1 for (int r = 0; r < regs; ++r) { - data_reg.num = dwarf_d0 + d + r; + GetRegisterInfo (eRegisterKindDWARF, dwarf_d0 + d + r, data_reg); uint64_t register_data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_d0 + d + r, 0, &success); if (!success) return false; @@ -11695,8 +11714,8 @@ return false; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -11735,8 +11754,8 @@ uint64_t word = Bits64 (register_data, ((index + 1) * esize) - 1, index * esize); - Register data_reg; - data_reg.SetRegister (eRegisterKindDWARF, dwarf_d0 + d); + RegisterInfo data_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_d0 + d, data_reg); context.type = eContextRegisterStore; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - Rn); @@ -11821,8 +11840,8 @@ break; } - Register base_reg; - base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 +n); + RegisterInfo base_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + n, base_reg); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -12958,7 +12977,7 @@ cpsr_changed = true; } target = addr & 0xfffffffe; - context.SetMode (eModeThumb); + context.SetISA (eModeThumb); } else if (BitIsClear(addr, 1)) { @@ -12968,7 +12987,7 @@ cpsr_changed = true; } target = addr & 0xfffffffc; - context.SetMode (eModeARM); + context.SetISA (eModeARM); } else return false; // address<1:0> == '10' => UNPREDICTABLE @@ -13369,27 +13388,52 @@ return success; } - - -const char * -EmulateInstructionARM::GetRegisterName (uint32_t reg_kind, uint32_t reg_num) +// +// +//const char * +//EmulateInstructionARM::GetRegisterName (uint32_t reg_kind, uint32_t reg_num) +//{ +// if (reg_kind == eRegisterKindGeneric) +// { +// switch (reg_num) +// { +// case LLDB_REGNUM_GENERIC_PC: return "pc"; +// case LLDB_REGNUM_GENERIC_SP: return "sp"; +// case LLDB_REGNUM_GENERIC_FP: return "fp"; +// case LLDB_REGNUM_GENERIC_RA: return "lr"; +// case LLDB_REGNUM_GENERIC_FLAGS: return "cpsr"; +// default: return NULL; +// } +// } +// else if (reg_kind == eRegisterKindDWARF) +// { +// return GetARMDWARFRegisterName (reg_num); +// } +// return NULL; +//} +// +bool +EmulateInstructionARM::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan) { - if (reg_kind == eRegisterKindGeneric) - { - switch (reg_num) - { - case LLDB_REGNUM_GENERIC_PC: return "pc"; - case LLDB_REGNUM_GENERIC_SP: return "sp"; - case LLDB_REGNUM_GENERIC_FP: return "fp"; - case LLDB_REGNUM_GENERIC_RA: return "lr"; - case LLDB_REGNUM_GENERIC_FLAGS: return "cpsr"; - default: return NULL; - } - } - else if (reg_kind == eRegisterKindDWARF) - { - return GetARMDWARFRegisterName (reg_num); - } - return NULL; + unwind_plan.SetRegisterKind (eRegisterKindDWARF); + + UnwindPlan::Row row; + UnwindPlan::Row::RegisterLocation regloc; + + // Our previous Call Frame Address is the stack pointer + row.SetCFARegister (dwarf_sp); + + // Our previous PC is in the LR + regloc.SetInRegister(dwarf_lr); + row.SetRegisterInfo (dwarf_pc, regloc); + unwind_plan.AppendRow (row); + + // All other registers are the same. + + unwind_plan.SetSourceName ("EmulateInstructionARM"); + return true; } + + + Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Apr 26 18:48:45 2011 @@ -120,7 +120,7 @@ enum Mode { - eModeInvalid, + eModeInvalid = -1, eModeARM, eModeThumb }; @@ -178,8 +178,12 @@ virtual bool TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data); - virtual const char * - GetRegisterName (uint32_t reg_kind, uint32_t reg_num); + virtual bool + GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num, RegisterInfo ®_info); + + + virtual bool + CreateFunctionEntryUnwind (UnwindPlan &unwind_plan); uint32_t ArchVersion(); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Tue Apr 26 18:48:45 2011 @@ -254,8 +254,7 @@ bool EmulationStateARM::ReadPseudoRegister (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value) { if (!baton) @@ -264,23 +263,8 @@ bool success = true; EmulationStateARM *pseudo_state = (EmulationStateARM *) baton; - if (reg_kind == eRegisterKindGeneric) - { - switch (reg_num) - { - case LLDB_REGNUM_GENERIC_PC: - reg_num = dwarf_pc; break; - case LLDB_REGNUM_GENERIC_SP: - reg_num = dwarf_sp; break; - case LLDB_REGNUM_GENERIC_FLAGS: - reg_num = dwarf_cpsr; break; - case LLDB_REGNUM_GENERIC_RA: - reg_num = dwarf_lr; break; - default: - break; - } - } - reg_value = pseudo_state->ReadPseudoRegisterValue (reg_num, success); + assert (reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM); + reg_value = pseudo_state->ReadPseudoRegisterValue (reg_info.kinds[eRegisterKindDWARF], success); return success; @@ -290,32 +274,15 @@ EmulationStateARM::WritePseudoRegister (EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value) { if (!baton) return false; - if (reg_kind == eRegisterKindGeneric) - { - switch (reg_num) - { - case LLDB_REGNUM_GENERIC_PC: - reg_num = dwarf_pc; break; - case LLDB_REGNUM_GENERIC_SP: - reg_num = dwarf_sp; break; - case LLDB_REGNUM_GENERIC_FLAGS: - reg_num = dwarf_cpsr; break; - case LLDB_REGNUM_GENERIC_RA: - reg_num = dwarf_lr; break; - default: - break; - } - } - + assert (reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM); EmulationStateARM *pseudo_state = (EmulationStateARM *) baton; - return pseudo_state->StorePseudoRegisterValue (reg_num, reg_value); + return pseudo_state->StorePseudoRegisterValue (reg_info.kinds[eRegisterKindDWARF], reg_value); } bool Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h Tue Apr 26 18:48:45 2011 @@ -70,16 +70,14 @@ static bool ReadPseudoRegister (lldb_private::EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const lldb_private::RegisterInfo ®_info, uint64_t ®_value); static bool WritePseudoRegister (lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const lldb_private::RegisterInfo ®_info, uint64_t reg_value); private: uint32_t m_gpr[17]; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Tue Apr 26 18:48:45 2011 @@ -147,8 +147,8 @@ { case llvm::Triple::x86_64: case llvm::Triple::x86: - case llvm::Triple::arm: - case llvm::Triple::thumb: +// case llvm::Triple::arm: +// case llvm::Triple::thumb: m_unwinder_ap.reset (new UnwindLLDB (*this)); break; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Tue Apr 26 18:48:45 2011 @@ -18,6 +18,7 @@ #include "lldb/Core/Error.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -101,7 +102,9 @@ // Initialize the stack pointer with a known value. In the 32 bit case // it will be 0x80000000, and in the 64 bit case 0x8000000000000000. // We use the address byte size to be safe for any future addresss sizes - SetRegisterValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, (1ull << ((addr_byte_size * 8) - 1))); + RegisterInfo sp_reg_info; + m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp_reg_info); + SetRegisterValue(sp_reg_info, (1ull << ((addr_byte_size * 8) - 1))); const InstructionList &inst_list = disasm_sp->GetInstructionList (); const size_t num_instructions = inst_list.GetSize(); @@ -201,6 +204,31 @@ } +uint64_t +UnwindAssemblyInstEmulation::MakeRegisterKindValuePair (const lldb_private::RegisterInfo ®_info) +{ + uint32_t reg_kind, reg_num; + if (EmulateInstruction::GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) + return (uint64_t)reg_kind << 24 | reg_num; + return 0ull; +} + +void +UnwindAssemblyInstEmulation::SetRegisterValue (const lldb_private::RegisterInfo ®_info, uint64_t reg_value) +{ + m_register_values[MakeRegisterKindValuePair (reg_info)] = reg_value; +} + +uint64_t +UnwindAssemblyInstEmulation::GetRegisterValue (const lldb_private::RegisterInfo ®_info) +{ + const uint64_t reg_id = MakeRegisterKindValuePair (reg_info); + RegisterValueMap::const_iterator pos = m_register_values.find(reg_id); + if (pos != m_register_values.end()) + return pos->second; + return MakeRegisterKindValuePair (reg_info); +} + size_t UnwindAssemblyInstEmulation::ReadMemory (EmulateInstruction *instruction, @@ -211,12 +239,11 @@ size_t dst_len) { //UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - printf ("UnwindAssemblyInstEmulation::ReadMemory (context.type = %i, context.info_type = %i, addr = 0x%16.16llx, dst = %p, dst_len = %zu)\n", - context.type, - context.info_type, + printf ("UnwindAssemblyInstEmulation::ReadMemory (addr = 0x%16.16llx, dst = %p, dst_len = %zu, context = ", addr, dst, dst_len); + context.Dump(stdout, instruction); return dst_len; } @@ -236,27 +263,23 @@ instruction->GetArchitecture ().GetAddressByteSize()); StreamFile strm(stdout, false); - strm.Printf ("UnwindAssemblyInstEmulation::WriteMemory (context.type = %i, context.info_type = %i, ", - context.type, - context.info_type); + strm.PutCString ("UnwindAssemblyInstEmulation::WriteMemory ("); data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0); - strm.EOL(); + strm.PutCString (", context = "); + context.Dump(stdout, instruction); return dst_len; } bool UnwindAssemblyInstEmulation::ReadRegister (EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t ®_value) { UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - const char *reg_name = instruction->GetRegisterName (reg_kind, reg_num); + reg_value = inst_emulator->GetRegisterValue (reg_info); - reg_value = inst_emulator->GetRegisterValue (reg_kind, reg_num); - - printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => value = 0x%16.16llx\n", reg_name, reg_value); + printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => value = 0x%16.16llx\n", reg_info.name, reg_value); return true; } @@ -265,20 +288,19 @@ UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const RegisterInfo ®_info, uint64_t reg_value) { UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - const char *reg_name = instruction->GetRegisterName (reg_kind, reg_num); - printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = 0x%16.16llx, context.type = %i, context.info_type = %i)\n", - reg_name, - reg_value, - context.type, - context.info_type); + printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = 0x%16.16llx, context =", + reg_info.name, + reg_value); + context.Dump(stdout, instruction); + + inst_emulator->SetRegisterValue (reg_info, reg_value); - inst_emulator->SetRegisterValue (reg_kind, reg_num, reg_value); + UnwindPlan::Row::RegisterLocation regloc; switch (context.type) { @@ -296,9 +318,7 @@ case EmulateInstruction::eContextTableBranchReadMemory: case EmulateInstruction::eContextWriteRegisterRandomBits: case EmulateInstruction::eContextWriteMemoryRandomBits: - case EmulateInstruction::eContextMultiplication: - case EmulateInstruction::eContextAddition: - case EmulateInstruction::eContextSubtraction: + case EmulateInstruction::eContextArithmetic: case EmulateInstruction::eContextAdvancePC: case EmulateInstruction::eContextReturnFromException: break; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Tue Apr 26 18:48:45 2011 @@ -88,16 +88,14 @@ static bool ReadRegister (lldb_private::EmulateInstruction *instruction, void *baton, - uint32_t reg_kind, - uint32_t reg_num, + const lldb_private::RegisterInfo ®_info, uint64_t ®_value); static bool WriteRegister (lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, - uint32_t reg_kind, - uint32_t reg_num, + const lldb_private::RegisterInfo ®_info, uint64_t reg_value); @@ -118,26 +116,13 @@ } static uint64_t - MakeRegisterKindValuePair (uint32_t reg_kind, uint32_t reg_num) - { - return (uint64_t)reg_kind << 32 | reg_num; - } + MakeRegisterKindValuePair (const lldb_private::RegisterInfo ®_info); void - SetRegisterValue (uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value) - { - m_register_values[MakeRegisterKindValuePair (reg_kind, reg_num)] = reg_value; - } + SetRegisterValue (const lldb_private::RegisterInfo ®_info, uint64_t reg_value); uint64_t - GetRegisterValue (uint32_t reg_kind, uint32_t reg_num) - { - const uint64_t reg_id = MakeRegisterKindValuePair (reg_kind, reg_num); - RegisterValueMap::const_iterator pos = m_register_values.find(reg_id); - if (pos != m_register_values.end()) - return pos->second; - return (uint64_t)reg_kind << 24 | (uint64_t)reg_num; - } + GetRegisterValue (const lldb_private::RegisterInfo ®_info); std::auto_ptr m_inst_emulator_ap; lldb_private::AddressRange* m_range_ptr; Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindPlan.cpp (original) +++ lldb/trunk/source/Symbol/UnwindPlan.cpp Tue Apr 26 18:48:45 2011 @@ -8,10 +8,11 @@ //===----------------------------------------------------------------------===// #include "lldb/Symbol/UnwindPlan.h" + +#include "lldb/Core/ConstString.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" -#include "lldb/Core/ConstString.h" using namespace lldb; using namespace lldb_private; Removed: lldb/trunk/source/Utility/ARM_DWARF_Registers.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.c?rev=130255&view=auto ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.c (original) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.c (removed) @@ -1,183 +0,0 @@ -//===-- ARM_DWARF_Registers.c -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ARM_DWARF_Registers.h" - -const char * -GetARMDWARFRegisterName (unsigned reg_num) -{ - switch (reg_num) - { - case dwarf_r0: return "r0"; - case dwarf_r1: return "r1"; - case dwarf_r2: return "r2"; - case dwarf_r3: return "r3"; - case dwarf_r4: return "r4"; - case dwarf_r5: return "r5"; - case dwarf_r6: return "r6"; - case dwarf_r7: return "r7"; - case dwarf_r8: return "r8"; - case dwarf_r9: return "r9"; - case dwarf_r10: return "r10"; - case dwarf_r11: return "r11"; - case dwarf_r12: return "r12"; - case dwarf_sp: return "sp"; - case dwarf_lr: return "lr"; - case dwarf_pc: return "pc"; - case dwarf_cpsr:return "cpsr"; - - case dwarf_s0: return "s0"; - case dwarf_s1: return "s1"; - case dwarf_s2: return "s2"; - case dwarf_s3: return "s3"; - case dwarf_s4: return "s4"; - case dwarf_s5: return "s5"; - case dwarf_s6: return "s6"; - case dwarf_s7: return "s7"; - case dwarf_s8: return "s8"; - case dwarf_s9: return "s9"; - case dwarf_s10: return "s10"; - case dwarf_s11: return "s11"; - case dwarf_s12: return "s12"; - case dwarf_s13: return "s13"; - case dwarf_s14: return "s14"; - case dwarf_s15: return "s15"; - case dwarf_s16: return "s16"; - case dwarf_s17: return "s17"; - case dwarf_s18: return "s18"; - case dwarf_s19: return "s19"; - case dwarf_s20: return "s20"; - case dwarf_s21: return "s21"; - case dwarf_s22: return "s22"; - case dwarf_s23: return "s23"; - case dwarf_s24: return "s24"; - case dwarf_s25: return "s25"; - case dwarf_s26: return "s26"; - case dwarf_s27: return "s27"; - case dwarf_s28: return "s28"; - case dwarf_s29: return "s29"; - case dwarf_s30: return "s30"; - case dwarf_s31: return "s31"; - - // FPA Registers 0-7 - case dwarf_f0: return "f0"; - case dwarf_f1: return "f1"; - case dwarf_f2: return "f2"; - case dwarf_f3: return "f3"; - case dwarf_f4: return "f4"; - case dwarf_f5: return "f5"; - case dwarf_f6: return "f6"; - case dwarf_f7: return "f7"; - - // Intel wireless MMX general purpose registers 0???7 - // XScale accumulator register 0???7 (they do overlap with wCGR0 - wCGR7) - case dwarf_wCGR0: return "wCGR0/ACC0"; - case dwarf_wCGR1: return "wCGR1/ACC1"; - case dwarf_wCGR2: return "wCGR2/ACC2"; - case dwarf_wCGR3: return "wCGR3/ACC3"; - case dwarf_wCGR4: return "wCGR4/ACC4"; - case dwarf_wCGR5: return "wCGR5/ACC5"; - case dwarf_wCGR6: return "wCGR6/ACC6"; - case dwarf_wCGR7: return "wCGR7/ACC7"; - - // Intel wireless MMX data registers 0???15 - case dwarf_wR0: return "wR0"; - case dwarf_wR1: return "wR1"; - case dwarf_wR2: return "wR2"; - case dwarf_wR3: return "wR3"; - case dwarf_wR4: return "wR4"; - case dwarf_wR5: return "wR5"; - case dwarf_wR6: return "wR6"; - case dwarf_wR7: return "wR7"; - case dwarf_wR8: return "wR8"; - case dwarf_wR9: return "wR9"; - case dwarf_wR10: return "wR10"; - case dwarf_wR11: return "wR11"; - case dwarf_wR12: return "wR12"; - case dwarf_wR13: return "wR13"; - case dwarf_wR14: return "wR14"; - case dwarf_wR15: return "wR15"; - - case dwarf_spsr: return "spsr"; - case dwarf_spsr_fiq: return "spsr_fiq"; - case dwarf_spsr_irq: return "spsr_irq"; - case dwarf_spsr_abt: return "spsr_abt"; - case dwarf_spsr_und: return "spsr_und"; - case dwarf_spsr_svc: return "spsr_svc"; - - case dwarf_r8_usr: return "r8_usr"; - case dwarf_r9_usr: return "r9_usr"; - case dwarf_r10_usr: return "r10_usr"; - case dwarf_r11_usr: return "r11_usr"; - case dwarf_r12_usr: return "r12_usr"; - case dwarf_r13_usr: return "r13_usr"; - case dwarf_r14_usr: return "r14_usr"; - case dwarf_r8_fiq: return "r8_fiq"; - case dwarf_r9_fiq: return "r9_fiq"; - case dwarf_r10_fiq: return "r10_fiq"; - case dwarf_r11_fiq: return "r11_fiq"; - case dwarf_r12_fiq: return "r12_fiq"; - case dwarf_r13_fiq: return "r13_fiq"; - case dwarf_r14_fiq: return "r14_fiq"; - case dwarf_r13_irq: return "r13_irq"; - case dwarf_r14_irq: return "r14_irq"; - case dwarf_r13_abt: return "r13_abt"; - case dwarf_r14_abt: return "r14_abt"; - case dwarf_r13_und: return "r13_und"; - case dwarf_r14_und: return "r14_und"; - case dwarf_r13_svc: return "r13_svc"; - case dwarf_r14_svc: return "r14_svc"; - - // Intel wireless MMX control register in co-processor 0???7 - case dwarf_wC0: return "wC0"; - case dwarf_wC1: return "wC1"; - case dwarf_wC2: return "wC2"; - case dwarf_wC3: return "wC3"; - case dwarf_wC4: return "wC4"; - case dwarf_wC5: return "wC5"; - case dwarf_wC6: return "wC6"; - case dwarf_wC7: return "wC7"; - - // VFP-v3/Neon - case dwarf_d0: return "d0"; - case dwarf_d1: return "d1"; - case dwarf_d2: return "d2"; - case dwarf_d3: return "d3"; - case dwarf_d4: return "d4"; - case dwarf_d5: return "d5"; - case dwarf_d6: return "d6"; - case dwarf_d7: return "d7"; - case dwarf_d8: return "d8"; - case dwarf_d9: return "d9"; - case dwarf_d10: return "d10"; - case dwarf_d11: return "d11"; - case dwarf_d12: return "d12"; - case dwarf_d13: return "d13"; - case dwarf_d14: return "d14"; - case dwarf_d15: return "d15"; - case dwarf_d16: return "d16"; - case dwarf_d17: return "d17"; - case dwarf_d18: return "d18"; - case dwarf_d19: return "d19"; - case dwarf_d20: return "d20"; - case dwarf_d21: return "d21"; - case dwarf_d22: return "d22"; - case dwarf_d23: return "d23"; - case dwarf_d24: return "d24"; - case dwarf_d25: return "d25"; - case dwarf_d26: return "d26"; - case dwarf_d27: return "d27"; - case dwarf_d28: return "d28"; - case dwarf_d29: return "d29"; - case dwarf_d30: return "d30"; - case dwarf_d31: return "d31"; - } - return 0; -} - Copied: lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp (from r130203, lldb/trunk/source/Utility/ARM_DWARF_Registers.c) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp?p2=lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp&p1=lldb/trunk/source/Utility/ARM_DWARF_Registers.c&r1=130203&r2=130256&rev=130256&view=diff ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.c (original) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp Tue Apr 26 18:48:45 2011 @@ -9,6 +9,9 @@ #include "ARM_DWARF_Registers.h" +using namespace lldb; +using namespace lldb_private; + const char * GetARMDWARFRegisterName (unsigned reg_num) { @@ -181,3 +184,205 @@ return 0; } +bool +GetARMDWARFRegisterInfo (unsigned reg_num, RegisterInfo ®_info) +{ + ::memset (®_info, 0, sizeof(RegisterInfo)); + ::memset (reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds)); + + if (reg_num >= dwarf_d0 && reg_num <= dwarf_d31) + { + reg_info.byte_size = 8; + reg_info.format = eFormatFloat; + reg_info.encoding = eEncodingIEEE754; + } + else if (reg_num >= dwarf_s0 && reg_num <= dwarf_s31) + { + reg_info.byte_size = 4; + reg_info.format = eFormatFloat; + reg_info.encoding = eEncodingIEEE754; + } + else if (reg_num >= dwarf_f0 && reg_num <= dwarf_f7) + { + reg_info.byte_size = 12; + reg_info.format = eFormatFloat; + reg_info.encoding = eEncodingIEEE754; + } + else + { + reg_info.byte_size = 4; + reg_info.format = eFormatHex; + reg_info.encoding = eEncodingUint; + } + + reg_info.kinds[eRegisterKindDWARF] = reg_num; + + switch (reg_num) + { + case dwarf_r0: reg_info.name = "r0"; break; + case dwarf_r1: reg_info.name = "r1"; break; + case dwarf_r2: reg_info.name = "r2"; break; + case dwarf_r3: reg_info.name = "r3"; break; + case dwarf_r4: reg_info.name = "r4"; break; + case dwarf_r5: reg_info.name = "r5"; break; + case dwarf_r6: reg_info.name = "r6"; break; + case dwarf_r7: reg_info.name = "r7"; reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break; + case dwarf_r8: reg_info.name = "r8"; break; + case dwarf_r9: reg_info.name = "r9"; break; + case dwarf_r10: reg_info.name = "r10"; break; + case dwarf_r11: reg_info.name = "r11"; break; + case dwarf_r12: reg_info.name = "r12"; break; + case dwarf_sp: reg_info.name = "sp"; reg_info.alt_name = "r13"; reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break; + case dwarf_lr: reg_info.name = "lr"; reg_info.alt_name = "r14"; reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break; + case dwarf_pc: reg_info.name = "pc"; reg_info.alt_name = "r15"; reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break; + case dwarf_cpsr:reg_info.name = "cpsr"; reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break; + + case dwarf_s0: reg_info.name = "s0"; break; + case dwarf_s1: reg_info.name = "s1"; break; + case dwarf_s2: reg_info.name = "s2"; break; + case dwarf_s3: reg_info.name = "s3"; break; + case dwarf_s4: reg_info.name = "s4"; break; + case dwarf_s5: reg_info.name = "s5"; break; + case dwarf_s6: reg_info.name = "s6"; break; + case dwarf_s7: reg_info.name = "s7"; break; + case dwarf_s8: reg_info.name = "s8"; break; + case dwarf_s9: reg_info.name = "s9"; break; + case dwarf_s10: reg_info.name = "s10"; break; + case dwarf_s11: reg_info.name = "s11"; break; + case dwarf_s12: reg_info.name = "s12"; break; + case dwarf_s13: reg_info.name = "s13"; break; + case dwarf_s14: reg_info.name = "s14"; break; + case dwarf_s15: reg_info.name = "s15"; break; + case dwarf_s16: reg_info.name = "s16"; break; + case dwarf_s17: reg_info.name = "s17"; break; + case dwarf_s18: reg_info.name = "s18"; break; + case dwarf_s19: reg_info.name = "s19"; break; + case dwarf_s20: reg_info.name = "s20"; break; + case dwarf_s21: reg_info.name = "s21"; break; + case dwarf_s22: reg_info.name = "s22"; break; + case dwarf_s23: reg_info.name = "s23"; break; + case dwarf_s24: reg_info.name = "s24"; break; + case dwarf_s25: reg_info.name = "s25"; break; + case dwarf_s26: reg_info.name = "s26"; break; + case dwarf_s27: reg_info.name = "s27"; break; + case dwarf_s28: reg_info.name = "s28"; break; + case dwarf_s29: reg_info.name = "s29"; break; + case dwarf_s30: reg_info.name = "s30"; break; + case dwarf_s31: reg_info.name = "s31"; break; + + // FPA Registers 0-7 + case dwarf_f0: reg_info.name = "f0"; break; + case dwarf_f1: reg_info.name = "f1"; break; + case dwarf_f2: reg_info.name = "f2"; break; + case dwarf_f3: reg_info.name = "f3"; break; + case dwarf_f4: reg_info.name = "f4"; break; + case dwarf_f5: reg_info.name = "f5"; break; + case dwarf_f6: reg_info.name = "f6"; break; + case dwarf_f7: reg_info.name = "f7"; break; + + // Intel wireless MMX general purpose registers 0???7 + // XScale accumulator register 0???7 (they do overlap with wCGR0 - wCGR7) + case dwarf_wCGR0: reg_info.name = "wCGR0/ACC0"; break; + case dwarf_wCGR1: reg_info.name = "wCGR1/ACC1"; break; + case dwarf_wCGR2: reg_info.name = "wCGR2/ACC2"; break; + case dwarf_wCGR3: reg_info.name = "wCGR3/ACC3"; break; + case dwarf_wCGR4: reg_info.name = "wCGR4/ACC4"; break; + case dwarf_wCGR5: reg_info.name = "wCGR5/ACC5"; break; + case dwarf_wCGR6: reg_info.name = "wCGR6/ACC6"; break; + case dwarf_wCGR7: reg_info.name = "wCGR7/ACC7"; break; + + // Intel wireless MMX data registers 0???15 + case dwarf_wR0: reg_info.name = "wR0"; break; + case dwarf_wR1: reg_info.name = "wR1"; break; + case dwarf_wR2: reg_info.name = "wR2"; break; + case dwarf_wR3: reg_info.name = "wR3"; break; + case dwarf_wR4: reg_info.name = "wR4"; break; + case dwarf_wR5: reg_info.name = "wR5"; break; + case dwarf_wR6: reg_info.name = "wR6"; break; + case dwarf_wR7: reg_info.name = "wR7"; break; + case dwarf_wR8: reg_info.name = "wR8"; break; + case dwarf_wR9: reg_info.name = "wR9"; break; + case dwarf_wR10: reg_info.name = "wR10"; break; + case dwarf_wR11: reg_info.name = "wR11"; break; + case dwarf_wR12: reg_info.name = "wR12"; break; + case dwarf_wR13: reg_info.name = "wR13"; break; + case dwarf_wR14: reg_info.name = "wR14"; break; + case dwarf_wR15: reg_info.name = "wR15"; break; + + case dwarf_spsr: reg_info.name = "spsr"; break; + case dwarf_spsr_fiq: reg_info.name = "spsr_fiq"; break; + case dwarf_spsr_irq: reg_info.name = "spsr_irq"; break; + case dwarf_spsr_abt: reg_info.name = "spsr_abt"; break; + case dwarf_spsr_und: reg_info.name = "spsr_und"; break; + case dwarf_spsr_svc: reg_info.name = "spsr_svc"; break; + + case dwarf_r8_usr: reg_info.name = "r8_usr"; break; + case dwarf_r9_usr: reg_info.name = "r9_usr"; break; + case dwarf_r10_usr: reg_info.name = "r10_usr"; break; + case dwarf_r11_usr: reg_info.name = "r11_usr"; break; + case dwarf_r12_usr: reg_info.name = "r12_usr"; break; + case dwarf_r13_usr: reg_info.name = "r13_usr"; break; + case dwarf_r14_usr: reg_info.name = "r14_usr"; break; + case dwarf_r8_fiq: reg_info.name = "r8_fiq"; break; + case dwarf_r9_fiq: reg_info.name = "r9_fiq"; break; + case dwarf_r10_fiq: reg_info.name = "r10_fiq"; break; + case dwarf_r11_fiq: reg_info.name = "r11_fiq"; break; + case dwarf_r12_fiq: reg_info.name = "r12_fiq"; break; + case dwarf_r13_fiq: reg_info.name = "r13_fiq"; break; + case dwarf_r14_fiq: reg_info.name = "r14_fiq"; break; + case dwarf_r13_irq: reg_info.name = "r13_irq"; break; + case dwarf_r14_irq: reg_info.name = "r14_irq"; break; + case dwarf_r13_abt: reg_info.name = "r13_abt"; break; + case dwarf_r14_abt: reg_info.name = "r14_abt"; break; + case dwarf_r13_und: reg_info.name = "r13_und"; break; + case dwarf_r14_und: reg_info.name = "r14_und"; break; + case dwarf_r13_svc: reg_info.name = "r13_svc"; break; + case dwarf_r14_svc: reg_info.name = "r14_svc"; break; + + // Intel wireless MMX control register in co-processor 0???7 + case dwarf_wC0: reg_info.name = "wC0"; break; + case dwarf_wC1: reg_info.name = "wC1"; break; + case dwarf_wC2: reg_info.name = "wC2"; break; + case dwarf_wC3: reg_info.name = "wC3"; break; + case dwarf_wC4: reg_info.name = "wC4"; break; + case dwarf_wC5: reg_info.name = "wC5"; break; + case dwarf_wC6: reg_info.name = "wC6"; break; + case dwarf_wC7: reg_info.name = "wC7"; break; + + // VFP-v3/Neon + case dwarf_d0: reg_info.name = "d0"; break; + case dwarf_d1: reg_info.name = "d1"; break; + case dwarf_d2: reg_info.name = "d2"; break; + case dwarf_d3: reg_info.name = "d3"; break; + case dwarf_d4: reg_info.name = "d4"; break; + case dwarf_d5: reg_info.name = "d5"; break; + case dwarf_d6: reg_info.name = "d6"; break; + case dwarf_d7: reg_info.name = "d7"; break; + case dwarf_d8: reg_info.name = "d8"; break; + case dwarf_d9: reg_info.name = "d9"; break; + case dwarf_d10: reg_info.name = "d10"; break; + case dwarf_d11: reg_info.name = "d11"; break; + case dwarf_d12: reg_info.name = "d12"; break; + case dwarf_d13: reg_info.name = "d13"; break; + case dwarf_d14: reg_info.name = "d14"; break; + case dwarf_d15: reg_info.name = "d15"; break; + case dwarf_d16: reg_info.name = "d16"; break; + case dwarf_d17: reg_info.name = "d17"; break; + case dwarf_d18: reg_info.name = "d18"; break; + case dwarf_d19: reg_info.name = "d19"; break; + case dwarf_d20: reg_info.name = "d20"; break; + case dwarf_d21: reg_info.name = "d21"; break; + case dwarf_d22: reg_info.name = "d22"; break; + case dwarf_d23: reg_info.name = "d23"; break; + case dwarf_d24: reg_info.name = "d24"; break; + case dwarf_d25: reg_info.name = "d25"; break; + case dwarf_d26: reg_info.name = "d26"; break; + case dwarf_d27: reg_info.name = "d27"; break; + case dwarf_d28: reg_info.name = "d28"; break; + case dwarf_d29: reg_info.name = "d29"; break; + case dwarf_d30: reg_info.name = "d30"; break; + case dwarf_d31: reg_info.name = "d31"; break; + default: return false; + } + return true; +} Modified: lldb/trunk/source/Utility/ARM_DWARF_Registers.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.h?rev=130256&r1=130255&r2=130256&view=diff ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.h (original) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.h Tue Apr 26 18:48:45 2011 @@ -10,6 +10,8 @@ #ifndef utility_ARM_DWARF_Registers_h_ #define utility_ARM_DWARF_Registers_h_ +#include "lldb/lldb-private.h" + enum { dwarf_r0 = 0, @@ -186,16 +188,12 @@ dwarf_d31 }; -#if defined(__cplusplus) -extern "C" { -#endif - const char * GetARMDWARFRegisterName (unsigned reg_num); - -#if defined(__cplusplus) -} -#endif + +bool +GetARMDWARFRegisterInfo (unsigned reg_num, + lldb_private::RegisterInfo ®_info); #endif // utility_ARM_DWARF_Registers_h_ From johnny.chen at apple.com Tue Apr 26 18:54:26 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Apr 2011 23:54:26 -0000 Subject: [Lldb-commits] [lldb] r130258 - /lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Message-ID: <20110426235426.210BB2A6C12D@llvm.org> Author: johnny Date: Tue Apr 26 18:54:25 2011 New Revision: 130258 URL: http://llvm.org/viewvc/llvm-project?rev=130258&view=rev Log: Add a test case for lldbutil.lldb_iter() which returns an iterator object for lldb objects which can contain other lldb objects. Examples are: SBTarget contains SBModule, SBModule contains SBSymbols, SBProcess contains SBThread, SBThread contains SBFrame, etc. Added: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Added: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130258&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (added) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Tue Apr 26 18:54:25 2011 @@ -0,0 +1,64 @@ +""" +Test lldbutil.lldb_iter() which returns an iterator object for lldb's aggregate +data structures. +""" + +import os, time +import re +import unittest2 +import lldb +from lldbtest import * + +class LLDBIteratorTestCase(TestBase): + + mydir = "python_api/lldbutil" + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.line = line_number('main.cpp', '// Set break point at this line.') + + def test_lldb_iter(self): + """Test lldb_iter works correctly.""" + self.buildDefault() + self.lldb_iter_test() + + def lldb_iter_test(self): + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + + if not rc.Success() or not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + + from lldbutil import lldb_iter, get_description + yours = [] + for i in range(target.GetNumModules()): + yours.append(target.GetModuleAtIndex(i)) + mine = [] + for m in lldb_iter(target, 'GetNumModules', 'GetModuleAtIndex'): + mine.append(m) + + self.assertTrue(len(yours) == len(mine)) + for i in range(len(yours)): + if self.TraceOn(): + print "yours[%d]='%s'" % (i, get_description(yours[i])) + print "mine[%d]='%s'" % (i, get_description(mine[i])) + self.assertTrue(yours[i].GetUUIDString() == mine[i].GetUUIDString(), + "UUID of yours[%d] and mine[%d] matches" % (i, i)) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From johnny.chen at apple.com Wed Apr 27 12:43:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Apr 2011 17:43:07 -0000 Subject: [Lldb-commits] [lldb] r130314 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py class_static/TestStaticVariables.py class_types/TestClassTypes.py expression_command/test/TestExprs.py foundation/TestObjCMethods.py hello_world/TestHelloWorld.py inferior-crashing/TestInferiorCrashing.py lldbtest.py lldbutil.py objc-stepping/TestObjCStepping.py python_api/lldbutil/TestPrintStackTraces.py python_api/process/TestProcessAPI.py Message-ID: <20110427174307.DA2672A6C12D@llvm.org> Author: johnny Date: Wed Apr 27 12:43:07 2011 New Revision: 130314 URL: http://llvm.org/viewvc/llvm-project?rev=130314&view=rev Log: Change the rest of lldbutil.py's function names to all lower case formats to be consistent. And modify the test cases accordingly. Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/class_static/TestStaticVariables.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/expression_command/test/TestExprs.py lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/hello_world/TestHelloWorld.py lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py lldb/trunk/test/lldbtest.py lldb/trunk/test/lldbutil.py lldb/trunk/test/objc-stepping/TestObjCStepping.py lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py lldb/trunk/test/python_api/process/TestProcessAPI.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Apr 27 12:43:07 2011 @@ -124,9 +124,9 @@ # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # Sanity check the print representation of thread. thr = repr(thread) @@ -201,15 +201,15 @@ # Last, check that "long_6" has a value type of eValueTypeVariableLocal # and "argc" has eValueTypeVariableArgument. - from lldbutil import ValueTypeString + from lldbutil import value_type_to_str self.assertTrue(variable.GetValueType() == lldb.eValueTypeVariableLocal, "Variable 'long_6' should have '%s' value type." % - ValueTypeString(lldb.eValueTypeVariableLocal)) + value_type_to_str(lldb.eValueTypeVariableLocal)) argc = frame.FindVariable("argc") self.DebugSBValue(frame, argc) self.assertTrue(argc.GetValueType() == lldb.eValueTypeVariableArgument, "Variable 'argc' should have '%s' value type." % - ValueTypeString(lldb.eValueTypeVariableArgument)) + value_type_to_str(lldb.eValueTypeVariableArgument)) if __name__ == '__main__': Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Wed Apr 27 12:43:07 2011 @@ -100,9 +100,9 @@ # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) Modified: lldb/trunk/test/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/TestStaticVariables.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/class_static/TestStaticVariables.py Wed Apr 27 12:43:07 2011 @@ -88,9 +88,9 @@ # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # Get the SBValue of 'A::g_points' and 'g_points'. frame = thread.GetFrameAtIndex(0) Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Apr 27 12:43:07 2011 @@ -129,14 +129,14 @@ if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.StateTypeString(self.process.GetState())) + lldbutil.state_type_to_str(self.process.GetState())) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. Modified: lldb/trunk/test/expression_command/test/TestExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/expression_command/test/TestExprs.py (original) +++ lldb/trunk/test/expression_command/test/TestExprs.py Wed Apr 27 12:43:07 2011 @@ -109,14 +109,14 @@ if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.StateTypeString(self.process.GetState())) + lldbutil.state_type_to_str(self.process.GetState())) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # The filename of frame #0 should be 'main.cpp' and function is main. self.expect(lldbutil.get_filenames(thread)[0], Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Apr 27 12:43:07 2011 @@ -220,9 +220,9 @@ # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # Make sure we stopped at the first breakpoint. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Wed Apr 27 12:43:07 2011 @@ -71,9 +71,9 @@ thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Wed Apr 27 12:43:07 2011 @@ -64,7 +64,7 @@ if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.StateTypeString(self.process.GetState())) + lldbutil.state_type_to_str(self.process.GetState())) thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonException) if not thread: Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Apr 27 12:43:07 2011 @@ -863,7 +863,7 @@ thread = process.GetThreadAtIndex(0) SR = thread.GetStopReason() with recording(self, trace) as sbuf: - print >> sbuf, "StopReason =", StopReasonString(SR) + print >> sbuf, "StopReason =", stop_reason_to_str(SR) if SR == StopReasonEnum("Breakpoint"): frame = thread.GetFrameAtIndex(0) @@ -932,7 +932,7 @@ def DebugSBValue(self, frame, val): """Debug print a SBValue object, if traceAlways is True.""" - from lldbutil import ValueTypeString + from lldbutil import value_type_to_str if not traceAlways: return @@ -943,7 +943,7 @@ err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n') err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n') err.write('\t' + "Value -> " + str(val.GetValue(frame)) + '\n') - err.write('\t' + "ValueType -> " + ValueTypeString(val.GetValueType()) + '\n') + err.write('\t' + "ValueType -> " + value_type_to_str(val.GetValueType()) + '\n') err.write('\t' + "Summary -> " + str(val.GetSummary(frame)) + '\n') err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n') err.write('\t' + "Location -> " + val.GetLocation(frame) + '\n') Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed Apr 27 12:43:07 2011 @@ -166,7 +166,7 @@ # Convert some enum value to its string counterpart # ================================================= -def StateTypeString(enum): +def state_type_to_str(enum): """Returns the stateType string given an enum.""" if enum == lldb.eStateInvalid: return "invalid" @@ -195,7 +195,7 @@ else: raise Exception("Unknown StateType enum") -def StopReasonString(enum): +def stop_reason_to_str(enum): """Returns the stopReason string given an enum.""" if enum == lldb.eStopReasonInvalid: return "invalid" @@ -216,7 +216,7 @@ else: raise Exception("Unknown StopReason enum") -def ValueTypeString(enum): +def value_type_to_str(enum): """Returns the valueType string given an enum.""" if enum == lldb.eValueTypeInvalid: return "invalid" @@ -404,7 +404,7 @@ addrs = get_pc_addresses(thread) if thread.GetStopReason() != lldb.eStopReasonInvalid: - desc = "stop reason=" + StopReasonString(thread.GetStopReason()) + desc = "stop reason=" + stop_reason_to_str(thread.GetStopReason()) else: desc = "" print >> output, "Stack trace for thread id={0:#x} name={1} queue={2} ".format( Modified: lldb/trunk/test/objc-stepping/TestObjCStepping.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-stepping/TestObjCStepping.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/objc-stepping/TestObjCStepping.py (original) +++ lldb/trunk/test/objc-stepping/TestObjCStepping.py Wed Apr 27 12:43:07 2011 @@ -71,9 +71,9 @@ # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import StopReasonString + from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - StopReasonString(thread.GetStopReason())) + stop_reason_to_str(thread.GetStopReason())) # Make sure we stopped at the first breakpoint. Modified: lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py Wed Apr 27 12:43:07 2011 @@ -44,7 +44,7 @@ if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.StateTypeString(self.process.GetState())) + lldbutil.state_type_to_str(self.process.GetState())) if self.TraceOn(): lldbutil.print_stacktraces(self.process) Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=130314&r1=130313&r2=130314&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Wed Apr 27 12:43:07 2011 @@ -5,7 +5,7 @@ import os, time import unittest2 import lldb -from lldbutil import get_stopped_thread, StateTypeString +from lldbutil import get_stopped_thread, state_type_to_str from lldbtest import * class ProcessAPITestCase(TestBase): @@ -258,7 +258,7 @@ process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) if self.TraceOn(): - print "process state:", StateTypeString(process.GetState()) + print "process state:", state_type_to_str(process.GetState()) self.assertTrue(process.GetState() != lldb.eStateConnected) success = process.RemoteLaunch(None, None, None, None, None, None, 0, False, error) From jingham at apple.com Wed Apr 27 13:49:18 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 27 Apr 2011 18:49:18 -0000 Subject: [Lldb-commits] [lldb] r130319 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20110427184918.258F92A6C12D@llvm.org> Author: jingham Date: Wed Apr 27 13:49:17 2011 New Revision: 130319 URL: http://llvm.org/viewvc/llvm-project?rev=130319&view=rev Log: Removing Greg's working directory & startup arguments from the shared lldb-tool scheme. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=130319&r1=130318&r2=130319&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Wed Apr 27 13:49:17 2011 @@ -75,9 +75,9 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" - useCustomWorkingDirectory = "YES" - customWorkingDirectory = "/Volumes/work/gclayton/Documents/src/lldb/build/Debug" - buildConfiguration = "Debug"> + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + ignoresPersistentStateOnLaunch = "YES"> - - - - + buildConfiguration = "Release" + ignoresPersistentStateOnLaunch = "YES"> Author: johnny Date: Wed Apr 27 14:29:39 2011 New Revision: 130323 URL: http://llvm.org/viewvc/llvm-project?rev=130323&view=rev Log: Add another test case for lldb_iter(), this time using SBTarget to get at its SBBreakpoint containees. Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/main.cpp Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130323&r1=130322&r2=130323&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Wed Apr 27 14:29:39 2011 @@ -16,21 +16,27 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break inside main(). - self.line = line_number('main.cpp', '// Set break point at this line.') + # Find the line numbers to break inside main(). + self.line1 = line_number('main.cpp', '// Set break point at this line.') + self.line2 = line_number('main.cpp', '// And that line.') - def test_lldb_iter(self): - """Test lldb_iter works correctly.""" + def test_lldb_iter_1(self): + """Test lldb_iter works correctly for SBTarget -> SBModule.""" self.buildDefault() - self.lldb_iter_test() + self.lldb_iter_1() - def lldb_iter_test(self): + def test_lldb_iter_2(self): + """Test lldb_iter works correctly for SBTarget -> SBBreakpoint.""" + self.buildDefault() + self.lldb_iter_2() + + def lldb_iter_1(self): exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target.IsValid(), VALID_TARGET) - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. @@ -56,6 +62,35 @@ self.assertTrue(yours[i].GetUUIDString() == mine[i].GetUUIDString(), "UUID of yours[%d] and mine[%d] matches" % (i, i)) + def lldb_iter_2(self): + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line2) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + self.assertTrue(target.GetNumBreakpoints() == 2) + + from lldbutil import lldb_iter, get_description + yours = [] + for i in range(target.GetNumBreakpoints()): + yours.append(target.GetBreakpointAtIndex(i)) + mine = [] + for m in lldb_iter(target, 'GetNumBreakpoints', 'GetBreakpointAtIndex'): + mine.append(m) + + self.assertTrue(len(yours) == len(mine)) + for i in range(len(yours)): + if self.TraceOn(): + print "yours[%d]='%s'" % (i, get_description(yours[i])) + print "mine[%d]='%s'" % (i, get_description(mine[i])) + self.assertTrue(yours[i].GetID() == mine[i].GetID(), + "ID of yours[%d] and mine[%d] matches" % (i, i)) + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/python_api/lldbutil/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/main.cpp?rev=130323&r1=130322&r2=130323&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/main.cpp (original) +++ lldb/trunk/test/python_api/lldbutil/main.cpp Wed Apr 27 14:29:39 2011 @@ -82,7 +82,7 @@ uint32_t thread_mask_3 = (1u << thread_index_3); // Make a mask that will keep all threads alive - mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); + mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line. // Create 3 threads err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); From johnny.chen at apple.com Wed Apr 27 14:52:41 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Apr 2011 19:52:41 -0000 Subject: [Lldb-commits] [lldb] r130325 - /lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Message-ID: <20110427195241.4FF5D2A6C12D@llvm.org> Author: johnny Date: Wed Apr 27 14:52:41 2011 New Revision: 130325 URL: http://llvm.org/viewvc/llvm-project?rev=130325&view=rev Log: Use new string formatting operations in assert messages to simplify things. Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130325&r1=130324&r2=130325&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Wed Apr 27 14:52:41 2011 @@ -60,7 +60,7 @@ print "yours[%d]='%s'" % (i, get_description(yours[i])) print "mine[%d]='%s'" % (i, get_description(mine[i])) self.assertTrue(yours[i].GetUUIDString() == mine[i].GetUUIDString(), - "UUID of yours[%d] and mine[%d] matches" % (i, i)) + "UUID of yours[{0}] and mine[{0}] matches".format(i)) def lldb_iter_2(self): exe = os.path.join(os.getcwd(), "a.out") @@ -89,7 +89,7 @@ print "yours[%d]='%s'" % (i, get_description(yours[i])) print "mine[%d]='%s'" % (i, get_description(mine[i])) self.assertTrue(yours[i].GetID() == mine[i].GetID(), - "ID of yours[%d] and mine[%d] matches" % (i, i)) + "ID of yours[{0}] and mine[{0}] matches".format(i)) if __name__ == '__main__': From johnny.chen at apple.com Wed Apr 27 16:44:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Apr 2011 21:44:09 -0000 Subject: [Lldb-commits] [lldb] r130332 - in /lldb/trunk/test: lldbutil.py python_api/lldbutil/TestLLDBIterator.py Message-ID: <20110427214409.4C8DA2A6C12D@llvm.org> Author: johnny Date: Wed Apr 27 16:44:09 2011 New Revision: 130332 URL: http://llvm.org/viewvc/llvm-project?rev=130332&view=rev Log: Add a utility function smart_iter() which has knowledge of the getsize and the getelem method names of all the lldb container objects and returns an iterator object when passed an eligible lldb container object. Example: from lldb_util import smart_iter for thread in smart_iter(process): ID = thread.GetThreadID() if thread.GetStopReason() == lldb.eStopReasonBreakpoint: stopped_due_to_breakpoint = True for frame in smart_iter(thread): self.assertTrue(frame.GetThread().GetThreadID() == ID) ... Add a test case for lldb.smart_iter(). Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130332&r1=130331&r2=130332&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed Apr 27 16:44:09 2011 @@ -56,11 +56,55 @@ name = symbol.GetName() ... """ + #import traceback + #traceback.print_stack() size = getattr(obj, getsize) elem = getattr(obj, getelem) for i in range(size()): yield elem(i) +def smart_iter(obj): + """Returns an iterator for eligible lldb objects, or None otherwise. + + An example of eligible lldb container object is SBModule, which contains + SBSymbols. While SBTarget contains SBModules and SBBreakpoints, because it + is ambiguous which containee type to iterate on, the best we can do is to + return None. API clients can use lldb_iter() to clarify their intentions. + + SBSymbol does not have the notion of containee objects and is not eligible + for smart iterator. + + Example usage: + + from lldb_util import smart_iter + for thread in smart_iter(process): + ID = thread.GetThreadID() + if thread.GetStopReason() == lldb.eStopReasonBreakpoint: + stopped_due_to_breakpoint = True + for frame in smart_iter(thread): + self.assertTrue(frame.GetThread().GetThreadID() == ID) + ... + """ + d = { lldb.SBBreakpoint: ('GetNumLocations', 'GetLocationAtIndex'), + lldb.SBCompileUnit: ('GetNumLineEntries', 'GetLineEntryAtIndex'), + lldb.SBDebugger: ('GetNumTargets', 'GetTargetAtIndex'), + lldb.SBModule: ('GetNumSymbols', 'GetSymbolAtIndex'), + lldb.SBProcess: ('GetNumThreads', 'GetThreadAtIndex'), + lldb.SBThread: ('GetNumFrames', 'GetFrameAtIndex'), + + lldb.SBInstructionList: ('GetSize', 'GetInstructionAtIndex'), + lldb.SBStringList: ('GetSize', 'GetStringAtIndex',), + lldb.SBSymbolContextList: ('GetSize', 'GetContextAtIndex'), + lldb.SBValueList: ('GetSize', 'GetValueAtIndex'), + + lldb.SBType: ('GetNumberChildren', 'GetChildAtIndex'), + lldb.SBValue: ('GetNumChildren', 'GetChildAtIndex') + } + if obj.__class__ in d: + val = d.get(obj.__class__) + return lldb_iter(obj, val[0], val[1]) + else: + return None # =================================================== # Disassembly for an SBFunction or an SBSymbol object Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130332&r1=130331&r2=130332&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Wed Apr 27 16:44:09 2011 @@ -1,6 +1,6 @@ """ -Test lldbutil.lldb_iter() which returns an iterator object for lldb's aggregate -data structures. +Test lldb_iter/smart_iter() which returns an iterator object for lldb container +objects. """ import os, time @@ -30,6 +30,11 @@ self.buildDefault() self.lldb_iter_2() + def test_smart_iter_1(self): + """Test smart_iter works correctly for SBProcess->SBThread->SBFrame.""" + self.buildDefault() + self.smart_iter_1() + def lldb_iter_1(self): exe = os.path.join(os.getcwd(), "a.out") @@ -91,6 +96,36 @@ self.assertTrue(yours[i].GetID() == mine[i].GetID(), "ID of yours[{0}] and mine[{0}] matches".format(i)) + def smart_iter_1(self): + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + + if not rc.Success() or not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + + from lldbutil import smart_iter, print_stacktrace + stopped_due_to_breakpoint = False + for thread in smart_iter(self.process): + if self.TraceOn(): + print_stacktrace(thread) + ID = thread.GetThreadID() + if thread.GetStopReason() == lldb.eStopReasonBreakpoint: + stopped_due_to_breakpoint = True + for frame in smart_iter(thread): + self.assertTrue(frame.GetThread().GetThreadID() == ID) + if self.TraceOn(): + print frame + + self.assertTrue(stopped_due_to_breakpoint) if __name__ == '__main__': import atexit From gclayton at apple.com Wed Apr 27 17:04:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 27 Apr 2011 22:04:39 -0000 Subject: [Lldb-commits] [lldb] r130334 - in /lldb/trunk: include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Symbol/ lldb.xcodeproj/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/Instruction/ARM/ Message-ID: <20110427220439.EA3052A6C12D@llvm.org> Author: gclayton Date: Wed Apr 27 17:04:39 2011 New Revision: 130334 URL: http://llvm.org/viewvc/llvm-project?rev=130334&view=rev Log: Added a new OptionValue subclass for lldb::Format: OptionValueFormat. Added new OptionGroup subclasses for: - output file for use with options: long opts: --outfile --append--output short opts: -o -A - format for use with options: long opts: --format - variable object display controls for depth, pointer depth, wether to show types, show summary, show location, flat output, use objc "po" style summary. Modified ValueObjectMemory to be able to be created either with a TypeSP or a ClangASTType. Switched "memory read" over to use OptionGroup subclasses: one for the outfile options, one for the command specific options, and one for the format. Added: lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/trunk/source/Interpreter/OptionGroupFormat.cpp lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Modified: lldb/trunk/include/lldb/Core/State.h lldb/trunk/include/lldb/Core/ValueObjectMemory.h lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Core/State.cpp lldb/trunk/source/Core/ValueObjectMemory.cpp lldb/trunk/source/Interpreter/NamedOptionValue.cpp lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Modified: lldb/trunk/include/lldb/Core/State.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/State.h?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/State.h (original) +++ lldb/trunk/include/lldb/Core/State.h Wed Apr 27 17:04:39 2011 @@ -38,6 +38,9 @@ bool StateIsStoppedState (lldb::StateType state); +const char * +GetFormatAsCString (lldb::Format format); + } // namespace lldb_private #endif // liblldb_State_h_ Modified: lldb/trunk/include/lldb/Core/ValueObjectMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectMemory.h?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectMemory.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectMemory.h Wed Apr 27 17:04:39 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ValueObject.h" +#include "lldb/Symbol/ClangASTType.h" namespace lldb_private { @@ -31,6 +32,12 @@ const Address &address, lldb::TypeSP &type_sp); + static lldb::ValueObjectSP + Create (ExecutionContextScope *exe_scope, + const char *name, + const Address &address, + const ClangASTType &ast_type); + virtual ~ValueObjectMemory(); @@ -61,6 +68,7 @@ Address m_address; ///< The variable that this value object is based upon lldb::TypeSP m_type_sp; + ClangASTType m_clang_type; private: ValueObjectMemory (ExecutionContextScope *exe_scope, @@ -68,6 +76,10 @@ const Address &address, lldb::TypeSP &type_sp); + ValueObjectMemory (ExecutionContextScope *exe_scope, + const char *name, + const Address &address, + const ClangASTType &ast_type); //------------------------------------------------------------------ // For ValueObject only //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (original) +++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Wed Apr 27 17:04:39 2011 @@ -27,6 +27,7 @@ class OptionValueUInt64; class OptionValueString; class OptionValueFileSpec; + class OptionValueFormat; class OptionValueArray; class OptionValueDictionary; @@ -43,6 +44,7 @@ eTypeDictionary, eTypeEnum, eTypeFileSpec, + eTypeFormat, eTypeSInt64, eTypeUInt64, eTypeString @@ -89,32 +91,38 @@ GetUInt64Value (uint64_t fail_value, bool *success_ptr); OptionValueBoolean * - GetAsBooleanValue (); + GetAsBoolean (); OptionValueSInt64 * - GetAsSInt64Value (); + GetAsSInt64 (); OptionValueUInt64 * - GetAsUInt64Value (); + GetAsUInt64 (); OptionValueString * - GetAsStringValue (); + GetAsString (); OptionValueFileSpec * - GetAsFileSpecValue(); + GetAsFileSpec (); + + OptionValueFormat * + GetAsFormat (); OptionValueArray * - GetAsArrayValue(); + GetAsArray (); OptionValueDictionary * - GetAsDictionaryValue(); + GetAsDictionary (); const char * - GetStringValue (); + GetStringValue (const char *fail_value = NULL); uint64_t - GetUInt64Value (); + GetUInt64Value (uint64_t fail_value = 0); + lldb::Format + GetFormatValue (lldb::Format fail_value = lldb::eFormatDefault); + protected: bool m_value_was_set; // This can be used to see if a value has been set // by a call to SetValueFromCString(). It is often @@ -532,13 +540,13 @@ m_default_value () { } - + OptionValueFileSpec (const FileSpec ¤t_value) : m_current_value (current_value), m_default_value () { } - + OptionValueFileSpec (const FileSpec ¤t_value, const FileSpec &default_value) : m_current_value (current_value), @@ -584,7 +592,13 @@ { return m_current_value; } - + + const FileSpec & + GetCurrentValue() const + { + return m_current_value; + } + const FileSpec & GetDefaultValue() const { @@ -609,6 +623,93 @@ }; //--------------------------------------------------------------------- + // OptionValueFormat + //--------------------------------------------------------------------- + class OptionValueFormat : public OptionValue + { + public: + OptionValueFormat () : + m_current_value (lldb::eFormatInvalid), + m_default_value (lldb::eFormatDefault) + { + } + + OptionValueFormat (lldb::Format current_value) : + m_current_value (current_value), + m_default_value (lldb::eFormatDefault) + { + } + + OptionValueFormat (lldb::Format current_value, + lldb::Format default_value) : + m_current_value (current_value), + m_default_value (default_value) + { + } + + virtual + ~OptionValueFormat() + { + } + + //--------------------------------------------------------------------- + // Virtual subclass pure virtual overrides + //--------------------------------------------------------------------- + + virtual OptionValue::Type + GetType () + { + return eTypeFormat; + } + + virtual void + DumpValue (Stream &strm); + + virtual Error + SetValueFromCString (const char *value); + + virtual bool + Clear () + { + m_current_value = m_default_value; + m_value_was_set = false; + return true; + } + + //--------------------------------------------------------------------- + // Subclass specific functions + //--------------------------------------------------------------------- + + lldb::Format + GetCurrentValue() + { + return m_current_value; + } + + lldb::Format + GetDefaultValue() const + { + return m_default_value; + } + + void + SetCurrentValue (lldb::Format value) + { + m_current_value = value; + } + + void + SetDefaultValue (lldb::Format value) + { + m_default_value = value; + } + + protected: + lldb::Format m_current_value; + lldb::Format m_default_value; + }; + + //--------------------------------------------------------------------- // OptionValueArray //--------------------------------------------------------------------- class OptionValueArray : public OptionValue Added: lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h?rev=130334&view=auto ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h (added) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h Wed Apr 27 17:04:39 2011 @@ -0,0 +1,64 @@ +//===-- OptionGroupFormat.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_OptionGroupFormat_h_ +#define liblldb_OptionGroupFormat_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/NamedOptionValue.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// OptionGroupFormat +//------------------------------------------------------------------------- + +class OptionGroupFormat : public OptionGroup +{ +public: + + OptionGroupFormat (lldb::Format default_format); + + virtual + ~OptionGroupFormat (); + + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + lldb::Format + GetFormat () + { + return m_format.GetCurrentValue(); + } + + +protected: + + OptionValueFormat m_format; +}; + +} // namespace lldb_private + +#endif // liblldb_OptionGroupFormat_h_ Added: lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h?rev=130334&view=auto ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h (added) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h Wed Apr 27 17:04:39 2011 @@ -0,0 +1,69 @@ +//===-- OptionGroupOutputFile.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_OptionGroupOutputFile_h_ +#define liblldb_OptionGroupOutputFile_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/NamedOptionValue.h" + +namespace lldb_private { +//------------------------------------------------------------------------- +// OptionGroupOutputFile +//------------------------------------------------------------------------- + +class OptionGroupOutputFile : public OptionGroup +{ +public: + + OptionGroupOutputFile (); + + virtual + ~OptionGroupOutputFile (); + + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + const OptionValueFileSpec & + GetFile () + { + return m_file; + } + + const OptionValueBoolean & + GetAppend () + { + return m_append; + } + +protected: + OptionValueFileSpec m_file; + OptionValueBoolean m_append; + +}; + +} // namespace lldb_private + +#endif // liblldb_OptionGroupOutputFile_h_ Added: lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h?rev=130334&view=auto ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h (added) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h Wed Apr 27 17:04:39 2011 @@ -0,0 +1,61 @@ +//===-- OptionGroupValueObjectDisplay.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_OptionGroupValueObjectDisplay_h_ +#define liblldb_OptionGroupValueObjectDisplay_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/Options.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// OptionGroupValueObjectDisplay +//------------------------------------------------------------------------- + +class OptionGroupValueObjectDisplay : public OptionGroup +{ +public: + + OptionGroupValueObjectDisplay (); + + virtual + ~OptionGroupValueObjectDisplay (); + + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + bool show_types; + bool show_summary; + bool show_location; + bool flat_output; + bool use_objc; + uint32_t max_depth; + uint32_t ptr_depth; + lldb::Format format; +}; + +} // namespace lldb_private + +#endif // liblldb_OptionGroupValueObjectDisplay_h_ Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Wed Apr 27 17:04:39 2011 @@ -392,6 +392,20 @@ { } + + //---------------------------------------------------------------------- + /// Append options from a OptionGroup class. + /// + /// Append all options from \a group using the exact same option groups + /// that each option is defined with. + /// + /// @param[in] group + /// A group of options to take option values from and copy their + /// definitions into this class. + //---------------------------------------------------------------------- + void + Append (OptionGroup* group); + //---------------------------------------------------------------------- /// Append options from a OptionGroup class. /// Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Wed Apr 27 17:04:39 2011 @@ -27,7 +27,7 @@ //---------------------------------------------------------------------- class ClangASTType { -protected: +public: ClangASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) : m_type (type), m_ast (ast_context) @@ -56,7 +56,6 @@ return *this; } -public: lldb::clang_type_t GetOpaqueQualType() const { @@ -218,6 +217,13 @@ const Scalar &value, Stream &strm); + void + SetClangType (clang::ASTContext *ast, lldb::clang_type_t type) + { + m_type = type; + m_ast = ast; + } + bool ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, @@ -256,8 +262,8 @@ RemoveFastQualifiers (lldb::clang_type_t); private: - void *m_type; - clang::ASTContext *m_ast; + lldb::clang_type_t m_type; + clang::ASTContext *m_ast; }; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Apr 27 17:04:39 2011 @@ -73,6 +73,8 @@ 26744EF21338317700EF765A /* GDBRemoteCommunicationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */; }; 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; }; 26744EF41338317700EF765A /* GDBRemoteCommunicationServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */; }; + 267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */; }; + 267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */; }; 2689000013353DB600698AC0 /* BreakpointResolverAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5010FE554D00271C65 /* BreakpointResolverAddress.h */; }; 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; 2689000213353DB600698AC0 /* BreakpointResolverFileLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5110FE554D00271C65 /* BreakpointResolverFileLine.h */; }; @@ -379,6 +381,7 @@ 26B1FCBD13381071002886E2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; 26B1FCC21338115F002886E2 /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; }; 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */; }; 26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; @@ -695,6 +698,8 @@ 2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformRemoteiOS.h; sourceTree = ""; }; 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = ""; }; 2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = source/Utility/StringExtractorGDBRemote.h; sourceTree = ""; }; + 267C0128136880C7006E963E /* OptionGroupValueObjectDisplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupValueObjectDisplay.h; path = include/lldb/Interpreter/OptionGroupValueObjectDisplay.h; sourceTree = ""; }; + 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupValueObjectDisplay.cpp; path = source/Interpreter/OptionGroupValueObjectDisplay.cpp; sourceTree = ""; }; 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PseudoTerminal.cpp; path = source/Utility/PseudoTerminal.cpp; sourceTree = ""; }; 2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Utility/PseudoTerminal.h; sourceTree = ""; }; 2682F284115EF3A700CCFF99 /* SBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBError.cpp; path = source/API/SBError.cpp; sourceTree = ""; }; @@ -988,6 +993,10 @@ 26BC7F3E10F1B90C00F91463 /* ThreadList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadList.cpp; path = source/Target/ThreadList.cpp; sourceTree = ""; }; 26BC7F3F10F1B90C00F91463 /* ThreadPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlan.cpp; path = source/Target/ThreadPlan.cpp; sourceTree = ""; }; 26BC7F4C10F1BC1A00F91463 /* ObjectFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFile.cpp; path = source/Symbol/ObjectFile.cpp; sourceTree = ""; }; + 26BCFC4F1368ADF7006DC050 /* OptionGroupFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupFormat.h; path = include/lldb/Interpreter/OptionGroupFormat.h; sourceTree = ""; }; + 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupFormat.cpp; path = source/Interpreter/OptionGroupFormat.cpp; sourceTree = ""; }; + 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupOutputFile.cpp; path = source/Interpreter/OptionGroupOutputFile.cpp; sourceTree = ""; }; + 26BCFC541368B4B8006DC050 /* OptionGroupOutputFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupOutputFile.h; path = include/lldb/Interpreter/OptionGroupOutputFile.h; sourceTree = ""; }; 26BD407D135D2AC400237D80 /* FileLineResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FileLineResolver.h; path = include/lldb/Core/FileLineResolver.h; sourceTree = ""; }; 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileLineResolver.cpp; path = source/Core/FileLineResolver.cpp; sourceTree = ""; }; 26C5577B132575AD008FD8FE /* PlatformMacOSX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformMacOSX.cpp; sourceTree = ""; }; @@ -2248,8 +2257,14 @@ 26BC7E8610F1B85900F91463 /* Options.cpp */, 26D5E160135BAEB0006EA0A7 /* OptionGroupArchitecture.h */, 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */, + 26BCFC4F1368ADF7006DC050 /* OptionGroupFormat.h */, + 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */, + 26BCFC541368B4B8006DC050 /* OptionGroupOutputFile.h */, + 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */, 26D5E161135BB040006EA0A7 /* OptionGroupPlatform.h */, 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */, + 267C0128136880C7006E963E /* OptionGroupValueObjectDisplay.h */, + 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */, 26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */, 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */, 9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */, @@ -3235,6 +3250,9 @@ 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */, 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */, 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */, + 267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */, + 26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */, + 267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Apr 27 17:04:39 2011 @@ -17,181 +17,367 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/ValueObjectMemory.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/OptionGroupFormat.h" +#include "lldb/Interpreter/OptionGroupOutputFile.h" #include "lldb/Target/Process.h" +#include "lldb/Target/StackFrame.h" using namespace lldb; using namespace lldb_private; -//---------------------------------------------------------------------- -// Read memory from the inferior process -//---------------------------------------------------------------------- -class CommandObjectMemoryRead : public CommandObject +OptionDefinition +g_option_table[] = { -public: - - class CommandOptions : public Options - { - public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) - { - OptionParsingStarting(); - } - - virtual - ~CommandOptions () - { - } + { LLDB_OPT_SET_1| + LLDB_OPT_SET_2, false, "size" ,'s', required_argument, NULL, 0, eArgTypeByteSize ,"The size in bytes to use when displaying with the selected format."}, + { LLDB_OPT_SET_1| + LLDB_OPT_SET_3, false, "count" ,'c', required_argument, NULL, 0, eArgTypeCount ,"The number of total items to display."}, + { LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, + { LLDB_OPT_SET_2, false, "binary" ,'b', no_argument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, + { LLDB_OPT_SET_3, true , "view-as" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, +}; - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) - { - Error error; - char short_option = (char) m_getopt_table[option_idx].val; - switch (short_option) - { - case 'f': - error = Args::StringToFormat (option_arg, m_format); - switch (m_format) - { - default: - break; +class OptionGroupReadMemory : public OptionGroup +{ +public: - case eFormatBoolean: - if (m_byte_size == 0) - m_byte_size = 1; - if (m_num_per_line == 0) - m_num_per_line = 1; - break; - - case eFormatCString: - if (m_num_per_line == 0) - m_num_per_line = 1; - break; - - case eFormatPointer: - break; - - case eFormatBinary: - case eFormatFloat: - case eFormatOctal: - case eFormatDecimal: - case eFormatEnum: - case eFormatUnicode16: - case eFormatUnicode32: - case eFormatUnsigned: - if (m_byte_size == 0) - m_byte_size = 4; - if (m_num_per_line == 0) - m_num_per_line = 1; - break; - - case eFormatBytes: - case eFormatBytesWithASCII: - case eFormatChar: - case eFormatCharPrintable: - if (m_byte_size == 0) - m_byte_size = 1; - break; - case eFormatComplex: - if (m_byte_size == 0) - m_byte_size = 8; - break; - case eFormatHex: - if (m_byte_size == 0) - m_byte_size = 4; - break; - - case eFormatVectorOfChar: - case eFormatVectorOfSInt8: - case eFormatVectorOfUInt8: - case eFormatVectorOfSInt16: - case eFormatVectorOfUInt16: - case eFormatVectorOfSInt32: - case eFormatVectorOfUInt32: - case eFormatVectorOfSInt64: - case eFormatVectorOfUInt64: - case eFormatVectorOfFloat32: - case eFormatVectorOfFloat64: - case eFormatVectorOfUInt128: - break; - } - break; + OptionGroupReadMemory () : + m_byte_size (0,0), + m_count (0,0), + m_num_per_line (0,0), + m_output_as_binary (false), + m_view_as_type() + { + } + virtual + ~OptionGroupReadMemory () + { + } + + + virtual uint32_t + GetNumDefinitions () + { + return sizeof (g_option_table) / sizeof (OptionDefinition); + } + + virtual const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) + { + Error error; + char short_option = (char) g_option_table[option_idx].short_option; + + switch (short_option) + { case 'l': - m_num_per_line = Args::StringToUInt32 (option_arg, 0); - if (m_num_per_line == 0) + error = m_num_per_line.SetValueFromCString (option_arg); + if (m_num_per_line.GetCurrentValue() == 0) error.SetErrorStringWithFormat("Invalid value for --num-per-line option '%s'. Must be positive integer value.\n", option_arg); break; - + case 'c': - m_count = Args::StringToUInt32 (option_arg, 0); - if (m_count == 0) + error = m_count.SetValueFromCString (option_arg); + if (m_count.GetCurrentValue() == 0) error.SetErrorStringWithFormat("Invalid value for --count option '%s'. Must be positive integer value.\n", option_arg); break; - + case 's': - m_byte_size = Args::StringToUInt32 (option_arg, 0); - if (m_byte_size == 0) + error = m_byte_size.SetValueFromCString (option_arg); + if (m_byte_size.GetCurrentValue() == 0) error.SetErrorStringWithFormat("Invalid value for --size option '%s'. Must be positive integer value.\n", option_arg); break; - - case 'o': - m_outfile_filespec.SetFile (option_arg, true); - break; - + case 'b': m_output_as_binary = true; break; - - case 'a': - m_append_to_outfile = true; + + case 't': + error = m_view_as_type.SetValueFromCString (option_arg); break; - + default: error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); break; - } - return error; } + return error; + } + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter) + { + m_byte_size.Clear(); + m_count.Clear(); + m_num_per_line.Clear(); + m_output_as_binary = false; + m_view_as_type.Clear(); + } + + void + FinalizeSettings (lldb::Format format) + { + if (m_num_per_line.GetCurrentValue() == 0) + m_num_per_line.SetCurrentValue(1); - void - OptionParsingStarting () + switch (format) { - m_format = eFormatBytesWithASCII; - m_byte_size = 0; - m_count = 0; - m_num_per_line = 0; - m_outfile_filespec.Clear(); - m_append_to_outfile = false; - m_output_as_binary = false; + default: + break; + + case eFormatBoolean: + if (m_byte_size.GetCurrentValue() == 0) + m_byte_size = 1; + break; + + case eFormatCString: + break; + + case eFormatPointer: + break; + + case eFormatBinary: + case eFormatFloat: + case eFormatOctal: + case eFormatDecimal: + case eFormatEnum: + case eFormatUnicode16: + case eFormatUnicode32: + case eFormatUnsigned: + if (m_byte_size.GetCurrentValue() == 0) + m_byte_size = 4; + break; + + case eFormatBytes: + case eFormatBytesWithASCII: + if (m_byte_size.GetCurrentValue() == 0) + m_byte_size = 1; + break; + case eFormatChar: + case eFormatCharPrintable: + if (m_byte_size.GetCurrentValue() == 0) + m_byte_size = 1; + break; + case eFormatComplex: + if (m_byte_size.GetCurrentValue() == 0) + m_byte_size = 8; + break; + case eFormatHex: + if (m_byte_size.GetCurrentValue() == 0) + m_byte_size = 4; + break; + + case eFormatVectorOfChar: + case eFormatVectorOfSInt8: + case eFormatVectorOfUInt8: + case eFormatVectorOfSInt16: + case eFormatVectorOfUInt16: + case eFormatVectorOfSInt32: + case eFormatVectorOfUInt32: + case eFormatVectorOfSInt64: + case eFormatVectorOfUInt64: + case eFormatVectorOfFloat32: + case eFormatVectorOfFloat64: + case eFormatVectorOfUInt128: + break; } + } - const OptionDefinition* - GetDefinitions () - { - return g_option_table; - } + OptionValueUInt64 m_byte_size; + OptionValueUInt64 m_count; + OptionValueUInt64 m_num_per_line; + bool m_output_as_binary; + OptionValueString m_view_as_type; +}; - // Options table: Required for subclasses of Options. - static OptionDefinition g_option_table[]; - // Instance variables to hold the values for command options. - lldb::Format m_format; - uint32_t m_byte_size; - uint32_t m_count; - uint32_t m_num_per_line; - FileSpec m_outfile_filespec; - bool m_append_to_outfile; - bool m_output_as_binary; - }; +//---------------------------------------------------------------------- +// Read memory from the inferior process +//---------------------------------------------------------------------- +class CommandObjectMemoryRead : public CommandObject +{ +public: + +// class CommandOptions : public Options +// { +// public: +// CommandOptions (CommandInterpreter &interpreter) : +// Options(interpreter) +// { +// OptionParsingStarting(); +// } +// +// virtual +// ~CommandOptions () +// { +// } +// +// virtual Error +// SetOptionValue (uint32_t option_idx, const char *option_arg) +// { +// Error error; +// char short_option = (char) m_getopt_table[option_idx].val; +// +// switch (short_option) +// { +// case 'f': +// error = Args::StringToFormat (option_arg, m_format); +// +// switch (m_format) +// { +// default: +// break; +// +// case eFormatBoolean: +// if (m_byte_size == 0) +// m_byte_size = 1; +// if (m_num_per_line == 0) +// m_num_per_line = 1; +// break; +// +// case eFormatCString: +// if (m_num_per_line == 0) +// m_num_per_line = 1; +// break; +// +// case eFormatPointer: +// break; +// +// case eFormatBinary: +// case eFormatFloat: +// case eFormatOctal: +// case eFormatDecimal: +// case eFormatEnum: +// case eFormatUnicode16: +// case eFormatUnicode32: +// case eFormatUnsigned: +// if (m_byte_size == 0) +// m_byte_size = 4; +// if (m_num_per_line == 0) +// m_num_per_line = 1; +// break; +// +// case eFormatBytes: +// case eFormatBytesWithASCII: +// case eFormatChar: +// case eFormatCharPrintable: +// if (m_byte_size == 0) +// m_byte_size = 1; +// break; +// case eFormatComplex: +// if (m_byte_size == 0) +// m_byte_size = 8; +// break; +// case eFormatHex: +// if (m_byte_size == 0) +// m_byte_size = 4; +// break; +// +// case eFormatVectorOfChar: +// case eFormatVectorOfSInt8: +// case eFormatVectorOfUInt8: +// case eFormatVectorOfSInt16: +// case eFormatVectorOfUInt16: +// case eFormatVectorOfSInt32: +// case eFormatVectorOfUInt32: +// case eFormatVectorOfSInt64: +// case eFormatVectorOfUInt64: +// case eFormatVectorOfFloat32: +// case eFormatVectorOfFloat64: +// case eFormatVectorOfUInt128: +// break; +// } +// break; +// +// case 'l': +// m_num_per_line = Args::StringToUInt32 (option_arg, 0); +// if (m_num_per_line == 0) +// error.SetErrorStringWithFormat("Invalid value for --num-per-line option '%s'. Must be positive integer value.\n", option_arg); +// break; +// +// case 'c': +// m_count = Args::StringToUInt32 (option_arg, 0); +// if (m_count == 0) +// error.SetErrorStringWithFormat("Invalid value for --count option '%s'. Must be positive integer value.\n", option_arg); +// break; +// +// case 's': +// m_byte_size = Args::StringToUInt32 (option_arg, 0); +// if (m_byte_size == 0) +// error.SetErrorStringWithFormat("Invalid value for --size option '%s'. Must be positive integer value.\n", option_arg); +// break; +// +// case 'o': +// m_outfile_filespec.SetFile (option_arg, true); +// break; +// +// case 'b': +// m_output_as_binary = true; +// break; +// +// case 'a': +// m_append_to_outfile = true; +// break; +// +// case 't': +// m_view_as_type.assign (option_arg); +// break; +// +// default: +// error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); +// break; +// } +// return error; +// } +// +// void +// OptionParsingStarting () +// { +// m_format = eFormatBytesWithASCII; +// m_byte_size = 0; +// m_count = 0; +// m_num_per_line = 0; +// m_outfile_filespec.Clear(); +// m_view_as_type.clear(); +// m_append_to_outfile = false; +// m_output_as_binary = false; +// } +// +// const OptionDefinition* +// GetDefinitions () +// { +// return g_option_table; +// } +// +// // Options table: Required for subclasses of Options. +// +// static OptionDefinition g_option_table[]; +// +// // Instance variables to hold the values for command options. +// lldb::Format m_format; +// uint32_t m_byte_size; +// uint32_t m_count; +// uint32_t m_num_per_line; +// FileSpec m_outfile_filespec; +// std::string m_view_as_type; +// bool m_append_to_outfile; +// bool m_output_as_binary; +// }; CommandObjectMemoryRead (CommandInterpreter &interpreter) : CommandObject (interpreter, @@ -199,7 +385,10 @@ "Read from the memory of the process being debugged.", NULL, eFlagProcessMustBeLaunched), - m_options (interpreter) + m_option_group (interpreter), + m_format_options (eFormatBytesWithASCII), + m_memory_options (), + m_outfile_options () { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -223,6 +412,12 @@ // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg1); m_arguments.push_back (arg2); + + m_option_group.Append (&m_format_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_3); + m_option_group.Append (&m_memory_options); + m_option_group.Append (&m_outfile_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3); + m_option_group.Finalize(); + } virtual @@ -233,15 +428,15 @@ Options * GetOptions () { - return &m_options; + return &m_option_group; } virtual bool Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; - if (process == NULL) + ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); + if (exe_ctx.process == NULL) { result.AppendError("need a process to read memory"); result.SetStatus(eReturnStatusFailed); @@ -249,6 +444,7 @@ } const size_t argc = command.GetArgumentCount(); + if (argc == 0 || argc > 2) { result.AppendErrorWithFormat ("%s takes 1 or two args.\n", m_cmd_name.c_str()); @@ -256,26 +452,162 @@ return false; } - size_t item_byte_size = m_options.m_byte_size; - if (item_byte_size == 0) + size_t item_byte_size = m_memory_options.m_byte_size.GetCurrentValue(); + ClangASTType clang_ast_type; + + const char *view_as_type_cstr = m_memory_options.m_view_as_type.GetCurrentValue(); + if (view_as_type_cstr && view_as_type_cstr[0]) { - if (m_options.m_format == eFormatPointer) - item_byte_size = process->GetTarget().GetArchitecture().GetAddressByteSize(); - else - item_byte_size = 1; + // We are viewing memory as a type + SymbolContext sc; + const bool append = true; + TypeList type_list; + uint32_t reference_count = 0; + uint32_t pointer_count = 0; + size_t idx; + static const char *g_keywords[] = { "const", "volatile", "restrict", "struct", "class", "union"}; + static size_t g_num_keywords = sizeof(g_keywords)/sizeof(const char *); + std::string type_str(view_as_type_cstr); + + // Remove all instances of g_keywords that are followed by spaces + for (size_t i = 0; i < g_num_keywords; ++i) + { + const char *keyword = g_keywords[i]; + int keyword_len = ::strlen (keyword); + while ((idx = type_str.find (keyword)) != std::string::npos) + { + if (type_str[idx + keyword_len] == ' ' || type_str[idx + keyword_len] == '\t') + type_str.erase(idx, keyword_len+1); + } + } + bool done = type_str.empty(); + // + idx = type_str.find_first_not_of (" \t"); + if (idx > 0 && idx != std::string::npos) + type_str.erase (0, idx); + while (!done) + { + // Strip trailing spaces + if (type_str.empty()) + done = true; + else + { + switch (type_str[type_str.size()-1]) + { + case '*': + ++pointer_count; + // fall through... + case ' ': + case '\t': + type_str.erase(type_str.size()-1); + break; + + case '&': + if (reference_count == 0) + { + reference_count = 1; + type_str.erase(type_str.size()-1); + } + else + { + result.AppendErrorWithFormat ("invalid type string: '%s'\n", view_as_type_cstr); + result.SetStatus(eReturnStatusFailed); + return false; + } + break; + + default: + done = true; + break; + } + } + } + + ConstString lookup_type_name(type_str.c_str()); + if (exe_ctx.frame) + { + sc = exe_ctx.frame->GetSymbolContext (eSymbolContextModule); + if (sc.module_sp) + { + sc.module_sp->FindTypes (sc, + lookup_type_name, + append, + 1, + type_list); + } + } + if (type_list.GetSize() == 0) + { + exe_ctx.target->GetImages().FindTypes (sc, + lookup_type_name, + append, + 1, + type_list); + } + + if (type_list.GetSize() == 0) + { + result.AppendErrorWithFormat ("unable to find any types that match the raw type '%s' for full type '%s'\n", + lookup_type_name.GetCString(), + view_as_type_cstr); + result.SetStatus(eReturnStatusFailed); + return false; + } + + TypeSP type_sp (type_list.GetTypeAtIndex(0)); + clang_ast_type.SetClangType (type_sp->GetClangAST(), type_sp->GetClangFullType()); + + while (pointer_count > 0) + { + clang_type_t pointer_type = ClangASTContext::CreatePointerType (clang_ast_type.GetASTContext(), clang_ast_type.GetOpaqueQualType()); + if (pointer_type) + clang_ast_type.SetClangType (clang_ast_type.GetASTContext(), pointer_type); + else + { + result.AppendError ("unable make a pointer type\n"); + result.SetStatus(eReturnStatusFailed); + return false; + } + --pointer_count; + } + + item_byte_size = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8; + + if (item_byte_size == 0) + { + result.AppendErrorWithFormat ("unable to get the byte size of the type '%s'\n", + view_as_type_cstr); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + else + { + if (item_byte_size == 0) + { + if (m_format_options.GetFormat() == eFormatPointer) + item_byte_size = exe_ctx.target->GetArchitecture().GetAddressByteSize(); + else + item_byte_size = 1; + } } - size_t item_count = m_options.m_count; + size_t item_count = m_memory_options.m_count.GetCurrentValue(); - size_t num_per_line = m_options.m_num_per_line; + size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue(); if (num_per_line == 0) { - num_per_line = (16/item_byte_size); - if (num_per_line == 0) + if (clang_ast_type.GetOpaqueQualType()) num_per_line = 1; + else + { + num_per_line = (16/item_byte_size); + if (num_per_line == 0) + num_per_line = 1; + } } - size_t total_byte_size = m_options.m_count * item_byte_size; + size_t total_byte_size = item_count * item_byte_size; if (total_byte_size == 0) total_byte_size = 32; @@ -316,49 +648,56 @@ else { if (item_count == 0) - item_count = 32; + { + if (clang_ast_type.GetOpaqueQualType()) + item_count = 1; + else + item_count = 32; + } } - - DataBufferSP data_sp(new DataBufferHeap (total_byte_size, '\0')); + + DataBufferSP data_sp; Error error; - size_t bytes_read = process->ReadMemory(addr, data_sp->GetBytes (), data_sp->GetByteSize(), error); - if (bytes_read == 0) + size_t bytes_read = 0; + if (!clang_ast_type.GetOpaqueQualType()) { - result.AppendWarningWithFormat("Read from 0x%llx failed.\n", addr); - result.AppendError(error.AsCString()); - result.SetStatus(eReturnStatusFailed); - return false; + data_sp.reset (new DataBufferHeap (total_byte_size, '\0')); + bytes_read = exe_ctx.process->ReadMemory(addr, data_sp->GetBytes (), data_sp->GetByteSize(), error); + if (bytes_read == 0) + { + result.AppendWarningWithFormat("Read from 0x%llx failed.\n", addr); + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (bytes_read < total_byte_size) + result.AppendWarningWithFormat("Not all bytes (%u/%u) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr); } - if (bytes_read < total_byte_size) - result.AppendWarningWithFormat("Not all bytes (%u/%u) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr); - - result.SetStatus(eReturnStatusSuccessFinishResult); - DataExtractor data (data_sp, - process->GetTarget().GetArchitecture().GetByteOrder(), - process->GetTarget().GetArchitecture().GetAddressByteSize()); - StreamFile outfile_stream; Stream *output_stream = NULL; - - if (m_options.m_outfile_filespec) + const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue(); + if (outfile_spec) { char path[PATH_MAX]; - m_options.m_outfile_filespec.GetPath (path, sizeof(path)); - char mode[16] = { 'w', '\0' }; - if (m_options.m_append_to_outfile) - mode[0] = 'a'; - - if (outfile_stream.GetFile ().Open (path, File::eOpenOptionWrite | File::eOpenOptionCanCreate).Success()) + outfile_spec.GetPath (path, sizeof(path)); + + uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate; + const bool append = m_outfile_options.GetAppend().GetCurrentValue(); + if (append) + open_options |= File::eOpenOptionAppend; + + if (outfile_stream.GetFile ().Open (path, open_options).Success()) { - if (m_options.m_output_as_binary) + if (m_memory_options.m_output_as_binary) { int bytes_written = outfile_stream.Write (data_sp->GetBytes(), bytes_read); if (bytes_written > 0) { result.GetOutputStream().Printf ("%i bytes %s to '%s'\n", bytes_written, - m_options.m_append_to_outfile ? "appended" : "written", + append ? "appended" : "written", path); return true; } @@ -378,7 +717,7 @@ } else { - result.AppendErrorWithFormat("Failed to open file '%s' with a mode of '%s'.\n", path, mode); + result.AppendErrorWithFormat("Failed to open file '%s' for %s.\n", path, append ? "append" : "write"); result.SetStatus(eReturnStatusFailed); return false; } @@ -388,10 +727,66 @@ output_stream = &result.GetOutputStream(); } + + if (clang_ast_type.GetOpaqueQualType()) + { + for (uint32_t i = 0; iGetArchitecture().GetByteOrder(), + exe_ctx.target->GetArchitecture().GetAddressByteSize()); + + assert (output_stream); data.Dump (output_stream, 0, - m_options.m_format, + m_format_options.GetFormat(), item_byte_size, item_count, num_per_line, @@ -403,27 +798,33 @@ } protected: - CommandOptions m_options; -}; +// CommandOptions m_options; + OptionGroupOptions m_option_group; + OptionGroupFormat m_format_options; + OptionGroupReadMemory m_memory_options; + OptionGroupOutputFile m_outfile_options; -#define SET1 LLDB_OPT_SET_1 -#define SET2 LLDB_OPT_SET_2 - -OptionDefinition -CommandObjectMemoryRead::CommandOptions::g_option_table[] = -{ -{ SET1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, -{ SET1 , false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes to use when displaying with the selected format."}, -{ SET1 , false, "num-per-line", 'l', required_argument, NULL, 0, eArgTypeNumberPerLine,"The number of items per line to display."}, -{ SET1 | SET2, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, -{ SET1 | SET2, false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename, "Dump memory read results into a file."}, -{ SET1 | SET2, false, "append", 'a', no_argument, NULL, 0, eArgTypeNone, "Append memory read results to 'outfile'."}, -{ SET2, false, "binary", 'b', no_argument, NULL, 0, eArgTypeNone, "If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, -{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; -#undef SET1 -#undef SET2 +//OptionDefinition +//CommandObjectMemoryRead::CommandOptions::g_option_table[] = +//{ +//{ LLDB_OPT_SET_1, false, "format" ,'f', required_argument, NULL, 0, eArgTypeFormat ,"The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, +//{ LLDB_OPT_SET_1, false, "size" ,'s', required_argument, NULL, 0, eArgTypeByteSize ,"The size in bytes to use when displaying with the selected format."}, +//{ LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, +//{ LLDB_OPT_SET_1| +// LLDB_OPT_SET_2| +// LLDB_OPT_SET_3, false, "count" ,'c', required_argument, NULL, 0, eArgTypeCount ,"The number of total items to display."}, +//{ LLDB_OPT_SET_1| +// LLDB_OPT_SET_2| +// LLDB_OPT_SET_3, false, "outfile" ,'o', required_argument, NULL, 0, eArgTypeFilename ,"Dump memory read results into a file."}, +//{ LLDB_OPT_SET_1| +// LLDB_OPT_SET_2| +// LLDB_OPT_SET_3, false, "append" ,'a', no_argument , NULL, 0, eArgTypeNone ,"Append memory read results to 'outfile'."}, +//{ LLDB_OPT_SET_2, false, "binary" ,'b', no_argument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, +//{ LLDB_OPT_SET_3, true , "view-as" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, +//{ 0 , false, NULL , 0 , 0 , NULL, 0, eArgTypeNone , NULL } +//}; //---------------------------------------------------------------------- // Write memory to the inferior process Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Wed Apr 27 17:04:39 2011 @@ -569,7 +569,7 @@ break; } - option_value_sp->GetAsArrayValue()->InsertValue (idx, data_value_sp); + option_value_sp->GetAsArray()->InsertValue (idx, data_value_sp); ++idx; } } @@ -687,7 +687,7 @@ data_type = OptionValue::eTypeUInt64; } else - option_value_sp->GetAsDictionaryValue()->SetValueForKey (const_key, value_sp, false); + option_value_sp->GetAsDictionary()->SetValueForKey (const_key, value_sp, false); } } @@ -740,7 +740,7 @@ fclose (test_file); - OptionValueDictionary *data_dictionary = data_dictionary_sp->GetAsDictionaryValue(); + OptionValueDictionary *data_dictionary = data_dictionary_sp->GetAsDictionary(); static ConstString description_key ("assembly_string"); static ConstString triple_key ("triple"); Modified: lldb/trunk/source/Core/State.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/State.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Core/State.cpp (original) +++ lldb/trunk/source/Core/State.cpp Wed Apr 27 17:04:39 2011 @@ -40,6 +40,50 @@ return unknown_state_string; } +const char * +lldb_private::GetFormatAsCString (lldb::Format format) +{ + switch (format) + { + case eFormatDefault: return "default"; + case eFormatBoolean: return "boolean"; + case eFormatBinary: return "binary"; + case eFormatBytes: return "bytes"; + case eFormatBytesWithASCII: return "bytes with ASCII"; + case eFormatChar: return "character"; + case eFormatCharPrintable: return "printable character"; + case eFormatComplexFloat: return "complet float"; + case eFormatCString: return "c-string"; + case eFormatDecimal: return "signed decimal"; + case eFormatEnum: return "enumeration"; + case eFormatHex: return "hex"; + case eFormatFloat: return "float"; + case eFormatOctal: return "octal"; + case eFormatOSType: return "OSType"; + case eFormatUnicode16: return "Unicode16"; + case eFormatUnicode32: return "Unicode32"; + case eFormatUnsigned: return "unsigned decimal"; + case eFormatPointer: return "pointer"; + case eFormatVectorOfChar: return "vector of characters"; + case eFormatVectorOfSInt8: return "vector of int8_t"; + case eFormatVectorOfUInt8: return "vector of uint8_t"; + case eFormatVectorOfSInt16: return "vector of int16_t"; + case eFormatVectorOfUInt16: return "vector of uint16_t"; + case eFormatVectorOfSInt32: return "vector of int32_t"; + case eFormatVectorOfUInt32: return "vector of uint32_t"; + case eFormatVectorOfSInt64: return "vector of int64_t"; + case eFormatVectorOfUInt64: return "vector of uint64_t"; + case eFormatVectorOfFloat32:return "vector of float32"; + case eFormatVectorOfFloat64:return "vector of float64"; + case eFormatVectorOfUInt128:return "vector of uint128_t"; + case eFormatComplexInteger: return "complex integer"; + default: break; + } + static char unknown_format_string[64]; + snprintf(unknown_format_string, sizeof (unknown_format_string), "Format = %u", format); + return unknown_format_string; +} + bool lldb_private::StateIsRunningState (StateType state) { Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectMemory.cpp (original) +++ lldb/trunk/source/Core/ValueObjectMemory.cpp Wed Apr 27 17:04:39 2011 @@ -42,13 +42,23 @@ return (new ValueObjectMemory (exe_scope, name, address, type_sp))->GetSP(); } +ValueObjectSP +ValueObjectMemory::Create (ExecutionContextScope *exe_scope, + const char *name, + const Address &address, + const ClangASTType &ast_type) +{ + return (new ValueObjectMemory (exe_scope, name, address, ast_type))->GetSP(); +} + ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope, const char *name, const Address &address, lldb::TypeSP &type_sp) : ValueObject(exe_scope), m_address (address), - m_type_sp(type_sp) + m_type_sp(type_sp), + m_clang_type() { // Do not attempt to construct one of these objects with no variable! assert (m_type_sp.get() != NULL); @@ -76,6 +86,43 @@ } } +ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope, + const char *name, + const Address &address, + const ClangASTType &ast_type) : + ValueObject(exe_scope), + m_address (address), + m_type_sp(), + m_clang_type(ast_type) +{ + // Do not attempt to construct one of these objects with no variable! + assert (m_clang_type.GetASTContext()); + assert (m_clang_type.GetOpaqueQualType()); + + SetName (name); + m_value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType()); + lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget()); + if (load_address != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeLoadAddress); + m_value.GetScalar() = load_address; + } + else + { + lldb::addr_t file_address = m_address.GetFileAddress(); + if (file_address != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeFileAddress); + m_value.GetScalar() = file_address; + } + else + { + m_value.GetScalar() = m_address.GetOffset(); + m_value.SetValueType (Value::eValueTypeScalar); + } + } +} + ValueObjectMemory::~ValueObjectMemory() { } @@ -83,31 +130,48 @@ lldb::clang_type_t ValueObjectMemory::GetClangType () { - return m_type_sp->GetClangForwardType(); + if (m_type_sp) + return m_type_sp->GetClangForwardType(); + return m_clang_type.GetOpaqueQualType(); } ConstString ValueObjectMemory::GetTypeName() { - return m_type_sp->GetName(); + if (m_type_sp) + return m_type_sp->GetName(); + ConstString name; + std::string type_name (ClangASTContext::GetTypeName (m_clang_type.GetOpaqueQualType())); + if (!type_name.empty()) + name.SetCString (type_name.c_str()); + return name; } uint32_t ValueObjectMemory::CalculateNumChildren() { - return m_type_sp->GetNumChildren(true); + if (m_type_sp) + return m_type_sp->GetNumChildren(true); + const bool omit_empty_base_classes = true; + return ClangASTContext::GetNumChildren (m_clang_type.GetASTContext(), + m_clang_type.GetOpaqueQualType(), + omit_empty_base_classes); } clang::ASTContext * ValueObjectMemory::GetClangAST () { - return m_type_sp->GetClangAST(); + if (m_type_sp) + return m_type_sp->GetClangAST(); + return m_clang_type.GetASTContext(); } size_t ValueObjectMemory::GetByteSize() { - return m_type_sp->GetByteSize(); + if (m_type_sp) + return m_type_sp->GetByteSize(); + return (m_clang_type.GetClangTypeBitWidth () + 7) / 8; } lldb::ValueType @@ -182,7 +246,11 @@ // Copy the Value and set the context to use our Variable // so it can extract read its value into m_data appropriately Value value(m_value); - value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get()); + if (m_type_sp) + value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get()); + else + value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType()); + m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0); } break; Modified: lldb/trunk/source/Interpreter/NamedOptionValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/NamedOptionValue.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/NamedOptionValue.cpp (original) +++ lldb/trunk/source/Interpreter/NamedOptionValue.cpp Wed Apr 27 17:04:39 2011 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/State.h" #include "lldb/Core/Stream.h" #include "lldb/Interpreter/Args.h" @@ -47,7 +48,7 @@ OptionValueBoolean * -OptionValue::GetAsBooleanValue () +OptionValue::GetAsBoolean () { if (GetType () == OptionValue::eTypeBoolean) return static_cast(this); @@ -55,7 +56,7 @@ } OptionValueSInt64 * -OptionValue::GetAsSInt64Value () +OptionValue::GetAsSInt64 () { if (GetType () == OptionValue::eTypeSInt64) return static_cast(this); @@ -63,7 +64,7 @@ } OptionValueUInt64 * -OptionValue::GetAsUInt64Value () +OptionValue::GetAsUInt64 () { if (GetType () == OptionValue::eTypeUInt64) return static_cast(this); @@ -71,7 +72,7 @@ } OptionValueString * -OptionValue::GetAsStringValue () +OptionValue::GetAsString () { if (GetType () == OptionValue::eTypeString) return static_cast(this); @@ -79,15 +80,24 @@ } OptionValueFileSpec * -OptionValue::GetAsFileSpecValue () +OptionValue::GetAsFileSpec () { if (GetType () == OptionValue::eTypeFileSpec) return static_cast(this); return NULL; + +} + +OptionValueFormat * +OptionValue::GetAsFormat () +{ + if (GetType () == OptionValue::eTypeFormat) + return static_cast(this); + return NULL; } OptionValueArray * -OptionValue::GetAsArrayValue () +OptionValue::GetAsArray () { if (GetType () == OptionValue::eTypeArray) return static_cast(this); @@ -95,7 +105,7 @@ } OptionValueDictionary * -OptionValue::GetAsDictionaryValue () +OptionValue::GetAsDictionary () { if (GetType () == OptionValue::eTypeDictionary) return static_cast(this); @@ -103,19 +113,30 @@ } const char * -OptionValue::GetStringValue () +OptionValue::GetStringValue (const char *fail_value) { - if (GetType () == OptionValue::eTypeString) - return static_cast(this)->GetCurrentValue(); - return NULL; + OptionValueString *option_value = GetAsString (); + if (option_value) + return option_value->GetCurrentValue(); + return fail_value; } uint64_t -OptionValue::GetUInt64Value () +OptionValue::GetUInt64Value (uint64_t fail_value) { - if (GetType () == OptionValue::eTypeUInt64) - return static_cast(this)->GetCurrentValue(); - return 0; + OptionValueUInt64 *option_value = GetAsUInt64 (); + if (option_value) + return option_value->GetCurrentValue(); + return fail_value; +} + +lldb::Format +OptionValue::GetFormatValue (lldb::Format fail_value) +{ + OptionValueFormat *option_value = GetAsFormat (); + if (option_value) + return option_value->GetCurrentValue(); + return fail_value; } //------------------------------------------------------------------------- @@ -250,8 +271,6 @@ return Error (); } - - //------------------------------------------------------------------------- // OptionValueFileSpec //------------------------------------------------------------------------- @@ -287,6 +306,29 @@ //------------------------------------------------------------------------- +// OptionValueFormat +//------------------------------------------------------------------------- +void +OptionValueFormat::DumpValue (Stream &strm) +{ + strm.PutCString (GetFormatAsCString (m_current_value)); +} + +Error +OptionValueFormat::SetValueFromCString (const char *value_cstr) +{ + Format new_format; + Error error (Args::StringToFormat(value_cstr, new_format)); + if (error.Success()) + { + m_value_was_set = true; + m_current_value = new_format; + } + return error; +} + + +//------------------------------------------------------------------------- // OptionValueArray //------------------------------------------------------------------------- void Modified: lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp Wed Apr 27 17:04:39 2011 @@ -26,11 +26,13 @@ { } -OptionDefinition g_file_option_table[] = +static OptionDefinition +g_option_table[] = { - { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, +{ LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, }; -const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition); + +const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); uint32_t OptionGroupArchitecture::GetNumDefinitions () @@ -41,7 +43,7 @@ const OptionDefinition * OptionGroupArchitecture::GetDefinitions () { - return g_file_option_table; + return g_option_table; } bool @@ -61,7 +63,7 @@ const char *option_arg) { Error error; - char short_option = (char) g_file_option_table[option_idx].short_option; + char short_option = (char) g_option_table[option_idx].short_option; switch (short_option) { Added: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=130334&view=auto ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (added) +++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Wed Apr 27 17:04:39 2011 @@ -0,0 +1,75 @@ +//===-- OptionGroupFormat.cpp -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "OptionGroupFormat.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +using namespace lldb; +using namespace lldb_private; + +OptionGroupFormat::OptionGroupFormat(lldb::Format default_format) : + m_format (default_format, default_format) +{ +} + +OptionGroupFormat::~OptionGroupFormat () +{ +} + +static OptionDefinition +g_option_table[] = +{ +{ LLDB_OPT_SET_1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat , "Specify a format to be used for display."}, +}; +const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); + +uint32_t +OptionGroupFormat::GetNumDefinitions () +{ + return k_num_file_options; +} + +const OptionDefinition * +OptionGroupFormat::GetDefinitions () +{ + return g_option_table; +} + +Error +OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + char short_option = (char) g_option_table[option_idx].short_option; + + switch (short_option) + { + case 'f': + error = m_format.SetValueFromCString (option_arg); + break; + + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter) +{ + m_format.Clear(); +} + Added: lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp?rev=130334&view=auto ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp (added) +++ lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp Wed Apr 27 17:04:39 2011 @@ -0,0 +1,82 @@ +//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "OptionGroupOutputFile.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +using namespace lldb; +using namespace lldb_private; + +OptionGroupOutputFile::OptionGroupOutputFile() : + m_file (), + m_append (false, false) +{ +} + +OptionGroupOutputFile::~OptionGroupOutputFile () +{ +} + +static OptionDefinition +g_option_table[] = +{ +{ LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypePath , "Specify a path for capturing command output."}, +{ LLDB_OPT_SET_1 , false, "append-outfile" , 'A', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile '."}, +}; + +const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); + +uint32_t +OptionGroupOutputFile::GetNumDefinitions () +{ + return k_num_file_options; +} + +const OptionDefinition * +OptionGroupOutputFile::GetDefinitions () +{ + return g_option_table; +} + +Error +OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + char short_option = (char) g_option_table[option_idx].short_option; + + switch (short_option) + { + case 'o': + error = m_file.SetValueFromCString (option_arg); + break; + + case 'A': + m_append.SetCurrentValue(true); + break; + + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +OptionGroupOutputFile::OptionParsingStarting (CommandInterpreter &interpreter) +{ + m_file.Clear(); + m_append.Clear(); +} Added: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=130334&view=auto ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (added) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Wed Apr 27 17:04:39 2011 @@ -0,0 +1,106 @@ +//===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "OptionGroupValueObjectDisplay.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +using namespace lldb; +using namespace lldb_private; + +OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() +{ +} + +OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay () +{ +} + +OptionDefinition +g_option_table[] = +{ + { LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, + { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat,"Specify the format that the variable output should use."}, + { LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, + { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, + { LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, + { LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, + { LLDB_OPT_SET_1, false, "show-types", 't', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, + { LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, + { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } +}; + +const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition); + +uint32_t +OptionGroupValueObjectDisplay::GetNumDefinitions () +{ + return k_num_file_options; +} + +const OptionDefinition * +OptionGroupValueObjectDisplay::GetDefinitions () +{ + return g_option_table; +} + + +Error +OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + char short_option = (char) g_option_table[option_idx].short_option; + bool success = false; + + switch (short_option) + { + case 't': show_types = true; break; + case 'y': show_summary = false; break; + case 'L': show_location= true; break; + case 'F': flat_output = true; break; + case 'f': error = Args::StringToFormat(option_arg, format); break; + case 'o': use_objc = true; break; + case 'd': + max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); + break; + + case 'p': + ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); + break; + + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) +{ + show_types = false; + show_summary = true; + show_location = false; + flat_output = false; + use_objc = false; + max_depth = UINT32_MAX; + ptr_depth = 0; + format = eFormatDefault; +} + Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Wed Apr 27 17:04:39 2011 @@ -907,6 +907,18 @@ void +OptionGroupOptions::Append (OptionGroup* group) +{ + const OptionDefinition* group_option_defs = group->GetDefinitions (); + const uint32_t group_option_count = group->GetNumDefinitions(); + for (uint32_t i=0; iGetAsDictionaryValue (); + OptionValueDictionary *state_dictionary = value_sp->GetAsDictionary (); if (!before_state.LoadStateFromDictionary (state_dictionary)) { out_stream->Printf ("TestEmulation: Failed loading 'before' state.\n"); @@ -13362,7 +13362,7 @@ return false; } - state_dictionary = value_sp->GetAsDictionaryValue (); + state_dictionary = value_sp->GetAsDictionary (); if (!after_state.LoadStateFromDictionary (state_dictionary)) { out_stream->Printf ("TestEmulation: Failed loading 'after' state.\n"); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp?rev=130334&r1=130333&r2=130334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Wed Apr 27 17:04:39 2011 @@ -341,7 +341,7 @@ static ConstString data_key ("data"); uint64_t start_address = 0; - OptionValueDictionary *mem_dict = value_sp->GetAsDictionaryValue(); + OptionValueDictionary *mem_dict = value_sp->GetAsDictionary(); value_sp = mem_dict->GetValueForKey (address_key); if (value_sp.get() == NULL) return false; @@ -349,7 +349,7 @@ start_address = value_sp->GetUInt64Value (); value_sp = mem_dict->GetValueForKey (data_key); - OptionValueArray *mem_array = value_sp->GetAsArrayValue(); + OptionValueArray *mem_array = value_sp->GetAsArray(); if (!mem_array) return false; @@ -374,7 +374,7 @@ // Load General Registers - OptionValueDictionary *reg_dict = value_sp->GetAsDictionaryValue (); + OptionValueDictionary *reg_dict = value_sp->GetAsDictionary (); StreamString sstr; for (int i = 0; i < 16; ++i) From gclayton at apple.com Thu Apr 28 15:55:26 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 28 Apr 2011 20:55:26 -0000 Subject: [Lldb-commits] [lldb] r130436 - in /lldb/trunk: include/lldb/Core/ include/lldb/Interpreter/ source/Commands/ source/Core/ source/Interpreter/ Message-ID: <20110428205526.CE9A42A6C135@llvm.org> Author: gclayton Date: Thu Apr 28 15:55:26 2011 New Revision: 130436 URL: http://llvm.org/viewvc/llvm-project?rev=130436&view=rev Log: Added the ability to specify dumping options (show types, show location, depth control, pointer depth, and more) when dumping memory and viewing as a type. Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Interpreter/Args.h lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Interpreter/NamedOptionValue.cpp lldb/trunk/source/Interpreter/OptionGroupFormat.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Apr 28 15:55:26 2011 @@ -426,6 +426,8 @@ lldb::Format GetFormat () const { + if (m_parent && m_format == lldb::eFormatDefault) + return m_parent->GetFormat(); return m_format; } @@ -467,8 +469,8 @@ //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these //------------------------------------------------------------------ - ValueObject *m_parent; // The parent value object, or NULL if this has no parent - EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last + ValueObject * m_parent; // The parent value object, or NULL if this has no parent + EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last // updated. When we are asked to update the value object, we check whether // the context & stop id are the same before updating. ConstString m_name; // The name of this object Modified: lldb/trunk/include/lldb/Interpreter/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Args.h (original) +++ lldb/trunk/include/lldb/Interpreter/Args.h Thu Apr 28 15:55:26 2011 @@ -360,7 +360,9 @@ StringToScriptLanguage (const char *s, lldb::ScriptLanguage fail_value, bool *success_ptr); static Error - StringToFormat (const char *s, lldb::Format &format); + StringToFormat (const char *s, + lldb::Format &format, + uint32_t *byte_size_ptr); // If non-NULL, then a byte size can precede the format character static const char * StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t &update); Modified: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (original) +++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Thu Apr 28 15:55:26 2011 @@ -123,6 +123,12 @@ lldb::Format GetFormatValue (lldb::Format fail_value = lldb::eFormatDefault); + bool + OptionWasSet () const + { + return m_value_was_set; + } + protected: bool m_value_was_set; // This can be used to see if a value has been set // by a call to SetValueFromCString(). It is often @@ -392,6 +398,11 @@ return m_current_value; } + operator uint64_t () const + { + return m_current_value; + } + uint64_t GetCurrentValue() const { @@ -628,22 +639,16 @@ class OptionValueFormat : public OptionValue { public: - OptionValueFormat () : - m_current_value (lldb::eFormatInvalid), - m_default_value (lldb::eFormatDefault) - { - } - - OptionValueFormat (lldb::Format current_value) : - m_current_value (current_value), - m_default_value (lldb::eFormatDefault) - { - } - - OptionValueFormat (lldb::Format current_value, - lldb::Format default_value) : + OptionValueFormat (lldb::Format current_value = lldb::eFormatDefault, + lldb::Format default_value = lldb::eFormatDefault, + uint32_t current_byte_size = 0, + uint32_t default_byte_size = 0, + bool byte_size_prefix_ok = false) : m_current_value (current_value), - m_default_value (default_value) + m_default_value (default_value), + m_current_byte_size (current_byte_size), + m_default_byte_size (default_byte_size), + m_byte_size_prefix_ok (byte_size_prefix_ok) { } @@ -681,7 +686,7 @@ //--------------------------------------------------------------------- lldb::Format - GetCurrentValue() + GetCurrentValue() const { return m_current_value; } @@ -704,9 +709,36 @@ m_default_value = value; } + uint32_t + GetCurrentByteSize () const + { + return m_current_byte_size; + } + + uint32_t + GetDefaultByteSize () const + { + return m_default_byte_size; + } + + void + SetCurrentByteSize (uint32_t byte_size) + { + m_current_byte_size = byte_size; + } + + void + SetDefaultByteSize (uint32_t byte_size) + { + m_default_byte_size = byte_size; + } + protected: lldb::Format m_current_value; lldb::Format m_default_value; + uint32_t m_current_byte_size; + uint32_t m_default_byte_size; + bool m_byte_size_prefix_ok; }; //--------------------------------------------------------------------- Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h Thu Apr 28 15:55:26 2011 @@ -27,7 +27,9 @@ { public: - OptionGroupFormat (lldb::Format default_format); + OptionGroupFormat (lldb::Format default_format, + uint32_t default_byte_size, + bool byte_size_prefix_ok); virtual ~OptionGroupFormat (); @@ -48,11 +50,16 @@ OptionParsingStarting (CommandInterpreter &interpreter); lldb::Format - GetFormat () + GetFormat () const { return m_format.GetCurrentValue(); } + uint32_t + GetByteSize() const + { + return m_format.GetCurrentByteSize(); + } protected: Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h Thu Apr 28 15:55:26 2011 @@ -53,7 +53,6 @@ bool use_objc; uint32_t max_depth; uint32_t ptr_depth; - lldb::Format format; }; } // namespace lldb_private Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Apr 28 15:55:26 2011 @@ -70,7 +70,7 @@ break; case 'f': - error = Args::StringToFormat(option_arg, format); + error = Args::StringToFormat(option_arg, format, NULL); break; case 'o': Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Apr 28 15:55:26 2011 @@ -334,7 +334,7 @@ case 'L': show_location= true; break; case 'c': show_decl = true; break; case 'D': debug = true; break; - case 'f': error = Args::StringToFormat(option_arg, format); break; + case 'f': error = Args::StringToFormat(option_arg, format, NULL); break; case 'F': flat_output = true; break; case 'A': max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Thu Apr 28 15:55:26 2011 @@ -24,13 +24,14 @@ #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupOutputFile.h" +#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" using namespace lldb; using namespace lldb_private; -OptionDefinition +static OptionDefinition g_option_table[] = { { LLDB_OPT_SET_1| @@ -49,9 +50,9 @@ public: OptionGroupReadMemory () : - m_byte_size (0,0), - m_count (0,0), - m_num_per_line (0,0), + m_byte_size (1,1), + m_count (8,8), + m_num_per_line (1,1), m_output_as_binary (false), m_view_as_type() { @@ -128,26 +129,55 @@ m_view_as_type.Clear(); } - void - FinalizeSettings (lldb::Format format) + Error + FinalizeSettings (Target *target, const OptionGroupFormat& format_options) { - if (m_num_per_line.GetCurrentValue() == 0) - m_num_per_line.SetCurrentValue(1); - - switch (format) + Error error; + bool byte_size_option_set = m_byte_size.OptionWasSet(); + const bool num_per_line_option_set = m_num_per_line.OptionWasSet(); + const bool count_option_set = m_count.OptionWasSet(); + + uint32_t format_byte_size = format_options.GetByteSize(); + if (byte_size_option_set) + { + if (format_byte_size > 0) + { + error.SetErrorString("can't specify the byte size in both the '--size ' option and the '--format []' options."); + return error; + } + } + else + { + if (format_byte_size != 0) + { + byte_size_option_set = true; + m_byte_size = format_byte_size; + } + } + + switch (format_options.GetFormat()) { default: break; case eFormatBoolean: - if (m_byte_size.GetCurrentValue() == 0) + if (!byte_size_option_set) m_byte_size = 1; + if (!num_per_line_option_set) + m_num_per_line = 1; + if (!count_option_set) + m_count = 8; break; case eFormatCString: break; case eFormatPointer: + m_byte_size = target->GetArchitecture().GetAddressByteSize(); + if (!num_per_line_option_set) + m_num_per_line = 4; + if (!count_option_set) + m_count = 8; break; case eFormatBinary: @@ -158,27 +188,69 @@ case eFormatUnicode16: case eFormatUnicode32: case eFormatUnsigned: - if (m_byte_size.GetCurrentValue() == 0) + if (!byte_size_option_set) m_byte_size = 4; + if (!num_per_line_option_set) + m_num_per_line = 1; + if (!count_option_set) + m_count = 8; break; case eFormatBytes: case eFormatBytesWithASCII: - if (m_byte_size.GetCurrentValue() == 0) + if (m_byte_size.OptionWasSet()) + { + if (m_byte_size > 1) + error.SetErrorString ("use --count option to specify an end address to display a number of bytes"); + } + else m_byte_size = 1; + if (!num_per_line_option_set) + m_num_per_line = 16; + if (!count_option_set) + m_count = 32; break; case eFormatChar: case eFormatCharPrintable: - if (m_byte_size.GetCurrentValue() == 0) + if (!byte_size_option_set) m_byte_size = 1; + if (!num_per_line_option_set) + m_num_per_line = 32; + if (!count_option_set) + m_count = 64; break; case eFormatComplex: - if (m_byte_size.GetCurrentValue() == 0) + if (!byte_size_option_set) m_byte_size = 8; + if (!num_per_line_option_set) + m_num_per_line = 1; + if (!count_option_set) + m_count = 8; break; case eFormatHex: - if (m_byte_size.GetCurrentValue() == 0) + if (!byte_size_option_set) m_byte_size = 4; + if (!num_per_line_option_set) + { + switch (m_byte_size) + { + case 1: + case 2: + m_num_per_line = 8; + break; + case 4: + m_num_per_line = 4; + break; + case 8: + m_num_per_line = 2; + break; + default: + m_num_per_line = 1; + break; + } + } + if (!count_option_set) + m_count = 8; break; case eFormatVectorOfChar: @@ -193,8 +265,15 @@ case eFormatVectorOfFloat32: case eFormatVectorOfFloat64: case eFormatVectorOfUInt128: + if (!byte_size_option_set) + m_byte_size = 128; + if (!num_per_line_option_set) + m_num_per_line = 1; + if (!count_option_set) + m_count = 4; break; } + return error; } OptionValueUInt64 m_byte_size; @@ -213,172 +292,6 @@ { public: -// class CommandOptions : public Options -// { -// public: -// CommandOptions (CommandInterpreter &interpreter) : -// Options(interpreter) -// { -// OptionParsingStarting(); -// } -// -// virtual -// ~CommandOptions () -// { -// } -// -// virtual Error -// SetOptionValue (uint32_t option_idx, const char *option_arg) -// { -// Error error; -// char short_option = (char) m_getopt_table[option_idx].val; -// -// switch (short_option) -// { -// case 'f': -// error = Args::StringToFormat (option_arg, m_format); -// -// switch (m_format) -// { -// default: -// break; -// -// case eFormatBoolean: -// if (m_byte_size == 0) -// m_byte_size = 1; -// if (m_num_per_line == 0) -// m_num_per_line = 1; -// break; -// -// case eFormatCString: -// if (m_num_per_line == 0) -// m_num_per_line = 1; -// break; -// -// case eFormatPointer: -// break; -// -// case eFormatBinary: -// case eFormatFloat: -// case eFormatOctal: -// case eFormatDecimal: -// case eFormatEnum: -// case eFormatUnicode16: -// case eFormatUnicode32: -// case eFormatUnsigned: -// if (m_byte_size == 0) -// m_byte_size = 4; -// if (m_num_per_line == 0) -// m_num_per_line = 1; -// break; -// -// case eFormatBytes: -// case eFormatBytesWithASCII: -// case eFormatChar: -// case eFormatCharPrintable: -// if (m_byte_size == 0) -// m_byte_size = 1; -// break; -// case eFormatComplex: -// if (m_byte_size == 0) -// m_byte_size = 8; -// break; -// case eFormatHex: -// if (m_byte_size == 0) -// m_byte_size = 4; -// break; -// -// case eFormatVectorOfChar: -// case eFormatVectorOfSInt8: -// case eFormatVectorOfUInt8: -// case eFormatVectorOfSInt16: -// case eFormatVectorOfUInt16: -// case eFormatVectorOfSInt32: -// case eFormatVectorOfUInt32: -// case eFormatVectorOfSInt64: -// case eFormatVectorOfUInt64: -// case eFormatVectorOfFloat32: -// case eFormatVectorOfFloat64: -// case eFormatVectorOfUInt128: -// break; -// } -// break; -// -// case 'l': -// m_num_per_line = Args::StringToUInt32 (option_arg, 0); -// if (m_num_per_line == 0) -// error.SetErrorStringWithFormat("Invalid value for --num-per-line option '%s'. Must be positive integer value.\n", option_arg); -// break; -// -// case 'c': -// m_count = Args::StringToUInt32 (option_arg, 0); -// if (m_count == 0) -// error.SetErrorStringWithFormat("Invalid value for --count option '%s'. Must be positive integer value.\n", option_arg); -// break; -// -// case 's': -// m_byte_size = Args::StringToUInt32 (option_arg, 0); -// if (m_byte_size == 0) -// error.SetErrorStringWithFormat("Invalid value for --size option '%s'. Must be positive integer value.\n", option_arg); -// break; -// -// case 'o': -// m_outfile_filespec.SetFile (option_arg, true); -// break; -// -// case 'b': -// m_output_as_binary = true; -// break; -// -// case 'a': -// m_append_to_outfile = true; -// break; -// -// case 't': -// m_view_as_type.assign (option_arg); -// break; -// -// default: -// error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); -// break; -// } -// return error; -// } -// -// void -// OptionParsingStarting () -// { -// m_format = eFormatBytesWithASCII; -// m_byte_size = 0; -// m_count = 0; -// m_num_per_line = 0; -// m_outfile_filespec.Clear(); -// m_view_as_type.clear(); -// m_append_to_outfile = false; -// m_output_as_binary = false; -// } -// -// const OptionDefinition* -// GetDefinitions () -// { -// return g_option_table; -// } -// -// // Options table: Required for subclasses of Options. -// -// static OptionDefinition g_option_table[]; -// -// // Instance variables to hold the values for command options. -// lldb::Format m_format; -// uint32_t m_byte_size; -// uint32_t m_count; -// uint32_t m_num_per_line; -// FileSpec m_outfile_filespec; -// std::string m_view_as_type; -// bool m_append_to_outfile; -// bool m_output_as_binary; -// }; - CommandObjectMemoryRead (CommandInterpreter &interpreter) : CommandObject (interpreter, "memory read", @@ -386,9 +299,10 @@ NULL, eFlagProcessMustBeLaunched), m_option_group (interpreter), - m_format_options (eFormatBytesWithASCII), + m_format_options (eFormatBytesWithASCII, 0, true), m_memory_options (), - m_outfile_options () + m_outfile_options (), + m_varobj_options() { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -416,8 +330,8 @@ m_option_group.Append (&m_format_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_3); m_option_group.Append (&m_memory_options); m_option_group.Append (&m_outfile_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3); + m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_3); m_option_group.Finalize(); - } virtual @@ -452,9 +366,10 @@ return false; } - size_t item_byte_size = m_memory_options.m_byte_size.GetCurrentValue(); - ClangASTType clang_ast_type; - + ClangASTType clang_ast_type; + Error error; + + Format format = m_format_options.GetFormat(); const char *view_as_type_cstr = m_memory_options.m_view_as_type.GetCurrentValue(); if (view_as_type_cstr && view_as_type_cstr[0]) { @@ -571,42 +486,36 @@ --pointer_count; } - item_byte_size = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8; + m_memory_options.m_byte_size = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8; - if (item_byte_size == 0) + if (m_memory_options.m_byte_size == 0) { result.AppendErrorWithFormat ("unable to get the byte size of the type '%s'\n", view_as_type_cstr); result.SetStatus(eReturnStatusFailed); return false; } + + if (!m_memory_options.m_count.OptionWasSet()) + m_memory_options.m_count = 1; } else { - if (item_byte_size == 0) - { - if (m_format_options.GetFormat() == eFormatPointer) - item_byte_size = exe_ctx.target->GetArchitecture().GetAddressByteSize(); - else - item_byte_size = 1; - } + error = m_memory_options.FinalizeSettings (exe_ctx.target, m_format_options); } - size_t item_count = m_memory_options.m_count.GetCurrentValue(); - - size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue(); - if (num_per_line == 0) + // Look for invalid combinations of settings + if (error.Fail()) { - if (clang_ast_type.GetOpaqueQualType()) - num_per_line = 1; - else - { - num_per_line = (16/item_byte_size); - if (num_per_line == 0) - num_per_line = 1; - } + result.AppendErrorWithFormat("%s", error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; } + size_t item_count = m_memory_options.m_count.GetCurrentValue(); + const size_t item_byte_size = m_memory_options.m_byte_size; + const size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue(); + size_t total_byte_size = item_count * item_byte_size; if (total_byte_size == 0) total_byte_size = 32; @@ -625,19 +534,19 @@ lldb::addr_t end_addr = Args::StringToUInt64(command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0); if (end_addr == LLDB_INVALID_ADDRESS) { - result.AppendErrorWithFormat("Invalid end address string '%s'.\n", command.GetArgumentAtIndex(1)); + result.AppendErrorWithFormat("invalid end address string '%s'.\n", command.GetArgumentAtIndex(1)); result.SetStatus(eReturnStatusFailed); return false; } else if (end_addr <= addr) { - result.AppendErrorWithFormat("End address (0x%llx) must be greater that the start address (0x%llx).\n", end_addr, addr); + result.AppendErrorWithFormat("end address (0x%llx) must be greater that the start address (0x%llx).\n", end_addr, addr); result.SetStatus(eReturnStatusFailed); return false; } - else if (item_count != 0) + else if (m_memory_options.m_count.OptionWasSet()) { - result.AppendErrorWithFormat("Specify either the end address (0x%llx) or the count (--count %u), not both.\n", end_addr, item_count); + result.AppendErrorWithFormat("specify either the end address (0x%llx) or the count (--count %u), not both.\n", end_addr, item_count); result.SetStatus(eReturnStatusFailed); return false; } @@ -645,19 +554,8 @@ total_byte_size = end_addr - addr; item_count = total_byte_size / item_byte_size; } - else - { - if (item_count == 0) - { - if (clang_ast_type.GetOpaqueQualType()) - item_count = 1; - else - item_count = 32; - } - } DataBufferSP data_sp; - Error error; size_t bytes_read = 0; if (!clang_ast_type.GetOpaqueQualType()) { @@ -742,28 +640,24 @@ clang_ast_type)); if (valobj_sp) { - uint32_t ptr_depth = 0; - uint32_t curr_depth = 0; - uint32_t max_depth = UINT32_MAX; - bool show_types = false; - bool show_location = false; - bool use_objc = false; + if (format != eFormatDefault) + valobj_sp->SetFormat (format); + bool use_dynamic = false; - bool scope_already_checked = false; - bool flat_output = false; + bool scope_already_checked = true; ValueObject::DumpValueObject (*output_stream, valobj_sp.get(), NULL, - ptr_depth, - curr_depth, - max_depth, - show_types, - show_location, - use_objc, + m_varobj_options.ptr_depth, + 0, + m_varobj_options.max_depth, + m_varobj_options.show_types, + m_varobj_options.show_location, + m_varobj_options.use_objc, use_dynamic, scope_already_checked, - flat_output); + m_varobj_options.flat_output); } else { @@ -803,6 +697,7 @@ OptionGroupFormat m_format_options; OptionGroupReadMemory m_memory_options; OptionGroupOutputFile m_outfile_options; + OptionGroupValueObjectDisplay m_varobj_options; }; @@ -855,7 +750,7 @@ switch (short_option) { case 'f': - error = Args::StringToFormat (option_arg, m_format); + error = Args::StringToFormat (option_arg, m_format, &m_byte_size); break; case 's': Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Thu Apr 28 15:55:26 2011 @@ -265,7 +265,7 @@ switch (short_option) { case 'f': - error = Args::StringToFormat (option_arg, format); + error = Args::StringToFormat (option_arg, format, NULL); break; case 's': Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Thu Apr 28 15:55:26 2011 @@ -1446,24 +1446,20 @@ { assert (item_bit_size == 0 && item_bit_offset == 0); s->PutCString("0x"); - int32_t start_idx, end_idx, delta; - if (m_byte_order == eByteOrderBig) - { - start_idx = offset; - end_idx = offset + item_byte_size; - delta = 1; - } - else - { - start_idx = offset + item_byte_size - 1; - end_idx = -1; - delta = -1; - } const uint8_t *bytes = (const uint8_t* )GetData(&offset, item_byte_size); if (bytes) { - for (int32_t idx = start_idx; idx != end_idx; idx += delta) - s->Printf("%2.2x", bytes[idx]); + uint32_t idx; + if (m_byte_order == eByteOrderBig) + { + for (idx = 0; idx < item_byte_size; ++idx) + s->Printf("%2.2x", bytes[idx]); + } + else + { + for (idx = 0; idx < item_byte_size; ++idx) + s->Printf("%2.2x", bytes[item_byte_size - 1 - idx]); + } } } break; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Thu Apr 28 15:55:26 2011 @@ -674,13 +674,14 @@ if (clang_type) { StreamString sstr; - if (m_format == eFormatDefault) - m_format = ClangASTType::GetFormat(clang_type); + Format format = GetFormat(); + if (format == eFormatDefault) + format = ClangASTType::GetFormat(clang_type); if (ClangASTType::DumpTypeValue (GetClangAST(), // The clang AST clang_type, // The clang type to display &sstr, - m_format, // Format to display this type with + format, // Format to display this type with m_data, // Data to extract from 0, // Byte offset into "m_data" GetByteSize(), // Byte size of item in "m_data" Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Thu Apr 28 15:55:26 2011 @@ -876,7 +876,8 @@ Args::StringToFormat ( const char *s, - lldb::Format &format + lldb::Format &format, + uint32_t *byte_size_ptr ) { format = eFormatInvalid; @@ -884,29 +885,51 @@ if (s && s[0]) { - switch (s[0]) + if (byte_size_ptr) { - case 'y': format = eFormatBytes; break; - case 'Y': format = eFormatBytesWithASCII; break; - case 'b': format = eFormatBinary; break; - case 'B': format = eFormatBoolean; break; - case 'c': format = eFormatChar; break; - case 'C': format = eFormatCharPrintable; break; - case 'o': format = eFormatOctal; break; - case 'O': format = eFormatOSType; break; - case 'i': - case 'd': format = eFormatDecimal; break; - case 'I': format = eFormatComplexInteger; break; - case 'u': format = eFormatUnsigned; break; - case 'x': format = eFormatHex; break; - case 'X': format = eFormatComplex; break; - case 'f': - case 'e': - case 'g': format = eFormatFloat; break; - case 'p': format = eFormatPointer; break; - case 's': format = eFormatCString; break; - default: - error.SetErrorStringWithFormat("Invalid format character '%c'. Valid values are:\n" + if (isdigit (s[0])) + { + char *format_char = NULL; + unsigned long byte_size = ::strtoul (s, &format_char, 0); + if (byte_size != ULONG_MAX) + *byte_size_ptr = byte_size; + s = format_char; + } + else + *byte_size_ptr = 0; + } + + bool success = s[1] == '\0'; + if (success) + { + switch (s[0]) + { + case 'y': format = eFormatBytes; break; + case 'Y': format = eFormatBytesWithASCII; break; + case 'b': format = eFormatBinary; break; + case 'B': format = eFormatBoolean; break; + case 'c': format = eFormatChar; break; + case 'C': format = eFormatCharPrintable; break; + case 'o': format = eFormatOctal; break; + case 'O': format = eFormatOSType; break; + case 'i': + case 'd': format = eFormatDecimal; break; + case 'I': format = eFormatComplexInteger; break; + case 'u': format = eFormatUnsigned; break; + case 'x': format = eFormatHex; break; + case 'X': format = eFormatComplex; break; + case 'f': + case 'e': + case 'g': format = eFormatFloat; break; + case 'p': format = eFormatPointer; break; + case 's': format = eFormatCString; break; + default: + success = false; + break; + } + } + if (!success) + error.SetErrorStringWithFormat ("Invalid format specification '%s'. Valid values are:\n" " b - binary\n" " B - boolean\n" " c - char\n" @@ -925,9 +948,10 @@ " x - hex\n" " X - complex float\n" " y - bytes\n" - " Y - bytes with ASCII\n", s[0]); - break; - } + " Y - bytes with ASCII\n%s", + s, + byte_size_ptr ? "An optional byte size can precede the format character.\n" : ""); + if (error.Fail()) return error; Modified: lldb/trunk/source/Interpreter/NamedOptionValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/NamedOptionValue.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/NamedOptionValue.cpp (original) +++ lldb/trunk/source/Interpreter/NamedOptionValue.cpp Thu Apr 28 15:55:26 2011 @@ -318,11 +318,14 @@ OptionValueFormat::SetValueFromCString (const char *value_cstr) { Format new_format; - Error error (Args::StringToFormat(value_cstr, new_format)); + uint32_t new_byte_size = UINT32_MAX; + Error error (Args::StringToFormat(value_cstr, new_format, m_byte_size_prefix_ok ? &new_byte_size : NULL)); if (error.Success()) { m_value_was_set = true; m_current_value = new_format; + if (new_byte_size != UINT32_MAX) + m_current_byte_size = new_byte_size; } return error; } Modified: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Thu Apr 28 15:55:26 2011 @@ -17,8 +17,14 @@ using namespace lldb; using namespace lldb_private; -OptionGroupFormat::OptionGroupFormat(lldb::Format default_format) : - m_format (default_format, default_format) +OptionGroupFormat::OptionGroupFormat(lldb::Format default_format, + uint32_t default_byte_size, + bool byte_size_prefix_ok) : + m_format (default_format, + default_format, + default_byte_size, + default_byte_size, + byte_size_prefix_ok) { } @@ -47,8 +53,8 @@ Error OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) + uint32_t option_idx, + const char *option_arg) { Error error; char short_option = (char) g_option_table[option_idx].short_option; Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=130436&r1=130435&r2=130436&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Thu Apr 28 15:55:26 2011 @@ -25,17 +25,16 @@ { } -OptionDefinition +static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, - { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat,"Specify the format that the variable output should use."}, + { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, { LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, - { LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, - { LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, - { LLDB_OPT_SET_1, false, "show-types", 't', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, - { LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, + { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "Print as an Objective-C object."}, + { LLDB_OPT_SET_1, false, "ptr-depth", 'P', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, + { LLDB_OPT_SET_1, false, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, + { LLDB_OPT_SET_1, false, "no-summary", 'Y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; @@ -65,19 +64,18 @@ switch (short_option) { - case 't': show_types = true; break; - case 'y': show_summary = false; break; + case 'T': show_types = true; break; + case 'Y': show_summary = false; break; case 'L': show_location= true; break; case 'F': flat_output = true; break; - case 'f': error = Args::StringToFormat(option_arg, format); break; - case 'o': use_objc = true; break; - case 'd': + case 'O': use_objc = true; break; + case 'D': max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); if (!success) error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); break; - case 'p': + case 'P': ptr_depth = Args::StringToUInt32 (option_arg, 0, 0, &success); if (!success) error.SetErrorStringWithFormat("Invalid pointer depth '%s'.\n", option_arg); @@ -101,6 +99,5 @@ use_objc = false; max_depth = UINT32_MAX; ptr_depth = 0; - format = eFormatDefault; } From johnny.chen at apple.com Thu Apr 28 16:31:18 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Apr 2011 21:31:18 -0000 Subject: [Lldb-commits] [lldb] r130442 - in /lldb/trunk: scripts/Python/append-debugger-id.py scripts/Python/build-swig-Python.sh scripts/Python/modify-python-lldb.py test/python_api/lldbutil/TestLLDBIterator.py Message-ID: <20110428213118.8EF222A6C135@llvm.org> Author: johnny Date: Thu Apr 28 16:31:18 2011 New Revision: 130442 URL: http://llvm.org/viewvc/llvm-project?rev=130442&view=rev Log: Move the iteration protocol of lldb objects to the auto-generated lldb Python module. This is so that the objects which support the iteration protocol are immediately obvious from looking at the lldb.py file. SBTarget supports two types of iterations: module and breakpoint. For an SBTarget instance, you will need to issue either: for m in target.module_iter() or for b in target.breakpoint_iter() For other single iteration protocol objects, just use, for example: for thread in process: ID = thread.GetThreadID() for frame in thread: frame.Disassemble() .... Added: lldb/trunk/scripts/Python/modify-python-lldb.py - copied, changed from r130407, lldb/trunk/scripts/Python/append-debugger-id.py Removed: lldb/trunk/scripts/Python/append-debugger-id.py Modified: lldb/trunk/scripts/Python/build-swig-Python.sh lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Removed: lldb/trunk/scripts/Python/append-debugger-id.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/append-debugger-id.py?rev=130441&view=auto ============================================================================== --- lldb/trunk/scripts/Python/append-debugger-id.py (original) +++ lldb/trunk/scripts/Python/append-debugger-id.py (removed) @@ -1,23 +0,0 @@ -# -# append-debugger-id.py -# -# This script adds a global variable, 'debugger_unique_id' to the lldb -# module (which was automatically generated via running swig), and -# initializes it to 0. -# -# It also calls SBDebugger.Initialize() to initialize the lldb debugger -# subsystem. -# - -import sys - -if len (sys.argv) != 2: - output_name = "./lldb.py" -else: - output_name = sys.argv[1] + "/lldb.py" - -# print "output_name is '" + output_name + "'" - -with open(output_name, 'a') as f_out: - f_out.write("debugger_unique_id = 0\n") - f_out.write("SBDebugger.Initialize()\n") Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=130442&r1=130441&r2=130442&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Thu Apr 28 16:31:18 2011 @@ -173,12 +173,13 @@ $SWIG -c++ -shadow -python -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" +# Implement the iterator protocol for some lldb objects. # Append global variable to lldb Python module. - +# And initialize the lldb debugger subsystem. current_dir=`pwd` -if [ -f "${current_dir}/append-debugger-id.py" ] +if [ -f "${current_dir}/modify-python-lldb.py" ] then - python ${current_dir}/append-debugger-id.py ${CONFIG_BUILD_DIR} + python ${current_dir}/modify-python-lldb.py ${CONFIG_BUILD_DIR} fi # Fix the "#include" statement in the swig output file Copied: lldb/trunk/scripts/Python/modify-python-lldb.py (from r130407, lldb/trunk/scripts/Python/append-debugger-id.py) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?p2=lldb/trunk/scripts/Python/modify-python-lldb.py&p1=lldb/trunk/scripts/Python/append-debugger-id.py&r1=130407&r2=130442&rev=130442&view=diff ============================================================================== --- lldb/trunk/scripts/Python/append-debugger-id.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Thu Apr 28 16:31:18 2011 @@ -1,15 +1,15 @@ # -# append-debugger-id.py +# finish-lldb-python.py # -# This script adds a global variable, 'debugger_unique_id' to the lldb -# module (which was automatically generated via running swig), and -# initializes it to 0. +# This script modifies the lldb module (which was automatically generated via +# running swig) to support iteration for certain lldb objects, adds a global +# variable 'debugger_unique_id' and initializes it to 0. # # It also calls SBDebugger.Initialize() to initialize the lldb debugger # subsystem. # -import sys +import sys, re, StringIO if len (sys.argv) != 2: output_name = "./lldb.py" @@ -18,6 +18,103 @@ # print "output_name is '" + output_name + "'" -with open(output_name, 'a') as f_out: +# +# lldb_iter() should appear before the our first SB* class definition. +# +lldb_iter_def = ''' +# =================================== +# Iterator for lldb container objects +# =================================== +def lldb_iter(obj, getsize, getelem): + """A generator adaptor to support iteration for lldb container objects.""" + size = getattr(obj, getsize) + elem = getattr(obj, getelem) + for i in range(size()): + yield elem(i) + +''' + +# +# This supports the iteration protocol. +# +iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" +module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" +breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" + +# +# The dictionary defines a mapping from classname to (getsize, getelem) tuple. +# +d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), + 'SBCompileUnit': ('GetNumLineEntries', 'GetLineEntryAtIndex'), + 'SBDebugger': ('GetNumTargets', 'GetTargetAtIndex'), + 'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'), + 'SBProcess': ('GetNumThreads', 'GetThreadAtIndex'), + 'SBThread': ('GetNumFrames', 'GetFrameAtIndex'), + + 'SBInstructionList': ('GetSize', 'GetInstructionAtIndex'), + 'SBStringList': ('GetSize', 'GetStringAtIndex',), + 'SBSymbolContextList': ('GetSize', 'GetContextAtIndex'), + 'SBValueList': ('GetSize', 'GetValueAtIndex'), + + 'SBType': ('GetNumberChildren', 'GetChildAtIndex'), + 'SBValue': ('GetNumChildren', 'GetChildAtIndex'), + + 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), + 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex') + } + } + +# The new content will have the iteration protocol defined for our lldb objects. +new_content = StringIO.StringIO() + +with open(output_name, 'r') as f_in: + content = f_in.read() + +# The pattern for recognizing the beginning of an SB class definition. +class_pattern = re.compile("^class (SB.*)\(_object\):$") + +# The pattern for recognizing the beginning of the __init__ method definition. +init_pattern = re.compile("^ def __init__\(self, \*args\):") + +# These define the states of our state machine. +NORMAL = 0 +DEFINING_ITERATOR = 1 +DEFINING_TARGET_ITERATOR = 2 + +# The lldb_iter_def only needs to be inserted once. +lldb_iter_defined = False; + +state = NORMAL +for line in content.splitlines(): + if state == NORMAL: + match = class_pattern.search(line) + if not lldb_iter_defined and match: + print >> new_content, lldb_iter_def + lldb_iter_defined = True + if match and match.group(1) in d: + # Adding support for iteration for the matched SB class. + cls = match.group(1) + # Next state will be DEFINING_ITERATOR. + state = DEFINING_ITERATOR + elif state == DEFINING_ITERATOR: + match = init_pattern.search(line) + if match: + # We found the beginning of the __init__ method definition. + # This is a good spot to insert the iteration support. + # + # But note that SBTarget has two types of iterations. + if cls == "SBTarget": + print >> new_content, module_iter % (d[cls]['module']) + print >> new_content, breakpoint_iter % (d[cls]['breakpoint']) + else: + print >> new_content, iter_def % d[cls] + # Next state will be NORMAL. + state = NORMAL + + # Pass the original line of content to the ew_content. + print >> new_content, line + +with open(output_name, 'w') as f_out: + f_out.write(new_content.getvalue()) f_out.write("debugger_unique_id = 0\n") f_out.write("SBDebugger.Initialize()\n") Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130442&r1=130441&r2=130442&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Thu Apr 28 16:31:18 2011 @@ -21,19 +21,19 @@ self.line2 = line_number('main.cpp', '// And that line.') def test_lldb_iter_1(self): - """Test lldb_iter works correctly for SBTarget -> SBModule.""" + """Test module_iter works correctly for SBTarget -> SBModule.""" self.buildDefault() self.lldb_iter_1() def test_lldb_iter_2(self): - """Test lldb_iter works correctly for SBTarget -> SBBreakpoint.""" + """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" self.buildDefault() self.lldb_iter_2() - def test_smart_iter_1(self): - """Test smart_iter works correctly for SBProcess->SBThread->SBFrame.""" + def test_lldb_iter_3(self): + """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" self.buildDefault() - self.smart_iter_1() + self.lldb_iter_3() def lldb_iter_1(self): exe = os.path.join(os.getcwd(), "a.out") @@ -51,12 +51,12 @@ if not rc.Success() or not self.process.IsValid(): self.fail("SBTarget.LaunchProcess() failed") - from lldbutil import lldb_iter, get_description + from lldbutil import get_description yours = [] for i in range(target.GetNumModules()): yours.append(target.GetModuleAtIndex(i)) mine = [] - for m in lldb_iter(target, 'GetNumModules', 'GetModuleAtIndex'): + for m in target.module_iter(): mine.append(m) self.assertTrue(len(yours) == len(mine)) @@ -80,12 +80,12 @@ self.assertTrue(target.GetNumBreakpoints() == 2) - from lldbutil import lldb_iter, get_description + from lldbutil import get_description yours = [] for i in range(target.GetNumBreakpoints()): yours.append(target.GetBreakpointAtIndex(i)) mine = [] - for m in lldb_iter(target, 'GetNumBreakpoints', 'GetBreakpointAtIndex'): + for m in target.breakpoint_iter(): mine.append(m) self.assertTrue(len(yours) == len(mine)) @@ -96,7 +96,7 @@ self.assertTrue(yours[i].GetID() == mine[i].GetID(), "ID of yours[{0}] and mine[{0}] matches".format(i)) - def smart_iter_1(self): + def lldb_iter_3(self): exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -112,15 +112,15 @@ if not rc.Success() or not self.process.IsValid(): self.fail("SBTarget.LaunchProcess() failed") - from lldbutil import smart_iter, print_stacktrace + from lldbutil import print_stacktrace stopped_due_to_breakpoint = False - for thread in smart_iter(self.process): + for thread in self.process: if self.TraceOn(): print_stacktrace(thread) ID = thread.GetThreadID() if thread.GetStopReason() == lldb.eStopReasonBreakpoint: stopped_due_to_breakpoint = True - for frame in smart_iter(thread): + for frame in thread: self.assertTrue(frame.GetThread().GetThreadID() == ID) if self.TraceOn(): print frame From johnny.chen at apple.com Thu Apr 28 17:57:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Apr 2011 22:57:01 -0000 Subject: [Lldb-commits] [lldb] r130452 - in /lldb/trunk/test: class_static/TestStaticVariables.py class_types/TestClassTypesDisassembly.py foundation/TestSymbolTable.py lldbutil.py python_api/frame/TestFrames.py python_api/lldbutil/TestLLDBIterator.py Message-ID: <20110428225702.09D052A6C135@llvm.org> Author: johnny Date: Thu Apr 28 17:57:01 2011 New Revision: 130452 URL: http://llvm.org/viewvc/llvm-project?rev=130452&view=rev Log: Modify the test suite and lldbutil.py to utilize the Python iteration pattern now that the lldb iteration protocol has been added to lldb.py module. Modified: lldb/trunk/test/class_static/TestStaticVariables.py lldb/trunk/test/class_types/TestClassTypesDisassembly.py lldb/trunk/test/foundation/TestSymbolTable.py lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/frame/TestFrames.py lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Modified: lldb/trunk/test/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/TestStaticVariables.py?rev=130452&r1=130451&r2=130452&view=diff ============================================================================== --- lldb/trunk/test/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/class_static/TestStaticVariables.py Thu Apr 28 17:57:01 2011 @@ -101,8 +101,7 @@ # in_scope_only => False valList = frame.GetVariables(False, False, True, False) - from lldbutil import lldb_iter - for val in lldb_iter(valList, 'GetSize', 'GetValueAtIndex'): + for val in valList: self.DebugSBValue(frame, val) self.assertTrue(val.GetValueType() == lldb.eValueTypeVariableGlobal) name = val.GetName() Modified: lldb/trunk/test/class_types/TestClassTypesDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypesDisassembly.py?rev=130452&r1=130451&r2=130452&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypesDisassembly.py (original) +++ lldb/trunk/test/class_types/TestClassTypesDisassembly.py Thu Apr 28 17:57:01 2011 @@ -103,9 +103,8 @@ if function.IsValid(): # Get all instructions for this function and print them out. insts = function.GetInstructions(target) - from lldbutil import lldb_iter - for inst in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'): - # It could simply be 'print inst' to print out the disassembly. + for inst in insts: + # We could simply do 'print inst' to print out the disassembly. # But we want to print to stdout only if self.TraceOn() is True. disasm = str(inst) if self.TraceOn(): Modified: lldb/trunk/test/foundation/TestSymbolTable.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestSymbolTable.py?rev=130452&r1=130451&r2=130452&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestSymbolTable.py (original) +++ lldb/trunk/test/foundation/TestSymbolTable.py Thu Apr 28 17:57:01 2011 @@ -60,8 +60,7 @@ # Create the set of known symbols. As we iterate through the symbol # table, remove the symbol from the set if it is a known symbol. expected_symbols = set(self.symbols_list) - from lldbutil import lldb_iter - for symbol in lldb_iter(module, 'GetNumSymbols', 'GetSymbolAtIndex'): + for symbol in module: self.assertTrue(symbol.IsValid(), VALID_SYMBOL) #print "symbol:", symbol name = symbol.GetName() Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130452&r1=130451&r2=130452&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu Apr 28 17:57:01 2011 @@ -27,85 +27,6 @@ return exe_file return None -# =========================================== -# Iterator for lldb aggregate data structures -# =========================================== - -def lldb_iter(obj, getsize, getelem): - """A generator adaptor for lldb aggregate data structures. - - API clients pass in an aggregate object or a container of it, the name of - the method to get the size of the aggregate, and the name of the method to - get the element by index. - - Example usages: - - 1. Pass an aggregate as the first argument: - - def disassemble_instructions (insts): - from lldbutil import lldb_iter - for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'): - print i - - 2. Pass a container of aggregate which provides APIs to get to the size and - the element of the aggregate: - - # Module is a container of symbol table - module = target.FindModule(filespec) - for symbol in lldb_iter(module, 'GetNumSymbols', 'GetSymbolAtIndex'): - name = symbol.GetName() - ... - """ - #import traceback - #traceback.print_stack() - size = getattr(obj, getsize) - elem = getattr(obj, getelem) - for i in range(size()): - yield elem(i) - -def smart_iter(obj): - """Returns an iterator for eligible lldb objects, or None otherwise. - - An example of eligible lldb container object is SBModule, which contains - SBSymbols. While SBTarget contains SBModules and SBBreakpoints, because it - is ambiguous which containee type to iterate on, the best we can do is to - return None. API clients can use lldb_iter() to clarify their intentions. - - SBSymbol does not have the notion of containee objects and is not eligible - for smart iterator. - - Example usage: - - from lldb_util import smart_iter - for thread in smart_iter(process): - ID = thread.GetThreadID() - if thread.GetStopReason() == lldb.eStopReasonBreakpoint: - stopped_due_to_breakpoint = True - for frame in smart_iter(thread): - self.assertTrue(frame.GetThread().GetThreadID() == ID) - ... - """ - d = { lldb.SBBreakpoint: ('GetNumLocations', 'GetLocationAtIndex'), - lldb.SBCompileUnit: ('GetNumLineEntries', 'GetLineEntryAtIndex'), - lldb.SBDebugger: ('GetNumTargets', 'GetTargetAtIndex'), - lldb.SBModule: ('GetNumSymbols', 'GetSymbolAtIndex'), - lldb.SBProcess: ('GetNumThreads', 'GetThreadAtIndex'), - lldb.SBThread: ('GetNumFrames', 'GetFrameAtIndex'), - - lldb.SBInstructionList: ('GetSize', 'GetInstructionAtIndex'), - lldb.SBStringList: ('GetSize', 'GetStringAtIndex',), - lldb.SBSymbolContextList: ('GetSize', 'GetContextAtIndex'), - lldb.SBValueList: ('GetSize', 'GetValueAtIndex'), - - lldb.SBType: ('GetNumberChildren', 'GetChildAtIndex'), - lldb.SBValue: ('GetNumChildren', 'GetChildAtIndex') - } - if obj.__class__ in d: - val = d.get(obj.__class__) - return lldb_iter(obj, val[0], val[1]) - else: - return None - # =================================================== # Disassembly for an SBFunction or an SBSymbol object # =================================================== @@ -117,7 +38,7 @@ """ buf = StringIO.StringIO() insts = function_or_symbol.GetInstructions(target) - for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'): + for i in insts: print >> buf, i return buf.getvalue() @@ -289,7 +210,7 @@ def get_stopped_threads(process, reason): """Returns the thread(s) with the specified stop reason in a list.""" threads = [] - for t in lldb_iter(process, 'GetNumThreads', 'GetThreadAtIndex'): + for t in process: if t.GetStopReason() == reason: threads.append(t) return threads Modified: lldb/trunk/test/python_api/frame/TestFrames.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/TestFrames.py?rev=130452&r1=130451&r2=130452&view=diff ============================================================================== --- lldb/trunk/test/python_api/frame/TestFrames.py (original) +++ lldb/trunk/test/python_api/frame/TestFrames.py Thu Apr 28 17:57:01 2011 @@ -80,8 +80,7 @@ # in_scope_only => True valList = frame.GetVariables(True, False, False, True) argList = [] - from lldbutil import lldb_iter - for val in lldb_iter(valList, 'GetSize', 'GetValueAtIndex'): + for val in valList: #self.DebugSBValue(frame, val) argList.append("(%s)%s=%s" % (val.GetTypeName(), val.GetName(), Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130452&r1=130451&r2=130452&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Thu Apr 28 17:57:01 2011 @@ -1,6 +1,5 @@ """ -Test lldb_iter/smart_iter() which returns an iterator object for lldb container -objects. +Test the iteration protocol for some lldb container objects. """ import os, time From johnny.chen at apple.com Thu Apr 28 18:26:17 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Apr 2011 23:26:17 -0000 Subject: [Lldb-commits] [lldb] r130456 - /lldb/trunk/examples/python/disasm.py Message-ID: <20110428232617.934C12A6C135@llvm.org> Author: johnny Date: Thu Apr 28 18:26:17 2011 New Revision: 130456 URL: http://llvm.org/viewvc/llvm-project?rev=130456&view=rev Log: Modified to take advantage of the iteration protocol for our lldb container objects. Modified: lldb/trunk/examples/python/disasm.py Modified: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=130456&r1=130455&r2=130456&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Thu Apr 28 18:26:17 2011 @@ -14,8 +14,8 @@ import time def disassemble_instructions (insts): - for i in range(insts.GetSize()): - print insts.GetInstructionAtIndex(i) + for i in insts: + print i # Create a new debugger instance debugger = lldb.SBDebugger.Create() @@ -74,17 +74,13 @@ insts = symbol.GetInstructions(target) disassemble_instructions (insts) - print "Frame registers:" registerList = frame.GetRegisters() - numRegisterSets = registerList.GetSize() - for i in range (0, numRegisterSets): - value = registerList.GetValueAtIndex(i) - print value - numChildren = value.GetNumChildren() - if numChildren > 0: - for j in range (0, numChildren): - child = value.GetChildAtIndex(j) - print "Name: ", child.GetName(), " Value: ", child.GetValue(frame) + print "Frame registers (size of register set = %d):" % registerList.GetSize() + for value in registerList: + #print value + print "%s (number of children = %d):" % (value.GetName(), value.GetNumChildren()) + for child in value: + print "Name: ", child.GetName(), " Value: ", child.GetValue(frame) print "Hit the breakpoint at main, continue and wait for program to exit..." # Now continue to the program exit From johnny.chen at apple.com Thu Apr 28 18:34:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Apr 2011 23:34:58 -0000 Subject: [Lldb-commits] [lldb] r130457 - /lldb/trunk/utils/test/lldb-disasm.py Message-ID: <20110428233458.67D0A2A6C135@llvm.org> Author: johnny Date: Thu Apr 28 18:34:58 2011 New Revision: 130457 URL: http://llvm.org/viewvc/llvm-project?rev=130457&view=rev Log: Modified to take advantage of the iteration protocol for our lldb container objects. Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=130457&r1=130456&r2=130457&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Thu Apr 28 18:34:58 2011 @@ -78,7 +78,6 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, symbols_to_disassemble): import lldb, atexit, re - from lldbutil import lldb_iter # Create the debugger instance now. dbg = lldb.SBDebugger.Create() @@ -127,9 +126,9 @@ if limited: count = 0 stream = lldb.SBStream() - for m in lldb_iter(target, 'GetNumModules', 'GetModuleAtIndex'): + for m in target.module_iter(): print "module:", m - for s in lldb_iter(m, 'GetNumSymbols', 'GetSymbolAtIndex'): + for s in m: if limited and count >= num: return print "symbol:", s.GetName() From johnny.chen at apple.com Thu Apr 28 18:53:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Apr 2011 23:53:16 -0000 Subject: [Lldb-commits] [lldb] r130461 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110428235317.043BE2A6C135@llvm.org> Author: johnny Date: Thu Apr 28 18:53:16 2011 New Revision: 130461 URL: http://llvm.org/viewvc/llvm-project?rev=130461&view=rev Log: Fix a typo. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=130461&r1=130460&r2=130461&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Thu Apr 28 18:53:16 2011 @@ -1,5 +1,5 @@ # -# finish-lldb-python.py +# modify-lldb-python.py # # This script modifies the lldb module (which was automatically generated via # running swig) to support iteration for certain lldb objects, adds a global From johnny.chen at apple.com Fri Apr 29 14:03:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 29 Apr 2011 19:03:03 -0000 Subject: [Lldb-commits] [lldb] r130531 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/lldbutil/TestLLDBIterator.py Message-ID: <20110429190303.0DFAB2A6C135@llvm.org> Author: johnny Date: Fri Apr 29 14:03:02 2011 New Revision: 130531 URL: http://llvm.org/viewvc/llvm-project?rev=130531&view=rev Log: Add the Python rich comparison methods for SBBreakpoint, where GetID() returns the breakpoint ID and provides the semantics needed for '==' and '!='. And modify LLDBIteratorTestCase.lldb_iter_2() to use '==' between two SBBreakpoint's. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=130531&r1=130530&r2=130531&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Fri Apr 29 14:03:02 2011 @@ -40,6 +40,10 @@ iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" +# +# This supports the rich comparison methods of __eq__ and __ne__. +eq_def = " def __eq__(self, other): return isinstance(other, %s) and self.%s() == other.%s()" +ne_def = " def __ne__(self, other): return not self.__eq__(other)" # # The dictionary defines a mapping from classname to (getsize, getelem) tuple. @@ -64,6 +68,11 @@ } } +# +# This dictionary defines a mapping from classname to equality method name. +# +e = { 'SBBreakpoint': 'GetID' } + # The new content will have the iteration protocol defined for our lldb objects. new_content = StringIO.StringIO() @@ -79,7 +88,7 @@ # These define the states of our state machine. NORMAL = 0 DEFINING_ITERATOR = 1 -DEFINING_TARGET_ITERATOR = 2 +DEFINING_EQUALITY = 2 # The lldb_iter_def only needs to be inserted once. lldb_iter_defined = False; @@ -91,25 +100,32 @@ if not lldb_iter_defined and match: print >> new_content, lldb_iter_def lldb_iter_defined = True - if match and match.group(1) in d: - # Adding support for iteration for the matched SB class. + if match: cls = match.group(1) - # Next state will be DEFINING_ITERATOR. - state = DEFINING_ITERATOR - elif state == DEFINING_ITERATOR: + if cls in d: + # Adding support for iteration for the matched SB class. + state = (state | DEFINING_ITERATOR) + if cls in e: + # Adding support for eq and ne for the matched SB class. + state = (state | DEFINING_EQUALITY) + elif state > NORMAL: match = init_pattern.search(line) if match: # We found the beginning of the __init__ method definition. - # This is a good spot to insert the iteration support. + # This is a good spot to insert the iter and/or eq-ne support. # # But note that SBTarget has two types of iterations. if cls == "SBTarget": print >> new_content, module_iter % (d[cls]['module']) print >> new_content, breakpoint_iter % (d[cls]['breakpoint']) else: - print >> new_content, iter_def % d[cls] - # Next state will be NORMAL. - state = NORMAL + if (state & DEFINING_ITERATOR): + print >> new_content, iter_def % d[cls] + if (state & DEFINING_EQUALITY): + print >> new_content, eq_def % (cls, e[cls], e[cls]) + print >> new_content, ne_def + # Next state will be NORMAL. + state = NORMAL # Pass the original line of content to the ew_content. print >> new_content, line Modified: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=130531&r1=130530&r2=130531&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py Fri Apr 29 14:03:02 2011 @@ -92,7 +92,7 @@ if self.TraceOn(): print "yours[%d]='%s'" % (i, get_description(yours[i])) print "mine[%d]='%s'" % (i, get_description(mine[i])) - self.assertTrue(yours[i].GetID() == mine[i].GetID(), + self.assertTrue(yours[i] == mine[i], "ID of yours[{0}] and mine[{0}] matches".format(i)) def lldb_iter_3(self): From johnny.chen at apple.com Fri Apr 29 14:19:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 29 Apr 2011 19:19:13 -0000 Subject: [Lldb-commits] [lldb] r130532 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110429191913.61B852A6C135@llvm.org> Author: johnny Date: Fri Apr 29 14:19:13 2011 New Revision: 130532 URL: http://llvm.org/viewvc/llvm-project?rev=130532&view=rev Log: Fix a bug introduced in my previous checkin, where the state was not properly restored after parsing "SBTarget". Indentation matters in Python. :-) Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=130532&r1=130531&r2=130532&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Fri Apr 29 14:19:13 2011 @@ -124,8 +124,9 @@ if (state & DEFINING_EQUALITY): print >> new_content, eq_def % (cls, e[cls], e[cls]) print >> new_content, ne_def - # Next state will be NORMAL. - state = NORMAL + + # Next state will be NORMAL. + state = NORMAL # Pass the original line of content to the ew_content. print >> new_content, line From johnny.chen at apple.com Fri Apr 29 14:22:25 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 29 Apr 2011 19:22:25 -0000 Subject: [Lldb-commits] [lldb] r130533 - in /lldb/trunk/scripts/Python: build-swig-Python.sh modify-python-lldb.py Message-ID: <20110429192225.1ABC72A6C135@llvm.org> Author: johnny Date: Fri Apr 29 14:22:24 2011 New Revision: 130533 URL: http://llvm.org/viewvc/llvm-project?rev=130533&view=rev Log: Update comments. Modified: lldb/trunk/scripts/Python/build-swig-Python.sh lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=130533&r1=130532&r2=130533&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Fri Apr 29 14:22:24 2011 @@ -173,7 +173,7 @@ $SWIG -c++ -shadow -python -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" -# Implement the iterator protocol for some lldb objects. +# Implement the iterator protocol and/or eq/ne operators for some lldb objects. # Append global variable to lldb Python module. # And initialize the lldb debugger subsystem. current_dir=`pwd` Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=130533&r1=130532&r2=130533&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Fri Apr 29 14:22:24 2011 @@ -2,8 +2,8 @@ # modify-lldb-python.py # # This script modifies the lldb module (which was automatically generated via -# running swig) to support iteration for certain lldb objects, adds a global -# variable 'debugger_unique_id' and initializes it to 0. +# running swig) to support iteration and/or equality operations for certain lldb +# objects, adds a global variable 'debugger_unique_id' and initializes it to 0. # # It also calls SBDebugger.Initialize() to initialize the lldb debugger # subsystem. From gclayton at apple.com Fri Apr 29 17:50:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 29 Apr 2011 22:50:32 -0000 Subject: [Lldb-commits] [lldb] r130556 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Core/EmulateInstruction.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Message-ID: <20110429225032.4BF622A6C135@llvm.org> Author: gclayton Date: Fri Apr 29 17:50:31 2011 New Revision: 130556 URL: http://llvm.org/viewvc/llvm-project?rev=130556&view=rev Log: Added the start of the CFI row production using the emulate instruction classes. Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=130556&r1=130555&r2=130556&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Fri Apr 29 17:50:31 2011 @@ -467,6 +467,12 @@ return m_opcode; } + lldb::addr_t + GetAddress () const + { + return m_addr; + } + const ArchSpec & GetArchitecture () const { @@ -571,7 +577,7 @@ WriteMemory m_write_mem_callback; ReadRegister m_read_reg_callback; WriteRegister m_write_reg_callback; - lldb::addr_t m_opcode_pc; + lldb::addr_t m_addr; Opcode m_opcode; Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=130556&r1=130555&r2=130556&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Fri Apr 29 17:50:31 2011 @@ -58,7 +58,7 @@ m_write_mem_callback (&WriteMemoryDefault), m_read_reg_callback (&ReadRegisterDefault), m_write_reg_callback (&WriteRegisterDefault), - m_opcode_pc (LLDB_INVALID_ADDRESS) + m_addr (LLDB_INVALID_ADDRESS) { ::memset (&m_opcode, 0, sizeof (m_opcode)); } @@ -536,13 +536,13 @@ EmulateInstruction::SetInstruction (const Opcode &opcode, const Address &inst_addr, Target *target) { m_opcode = opcode; - m_opcode_pc = LLDB_INVALID_ADDRESS; + m_addr = LLDB_INVALID_ADDRESS; if (inst_addr.IsValid()) { if (target) - m_opcode_pc = inst_addr.GetLoadAddress (target); - if (m_opcode_pc == LLDB_INVALID_ADDRESS) - m_opcode_pc = inst_addr.GetFileAddress (); + m_addr = inst_addr.GetLoadAddress (target); + if (m_addr == LLDB_INVALID_ADDRESS) + m_addr = inst_addr.GetFileAddress (); } return true; } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=130556&r1=130555&r2=130556&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Fri Apr 29 17:50:31 2011 @@ -12729,7 +12729,7 @@ if (!success) { m_opcode_mode = eModeInvalid; - m_opcode_pc = LLDB_INVALID_ADDRESS; + m_addr = LLDB_INVALID_ADDRESS; } return success; } Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=130556&r1=130555&r2=130556&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Fri Apr 29 17:50:31 2011 @@ -18,7 +18,6 @@ #include "lldb/Core/Error.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -108,16 +107,27 @@ const InstructionList &inst_list = disasm_sp->GetInstructionList (); const size_t num_instructions = inst_list.GetSize(); - for (size_t idx=0; idx 0) { - Instruction *inst = inst_list.GetInstructionAtIndex (idx).get(); - if (inst) + Instruction *inst = inst_list.GetInstructionAtIndex (0).get(); + const addr_t base_addr = inst->GetAddress().GetFileAddress(); + + for (size_t idx=0; idxDump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw); - strm.EOL(); + inst = inst_list.GetInstructionAtIndex (idx).get(); + if (inst) + { + m_curr_row.Clear(); + inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw); + strm.EOL(); + + m_inst_emulator_ap->SetInstruction (inst->GetOpcode(), + inst->GetAddress(), + exe_ctx.target); + m_curr_row.SetOffset (inst->GetAddress().GetFileAddress() + inst->GetOpcode().GetByteSize() - base_addr); - m_inst_emulator_ap->SetInstruction (inst->GetOpcode(), inst->GetAddress(), exe_ctx.target); - m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions); + m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions); + } } } } @@ -255,7 +265,7 @@ const void *dst, size_t dst_len) { - // UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; + UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; DataExtractor data (dst, dst_len, @@ -267,6 +277,53 @@ data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0); strm.PutCString (", context = "); context.Dump(stdout, instruction); + + switch (context.type) + { + case EmulateInstruction::eContextInvalid: + case EmulateInstruction::eContextReadOpcode: + case EmulateInstruction::eContextImmediate: + case EmulateInstruction::eContextAdjustBaseRegister: + case EmulateInstruction::eContextRegisterPlusOffset: + case EmulateInstruction::eContextAdjustPC: + case EmulateInstruction::eContextRegisterStore: + case EmulateInstruction::eContextRegisterLoad: + case EmulateInstruction::eContextRelativeBranchImmediate: + case EmulateInstruction::eContextAbsoluteBranchRegister: + case EmulateInstruction::eContextSupervisorCall: + case EmulateInstruction::eContextTableBranchReadMemory: + case EmulateInstruction::eContextWriteRegisterRandomBits: + case EmulateInstruction::eContextWriteMemoryRandomBits: + case EmulateInstruction::eContextArithmetic: + case EmulateInstruction::eContextAdvancePC: + case EmulateInstruction::eContextReturnFromException: + case EmulateInstruction::eContextPopRegisterOffStack: + case EmulateInstruction::eContextAdjustStackPointer: + break; + + case EmulateInstruction::eContextPushRegisterOnStack: + switch (context.info_type) + { + case EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset: + { + UnwindPlan::Row::RegisterLocation regloc; + const uint32_t dwarf_reg_num = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[eRegisterKindDWARF]; + const addr_t reg_cfa_offset = inst_emulator->m_curr_row.GetCFAOffset() + context.info.RegisterToRegisterPlusOffset.offset; + regloc.SetIsCFAPlusOffset (reg_cfa_offset); + inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc); + } + break; + + default: + assert (!"unhandled case, add code to handle this!"); + break; + } + break; + + break; + + } + return dst_len; } @@ -300,8 +357,6 @@ inst_emulator->SetRegisterValue (reg_info, reg_value); - UnwindPlan::Row::RegisterLocation regloc; - switch (context.type) { case EmulateInstruction::eContextInvalid: @@ -321,15 +376,40 @@ case EmulateInstruction::eContextArithmetic: case EmulateInstruction::eContextAdvancePC: case EmulateInstruction::eContextReturnFromException: - break; - case EmulateInstruction::eContextPushRegisterOnStack: break; - + case EmulateInstruction::eContextPopRegisterOffStack: + { + switch (context.info_type) + { + case EmulateInstruction::eInfoTypeRegisterPlusOffset: + { + const uint32_t dwarf_reg_num = reg_info.kinds[eRegisterKindDWARF]; + UnwindPlan::Row::RegisterLocation regloc; + regloc.SetSame(); + inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc); + } + break; + + default: + assert (!"unhandled case, add code to handle this!"); + break; + } + } break; case EmulateInstruction::eContextAdjustStackPointer: + switch (context.info_type) + { + case EmulateInstruction::eInfoTypeImmediateSigned: + inst_emulator->m_curr_row.SetCFAOffset (inst_emulator->m_curr_row.GetCFAOffset() + context.info.signed_immediate); + break; + + default: + assert (!"unhandled case, add code to handle this!"); + break; + } break; } return true; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=130556&r1=130555&r2=130556&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Fri Apr 29 17:50:31 2011 @@ -12,6 +12,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/EmulateInstruction.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/UnwindAssembly.h" class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly @@ -128,6 +129,7 @@ lldb_private::AddressRange* m_range_ptr; lldb_private::Thread* m_thread_ptr; lldb_private::UnwindPlan* m_unwind_plan_ptr; + lldb_private::UnwindPlan::Row m_curr_row; typedef std::map RegisterValueMap; RegisterValueMap m_register_values; }; From gclayton at apple.com Fri Apr 29 20:09:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 30 Apr 2011 01:09:13 -0000 Subject: [Lldb-commits] [lldb] r130565 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/API/SBModule.h lldb.xcodeproj/project.pbxproj source/API/SBDebugger.cpp source/API/SBModule.cpp source/API/SBTarget.cpp source/Core/ConnectionFileDescriptor.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Process.cpp Message-ID: <20110430010913.60C132A6C135@llvm.org> Author: gclayton Date: Fri Apr 29 20:09:13 2011 New Revision: 130565 URL: http://llvm.org/viewvc/llvm-project?rev=130565&view=rev Log: Added the ability to set the Platform path for a module through the SBModule interface. Added a quick way to set the platform though the SBDebugger interface. I will actually an a SBPlatform support soon, but for now this will do. ConnectionFileDescriptor can be passed a url formatted as: "fd://" where is a file descriptor in the current process. This is handy if you have services, deamons, or other tools that can spawn processes and give you a file handle. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Apr 29 20:09:13 2011 @@ -116,6 +116,11 @@ lldb::SBSourceManager & GetSourceManager (); + + // REMOVE: just for a quick fix, need to expose platforms through + // SBPlatform from this class. + lldb::SBError + SetCurrentPlatform (const char *platform_name); // FIXME: Once we get the set show stuff in place, the driver won't need // an interface to the Set/Get UseExternalEditor. Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Fri Apr 29 20:09:13 2011 @@ -36,6 +36,12 @@ lldb::SBFileSpec GetFileSpec () const; + lldb::SBFileSpec + GetPlatformFileSpec () const; + + bool + SetPlatformFileSpec (const lldb::SBFileSpec &platform_file); + const uint8_t * GetUUIDBytes () const; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Apr 29 20:09:13 2011 @@ -385,6 +385,8 @@ 26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; + 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A14133BEC76005B64B7 /* lldb-public.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */; }; 26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */; }; 26DC6A171337FE8000FF7998 /* liblldb-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; }; @@ -2639,6 +2641,8 @@ 2617447A11685869005ADD65 /* SBType.h in Headers */, 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */, 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, + 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */, + 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Apr 29 20:09:13 2011 @@ -15,6 +15,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBInputReader.h" @@ -811,3 +812,22 @@ return m_opaque_sp->GetID(); return LLDB_INVALID_UID; } + + +SBError +SBDebugger::SetCurrentPlatform (const char *platform_name) +{ + SBError sb_error; + if (m_opaque_sp) + { + PlatformSP platform_sp (Platform::Create (platform_name, sb_error.ref())); + + if (platform_sp) + { + bool make_selected = true; + m_opaque_sp->GetPlatformList().Append (platform_sp, make_selected); + } + } + return sb_error; +} + Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Fri Apr 29 20:09:13 2011 @@ -71,6 +71,52 @@ return file_spec; } +lldb::SBFileSpec +SBModule::GetPlatformFileSpec () const +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBFileSpec file_spec; + if (m_opaque_sp) + file_spec.SetFileSpec(m_opaque_sp->GetPlatformFileSpec()); + + if (log) + { + log->Printf ("SBModule(%p)::GetPlatformFileSpec () => SBFileSpec(%p)", + m_opaque_sp.get(), file_spec.get()); + } + + return file_spec; + +} + +bool +SBModule::SetPlatformFileSpec (const lldb::SBFileSpec &platform_file) +{ + bool result = false; + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + if (m_opaque_sp) + { + m_opaque_sp->SetPlatformFileSpec(*platform_file); + result = true; + } + + if (log) + { + log->Printf ("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s%s%s)) => %i", + m_opaque_sp.get(), + platform_file.get(), + platform_file->GetDirectory().GetCString(), + platform_file->GetDirectory() ? "/" : "", + platform_file->GetFilename().GetCString(), + result); + } + return result; +} + + + const uint8_t * SBModule::GetUUIDBytes () const { Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Apr 29 20:09:13 2011 @@ -183,126 +183,74 @@ if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR")) launch_flags |= eLaunchFlagDisableASLR; - static const char *g_launch_tty = NULL; - static bool g_got_launch_tty = false; - if (!g_got_launch_tty) - { - // Get the LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY only once - g_got_launch_tty = true; - g_launch_tty = ::getenv ("LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY"); - if (g_launch_tty) + StateType state = eStateInvalid; + sb_process.SetProcess (m_opaque_sp->GetProcessSP()); + if (sb_process.IsValid()) + { + state = sb_process->GetState(); + + if (sb_process->IsAlive() && state != eStateConnected) + { + if (state == eStateAttaching) + error.SetErrorString ("process attach is in progress"); + else + error.SetErrorString ("a process is already being debugged"); + sb_process.Clear(); + return sb_process; + } + } + + if (state == eStateConnected) + { + // If we are already connected, then we have already specified the + // listener, so if a valid listener is supplied, we need to error out + // to let the client know. + if (listener.IsValid()) { - // LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY is a path to a terminal to reuse - // if the first character is '/', else it is a boolean value. - if (g_launch_tty[0] != '/') - { - if (Args::StringToBoolean(g_launch_tty, false, NULL)) - g_launch_tty = ""; - else - g_launch_tty = NULL; - } + error.SetErrorString ("process is connected and already has a listener, pass empty listener"); + sb_process.Clear(); + return sb_process; } } - -// if ((launch_flags & eLaunchFlagLaunchInTTY) || g_launch_tty) -// { -// ArchSpec arch (m_opaque_sp->GetArchitecture ()); -// -// Module *exe_module = m_opaque_sp->GetExecutableModule().get(); -// if (exe_module) -// { -// char exec_file_path[PATH_MAX]; -// exe_module->GetFileSpec().GetPath(exec_file_path, sizeof(exec_file_path)); -// if (exe_module->GetFileSpec().Exists()) -// { -// // Make a new argument vector -// std::vector exec_path_plus_argv; -// // Append the resolved executable path -// exec_path_plus_argv.push_back (exec_file_path); -// -// // Push all args if there are any -// if (argv) -// { -// for (int i = 0; argv[i]; ++i) -// exec_path_plus_argv.push_back(argv[i]); -// } -// -// // Push a NULL to terminate the args. -// exec_path_plus_argv.push_back(NULL); -// -// -// const char *tty_name = NULL; -// if (g_launch_tty && g_launch_tty[0] == '/') -// tty_name = g_launch_tty; -// -// lldb::pid_t pid = Host::LaunchInNewTerminal (tty_name, -// &exec_path_plus_argv[0], -// envp, -// working_directory, -// &arch, -// true, -// launch_flags & eLaunchFlagDisableASLR); -// -// if (pid != LLDB_INVALID_PROCESS_ID) -// { -// sb_process = AttachToProcessWithID(listener, pid, error); -// } -// else -// { -// error.SetErrorStringWithFormat("failed to launch process in terminal"); -// } -// } -// else -// { -// error.SetErrorStringWithFormat("executable doesn't exist: \"%s\"", exec_file_path); -// } -// } -// else -// { -// error.SetErrorStringWithFormat("invalid executable"); -// } -// } -// else + else { if (listener.IsValid()) sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); else sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + } - if (sb_process.IsValid()) - { + if (sb_process.IsValid()) + { + if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) + launch_flags |= eLaunchFlagDisableSTDIO; - if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) - launch_flags |= eLaunchFlagDisableSTDIO; + error.SetError (sb_process->Launch (argv, envp, launch_flags, stdin_path, stdout_path, stderr_path, working_directory)); + if (error.Success()) + { + // We we are stopping at the entry point, we can return now! + if (stop_at_entry) + return sb_process; - - error.SetError (sb_process->Launch (argv, envp, launch_flags, stdin_path, stdout_path, stderr_path, working_directory)); - if (error.Success()) + // Make sure we are stopped at the entry + StateType state = sb_process->WaitForProcessToStop (NULL); + if (state == eStateStopped) { - // We we are stopping at the entry point, we can return now! - if (stop_at_entry) - return sb_process; - - // Make sure we are stopped at the entry - StateType state = sb_process->WaitForProcessToStop (NULL); - if (state == eStateStopped) + // resume the process to skip the entry point + error.SetError (sb_process->Resume()); + if (error.Success()) { - // resume the process to skip the entry point - error.SetError (sb_process->Resume()); - if (error.Success()) - { - // If we are doing synchronous mode, then wait for the - // process to stop yet again! - if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) - sb_process->WaitForProcessToStop (NULL); - } + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + sb_process->WaitForProcessToStop (NULL); } } } - else - { - error.SetErrorString ("unable to create lldb_private::Process"); - } + } + else + { + error.SetErrorString ("unable to create lldb_private::Process"); } } else Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Fri Apr 29 20:09:13 2011 @@ -97,6 +97,46 @@ { return SocketConnect (s + strlen("connect://"), error_ptr); } + else if (strstr(s, "fd://")) + { + // Just passing a native file descriptor within this current process + // that is already opened (possibly from a service or other source). + s += strlen ("fd://"); + bool success = false; + m_fd = Args::StringToSInt32 (s, -1, 0, &success); + if (success) + { + // We have what looks to be a valid file descriptor, but we + // should make it is. We currently are doing this by trying to + // get the flags from the file descriptor and making sure it + // isn't a bad fd. We also need to enable non blocking mode for + // the fd if it already isn't. + errno = 0; + int flags = ::fcntl (m_fd, F_GETFL, 0); + if (flags == -1 || errno == EBADF) + { + if (error_ptr) + error_ptr->SetErrorStringWithFormat ("stale file descriptor: %s", s); + m_fd = -1; + return eConnectionStatusError; + } + else + { + if ((flags & O_NONBLOCK) == 0) + { + flags |= O_NONBLOCK; + ::fcntl (m_fd, F_SETFL, flags); + } + m_should_close_fd = true; + return eConnectionStatusSuccess; + } + } + + if (error_ptr) + error_ptr->SetErrorStringWithFormat ("invalid file descriptor: \"fd://%s\"", s); + m_fd = -1; + return eConnectionStatusError; + } else if (strstr(s, "file://")) { // file:///PATH Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Apr 29 20:09:13 2011 @@ -352,14 +352,7 @@ if (error.Fail()) return error; - if (strncmp (remote_url, "connect://", strlen ("connect://")) == 0) - { - error = ConnectToDebugserver (remote_url); - } - else - { - error.SetErrorStringWithFormat ("unsupported remote url: %s", remote_url); - } + error = ConnectToDebugserver (remote_url); if (error.Fail()) return error; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=130565&r1=130564&r2=130565&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Apr 29 20:09:13 2011 @@ -2065,8 +2065,10 @@ Module *exe_module = m_target.GetExecutableModule().get(); if (exe_module) { - char exec_file_path[PATH_MAX]; - exe_module->GetFileSpec().GetPath(exec_file_path, sizeof(exec_file_path)); + char local_exec_file_path[PATH_MAX]; + char platform_exec_file_path[PATH_MAX]; + exe_module->GetFileSpec().GetPath(local_exec_file_path, sizeof(local_exec_file_path)); + exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path, sizeof(platform_exec_file_path)); if (exe_module->GetFileSpec().Exists()) { if (PrivateStateThreadIsValid ()) @@ -2089,7 +2091,7 @@ // Make a new argument vector std::vector exec_path_plus_argv; // Append the resolved executable path - exec_path_plus_argv.push_back (exec_file_path); + exec_path_plus_argv.push_back (platform_exec_file_path); // Push all args if there are any if (argv) @@ -2156,7 +2158,7 @@ } else { - error.SetErrorStringWithFormat("File doesn't exist: '%s'.\n", exec_file_path); + error.SetErrorStringWithFormat("File doesn't exist: '%s'.\n", local_exec_file_path); } } return error;