Giter VIP home page Giter VIP logo

Comments (15)

brunoalr avatar brunoalr commented on June 9, 2024 1

I'm waiting for @csantosbh to be available, because I don't have access to Mac myself.

from openimagedebugger.

csantosbh avatar csantosbh commented on June 9, 2024 1

Glad to hear it works for you! :)
I've never tested the plugin on xcode, but I do know that every IDE will likely have its own integration with LLDB to get events such as breakpoints and whatnot. QtCreator for instance has a python module for that.

The problem is that as far as I remember, LLDB doesn't have an API for registering multiple listeners to its events. So either the OpenImageDebugger plugin gets these events, or the IDE does. The workaround this situation for QtCreator was to monkey patch their lldb module, creating a "man in the middle" situation that gets events before they reach the IDE and propagate them to the plugin and the IDE itself. The code for that is located in OpenImageDebugger/resources/oidscripts/ides/qtcreator.py

If you'd like to help, you could figure out how XCode integrates with LLDB and how we can listen to its events such as breakpoints being hit and how to get the lldb handler python object. One starting point would probably be this project. Depending on how similar to QtCreator is their implementation, it would be a matter of creating a copy of the qtcreator.py file with the XCode specifics.

from openimagedebugger.

CanCanZeng avatar CanCanZeng commented on June 9, 2024

I find the debug logger of Qt Creator.
If I set command script import /path/to/OpenImageDebugger/oid.py in ~/.lldbinit, there will be an error in Qt Creator just like xcode:

>[OpenImageDebugger] Info: Could not activate hooks for any IDEs
>Traceback (most recent call last):
>  File "/Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oid.py", line 79, in register_ide_hooks
>    initializer(debugger, event_handler)
>  File "/Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oidscripts/ides/qtcreator.py", line 68, in register_symbol_fetch_hook
>    lldb_fetch_hook(debugger, event_handler)
>  File "/Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oidscripts/ides/qtcreator.py", line 41, in lldb_fetch_hook
>    imp = __import__('lldbbridge')
>ModuleNotFoundError: No module named 'lldbbridge'
>
 Setting up inferior...

And I find that this maybe because we import oid.py too early, since the logger shows after import oid.py, Qt Creator will call script from lldbbridge import *. So I tried to not set ~/.lldbinit file, but import oid.py after debug starts. This time, no error happens, but the imagewatch window also not show, nothing happens, and then I continue debug, this time the debug procedure ends, maybe crashed.
Then I repeat above operation, after I call command script import /Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oid.py in Qt Creator's debug window, new error occurs, says

<37executeDebuggerCommand({"command":"command script import /Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oid.py","token":37})
>(lldb) script theDumper.executeDebuggerCommand({"command":"command script import /Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oid.py","token":37})
>@
>token("37")@
eERROR: Lldb stderr: Exception in thread Thread-2:
eTraceback (most recent call last):
e  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
e    self.run()
e  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
e    self._target(*self._args, **self._kwargs)
e  File "/Users/zengcancan/Softwarebag/OpenImageDebugger/installPath/OpenImageDebugger/oidwindow.app/Contents/MacOS/oidscripts/debuggers/lldbbridge.py", line 84, in event_loop
e    self._event_handler.stop_handler()
eAttributeError: 'NoneType' object has no attribute 'stop_handler'
e
>@
>success="1",output="None",error="None"@

from openimagedebugger.

CanCanZeng avatar CanCanZeng commented on June 9, 2024

I find a simillar project: https://github.com/carlodalmutto/ImageWatchLLDB.git
It can debug inside xcode, I guess that project does not depend on any IDE, but it's function is very limited. Does this information helpful?

from openimagedebugger.

MaxDilling avatar MaxDilling commented on June 9, 2024

I encounter the same error.

I used these eight commands to build the OID (as specified in README.md):

git clone https://github.com/OpenImageDebugger/OpenImageDebugger.git
cd OpenImageDebugger
git submodule init
git submodule update
mkdir build && cd build
qmake .. BUILD_MODE=release PREFIX=/path/to/installation/folder
make -j4
sudo make install

When I try to import oid.py to the lldb command line (inside Xcode) the following happens:

(lldb) command script import /Users/campadejo/bin/oid/OpenImageDebugger/oid.py
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/debuggers/lldbbridge.py", line 84, in event_loop
    self._event_handler.stop_handler()
AttributeError: 'NoneType' object has no attribute 'stop_handler'

[OpenImageDebugger] Info: Could not activate hooks for any IDEs
Traceback (most recent call last):
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oid.py", line 79, in register_ide_hooks
    initializer(debugger, event_handler)
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/ides/qtcreator.py", line 70, in register_symbol_fetch_hook
    lldb_fetch_hook(debugger, event_handler)
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/ides/qtcreator.py", line 43, in lldb_fetch_hook
    imp = __import__('lldbbridge')
ImportError: No module named lldbbridge

Stop hook #1 added.

After adding sys.path.append('/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/debuggers/') to qtcreator.py (which you probably shouldn’t do), I get the following error message:

