南京大学:《软件工程研究导引 Introduction to Software Engineering Research》课程教学资源(课件讲稿)07 Tracing, Profiling, and Dynamic Program Analysis

Dynamic Program Analysis Jun Ma majun@nju.edu.cn
Dynamic Program Analysis majun@nju.edu.cn Jun Ma

Overview Static analysis A program that takes programs as input and produces useful results(without executing it). Dynamic analysis A program that monitors and alters program execution to produce useful results
Overview Static analysis A program that takes programs as input and produces useful results (without executing it). Dynamic analysis A program that monitors and alters program execution to produce useful results

Computer Systems as State Machine
Computer Systems as State Machine

Computer Systems .. Computer system state machine of(memory,registers)whose running is driven by instructions. (Because computer systems are simply circuits.) M,R -instruction-M',R' instruction M",R" …instructions.-pM,R" This model works for user-level programs(syscall is a special non-deterministic instruction) operating systems(may have external interrupts) concurrent/multiprocessor systems (we can choose a thread for executing an instruction)
Computer Systems … Computer system = state machine of (memory, registers) whose running is driven by instructions. (Because computer systems are simply circuits.) M,R instruction M',R' instruction M'',R'' instructions M''',R''' This model works for user-level programs (syscall is a special non-deterministic instruction) operating systems (may have external interrupts) concurrent/multiprocessor systems (we can choose a thread for executing an instruction)

Dynamic Analysis A program that monitors and alters program execution to produce useful results. That is,a function f(T)to produce useful results given the execution trace T of a state machine(program/computer system). Only provides useful results for the given T usually complete but unsound complements static analyses SE tasks tolerate unsound and incomplete analyses as long as results are useful in engineering PL guys don't like this
Dynamic Analysis A program that monitors and alters program execution to produce useful results. That is, a function to produce useful results given the execution trace of a state machine (program/computer system). Only provides useful results for the given usually complete but unsound complements static analyses SE tasks tolerate unsound and incomplete analyses as long as results are useful in engineering PL guys don’t like this f(τ ) τ τ

Debuggers
Debuggers

The GNU Project Debugger(GDB) GDB,the GNU Project debugger,allows you to see what is going on "inside"another program while it executes-or what another program was doing at the moment it crashed. Start your program,specifying anything that might affect its behavior. Make your program stop on specified conditions. Examine what has happened when your program has stopped. Change things in your program,so you can experiment with correcting the effects of one bug and go on to learn about another
The GNU Project Debugger (GDB) GDB, the GNU Project debugger, allows you to see what is going on “inside” another program while it executes – or what another program was doing at the moment it crashed. Start your program, specifying anything that might affect its behavior. Make your program stop on specified conditions. Examine what has happened when your program has stopped. Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another

GDB's Offer Lots of commands Execution controlr,c,f,n,s,si,.. Breakpoints b,hb,wa,... ·Program state display`p,x,i,bt`,… Program state modification set,... Black magic -reverse debugging: ■`record,rc,rn,rsi, Suffices for anything GDB captures the entire "state transition"procedure of a process
GDB’s Offer Lots of commands Execution control r, c, f, n, s, si ,… Breakpoints b, hb, wa , … Program state display p, x, i, bt , … Program state modification set , … Black magic - reverse debugging: record, rc, rn, rsi , … Suffices for anything GDB captures the entire “ state transition” procedure of a process ` ` ` ` ` ` ` ` ` `

