Playing with process tracing to instrument static function at runtime in EZTrace. Damien Martin-Guillerez SED

Size: px
Start display at page:

Download "Playing with process tracing to instrument static function at runtime in EZTrace. Damien Martin-Guillerez SED"

Transcription

1 Playing with process tracing to instrument static function at runtime in EZTrace Damien Martin-Guillerez SED CENTRE Inria BORDEAUX SUD-OUEST

2 INTRODUCTION EZTrace is a performance trace generator for parallel programs - 1

3 INTRODUCTION EZTrace is a performance trace generator for parallel programs It relies on the dynamic library preloading mechanism to intercept function calls and insert event logs - 1

4 INTRODUCTION EZTrace is a performance trace generator for parallel programs It relies on the dynamic library preloading mechanism to intercept function calls and insert event logs As a consequence, no instrumentation of static function, i.e. no trace for them - 1

5 INTRODUCTION EZTrace is a performance trace generator for parallel programs It relies on the dynamic library preloading mechanism to intercept function calls and insert event logs As a consequence, no instrumentation of static function, i.e. no trace for them PROCESS TRACING - 1

6 INTRODUCTION EZTrace is a performance trace generator for parallel programs It relies on the dynamic library preloading mechanism to intercept function calls and insert event logs As a consequence, no instrumentation of static function, i.e. no trace for them PROCESS TRACING - 1

7 OUTLINE 1. EZTrace insights 2. The ptrace() system call 3. Instrumentation of static functions in EZTrace 4. Technical details for the geek 5. Other architectures - 2

8 1EZTrace Insights - 3

9 EZTrace basics EZTrace is a trace generator: $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp - 4

10 EZTrace basics EZTrace is a trace generator: Look out for some events during execution and record them in a file $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp EZTrace log files (/tmp/<username>_eztrace_log_rank_<rank>) - 4

11 EZTrace basics EZTrace is a trace generator: Look out for some events during execution and record them in a file Convert them to a standard format $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp EZTrace log files (/tmp/<username>_eztrace_log_rank_<rank>) $ eztrace_convert -o myfile.paje /tmp/<username>_eztrace_log* - 4

12 EZTrace basics EZTrace is a trace generator: Look out for some events during execution and record them in a file Convert them to a standard format $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp EZTrace log files (/tmp/<username>_eztrace_log_rank_<rank>) $ eztrace_convert -o myfile.paje /tmp/<username>_eztrace_log* Paje File (or OTF) - 4

13 EZTrace basics EZTrace is a trace generator: Look out for some events during execution and record them in a file Convert them to a standard format View the events $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp EZTrace log files (/tmp/<username>_eztrace_log_rank_<rank>) $ eztrace_convert -o myfile.paje /tmp/<username>_eztrace_log* Paje File (or OTF) Visualizer (ex.: ViTE) - 4

14 EZTrace basics EZTrace is a trace generator: Look out for some events during execution and record them in a file Convert them to a standard format View the events $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp EZTrace log files (/tmp/<username>_eztrace_log_rank_<rank>) ON DYNAMIC LIBRARIES! $ eztrace_convert -o myfile.paje /tmp/<username>_eztrace_log* Paje File (or OTF) Visualizer (ex.: ViTE) - 4

15 EZTrace is good for your health You can use EZTrace to trace parallel programs in order to: Detect problems in message exchanges and in parallel algorithm Improve communication patterns Show beautiful traces of your software to the world - 5

16 EZTrace is good for your health You can use EZTrace to trace parallel programs in order to: Detect problems in message exchanges and in parallel algorithm Improve communication patterns Show beautiful traces of your software to the world You probably should not use EZTrace to: Detect general bugs like memory faults Trace non-parallel programs Show that you program has ugly traces - 5

17 EZTrace is good for your health You can use EZTrace to trace parallel programs in order to: Detect problems in message exchanges and in parallel algorithm Improve communication patterns Show beautiful traces of your software to the world You probably should not use EZTrace to: Detect general bugs like memory faults Trace non-parallel programs Show that you program has ugly traces You cannot (currently) use EZTrace to: Stop when a memory error occurs Trace your own library or non-packaged library Trace static libraries Make the coffee - 5

18 Dynamic library loading libmpi.so./toto MPI_Send() MPI_Send: - 6

19 Dynamic library preloading With an EZTrace module LD_PRELOAD= libeztrace_mpi.so./toto MPI_Send() libmpi.so MPI_Send: - 6

20 Dynamic library preloading With an EZTrace module LD_PRELOAD= libeztrace_mpi.so./toto MPI_Send() libmpi.so MPI_Send: libeztrace_mpi.so - 6

21 Dynamic library preloading With an EZTrace module LD_PRELOAD= libeztrace_mpi.so./toto MPI_Send() libmpi.so MPI_Send: libeztrace_mpi.so MPI_Send: - 6

22 Dynamic library preloading With an EZTrace module LD_PRELOAD= libeztrace_mpi.so./toto MPI_Send() libmpi.so MPI_Send: libeztrace_mpi.so MPI_Send: LOG_EVENT( In MPI_Send, ) orig_mpi_send( ) LOG_EVENT( Out MPI_Send, ) - 6

23 Dynamic library preloading With an EZTrace module LD_PRELOAD= libeztrace_mpi.so./toto MPI_Send() libmpi.so MPI_Send: libeztrace_mpi.so orig_mpi_send = MPI_Send: LOG_EVENT( In MPI_Send, ) orig_mpi_send( ) LOG_EVENT( Out MPI_Send, ) - 6

24 Dynamic library preloading With an EZTrace module LD_PRELOAD= libeztrace_mpi.so./toto MPI_Send() libmpi.so MPI_Send: libeztrace_mpi.so orig_lib = dlopen( libmpi.so, ) orig_mpi_send = dlsym(orig_lib, MPI_Send ) MPI_Send: LOG_EVENT( In MPI_Send, ) orig_mpi_send( ) LOG_EVENT( Out MPI_Send, ) - 6

