Closed frnkwtzl closed 8 months ago
IIRC, recent macOS has process space protection that prevents normal processes from attaching to other normal processes in different process spaces, even if run by the same user. This also affects tools like gdb
, for example.
AIUI there are ways to override this protection, but the simplest solution is often to simply launch the process-to-be-inspected as a child of the debugging tool. That keeps it in the same process space, and should make it inspectable.
If you run GammaRay itself first, and then use its "Launch" tab to start /testbin/minimalwidgetapplication
as a child of the GammaRay process, does that work?
Shoot, sorry, I missed that you'd already covered that:
This happens with any access mode option selected, and also when attempting to launch (rather than attach to) minimalwidgetapplication. I didn't manage to attach to or launch any Qt application either.
I tracked down a discussion I recalled having a while back regarding how this has to be handled for gdb
:
https://gist.github.com/mike-myers-tob/9a6013124bad7ff074d3297db2c98247
Basically, the binary has to be codesigned (a local certificate is fine), and it has to be configured with a set of entitlements that permit debugging of other processes, for it to be usable in macOS 11+. I would not be at all surprised if the same is true of GammaRay.
After codesigning
<build directory>/GammaRay.app/Contents/MacOS/gammaray
and
<build directory>/GammaRay.app/Contents/MacOS/gammaray-launcher
,
and running
<build directory>/GammaRay.app
(from Finder, not from Qt Creator), I was able to launch and attach to
<build directory>//testbin/minimalwidgetapplication
as well as launch
<build directory>//testbin/minimalcoreapplication
.
The latter didn't display a GUI of its own, though. Not sure if this is to be expected, but at least I'm beginning to get somewhere. Will proceed to introspecting custom projects (once I figured out how to build an executable from a Qt for Python Qt Quick Project).
I followed the instructions in GammaRay Tutorials (Part 2), i.e. built GammaRay from Git Clone with Compiler Kit Qt 6.5.4 for macOS, build configuration release, using Qt Creator 12.0.2 on a Mac Mini with Apple M2 Pro Chip running macOS Sonoma (14.2.1). This resulted in GammaRay 3.0.95 (revision: 1dbceb189). At some point of this process I selected the first entry of this list: I launched/testbin/minimalwidgetapplication
Then I ran GammaRay – gammaray-launcher from within Qt Creator.
After clicking Attach GammaRay terminated immediately, with Qt Creator's Application Output printing
This happens with any access mode option selected, and also when attempting to launch (rather than attach to) minimalwidgetapplication. I didn't manage to attach to or launch any other Qt application either.
I am new to all this, so please be gentle with my verboseness as well as omissions. I'll be happy to run more tests or provide additional information as needed.