forked from qt-creator/qt-creator
Debugger: Fix support for big-endian targets
Amends 67072d3f5b
.
Change-Id: I7c3c08d970e837f77f7194aa80ad403da1ddd4e9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
bd70259029
commit
0ad4bafa04
@@ -188,6 +188,7 @@ class DumperBase():
|
||||
self.typeData = {}
|
||||
self.isBigEndian = False
|
||||
self.packCode = '<'
|
||||
self.byteorder = 'little'
|
||||
|
||||
self.resetCaches()
|
||||
self.resetStats()
|
||||
@@ -1560,17 +1561,17 @@ class DumperBase():
|
||||
primaryOpcode = data[0]
|
||||
if primaryOpcode == relativeJumpCode:
|
||||
# relative jump on 32 and 64 bit with a 32bit offset
|
||||
offset = int.from_bytes(data[1:5], byteorder='little')
|
||||
offset = int.from_bytes(data[1:5], byteorder=self.byteorder)
|
||||
return address + 5 + offset
|
||||
if primaryOpcode == jumpCode:
|
||||
if data[1] != 0x25: # check for known extended opcode
|
||||
return 0
|
||||
# 0xff25 is a relative jump on 64bit and an absolute jump on 32 bit
|
||||
if self.ptrSize() == 8:
|
||||
offset = int.from_bytes(data[2:6], byteorder='little')
|
||||
offset = int.from_bytes(data[2:6], byteorder=self.byteorder)
|
||||
return address + 6 + offset
|
||||
else:
|
||||
return int.from_bytes(data[2:6], byteorder='little')
|
||||
return int.from_bytes(data[2:6], byteorder=self.byteorder)
|
||||
return 0
|
||||
|
||||
# Do not try to extract a function pointer if there are no values to compare with
|
||||
|
@@ -666,6 +666,7 @@ class Dumper(DumperBase):
|
||||
|
||||
self.isBigEndian = gdb.execute('show endian', to_string=True).find('big endian') > 0
|
||||
self.packCode = '>' if self.isBigEndian else '<'
|
||||
self.byteorder = 'big' if self.isBigEndian else 'little'
|
||||
|
||||
(ok, res) = self.tryFetchInterpreterVariables(args)
|
||||
if ok:
|
||||
|
@@ -178,6 +178,7 @@ class DumperBase():
|
||||
|
||||
self.isBigEndian = False
|
||||
self.packCode = '<'
|
||||
self.byteorder = 'little'
|
||||
|
||||
self.resetCaches()
|
||||
self.resetStats()
|
||||
@@ -1767,17 +1768,17 @@ class DumperBase():
|
||||
primaryOpcode = data[0]
|
||||
if primaryOpcode == relativeJumpCode:
|
||||
# relative jump on 32 and 64 bit with a 32bit offset
|
||||
offset = int.from_bytes(data[1:5], byteorder='little')
|
||||
offset = int.from_bytes(data[1:5], byteorder=self.byteorder)
|
||||
return address + 5 + offset
|
||||
if primaryOpcode == jumpCode:
|
||||
if data[1] != 0x25: # check for known extended opcode
|
||||
return 0
|
||||
# 0xff25 is a relative jump on 64bit and an absolute jump on 32 bit
|
||||
if self.ptrSize() == 8:
|
||||
offset = int.from_bytes(data[2:6], byteorder='little')
|
||||
offset = int.from_bytes(data[2:6], byteorder=self.byteorder)
|
||||
return address + 6 + offset
|
||||
else:
|
||||
return int.from_bytes(data[2:6], byteorder='little')
|
||||
return int.from_bytes(data[2:6], byteorder=self.byteorder)
|
||||
return 0
|
||||
|
||||
# Do not try to extract a function pointer if there are no values to compare with
|
||||
@@ -2532,7 +2533,7 @@ typename))
|
||||
|
||||
def extract_pointer_at_address(self, address):
|
||||
blob = self.value_data_from_address(address, self.ptrSize())
|
||||
return int.from_bytes(blob, byteorder='little')
|
||||
return int.from_bytes(blob, byteorder=self.byteorder)
|
||||
|
||||
def value_extract_integer(self, value, size, signed):
|
||||
if isinstance(value.lvalue, int):
|
||||
@@ -2542,7 +2543,7 @@ typename))
|
||||
#with self.dumper.timer('extractInt'):
|
||||
value.check()
|
||||
blob = self.value_data(value, size)
|
||||
return int.from_bytes(blob, byteorder='little', signed=signed)
|
||||
return int.from_bytes(blob, byteorder=self.byteorder, signed=signed)
|
||||
|
||||
def value_extract_something(self, valuish, size, signed=False):
|
||||
if isinstance(valuish, int):
|
||||
@@ -2551,7 +2552,7 @@ typename))
|
||||
blob = self.value_data(valuish, size)
|
||||
else:
|
||||
raise RuntimeError('CANT EXTRACT FROM %s' % type(valuish))
|
||||
res = int.from_bytes(blob, byteorder='little', signed=signed)
|
||||
res = int.from_bytes(blob, byteorder=self.byteorder, signed=signed)
|
||||
#self.warn("EXTRACTED %s SIZE %s FROM %s" % (res, size, blob))
|
||||
return res
|
||||
|
||||
|
@@ -679,6 +679,7 @@ class Dumper(DumperBase):
|
||||
|
||||
self.isBigEndian = gdb.execute('show endian', to_string=True).find('big endian') > 0
|
||||
self.packCode = '>' if self.isBigEndian else '<'
|
||||
self.byteorder = 'big' if self.isBigEndian else 'little'
|
||||
|
||||
#(ok, res) = self.tryFetchInterpreterVariables(args)
|
||||
#if ok:
|
||||
|
@@ -145,7 +145,7 @@ class Dumper(DumperBase):
|
||||
target_typeid = self.from_native_type(nativeTargetType)
|
||||
target_address = nativeValue.GetValueAsUnsigned()
|
||||
val = self.Value(self)
|
||||
val.ldata = target_address.to_bytes(self.ptrSize(), 'little')
|
||||
val.ldata = target_address.to_bytes(self.ptrSize(), self.byteorder)
|
||||
if self.useDynamicType:
|
||||
target_typeid = self.dynamic_typeid_at_address(target_typeid, target_address)
|
||||
val.typeid = self.create_reference_typeid(target_typeid)
|
||||
@@ -1354,6 +1354,9 @@ class Dumper(DumperBase):
|
||||
return
|
||||
|
||||
self.isArmMac = frame.module.triple.startswith('arm64-apple')
|
||||
self.isBigEndian = frame.module.byte_order == lldb.eByteOrderBig
|
||||
self.packCode = '>' if self.isBigEndian else '<'
|
||||
self.byteorder = 'big' if self.isBigEndian else 'little'
|
||||
|
||||
self.output = []
|
||||
isPartial = len(self.partialVariable) > 0
|
||||
|
Reference in New Issue
Block a user