Tim Haines [Tue, 5 Dec 2023 18:05:48 +0000 (12:05 -0600)]
Set new CMake policy for upper-case <NAME>_ROOT variables (#1642)
In CMake 3.27 and above the find_package(<PackageName>) command now
searches prefixes specified by the upper-case <PACKAGENAME>_ROOT CMake
variable and the <PACKAGENAME>_ROOT environment variable in addition to
the case-preserved <PackageName>_ROOT and <PackageName>_ROOT variables
used since policy CMP0074. This policy provides compatibility with
projects that have not been updated to avoid using <PACKAGENAME>_ROOT
variables for other purposes.
The OLD behavior for this policy is to ignore <PACKAGENAME>_ROOT
variables if the original <PackageName> has lower-case characters. The
NEW behavior for this policy is to use <PACKAGENAME>_ROOT variables.
Tim Haines [Fri, 1 Dec 2023 20:42:13 +0000 (14:42 -0600)]
Clean up includes in instructionAPI/Result.h (#1641)
* Remove unused stringstream include
* Use cstdint instead of custom defines
* Use cassert instead of assert.h
* Include common/util.h for INSTRUCTION_EXPORT
Tim Haines [Fri, 1 Dec 2023 19:15:00 +0000 (13:15 -0600)]
Add debugging functions for instructionAPI (#1640)
Tim Haines [Wed, 29 Nov 2023 21:41:58 +0000 (15:41 -0600)]
Add DWARF mappings for cr8-15 and dr8-15 (#1639)
Tim Haines [Wed, 29 Nov 2023 12:12:01 +0000 (06:12 -0600)]
Add missing x86_64 control and debug registers (#1638)
Tim Haines [Wed, 29 Nov 2023 01:00:07 +0000 (19:00 -0600)]
Synchronize x86 mnemonics with Capstone (#1634)
* Create Capstone import script
This currently only supports x86, but can be readily expanded to the
other architectures.
* Remove invalid opcodes
Some of these are used to label subtypes of the general
instruction and some are just madeup mnemonics that were never
used in Dyninst.
* Move pseudo-mnemonics to top of file
This makes them easier to see.
* Remove AT&T aliases
* Replace fstcw with fnstcw
* Replace fstenv with fnstenv
* Replace fstsw with fnstsw
* Replace fsave with fnsave
The fstX instructions are actually aliases for 'waitf' followed by
the fnstX variant. There's no need to have both.
* Rename loopn -> loopne
loopn isn't a valid mnemonic for 0xE0.
* Remove e_jmpe
The opcode 0x0FB8 is decoded as popcnt unless the preceeding byte is
0xF3. However, not even Xed decodes this instruction. From Table A-3 of
the June 2021 Intel SDM:
JMPE (reserved for emulator on IPF)
* Rename cmpxch -> cmpxchg
* Rename e_cmpxch -> e_cmpxchg
* Rename cmpxch8b -> cmpxchg8b
* Rename e_prefetchNTA -> e_prefetchnta
* Rename e_prefetchT0 -> e_prefetcht0
* Rename e_prefetchT1 -> e_prefetcht1
* Rename e_prefetchT2 -> e_prefetcht2
* Rename e_punpcklqld -> e_punpcklqdq
* Rename e_shl_sal -> e_shl
There's no real concensus, but Capstone and Xed use shl.
* Rename e_ud -> e_ud0
* Make cmovnbe an alias of cmova
* Make cmovnb an alias of cmovae
* Make cmovnae an alias of cmovb
* Make cmovng an alias of cmovle
* Make cmovnge an alias of cmovl
* Make cmovnl an alias of cmovge
* Make cmovpe an alias of cmovp
* Make cmovpo an alias of cmovnp
* Make cwd an alias of cdq
* Make fcomip an alias of fcompi
* Make fucomip an alias of fucompi
* Make jnb an alias of jae
* Make jnbe an alias of ja
* Make jnl an alias of jge
* Make jnle an alias of jg
* Make jnz an alias of jne
* Make jz an alias of je
* Make jrcxz an alias of jcxz
* Make lods an alias of lodsb
* Make popa an alias of popal
popal isn't a valid mnemonic, but it's what Capstone uses.
* Make popad an alias of popaw
popaw isn't a valid mnemonic, but it's what Capstone uses.
* Make pushad, pusha, and pushaw aliases of pushal
pushal isn't a valid mnemonic, but it's what Capstone uses.
* Make pushfd an alias of pushf
* Make setnb an alias of setae
* Make setnbe an alias of seta
* Make setnl an alias of setge
* Make setnle an alias of setg
* Make setnz an alias of setne
* Make setz an alias of sete
* Make xlat an alias of xlatb
* Add new mnemonics
Tim Haines [Tue, 28 Nov 2023 18:49:09 +0000 (12:49 -0600)]
Add x86_{i386,64} memory-management and x87 control/status registers (#1636)
* Add the memory-management registers
The processor provides four memory-management registers (GDTR, LDTR,
IDTR, and TR) that specify the locations of the data structures which
control segmented memory management. See Section 2.4 in Volume 3 of
the Intel 64 and IA-32 Architectures Software Developer’s Manual from
June 2021 for details.
* Add mxcsr
This is the SSE Control Status Word register. The AMD64
ABI doc says it's 128 bits, but it's actually 32.
* Add x87/SSE/AVX control and status word registers
Without these, getBaseRegister will convert fcw, fsw, and mxcsr to a
register with category '<id> | W_REG | ST | Arch_x86_64' which is
incorrect. getBaseRegister should return the register unmodified.
Tim Haines [Mon, 27 Nov 2023 20:39:49 +0000 (14:39 -0600)]
Update x86 DWARF registers maps (#1633)
* Update x86_64 DWARF registers to 2022 AMD64 standard
* Update x86_i386 DWARF registers to 2015 Intel386 standard
Tim Haines [Fri, 24 Nov 2023 16:38:34 +0000 (10:38 -0600)]
Remove deleted x86 RegisterDictionary functions (#1632)
These were commented out by
558227822 in 2016.
Tim Haines [Tue, 21 Nov 2023 21:52:49 +0000 (15:52 -0600)]
Clean up and improve documentation of x86_64 registers (#1630)
* Improve comments for register lengths
* Separate MMX/3DNow! and x87 register lengths and categories
The MMX* registers are only the lower 64 bits of the st* ones.
* Fix x86_64 subrange mappings in MachRegister::getROSERegister
The values in the two namespaces are not the same.
* Improve comments for EFLAGS fields
* Use symbolic names for the segment register base IDs
* Add missing flag1 from RFLAGS
* Add missing flag3 from RFLAGS
* Add missing flag5 from RFLAGS
* Add missing flagc from RFLAGS
FLAGC is the lower bit of the I/O Permission Level field.
* Add missing flagd from RFLAGS
FLAGC is the upper bit of the I/O Permission Level field.
* Add missing flagf from RFLAGS
* Add missing Virtual-8086 mode (VM) rFLAGS field
* Add conversion to ROSE register for Resume Flag
* Add conversion to ROSE register for Nested Task flag
* Add missing Alignment Check/Access Control (AC) RFLAGS field
* Add missing Virtual Interrupt Flag (VIF) RFLAGS field
* Add missing Virtual Interrupt Pending (VIP) RFLAGS field
* Add missing ID Flag (ID) RFLAGS field
* Fix avx-512 opmask size.
It's 64 bits, not 128.
From Intel(R) 64 and IA-32 Architectures Software Developer’s Manual
June 2021
15.6.1 OPMASK Register to Predicate Vector Data Processing
The opmask is a set of eight architectural registers of size
MAX_KL (64-bit).
* Rename OCT to XMMS
This makes it consistent with the names used for the other vector
extensions.
* Add missing subranges in MachRegister::getROSERegister
* Preserve register number in getBaseRegister
* Clear whole subrange byte for GPRs in getBaseRegister
Tim Haines [Tue, 21 Nov 2023 20:59:06 +0000 (14:59 -0600)]
Clean up and improve documentation of x86_32 registers (#1629)
* Improve comments for register lengths
* Separate MMX/3DNow! and x87 register lengths and categories
The MMX* registers are only the lower 64 bits of the st* ones.
* Improve comments for EFLAGS fields
* Add conversion to ROSE register for FLAGC
FLAGC is the lower bit of the I/O Permission Level field in EFIELD.
* Add conversion to ROSE register for FLAGD
FLAGC is the upper bit of the I/O Permission Level field in EFIELD.
* Add conversion to ROSE register for Nested Task flag
* Add conversion to ROSE register for Resume Flag
* Add missing Virtual-8086 mode (VM) EFLAGS field
* Add missing Alignment Check/Access Control (AC) EFLAGS field
* Add missing Virtual Interrupt Flag (VIF) EFLAGS field
* Add missing Virtual Interrupt Pending (VIP) EFLAGS field
* Add missing ID Flag (ID) EFLAGS field
* Remove registers xmm8-xmm31 and aliases
These registers are only available in 64-bit mode.
From Intel(r) 64 and IA-32 Architectures Software Developer’s Manual
June 2021:
11.2.1 SSE2 in 64-Bit Mode and Compatibility Mode
In compatibility mode, SSE2 extensions function like they do in
protected mode. In 64-bit mode, eight additional XMM registers are
accessible. Registers XMM8-XMM15 are accessed by using REX prefixes.
14.1.1 256-Bit Wide SIMD Register Support
Intel AVX introduces support for 256-bit wide SIMD registers
(YMM0-YMM7 in operating modes that are 32-bit or less, YMM0-YMM15 in
64-bit mode).
15.1.2 32 SIMD Register Support
Intel AVX-512 instructions also support 32 SIMD registers in 64-bit
mode (XMM0-XMM31, YMM0-YMM31 and ZMM0-ZMM31). The number of available
vector registers in 32-bit mode is still 8.
* Fix avx-512 opmask size.
It's 64 bits, not 128.
From Intel(R) 64 and IA-32 Architectures Software Developer’s Manual
June 2021
15.6.1 OPMASK Register to Predicate Vector Data Processing
The opmask is a set of eight architectural registers of size
MAX_KL (64-bit).
* Rename OCT to XMMS
This makes it consistent with the names used for the other vector
extensions.
* Use symbolic names for the segment register base IDs
* Add missing ROSE category conversions
* Add missing ROSE subrange conversions
* Preserve register number in getBaseRegister
* Clear whole subrange byte for GPRs in getBaseRegister
Tim Haines [Tue, 21 Nov 2023 19:13:36 +0000 (13:13 -0600)]
Remove MachineRegister::getSubRegValue (#1631)
It's neither documented nor used.
Tim Haines [Tue, 14 Nov 2023 12:46:06 +0000 (06:46 -0600)]
Construct a Module from the CU's offset not its PC (#1626)
* Construct a Module from the CU's offset not its PC
The PC value can be non-unique across CUs. For example, they can all
be 0x0 for a PIE binary. The offset of the CU is unique as it's the
location inside of the .debug_info table.
* Use correct lookup when creating module during Object parse
When creating a module during fix_global_symbol_modules_static_dwarf,
the default module covers all ranges, so we need to look for the
exact offset to prevent using the default module every time.
* Use correct offset in DwarfWalker::parseModule
* Lookup DIE location with dwarf_offdie when parsing ranges
bbiiggppiigg [Tue, 7 Nov 2023 21:54:48 +0000 (21:54 +0000)]
Restructure operand decoding logic for AMDGPU (#1614)
As title, this commit restructured the operand decoding logic.
The main changes are as follows:
* Fix operand length for MFMA instructions
* Reorganize AMDGPU-decoder for separate-compilation
* Fix formatting for script-generated code.
Tim Haines [Tue, 7 Nov 2023 21:24:11 +0000 (15:24 -0600)]
Deprecate Symtab::getOrCreateModule (#1623)
* Deprecate Symtab::getOrCreateModule
There are several problems here:
1) Users shouldn't be creating modules
2) When created, the returned module must be "fixed up" before it's
useful. There's no need for that when one could be properly constructed
at the callsite inside Dyninst.
3) It violates the Single Responsibility Principle
* Add Symtab::addModule
It's private, so can only be used by friends- specifically Object.
* Use addModule throughout Symtab
* Don't update mod_lookup_ in fixSymModules
The address ranges have already been inserted there by 'addModule'.
* Use new check/add idiom for Modules in binaryEdit::writeFile
* Use new idiom in Object::fix_global_symbol_modules_static_dwarf
Tim Haines [Tue, 7 Nov 2023 20:19:01 +0000 (14:19 -0600)]
Explicitly mark overridden member functions in Object-elf (#1624)
clang checks this by default.
Tim Haines [Mon, 6 Nov 2023 22:58:38 +0000 (16:58 -0600)]
Clean up dead code in common/ast.C (#1622)
* Remove AStNode::printRC
It was introduced by
bddc6379 in 1996, but doesn't seem to have ever
been called.
* Remove AstNode::print()
Its declaration was removed by
123a8c7f3 in 2006.
* Remove getOpString
It's not used anymore.
* Remove AST_PRINT
It's not used anymore.
* Remove call to ASTcounter
Its definition was removed by
e7c183b93 in 2007.
* Get rid of the rest of usages of ASTDEBUG
The macro was broken by
e7c183b93 in 2007 when ASTcounter was removed.
* Remove commented-out code in AstNode::accessesParam
It was removed by
20116a102 in 2006.
* Remove tramp_pre_frame_size_{32,64}
They were added by
4d85176be in 2008, but never used.
* Remove unused forward declarations
Tim Haines [Mon, 6 Nov 2023 21:58:07 +0000 (15:58 -0600)]
Clean up common/Types.h (#1619)
* Move definition of Dyninst::ThrIDToTid into common/dyntypes.h
59ddf22 in 2009, this function was changed to always just return an int-like representation of 'id'.
* Move Address_str into dynProcess.C
It's only ever used there.
* Remove Address_chk
It is never used.
* Remove common/src/Types.C
All of the definitions have been removed/relocated.
* Remove unused time64 declaration
* Remove unused Word type
* Remove hash_address from Types.h
It's not used.
* Explicitly use namespace for read_memory_as
* Merge Address definition and variable decls
* Remove unused includes of common/Types.h
* Add Dyninst namespace directive in arch-x86.C
It was transitively included from common/Types.h.
* Move Register type into its own file
* Rename NULL_REG -> Null_Register
No need to have two names for the same value.
* Put Register, RegVal, and Null_Register in Dyninst namespace
* Move map_entries into its own file
* Remove common/Types.h
* Fixes for ppc
* Use Dyninst::Address in codegen-aarch64
* Use Dyninst::Register in codegen-aarch64
* Simplify Address_str
Address is a typedef to an unsigned long on all platforms. No need for
the other case.
* Use Dyninst::Address in dynProcess.C
Tim Haines [Mon, 6 Nov 2023 20:00:17 +0000 (14:00 -0600)]
Fix astOperatorNode semantics (#1621)
* Revert "Guarantee operands in AstOperatorNode are non-null (#1609)"
This reverts commit
9fa5f6dc0307d735700c544ca83d661926b40803.
* Fix loperand
* Use tighter checks on roperand in generateCode_phase2
* Remove useless checks in generateCode_phase2
Variables are used before checked.
* Remove AstOperatorNode default ctor
* Remove ~AstOperatorNode
* Remove assert on loperand
It's checked on line 1303.
* Add more loperand checks
Tim Haines [Mon, 6 Nov 2023 19:23:50 +0000 (13:23 -0600)]
Remove dead code binaryEdit.C (#1620)
* Remove a bunch of commented-out code
* Remove check for .bss
Removed by
81ad56701 in 2009.
Tim Haines [Fri, 3 Nov 2023 14:50:26 +0000 (09:50 -0500)]
Remove addTrapTableSpace_win and addTrapTable_win in binaryEdit.C (#1618)
They were commented out by
918945edb in 2011.
Tim Haines [Fri, 3 Nov 2023 14:49:59 +0000 (09:49 -0500)]
Remove code protected by USE_ADDRESS_MAPS (#1617)
The usage of the variables it protects was removed by
399a10ea in 2007.
Tim Haines [Fri, 3 Nov 2023 14:39:31 +0000 (09:39 -0500)]
Remove useless assert in binaryEdit::writeFile (#1616)
The variable is used before the assert.
Tim Haines [Fri, 3 Nov 2023 14:39:12 +0000 (09:39 -0500)]
Remove extraneous variables in Symbol.C (#1615)
These were added by
c848409ec in 2009, but never used.
Tim Haines [Tue, 31 Oct 2023 12:44:00 +0000 (07:44 -0500)]
Fix MachRegister bool checks (#1613)
The logic between the getRegisterX and isRegisterX members diverged over time. This implements the isRegisterX in terms of the getRegisterX while preserving extra checks where necessary.
* Write 'isPC' in terms of 'getPC'
* Add missing architectures in getFramePointer
* Don't assert in getFramePointer
* Write isFramePointer in terms of getFramePointer
This also adds correct detection of frame pointers on PPC.
* Add missing arch in getStackPointer
* Don't assert in getStackPointer
* Reorder checks in getStackPointer
For consistency
* Write isStackPointer in terms of getStackPointer
This also now includes StackTop.
* isFramePointer ws
* isPC ws
* isStackPointer typo
* Don't assert in getSyscallNumberReg
* Add missing arch in getSyscallNumberReg
* Write isSyscallNumberReg in terms of getSyscallNumberReg
The original implementation in
7b8d777ce from 2013 used o{r,e}ax for
x86, but was changed to use {r,e}ax by
23a5a76d2 in 2015. Neither
the SystemV ABI nor Intel Dev Guide refer to o*ax, so I think this
check is now correct.
* Don't assert in getSyscallReturnValueReg
* Add missing arches in getSyscallReturnValueReg
* Write isSyscallReturnValueReg in terms of getSyscallReturnValueReg
These two had become completely unsynchronized. There is a reg for
aarch64 and both PPC registers were wrong in the bool check.
* Reorder checks in getZeroFlag
For consistency
* Don't assert in getZeroFlag
* Add missing arch in getZeroFlag
* Write isZeroFlag in terms of getZeroFlag
Tim Haines [Mon, 30 Oct 2023 21:22:43 +0000 (16:22 -0500)]
Improve name handling in MachRegister (#1612)
* Clean up name caching in MachRegister
This just needs to be a file-scope static. It also doesn't need to be
allocated on the heap or be an ordered container.
* Fix broken transient include
* Have 'name' return ref to const
No need to make a copy.
* Add back error handling for missing name
Tim Haines [Mon, 30 Oct 2023 20:28:26 +0000 (15:28 -0500)]
Remove locking before calls to convertDebugOffset (#1611)
It uses a lock internally.
Tim Haines [Mon, 30 Oct 2023 15:36:57 +0000 (10:36 -0500)]
Make null pointer checks for ParseAPI::Block::_obj consistent (#1608)
Found by cppcheck's nullPointerRedundantCheck.
Tim Haines [Mon, 30 Oct 2023 15:36:39 +0000 (10:36 -0500)]
Guarantee operands in AstOperatorNode are non-null (#1609)
* AstOperatorNode: operands are non-null
This is now a class invariant. Found by cppcheck's
nullPointerRedundantCheck.
* AstOperatorNode: remove dtor and default ctor
They don't enforce the new invariant.
Tim Haines [Mon, 30 Oct 2023 11:46:05 +0000 (06:46 -0500)]
Remove FunctionBase::ranges_lock (#1596)
It's only ever used in DwarfWalker::setRanges, and that is only ever
called from DwarfWalker::parseSubprogram which is now correctly
guarded (as of
8b400af59b).
Tim Haines [Mon, 30 Oct 2023 11:45:51 +0000 (06:45 -0500)]
Remove redundant declaration of SymtabAPI::FuncRangeCollection (#1597)
It was added by
5ed068167 in 2013.
Tim Haines [Mon, 30 Oct 2023 11:45:35 +0000 (06:45 -0500)]
Remove Symtab(MappedFile*) (#1598)
It's never used. MappedFile is also an opaque type here, so users
could never have used it. This makes it not an ABI/API-breaking change.
Tim Haines [Mon, 30 Oct 2023 11:45:20 +0000 (06:45 -0500)]
Remove Symtab::exportXML,exportBin,importBin (#1599)
These were part of the serialization interface and should have been
removed by
f4ee3410b.
Tim Haines [Mon, 30 Oct 2023 11:45:04 +0000 (06:45 -0500)]
Remove module contains check in Symtab::create{Function,Variable} (#1601)
Having a default module was made a class invariant in
9e855250.
Tim Haines [Mon, 30 Oct 2023 11:44:47 +0000 (06:44 -0500)]
Remove dyninst.h, stringDecl.h (#1600)
* Remove dyninstAPI/dyninst.h
The includes it imports aren't used by the places including this file.
* Remove common/stringDecl.h
It's not used. This might be the oldest surviving piece of code in Dyninst.
Tim Haines [Mon, 30 Oct 2023 11:44:33 +0000 (06:44 -0500)]
Make SymtabAPI::errMsg thread_local (#1602)
This makes it consistent with serr.
Tim Haines [Mon, 30 Oct 2023 11:44:19 +0000 (06:44 -0500)]
Clean up MachRegister class (#1604)
* Add missing switch breaks in size()
* Add break after assert in case statement
* Move assert into default case in 'size'
This is semantically equivalent, but fixes the 'incomplete without
default' linter warning.
* Add error messages in getROSERegister
I don't know if it's correct to assert in these conditions. This is
semantically equivalent, fixes the 'incomplete without default' linter
warning, and avoids asserting.
* Return InvalidRegister in DwarfEncToReg
This makes them all consisent and fixes the 'incomplete without default'
linter warning.
* Remove dead code
I left the commented-out switch cases. I'm not sure why they aren't
used.
* Remove useless asserts
* Remove 'init_names' declaration
It was never implemented.
Tim Haines [Mon, 30 Oct 2023 11:43:45 +0000 (06:43 -0500)]
Lazily parse function ranges in Symtab::getContainingFunction (#1603)
* Lazily parse function ranges in Symtab::getContainingFunction
This makes it consistent with getContainingInlinedFunction.
* Remove sorting in Symtab::getContainingFunction
This is done in parseFunctionRanges.
Tim Haines [Mon, 30 Oct 2023 11:43:14 +0000 (06:43 -0500)]
Remove char* ctor overload (#1605)
It makes no sense to have this and the std::string version when they do
the same thing.
Tim Haines [Mon, 30 Oct 2023 11:43:00 +0000 (06:43 -0500)]
Remove Symtab::newModule declaration (#1606)
This should have been removed by
7e62e5e7f.
Tim Haines [Mon, 30 Oct 2023 11:42:46 +0000 (06:42 -0500)]
Remove BINEDIT_DEBUG (#1607)
* Remove BINEDIT_DEBUG
The vast majority of usages were removed over the years (e.g.,
f90cb3d09 0f9ac8641 ee95eb18b cf5cf6e15 26947f8dc c9807b2ff). It's also
not every been turned on in the CMake build system, so it's not been
used in at least a decade.
* Remove print_symbols_map
* Remove print_symbols
It was only used by print_symbol_map
* rm print_symbol_map rebase
* Remove ____sym_hdr_printed
It's unused now.
Tim Haines [Mon, 30 Oct 2023 11:42:15 +0000 (06:42 -0500)]
Remove Symtab::getSymbolByIndex (#1610)
It was added by
3a7f5df6 in 2009, but never implemented.
Tim Haines [Sat, 28 Oct 2023 04:15:08 +0000 (23:15 -0500)]
Remove common/std_namesp.h (#1594)
Tim Haines [Sat, 28 Oct 2023 03:43:47 +0000 (22:43 -0500)]
Remove codeRange::operator<< (#1595)
It was added by
fa76232b4 in 2005, but never implemented.
Tim Haines [Sat, 28 Oct 2023 02:56:57 +0000 (21:56 -0500)]
Refactor common/dyn_regs.h (#1590)
This is a substantial re-architecture of the files used to record the per-architecture machine instructions. Most of the changes here are to facilitate automation of integrating new instructions via Capstone.
* Move Dyninst::Architecture into its own file
* Move MachRegister into separate files
* Remove non-existent classes in MachRegister.h
These should have been removed by
d42b65910 in 2021.
* Only define registers in dyn_regs.C
* Move getArchAddressWidth into Architecture.h
* Use new Architecture.h and registers/MachRegister.h headers everywhere
Also fix broken transient includes.
* Remove unnecessary includes of 'dyn_regs.h'
* Put registers for each arch in separate file
* Move isSegmentRegister into x86_regs.h
* Use new per-architecture register files
This should reduce compile times and file sizes.
* Remove unnecessary comment in stackwalk/procstate.h
* Merge aarch64 sys regs into regs file
* Fix whitespace in aarch64_regs.h
* Get rid of aarch64 subdir
* Merge gfx908 sys_regs into regs
* Whitespace gfx908 regs
* Reorder gfx908 register declarations
This makes it consistent with the other architectures.
* Merge gfx90a sys_regs into regs
* Whitespace gfx90a
* Reorder gfx90a register declarations
This makes it consistent with the other architectures.
* Merge gfx940 sys_regs into regs
* Whitespace gfx940
* Reorder gfx940 register declarations
This makes it consistent with the other architectures.
* Flatten AMDGPU register namespace
This makes it consistent with the mnemonics namespace.
* Whitespace ppc32
* Whitespace ppc64
* Whitespace x86_64
* Whitespace ppc32
* Whitespace x86
* Whitespace abstract
* Whitespace cuda
* Remove extra slash in AMDGPU paths
Tim Haines [Thu, 26 Oct 2023 22:00:47 +0000 (17:00 -0500)]
Remove Pair.h and pdpair (#1593)
It's no longer used.
Tim Haines [Thu, 26 Oct 2023 21:35:00 +0000 (16:35 -0500)]
Remove Singleton.h (#1592)
It's not used anymore.
Tim Haines [Thu, 26 Oct 2023 21:03:50 +0000 (16:03 -0500)]
Remove BPatch_flowGraph::getLoopMinMaxSourceLines (#1591)
Its usage was removed by
f531f7261 in 2011.
Tim Haines [Wed, 25 Oct 2023 21:47:03 +0000 (16:47 -0500)]
Remove instructionAPI/h/RegisterIDs.h (#1589)
This should have been removed by
2dd88601a in 2010.
Tim Haines [Mon, 23 Oct 2023 18:33:03 +0000 (13:33 -0500)]
Reorder enumerators in instructionAPI::Result::Result_Type (#1588)
These enumerators were reordered by
85fd6745. It turns out there is
an undocumented requirement that they be in this specific order. Rather
than fixing the incorrect usage of inequality checks on enumerators,
I'm putting them back in order with a note.
Tim Haines [Tue, 17 Oct 2023 21:50:27 +0000 (16:50 -0500)]
Fix redundant parsing of linemap information (#1587)
This was introduced by
5835e29f.
Tim Haines [Tue, 17 Oct 2023 13:01:24 +0000 (08:01 -0500)]
Move entryIDs into separate data files (#1585)
* Move entryIDs into separate data files
This will make it much easier to update them as we migrate to Capstone.
This is a very poor solution, but is the only means of splitting the
architectures apart while maintaining the existing entryID enum usage.
* Add newline in x86 file
* Add suffix '_entryIDs.h' to data files
This gives the reader a better idea of what they are and lets tools like
cloc know that they correspond to a language.
Tim Haines [Mon, 16 Oct 2023 17:31:35 +0000 (12:31 -0500)]
Remove mapped_module::getAddrFromLine (#1586)
It was introduced in 2005 by
5731bd02a, but never implemented.
Tim Haines [Sun, 15 Oct 2023 12:23:52 +0000 (07:23 -0500)]
Handle implicit operand for call instruction to ROSE (#1583)
Co-authored-by: Xiaozhu Meng <xmeng@cs.wisc.edu>
Tim Haines [Sun, 15 Oct 2023 12:23:40 +0000 (07:23 -0500)]
Add missing memory operand sizes and decoding in instructionAPI::Result (#1582)
* Put case statements in same order
This makes it much easier to see if any are missing.
* Add useful comment for m14
* Add missing case values
---------
Co-authored-by: Xiaozhu Meng <xmeng@cs.wisc.edu>
Tim Haines [Fri, 13 Oct 2023 23:15:16 +0000 (18:15 -0500)]
Fix line information parsing for CUs with no aranges (#1581)
As of libdw 0.189, `dwarf_addrdie` assumes the presence of
.debug_aranges. For compilers that do not emit one, or emit an invalid
one (e.g., gtpin binaries), then manually search through all of the CUs
to find a match.
Tim Haines [Thu, 12 Oct 2023 22:56:20 +0000 (17:56 -0500)]
Fix naming of Modules with relative CU paths (#1580)
* Use correct directory when adding source files
* Use correct directory when creating a Module
Tim Haines [Thu, 12 Oct 2023 20:59:39 +0000 (15:59 -0500)]
Replace Module::getAllFunctions (#1579)
The documented meaning did not match the implementation. This fixes
that and breaks the interface so that users are forced to see the
change rather than being surprised by it. It also makes it consistent
with the other 'find' members like findSymbol and findLocalVariable.
Tim Haines [Thu, 12 Oct 2023 20:58:11 +0000 (15:58 -0500)]
Reduce usage of concurrent.h (#1578)
Tim Haines [Thu, 12 Oct 2023 20:15:29 +0000 (15:15 -0500)]
Remove Module::findFunctionByEntryOffset (#1577)
This was originally done in
d2d48213a, but was accidentally reverted in
1c5f4966b.
Tim Haines [Thu, 12 Oct 2023 20:07:37 +0000 (15:07 -0500)]
Remove MODULE_ANNOTATABLE_CLASS (#1576)
This is never used and Module doesn't inherit from AnnotatableSparse.
Tim Haines [Thu, 12 Oct 2023 20:07:16 +0000 (15:07 -0500)]
Remove DWARFisms from Symtab::Module (#1575)
* Remove compilation directory from Module
This is a concept specific to DWARF. These functions are not documented.
* Remove DWARFisms from Symtab::Module
There is no need to store the CU DIE from which a Module instance is
derived. The address of the CU can be used to reconstitute the
entry in the .debug_info section using dwarf_addrdie.
Because Module.h is part of the public API for Dyninst, this also
removes the transitive dependency on libdw.
Tim Haines [Wed, 11 Oct 2023 21:11:51 +0000 (16:11 -0500)]
Deprecate mapped_module::truncateLineFilenames (#1574)
It's never used.
Tim Haines [Wed, 11 Oct 2023 11:37:29 +0000 (06:37 -0500)]
Refactor symtab/Module.h (#1573)
* Move Statement class into its own header/source
* Add missing include in RangeLookup.h
* Remove redundant visibility specifier in Statement
* Use in-class member initializers
This removes the sign conversion.
* Default the dtor
* Whitespace Module.h
This was just too terrible to leave alone.
* Clean up includes in Module.h
* Merge public sections
Tim Haines [Wed, 11 Oct 2023 03:02:59 +0000 (22:02 -0500)]
Use Symtab::getContainingModule instead of Symtab::findModuleByOffset (#1572)
This should have been part of
ddd2315b5.
Tim Haines [Tue, 10 Oct 2023 20:37:49 +0000 (15:37 -0500)]
Add Symtab::getContainingModule(Offset) (#1571)
* Add Symtab::getContainingModule(Offset)
Returns the module with PC ranges that contain a given offset (really
address). In contrast, findModuleByOffset(Offset) finds a module
starting at the given offset.
kupsch [Tue, 10 Oct 2023 18:02:05 +0000 (13:02 -0500)]
warning fix: false positive maybe uninitialized (#1570)
gcc 12 reports a diagnostic for a maybe uninitialized value when
boost::option::value_or is called on an optional that has no
value, even though this is safe
- add a diagnostic suppression macro for this warning and use it
to suppress the warning
kupsch [Tue, 10 Oct 2023 14:24:43 +0000 (09:24 -0500)]
fix gcc 6's broken __has_x_attribute (#1569)
- gcc 6's __has_c_attribute and __has_cpp_attribute return true if
an attribute is supported as a non-standard extension, but if used
produces a warning if the language standard is earlier than the
attribute's standardization; treat gcc 6 like clang and only allow
if the language standard is after the introduction.
- refactor the conditional compilation tests into common macros
Tim Haines [Mon, 9 Oct 2023 18:55:57 +0000 (13:55 -0500)]
Refactor Symtab::getOrCreateModule (#1568)
* Merge getOrCreateModule and newModule
The latter was only ever called from the former.
* Remove dead debug code
* Do not adjust Module's address
It's unclear why this was here. This function is currently called from
only two places: BinaryEdit::writeFile and
Object::fix_global_symbol_modules_static_dwarf.
In the first, the module created is called 'dyninstInst'. This is the
only place where that name is used, so only one module would be created.
Moreover, 'writeFile' will only produce a single binary output, so there
wouldn't be multiple modules.
In the second, the module lookup will always fail because we are
creating new ones for each DWARF compilation unit (CU), and those are
guaranteed to be unique as we iterate over the results of
'dwarf_nextcu'.
* Remove 'directory definitions' check
This kind of name is never used manually anywhere in Dyninst and the
names that come from DWARF compilation units (CUs) are never
directories.
* Clean up 'create' tracing message
* Tidy up variable declarations.
* Remove 'assert' after 'new'.
We require exceptions to be enabled when building Dyninst and we aren't
using the 'nothrow' version of 'operator new' here. This check is
useless.
* Remove existence check.
This will never be true because 'findModuleByOffset' would have found
the module.
* Don't return with parens
* Rename 'ret' to 'mod'.
For clarity.
Tim Haines [Mon, 9 Oct 2023 18:09:00 +0000 (13:09 -0500)]
Remove Symtab::findModuleByName(Module *&, std::string) (#1565)
A Symtab::Module is a one-to-one mapping to a DWARF compilation unit
(CU). In DWARF4, we consider a CU to be an entry in the .debug_info
section with the tag DW_TAG_compile_unit. In DWARF5, we also include
entries with the tag DW_TAG_partial_unit as they can contain symbol
definitions; we assume libdw will merge all other split unit types for
us.
The name of a module is the DW_AT_name of the containing DIE. This is
either the full path name of the source file used to create the CU or
the relative path of the same with respect to the DW_AT_comp_dir. We
ensure that the module's name is always an absolute path.
Modules have never been required to have unique names. That is, many
modules can share the same name. The following demonstrates this case:
test.c
------
#ifdef FUNC1
void func1(){}
#endif
#ifdef FUNC2
void func2(){}
#endif
$ gcc -g -c -DFUNC1 -o func1.o test.c
$ gcc -g -c -DFUNC2 -o func2.o test.c
$ gcc -g -fPIC -shared func1.o func2.o -o libfunc.so
$ readelf --debug-dump=info libfunc.so | grep -A 6 DW_TAG_compile_unit
<0><c>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d> DW_AT_producer : <redacted>
<11> DW_AT_language : 29 (C11)
<12> DW_AT_name : test.c
<16> DW_AT_comp_dir : /path/to/test
<1a> DW_AT_low_pc : 0x10f9
<22> DW_AT_high_pc : 0x1104
<0><55>: Abbrev Number: 1 (DW_TAG_compile_unit)
<56> DW_AT_producer : <redacted>
<5a> DW_AT_language : 29 (C11)
<5b> DW_AT_name : test.c
<5f> DW_AT_comp_dir : /path/to/test
<63> DW_AT_low_pc : 0x1104
<6b> DW_AT_high_pc : 0x110F
Because the two CUs have the same name, Dyninst throws away the contents
of the second one because this function would return the first. It is
also possible (and likely) that the two CUs have different line maps and
location lists. These, too, are discarded. Although unlikely, it is
legal for a compiler to emit CUs with overlapping PC range values. This
means the only way to uniquely identify a module is by its offset in
the .debug_info section.
Tim Haines [Mon, 9 Oct 2023 18:02:41 +0000 (13:02 -0500)]
Remove Module::findFunctionByEntryOffset (#1561)
This was added by
c848409ec in 2009, but never implemented. It looks
like this was copy/pasted from the earliest Symtab rewrite.
Tim Haines [Mon, 9 Oct 2023 17:16:38 +0000 (12:16 -0500)]
Remove Module::findFunctionsByName (#1562)
This was added by c848409 in 2009, but never implemented. It looks
like this was copy/pasted from the earliest Symtab rewrite.
Tim Haines [Mon, 9 Oct 2023 17:16:21 +0000 (12:16 -0500)]
Fix inline detection in findFuncName (#1563)
Tim Haines [Mon, 9 Oct 2023 17:16:08 +0000 (12:16 -0500)]
Improve DWARF debugging in Object::fix_global_symbol_modules_static_dwarf (#1564)
* Remove dead debug code
* Add new debug tracing with dwarf_printf
Tim Haines [Mon, 9 Oct 2023 17:15:48 +0000 (12:15 -0500)]
Clean up dead code in dwarfWalker.C (#1566)
* Remove commented-out code
It's just noise.
* Remove useless comments
Tim Haines [Mon, 9 Oct 2023 17:15:22 +0000 (12:15 -0500)]
Remove Symtab::changeSymbolOffset (#1567)
It is never used. Not a breaking change as it's private.
I have left the function of the same name in Aggregate because it's
protected, there is a virtual dtor, and that class is accessible by
users. It's possible that someone is using it.
Tim Haines [Sat, 7 Oct 2023 20:44:32 +0000 (15:44 -0500)]
Remove DwarfWalker::setModuleFromName (#1546)
It's replaced with the updated Symtab::findModuleByOffset. Finding by
name was always unnecessary as we know the offset of the current DIE.
Tim Haines [Fri, 6 Oct 2023 22:09:28 +0000 (17:09 -0500)]
GithubCI: add testing on Fedora-39 (#1560)
* Add Dockerfile to build Fedora
* Add fedora-39 to PR tests (gcc only)
The available libomp is for clang-17, but the highest installable
version is clang-15. Seems like a bug.
* Add fedora-39 to release containers
kupsch [Fri, 6 Oct 2023 00:36:34 +0000 (19:36 -0500)]
warning fix: improve logical-op handling (#1559)
- use DYNINST_DIAGNOSTIC_BEGIN_SUPPRESS_LOGICAL_OP and END
macros to suppress logical-op warning
Tim Haines [Thu, 5 Oct 2023 20:51:37 +0000 (15:51 -0500)]
Create unique names for unnamed partial DWARF DIEs (#1558)
* Refactor out is_*_unit functions from dwarf_cu_info.h
* Give names to DW_TAG_partial_unit DIEs
bbiiggppiigg [Tue, 3 Oct 2023 21:39:43 +0000 (21:39 +0000)]
Drop Support for AMDGPU GFX900(VEGA) (#1555)
This commit drops the manual implementation for supporting AMDGPU GFX900 (VEGA) architecture,
which we don't have XML-ISA-SPEC for.
* drop support for gfx900
* remove legacy register vector types
kupsch [Tue, 3 Oct 2023 21:00:16 +0000 (16:00 -0500)]
reorganize and cleanup Symtab.h (#1557)
- fix incomplete type error of a std::vector<relocationEntry>
member declared before relocationEntry was defined
- move class ExceptionBlock to its own .h and .C
- move class relocationEntry to its own .h and .C
- move Symbol:: methods from Symtab.C to Symbol.C
Tim Haines [Mon, 2 Oct 2023 19:19:04 +0000 (14:19 -0500)]
Mark Symtab::findModuleByOffset(Module*&,Offset) with DYNINST_DEPRECATED (#1551)
* Mark Symtab::findModuleByOffset(Module*&,Offset) with DYNINST_DEPRECATED
* Replace use of deprecated findModuleByOffset
This should have been part of
f41e64479.
kupsch [Mon, 2 Oct 2023 18:36:35 +0000 (13:36 -0500)]
fix deprecated annotation warning using clang (#1554)
The clang compiler allows the use of some attributes introduced in a
later language standard than use to compile the source as a
non-standard extension. Clang's __has_cpp_attribute and
__has_c_attribute returns true for these attributes. If one of
these attributes is used, clang warns of a non-standard language
feature usage. So for clang, only use a standard attribute if the
feature test returns true and the language standard version is
valid.
- fix clang's [[deprecated]] (only if C++ >= 14 and C >= 23)
- use now known C-23 __STDC_VERSION__ value 202311L
Tim Haines [Mon, 2 Oct 2023 18:15:59 +0000 (13:15 -0500)]
GithubCI: fix names in consumer weekly build (#1553)
bbiiggppiigg [Mon, 2 Oct 2023 17:08:27 +0000 (17:08 +0000)]
Add Initial Support for GFX940 (#1541)
* Add Initial Support for GFX940
Tim Haines [Fri, 29 Sep 2023 20:26:01 +0000 (15:26 -0500)]
Add findModulesByName(std::string const&) (#1552)
Tim Haines [Fri, 29 Sep 2023 19:48:53 +0000 (14:48 -0500)]
GithubCI: improve error handling (#1548)
These were causing false negatives in testing.
kupsch [Fri, 29 Sep 2023 19:14:37 +0000 (14:14 -0500)]
add deprecated annotation support (#1550)
- Added the macro DYNINST_DEPRECATED(msg). It can be placed before a
function, method, type or variable so that on use a deprecated
diagnostic is produced. The macro works using language standard
annotation or compiler specific annotations or has no effect if
neither is available.
Tim Haines [Fri, 29 Sep 2023 19:12:16 +0000 (14:12 -0500)]
Remove public Symtab API for adding line information (#1547)
The Module into which the line information will be isnserted cannot be
uniquely identified by name.
Tim Haines [Fri, 29 Sep 2023 19:11:53 +0000 (14:11 -0500)]
Add new Symtab interface for accessing modules by offset (#1545)
* Add findModuleByOffset(Offset)
* Deprecate findModuleByOffset(Module *&, Offset)
It is replaced by findModuleByOffset(Offset).
* Remove findModuleByOffset(std::set<Module *>&, Offset)
It was never documented and makes no sense as offsets are unique
within a module (i.e., DWARF CU). Further, Dyninst uses a separate
Symtab instance for each object file in an archive.
Tim Haines [Fri, 29 Sep 2023 19:11:10 +0000 (14:11 -0500)]
Mark SymtabAPI::Function::removeSymbol as 'override' (#1549)
This was detected by -Winconsistent-missing-override enabled by default
in clang-15.
Tim Haines [Thu, 28 Sep 2023 20:53:04 +0000 (15:53 -0500)]
Replace boost::multi_index_container with tbb::concurrent_unordered_set in symtab_impl (#1544)
* Replace boost::multi_index_container with tbb::concurrent_unordered_set
There are now only two dimensions to each Module, so the multi_index
isn't needed. This also replaces the mutex with the intrinsic reader/
writer locks in TBB.
* Rename indexed_modules.hpp -> indexed_modules.h
* Add include guards
* add copyright
* Remove usage of'this' in fixSymModules
Tim Haines [Thu, 28 Sep 2023 19:58:52 +0000 (14:58 -0500)]
Make Symtab::getDefaultModule const (#1543)
Tim Haines [Thu, 28 Sep 2023 18:34:27 +0000 (13:34 -0500)]
Make a default module a class invariant in Symtab (#1538)
This simplifies the handling of modules and ensures a default
always exists. Creation must happen after the MappedFile has
been created (Symtab::file() checks that one has been created),
but before the symbols are assigned to a Module.
Tim Haines [Thu, 28 Sep 2023 18:33:25 +0000 (13:33 -0500)]
Default-initialized 'std::once_flag's in symtab_impl (#1539)
Tim Haines [Thu, 28 Sep 2023 18:33:11 +0000 (13:33 -0500)]
Use fully-qualified name in fix_global_symbol_modules_static_dwarf (#1540)
A minor cleanup item, but it makes IDE lookup easier.
Tim Haines [Thu, 28 Sep 2023 18:32:56 +0000 (13:32 -0500)]
Fix duplicate symbol entries in Symtab:everyFunction (#1542)
A function should only be added to everyFunction if it was not already
in funcsByOffset or if it lives in a different code region from the
function found with the same offset.
This was introduced by https://github.com/dyninst/dyninst/pull/1534.
bbiiggppiigg [Thu, 28 Sep 2023 15:30:21 +0000 (15:30 +0000)]
Fix overflow of fields in instruction layout (#1476)
Fields in instruction layouts can have implicit LSBs.
Previously this wasn't taken into consideration,
and causes overflow and decoding instruction.
This PR fixes the layout definition to include the LSBs.
Tim Haines [Sat, 23 Sep 2023 01:50:22 +0000 (20:50 -0500)]
Refactor DwarfWalker::dieRanges (#1535)
* Remove unused parameters
Their usage was removed by
48d4286c in 2018.
* Remove old debug code