25 EZTrace basics EZTrace is a trace generator: Look out for some events during execution and record them in a file Convert them to a standard format View the events $ export EZTRACE_TRACE= mpi pthread $ mpirun -np 16 `eztrace -e mpiapp` or $ eztrace pthreadapp EZTrace log files (/tmp/<username>_eztrace_log_rank_<rank>) ONLY ON DYNAMIC LIBRARIES! $ eztrace_convert -o myfile.paje /tmp/<username>_eztrace_log* Paje File (or OTF) Visualizer (ex.: ViTE) - 7

26 It is the story of a fool that says to another fool who says to another fool that - 8

27 2The ptrace() system call - 9

28 ptrace() stands for process tracing ptrace() is: A POSIX system call Extended in its Linux version A process tracing mechanism - Attach and detach a target process - Stop at each system call / each instruction of target process - Examine and modify target memory and registers #include <sys/ptrace.h> int ptrace(int requête, int pid, void* addr, void* data); man 2 ptrace - 10

29 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers Two methods: - 11

30 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers tracer pid = fork() target Two methods: - fork() and PTRACE_TRACEME - 11

31 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers tracer pid = fork() target Two methods: - fork() and PTRACE_TRACEME execve(./target, ) - 11

32 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers wait(null) tracer pid = fork() target Two methods: - fork() and PTRACE_TRACEME execve(./target, ) - 11

33 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers wait(null) tracer pid = fork() target ptrace(ptrace_traceme, 0,0,0) Two methods: - fork() and PTRACE_TRACEME execve(./target, ) - 11

34 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers wait(null) tracer pid = fork() target ptrace(ptrace_traceme, 0,0,0) Two methods: - fork() and PTRACE_TRACEME SIGTRAP execve(./target, ) - 11

35 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers wait(null) tracer pid = fork() target ptrace(ptrace_traceme, 0,0,0) Two methods: - fork() and PTRACE_TRACEME - PTRACE_ATTACH SIGTRAP execve(./target, ) tracer target ptrace(ptrace_attach, pid,0,0) - 11

36 ptrace() process attachment An attached process can be traced - Stop at each system call / each instruction of target process - Examine and modify target memory and registers wait(null) tracer pid = fork() target ptrace(ptrace_traceme, 0,0,0) Two methods: - fork() and PTRACE_TRACEME - PTRACE_ATTACH SIGTRAP execve(./target, ) Detaching using PTRACE_DETACH tracer target ptrace(ptrace_attach, pid,0,0) - 11

37 ptrace() stepping Continue until next signal ptrace(ptrace_cont, pid, NULL, NULL); ptrace(ptrace_cont, pid, NULL, (void*)_signal); - 12

38 ptrace() stepping Continue until next signal ptrace(ptrace_cont, pid, NULL, NULL); ptrace(ptrace_cont, pid, NULL, (void*)_signal); Continue until next system call - Stops at system call entry and exit ptrace(ptrace_syscall, pid, NULL, NULL); ptrace(ptrace_syscall, pid, NULL, (void*)_signal); - 12

39 ptrace() stepping Continue until next signal ptrace(ptrace_cont, pid, NULL, NULL); ptrace(ptrace_cont, pid, NULL, (void*)_signal); Continue until next system call - Stops at system call entry and exit ptrace(ptrace_syscall, pid, NULL, NULL); ptrace(ptrace_syscall, pid, NULL, (void*)_signal); Stop after next instruction ptrace(ptrace_singlestep, pid, NULL, NULL); ptrace(ptrace_singlestep, pid, NULL, (void*)_signal); - 12

40 ptrace() memory reading and altering Reading / writing target memory type_of_word data; data = ptrace(ptrace_peektext, pid, (void*)addr, NULL); ptrace(ptrace_poketext, pid, (void*)addr, (void*)data); - 13

41 ptrace() memory reading and altering Reading / writing target memory type_of_word data; data = ptrace(ptrace_peektext, pid, (void*)addr, NULL); ptrace(ptrace_poketext, pid, (void*)addr, (void*)data); Reading / writing target registers #include <sys/user.h> struct user_regs_struct regs; ptrace(ptrace_getregs, pid, NULL, (void*)(&regs)); ptrace(ptrace_setregs, pid, NULL, (void*)(&regs)); - 13

42 ptrace() memory reading and altering Reading / writing target memory type_of_word data; data = ptrace(ptrace_peektext, pid, (void*)addr, NULL); ptrace(ptrace_poketext, pid, (void*)addr, (void*)data); Reading / writing target registers #include <sys/user.h> struct user_regs_struct regs; ptrace(ptrace_getregs, pid, NULL, (void*)(&regs)); ptrace(ptrace_setregs, pid, NULL, (void*)(&regs)); Reading / writing target user data #include <sys/user.h> struct user u; ptrace(ptrace_peekuser, pid, NULL, (void*)(&u)); ptrace(ptrace_pokeuser, pid, NULL, (void*)(&u)); - 13

43 ptrace() memory reading and altering Reading / writing target memory type_of_word data; data = ptrace(ptrace_peektext, pid, (void*)addr, NULL); ptrace(ptrace_poketext, pid, (void*)addr, (void*)data); Reading / writing target registers #include <sys/user.h> struct user_regs_struct regs; ptrace(ptrace_getregs, pid, NULL, (void*)(&regs)); ptrace(ptrace_setregs, pid, NULL, (void*)(&regs)); Reading / writing target user data #include <sys/user.h> struct user u; ptrace(ptrace_peekuser, pid, NULL, (void*)(&u)); ptrace(ptrace_pokeuser, pid, NULL, (void*)(&u)); Reading target signal informations siginfo_t siginfo; data = ptrace(ptrace_getsiginfo, pid, NULL, (void*)(&siginfo)); - 13

44 3Instrumentation of static functions in EZTrace - 14

45 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3-15

46 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3 Prolog/epilog library prolog: epilog: - 15

47 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3 Insertion of the library in target memory using LD_PRELOAD Prolog/epilog library prolog: epilog: - 15

