[Lldb-commits] [lldb] r157156 - in /lldb/branches/apple/python-GIL: ./ examples/summaries/cocoa/ include/lldb/Target/ lldb.xcodeproj/ resources/ scripts/ source/API/ source/Host/common/ source/Host/macosx/launcherXPCService/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/SymbolFile/DWARF/ source/Target/ test/functionalities/alias/ test/functionalities/watchpoint/multiple_threads/ test/settings/
Filipe Cabecinhas
me at filcab.net
Sun May 20 05:08:42 PDT 2012
Author: filcab
Date: Sun May 20 07:08:41 2012
New Revision: 157156
URL: http://llvm.org/viewvc/llvm-project?rev=157156&view=rev
Log:
Merge changes from ToT trunk.
Added:
lldb/branches/apple/python-GIL/scripts/llvm.amalgamated.diff
- copied unchanged from r157110, lldb/trunk/scripts/llvm.amalgamated.diff
Removed:
lldb/branches/apple/python-GIL/scripts/llvm.fix-target-amalgamated.diff
lldb/branches/apple/python-GIL/scripts/llvm.full-i386-relocations.diff
lldb/branches/apple/python-GIL/scripts/llvm.info-leak.diff
lldb/branches/apple/python-GIL/scripts/llvm.template-keyword-fixes.diff
Modified:
lldb/branches/apple/python-GIL/ (props changed)
lldb/branches/apple/python-GIL/examples/summaries/cocoa/metrics.py
lldb/branches/apple/python-GIL/examples/summaries/cocoa/objc_runtime.py
lldb/branches/apple/python-GIL/include/lldb/Target/Process.h
lldb/branches/apple/python-GIL/include/lldb/Target/Target.h
lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj
lldb/branches/apple/python-GIL/llvm.zip
lldb/branches/apple/python-GIL/resources/LLDB-Info.plist
lldb/branches/apple/python-GIL/source/API/SBTarget.cpp
lldb/branches/apple/python-GIL/source/Host/common/Host.cpp
lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherRootXPCService-Info.plist
lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherXPCService-Info.plist
lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/branches/apple/python-GIL/source/Target/Process.cpp
lldb/branches/apple/python-GIL/source/Target/Target.cpp
lldb/branches/apple/python-GIL/test/functionalities/alias/TestAliases.py
lldb/branches/apple/python-GIL/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py
lldb/branches/apple/python-GIL/test/settings/TestSettings.py
Propchange: lldb/branches/apple/python-GIL/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 20 07:08:41 2012
@@ -1 +1 @@
-/lldb/trunk:156467-157042
+/lldb/trunk:156467-157110
Modified: lldb/branches/apple/python-GIL/examples/summaries/cocoa/metrics.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/examples/summaries/cocoa/metrics.py?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/examples/summaries/cocoa/metrics.py (original)
+++ lldb/branches/apple/python-GIL/examples/summaries/cocoa/metrics.py Sun May 20 07:08:41 2012
@@ -6,6 +6,27 @@
License. See LICENSE.TXT for details.
"""
import lldb
+import time, datetime
+import inspect
+
+class TimeMetrics:
+ @staticmethod
+ def generate(label=None):
+ return TimeMetrics(label)
+
+ def __init__(self,lbl=None):
+ self.label = "" if lbl is None else lbl
+ pass
+
+ def __enter__(self):
+ caller = inspect.stack()[1]
+ self.function = str(caller)
+ self.enter_time = time.clock()
+
+ def __exit__(self, a,b,c):
+ self.exit_time = time.clock()
+ print "It took " + str(self.exit_time - self.enter_time) + " time units to run through " + self.function + self.label
+ return False
class Counter:
def __init__(self):
Modified: lldb/branches/apple/python-GIL/examples/summaries/cocoa/objc_runtime.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/examples/summaries/cocoa/objc_runtime.py?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/examples/summaries/cocoa/objc_runtime.py (original)
+++ lldb/branches/apple/python-GIL/examples/summaries/cocoa/objc_runtime.py Sun May 20 07:08:41 2012
@@ -174,7 +174,8 @@
logger >> "Marking as invalid - rwt is invald"
self.valid = False
if self.valid:
- self.rot = self.valobj.CreateValueFromAddress("rot",self.roPointer,self.sys_params.types_cache.addr_ptr_type).AddressOf()
+ self.rot = self.valobj.CreateValueFromData("rot",lldb.SBData.CreateDataFromUInt64Array(self.sys_params.endianness, self.sys_params.pointer_size, [self.roPointer]),self.sys_params.types_cache.addr_ptr_type)
+# self.rot = self.valobj.CreateValueFromAddress("rot",self.roPointer,self.sys_params.types_cache.addr_ptr_type).AddressOf()
self.data = RoT_Data(self.rot,self.sys_params)
# perform sanity checks on the contents of this class_rw_t
@@ -207,7 +208,8 @@
logger >> "Marking as invalid - isa is invalid or None"
self.valid = False
if self.valid:
- self.rwt = self.valobj.CreateValueFromAddress("rwt",self.dataPointer,self.sys_params.types_cache.addr_ptr_type).AddressOf()
+ self.rwt = self.valobj.CreateValueFromData("rwt",lldb.SBData.CreateDataFromUInt64Array(self.sys_params.endianness, self.sys_params.pointer_size, [self.dataPointer]),self.sys_params.types_cache.addr_ptr_type)
+# self.rwt = self.valobj.CreateValueFromAddress("rwt",self.dataPointer,self.sys_params.types_cache.addr_ptr_type).AddressOf()
self.data = RwT_Data(self.rwt,self.sys_params)
# perform sanity checks on the contents of this class_t
@@ -609,7 +611,8 @@
process = valobj.GetTarget().GetProcess()
self.pointer_size = process.GetAddressByteSize()
self.is_64_bit = (self.pointer_size == 8)
- self.is_little = (process.GetByteOrder() == lldb.eByteOrderLittle)
+ self.endianness = process.GetByteOrder()
+ self.is_little = (self.endianness == lldb.eByteOrderLittle)
self.cfruntime_size = 16 if self.is_64_bit else 8
# a simple helper function that makes it more explicit that one is calculating
Modified: lldb/branches/apple/python-GIL/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/Process.h?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/Process.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/Process.h Sun May 20 07:08:41 2012
@@ -2510,6 +2510,11 @@
Error &error);
size_t
+ ReadCStringFromMemory (lldb::addr_t vm_addr,
+ std::string &out_str,
+ Error &error);
+
+ size_t
ReadMemoryFromInferior (lldb::addr_t vm_addr,
void *buf,
size_t size,
Modified: lldb/branches/apple/python-GIL/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/Target.h?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/Target.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/Target.h Sun May 20 07:08:41 2012
@@ -414,6 +414,12 @@
const lldb::ProcessSP &
GetProcessSP () const;
+ bool
+ IsValid()
+ {
+ return m_valid;
+ }
+
void
Destroy();
@@ -1156,6 +1162,7 @@
// we can correctly tear down everything that we need to, so the only
// class that knows about the process lifespan is this target class.
lldb::ProcessSP m_process_sp;
+ bool m_valid;
lldb::SearchFilterSP m_search_filter_sp;
PathMappingList m_image_search_paths;
std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap;
Modified: lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj Sun May 20 07:08:41 2012
@@ -4173,9 +4173,9 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_LINK_OBJC_RUNTIME = NO;
CLANG_OBJC_RUNTIME = NO;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 149;
+ DYLIB_CURRENT_VERSION = 150;
EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -4235,10 +4235,10 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_LINK_OBJC_RUNTIME = NO;
CLANG_OBJC_RUNTIME = NO;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
DEAD_CODE_STRIPPING = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 149;
+ DYLIB_CURRENT_VERSION = 150;
EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -4296,7 +4296,7 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
DEBUGGING_SYMBOLS = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@@ -4322,7 +4322,7 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -4339,7 +4339,7 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -4353,8 +4353,8 @@
2689FFD513353D7A00698AC0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CURRENT_PROJECT_VERSION = 149;
- DYLIB_CURRENT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
+ DYLIB_CURRENT_VERSION = 150;
EXECUTABLE_EXTENSION = a;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -4382,8 +4382,8 @@
2689FFD613353D7A00698AC0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CURRENT_PROJECT_VERSION = 149;
- DYLIB_CURRENT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
+ DYLIB_CURRENT_VERSION = 150;
EXECUTABLE_EXTENSION = a;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -4411,8 +4411,8 @@
2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CURRENT_PROJECT_VERSION = 149;
- DYLIB_CURRENT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
+ DYLIB_CURRENT_VERSION = 150;
EXECUTABLE_EXTENSION = a;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -4498,7 +4498,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
@@ -4538,10 +4538,10 @@
CLANG_LINK_OBJC_RUNTIME = NO;
CLANG_OBJC_RUNTIME = NO;
COPY_PHASE_STRIP = YES;
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
DEAD_CODE_STRIPPING = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 149;
+ DYLIB_CURRENT_VERSION = 150;
EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -4842,7 +4842,7 @@
26F5C26C10F3D9A5009D5894 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
@@ -4872,7 +4872,7 @@
26F5C26D10F3D9A5009D5894 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CURRENT_PROJECT_VERSION = 149;
+ CURRENT_PROJECT_VERSION = 150;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
Modified: lldb/branches/apple/python-GIL/llvm.zip
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/llvm.zip?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
Binary files - no diff available.
Modified: lldb/branches/apple/python-GIL/resources/LLDB-Info.plist
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/resources/LLDB-Info.plist?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/resources/LLDB-Info.plist (original)
+++ lldb/branches/apple/python-GIL/resources/LLDB-Info.plist Sun May 20 07:08:41 2012
@@ -17,7 +17,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>149</string>
+ <string>150</string>
<key>CFBundleName</key>
<string>${EXECUTABLE_NAME}</string>
</dict>
Removed: lldb/branches/apple/python-GIL/scripts/llvm.fix-target-amalgamated.diff
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/scripts/llvm.fix-target-amalgamated.diff?rev=157155&view=auto
==============================================================================
--- lldb/branches/apple/python-GIL/scripts/llvm.fix-target-amalgamated.diff (original)
+++ lldb/branches/apple/python-GIL/scripts/llvm.fix-target-amalgamated.diff (removed)
@@ -1,399 +0,0 @@
-Index: lib/Target/ARM/ARMJITInfo.cpp
-===================================================================
---- lib/Target/ARM/ARMJITInfo.cpp (revision 152265)
-+++ lib/Target/ARM/ARMJITInfo.cpp (working copy)
-@@ -61,7 +61,7 @@
- // concerned, so we can't just preserve the callee saved regs.
- "stmdb sp!, {r0, r1, r2, r3, lr}\n"
- #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
-- "fstmfdd sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
-+ "vstmdb sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
- #endif
- // The LR contains the address of the stub function on entry.
- // pass it as the argument to the C part of the callback
-@@ -85,7 +85,7 @@
- //
- #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
- // Restore VFP caller-saved registers.
-- "fldmfdd sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
-+ "vldmia sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
- #endif
- //
- // We need to exchange the values in slots 0 and 1 so we can
-Index: lib/Target/ARM/ARMInstrNEON.td
-===================================================================
---- lib/Target/ARM/ARMInstrNEON.td (revision 152265)
-+++ lib/Target/ARM/ARMInstrNEON.td (working copy)
-@@ -4795,12 +4795,12 @@
-
- // Vector Swap
- def VSWPd : N2VX<0b11, 0b11, 0b00, 0b10, 0b00000, 0, 0,
-- (outs DPR:$Vd, DPR:$Vd1), (ins DPR:$Vm, DPR:$Vm1),
-- NoItinerary, "vswp", "$Vd, $Vd1", "$Vm = $Vd, $Vm1 = $Vd1",
-+ (outs DPR:$Vd, DPR:$Vm), (ins DPR:$in1, DPR:$in2),
-+ NoItinerary, "vswp", "$Vd, $Vm", "$in1 = $Vd, $in2 = $Vm",
- []>;
- def VSWPq : N2VX<0b11, 0b11, 0b00, 0b10, 0b00000, 1, 0,
-- (outs QPR:$Vd, QPR:$Vd1), (ins QPR:$Vm, QPR:$Vm1),
-- NoItinerary, "vswp", "$Vd, $Vd1", "$Vm = $Vd, $Vm1 = $Vd1",
-+ (outs QPR:$Vd, QPR:$Vm), (ins QPR:$in1, QPR:$in2),
-+ NoItinerary, "vswp", "$Vd, $Vm", "$in1 = $Vd, $in2 = $Vm",
- []>;
-
- // Vector Move Operations.
-Index: lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
-===================================================================
---- lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (revision 152265)
-+++ lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (working copy)
-@@ -212,12 +212,12 @@
- } else {
- assert(Op.isExpr() && "unknown operand kind in printOperand");
- // If a symbolic branch target was added as a constant expression then print
-- // that address in hex.
-+ // that address in hex. And only print 32 unsigned bits for the address.
- const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
- int64_t Address;
- if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
- O << "0x";
-- O.write_hex(Address);
-+ O.write_hex((uint32_t)Address);
- }
- else {
- // Otherwise, just print the expression.
-Index: lib/Target/ARM/ARMInstrThumb2.td
-===================================================================
---- lib/Target/ARM/ARMInstrThumb2.td (revision 152265)
-+++ lib/Target/ARM/ARMInstrThumb2.td (working copy)
-@@ -3198,6 +3198,7 @@
- let Inst{13} = target{17};
- let Inst{21-16} = target{16-11};
- let Inst{10-0} = target{10-0};
-+ let DecoderMethod = "DecodeT2BInstruction";
- }
-
- let isNotDuplicable = 1, isIndirectBranch = 1 in {
-Index: lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
-===================================================================
---- lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (revision 152265)
-+++ lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (working copy)
-@@ -397,39 +397,65 @@
- return swapped;
- }
- case ARM::fixup_arm_thumb_bl: {
-- // The value doesn't encode the low bit (always zero) and is offset by
-- // four. The value is encoded into disjoint bit positions in the destination
-- // opcode. x = unchanged, I = immediate value bit, S = sign extension bit
-- //
-- // BL: xxxxxSIIIIIIIIII xxxxxIIIIIIIIIII
-- //
-- // Note that the halfwords are stored high first, low second; so we need
-- // to transpose the fixup value here to map properly.
-- unsigned isNeg = (int64_t(Value - 4) < 0) ? 1 : 0;
-- uint32_t Binary = 0;
-- Value = 0x3fffff & ((Value - 4) >> 1);
-- Binary = (Value & 0x7ff) << 16; // Low imm11 value.
-- Binary |= (Value & 0x1ffc00) >> 11; // High imm10 value.
-- Binary |= isNeg << 10; // Sign bit.
-- return Binary;
-+ // The value doesn't encode the low bit (always zero) and is offset by
-+ // four. The 32-bit immediate value is encoded as
-+ // imm32 = SignExtend(S:I1:I2:imm10:imm11:0)
-+ // where I1 = NOT(J1 ^ S) and I2 = NOT(J2 ^ S).
-+ // The value is encoded into disjoint bit positions in the destination
-+ // opcode. x = unchanged, I = immediate value bit, S = sign extension bit,
-+ // J = either J1 or J2 bit
-+ //
-+ // BL: xxxxxSIIIIIIIIII xxJxJIIIIIIIIIII
-+ //
-+ // Note that the halfwords are stored high first, low second; so we need
-+ // to transpose the fixup value here to map properly.
-+ uint32_t offset = (Value - 4) >> 1;
-+ uint32_t signBit = (offset & 0x800000) >> 23;
-+ uint32_t I1Bit = (offset & 0x400000) >> 22;
-+ uint32_t J1Bit = (I1Bit ^ 0x1) ^ signBit;
-+ uint32_t I2Bit = (offset & 0x200000) >> 21;
-+ uint32_t J2Bit = (I2Bit ^ 0x1) ^ signBit;
-+ uint32_t imm10Bits = (offset & 0x1FF800) >> 11;
-+ uint32_t imm11Bits = (offset & 0x000007FF);
-+
-+ uint32_t Binary = 0;
-+ uint32_t firstHalf = (((uint16_t)signBit << 10) | (uint16_t)imm10Bits);
-+ uint32_t secondHalf = (((uint16_t)J1Bit << 13) | ((uint16_t)J2Bit << 11) |
-+ (uint16_t)imm11Bits);
-+ Binary |= secondHalf << 16;
-+ Binary |= firstHalf;
-+ return Binary;
-+
- }
- case ARM::fixup_arm_thumb_blx: {
-- // The value doesn't encode the low two bits (always zero) and is offset by
-- // four (see fixup_arm_thumb_cp). The value is encoded into disjoint bit
-- // positions in the destination opcode. x = unchanged, I = immediate value
-- // bit, S = sign extension bit, 0 = zero.
-- //
-- // BLX: xxxxxSIIIIIIIIII xxxxxIIIIIIIIII0
-- //
-- // Note that the halfwords are stored high first, low second; so we need
-- // to transpose the fixup value here to map properly.
-- unsigned isNeg = (int64_t(Value-4) < 0) ? 1 : 0;
-- uint32_t Binary = 0;
-- Value = 0xfffff & ((Value - 2) >> 2);
-- Binary = (Value & 0x3ff) << 17; // Low imm10L value.
-- Binary |= (Value & 0xffc00) >> 10; // High imm10H value.
-- Binary |= isNeg << 10; // Sign bit.
-- return Binary;
-+ // The value doesn't encode the low two bits (always zero) and is offset by
-+ // four (see fixup_arm_thumb_cp). The 32-bit immediate value is encoded as
-+ // imm32 = SignExtend(S:I1:I2:imm10H:imm10L:00)
-+ // where I1 = NOT(J1 ^ S) and I2 = NOT(J2 ^ S).
-+ // The value is encoded into disjoint bit positions in the destination
-+ // opcode. x = unchanged, I = immediate value bit, S = sign extension bit,
-+ // J = either J1 or J2 bit, 0 = zero.
-+ //
-+ // BLX: xxxxxSIIIIIIIIII xxJxJIIIIIIIIII0
-+ //
-+ // Note that the halfwords are stored high first, low second; so we need
-+ // to transpose the fixup value here to map properly.
-+ uint32_t offset = (Value - 2) >> 2;
-+ uint32_t signBit = (offset & 0x400000) >> 22;
-+ uint32_t I1Bit = (offset & 0x200000) >> 21;
-+ uint32_t J1Bit = (I1Bit ^ 0x1) ^ signBit;
-+ uint32_t I2Bit = (offset & 0x100000) >> 20;
-+ uint32_t J2Bit = (I2Bit ^ 0x1) ^ signBit;
-+ uint32_t imm10HBits = (offset & 0xFFC00) >> 10;
-+ uint32_t imm10LBits = (offset & 0x3FF);
-+
-+ uint32_t Binary = 0;
-+ uint32_t firstHalf = (((uint16_t)signBit << 10) | (uint16_t)imm10HBits);
-+ uint32_t secondHalf = (((uint16_t)J1Bit << 13) | ((uint16_t)J2Bit << 11) |
-+ ((uint16_t)imm10LBits) << 1);
-+ Binary |= secondHalf << 16;
-+ Binary |= firstHalf;
-+ return Binary;
- }
- case ARM::fixup_arm_thumb_cp:
- // Offset by 4, and don't encode the low two bits. Two bytes of that
-Index: lib/Target/ARM/ARMInstrThumb.td
-===================================================================
---- lib/Target/ARM/ARMInstrThumb.td (revision 152265)
-+++ lib/Target/ARM/ARMInstrThumb.td (working copy)
-@@ -413,11 +413,11 @@
- "bl${p}\t$func",
- [(ARMtcall tglobaladdr:$func)]>,
- Requires<[IsThumb, IsNotIOS]> {
-- bits<22> func;
-- let Inst{26} = func{21};
-+ bits<24> func;
-+ let Inst{26} = func{23};
- let Inst{25-16} = func{20-11};
-- let Inst{13} = 1;
-- let Inst{11} = 1;
-+ let Inst{13} = func{22};
-+ let Inst{11} = func{21};
- let Inst{10-0} = func{10-0};
- }
-
-@@ -427,10 +427,11 @@
- "blx${p}\t$func",
- [(ARMcall tglobaladdr:$func)]>,
- Requires<[IsThumb, HasV5T, IsNotIOS]> {
-- bits<21> func;
-+ bits<24> func;
-+ let Inst{26} = func{23};
- let Inst{25-16} = func{20-11};
-- let Inst{13} = 1;
-- let Inst{11} = 1;
-+ let Inst{13} = func{22};
-+ let Inst{11} = func{21};
- let Inst{10-1} = func{10-1};
- let Inst{0} = 0; // func{0} is assumed zero
- }
-Index: lib/Target/ARM/Disassembler/ARMDisassembler.cpp
-===================================================================
---- lib/Target/ARM/Disassembler/ARMDisassembler.cpp (revision 152265)
-+++ lib/Target/ARM/Disassembler/ARMDisassembler.cpp (working copy)
-@@ -182,6 +182,8 @@
- uint64_t Address, const void *Decoder);
- static DecodeStatus DecodeAddrMode7Operand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder);
-+static DecodeStatus DecodeT2BInstruction(MCInst &Inst, unsigned Insn,
-+ uint64_t Address, const void *Decoder);
- static DecodeStatus DecodeBranchImmInstruction(llvm::MCInst &Inst,unsigned Insn,
- uint64_t Address, const void *Decoder);
- static DecodeStatus DecodeAddrMode6Operand(llvm::MCInst &Inst, unsigned Val,
-@@ -1945,6 +1947,21 @@
- }
-
- static DecodeStatus
-+DecodeT2BInstruction(MCInst &Inst, unsigned Insn,
-+ uint64_t Address, const void *Decoder) {
-+ DecodeStatus S = MCDisassembler::Success;
-+ unsigned imm = (fieldFromInstruction32(Insn, 0, 11) << 0) |
-+ (fieldFromInstruction32(Insn, 11, 1) << 18) |
-+ (fieldFromInstruction32(Insn, 13, 1) << 17) |
-+ (fieldFromInstruction32(Insn, 16, 6) << 11) |
-+ (fieldFromInstruction32(Insn, 26, 1) << 19);
-+ if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<20>(imm<<1) + 4,
-+ true, 4, Inst, Decoder))
-+ Inst.addOperand(MCOperand::CreateImm(SignExtend32<20>(imm << 1)));
-+ return S;
-+}
-+
-+static DecodeStatus
- DecodeBranchImmInstruction(llvm::MCInst &Inst, unsigned Insn,
- uint64_t Address, const void *Decoder) {
- DecodeStatus S = MCDisassembler::Success;
-@@ -2177,6 +2194,8 @@
- case ARM::VLD2b8wb_register:
- case ARM::VLD2b16wb_register:
- case ARM::VLD2b32wb_register:
-+ Inst.addOperand(MCOperand::CreateImm(0));
-+ break;
- case ARM::VLD3d8_UPD:
- case ARM::VLD3d16_UPD:
- case ARM::VLD3d32_UPD:
-@@ -2245,6 +2264,16 @@
- !Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
- return MCDisassembler::Fail;
- break;
-+ case ARM::VLD2d8wb_fixed:
-+ case ARM::VLD2d16wb_fixed:
-+ case ARM::VLD2d32wb_fixed:
-+ case ARM::VLD2b8wb_fixed:
-+ case ARM::VLD2b16wb_fixed:
-+ case ARM::VLD2b32wb_fixed:
-+ case ARM::VLD2q8wb_fixed:
-+ case ARM::VLD2q16wb_fixed:
-+ case ARM::VLD2q32wb_fixed:
-+ break;
- }
-
- return S;
-@@ -2313,6 +2342,10 @@
- case ARM::VST2b8wb_register:
- case ARM::VST2b16wb_register:
- case ARM::VST2b32wb_register:
-+ if (Rm == 0xF)
-+ return MCDisassembler::Fail;
-+ Inst.addOperand(MCOperand::CreateImm(0));
-+ break;
- case ARM::VST3d8_UPD:
- case ARM::VST3d16_UPD:
- case ARM::VST3d32_UPD:
-@@ -2354,6 +2387,23 @@
- case ARM::VST1q16wb_fixed:
- case ARM::VST1q32wb_fixed:
- case ARM::VST1q64wb_fixed:
-+ case ARM::VST1d8Twb_fixed:
-+ case ARM::VST1d16Twb_fixed:
-+ case ARM::VST1d32Twb_fixed:
-+ case ARM::VST1d64Twb_fixed:
-+ case ARM::VST1d8Qwb_fixed:
-+ case ARM::VST1d16Qwb_fixed:
-+ case ARM::VST1d32Qwb_fixed:
-+ case ARM::VST1d64Qwb_fixed:
-+ case ARM::VST2d8wb_fixed:
-+ case ARM::VST2d16wb_fixed:
-+ case ARM::VST2d32wb_fixed:
-+ case ARM::VST2q8wb_fixed:
-+ case ARM::VST2q16wb_fixed:
-+ case ARM::VST2q32wb_fixed:
-+ case ARM::VST2b8wb_fixed:
-+ case ARM::VST2b16wb_fixed:
-+ case ARM::VST2b32wb_fixed:
- break;
- }
-
-@@ -2837,19 +2887,25 @@
-
- static DecodeStatus DecodeThumbBROperand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
-- Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
-+ if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<12>(Val<<1) + 4,
-+ true, 2, Inst, Decoder))
-+ Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
- return MCDisassembler::Success;
- }
-
- static DecodeStatus DecodeT2BROperand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
-- Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
-+ if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<21>(Val) + 4,
-+ true, 4, Inst, Decoder))
-+ Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
- return MCDisassembler::Success;
- }
-
- static DecodeStatus DecodeThumbCmpBROperand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
-- Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
-+ if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<7>(Val<<1) + 4,
-+ true, 2, Inst, Decoder))
-+ Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
- return MCDisassembler::Success;
- }
-
-@@ -3162,10 +3218,25 @@
-
- static DecodeStatus DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
-+ // Val is passed in as S:J1:J2:imm10H:imm10L:â0â
-+ // Note only one trailing zero not two. Also the J1 and J2 values are from
-+ // the encoded instruction. So here change to I1 and I2 values via:
-+ // I1 = NOT(J1 EOR S);
-+ // I2 = NOT(J2 EOR S);
-+ // and build the imm32 with two trailing zeros as documented:
-+ // imm32 = SignExtend(S:I1:I2:imm10H:imm10L:â00â, 32);
-+ unsigned S = (Val >> 23) & 1;
-+ unsigned J1 = (Val >> 22) & 1;
-+ unsigned J2 = (Val >> 21) & 1;
-+ unsigned I1 = !(J1 ^ S);
-+ unsigned I2 = !(J2 ^ S);
-+ unsigned tmp = (Val & ~0x600000) | (I1 << 22) | (I2 << 21);
-+ int imm32 = SignExtend32<25>(tmp << 1);
-+
- if (!tryAddingSymbolicOperand(Address,
-- (Address & ~2u) + SignExtend32<22>(Val << 1) + 4,
-+ (Address & ~2u) + imm32 + 4,
- true, 4, Inst, Decoder))
-- Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
-+ Inst.addOperand(MCOperand::CreateImm(imm32));
- return MCDisassembler::Success;
- }
-
-@@ -3271,15 +3342,32 @@
- static DecodeStatus
- DecodeThumbBCCTargetOperand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder){
-- Inst.addOperand(MCOperand::CreateImm(Val << 1));
-+ if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<8>(Val<<1) + 4,
-+ true, 2, Inst, Decoder))
-+ Inst.addOperand(MCOperand::CreateImm(SignExtend32<8>(Val << 1)));
- return MCDisassembler::Success;
- }
-
- static DecodeStatus DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder){
-- if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<22>(Val<<1) + 4,
-+ // Val is passed in as S:J1:J2:imm10:imm11
-+ // Note no trailing zero after imm11. Also the J1 and J2 values are from
-+ // the encoded instruction. So here change to I1 and I2 values via:
-+ // I1 = NOT(J1 EOR S);
-+ // I2 = NOT(J2 EOR S);
-+ // and build the imm32 with one trailing zero as documented:
-+ // imm32 = SignExtend(S:I1:I2:imm10:imm11:â0â, 32);
-+ unsigned S = (Val >> 23) & 1;
-+ unsigned J1 = (Val >> 22) & 1;
-+ unsigned J2 = (Val >> 21) & 1;
-+ unsigned I1 = !(J1 ^ S);
-+ unsigned I2 = !(J2 ^ S);
-+ unsigned tmp = (Val & ~0x600000) | (I1 << 22) | (I2 << 21);
-+ int imm32 = SignExtend32<25>(tmp << 1);
-+
-+ if (!tryAddingSymbolicOperand(Address, Address + imm32 + 4,
- true, 4, Inst, Decoder))
-- Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
-+ Inst.addOperand(MCOperand::CreateImm(imm32));
- return MCDisassembler::Success;
- }
-
Removed: lldb/branches/apple/python-GIL/scripts/llvm.full-i386-relocations.diff
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/scripts/llvm.full-i386-relocations.diff?rev=157155&view=auto
==============================================================================
--- lldb/branches/apple/python-GIL/scripts/llvm.full-i386-relocations.diff (original)
+++ lldb/branches/apple/python-GIL/scripts/llvm.full-i386-relocations.diff (removed)
@@ -1,841 +0,0 @@
-Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
-===================================================================
---- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (revision 152265)
-+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (working copy)
-@@ -24,7 +24,8 @@
- bool RuntimeDyldMachO::
- resolveRelocation(uint8_t *LocalAddress,
- uint64_t FinalAddress,
-- uint64_t Value,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
- bool isPCRel,
- unsigned Type,
- unsigned Size,
-@@ -32,10 +33,20 @@
- // This just dispatches to the proper target specific routine.
- switch (CPUType) {
- default: llvm_unreachable("Unsupported CPU type!");
-+ case mach::CTM_i386:
-+ return resolveI386Relocation(LocalAddress,
-+ FinalAddress,
-+ FinalSource1,
-+ FinalSource2,
-+ isPCRel,
-+ Type,
-+ Size,
-+ Addend);
- case mach::CTM_x86_64:
- return resolveX86_64Relocation(LocalAddress,
- FinalAddress,
-- (uintptr_t)Value,
-+ FinalSource1,
-+ FinalSource2,
- isPCRel,
- Type,
- Size,
-@@ -43,7 +54,8 @@
- case mach::CTM_ARM:
- return resolveARMRelocation(LocalAddress,
- FinalAddress,
-- (uintptr_t)Value,
-+ FinalSource1,
-+ FinalSource2,
- isPCRel,
- Type,
- Size,
-@@ -52,19 +64,52 @@
- }
-
- bool RuntimeDyldMachO::
-+resolveI386Relocation(uint8_t *LocalAddress,
-+ uint64_t FinalAddress,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
-+ bool isPCRel,
-+ unsigned Type,
-+ unsigned Size,
-+ int64_t Addend) {
-+ int64_t ValueToWrite = Addend;
-+
-+ switch (Type) {
-+ default:
-+ llvm_unreachable("Invalid relocation type!");
-+ case macho::RIT_Vanilla:
-+ ValueToWrite += FinalSource1;
-+ break;
-+ case macho::RIT_Difference:
-+ case macho::RIT_Generic_LocalDifference:
-+ case macho::RIT_Generic_PreboundLazyPointer:
-+ ValueToWrite += FinalSource1;
-+ ValueToWrite -= FinalSource2;
-+ break;
-+ }
-+
-+ if (isPCRel)
-+ ValueToWrite -= FinalAddress + 4; // see resolveX86_64Relocation
-+
-+ uint8_t *p = LocalAddress;
-+ for (unsigned i = 0; i < Size; ++i) {
-+ *p++ = (uint8_t)(ValueToWrite & 0xff);
-+ ValueToWrite >>= 8;
-+ }
-+
-+ return false;
-+}
-+
-+bool RuntimeDyldMachO::
- resolveX86_64Relocation(uint8_t *LocalAddress,
- uint64_t FinalAddress,
-- uint64_t Value,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
- bool isPCRel,
- unsigned Type,
- unsigned Size,
- int64_t Addend) {
-- // If the relocation is PC-relative, the value to be encoded is the
-- // pointer difference.
-- if (isPCRel)
-- // FIXME: It seems this value needs to be adjusted by 4 for an effective PC
-- // address. Is that expected? Only for branches, perhaps?
-- Value -= FinalAddress + 4;
-+ int64_t ValueToWrite = Addend;
-
- switch(Type) {
- default:
-@@ -74,41 +119,53 @@
- case macho::RIT_X86_64_Signed4:
- case macho::RIT_X86_64_Signed:
- case macho::RIT_X86_64_Unsigned:
-- case macho::RIT_X86_64_Branch: {
-- Value += Addend;
-- // Mask in the target value a byte at a time (we don't have an alignment
-- // guarantee for the target address, so this is safest).
-- uint8_t *p = (uint8_t*)LocalAddress;
-- for (unsigned i = 0; i < Size; ++i) {
-- *p++ = (uint8_t)Value;
-- Value >>= 8;
-- }
-- return false;
-- }
-+ case macho::RIT_X86_64_Branch:
-+ ValueToWrite += FinalSource1;
-+ break;
- case macho::RIT_X86_64_GOTLoad:
- case macho::RIT_X86_64_GOT:
- case macho::RIT_X86_64_Subtractor:
- case macho::RIT_X86_64_TLV:
- return Error("Relocation type not implemented yet!");
- }
-+
-+ // If the relocation is PC-relative, the value to be encoded is the
-+ // pointer difference.
-+ if (isPCRel)
-+ // FIXME: It seems this value needs to be adjusted by 4 for an effective PC
-+ // address. Is that expected? Only for branches, perhaps?
-+ ValueToWrite -= FinalAddress + 4;
-+
-+ // Mask in the target value a byte at a time (we don't have an alignment
-+ // guarantee for the target address, so this is safest).
-+ uint8_t *p = (uint8_t*)LocalAddress;
-+ for (unsigned i = 0; i < Size; ++i) {
-+ *p++ = (uint8_t)(ValueToWrite & 0xff);
-+ ValueToWrite >>= 8;
-+ }
-+
-+ return false;
- }
-
- bool RuntimeDyldMachO::
- resolveARMRelocation(uint8_t *LocalAddress,
- uint64_t FinalAddress,
-- uint64_t Value,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
- bool isPCRel,
- unsigned Type,
- unsigned Size,
- int64_t Addend) {
-+ int64_t ValueToWrite = Addend;
-+
- // If the relocation is PC-relative, the value to be encoded is the
- // pointer difference.
- if (isPCRel) {
-- Value -= FinalAddress;
-+ ValueToWrite -= FinalAddress;
- // ARM PCRel relocations have an effective-PC offset of two instructions
- // (four bytes in Thumb mode, 8 bytes in ARM mode).
- // FIXME: For now, assume ARM mode.
-- Value -= 8;
-+ ValueToWrite -= 8;
- }
-
- switch(Type) {
-@@ -119,8 +176,8 @@
- // guarantee for the target address, so this is safest).
- uint8_t *p = (uint8_t*)LocalAddress;
- for (unsigned i = 0; i < Size; ++i) {
-- *p++ = (uint8_t)Value;
-- Value >>= 8;
-+ *p++ = (uint8_t)(ValueToWrite & 0xff);
-+ ValueToWrite >>= 8;
- }
- break;
- }
-@@ -129,15 +186,15 @@
- // 32-bit aligned, so we can do it all at once.
- uint32_t *p = (uint32_t*)LocalAddress;
- // The low two bits of the value are not encoded.
-- Value >>= 2;
-+ ValueToWrite >>= 2;
- // Mask the value to 24 bits.
-- Value &= 0xffffff;
-+ ValueToWrite &= 0xffffff;
- // FIXME: If the destination is a Thumb function (and the instruction
- // is a non-predicated BL instruction), we need to change it to a BLX
- // instruction instead.
-
- // Insert the value into the instruction.
-- *p = (*p & ~0xffffff) | Value;
-+ *p = (*p & ~0xffffff) | ValueToWrite;
- break;
- }
- case macho::RIT_ARM_ThumbBranch22Bit:
-@@ -153,6 +210,29 @@
- return false;
- }
-
-+static bool
-+ResolveSectionAndOffset(const MachOObject *Obj,
-+ SmallVectorImpl<unsigned> &SectionMap,
-+ const MachOObject::LoadCommandInfo *SegmentLCI,
-+ InMemoryStruct<macho::SegmentLoadCommand> &SegmentLC,
-+ uint64_t Address,
-+ unsigned &SectionID,
-+ uint64_t &Offset)
-+{
-+ for (unsigned SI = 0, SE = SegmentLC->NumSections; SI < SE; ++SI) {
-+ InMemoryStruct<macho::Section> CandidateSection;
-+ Obj->ReadSection(*SegmentLCI, SI, CandidateSection);
-+ if (Address >= CandidateSection->Address &&
-+ Address < CandidateSection->Address + CandidateSection->Size) {
-+ SectionID = SectionMap[SI];
-+ Offset = Address - CandidateSection->Address;
-+ return true;
-+ }
-+ }
-+
-+ return false;
-+}
-+
- bool RuntimeDyldMachO::
- loadSegment32(const MachOObject *Obj,
- const MachOObject::LoadCommandInfo *SegmentLCI,
-@@ -210,6 +290,7 @@
-
- // Process the relocations for each section we're loading.
- Relocations.grow(Relocations.size() + SegmentLC->NumSections);
-+ RelocationSources.grow(RelocationSources.size() + SegmentLC->NumSections);
- for (unsigned SectNum = 0; SectNum != SegmentLC->NumSections; ++SectNum) {
- InMemoryStruct<macho::Section> Sect;
- Obj->ReadSection(*SegmentLCI, SectNum, Sect);
-@@ -218,51 +299,135 @@
- for (unsigned j = 0; j != Sect->NumRelocationTableEntries; ++j) {
- InMemoryStruct<macho::RelocationEntry> RE;
- Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE);
-- if (RE->Word0 & macho::RF_Scattered)
-- return Error("NOT YET IMPLEMENTED: scattered relocations.");
-- // Word0 of the relocation is the offset into the section where the
-- // relocation should be applied. We need to translate that into an
-- // offset into a function since that's our atom.
-- uint32_t Offset = RE->Word0;
-- bool isExtern = (RE->Word1 >> 27) & 1;
--
-- // FIXME: Get the relocation addend from the target address.
-- // FIXME: VERY imporant for internal relocations.
--
-- // Figure out the source symbol of the relocation. If isExtern is true,
-- // this relocation references the symbol table, otherwise it references
-- // a section in the same object, numbered from 1 through NumSections
-- // (SectionBases is [0, NumSections-1]).
-- uint32_t SourceNum = RE->Word1 & 0xffffff; // 24-bit value
-- if (!isExtern) {
-- assert(SourceNum > 0 && "Invalid relocation section number!");
-- unsigned SectionID = SectionMap[SourceNum - 1];
-+ if (RE->Word0 & macho::RF_Scattered) {
-+ // The lower 24 bits of Word0 of the scattered relocation is the offset
-+ // into the section where the relocation should be applied, i.e., the
-+ // current section.
-+ uint32_t OffsetInTarget = RE->Word0 & 0x00ffffff;
- unsigned TargetID = SectionMap[SectNum];
-- DEBUG(dbgs() << "Internal relocation at Section #"
-- << TargetID << " + " << Offset
-- << " from Section #"
-- << SectionID << " (Word1: "
-- << format("0x%x", RE->Word1) << ")\n");
--
-- // Store the relocation information. It will get resolved when
-- // the section addresses are assigned.
-- Relocations[SectionID].push_back(RelocationEntry(TargetID,
-- Offset,
-- RE->Word1,
-- 0 /*Addend*/));
-+ // Word1 of the scattered relocation is a file offset which needs to
-+ // be resolved into Section+Offset form. This gives the address of the
-+ // source.
-+ unsigned Source1ID;
-+ uint64_t Source1Offset;
-+ if (!ResolveSectionAndOffset(Obj,
-+ SectionMap,
-+ SegmentLCI,
-+ SegmentLC,
-+ RE->Word1,
-+ Source1ID,
-+ Source1Offset))
-+ return Error("couldn't find scattered relocation value in sections");
-+ // This relocation may have a paired relocation entry. If it does, set
-+ // the source/offset information for it correctly.
-+ unsigned Source2ID = SectionOffset::NoSectionID;
-+ uint64_t Source2Offset = 0;
-+ if (j + 1 < Sect->NumRelocationTableEntries) {
-+ InMemoryStruct<macho::RelocationEntry> PairRE;
-+ Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j+1, PairRE);
-+ if ((PairRE->Word0 & macho::RF_Scattered) &&
-+ ((PairRE->Word0 & 0x0f000000) >> 24) == macho::RIT_Pair) {
-+ if (!ResolveSectionAndOffset(Obj,
-+ SectionMap,
-+ SegmentLCI,
-+ SegmentLC,
-+ PairRE->Word1,
-+ Source2ID,
-+ Source2Offset))
-+ return Error("couldn't find scattered relocation value in sections");
-+ ++j;
-+ }
-+ }
-+ if (Source2ID == SectionOffset::NoSectionID)
-+ DEBUG(dbgs() << "Scattered relocation at Section #"
-+ << TargetID << " + " << OffsetInTarget
-+ << " from Section #" << Source1ID
-+ << "+" << Source1Offset
-+ << " (Word0: "
-+ << format("0x%x", RE->Word0) << ")\n");
-+ else
-+ DEBUG(dbgs() << "Scattered relocation at Section #"
-+ << TargetID << " + " << OffsetInTarget
-+ << " from Section #" << Source1ID
-+ << "+" << Source1Offset
-+ << " and Section #" << Source2ID
-+ << "+" << Source2Offset
-+ << " (Word0: "
-+ << format("0x%x", RE->Word0) << ")\n");
-+ uint32_t RelocationIndex = Relocations[TargetID].size();
-+ // FIXME: Get the relocation addend from the target address.
-+ // FIXME: VERY imporant for internal relocations.
-+ RelocationEntry TranslatedRE(OffsetInTarget,
-+ Source1ID,
-+ Source1Offset,
-+ Source2ID,
-+ Source2Offset,
-+ RE->Word1,
-+ 0 /*Addend*/);
-+ Relocations[TargetID].push_back(TranslatedRE);
-+ RelocationSources[Source1ID].push_back(RelocationSource(TargetID,
-+ RelocationIndex,
-+ 0));
-+ if (Source2ID != SectionOffset::NoSectionID)
-+ RelocationSources[Source2ID].push_back(RelocationSource(TargetID,
-+ RelocationIndex,
-+ 1));
- } else {
-- StringRef SourceName = SymbolNames[SourceNum];
--
-- // Now store the relocation information. Associate it with the source
-- // symbol. Just add it to the unresolved list and let the general
-- // path post-load resolve it if we know where the symbol is.
-- UnresolvedRelocations[SourceName].push_back(RelocationEntry(SectNum,
-- Offset,
-- RE->Word1,
-- 0 /*Addend*/));
-- DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << Offset
-- << " from '" << SourceName << "(Word1: "
-- << format("0x%x", RE->Word1) << ")\n");
-+ // Word0 of the relocation is the offset into the section where the
-+ // relocation should be applied, i.e., the current section. We need
-+ // to translate that into an offset into a function since that's our atom.
-+ uint32_t OffsetInTarget = RE->Word0;
-+ bool isExtern = (RE->Word1 >> 27) & 1;
-+
-+ // FIXME: Get the relocation addend from the target address.
-+ // FIXME: VERY imporant for internal relocations.
-+
-+ // Figure out the source symbol of the relocation. If isExtern is true,
-+ // this relocation references the symbol table, otherwise it references
-+ // a section in the same object, numbered from 1 through NumSections
-+ // (SectionBases is [0, NumSections-1]).
-+ uint32_t SourceNum_OneBased = RE->Word1 & 0xffffff; // 24-bit value
-+ if (!isExtern) {
-+ assert(SourceNum_OneBased > 0 && "Invalid relocation section number!");
-+ unsigned SourceID = SectionMap[SourceNum_OneBased - 1];
-+ unsigned TargetID = SectionMap[SectNum];
-+ DEBUG(dbgs() << "Internal relocation at Section #"
-+ << TargetID << " + " << OffsetInTarget
-+ << " from Section #"
-+ << SourceID << " (Word1: "
-+ << format("0x%x", RE->Word1) << ")\n");
-+
-+ // Store the relocation information. It will get resolved when
-+ // the section addresses are assigned.
-+ uint32_t RelocationIndex = Relocations[TargetID].size();
-+ Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+ SourceID,
-+ SectionOffset::NoSectionID,
-+ RE->Word1,
-+ 0 /*Addend*/));
-+ RelocationSources[SourceID].push_back(RelocationSource(TargetID,
-+ RelocationIndex,
-+ 0));
-+ } else {
-+ StringRef SourceName = SymbolNames[SourceNum_OneBased];
-+
-+ // Now store the relocation information. Associate it with the source
-+ // symbol. Just add it to the unresolved list and let the general
-+ // path post-load resolve it if we know where the symbol is.
-+ unsigned TargetID = SectionMap[SectNum];
-+ uint32_t RelocationIndex = Relocations[TargetID].size();
-+ Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+ SectionOffset::UnresolvedSourceID,
-+ SectionOffset::NoSectionID,
-+ RE->Word1,
-+ 0 /*Addend*/));
-+ UnresolvedRelocations[SourceName].push_back(RelocationSource(TargetID,
-+ RelocationIndex,
-+ 0));
-+ DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << OffsetInTarget
-+ << " from '" << SourceName << "' (Word1: "
-+ << format("0x%x", RE->Word1) << ")\n");
-+ }
- }
- }
- }
-@@ -332,6 +497,7 @@
-
- // Process the relocations for each section we're loading.
- Relocations.grow(Relocations.size() + Segment64LC->NumSections);
-+ RelocationSources.grow(RelocationSources.size() + Segment64LC->NumSections);
- for (unsigned SectNum = 0; SectNum != Segment64LC->NumSections; ++SectNum) {
- InMemoryStruct<macho::Section64> Sect;
- Obj->ReadSection64(*SegmentLCI, SectNum, Sect);
-@@ -341,11 +507,11 @@
- InMemoryStruct<macho::RelocationEntry> RE;
- Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE);
- if (RE->Word0 & macho::RF_Scattered)
-- return Error("NOT YET IMPLEMENTED: scattered relocations.");
-+ return Error("scattered relocations don't exist on 64-bit platforms");
- // Word0 of the relocation is the offset into the section where the
- // relocation should be applied. We need to translate that into an
- // offset into a function since that's our atom.
-- uint32_t Offset = RE->Word0;
-+ uint32_t OffsetInTarget = RE->Word0;
- bool isExtern = (RE->Word1 >> 27) & 1;
-
- // FIXME: Get the relocation addend from the target address.
-@@ -355,34 +521,45 @@
- // this relocation references the symbol table, otherwise it references
- // a section in the same object, numbered from 1 through NumSections
- // (SectionBases is [0, NumSections-1]).
-- uint32_t SourceNum = RE->Word1 & 0xffffff; // 24-bit value
-+ uint32_t SourceNum_OneBased = RE->Word1 & 0xffffff; // 24-bit value
- if (!isExtern) {
-- assert(SourceNum > 0 && "Invalid relocation section number!");
-- unsigned SectionID = SectionMap[SourceNum - 1];
-+ assert(SourceNum_OneBased > 0 && "Invalid relocation section number!");
-+ unsigned SourceID = SectionMap[SourceNum_OneBased - 1];
- unsigned TargetID = SectionMap[SectNum];
- DEBUG(dbgs() << "Internal relocation at Section #"
-- << TargetID << " + " << Offset
-+ << TargetID << " + " << OffsetInTarget
- << " from Section #"
-- << SectionID << " (Word1: "
-+ << SourceID << " (Word1: "
- << format("0x%x", RE->Word1) << ")\n");
-
- // Store the relocation information. It will get resolved when
- // the section addresses are assigned.
-- Relocations[SectionID].push_back(RelocationEntry(TargetID,
-- Offset,
-- RE->Word1,
-- 0 /*Addend*/));
-+ uint32_t RelocationIndex = Relocations[TargetID].size();
-+ Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+ SourceID,
-+ SectionOffset::NoSectionID,
-+ RE->Word1,
-+ 0 /*Addend*/));
-+ RelocationSources[SourceID].push_back(RelocationSource(TargetID,
-+ RelocationIndex,
-+ 0));
- } else {
-- StringRef SourceName = SymbolNames[SourceNum];
-+ StringRef SourceName = SymbolNames[SourceNum_OneBased];
-
- // Now store the relocation information. Associate it with the source
- // symbol. Just add it to the unresolved list and let the general
- // path post-load resolve it if we know where the symbol is.
-- UnresolvedRelocations[SourceName].push_back(RelocationEntry(SectNum,
-- Offset,
-- RE->Word1,
-- 0 /*Addend*/));
-- DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << Offset
-+ unsigned TargetID = SectionMap[SectNum];
-+ uint32_t RelocationIndex = Relocations[TargetID].size();
-+ Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+ SectionOffset::UnresolvedSourceID,
-+ SectionOffset::NoSectionID,
-+ RE->Word1,
-+ 0 /*Addend*/));
-+ UnresolvedRelocations[SourceName].push_back(RelocationSource(TargetID,
-+ RelocationIndex,
-+ 0));
-+ DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << OffsetInTarget
- << " from '" << SourceName << "(Word1: "
- << format("0x%x", RE->Word1) << ")\n");
- }
-@@ -468,18 +645,22 @@
- if (Loc == SymbolTable.end())
- return;
-
-- RelocationList &Relocs = UnresolvedRelocations[Name];
-+ RelocationSourceList &SourcesForSymbol = UnresolvedRelocations[Name];
- DEBUG(dbgs() << "Resolving symbol '" << Name << "'\n");
-- for (int i = 0, e = Relocs.size(); i != e; ++i) {
-- // Change the relocation to be section relative rather than symbol
-- // relative and move it to the resolved relocation list.
-- RelocationEntry Entry = Relocs[i];
-- Entry.Addend += Loc->second.second;
-- Relocations[Loc->second.first].push_back(Entry);
-+ for (int i = 0, e = SourcesForSymbol.size(); i != e; ++i) {
-+ // Find the relocation entry corresponding to this source and fill
-+ // in its source information with the resolved information from this
-+ // symbol.
-+ RelocationSource &Source = SourcesForSymbol[i];
-+ RelocationEntry &Entry = Relocations[Source.SectionID][Source.Index];
-+ Entry.Sources[Source.SourceIdx].Offset = Loc->second.second;
-+ Entry.Sources[Source.SourceIdx].ID = Loc->second.first;
-+ // Now create a relocation source in the pointed-to section.
-+ RelocationSources[Loc->second.first].push_back(Source);
- }
- // FIXME: Keep a worklist of the relocations we've added so that we can
- // resolve more selectively later.
-- Relocs.clear();
-+ SourcesForSymbol.clear();
- }
-
- bool RuntimeDyldMachO::loadObject(MemoryBuffer *InputBuffer) {
-@@ -575,6 +756,56 @@
- return false;
- }
-
-+bool RuntimeDyldMachO::resolveRelocationEntry(unsigned SectionID,
-+ RelocationEntry &RE)
-+{
-+ uint8_t *Target = (uint8_t*)Sections[SectionID].base() + RE.Offset;
-+ uint64_t FinalTarget = SectionLoadAddress[SectionID] + RE.Offset;
-+
-+ uint64_t FinalSource1 = 0;
-+ uint64_t FinalSource2 = 0;
-+
-+ if (RE.Sources[0].ID == SectionOffset::UnresolvedSourceID ||
-+ RE.Sources[1].ID == SectionOffset::UnresolvedSourceID)
-+ return false;
-+
-+ FinalSource1 = SectionLoadAddress[RE.Sources[0].ID] + RE.Sources[0].Offset;
-+ if (RE.Sources[1].ID != SectionOffset::NoSectionID)
-+ FinalSource2 = SectionLoadAddress[RE.Sources[1].ID] + RE.Sources[1].Offset;
-+
-+ bool isPCRel = RE.isPCRel();
-+ unsigned Type = RE.type();
-+ unsigned Size = RE.length();
-+
-+ if (RE.Sources[1].ID == SectionOffset::NoSectionID)
-+ DEBUG(dbgs() << "Resolving relocation at Section #" << SectionID
-+ << " + " << RE.Offset << " (" << format("%p", Target) << ")"
-+ << " from Section #" << RE.Sources[0].ID << "+" << RE.Sources[0].Offset
-+ << " (" << format("0x%llx", FinalSource1) << ")"
-+ << " (" << (isPCRel ? "pcrel" : "absolute")
-+ << ", type: " << Type << ", Size: " << Size << ", Addend: "
-+ << RE.Addend << ").\n");
-+ else
-+ DEBUG(dbgs() << "Resolving relocation at Section #" << SectionID
-+ << " + " << RE.Offset << " (" << format("%p", Target) << ")"
-+ << " from Section #" << RE.Sources[0].ID << "+" << RE.Sources[0].Offset
-+ << " (" << format("0x%llx", FinalSource1) << ")"
-+ << " and Section #" << RE.Sources[1].ID << "+" << RE.Sources[1].Offset
-+ << " (" << format("0x%llx", FinalSource2) << ")"
-+ << " (" << (isPCRel ? "pcrel" : "absolute")
-+ << ", type: " << Type << ", Size: " << Size << ", Addend: "
-+ << RE.Addend << ").\n");
-+
-+ return resolveRelocation(Target,
-+ FinalTarget,
-+ FinalSource1,
-+ FinalSource2,
-+ isPCRel,
-+ Type,
-+ Size,
-+ RE.Addend);
-+}
-+
- // Assign an address to a symbol name and resolve all the relocations
- // associated with it.
- void RuntimeDyldMachO::reassignSectionAddress(unsigned SectionID,
-@@ -590,30 +821,17 @@
-
- SectionLoadAddress[SectionID] = Addr;
-
-- RelocationList &Relocs = Relocations[SectionID];
-- for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
-- RelocationEntry &RE = Relocs[i];
-- uint8_t *Target = (uint8_t*)Sections[RE.SectionID].base() + RE.Offset;
-- uint64_t FinalTarget = (uint64_t)SectionLoadAddress[RE.SectionID] + RE.Offset;
-- bool isPCRel = (RE.Data >> 24) & 1;
-- unsigned Type = (RE.Data >> 28) & 0xf;
-- unsigned Size = 1 << ((RE.Data >> 25) & 3);
--
-- DEBUG(dbgs() << "Resolving relocation at Section #" << RE.SectionID
-- << " + " << RE.Offset << " (" << format("%p", Target) << ")"
-- << " from Section #" << SectionID << " (" << format("%p", Addr) << ")"
-- << "(" << (isPCRel ? "pcrel" : "absolute")
-- << ", type: " << Type << ", Size: " << Size << ", Addend: "
-- << RE.Addend << ").\n");
--
-- resolveRelocation(Target,
-- FinalTarget,
-- Addr,
-- isPCRel,
-- Type,
-- Size,
-- RE.Addend);
-+ RelocationList &RelocsForSection = Relocations[SectionID];
-+ for (unsigned i = 0, e = RelocsForSection.size(); i != e; ++i) {
-+ RelocationEntry &RE = RelocsForSection[i];
-+ resolveRelocationEntry(SectionID, RE);
- }
-+ RelocationSourceList &SourcesForSection = RelocationSources[SectionID];
-+ for (unsigned i = 0, e = SourcesForSection.size(); i != e; ++i) {
-+ RelocationSource &R = SourcesForSection[i];
-+ RelocationEntry &RE = Relocations[R.SectionID][R.Index];
-+ resolveRelocationEntry(R.SectionID, RE);
-+ }
- }
-
- bool RuntimeDyldMachO::isKnownFormat(const MemoryBuffer *InputBuffer) {
-Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
-===================================================================
---- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h (revision 152265)
-+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h (working copy)
-@@ -26,48 +26,183 @@
- namespace llvm {
- class RuntimeDyldMachO : public RuntimeDyldImpl {
-
-- // For each symbol, keep a list of relocations based on it. Anytime
-- // its address is reassigned (the JIT re-compiled the function, e.g.),
-- // the relocations get re-resolved.
-- // The symbol (or section) the relocation is sourced from is the Key
-- // in the relocation list where it's stored.
-+ // For each section, keep a list of relocatable pieces of data that
-+ // reside in it. If the section moves, or the sections whose
-+ // locations the data depends on move, re-resolve the relocations
-+ // based on that movement.
-+ //
-+ // RelocationEntry structures correspond to one or two Mach-O
-+ // relocation_info or scattered_relocation_info structures --
-+ // usually one, but two iff the original has a paired structure
-+ // following it.
-+ //
-+ // To facilitate updating a relocation when its sources move, we
-+ // also keep RelocationSource structures associated with the sections
-+ // whose location the data depends on.
-+
-+ // FIXME: Use SymbolLoc for this instead. Where should the enum live?
-+ struct SectionOffset {
-+ uint64_t Offset; // Offset of the location into its section.
-+ unsigned ID; // The section the location is contained in.
-+
-+ enum {
-+ NoSectionID = 0xffff0000,
-+ UnresolvedSourceID = 0xffffffff
-+ };
-+ };
-+
- struct RelocationEntry {
-- unsigned SectionID; // Section the relocation is contained in.
-- uint64_t Offset; // Offset into the section for the relocation.
-- uint32_t Data; // Second word of the raw macho relocation entry.
-- int64_t Addend; // Addend encoded in the instruction itself, if any,
-- // plus the offset into the source section for
-- // the symbol once the relocation is resolvable.
-+ SectionOffset Sources[2]; // The section/offset pairs this relocation
-+ // refers to.
-+ // If the original Mach-O relocation entries used
-+ // relocation_info, this data is computed from
-+ // r_symbolnum and the offsets are locked to 0.
-+ // (The only offset is determined by the addend.)
-+ // If the original Mach-O relocation entries used
-+ // scattered_relocation_info, this data, including
-+ // offsets, is computed by looking r_value up in
-+ // the section table.
-
-- RelocationEntry(unsigned id, uint64_t offset, uint32_t data, int64_t addend)
-- : SectionID(id), Offset(offset), Data(data), Addend(addend) {}
-+ uint64_t Offset; // The offset of the data to be relocated.
-+ // We don't use a SectionOffset because this
-+ // RelocationEntry is already associated with the
-+ // proper Section.
-+
-+ int64_t Addend; // Addend encoded in the instruction itself, if any,
-+ // plus the offset into the source section for
-+ // the symbol once the relocation is resolvable.
-+
-+ uint32_t Data; // If the original Mach-O relocation entry was a
-+ // relocation_info, the bitfield { r_symbolnum,
-+ // r_pcrel, r_length, r_extern, r_type }.
-+ // If the original Mach-O relocation entry was a
-+ // scattered_relocation_info, the bitfield
-+ // { r_address, r_type, r_length, r_pcrel,
-+ // r_scattered }.
-+
-+ bool Scattered; // True iff this relocation is scattered.
-+
-+ bool isPCRel()
-+ {
-+ if (Scattered)
-+ return (Data & 0x40000000) >> 30;
-+ else
-+ return (Data & 0x01000000) >> 24;
-+ }
-+
-+ uint8_t type()
-+ {
-+ if (Scattered)
-+ return (Data & 0x0f000000) >> 24;
-+ else
-+ return (Data & 0xf0000000) >> 28;
-+ }
-+
-+ // Returns the decoded version of the length field
-+ uint8_t length()
-+ {
-+ if (Scattered)
-+ return 1 << ((Data & 0x30000000) >> 28);
-+ else
-+ return 1 << ((Data & 0x0e000000) >> 25);
-+ }
-+
-+ // Used with an ordinary relocation entry, where the source_offsets are not
-+ // known yet.
-+ RelocationEntry(uint64_t offset, // See the Offset field.
-+ unsigned source_id0, // The section ID for the first source.
-+ unsigned source_id1, // The section ID for the second source.
-+ uint32_t data, // See the Data field.
-+ int64_t addend) // See the Addend field.
-+ : Offset(offset),
-+ Addend(addend),
-+ Data(data),
-+ Scattered(false) {
-+ Sources[0].ID = source_id0;
-+ Sources[0].Offset = 0;
-+ Sources[1].ID = source_id1;
-+ Sources[1].Offset = 0;
-+ }
-+
-+ // Used with a scattered relocation entry, where the source_offsets can be
-+ // derived from the value.
-+ RelocationEntry(uint64_t offset, // See the Offset field.
-+ unsigned source_id0, // The section ID for the first source.
-+ uint64_t source_off0, // The offset for the first source.
-+ unsigned source_id1, // The section ID for the second source.
-+ uint64_t source_off1, // The offset for the second source.
-+ uint32_t data, // See the Data field.
-+ int64_t addend) // See the Addend field.
-+ : Offset(offset),
-+ Addend(addend),
-+ Data(data),
-+ Scattered(true) {
-+ Sources[0].ID = source_id0;
-+ Sources[0].Offset = source_off0;
-+ Sources[1].ID = source_id1;
-+ Sources[1].Offset = source_off1;
-+ }
- };
- typedef SmallVector<RelocationEntry, 4> RelocationList;
-- // Relocations to sections already loaded. Indexed by SectionID which is the
-- // source of the address. The target where the address will be writen is
-- // SectionID/Offset in the relocation itself.
-+
-+ // For each section, keep a list of sources that are used by relocations in
-+ // other sections. Whenever a relocation gets created, create one or two
-+ // corresponding relocation sources. Whenever relocations are re-resolved
-+ // for a section, also re-resolve the relocations corresponding to that
-+ // section's relocation targets.
-+ struct RelocationSource {
-+ unsigned SectionID; // Section whose RelocationList contains the relocation.
-+ uint32_t Index : 24; // Index of the RelocatonEntry in that RelocationList.
-+ uint8_t SourceIdx : 1; // Index of this source in the RelocationEntry's Sources.
-+
-+ RelocationSource(unsigned id,
-+ uint32_t index,
-+ uint8_t source_idx)
-+ : SectionID(id),
-+ Index(index),
-+ SourceIdx(source_idx) {}
-+ };
-+ typedef SmallVector<RelocationSource, 4> RelocationSourceList;
-+
-+ // Relocations which refer to already-loaded section. Indexed by SectionID
-+ // which is the section containing the relocatable data.
- IndexedMap<RelocationList> Relocations;
-+ // Targets corresponding to Relocations.
-+ IndexedMap<RelocationSourceList> RelocationSources;
- // Relocations to symbols that are not yet resolved. Must be external
- // relocations by definition. Indexed by symbol name.
-- StringMap<RelocationList> UnresolvedRelocations;
-+ StringMap<RelocationSourceList> UnresolvedRelocations;
-
-+ bool resolveRelocationEntry(unsigned SectionID,
-+ RelocationEntry &RE);
- bool resolveRelocation(uint8_t *LocalAddress,
- uint64_t FinalAddress,
-- uint64_t Value,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
- bool isPCRel,
- unsigned Type,
- unsigned Size,
- int64_t Addend);
-+ bool resolveI386Relocation(uint8_t *LocalAddress,
-+ uint64_t FinalAddress,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
-+ bool isPCRel,
-+ unsigned Type,
-+ unsigned Size,
-+ int64_t Addend);
- bool resolveX86_64Relocation(uint8_t *LocalAddress,
- uint64_t FinalAddress,
-- uint64_t Value,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
- bool isPCRel,
- unsigned Type,
- unsigned Size,
- int64_t Addend);
- bool resolveARMRelocation(uint8_t *LocalAddress,
- uint64_t FinalAddress,
-- uint64_t Value,
-+ uint64_t FinalSource1,
-+ uint64_t FinalSource2,
- bool isPCRel,
- unsigned Type,
- unsigned Size,
Removed: lldb/branches/apple/python-GIL/scripts/llvm.info-leak.diff
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/scripts/llvm.info-leak.diff?rev=157155&view=auto
==============================================================================
--- lldb/branches/apple/python-GIL/scripts/llvm.info-leak.diff (original)
+++ lldb/branches/apple/python-GIL/scripts/llvm.info-leak.diff (removed)
@@ -1,60 +0,0 @@
-Index: lib/MC/MCDisassembler/Disassembler.cpp
-===================================================================
---- lib/MC/MCDisassembler/Disassembler.cpp (revision 152265)
-+++ lib/MC/MCDisassembler/Disassembler.cpp (working copy)
-@@ -15,7 +15,9 @@
- #include "llvm/MC/MCDisassembler.h"
- #include "llvm/MC/MCInst.h"
- #include "llvm/MC/MCInstPrinter.h"
-+#include "llvm/MC/MCInstrInfo.h"
- #include "llvm/MC/MCRegisterInfo.h"
-+#include "llvm/MC/MCSubtargetInfo.h"
- #include "llvm/Support/MemoryObject.h"
- #include "llvm/Support/TargetRegistry.h"
- #include "llvm/Support/TargetSelect.h"
-@@ -86,7 +88,7 @@
- LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,
- GetOpInfo, SymbolLookUp,
- TheTarget, MAI, MRI,
-- Ctx, DisAsm, IP);
-+ STI, Ctx, DisAsm, IP);
- assert(DC && "Allocation failure!");
-
- return DC;
-Index: lib/MC/MCDisassembler/Disassembler.h
-===================================================================
---- lib/MC/MCDisassembler/Disassembler.h (revision 152265)
-+++ lib/MC/MCDisassembler/Disassembler.h (working copy)
-@@ -29,6 +29,7 @@
- class MCDisassembler;
- class MCInstPrinter;
- class MCRegisterInfo;
-+class MCSubtargetInfo;
- class Target;
-
- //
-@@ -61,6 +62,8 @@
- llvm::OwningPtr<const llvm::MCAsmInfo> MAI;
- // The register information for the target architecture.
- llvm::OwningPtr<const llvm::MCRegisterInfo> MRI;
-+ // The subtarget information for the target architecture.
-+ llvm::OwningPtr<const llvm::MCSubtargetInfo> MSI;
- // The assembly context for creating symbols and MCExprs.
- llvm::OwningPtr<const llvm::MCContext> Ctx;
- // The disassembler for the target architecture.
-@@ -78,6 +81,7 @@
- LLVMSymbolLookupCallback symbolLookUp,
- const Target *theTarget, const MCAsmInfo *mAI,
- const MCRegisterInfo *mRI,
-+ const MCSubtargetInfo *mSI,
- llvm::MCContext *ctx, const MCDisassembler *disAsm,
- MCInstPrinter *iP) : TripleName(tripleName),
- DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo),
-@@ -85,6 +89,7 @@
- CommentStream(CommentsToEmit) {
- MAI.reset(mAI);
- MRI.reset(mRI);
-+ MSI.reset(mSI);
- Ctx.reset(ctx);
- DisAsm.reset(disAsm);
- IP.reset(iP);
Removed: lldb/branches/apple/python-GIL/scripts/llvm.template-keyword-fixes.diff
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/scripts/llvm.template-keyword-fixes.diff?rev=157155&view=auto
==============================================================================
--- lldb/branches/apple/python-GIL/scripts/llvm.template-keyword-fixes.diff (original)
+++ lldb/branches/apple/python-GIL/scripts/llvm.template-keyword-fixes.diff (removed)
@@ -1,35 +0,0 @@
-Index: include/llvm/ADT/PointerUnion.h
-===================================================================
---- include/llvm/ADT/PointerUnion.h (revision 152265)
-+++ include/llvm/ADT/PointerUnion.h (working copy)
-@@ -266,7 +266,7 @@
- ::llvm::PointerUnionTypeSelector<PT1, T, IsInnerUnion,
- ::llvm::PointerUnionTypeSelector<PT2, T, IsInnerUnion, IsPT3 >
- >::Return Ty;
-- return Ty(Val).is<T>();
-+ return Ty(Val).template is<T>();
- }
-
- /// get<T>() - Return the value of the specified pointer type. If the
-@@ -279,7 +279,7 @@
- ::llvm::PointerUnionTypeSelector<PT1, T, IsInnerUnion,
- ::llvm::PointerUnionTypeSelector<PT2, T, IsInnerUnion, IsPT3 >
- >::Return Ty;
-- return Ty(Val).get<T>();
-+ return Ty(Val).template get<T>();
- }
-
- /// dyn_cast<T>() - If the current value is of the specified pointer type,
-Index: include/llvm/ADT/IntervalMap.h
-===================================================================
---- include/llvm/ADT/IntervalMap.h (revision 152265)
-+++ include/llvm/ADT/IntervalMap.h (working copy)
-@@ -1977,7 +1977,7 @@
- CurSize[Nodes] = CurSize[NewNode];
- Node[Nodes] = Node[NewNode];
- CurSize[NewNode] = 0;
-- Node[NewNode] = this->map->newNode<NodeT>();
-+ Node[NewNode] = this->map->template newNode<NodeT>();
- ++Nodes;
- }
-
Modified: lldb/branches/apple/python-GIL/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/API/SBTarget.cpp?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/API/SBTarget.cpp (original)
+++ lldb/branches/apple/python-GIL/source/API/SBTarget.cpp Sun May 20 07:08:41 2012
@@ -502,7 +502,7 @@
bool
SBTarget::IsValid () const
{
- return m_opaque_sp.get() != NULL;
+ return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
}
SBProcess
Modified: lldb/branches/apple/python-GIL/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Host/common/Host.cpp?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Host/common/Host.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Host/common/Host.cpp Sun May 20 07:08:41 2012
@@ -1227,19 +1227,23 @@
lldb::TargetSP
Host::GetDummyTarget (lldb_private::Debugger &debugger)
{
- lldb::TargetSP dummy_target_sp;
+ static TargetSP g_dummy_target_sp;
- ArchSpec arch(Target::GetDefaultArchitecture());
- if (!arch.IsValid())
- arch = Host::GetArchitecture ();
- Error err = debugger.GetTargetList().CreateTarget(debugger,
- FileSpec(),
- arch.GetTriple().getTriple().c_str(),
- false,
- NULL,
- dummy_target_sp);
+ // FIXME: Maybe the dummy target should be per-Debugger
+ if (!g_dummy_target_sp || !g_dummy_target_sp->IsValid())
+ {
+ ArchSpec arch(Target::GetDefaultArchitecture());
+ if (!arch.IsValid())
+ arch = Host::GetArchitecture ();
+ Error err = debugger.GetTargetList().CreateTarget(debugger,
+ FileSpec(),
+ arch.GetTriple().getTriple().c_str(),
+ false,
+ NULL,
+ g_dummy_target_sp);
+ }
- return dummy_target_sp;
+ return g_dummy_target_sp;
}
struct ShellInfo
Modified: lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherRootXPCService-Info.plist
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherRootXPCService-Info.plist?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherRootXPCService-Info.plist (original)
+++ lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherRootXPCService-Info.plist Sun May 20 07:08:41 2012
@@ -25,7 +25,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>149</string>
+ <string>150</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 Apple Inc. All rights reserved.</string>
<key>XPCService</key>
Modified: lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherXPCService-Info.plist
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherXPCService-Info.plist?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherXPCService-Info.plist (original)
+++ lldb/branches/apple/python-GIL/source/Host/macosx/launcherXPCService/LauncherXPCService-Info.plist Sun May 20 07:08:41 2012
@@ -25,7 +25,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>149</string>
+ <string>150</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 Apple Inc. All rights reserved.</string>
<key>XPCService</key>
Modified: lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Sun May 20 07:08:41 2012
@@ -1257,6 +1257,7 @@
return 0;
ProcessSP process_sp (m_process_wp.lock());
+ Process *process = process_sp.get();
const size_t addr_byte_size = m_data.GetAddressByteSize();
bool bit_width_32 = addr_byte_size == 4;
@@ -1268,9 +1269,10 @@
const addr_t nlist_data_byte_size = symtab_load_command.nsyms * nlist_byte_size;
const addr_t strtab_data_byte_size = symtab_load_command.strsize;
- if (process_sp)
+ addr_t strtab_addr = LLDB_INVALID_ADDRESS;
+ if (process)
{
- Target &target = process_sp->GetTarget();
+ Target &target = process->GetTarget();
SectionSP linkedit_section_sp(section_list->FindSectionByName(GetSegmentNameLINKEDIT()));
// Reading mach file from memory in a process or core file...
@@ -1279,7 +1281,7 @@
const addr_t linkedit_load_addr = linkedit_section_sp->GetLoadBaseAddress(&target);
const addr_t linkedit_file_offset = linkedit_section_sp->GetFileOffset();
const addr_t symoff_addr = linkedit_load_addr + symtab_load_command.symoff - linkedit_file_offset;
- const addr_t stroff_addr = linkedit_load_addr + symtab_load_command.stroff - linkedit_file_offset;
+ strtab_addr = linkedit_load_addr + symtab_load_command.stroff - linkedit_file_offset;
bool data_was_read = false;
@@ -1305,7 +1307,7 @@
{
data_was_read = true;
nlist_data.SetData((void *)symoff_addr, nlist_data_byte_size, eByteOrderLittle);
- strtab_data.SetData((void *)stroff_addr, strtab_data_byte_size, eByteOrderLittle);
+ strtab_data.SetData((void *)strtab_addr, strtab_data_byte_size, eByteOrderLittle);
if (function_starts_load_command.cmd)
{
const addr_t func_start_addr = linkedit_load_addr + function_starts_load_command.dataoff - linkedit_file_offset;
@@ -1320,9 +1322,9 @@
DataBufferSP nlist_data_sp (ReadMemory (process_sp, symoff_addr, nlist_data_byte_size));
if (nlist_data_sp)
nlist_data.SetData (nlist_data_sp, 0, nlist_data_sp->GetByteSize());
- DataBufferSP strtab_data_sp (ReadMemory (process_sp, stroff_addr, strtab_data_byte_size));
- if (strtab_data_sp)
- strtab_data.SetData (strtab_data_sp, 0, strtab_data_sp->GetByteSize());
+ //DataBufferSP strtab_data_sp (ReadMemory (process_sp, strtab_addr, strtab_data_byte_size));
+ //if (strtab_data_sp)
+ // strtab_data.SetData (strtab_data_sp, 0, strtab_data_sp->GetByteSize());
if (function_starts_load_command.cmd)
{
const addr_t func_start_addr = linkedit_load_addr + function_starts_load_command.dataoff - linkedit_file_offset;
@@ -1357,13 +1359,22 @@
}
- if (strtab_data.GetByteSize() == 0)
+ if (process)
+ {
+ if (strtab_addr == LLDB_INVALID_ADDRESS)
+ {
+ if (log)
+ module_sp->LogMessage(log.get(), "failed to locate the strtab in memory");
+ return 0;
+ }
+ }
+ else if (strtab_data.GetByteSize() == 0)
{
if (log)
module_sp->LogMessage(log.get(), "failed to read strtab data");
return 0;
}
-
+
const ConstString &g_segment_name_TEXT = GetSegmentNameTEXT();
const ConstString &g_segment_name_DATA = GetSegmentNameDATA();
const ConstString &g_segment_name_OBJC = GetSegmentNameOBJC();
@@ -1420,6 +1431,7 @@
uint32_t sym_idx = 0;
Symbol *sym = symtab->Resize (symtab_load_command.nsyms + m_dysymtab.nindirectsyms);
uint32_t num_syms = symtab->GetNumSymbols();
+ std::string memory_symbol_name;
//symtab->Reserve (symtab_load_command.nsyms + m_dysymtab.nindirectsyms);
for (nlist_idx = 0; nlist_idx < symtab_load_command.nsyms; ++nlist_idx)
@@ -1435,24 +1447,37 @@
nlist.n_value = nlist_data.GetAddress_unchecked (&nlist_data_offset);
SymbolType type = eSymbolTypeInvalid;
- const char *symbol_name = strtab_data.PeekCStr(nlist.n_strx);
- if (symbol_name == NULL)
+ const char *symbol_name = NULL;
+
+ if (process)
{
- // No symbol should be NULL, even the symbols with no
- // string values should have an offset zero which points
- // to an empty C-string
- Host::SystemLog (Host::eSystemLogError,
- "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
- nlist_idx,
- nlist.n_strx,
- module_sp->GetFileSpec().GetDirectory().GetCString(),
- module_sp->GetFileSpec().GetFilename().GetCString());
- continue;
+ const addr_t str_addr = strtab_addr + nlist.n_strx;
+ Error str_error;
+ if (process->ReadCStringFromMemory(str_addr, memory_symbol_name, str_error))
+ symbol_name = memory_symbol_name.c_str();
+ }
+ else
+ {
+ symbol_name = strtab_data.PeekCStr(nlist.n_strx);
+
+ if (symbol_name == NULL)
+ {
+ // No symbol should be NULL, even the symbols with no
+ // string values should have an offset zero which points
+ // to an empty C-string
+ Host::SystemLog (Host::eSystemLogError,
+ "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
+ nlist_idx,
+ nlist.n_strx,
+ module_sp->GetFileSpec().GetDirectory().GetCString(),
+ module_sp->GetFileSpec().GetFilename().GetCString());
+ continue;
+ }
+ if (symbol_name[0] == '\0')
+ symbol_name = NULL;
}
const char *symbol_name_non_abi_mangled = NULL;
- if (symbol_name[0] == '\0')
- symbol_name = NULL;
SectionSP symbol_section;
uint32_t symbol_byte_size = 0;
bool add_nlist = true;
Modified: lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun May 20 07:08:41 2012
@@ -502,6 +502,28 @@
else
m_flags.Set (flagsGotDebugStrData);
}
+ else
+ {
+ const char *symfile_dir_cstr = m_obj_file->GetFileSpec().GetDirectory().GetCString();
+ if (symfile_dir_cstr)
+ {
+ if (strcasestr(symfile_dir_cstr, ".dsym"))
+ {
+ if (m_obj_file->GetType() == ObjectFile::eTypeDebugInfo)
+ {
+ // We have a dSYM file that didn't have a any debug info.
+ // If the string table has a size of 1, then it was made from
+ // an executable with no debug info, or from an executable that
+ // was stripped.
+ section = section_list->FindSectionByType (eSectionTypeDWARFDebugStr, true).get();
+ if (section && section->GetFileSize() == 1)
+ {
+ m_obj_file->GetModule()->ReportWarning ("empty dSYM file detected, dSYM was created with an executable with no debug info.");
+ }
+ }
+ }
+ }
+ }
if (debug_abbrev_file_size > 0 && debug_info_file_size > 0)
abilities |= CompileUnits | Functions | Blocks | GlobalVariables | LocalVariables | VariableTypes;
Modified: lldb/branches/apple/python-GIL/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/Process.cpp?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/Process.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/Process.cpp Sun May 20 07:08:41 2012
@@ -1960,6 +1960,28 @@
#endif // #else for #if defined (ENABLE_MEMORY_CACHING)
+size_t
+Process::ReadCStringFromMemory (addr_t addr, std::string &out_str, Error &error)
+{
+ char buf[256];
+ out_str.clear();
+ addr_t curr_addr = addr;
+ while (1)
+ {
+ size_t length = ReadCStringFromMemory (curr_addr, buf, sizeof(buf), error);
+ if (length == 0)
+ break;
+ out_str.append(buf, length);
+ // If we got "length - 1" bytes, we didn't get the whole C string, we
+ // need to read some more characters
+ if (length == sizeof(buf) - 1)
+ curr_addr += length;
+ else
+ break;
+ }
+ return out_str.size();
+}
+
size_t
Process::ReadCStringFromMemory (addr_t addr, char *dst, size_t dst_max_len, Error &result_error)
Modified: lldb/branches/apple/python-GIL/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/Target.cpp?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/Target.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/Target.cpp Sun May 20 07:08:41 2012
@@ -64,6 +64,7 @@
m_internal_breakpoint_list (true),
m_watchpoint_list (),
m_process_sp (),
+ m_valid (true),
m_search_filter_sp (),
m_image_search_paths (ImageSearchPathsChanged, this),
m_scratch_ast_context_ap (NULL),
@@ -165,6 +166,7 @@
Target::Destroy()
{
Mutex::Locker locker (m_mutex);
+ m_valid = false;
DeleteCurrentProcess ();
m_platform_sp.reset();
m_arch.Clear();
Modified: lldb/branches/apple/python-GIL/test/functionalities/alias/TestAliases.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/functionalities/alias/TestAliases.py?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/functionalities/alias/TestAliases.py (original)
+++ lldb/branches/apple/python-GIL/test/functionalities/alias/TestAliases.py Sun May 20 07:08:41 2012
@@ -107,16 +107,16 @@
self.expect ("help run",
- substrs = [ "'run' is an abbreviation for 'process launch --'" ])
+ substrs = [ "'run' is an abbreviation for 'process launch -c /bin/bash --'" ])
self.expect ("help -a run",
- substrs = [ "'run' is an abbreviation for 'process launch --'" ])
+ substrs = [ "'run' is an abbreviation for 'process launch -c /bin/bash --'" ])
self.expect ("help -a",
- substrs = [ 'run', 'process launch' ])
+ substrs = [ 'run', 'process launch -c /bin/bash' ])
self.expect ("help", matching=False,
- substrs = [ "'run'", 'process launch' ])
+ substrs = [ "'run'", 'process launch -c /bin/bash' ])
self.expect ("run",
patterns = [ "Process .* launched: .*a.out" ])
Modified: lldb/branches/apple/python-GIL/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py (original)
+++ lldb/branches/apple/python-GIL/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py Sun May 20 07:08:41 2012
@@ -4,6 +4,7 @@
import os, time
import unittest2
+import re
import lldb
from lldbtest import *
@@ -26,6 +27,21 @@
self.setTearDownCleanup(dictionary=self.d)
self.hello_multiple_threads()
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @dsym_test
+ def test_watchpoint_multiple_threads_wp_set_and_then_delete_with_dsym(self):
+ """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires."""
+ self.buildDsym(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+ self.hello_multiple_threads_wp_set_and_then_delete()
+
+ @dwarf_test
+ def test_watchpoint_multiple_threads_wp_set_and_then_delete_with_dwarf(self):
+ """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires."""
+ self.buildDwarf(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+ self.hello_multiple_threads_wp_set_and_then_delete()
+
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
@@ -81,6 +97,7 @@
self.runCmd("thread list")
if "stop reason = breakpoint" in self.res.GetOutput():
breakpoint_stops += 1
+ # Since there are only three worker threads that could hit the breakpoint.
if breakpoint_stops > 3:
self.fail("Do not expect to break more than 3 times")
continue
@@ -96,6 +113,76 @@
self.expect("watchpoint list -v",
substrs = ['hit_count = 1'])
+ def hello_multiple_threads_wp_set_and_then_delete(self):
+ """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires."""
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ self.expect("breakpoint set -l %d" % self.first_stop, BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" %
+ (self.source, self.first_stop))
+
+ # Set this breakpoint to allow newly created thread to inherit the global watchpoint state.
+ self.expect("breakpoint set -l %d" % self.thread_function, BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 2: file ='%s', line = %d, locations = 1" %
+ (self.source, self.thread_function))
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a write-type watchpoint for variable 'g_val'.
+ # The main.cpp, by design, misbehaves by not following the agreed upon
+ # protocol of using a mutex while accessing the global pool and by not
+ # writing to the variable.
+ self.expect("watchpoint set variable -w write g_val", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = w'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 0'])
+
+ breakpoint_stops = 0
+ watchpoint_stops = 0
+ while True:
+ self.runCmd("process continue")
+ self.runCmd("process status")
+ if re.search("Process .* exited", self.res.GetOutput()):
+ # Great, we are done with this test!
+ break
+
+ self.runCmd("thread list")
+ if "stop reason = breakpoint" in self.res.GetOutput():
+ self.runCmd("thread backtrace all")
+ breakpoint_stops += 1
+ if self.TraceOn():
+ print "breakpoint_stops=%d...." % breakpoint_stops
+ # Since there are only three worker threads that could hit the breakpoint.
+ if breakpoint_stops > 3:
+ self.fail("Do not expect to break more than 3 times")
+ continue
+ elif "stop reason = watchpoint" in self.res.GetOutput():
+ self.runCmd("thread backtrace all")
+ watchpoint_stops += 1
+ if watchpoint_stops > 1:
+ self.fail("Watchpoint hits not supposed to exceed 1 by design!")
+ # Good, we verified that the watchpoint works! Now delete the watchpoint.
+ if self.TraceOn():
+ print "watchpoint_stops=%d at the moment we delete the watchpoint" % watchpoint_stops
+ self.runCmd("watchpoint delete 1")
+ self.expect("watchpoint list -v",
+ substrs = ['No watchpoints currently set.'])
+ continue
+ else:
+ self.fail("The stop reason should be either break or watchpoint")
+
if __name__ == '__main__':
import atexit
Modified: lldb/branches/apple/python-GIL/test/settings/TestSettings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/settings/TestSettings.py?rev=157156&r1=157155&r2=157156&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/settings/TestSettings.py (original)
+++ lldb/branches/apple/python-GIL/test/settings/TestSettings.py Sun May 20 07:08:41 2012
@@ -115,6 +115,14 @@
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+ def cleanup():
+ format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name}${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n"
+ self.runCmd("settings set frame-format %s" % format_string, check=False)
+ self.runCmd('command unalias hello', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name-with-args}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}\n"
self.runCmd("settings set frame-format %s" % format_string)
More information about the lldb-commits
mailing list