(lldb) command script import /Users/campadejo/bin/oid/OpenImageDebugger/oid.py
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/debuggers/lldbbridge.py", line 84, in event_loop
    self._event_handler.stop_handler()
AttributeError: 'NoneType' object has no attribute 'stop_handler'

[OpenImageDebugger] Info: Could not activate hooks for any IDEs
Traceback (most recent call last):
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oid.py", line 79, in register_ide_hooks
    initializer(debugger, event_handler)
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/ides/qtcreator.py", line 70, in register_symbol_fetch_hook
    lldb_fetch_hook(debugger, event_handler)
  File "/Users/campadejo/bin/oid/OpenImageDebugger/oidscripts/ides/qtcreator.py", line 44, in lldb_fetch_hook
    original_handle_event = imp.Dumper.handleEvent
AttributeError: 'module' object has no attribute 'Dumper'

Stop hook #1 added.

I also wondered why OID is build as an .app?

I’m on commit: 4ccb12d
QT: 5.13.1, MacOS: 10.14.6

I am happy to do more tests if necessary :)

from openimagedebugger.

MeisonP avatar MeisonP commented on June 9, 2024

请问最后在Mac上的使用问题是怎么解决的?

from openimagedebugger.

brunoalr avatar brunoalr commented on June 9, 2024

@MeisonP please, let's keep communication in English :)

from openimagedebugger.

MeisonP avatar MeisonP commented on June 9, 2024

@brunoalr Hi man, do u find the answer? How this project work on Mac?

from openimagedebugger.

csantosbh avatar csantosbh commented on June 9, 2024

@MaxDilinger The error message you saw was actually expected since you are not running the plug-in from QtCreator, and it can be ignored. I see this as a huge usability problem and will remove the stack trace from this message.

@MeisonP and @MaxDilinger In order to properly compile the plugin, you must make sure it is linked against the same python binary used by lldb. To find out this path, run:

lldb
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> import sys; print(sys.path)

Here, I got the following results:

['/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A', '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python3', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python37.zip', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/claudio.fernandes/Library/Python/3.7/lib/python/site-packages', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages', '.']

In my case, the linked python is located under /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7. Finally, to link OpenImageDebugger against this specific python version, set the PKG_CONFIG_PATH environment variable to the folder lib/pkgconfig inside this python path, but do it before running qmake. In my case, I ran:

export PKG_CONFIG_PATH=/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/Current/lib/pkgconfig

Finally you can proceed with the normal compilation instructions:

git clone https://github.com/OpenImageDebugger/OpenImageDebugger.git
cd OpenImageDebugger
git submodule init
git submodule update
mkdir build && cd build
qmake .. BUILD_MODE=release PREFIX=/path/to/installation/folder
make -j4
make install

Note that you don't need (and probably don't want to) use sudo in your installation command if you are installing to a local folder (which you probably should).

from openimagedebugger.

brunoalr avatar brunoalr commented on June 9, 2024

https://github.com/OpenImageDebugger/OpenImageDebugger/wiki/Building-on-MacOS

from openimagedebugger.

brunoalr avatar brunoalr commented on June 9, 2024

@CanCanZeng @MaxDilinger @MeisonP
please let us know if the instructions above work for you :)

from openimagedebugger.

MaxDilling avatar MaxDilling commented on June 9, 2024

I'm waiting for my new machine. I hope I can give you feedback for Catalina next week.

But it dosen't work with python 2.7, XCode 10.3 and Mojave. Maybe that's because of an old LLDB version.

(lldb) command script import /[...]/oid.py 
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/[...]/oidscripts/debuggers/lldbbridge.py", line 84, in event_loop
    self._event_handler.stop_handler()
AttributeError: 'NoneType' object has no attribute 'stop_handler'

[OpenImageDebugger] Info: Could not activate hooks for any IDEs
Stop hook #1 added.

from openimagedebugger.

csantosbh avatar csantosbh commented on June 9, 2024

I have a feeling this is due to an asynchronous call to stop_handler being made before some initialisation code is run. I've pushed a potential fix for this issue to the master branch. If you have a chance to test it, please let me know how that performs for you.

from openimagedebugger.

MaxDilling avatar MaxDilling commented on June 9, 2024

Thank you! It's working now.

At least in LLDB. XCode is freezing 0% CPU as soon as I hit a break point. Do you know what that could be?
And is that something I can contribute to? Xcode support would help me a lot. I have very good knowledge of C ++, but unfortunately I hardly know anything about LLDB.

Also to compile OID I had to remove 'src/oid bridge/python2' from 'oid.pro' and add '$$SCRIPT_INSTALLS' in 'python3.pro' as Catalina doesn't come with Python 2 out of the box.

from openimagedebugger.

brunoalr avatar brunoalr commented on June 9, 2024

I will close this issue due to inactivity. @CanCanZeng @MaxDilling, feel free to reopen later it if you need more information.

from openimagedebugger.

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.