48 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3 trampoline call prolog replay call epilog Prolog/epilog library prolog: epilog: - 15

49 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3 Fetch prolog & epilog addresses by using the Binary File Descriptor library (libbfd) and by analyzing target system calls Prolog/epilog library trampoline call prolog replay call epilog prolog: epilog: - 15

50 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3 trampoline call prolog replay call epilog Allocate memory in the target process for the trampoline using the mmap(2) system call Prolog/epilog library prolog: epilog: - 15

51 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 opcode2 opcode3 trampoline call prolog replay call epilog Prolog/epilog library prolog: epilog: Tune the stack to support arguments using the AMD64 Application Binary Interface - 15

52 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 trampoline call prolog replay call epilog Prolog/epilog library prolog: epilog: - 15

53 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 trampoline call prolog replay call epilog Prolog/epilog library prolog: epilog: MPI_Send address fetched using libbfd - 15

54 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 Replay the instructions overwritten by the base trampoline trampoline call prolog replay call epilog Prolog/epilog library prolog: epilog: - 15

55 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 trampoline call prolog call replay call epilog replay: opcode1 opcode2 jmp opcode3 Prolog/epilog library prolog: epilog: - 15

56 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 trampoline call prolog call replay call epilog replay: opcode1 opcode2 jmp opcode3 Prolog/epilog library prolog: epilog: - 15

57 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 trampoline call prolog call replay call epilog replay: opcode1 opcode2 jmp opcode3 Prolog/epilog library prolog: epilog: - 15

58 How to instrument static functions? Target program call MPI_Send MPI_Send: opcode1 jmp trampoline opcode2 opcode3 trampoline call prolog call replay call epilog replay: opcode1 opcode2 jmp opcode3 Prolog/epilog library prolog: epilog: Get the size of the opcodes overwritten by the base trampoline - 15

59 4Technical details for the geek - 16

60 Technical challenges left Allocate memory in the target process Get the address of the preloaded library - The offset of the prolog and epilog inside the library are fetched with libbfd - The library loading mechanisms is spyed to find the mmaping of the library Get the size of the overwritten opcodes - 17

61 The mmap() system call The mmap() system call allocate a memory page #include <sys/mman.h> void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) man 2 mmap - 18

62 The mmap() system call The mmap() system call allocate a memory page #include <sys/mman.h> void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) man 2 mmap Can be used to map a library in memory - 18

63 The mmap() system call The mmap() system call allocate a memory page #include <sys/mman.h> void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) man 2 mmap Can be used to map a library in memory Can also be used to allocate an executable segment for the trampoline - 18

64 Calling a system call from the parent process To call mmap() to allocate memory for the trampoline, we need to: Stop the target process Replace the current instruction by an int 0x80 (syscall) Set the accumulator (rax) to the system call number Fill the other registers according to the ABI Executes two ptrace(ptrace_syscall, pid, NULL, NULL) Get the result from the registers Restores the registers and the current instruction - 19

65 Fetching the library base address The base address of a preloaded library is determined at runtime. The dlopen() mechanism do it by: - Opening the library file using the open() system call - Mapping it in memory using the mmap() system call Thus to fetch the base address: - Wait for open(«library.so», *) = fd - Wait for mmap(*, *, *, *, fd, *) = baseaddress A wait is performed using the PTRACE_SYSCALL method and by looking into registers - 20

66 Getting the overwritten opcode size Obtained by single stepping ip = 4007c6 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: - 21

67 Getting the overwritten opcode size Obtained by single stepping ip = 4007ca 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: - 21

68 Getting the overwritten opcode size Obtained by single stepping ip = 4007ca 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip += 4 [sizeof( sub $0x8, %rsp )] incr = 4 < sizeof( base trampoline ) - 21

69 Getting the overwritten opcode size Obtained by single stepping ip = 4007cd 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip += 3 [sizeof( mov %rsi, %rbx )] incr = 7 (+3) < sizeof( base trampoline ) - 21

70 Getting the overwritten opcode size Obtained by single stepping ip = 4007d0 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip += 3 [sizeof( cmp $0x3, %edi )] incr = 10 (+3) < sizeof( base trampoline ) - 21

71 Getting the overwritten opcode size Obtained by single stepping ip = 4007fa 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip += 26 [JUMP] > threshold - 21

72 Getting the overwritten opcode size Obtained by single stepping ip = 4007fa 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip += 26 [JUMP] > threshold JUMP DECODER - 21

73 Getting the overwritten opcode size Obtained by single stepping ip = 4007fa 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip += 26 [JUMP] > threshold JUMP DECODER sizeof( jmp 4007fa ) = 4-21

74 Getting the overwritten opcode size Obtained by single stepping ip = 4007d4 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip 4007d4 [4007d0 + 4] incr = 14 (+4) sizeof( base trampoline ) - 21

75 Getting the overwritten opcode size Obtained by single stepping ip = 4007d4 4007c6: sub $0x8,%rsp 4007ca: mov %rsi,%rbx 4007cd: cmp $0x3,%edi 4007d0: jmp 4007fa 4007d4: ip 4007d4 [4007d0 + 4] incr = 14 (+4) sizeof( base trampoline ) The size of instruction is now known! - 21

76 5Other architectures - 22

77 Other architectures Other CPUs 32-bit Intel Architecture is straighforward - Just a simple modification of the ABI RISC processors are easier - Simplified ABI - Fixed-size instructions And other operating system *BSD should not be a problem - The ptrace() system call changes but offers similar functionalities - The ABI compatibility needs to be verified MacOS X is problematic - 23

78 The MacOS X issue MacOS X ptrace() system call is outdated The task_for_pid() mechanism replaces it The ABI changes MacOS X has a complex capability scheme needed for tracing Even the LD_PRELOAD mechanism changes - 24

79 6Future - 25

80 In the future EZTrace will: - 26

81 In the future EZTrace will: instrument functions of static libraries, - 26

