Skip to content

Instantly share code, notes, and snippets.

@khuey
Created January 23, 2017 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khuey/5b0a7d0cc68360e85cd31c67b0c0b0e7 to your computer and use it in GitHub Desktop.
Save khuey/5b0a7d0cc68360e85cd31c67b0c0b0e7 to your computer and use it in GitHub Desktop.
This C++
stacks.h
void look_at_the_stack_here(void);
inline void inlined_different_file(void) {
look_at_the_stack_here();
}
inline void inlined_separate_decl(void);
stacks_inl.h
inline void inlined_separate_decl(void) {
look_at_the_stack_here();
}
stacks.cpp
#include "stacks.h"
#include "stacks_inl.h"
void look_at_the_stack_here(void) {
raise(/* signal */);
}
void simple_call(void) {
look_at_the_stack_here();
}
inline void inlined_same_file(void) {
look_at_the_stack_here();
}
inline void inlined_same_file_two(void) {
simple_call();
}
int main(void) {
simple_call();
inlined_same_file();
inlined_same_file_two();
inlined_different_file();
inlined_separate_decl();
return 0;
}
Produces the DWARF line number program:
.debug_line: line number info for a single cu
Source lines (from CU-DIE at .debug_info offset 0x0000000b):
<pc> [row,col] NS BB ET PE EB IS= DI= uri: "filepath"
NS new statement, BB new basic block, ET end of text sequence
PE prologue end, EB epilogue begin
IA=val ISA number, DI=val discriminator value
0x00400977 [ 6, 0] NS uri: "stacks.h"
0x0040097b [ 7, 0] NS
0x00400980 [ 8, 0] NS
0x00400983 [ 8, 0] NS ET
0x00400983 [ 4, 0] NS uri: "stacks_inl.h"
0x00400987 [ 5, 0] NS
0x0040098c [ 6, 0] NS
0x0040098f [ 6, 0] NS ET
0x00400936 [ 6, 0] NS uri: "stacks.cpp"
0x0040093a [ 7, 0] NS
0x00400944 [ 8, 0] NS
0x00400947 [ 10, 0] NS
0x0040094b [ 11, 0] NS
0x00400950 [ 12, 0] NS
0x00400953 [ 22, 0] NS
0x00400957 [ 23, 0] NS
0x0040095c [ 24, 0] NS
0x00400961 [ 25, 0] NS
0x00400966 [ 26, 0] NS
0x0040096b [ 27, 0] NS
0x00400970 [ 28, 0] NS
0x00400975 [ 29, 0] NS
0x00400977 [ 29, 0] NS ET
0x0040098f [ 14, 0] NS
0x00400993 [ 15, 0] NS
0x00400998 [ 16, 0] NS
0x0040099b [ 16, 0] NS ET
0x0040099b [ 18, 0] NS
0x0040099f [ 19, 0] NS
0x004009a4 [ 20, 0] NS
0x004009a7 [ 20, 0] NS ET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment