Giter VIP home page Giter VIP logo

Comments (5)

fmagin avatar fmagin commented on June 14, 2024 1

One workaround is to set PyCharm's variable loading policy to "On demand" (Gear Icon on the left edge of the debugger panel). At least with my quick test just now this gets rid of all the errors in the ghidra_bridge server log. But at the obvious price of having to request the value for a variable if you want to see it in the debugger.

from ghidra_bridge.

justfoxing avatar justfoxing commented on June 14, 2024

Hi, @mechgt - can you post the script you're running, including how you're starting the bridge? That'll help me see if I can reproduce the problem.

from ghidra_bridge.

mechgt avatar mechgt commented on June 14, 2024

See below. When I 'run' the code from PyCharm it behaves normally. When I debug and it hits a breakpoint (e.g. at name = func.getName() ) it spits out the errors at the end of this post.

I made a simple demo script and can now see the first errors mentioning django missing. Is this maybe at the root of the issue?

# Ghidra Bridge Issue 53 Test
# @author mechgt
# @category _NEW_
# @keybinding
# @menupath
# @toolbar

try:
    import ghidra_bridge
    b = ghidra_bridge.GhidraBridge(namespace=globals(), hook_import=True) # creates the bridge and loads the flat API into the global namespace
except:
    pass

try:
    # import pydevd
    # pydevd.settrace("127.0.0.1", port=5678, stdoutToServer=True, stderrToServer=True)

    from ghidra_builtins import *
except:
    pass


def someFun(func):
    name = func.getName()
    return name


# Iterate through functions, parsing and printing each
function = getFirstFunction()
while function is not None:
    name = someFun(function)
    println(name)
    function = getFunctionAfter(function)

Ghidra Console output:

ghidra_bridge_server_background.py> Running...
INFO:jfx_bridge.bridge:Server launching in background - will continue to run after launch script finishes...
INFO:jfx_bridge.bridge:serving! (jfx_bridge v0.8.0, Python 2.7.1)
ghidra_bridge_server_background.py> Finished!
WARNING:jfx_bridge.bridge:Handling connection from ('127.0.0.1', 3960)
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 1129, in local_import
    result = importlib.import_module(name)
  File "C:\Ghidra\ghidra_9.1.2_PUBLIC\Ghidra\Features\Python\data\jython-2.7.1\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named django
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 1129, in local_import
    result = importlib.import_module(name)
  File "C:\Ghidra\ghidra_9.1.2_PUBLIC\Ghidra\Features\Python\data\jython-2.7.1\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named django
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
WARNING:jfx_bridge.bridge:Closing connection from ('127.0.0.1', 3960)
WARNING:jfx_bridge.bridge:Handling connection from ('127.0.0.1', 3966)
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 1129, in local_import
    result = importlib.import_module(name)
  File "C:\Ghidra\ghidra_9.1.2_PUBLIC\Ghidra\Features\Python\data\jython-2.7.1\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named ghidra_builtins
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 1129, in local_import
    result = importlib.import_module(name)
  File "C:\Ghidra\ghidra_9.1.2_PUBLIC\Ghidra\Features\Python\data\jython-2.7.1\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named django
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 1129, in local_import
    result = importlib.import_module(name)
  File "C:\Ghidra\ghidra_9.1.2_PUBLIC\Ghidra\Features\Python\data\jython-2.7.1\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named django
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
ghidra_bridge_server_background.py> FUN_StatusObjConstructor
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
ghidra_bridge_server_background.py> FUN_ReleaseMemory
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
Traceback (most recent call last):
  File "C:\Users\user\ghidra_scripts\jfx_bridge\bridge.py", line 974, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.function.FunctionDB' object has no attribute '__len__'
WARNING:jfx_bridge.bridge:Closing connection from ('127.0.0.1', 3966)

from ghidra_bridge.

justfoxing avatar justfoxing commented on June 14, 2024

Ahh, okay. So this looks like it's something to do with the PyCharm debugger (I've managed to replicate it by debugging in PyCharm). It looks like it's querying every Python object to see if it's got a __len__, probably so it can fill out some info or represent it in a handy way for debugging.

GhidraBridge will just blindly proxy the attribute requests across - on the server side, the error is caught and handled, and the message that appears is just a warning; everything should still be operating just fine.

Since this is only going to occur while debugging, and even then it doesn't really break things, I'm not going to be super-motivated to change this behaviour. Let me know if it is actually breaking things for you, though, and I can re-evaluate.

from ghidra_bridge.

mechgt avatar mechgt commented on June 14, 2024

Gotcha.
For a single user datapoint, my primary motivator for checking out ghidra_bridge was exclusively for debugging. I'm having trouble getting other debug mechanisms working, so this is currently THE solution that's working for me. Point being that debugging can be a primary use case for ghidra_bridge.

Thx for taking the time to check it the error messages and providing feedback!

from ghidra_bridge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.