8

What is the equivalent lldb command to the one shown below in GDB?

(gdb) set {char}0x02ae4=0x12

The values are arbitrary examples. With GDB I was able to easily edit the byte code at a given hex address while looking at dumps in terminal. Since I upgraded to mavericks I have been trying to fiddle around with lldb a little more but I am having a tough time in a few areas. Perhaps it doesn't even possess this functionality yet..

2 Answers2

17

According to lldb-basics guide LLDB alternative is memory write.

Also (lldb) help memory write defines such an input format:

memory write -i <filename> [-s <byte-size>] [-o <offset>] <address> <value> [<value> [...]]

   -f <format> ( --format <format> )
        Specify a format to be used for display.

   -i <filename> ( --infile <filename> )
        Write memory using the contents of a file.

   -o <offset> ( --offset <offset> )
        Start writng bytes from an offset within the input file.

   -s <byte-size> ( --size <byte-size> )
        The size in bytes to use when displaying with the selected format.

So, in Your case, something like (lldb) memory write 0x02ae4 0x12 should just work.

Kamiccolo
  • 7,758
  • 3
  • 34
  • 47
  • 1
    If you need to write more than one byte use the `-s` option: `(lldb) memory write 0x02ae4 -s 2 0xFFFF` – Picard Jan 26 '22 at 10:24
4

memory write works, but you can also use the expression engine with a C expression like

p *(char*)0x2ae4 = 0x12
Jason Molenda
  • 14,835
  • 1
  • 59
  • 61
  • 1
    I assume this example should use `0x12` to be equivalent to the question's example. – ecm Jun 20 '21 at 19:58