문제

gdb의 Objective-C 개체에 메시지를 보내려고 합니다.

(gdb) p $esi
$2 = (void *) 0x1268160
(gdb) po $esi
<NSArray: 0x1359c0>
(gdb) po [$esi count]
Target does not respond to this message selector.

나는 그것에 어떤 메시지도 보낼 수 없습니다.뭔가 빠졌나요?정말 기호나 다른 것이 필요한가요?

도움이 되었습니까?

해결책

gdb를 재정의하고 개체에 메시지를 보내야 하는 경우, PerformSelector를 사용할 수 있습니다.

(gdb) print (int)[receivedData count]
Target does not respond to this message selector.

(gdb) print (int)[receivedData performSelector:@selector(count) ]
2008-09-15 00:46:35.854 Executable[1008:20b] *** -[NSConcreteMutableData count]:
unrecognized selector sent to instance 0x105f2e0

인수를 전달해야 하는 경우 withObject를 사용하세요.

(gdb) print (int)[receivedData performSelector:@selector(count) withObject:myObject ]

다른 팁

캐스팅해야 할 수도 있나요? $esi?

p (NSUInteger)[(NSArray *)$esi count]

@[존 칼스비크]

그런 다음 기호 누락에 대해 불평합니다.

(gdb) p (NSUInteger)[(NSObject*)$esi retainCount]
No symbol table is loaded.  Use the "file" command.
(gdb) p [(NSArray *)$esi count]
No symbol "NSArray" in current context.

Foundation에 대한 기호를 로드하려고 했습니다.

(gdb) add-symbol-file /System/Library/Frameworks/Foundation.framework/Foundation 
add symbol table from file "/System/Library/Frameworks/Foundation.framework/Foundation"? (y or n) y
Reading symbols from /System/Library/Frameworks/Foundation.framework/Foundation...done.

하지만 여전히 운이 좋지 않습니다.

(gdb) p [(NSArray *)$esi count]
No symbol "NSArray" in current context.

어쨌든, 나는 캐스팅이 이 문제에 대한 해결책이라고 생각하지 않습니다. 메시지를 보낼 수 있으려면 그것이 어떤 개체인지 알 필요가 없습니다.이상한 점은 NSCFArray를 찾았는데 메시지를 보내는 데 문제가 없다는 것입니다.

(gdb) p $eax
$11 = 367589056
(gdb) po $eax
<NSCFArray 0x15e8f6c0>(
    file://localhost/Users/ask/Documents/composing-fractals.pdf
)

(gdb) p (int)[$eax retainCount]
$12 = 1

그래서 제가 조사하던 대상에 문제가 있었던 것 같아요...또는 뭔가.

당신의 도움을 주셔서 감사합니다!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top