Created
June 25, 2018 20:07
-
-
Save dcci/dcf74f683248c1a5649f2da9ab14e18b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davide@Davidinos-Mac-Pro ~/w/l/b/bin> ./clang ./pat.c -o pat -O1 -g | |
davide@Davidinos-Mac-Pro ~/w/l/b/bin> cat pat.c | |
int f(int x) { | |
asm(""); | |
return 0; | |
} | |
__attribute__((noinline)) | |
int g(int x) { | |
return x; | |
} | |
int main() { | |
int patatino = g(23); | |
return f(patatino); | |
} | |
davide@Davidinos-Mac-Pro ~/w/l/b/bin> ./lldb ./pat | |
(lldb) target create "./pat" | |
Current executable set to './pat' (x86_64). | |
(lldb) b main | |
Breakpoint 1: where = pat`main + 4 at pat.c:13, address = 0x0000000100000fa4 | |
(lldb) r | |
Process 12229 launched: '/Users/davide/work/llvm-monorepo/build-release/bin/pat' (x86_64) | |
pat was compiled with optimization - stepping may behave oddly; variables may not be available. | |
Process 12229 stopped | |
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 | |
frame #0: 0x0000000100000fa4 pat`main at pat.c:13 [opt] | |
10 | |
11 int main() { | |
12 int patatino = g(23); | |
-> 13 return f(patatino); | |
14 } | |
(lldb) frame var patatino | |
(int) patatino = <no location, value may have been optimized out> | |
(lldb) s | |
Process 12229 stopped | |
* thread #1, queue = 'com.apple.main-thread', stop reason = step in | |
frame #0: 0x0000000100000f84 pat`f(x=1) at pat.c:3 [opt] | |
1 int f(int x) { | |
2 asm(""); | |
-> 3 return 0; | |
4 } | |
5 | |
6 __attribute__((noinline)) | |
7 int g(int x) { | |
(lldb) frame var x | |
(int) x = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment