rocky/python-xasm

AssertionError

CoverDisc opened this issue · 9 comments

hi
i ran this command on a pyc file

pydysasm -F xasm mifile.pyc > myfile.pyasm

when i ran this

pyc-xasm myfile.pyasm i get this error

Traceback (most recent call last):
File "/usr/local/bin/pyc-xasm", line 33, in
sys.exit(load_entry_point('xasm==1.2.0', 'console_scripts', 'pyc-xasm')())
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.0-py3.10.egg/xasm/xasm_cli.py", line 28, in main
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.0-py3.10.egg/xasm/assemble.py", line 290, in asm_file
AssertionError: File needs to start out with: # Python bytecode

rocky commented

Please copy and post the first 10 lines of myfile.pyasm

# pydisasm version 6.0.5.dev0
# Python bytecode 3.10.0 (3439)
# Disassembled from Python 3.10.4 (main, Dec  1 2022, 10:22:11) [GCC 7.5.0]
# Timestamp in code: 0 (1970-01-01 01:00:00)
# Source code size mod 2**32: 0 bytes

# Method Name:       contatore
# Filename:         myfile.py
# Argument count:    1
# Position-only argument count: 0
# Keyword-only arguments: 0
# Number of locals:  5
# Stack size:        4
# Flags:             0x00000043 (NOFREE | NEWLOCALS | OPTIMIZED)
# First Line:        22
rocky commented

I can't reproduce this problem. If you are not using the latest github master, try with that. (I just changed the version number to a dev branch to distinguish from the last release).

Also there was an unrelated bug in xdis, so pull from the master use that.

If this doesn't correct things, then attach the entire disassembled file and the pyc file.

tank's , reproduce the same error with new dev branch

Traceback (most recent call last):
  File "/usr/local/bin/pyc-xasm", line 33, in <module>
    sys.exit(load_entry_point('xasm==1.2.1.dev0', 'console_scripts', 'pyc-xasm')())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/xasm_cli.py", line 28, in main
  File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/assemble.py", line 290, in asm_file
AssertionError: File needs to start out with: # Python bytecode <version>

the project it's a private with ip of my server if it's possible i send you in pm

rocky commented

Ok - send email to rocky@gnu.org and I'll look at it when I can.

thank's again i will send now

rocky commented

The file you sent doesn't match what you report above. The first line in the file sent is:

/root/python-xdis

The other thing about the file sent is that xdis needs to be redone to correct for changes in the instruction operand format for jump instructions in 3.10. I made yet another change just before writing this. So make sure to refresh your xdis development version, and run the disassembly again (and don't add further lines).

thank's for your time i don't know why the file that i have send report in frist line /root/python-xdis i ran again
pydisasm -F xasm myfile.pyc | tee > myfile.pyasm
and reinstall xdis from dev branch
this is the output of comand pyc-xasm myfile.pyasm

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/assemble.py", line 461, in create_code
KeyError: 'L40'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/pyc-xasm", line 33, in
sys.exit(load_entry_point('xasm==1.2.1.dev0', 'console_scripts', 'pyc-xasm')())
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/xasm_cli.py", line 28, in main
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/assemble.py", line 173, in asm_file
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/assemble.py", line 465, in create_code
File "/usr/local/lib/python3.10/site-packages/xasm-1.2.1.dev0-py3.10.egg/xasm/assemble.py", line 401, in err
RuntimeError: Label L40 not found.
I know about { POP_JUMP_IF_TRUE L2 (to 4), POP_JUMP_IF_FALSE L40 (to 80)}. Instruction 1:
POP_JUMP_IF_FALSE L40 (to 80)