How to change variables value while debugging with LLDB in Xcode?

前端 未结 3 502
南笙
南笙 2020-11-30 16:28

In Xcode, GDB allows you to change local variables while debugging (see how to change NSString value while debugging in XCode?). Does LLDB offer a similar functionality? If

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 17:04

    expr myString = @"Foo"
    

    (lldb) help expr
    Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope. This command takes 'raw' input (no need to quote stuff).

    Syntax: expression --

    Command Options Usage: expression [-f ] [-G ] [-d ] [-u ] -- expression [-o] [-d ] [-u ] -- expression

       -G   ( --gdb-format  )
            Specify a format using a GDB format specifier string.
    
       -d   ( --dynamic-value  )
            Upcast the value resulting from the expression to its dynamic type
            if available.
    
       -f   ( --format  )
            Specify a format to be used for display.
    
       -o  ( --object-description )
            Print the object description of the value resulting from the
            expression.
    
       -u   ( --unwind-on-error  )
            Clean up program state if the expression causes a crash, breakpoint
            hit or signal.
    

    Examples:

    expr my_struct->a = my_array[3]
    expr -f bin -- (index * 8) + 5
    expr char c[] = "foo"; c[0]

    IMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options you must use ' -- ' between the end of the command options and the beginning of the raw input.

    'expr' is an abbreviation for 'expression'

提交回复
热议问题