Search code examples
printingparameterslldb

how to print paramters with lldb?


I want to use lldb to output a parameter passed to a function call.

with AndroidStudio lldb NDK

int aaaaaa(int a, int b) {
    int rrr = a + b; 
    return rrr;
}
   int x = 111;
    int y = 222;
    int eee = aaaaaa(x,y);
 // I know that print x can output the correct result, but I want to 
 // output the result of x through the register, what should I do?

I used the second code above to call the function. I want to print the x and y values using lldb. When I use print $ebp+8 , the result is not correct.

How can I print out 111 using the lldb command?

What is the correct lldb command?

this is a image link to show my means http://note.youdao.com/noteshare?id=7adb0c6fd965d26553c6bbb05896721c


Solution

  • I'm not sure what you are trying to achieve so I might not be answering your question...

    But if you are at the start of the line that calls aaaaaa here:

    int eee = aaaaaa(x,y);
    

    then x probably hasn't been copied into the argument passing location yet - that's part of the code that belongs to this source line. You could look at the disassembly to check that. So if you want to see the value copied into the passing location you will have to step by instruction in this source line to get to the place where the value is copied from the stack to the passing register/stack slot.

    Otherwise you can step into aaaaaa and if you stop right on entry to the function the value will also still be in the passing location.