Commit Graph

94 Commits

Author SHA1 Message Date
rocky
d731d32c11 Simplify BREAK_LOOP detection...
by making more us of linestart. At least for now...
2024-07-14 14:45:25 -04:00
rocky
b0b67e9f34 Fix some 2.6 bytecode bugs
scanner26: disassemble interface has changed
make_function2: was missing ParserError2 import
2024-07-11 12:06:52 -04:00
rocky
bec88e4aaa Name phases "disassembly" and "tokenization" 2024-03-14 15:31:53 -04:00
rocky
daf54d2740 2.6 scanner show -A headers now 2024-03-13 21:39:35 -04:00
rocky
803678e9b4 Track recent xdis changes 2023-08-26 14:39:42 -04:00
rocky
656a9aa290 Bugs in 2.x relative import '.' and 1.x bytecode 2022-05-14 17:46:48 -04:00
rocky
223804ac1f semi-black scanner26.py 2022-05-14 09:51:50 -04:00
rocky
9aba1cc3af Bytecode 1.x fixes 2022-04-30 20:36:43 -04:00
rocky
eba0d37d0f Improve Python 1.x decompiling
Still has bugs, but is much better.
2022-04-30 05:54:22 -04:00
rocky
f35231a6f5 Correct bug in long literal replacement for 2.6-7 2022-04-28 17:28:09 -04:00
rocky
8e5faa933f Handle long 2.x bytecode literals more efficiently 2022-04-27 13:47:56 -04:00
rocky
c6642f5899 Revise "ingest" docstring 2022-04-25 07:42:56 -04:00
rocky
c806ef59c6 Update scanner demo code 2022-04-17 11:41:19 -04:00
rocky
f6f0e344d0 Python 3.6+ specialization 2021-11-03 02:23:19 -04:00
rocky
ed34bf9d4a use xdis.PYTHON3 not uncompyle.PYTHON3 2021-11-02 06:53:11 -04:00
rocky
8ac7a75372 Use tuples not floats in Python release comparison 2021-10-18 11:59:02 -04:00
rocky
e8e006bb8c More Python version comparison conversions 2021-10-16 11:33:03 -04:00
rocky
e8e7d2086d whileelse in 3.6 sometimes has come froms...
also remove extra "L. " in token printing
2020-04-04 10:12:12 -04:00
rocky
24afe072b7 LOAD_CONST -> LOAD_CODE where appropriate 2019-06-19 14:43:07 -04:00
rocky
1cd2d1e915 DRY scanner code more...
Expand 2.6 testing
2018-04-03 10:35:02 -04:00
rocky
fad43feb3d DRY instruction building code...
There is a little more that could be done with  self.offset2inst_index
2018-04-03 04:41:36 -04:00
rocky
f18ce71e91 Replace all_instrs with inst_matches...
which works on 3.6+. Still should write a pytest for this.
2018-03-29 21:23:26 -04:00
rocky
e23315b2e6 Fallout from more precise token attributes 2018-02-28 23:35:52 -05:00
rocky
296fcd89ce Add self.offset2inst_index and document more 2018-02-04 09:13:49 -05:00
rocky
b0d18cae6a Fix bug in 2.5- try/else inside ifelsestmt 2018-01-06 22:19:44 -05:00
rocky
15057bed1d Fix bugs in scanner.last_instr()...
And ave instruction stream self.insts like we do in Python 3 so we
can start simplifying code.
2017-12-15 20:34:34 -05:00
rocky
a7005f6a77 2.7 exec stmt grammar rule isolation/reduction 2017-12-02 09:23:18 -05:00
rocky
17f5b35b1d More grammar isolation 2017-11-26 16:34:10 -05:00
rocky
b7003914c9 localize 2 and 3 argument BUILD_SLICE...
Nontermninal name matches AST anme now. Add test.
2017-11-25 21:10:11 -05:00
rocky
dea17cd7f1 xdis _disassemble->disassemble 2017-11-06 00:38:22 -05:00
rocky
1392b18bd7 Adjust for spark-parser 2.7.0 incompatabilities 2017-10-10 14:14:26 -04:00
rocky
7b38d2f1f8 Adjust for xdis opcode JUMP_OPS. release 2.12.0 2017-09-25 20:01:31 -04:00
rocky
27ab6fe2f5 Use xdis 3.5.0's opcode sets 2017-07-08 20:41:46 -04:00
rocky
c7f8edd5ef Simplify access to L65536 ...
and fix use in scanner26.py. Thanks to AnythingTechPro
2017-06-09 18:22:02 -04:00
rocky
49fd430505 EXTENDED_ARG is implemented in 2.6 2017-05-19 19:29:56 -04:00
rocky
597d51951e Improve Python 2.6 & 2.7 verification 2017-01-23 02:32:09 -05:00
rocky
6c546fe6e1 WIP : Add THEN to disambigute from "and" 2016-12-27 22:45:08 -05:00
rocky
1e324e0e8d Misc changes
scanner26.py: make scanner2.py and scanner26.py more alike
scanner2.py: check that return stmt is last in list. (May change)
main.py: show filename on verify error
test/*: add more
2016-11-26 21:41:45 -05:00
rocky
195bbc746b Pass debug in scanner26 find_targets 2016-11-20 03:42:30 -05:00
rocky
f2a3721d7d Start to improve detect_structure for 2.7 and 2.x
Add debug flag to find_jump_targets to show the structure we found.
When there are control-flow bugs, it's often reflected here.

scanner3.py: make code make more similar to 2.x code
2016-11-20 02:38:59 -05:00
rocky
6073c77921 Show line numbers in 2.6 "after" asm ..
start to understand some of the Python 2.6 bytecode parse failures.
2016-11-14 00:30:23 -05:00
rocky
0826129112 DRY Python 2.x unmangle_classname
main.py: small typo: Disassembled -> Decompiled
2016-10-20 06:35:01 -04:00
rocky
5703ccd8b8 2.6 try statement (and below)
They may neeed arbitrary come_froms for each except clause
2016-10-13 19:37:38 -04:00
rocky
9ef670c872 Fix Python 1.5 bytecode deparse
Need xdis 3.0.2 though since the bug is really there.
2016-10-11 02:39:09 -04:00
rocky
8b240a80e7 Get ready for release 2.9.0 ...
- Use xdis 3.0.0 protocol load_module. Needs bump in requirements.txt
  and _pkg_info_.py
- Start Python 1.5 decompiling - another round of work is needed to remove
  bugs
- small cleanups
2016-10-10 09:33:49 -04:00
rocky
4f83a87a00 Python 2 & 3 scanner code ever so slightly closer 2016-09-21 07:06:30 -04:00
rocky
c119965d96 Small changes 2016-09-18 17:23:49 -04:00
rocky
318311818e Python 2.6- try/except control flow detection 2016-09-05 04:02:37 -04:00
rocky
c7788e4545 disassemble -> ingest where appropriate
As part of tokenization for (de)parsing, we need to do something like a
disassembly, but is is really a little different.

Disassembly, strictly speaking, is done by the xdis module now.
What "ingestion" does is massage the instruction tokens to a form that is
more amenable for parsing.

In sum, ingestion is different than disassembly, although disassembly is
generally the first part of ingestion.
2016-09-04 11:43:02 -04:00
rocky
f5eeed6759 2.6- bug: while..and: stmt - on one line
If 2.6 or before POP_BLOCK after a JUMP_IF_FALSE does not
constitute a new statement. The POP_BLOCK is really part
of the JUMP_IF_FALSE. In Python 2.7+ it's a single op.
2016-09-01 20:44:17 -04:00