Skip to content

Commit

Permalink
Ordering of itab.h and itab.c varies between runs and Python versions v…
Browse files Browse the repository at this point in the history
…mt#144 (vmt#144)

scripts/ud_opcode.py: Working on vmt#120, because I hadn't realized that someone had already got properly to the root of it, in vmt#139, I was hampered by the output, specifically itab.h, changing order every time I ran:

UD_OPCODE_DEBUG=1 python3 ../scripts/ud_itab.py ../docs/x86/optable.xml .

... from the libudis86/ directory.  The getLabels change here fixes that to be in a defined ordering.

The mergeSSENONE change fixes the ordering differences I see in itab.c between running the above command and similar with python2, by iterating over each table in the same style as used by genOpcodeTable in class UdItabGenerator in scripts/ud_itab.py.
  • Loading branch information
martindorey committed May 10, 2023
1 parent 56ff6c8 commit 63f4469
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/ud_opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def getOpcodeIdx(cls, opc):
@classmethod
def getLabels(cls):
"""Returns a list of all labels"""
return [cls._TableInfo[k]['label'] for k in cls._TableInfo.keys()]
return sorted([cls._TableInfo[k]['label'] for k in cls._TableInfo.keys()])


class UdOpcodeTables(object):
Expand Down Expand Up @@ -349,7 +349,8 @@ def genTableList(tbl):
if tbl not in uniqTables:
self._tables.append(tbl)
uniqTables[tbl] = 1
for k, e in tbl.entries():
for k in range(tbl.size()):
e = tbl.entryAt(k)
if isinstance(e, UdOpcodeTable):
genTableList(e)
self._tables = []
Expand Down

0 comments on commit 63f4469

Please sign in to comment.