Re: [Pyobjc-dev] using objc.inject
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2009-08-11 14:42:53
|
On 11 Aug, 2009, at 13:43, James R Eagan wrote: > Hi Dan, > > I actually use objc.inject for a few projects, and it's a great > debugging tool. I believe that your problem looks more like a bug > in the InjectInterpreter code rather than in the lower-level > objc.inject code (which works great!). In particular, try changing > line 365 of InjectInterpreterPlugin.py from NSAnyEventMask to > NSUIntegerMax. Objc.inject will go away in PyObjC 2.2. There are two reasons for that (as noted a while back): 1) objc.inject does not support 64-bit targets, and I don't have the time or inclination to try to add that support. Adding this requires low-level ABI hackery. 2) objc.inject doesn't really belong in PyObjC anyway, its functionality is orthogonal to the rest of PyObjC. > > Logically, the use of NSAnyEventMask is correct in the above code. > On the PyObjC side, however, it's a signed integer (at least in the > PyObjC that comes with Leopard) instead of an unsigned integer. > That's why NSUIntegerMax is functionally correct (even if logically > incorrect) here. As for why NSAnyEventMask is signed instead of > unsigned, that might be a bug in PyObjC. Maybe. > > >>> NSUIntegerMax > 4294967295L > >>> NSAnyEventMask > -1 > >>> struct.unpack('L', struct.pack('l', NSAnyEventMask))[0] # cast > to unsigned > 4294967295L Cocoa's header files are terribly confused about the semantics of 'enum' values. In particular, AFAIK the C standard says that enum's are basicly an alias for 'int' while the Cocoa header files assume that you can define unsigned or "long long" constants using enum definitions, e.g.: enum { NSAnyEventMask = 0xffffffffU }; The Cocoa headers seem to assume that 'NSAnyEventMask' is an unsigned value, while in reality this is a signed value as can be seen by compiling a test program like this: /* printtype.m */ #include <stdio.h> #import <Cocoa/Cocoa.h> int main(void) { printf("typestr: %s\n", @encode(__typeof__(NSAnyEventMask))); return 0; } /* EOF */ Luckily PyObjC knows about this problem and should automaticly do the right thing here, that is: it will automaticly perform the cast to unsigned where needed. Ronald > > Cheers! > James > > Le 29 juil. 09 à 18:18, Daniel Ashbrook a écrit : > >> Re: "does anyone use objc.inject" from a few months ago, I think I >> would like to. I'm hoping to get at the internals of a program and >> extract some hard-to-get-at information. However, trying the >> InjectInterpreter example code doesn't seem to work, so any hints >> would be appreciated. Doing: >> >> sudo python test.py 71755 >> >> (where 7155 is the pid of TextEdit) returns without comment, but >> prints to the system log: >> >> TextEdit[71755]: InjectInterpreterPlugin has encountered a fatal >> error, and will now terminate. >> TextEdit[71755]: An uncaught exception was raised during execution of >> the main script:^M^MSystemError: NULL result without error in >> PyObject_Call^M^MThis may mean that an unexpected error has occurred, >> or that you do not have all of the dependencies for this bundle. >> [0x0-0x48d48d].com.apple.TextEdit[71755]: Traceback (most recent call >> last): >> [0x0-0x48d48d].com.apple.TextEdit[71755]: File "/tmp/ >> InjectInterpreter/dist/InjectInterpreterPlugin.plugin/Contents/ >> Resources/__boot__.py", line 23, in <module> >> [0x0-0x48d48d].com.apple.TextEdit[71755]: >> _run('InjectInterpreterPlugin.py') >> [0x0-0x48d48d].com.apple.TextEdit[71755]: File "/tmp/ >> InjectInterpreter/dist/InjectInterpreterPlugin.plugin/Contents/ >> Resources/__boot__.py", line 20, in _run >> [0x0-0x48d48d].com.apple.TextEdit[71755]: execfile(path, >> globals(), globals()) >> [0x0-0x48d48d].com.apple.TextEdit[71755]: File "/tmp/ >> InjectInterpreter/dist/InjectInterpreterPlugin.plugin/Contents/ >> Resources/InjectInterpreterPlugin.py", line 187, in <module> >> [0x0-0x48d48d].com.apple.TextEdit[71755]: class >> PyInterpreter(NSTextView): >> [0x0-0x48d48d].com.apple.TextEdit[71755]: SystemError: NULL result >> without error in PyObject_Call >> >> Any hints? >> >> Thanks, >> >> >> dan >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports >> 2008 30-Day >> trial. Simplify your report design, integration and deployment - >> and focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |