cocoa - How to print a NSString from a DTrace script -
It is asking the same thing, but when I try to do: It was not working. Arg2 should be aware of NSString. I got it: NSWindow -setTitle: 100685240 7fff92d82f73 7fff78a6eb80 string addr = 7fff8e7e83b9 string val = window dtrace: enable probe ID error 5 (ID 35,737: objc9434: NSWindow: -setTitle :: Entry ): DIF invalid address (0x6c007400690074) offset 24 you can handle NSString of MacRoman or ASCII encoding - basically need complex (to worry any about the Encoding from DTrace Attitude) Your question is really the same or not, depends on the internal representation or an NSString is similar to a CFStringRef I do not know, and I hope someone else can explain, but I suspect that the answer is that two different shows D script in response to another question that CFStringRef a character Pointer , but using Gdb shows an NSString this Looks longer: Here is a related script in verb: If you are inspecting 32-bit process then
Typedef long ptr_t; ObjC $ target: NSWindow: -setTitle: entry {printf ( "% 30% 10s% x% x% x \ n", probemod, probefunc, arg0, ARG1, ARG2); This- & gt; Str = * (ptr_t *) duplicate (arg2 + 2 * sizeof (ptr_t), size (ptr_t)); Printf ("string ADR =% p \ n", this-> str); Printf ("string val =% s \ n", copinist (it-> str)); }
struct NSString {uintptr_t pad [2]; Four names [1]; / * Variable length array * /};
bash-3.2 # cat title. D type typhus strait {uintptr_t pad [2]; Four names [1]; } NSString_t; Objc $ Target: NSWindow: -setTitle ?: Entry {self-> name = (UITPrint_T) arg2 + offsetof (NSString_t, name); Printf ("name =% s \ n", copyinstr (self-> gt;)); } Bash-3.2 # ps -ef | Fgrep -i Firefox 501 318 9 204 0: 01.22 ?? 0: 04.48 /opt/Applications/Firefox.app/Contents/MacOS/firefox-psn_0_27167207 0 32,045 31,422 0 0: 00.05 ttys000 0: 00.06 fgrep I Firefox Bash-3.2 # dtrace -arch x86_64 -Cqs title.d -p 31,895 Name = Mozilla Firefox Name = New Tab Name = New Tab Name = Mozilla Firefox Name = New Tab ^ c bash-3.2 #
Use the -arch I386 and dtrace (1) indicator indicator will adjust its position of size appropriately.
Comments
Post a Comment