Book a Demo

Author Topic: Python reverse - empty result  (Read 6824 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Python reverse - empty result
« on: March 19, 2018, 07:13:41 pm »
Hi,

I received a python source code from a client to run the reverse eng. in EA.
EA processes all .py files without producing any result/class.

The Python code has :
- import declarations
- def (e.g. def functionA(arg1, arg2) : ...)

Is there any precondition to check so it works?

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Python reverse - empty result
« Reply #1 on: March 19, 2018, 09:39:54 pm »
There should be some classes at least.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Python reverse - empty result
« Reply #2 on: March 20, 2018, 03:23:04 am »
Are there classes in your code?

If you're writing classless Python I don't think you'll get anything out of an EA reverse-engineer.

/Uffe
My theories are always correct, just apply them to the right reality.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Python reverse - empty result
« Reply #3 on: March 23, 2018, 07:08:26 pm »
Hi,

The code I have does not include any class. I confirm that I got some results once I added "class : <classname>" in the files.

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Python reverse - empty result
« Reply #4 on: March 29, 2018, 09:49:09 pm »
Hi,

I ran a new test with a Python file with content illustrated as follows:

Code: [Select]
import libA
import libB
class myClass (arg1):
  def functA(arg1, arg2):
     localvar = arg1 ...

  def functB(arg1, arg2, arg3):
# code removed

  def functC():
# code removed

if a = "test":
  print('test')

Running EA reverse, I get a "myClass" class with functA operation only (and arg1 parameter).
Any idea why the other def are not picked up?

Thanks
Guillaume
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Python reverse - empty result
« Reply #5 on: March 29, 2018, 11:54:44 pm »
You should learn a bit Python first. Class operations have self as first parameter.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Python reverse - empty result
« Reply #6 on: April 03, 2018, 09:10:05 am »
I changed the incomplete method bodies from your example to 'pass' and EA imported all three methods.

They weren't static like I would have expected given they were missing the self parameter as suggested by qwerty.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Python reverse - empty result
« Reply #7 on: April 09, 2018, 10:26:56 pm »
Thanks for your replies.
With support of the Python dev team, I simply figured out that the code samples I got needed to have a proper indent level applied so the def can be reversed as class operations.

I got a query on running the EA Execution analyzer's recording feature with Python. I saw that it's not supported according to the help; could it be supported in the future?
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Python reverse - empty result
« Reply #8 on: April 10, 2018, 08:38:26 am »
You may be able to use the gdb debugger to do that, but I suspect the gdb support for python is in the UI side, not the API side.