1

I need to trace my program. I made symbolic breakpoint:

enter image description here

Full string is:

"Class name is @*(char*)object_getClassName(*(long*)($esp+4))@"

But instead full class name I have only first one symbol on console i.e:

"Class name is 'U'"

Why? Have you any idea?

IDE : Xcode 4.6.2. LLDB.

stosha
  • 2,108
  • 2
  • 27
  • 29

1 Answers1

2

From the screenshot it seems that you have an extra * before the (char *). That dereferences the string to its first character.

UPDATE: The log message

Class name is @(char*)object_getClassName(*(long*)($esp+4))@

does also not work as intended because lldb prints the pointer value instead of the C string. As a workaround, you can use the method from https://stackoverflow.com/a/12695845/1187415:

  • Set the action to "Debugger Command" instead of "Log Message",
  • Set the debugger command to

    expr -- (void)printf("Class name is %s\n",(char *) object_getClassName(*(long*)($esp+4)))
    
Community
  • 1
  • 1
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
  • @stosha: What happens if you remove the first star: `"Class name is @(char*)object_getClassName(...)"` – Martin R May 21 '13 at 04:56
  • Removing the first star would result in the pointer of string, not an instance of string. – stosha May 21 '13 at 05:44
  • @stosha: A C string *is* a pointer (to its characters). For example, `char *str = "UIKit"` is a C string, and `*str` gives the first character `'U'`. - But my first answer does not work as I could verify now (this could be a lldb bug). I have updated the answer with a possible workaround. – Martin R May 21 '13 at 06:07
  • It should be noted that if you try this on a device you'll get an error. $esp is an x86 register. – Snowcrash Mar 12 '15 at 07:49
  • @SnowCrash: That is correct. For arm and x86_64 one can use $arg1, compare http://stackoverflow.com/a/16346300/1187415. – Martin R Mar 12 '15 at 08:08