Debugger is ALL Dynamic Analyses Any practical dynamic analysis is a "simplified"(and more efficient)debugger. Virtually,we can do any observation or perturbation on a debugger Understanding program states info inferiors;thread 1;info registers;x/i srip Modifying program states ■`set var=value But single-step execution incurs 1000X slowdown and GB/s instruction log
Debugger is ALL Dynamic Analyses Any practical dynamic analysis is a “ simplified” (and more efficient) debugger. Virtually, we can do any observation or perturbation on a debugger Understanding program states info inferiors; thread 1; info registers; x/i $rip Modifying program states set var = value But single-step execution incurs 1000X slowdown and GB/s instruction log ` ` ` `

Implementing GDB The fundamental problem: How to pause program execution at an instruction (address)or statement? Dynamic program instrumentation patch the instruction!(quite clever idea) make the code writable(thus cannot breakpoint on ROM addresses) ■`mprotect() patch the instruction with a“debugger trap” int $3 (0xcc for x86)or 'ebreak (for risc-v) -OS will send a signal to the parent process(gdb) restore the instruction after hitting the breakpoint
Implementing GDB The fundamental problem: How to pause program execution at an instruction (address) or statement? Dynamic program instrumentation patch the instruction! (quite clever idea) make the code writable (thus cannot breakpoint on ROM addresses) mprotect() patch the instruction with a “debugger trap” int $3 ( 0xcc for x86) or ebreak (for risc-v) OS will send a signal to the parent process (gdb) restore the instruction after hitting the breakpoint ` ` ` ` ` ` ` `
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 南京大学:《软件工程研究导引 Introduction to Software Engineering Research》课程教学资源(课件讲稿)06 Static Program Analysis.pdf
- 南京大学:《软件工程研究导引 Introduction to Software Engineering Research》课程教学资源(课件讲稿)04 Conduct Rigorous and Scientific Research.pdf
- 《中国科学》:可成长软件理论方法和实现技术——从范型到跨越.pdf
- 计算机科学与技术(参考文献)Synthesizing Object State Transformers for Dynamic Software Updates.pdf
- 南京大学:《编译原理 Principles and Techniques of Compilers》课程教学电子教案(课件讲稿,2023)第三章 词法分析.pdf
- 南京大学:《编译原理 Principles and Techniques of Compilers》课程教学电子教案(课件讲稿,2023)第一章 引论(许畅).pdf
- 计算机科学与技术(参考文献)Pores-Preserving Face Cleaning Based on Improved Empirical Mode Decomposition.pdf
- 计算机科学与技术(参考文献)PG_2012_Photo_Optimization.pdf
- 计算机科学与技术(参考文献)Object Tracking Using Learned Feature Manifolds.pdf
- 计算机科学与技术(参考文献)Mesh-Guided Optimized Retexturing for Image and Video.pdf
- 计算机科学与技术(参考文献)Multi-view Video Summarization.pdf
- 计算机科学与技术(参考文献)Learning-Based 3D Face Detection Using Geometric Context.pdf
- 计算机科学与技术(参考文献)Image and Video Retexturing.pdf
- 计算机科学与技术(参考文献)Image Completion based on Views of Large Displacement.pdf
- 计算机科学与技术(参考文献)Fuzzy Quantization Based Bit Transform for Low Bit-Resolution Motion Estimation.pdf
- 计算机科学与技术(参考文献)Ensemble of trusted firmware services based on TPM.pdf
- 计算机科学与技术(参考文献)Efficient View Manipulation for Cuboid-Structured Images.pdf
- 计算机科学与技术(参考文献)A Robust and Fast Non-local Algorithm for Image Denoising.pdf
- 计算机科学与技术(参考文献)A Novel Constrained Texture Mapping Method Based on Harmonic Map.pdf
- 计算机科学与技术教学资源(参考文献)Properties and Computations of Matrix Pseudospectra.pdf
- 南京大学:《软件工程研究导引 Introduction to Software Engineering Research》课程教学资源(课件讲稿)09 The TEX Typesetting System.pdf
- 计算机科学与技术(参考文献)An Opportunistic Resource Sharing and Topology-Aware Mapping Framework for Virtual Networks.pdf
- 计算机科学与技术(参考文献)P3 - Joint Optimization of Charger Placement and Power Allocation for Wireless Power Transfer.pdf
- 计算机科学与技术(参考文献)Virtual Network Embedding with Opportunistic Resource Sharing.pdf
- 计算机科学与技术(参考文献)Burstiness-Aware Resource Reservation for Server Consolidation in Computing Clouds.pdf
- 计算机科学与技术(参考文献)MobiCache - Cellular traffic offloading leveraging cooperative caching in mobile social networks.pdf
- 计算机科学与技术(参考文献)Efficient Data Center Flow Scheduling Without Starvation Using Expansion Ratio.pdf
- 计算机科学与技术(参考文献)Optimizing Itinerary Selection and Charging Association for Mobile Chargers.pdf
- 计算机科学与技术(参考文献)Wireless Charger Placement and Power Allocation for Maximizing Charging Quality.pdf
- 计算机科学与技术(参考文献)Opportunistic Energy-Efficient Contact Probing in Delay-Tolerant Applications.pdf
- 计算机科学与技术(参考文献)Femto-Matching - Efficient Traffic Offloading in Heterogeneous Cellular Networks.pdf
- 计算机科学与技术(参考文献)WiTrace - Centimeter-Level Passive Gesture Tracking Using OFDM signals.pdf
- 计算机科学与技术(参考文献)Femto-Matching:Efficient Traffic Offloading in Heterogeneous Cellular Networks.pdf
- 计算机科学与技术(参考文献)Understanding and Modeling of WiFi Signal Based Human Activity Recognition.pdf
- 计算机科学与技术(参考文献)Understanding and Modeling of WiFi Signal Based Human Activity Recognition.pdf
- 计算机科学与技术(参考文献)Keystroke Recognition Using WiFi Signals.pdf
- 计算机科学与技术(参考文献)Depth Aware Finger Tapping on Virtual Display.pdf
- 计算机科学与技术(参考文献)Device-Free Gesture Tracking Using Acoustic Signals.pdf
- 计算机科学与技术(参考文献)Device-Free Gesture Tracking Using Acoustic Signals.pdf
- 计算机科学与技术(参考文献)Depth Aware Finger Tapping on Virtual Displays.pdf