82 In the future EZTrace will: instrument functions of static libraries, instrument user-defined functions, - 26

83 In the future EZTrace will: instrument functions of static libraries, instrument user-defined functions, do it easily thanks to a module generator, BEGIN_MODULE NAME example_lib DESC "module for the example library" LANGUAGE C ID 42 int example_function2(int* array, int array_size) BEGIN RECORD_STATE("running example_function2") END END_MODULE - 26

84 In the future EZTrace will: instrument functions of static libraries, instrument user-defined functions, do it easily thanks to a module generator, and save the world BEGIN_MODULE NAME example_lib DESC "module for the example library" LANGUAGE C ID 42 int example_function2(int* array, int array_size) BEGIN RECORD_STATE("running example_function2") END END_MODULE - 26

85 In the future EZTrace will: instrument functions of static libraries, instrument user-defined functions, do it easily thanks to a module generator, and save the world BEGIN_MODULE NAME example_lib DESC "module for the example library" LANGUAGE C ID 42 int example_function2(int* array, int array_size) BEGIN RECORD_STATE("running example_function2") END END_MODULE and the ornithorhynchus - 26

86 Thank you!

Runtime Function Instrumentation with EZTrace

Runtime Function Instrumentation with EZTrace Runtime Function Instrumentation with EZTrace Charles Aulagnon, Damien Martin-Guillerez, François Rué and François Trahay 5 th Workshop on Productivity and Performance (PROPER 2012) INTRODUCTION Modern

More information

EZTrace upcoming features

EZTrace upcoming features EZTrace 1.0 + upcoming features François Trahay francois.trahay@telecom-sudparis.eu 2015-01-08 Context Hardware is more and more complex NUMA, hierarchical caches, GPU,... Software is more and more complex

More information

Applications of. Virtual Memory in. OS Design

Applications of. Virtual Memory in. OS Design Applications of Virtual Memory in OS Design Nima Honarmand Introduction Virtual memory is a powerful level of indirection Indirection: IMO, the most powerful concept in Computer Science Fundamental Theorem

More information

Memory management. Johan Montelius KTH

Memory management. Johan Montelius KTH Memory management Johan Montelius KTH 2017 1 / 22 C program # include int global = 42; int main ( int argc, char * argv []) { if( argc < 2) return -1; int n = atoi ( argv [1]); int on_stack

More information

syscall_intercept A user space library for intercepting system calls Author Name, Company Krzysztof Czuryło, Intel

syscall_intercept A user space library for intercepting system calls Author Name, Company Krzysztof Czuryło, Intel Talk syscall_intercept Title Here A user space library for intercepting system calls Author Name, Company Krzysztof Czuryło, Intel What it is? Provides a low-level interface for hooking Linux system calls

More information

Outline. 1 Details of paging. 2 The user-level perspective. 3 Case study: 4.4 BSD 1 / 19

Outline. 1 Details of paging. 2 The user-level perspective. 3 Case study: 4.4 BSD 1 / 19 Outline 1 Details of paging 2 The user-level perspective 3 Case study: 4.4 BSD 1 / 19 Some complications of paging What happens to available memory? - Some physical memory tied up by kernel VM structures

More information

CPSC 457 Principles of Operating Systems Daniel de Castro Tutorial 16: Program supervision with ptrace Expected Time: minutes March 20, 2012

CPSC 457 Principles of Operating Systems Daniel de Castro Tutorial 16: Program supervision with ptrace Expected Time: minutes March 20, 2012 CPSC 457 Principles of Operating Systems Daniel de Castro Tutorial 16: Program supervision with ptrace Expected Time: 30-40 minutes March 20, 2012 In this exercise, we are going to implement a strace-inspired

More information

Code Instrumentation, Dynamic Tracing

Code Instrumentation, Dynamic Tracing Code Instrumentation, Dynamic Tracing http://d3s.mff.cuni.cz/aosy http://d3s.mff.cuni.cz Martin Děcký decky@d3s.mff.cuni.cz Observability What is the system doing? Beyond the obvious (externally visible

More information

CSE 509: Computer Security

CSE 509: Computer Security CSE 509: Computer Security Date: 2.16.2009 BUFFER OVERFLOWS: input data Server running a daemon Attacker Code The attacker sends data to the daemon process running at the server side and could thus trigger

More information

Lab 09 - Virtual Memory

Lab 09 - Virtual Memory Lab 09 - Virtual Memory Due: November 19, 2017 at 4:00pm 1 mmapcopy 1 1.1 Introduction 1 1.1.1 A door predicament 1 1.1.2 Concepts and Functions 2 1.2 Assignment 3 1.2.1 mmap copy 3 1.2.2 Tips 3 1.2.3

More information

Project #1: Tracing, System Calls, and Processes

Project #1: Tracing, System Calls, and Processes Project #1: Tracing, System Calls, and Processes Objectives In this project, you will learn about system calls, process control and several different techniques for tracing and instrumenting process behaviors.

More information

Lecture 4 CIS 341: COMPILERS

Lecture 4 CIS 341: COMPILERS Lecture 4 CIS 341: COMPILERS CIS 341 Announcements HW2: X86lite Available on the course web pages. Due: Weds. Feb. 7 th at midnight Pair-programming project Zdancewic CIS 341: Compilers 2 X86 Schematic

More information

ECEN 449 Microprocessor System Design. Review of C Programming

ECEN 449 Microprocessor System Design. Review of C Programming ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh es programming g skills s 2 1 Basic C program structure # include

More information

Online Monitoring of I/O

Online Monitoring of I/O Introduction On-line Monitoring Framework Evaluation Summary References Research Group German Climate Computing Center 23-03-2017 Introduction On-line Monitoring Framework Evaluation Summary References

More information

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh programming skills 2 Basic C program structure # include main()

More information

Process Address Spaces and Binary Formats

Process Address Spaces and Binary Formats Process Address Spaces and Binary Formats Don Porter Background We ve talked some about processes This lecture: discuss overall virtual memory organizafon Key abstracfon: Address space We will learn about

More information

My memcheck. Version 1 7 December Epita systems/security laboratory 2017

My memcheck. Version 1 7 December Epita systems/security laboratory 2017 My memcheck Version 1 7 December 2015 Epita systems/security laboratory 2017 1 I Copyright This document is for internal use only at EPITA http://www.epita.fr/. Copyright c 2015/2016

More information

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007.

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007. class.ppt 15-213 The course that gives CMU its Zip! ory System Case Studies November 7, 07 Topics P6 address translation x86-64 extensions Linux memory management Linux fault handling ory mapping Intel

More information

MMAP AND PIPE. UNIX Programming 2015 Fall by Euiseong Seo

MMAP AND PIPE. UNIX Programming 2015 Fall by Euiseong Seo MMAP AND PIPE UNIX Programming 2015 Fall by Euiseong Seo Memory Mapping mmap(2) system call allows mapping of a file into process address space Instead of using read() and write(), just write to memory

More information

Run-time Thread Injection The Jugaad way. By Aseem Jakhar

Run-time Thread Injection The Jugaad way. By Aseem Jakhar Run-time Thread Injection The Jugaad way By Aseem Jakhar $whoami Security and open source enthusiast. Founder null The open security community. Organizer nullcon security conference. Chief researcher Payatu

More information

Chapter 4. File Systems. Part 1

Chapter 4. File Systems. Part 1 Chapter 4 File Systems Part 1 1 Reading Chapter 4: File Systems Chapter 10: Case Study 1: Linux (& Unix) 2 Long-Term Storage of Information Must store large amounts of data Information must survive the

More information

CSCI 4061: Virtual Memory

CSCI 4061: Virtual Memory 1 CSCI 4061: Virtual Memory Chris Kauffman Last Updated: Thu Dec 7 12:52:03 CST 2017 2 Logistics: End Game Date Lecture Outside Mon 12/04 Lab 13: Sockets Tue 12/05 Sockets Thu 12/07 Virtual Memory Mon

More information

Page Which had internal designation P5

Page Which had internal designation P5 Intel P6 Internal Designation for Successor to Pentium Which had internal designation P5 Fundamentally Different from Pentium 1 Out-of-order, superscalar operation Designed to handle server applications

More information

Virtual Memory: Systems

Virtual Memory: Systems Virtual Memory: Systems 5-23: Introduction to Computer Systems 8 th Lecture, March 28, 27 Instructor: Franz Franchetti & Seth Copen Goldstein Recap: Hmmm, How Does This Work?! Process Process 2 Process

More information

Program Exploitation Intro

Program Exploitation Intro Program Exploitation Intro x86 Assembly 04//2018 Security 1 Univeristà Ca Foscari, Venezia What is Program Exploitation "Making a program do something unexpected and not planned" The right bugs can be

More information

mydbg Subject version # Epita systems/security laboratory

mydbg Subject version # Epita systems/security laboratory mydbg Subject version # Epita systems/security laboratory 1 Copyright This document is for internal use at EPITA (website) only. Copyright Assistants

More information

Overhead Evaluation about Kprobes and Djprobe (Direct Jump Probe)

Overhead Evaluation about Kprobes and Djprobe (Direct Jump Probe) Overhead Evaluation about Kprobes and Djprobe (Direct Jump Probe) Masami Hiramatsu Hitachi, Ltd., SDL Jul. 13. 25 1. Abstract To implement flight recorder system, the overhead

More information

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations 15-213 The course that gives CMU its Zip! P6/Linux ory System November 1, 01 Topics P6 address translation Linux memory management Linux fault handling memory mapping Intel P6 Internal Designation for

More information

Memory System Case Studies Oct. 13, 2008

Memory System Case Studies Oct. 13, 2008 Topics 15-213 Memory System Case Studies Oct. 13, 2008 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping Class15+.ppt Intel P6 (Bob Colwell s Chip,

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 208 Lecture 23 LAST TIME: VIRTUAL MEMORY Began to focus on how to virtualize memory Instead of directly addressing physical memory, introduce a level of indirection

More information

Unoptimized Code Generation

Unoptimized Code Generation Unoptimized Code Generation Last time we left off on the procedure abstraction Saman Amarasinghe 2 6.035 MIT Fall 1998 The Stack Arguments 0 to 6 are in: %b %rbp %rsp %rdi, %rsi, %rdx, %rcx, %r8 and %r9

More information

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ...

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ... 15-213 P6/Linux ory System October 31, 00 Topics P6 address translation Linux memory management Linux fault handling memory mapping DRAM bus interface unit instruction fetch unit processor package P6 memory

More information

Pentium/Linux Memory System March 17, 2005

Pentium/Linux Memory System March 17, 2005 15-213 The course that gives CMU its Zip! Topics Pentium/Linux Memory System March 17, 2005 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping 17-linuxmem.ppt

More information

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1 Memory Mapped I/O Michael Jantz Prasad Kulkarni EECS 678 Memory Mapped I/O Lab 1 Introduction This lab discusses various techniques user level programmers can use to control how their process' logical

More information

Memory management. Single process. Multiple processes. How to: All memory assigned to the process Addresses defined at compile time

Memory management. Single process. Multiple processes. How to: All memory assigned to the process Addresses defined at compile time Memory management Single process All memory assigned to the process Addresses defined at compile time Multiple processes. How to: assign memory manage addresses? manage relocation? manage program grow?

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 205 Lecture 23 LAST TIME: VIRTUAL MEMORY! Began to focus on how to virtualize memory! Instead of directly addressing physical memory, introduce a level of

More information

Application Fault Tolerance Using Continuous Checkpoint/Restart

Application Fault Tolerance Using Continuous Checkpoint/Restart Application Fault Tolerance Using Continuous Checkpoint/Restart Tomoki Sekiyama Linux Technology Center Yokohama Research Laboratory Hitachi Ltd. Outline 1. Overview of Application Fault Tolerance and

More information

Pianola: A script-based I/O benchmark

Pianola: A script-based I/O benchmark Pianola: A script-based I/O benchmark John May PSDW08, 17 November 2008, P. O. Box 808, Livermore, CA 94551 This work performed under the auspices of the U.S. Department of Energy by under Contract DE-AC52-07NA27344

More information

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 Inter-process Communication (IPC) Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Recall Process vs. Thread A process is

More information

Assembly Language Programming 64-bit environments

Assembly Language Programming 64-bit environments Assembly Language Programming 64-bit environments October 17, 2017 Some recent history Intel together with HP start to work on 64-bit processor using VLIW technology. Itanium processor is born with the

More information

Kprobes Presentation Overview

Kprobes Presentation Overview Kprobes Presentation Overview This talk is about how using the Linux kprobe kernel debugging API, may be used to subvert the kernels integrity by manipulating jprobes and kretprobes to patch the kernel.

More information

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14 SYSTEM CALL IMPLEMENTATION CS124 Operating Systems Fall 2017-2018, Lecture 14 2 User Processes and System Calls Previously stated that user applications interact with the kernel via system calls Typically

More information

an infinite loop Processes and Exceptions doing nothing on a busy system timing nothing

an infinite loop Processes and Exceptions doing nothing on a busy system timing nothing an infinite loop Processes and Exceptions int main(void) { while (1) { /* waste CPU time */ If I run this on a lab machine, can you still use it? even if the machine only has one core? 1 2 timing nothing

More information

Virtual Memory. Alan L. Cox Some slides adapted from CMU slides

Virtual Memory. Alan L. Cox Some slides adapted from CMU slides Alan L. Cox alc@rice.edu Some slides adapted from CMU 5.23 slides Objectives Be able to explain the rationale for VM Be able to explain how VM is implemented Be able to translate virtual addresses to physical

More information

Function Call Convention

Function Call Convention Function Call Convention Compass Security Schweiz AG Werkstrasse 20 Postfach 2038 CH-8645 Jona Tel +41 55 214 41 60 Fax +41 55 214 41 61 team@csnc.ch www.csnc.ch Content Intel Architecture Memory Layout

More information

Operating Systems. Part 8. Operating Systems. What is an operating system? Interact with Applications. Vector Tables. The master software

Operating Systems. Part 8. Operating Systems. What is an operating system? Interact with Applications. Vector Tables. The master software Part 8 Operating Systems Operating Systems The master software Operating Systems What is an operating system? Master controller for all of the activities that take place within a computer Basic Duties:

More information

Process Address Spaces and Binary Formats

Process Address Spaces and Binary Formats Process Address Spaces and Binary Formats Don Porter CSE 506 Binary Formats RCU Memory Management Logical Diagram File System Memory Threads Allocators Today s Lecture System Calls Device Drivers Networking

More information

Machine-Level Programming (2)

Machine-Level Programming (2) Machine-Level Programming (2) Yanqiao ZHU Introduction to Computer Systems Project Future (Fall 2017) Google Camp, Tongji University Outline Control Condition Codes Conditional Branches and Conditional

More information

CS5460: Operating Systems

CS5460: Operating Systems CS5460: Operating Systems Lecture 2: OS Hardware Interface (Chapter 2) Course web page: http://www.eng.utah.edu/~cs5460/ CADE lab: WEB L224 and L226 http://www.cade.utah.edu/ Projects will be on Linux

More information

Implementation of Breakpoints in GDB for Sim-nML based Architectures

Implementation of Breakpoints in GDB for Sim-nML based Architectures Implementation of Breakpoints in GDB for Sim-nML based Architectures CS499 Report by Amit Gaurav Y3036 under the guidance of Prof. Rajat Moona Department of Computer Science and Engineering Indian Institute

More information

Operating Systems 2010/2011

Operating Systems 2010/2011 Operating Systems 2010/2011 Input/Output Systems part 1 (ch13) Shudong Chen 1 Objectives Discuss the principles of I/O hardware and its complexity Explore the structure of an operating system s I/O subsystem

More information

Machine Program: Procedure. Zhaoguo Wang

Machine Program: Procedure. Zhaoguo Wang Machine Program: Procedure Zhaoguo Wang Requirements of procedure calls? P() { y = Q(x); y++; 1. Passing control int Q(int i) { int t, z; return z; Requirements of procedure calls? P() { y = Q(x); y++;

More information

Advanced virtualization techniques for FAUmachine

Advanced virtualization techniques for FAUmachine Advanced virtualization techniques for FAUmachine Hans-Jörg Höxer Volkmar Sieh Martin Waitz Institut für Informatik 3 Friedrich-Alexander-Universität Erlangen-Nürnberg Germany info@faumachine.org Abstract

More information

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon Carnegie Mellon Machine-Level Programming III: Procedures 15-213/18-213/14-513/15-513: Introduction to Computer Systems 7 th Lecture, September 18, 2018 Today Procedures Mechanisms Stack Structure Calling

More information

POSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017

POSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017 Linux/UNIX IPC Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2017 mtk@man7.org November 2017 Outline 10 POSIX Shared Memory 10-1 10.1 Overview 10-3 10.2 Creating and opening shared memory

More information

Princeton University Computer Science 217: Introduction to Programming Systems Exceptions and Processes

Princeton University Computer Science 217: Introduction to Programming Systems Exceptions and Processes Princeton University Computer Science 217: Introduction to Programming Systems Exceptions and Processes Much of the material for this lecture is drawn from Computer Systems: A Programmer s Perspective

More information

Reverse Engineering Malware Dynamic Analysis of Binary Malware II

Reverse Engineering Malware Dynamic Analysis of Binary Malware II Reverse Engineering Malware Dynamic Analysis of Binary Malware II Jarkko Turkulainen F-Secure Corporation Protecting the irreplaceable f-secure.com Advanced dynamic analysis Debugger scripting Hooking

More information

Introduction to pthreads

Introduction to pthreads CS 220: Introduction to Parallel Computing Introduction to pthreads Lecture 25 Threads In computing, a thread is the smallest schedulable unit of execution Your operating system has a scheduler that decides

More information

Making things work as expected

Making things work as expected Making things work as expected System Programming Lab Maksym Planeta Björn Döbel 20.09.2018 Table of Contents Introduction Hands-on Tracing made easy Dynamic intervention Compiler-based helpers The GNU

More information

Operating systems. Lecture 9

Operating systems. Lecture 9 Operating systems. Lecture 9 Michał Goliński 2018-11-27 Introduction Recall Reading and writing wiles in the C/C++ standard libraries System calls managing processes (fork, exec etc.) Plan for today fork

More information

CSE 351 Midterm - Winter 2015 Solutions

CSE 351 Midterm - Winter 2015 Solutions CSE 351 Midterm - Winter 2015 Solutions February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate

More information

Machine-level Programs Procedure

Machine-level Programs Procedure Computer Systems Machine-level Programs Procedure Han, Hwansoo Mechanisms in Procedures Passing control To beginning of procedure code Back to return point Passing data Procedure arguments Return value

More information

Sandboxing. (1) Motivation. (2) Sandboxing Approaches. (3) Chroot

Sandboxing. (1) Motivation. (2) Sandboxing Approaches. (3) Chroot Sandboxing (1) Motivation Depending on operating system to do access control is not enough. For example: download software, virus or Trojan horse, how to run it safely? Risks: Unauthorized access to files,

More information

CSE 351 Midterm - Winter 2015

CSE 351 Midterm - Winter 2015 CSE 351 Midterm - Winter 2015 February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate will prove

More information

Process Environment. Pradipta De

Process Environment. Pradipta De Process Environment Pradipta De pradipta.de@sunykorea.ac.kr Today s Topic Program to process How is a program loaded by the kernel How does kernel set up the process Outline Review of linking and loading

More information

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes CS 261 Fall 2017 Mike Lam, Professor Exceptional Control Flow and Processes Exceptional control flow Most control flow is sequential However, we have seen violations of this rule Exceptional control flow

More information

libxcpc(3) Exception and resource handling in C libxcpc(3)

libxcpc(3) Exception and resource handling in C libxcpc(3) NAME xcpc_set_exitproc, xcpc_push_tryctx, xcpc_pop_tryctx, xcpc_do_throw, xcpc_do_rethrow, xcpc_context_create, xcpc_context_reparent, xcpc_context_free, xcpc_context_parent, xcpc_context_root, xcpc_context_exhandler,

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

Assembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Assembly III: Procedures Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Mechanisms in Procedures Passing control To beginning of procedure code

More information

CS 550 Operating Systems Spring Interrupt

CS 550 Operating Systems Spring Interrupt CS 550 Operating Systems Spring 2019 Interrupt 1 Revisit -- Process MAX Stack Function Call Arguments, Return Address, Return Values Kernel data segment Kernel text segment Stack fork() exec() Heap Data

More information

RISC I from Berkeley. 44k Transistors 1Mhz 77mm^2

RISC I from Berkeley. 44k Transistors 1Mhz 77mm^2 The Case for RISC RISC I from Berkeley 44k Transistors 1Mhz 77mm^2 2 MIPS: A Classic RISC ISA Instructions 4 bytes (32 bits) 4-byte aligned Instructions operate on memory and registers Memory Data types

More information

Fixing/Making Holes in Binaries

Fixing/Making Holes in Binaries Fixing/Making Holes in Binaries The Easy, The Hard, The Time Consuming Shaun Clowes Ð shaun@securereality.com.au What are we doing? Changing the behaviour of programs Directly modifying the program in

More information

W4118: interrupt and system call. Junfeng Yang

W4118: interrupt and system call. Junfeng Yang W4118: interrupt and system call Junfeng Yang Outline Motivation for protection Interrupt System call 2 Need for protection Kernel privileged, cannot trust user processes User processes may be malicious

More information

Shared Memory Memory mapped files

Shared Memory Memory mapped files Shared Memory Memory mapped files 1 Shared Memory Introduction Creating a Shared Memory Segment Shared Memory Control Shared Memory Operations Using a File as Shared Memory 2 Introduction Shared memory

More information

Introduction to Linux, for Embedded Engineers Tutorial on Virtual Memory. Feb. 22, 2007 Tetsuyuki Kobayashi Aplix Corporation. [translated by ikoma]

Introduction to Linux, for Embedded Engineers Tutorial on Virtual Memory. Feb. 22, 2007 Tetsuyuki Kobayashi Aplix Corporation. [translated by ikoma] Introduction to Linux, for Embedded Engineers Tutorial on Virtual Memory Feb. 22, 2007 Tetsuyuki Kobayashi Aplix Corporation [translated by ikoma] 1 Target Audience of this Presentation People who have

More information

Section 4: Threads and Context Switching

Section 4: Threads and Context Switching CS162 September 19-20, 2017 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Join................................................ 3 3.2

More information

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2 CS162 September 15, 2016 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Join................................................ 3 3.2 Stack

More information

1 Number Representation(10 points)

1 Number Representation(10 points) Name: Sp15 Midterm Q1 1 Number Representation(10 points) 1 NUMBER REPRESENTATION(10 POINTS) Let x=0xe and y=0x7 be integers stored on a machine with a word size of 4bits. Show your work with the following

More information

CS 261 Fall Machine and Assembly Code. Data Movement and Arithmetic. Mike Lam, Professor

CS 261 Fall Machine and Assembly Code. Data Movement and Arithmetic. Mike Lam, Professor CS 261 Fall 2018 0000000100000f50 55 48 89 e5 48 83 ec 10 48 8d 3d 3b 00 00 00 c7 0000000100000f60 45 fc 00 00 00 00 b0 00 e8 0d 00 00 00 31 c9 89 0000000100000f70 45 f8 89 c8 48 83 c4 10 5d c3 Mike Lam,

More information

Programmation Système Cours 5 Memory Mapping

Programmation Système Cours 5 Memory Mapping Programmation Système Cours 5 Memory Mapping Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot 2014 2015 URL http://upsilon.cc/zack/teaching/1415/progsyst/ Copyright

More information

Stack Frames. September 2, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 September 2, / 15

Stack Frames. September 2, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 September 2, / 15 Stack Frames Geoffrey Brown Bryce Himebaugh Indiana University September 2, 2016 Geoffrey Brown, Bryce Himebaugh 2015 September 2, 2016 1 / 15 Outline Preserving Registers Saving and Restoring Registers

More information

CSC369 Lecture 2. Larry Zhang

CSC369 Lecture 2. Larry Zhang CSC369 Lecture 2 Larry Zhang 1 Announcements Lecture slides Midterm timing issue Assignment 1 will be out soon! Start early, and ask questions. We will have bonus for groups that finish early. 2 Assignment

More information

Signal Example 1. Signal Example 2

Signal Example 1. Signal Example 2 Signal Example 1 #include #include void ctrl_c_handler(int tmp) { printf("you typed CTL-C, but I don't want to die!\n"); int main(int argc, char* argv[]) { long i; signal(sigint, ctrl_c_handler);

More information

Assembly Language II: Addressing Modes & Control Flow

Assembly Language II: Addressing Modes & Control Flow Assembly Language II: Addressing Modes & Control Flow Learning Objectives Interpret different modes of addressing in x86 assembly Move data seamlessly between registers and memory Map data structures in

More information

Process Migration via Remote Fork: a Viable Programming Model? Branden J. Moor! cse 598z: Distributed Systems December 02, 2004

Process Migration via Remote Fork: a Viable Programming Model? Branden J. Moor! cse 598z: Distributed Systems December 02, 2004 Process Migration via Remote Fork: a Viable Programming Model? Branden J. Moor! cse 598z: Distributed Systems December 02, 2004 What is a Remote Fork? Creates an exact copy of the process on a remote system

More information

The Software Stack: From Assembly Language to Machine Code

The Software Stack: From Assembly Language to Machine Code COMP 506 Rice University Spring 2018 The Software Stack: From Assembly Language to Machine Code source code IR Front End Optimizer Back End IR target code Somewhere Out Here Copyright 2018, Keith D. Cooper

More information

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control. C Flow Control David Chisnall February 1, 2011 Outline What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope Disclaimer! These slides contain a lot of

More information

Process Migration. David Zuercher CS555 Distributed Systems

Process Migration. David Zuercher CS555 Distributed Systems Process Migration David Zuercher CS555 Distributed Systems What is Migration? Mi-gra-tion -The act or an instance of migrating. - A group migrating together. Mi-gra-te - Moving from one place to another.

More information

Runtime Process Insemination

Runtime Process Insemination Runtime Process Insemination Shawn lattera Webb SoldierX https://www.soldierx.com/ Who Am I? Just another blogger Professional Security Analyst Twelve-year C89 programmer Member of SoldierX, BinRev, and

More information

6.035 Project 3: Unoptimized Code Generation. Jason Ansel MIT - CSAIL

6.035 Project 3: Unoptimized Code Generation. Jason Ansel MIT - CSAIL 6.035 Project 3: Unoptimized Code Generation Jason Ansel MIT - CSAIL Quiz Monday 50 minute quiz Monday Covers everything up to yesterdays lecture Lexical Analysis (REs, DFAs, NFAs) Syntax Analysis (CFGs,

More information

CSC369 Lecture 2. Larry Zhang, September 21, 2015

CSC369 Lecture 2. Larry Zhang, September 21, 2015 CSC369 Lecture 2 Larry Zhang, September 21, 2015 1 Volunteer note-taker needed by accessibility service see announcement on Piazza for details 2 Change to office hour to resolve conflict with CSC373 lecture

More information

Assembler Programming. Lecture 10

Assembler Programming. Lecture 10 Assembler Programming Lecture 10 Lecture 10 Mixed language programming. C and Basic to MASM Interface. Mixed language programming Combine Basic, C, Pascal with assembler. Call MASM routines from HLL program.

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 7

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 7 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2017 Lecture 7 LAST TIME Dynamic memory allocation and the heap: A run-time facility that satisfies multiple needs: Programs can use widely varying, possibly

More information

Processes and Threads

Processes and Threads Process Processes and Threads A process is an abstraction that represent an executing program A program in execution An instance of a program running on a computer The entity that can be assigned to and

More information

Machine-Level Programming III: Procedures

Machine-Level Programming III: Procedures Machine-Level Programming III: Procedures CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides Mechanisms in Procedures Passing control

More information

Memory Mapping. Sarah Diesburg COP5641

Memory Mapping. Sarah Diesburg COP5641 Memory Mapping Sarah Diesburg COP5641 Memory Mapping Translation of address issued by some device (e.g., CPU or I/O device) to address sent out on memory bus (physical address) Mapping is performed by

More information

Generation. representation to the machine

Generation. representation to the machine Unoptimized i Code Generation From the intermediate representation to the machine code 5 Outline Introduction Machine Language Overview of a modern processor Memory Layout Procedure Abstraction Procedure

More information

Machine- Level Representa2on: Procedure

Machine- Level Representa2on: Procedure Machine- Level Representa2on: Procedure CSCI 2021: Machine Architecture and Organiza2on Pen- Chung Yew Department Computer Science and Engineering University of Minnesota With Slides from Bryant, O Hallaron

More information

CS631 - Advanced Programming in the UNIX Environment. Dæmon processes, System Logging, Advanced I/O

CS631 - Advanced Programming in the UNIX Environment. Dæmon processes, System Logging, Advanced I/O CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment Dæmon processes, System Logging, Advanced I/O Department of Computer Science Stevens Institute

More information

Android Dynamic Linker - Marshmallow

Android Dynamic Linker - Marshmallow Android Dynamic Linker - Marshmallow WANG Zhenhua, i@jackwish.net Abstract Dynamic linker, links shared libraries together to be able to run, has been a fundamental mechanism in modern operating system

More information