6

Are there any useful snippets or Gdb functions that you guys normally use to print out Unicode strings? I'm trying to debug Mach-O binaries and x/s seems to be printing out junk. I believe the default encoding for Objective C strings is UTF-16.

6
  • Borderline off topic. Debuggers are dual use, but this question is definitely borderline since you debug, i.e. you forward engineer code - and state that. Still +1 because it's interesting.
    – 0xC0000022L
    Apr 19, 2013 at 14:18
  • 3
    @0xC0000022L I don't see any sign that blahfish isn't reverse engineering an unknown binary. Apr 21, 2013 at 9:48
  • @0xC0000022L Thanks for your comment. Im curious, I don't understand why a question on debuggers is closed off as off-topic and not related to reverse engineering. Its dynamic analysis, the way i see it. Am I missing something?
    – user1743
    Apr 22, 2013 at 4:07
  • 1
    @blahfish: a.) this was a comment and I didn't flag this way, in fact I voted it up, a mod closed it, ask him/her and b.) yes, I maintain that this is borderline off topic, because this could be asked on StackOverflow without problem and answered by bus loads of programmers, whereas the same could not be said of actual RCE problems. But then, you are welcome to join the discussion on meta.RE.SE to contribute your opinion and help shape the community further ;)
    – 0xC0000022L
    Apr 22, 2013 at 12:45
  • 1
    @0xC0000022L Gotcha, you do have valid points there, thanks!
    – user1743
    Apr 23, 2013 at 1:59

1 Answer 1

4

If you think the encoding is wrong then you can try these 2 things:

Each time you specify a unit size with x, that size becomes the default unit the next time you use x ... Use x /hs to display 16-bit char strings

gdb has no way to automatically recognize which character set the inferior program uses; you must tell it, using the set target-charset command, described below.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.