consistent views at recommended breakpoints bis alexandre
play

Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva - PowerPoint PPT Presentation

1 Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva aoliva@redhat.com http://identi.ca/lxoliva/ http://people.redhat.com/~aoliva/ GNU Tools Cauldron, 2017 Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 2


  1. 1 Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva aoliva@redhat.com http://identi.ca/lxoliva/ http://people.redhat.com/~aoliva/ GNU Tools Cauldron, 2017

  2. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 2 Summary • Motivation • Debug Information • Statement Frontiers • Consistent Views • Representation • Status

  3. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 3 Motivation • Debugging optimized programs • Set breakpoint at a line... – Stop at a later line, results clobbered – Computation of previous lines not complete – Stepping bounces back and forth • Debuggers and Monitors • Recommended inspection points

  4. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 4 Sample Program C RISC asm (gdb) break f 1 int f(a, b, c, d) { f: ...at line 2 .loc 1 2 is stmt 1 (gdb) run r2(a) ← *(sp+ 4) 2 int x = a + b; 2 int x = a + b; r3(b) ← *(sp+ 8) (gdb) next r4(x) ← r2(a) + r3(b) 3 int y = c * d; .loc 1 3 is stmt 1 (gdb) next ⇒ r5(c) ← *(sp+12) 5 return x; 3 int y = c * d; r6(d) ← *(sp+16) (gdb) print a r7(y) ← r5(c) * r6(d) 1 4 x -= y; # .loc 1 4 is stmt 1 (gdb) print b 2 .loc 1 5 is stmt 1 (gdb) print x 5 return x; r1(x) ← r4(x) - r7(y) 3 6 } ret

  5. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 5 Optimization Before sched After sched 3 r5(c) ← *(sp+12) 3 r6(d) ← *(sp+16) r2(a) ← *(sp+ 4) 2 2 r2(a) ← *(sp+ 4) r3(b) ← *(sp+ 8) 2 2 r3(b) ← *(sp+ 8) 3 r7(y) ← r5(c) * r6(d) ⇒ r4(x) ← r2(a) + r3(b) 2 2 r4(x) ← r2(a) + r3(b) r5(c) ← *(sp+12) 3 r6(d) ← *(sp+16) 3 r7(y) ← r5(c) * r6(d) 3 r1(x) ← r4(x) - r7(y) 5 5 r1(x) ← r4(x) - r7(y) ret 5 5 ret

  6. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 6 Line Numbers .loc 1 3 is stmt 1 (gdb) b f 3 r5(c) ← *(sp+12) r5(c) ← *(sp+12) at line 3 3 r6(d) ← *(sp+16) r6(d) ← *(sp+16) (gdb) run .loc 1 2 is stmt 1 3 int y = 2 r2(a) ← *(sp+ 4) r2(a) ← *(sp+ 4) (gdb) n 2 r3(b) ← *(sp+ 8) r3(b) ← *(sp+ 8) 2 int x = .loc 1 3 is stmt 1 (gdb) n 3 r7(y) ← r5(c) * r6(d) r7(y) ← r5(c) * r6(d) ⇒ 3 int y = .loc 1 2 is stmt 1 (gdb) p x 2 r4(x) ← r2(a) + r3(b) r4(x) ← r2(a) + r3(b) optimized # .loc 1 3 is stmt 1 (gdb) n # .loc 1 4 is stmt 1 2 int x = .loc 1 5 is stmt 1 (gdb) n 5 r1(x) ← r4(x) - r7(y) r1(x) ← r4(x) - r7(y) 5 return 5 ret ret

  7. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 7 Variable Tracking at Assignments # a ⇒ *(sp+ 4) (gdb) b f 1 f(a,b,c,d) { ... .loc 1 3 is stmt 1 at line 3 # a ⇒ a ... .loc 1 2 is stmt 1 (gdb) run # b ⇒ b 8 r2(a) ← *(sp+ 4) 3 int y = # c ⇒ c 12 r3(b) ← *(sp+ 8) (gdb) u 4 # d ⇒ d .loc 1 3 is stmt 1 5 return 2 int x = a + b; 16 r7(y) ← r5(c) * r6(d) (gdb) p a # x ⇒ x .loc 1 2 is stmt 1 ⇒ 1 20 r4(x) ← r2(a) + r3(b) 3 int y = c * d; (gdb) p b # x ⇒ r4 (x) # y ⇒ y 2 4 x -= y; # y ⇒ r7(y) (gdb) p y # x ⇒ x # x ⇒ r4(x) - r7(y) 12 5 return x; .loc 1 5 is stmt 1 (gdb) p x 24 r1(x) ← r4(x) - r7(y) 6 } -9 28 ret

  8. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 8 Statement Frontier Notes ... # d ⇒ *(sp+16) .loc 1 3 is stmt 0 (gdb) b f ... .loc 1 2 is stmt 1 at line 2 ... # d ⇒ d 8 r2(a) ← *(sp+ 4) (gdb) run 2 # STMT 12 r3(b) ← *(sp+ 8) 2 int x = a + 2 int x = a + b; .loc 1 3 is stmt 0 (gdb) n # x ⇒ x 16 r7(y) ← r5(c) * r6(d) 5 return x; 3 # STMT .loc 1 2 is stmt 0 (gdb) b 3 3 int y = c * d; 20 r4(x) ← r2(a) + r3(b) at line 5 ⇒ # y ⇒ y # x ⇒ r4(x) (gdb) set x=3 4 # STMT .loc 1 3 is stmt 1 not an lvalue 4 x -= y; — # y ⇒ r7(y) # x ⇒ x .loc 1 4 is stmt 1 loclist(x): 5 # STMT — # x ⇒ r4(x) - r7(y) 24 24 r4 5 return x; 24 32 r4 - r7 .loc 1 5 is stmt 1 28 32 r1 24 r1(x) ← r4(x) - r7(y) 28 ret

  9. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 9 Location View Numbering 0.0 .loc 1 3 is stmt 0 view -0 8.0: 2 int x = a + ... .loc 1 2 is stmt 1 view 0 (gdb) n 8.0 r2(a) ← *(sp+ 4) 24.0: 3 int y = c * 12.0 r3(b) ← *(sp+ 8) (gdb) set x = 175 .loc 1 3 is stmt 0 view 0 175 16.0 r7(y) ← r5(c) * r6(d) (gdb) n .loc 1 2 is stmt 0 view 0 24.1: 4 x -= y; 20.0 r4(x) ← r2(a) + r3(b) (gdb) n # x ⇒ r4(x) 24.2: 5 return x; (gdb) b 4 .loc 1 3 is stmt 1 view .lvui at line 4, 24.1 24. lvui # y ⇒ r7(y) .loc 1 4 is stmt 1 view .lvuj 24. lvuj # x ⇒ r4(x) - r7(y) locviewlist(x): 24 .0 24 .2 r4 .loc 1 5 is stmt 1 view .lvuk 24 .2 32 .0 r4 - r7 24. lvuk r1(x) ← r4(x) - r7(y) 28.0 ret 28 .0 32 .0 r1

  10. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 10 Location View Numbering • Compiler- or assembler-computed views • Reinterpreting line-number programs – Change PC → reset view – Same PC → incremented view – Exception: DW LNS fixed advance pc # at view N .balign 32 # or asm # at view N+1 or 0?

  11. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 11 DWARF v5- GNU Extensions DIE for y : LLSTy DW AT location LVSTy DW AT GNU locviews 8.0 r2(a) ← *(sp+ 4) DIE for x : 12.0 r3(b) ← *(sp+ 8) LLSTx DW AT location 16.0 r7(y) ← r5(c) * r6(d) LVSTx DW AT GNU locviews 20.0 r4(x) ← r2(a) + r3(b) LVSTy: LLSTy: # x ⇒ r4(x) 1 0 24 32 r7 24. 0 # y ⇒ r7(y) 0 0 24. 1 # x ⇒ r4(x) - r7(y) LVSTx: LLSTx: 24. 2 r1(x) ← r4(x) - r7(y) 0 2 24 24 r4 28.0 ret 2 0 24 32 r4 - r7 0 0 28 32 r1 0 0

  12. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 12 DWARF v6+ Proposal DIE for y : LLSTy location DIE for x : 8.0 r2(a) ← *(sp+ 4) LLSTx location 12.0 r3(b) ← *(sp+ 8) 16.0 r7(y) ← r5(c) * r6(d) LLSTy: 20.0 r4(x) ← r2(a) + r3(b) view pair .uleb128 1, 0 # x ⇒ r4(x) start end 24 32 r7 24. 0 # y ⇒ r7(y) end 24. 1 # x ⇒ r4(x) - r7(y) LVSTx: 24. 2 r1(x) ← r4(x) - r7(y) view pair .uleb128 0, 2 28.0 ret start end 24 24 r4 view pair .uleb128 2, 0 start end 24 32 r4 - r7 no view pair ⇒ implied 0, 0 → start end 28 32 r1 end

  13. Consistent Views at Recommended Breakpoints (bis) Alexandre Oliva 13 Conclusion • Inlined Entry Point Markers; other markers? • Views in other addresses and ranges • GNU binutils 2.30 (master, users/aoliva/SFN) • GCC 8? (GIT branch aoliva/SFN) • GDB, Systemtap, ...? Thank you!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend