Testing Reactive Programs. Designing Programmable debugger easily

Size: px
Start display at page:

Download "Testing Reactive Programs. Designing Programmable debugger easily"

Transcription

1 Outline Plan Debugging Reactive Programs Debugging Reactive Programs 3 orthogonal ideas 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion Programmable debugger coroutine via continuations for reactive programs rdbg a Reactive programs DeBuGger 24 May 2016 < 2 / 48 > Debugging Reactive Programs Programming Reactive systems rdbg a Reactive programs DeBuGger 24 May 2016 < 3 / 48 > Debugging Reactive Programs Testing Reactive Programs rdbg a Reactive programs DeBuGger 24 May 2016 < 4 / 48 > Debugging Reactive Programs Debugging Reactive Programs Reactive systems in continuous interaction with their environments often critical Synchronous languages clean semantics w.r.t. time (discrete) and parallelism (perfect) compiled into statically scheduled tasks typically embedded in OS-free systems bounded memory and execution time (no while loop) program-level formal verification Lustre Generalised synchronous circuits : wires hold numerics types and clocks (when to compute) Scade (Esterel-Technologies) formal verification can be too costly But formal descriptions of the environment and expected properties can be used for black-box automated testing Lurette : the tool that performs all the red tape (plumbering) between the SUT, its env, and the oracles Lutin : a language to program non-deterministic reactive systems Lustre + control-structure + stochastic choices Stimulus (Argosim ; 2013 ) What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline Need to program reactive programs environments That s precisely what Lurette and Lutin do The idea is to reuse the Lurette infrastructure nb : Lutin environments models are also programs that needs debugging rdbg targets any kind of reactive languages, but currently works with Lustre and Lutin rdbg a Reactive programs DeBuGger 24 May 2016 < 5 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 6 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 > Debugger Debugging Reactive Programs Debugging Reactive Programs Designing Programmable debugger easily rdbg : a programmable debugger for reactive programs Plan A program execution = list of events (observation points) An event is a tuple of runtime information (execution) an event out to be defined w.r.t. to the operational semantics of the language (e.g., an instruction for imperative languages) in gdb an event is a line in the source A debugger is a program that works in coroutine with the debuggee, and that is able to inspect event contents and to navigate through the event list rdbg a Reactive programs DeBuGger 24 May 2016 < 8 / 48 > Why programmable? because debugger users are programmers (always) because debugging can be difficult moreover it s not hard to do! How 1. Given a pre-defined instrumentation of the debuggee process, providing an API that lets one inspect the debuggee runtime state (event) with well-chosen information at well-chosen observation point go to the next event 2. Given a host language equipped with a good library an interactive interpreter (i.e., a read-eval-print toplevel loop) Claim : then one can easily obtain a full-fledged extensible debugger by programming its own custom primitives that navigate through the event list custom primitives that perform runtime analysis (monitors) rdbg a Reactive programs DeBuGger 24 May 2016 < 9 / 48 > 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 10 / 48 >

2 rdbg : a programmable debugger for reactive programs Which host language? rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next rdbg : a programmable debugger for reactive programs Defining events The Lutin interpreter and the Lustre V6 compiler are programmed in Ocaml Lurette is programmed in Ocaml too Ocaml has good libraries and a good interactive read-eval-print toplevel interpreter It sounds like a good candidate for the host language PRE LUCIOLE ENV sim2chro SUT ocamlkmktop an interactive interpreter with all Lurette modules 2 functions run : Rdbg.args -> Event.t next : Event.t -> Event.t args is made of Lurette parameters : sut names, env names, oracle oracle.rif An event is an observation point The most difficult part Closely related to the language semantics A trade-off between completeness and efficiency Two dimensions : where to put events what an event contains rdbg a Reactive programs DeBuGger 24 May 2016 < 11 / 48 > rdbg : a programmable debugger for reactive programs Events names, test length, rif file name, etc. Demonstration rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 > rdbg : a programmable debugger for reactive programs The rdbg API [1/2] rdbg a Reactive programs DeBuGger 24 May 2016 < 13 / 48 > rdbg : a programmable debugger for reactive programs The rdbg API [2/2] Kind of events : call : when entering a node exit : when exiting a node microstep(string) : holds info related to the sub-lang micro-step Events specific to Lutin : microstep("try") : a choice is performed in the control structure microstep("sat") : the chosen constraint is satisfiable microstep("unsat") : the chosen constraint is unsatisfiable type kind = Ltop Call Exit MicroStep of string type s rc_info_atom = { } file : string ; line : int * int ; (* line nb begin / end in file *) char : int * int ; (* char nb begin / end in file *) stack : src_info option ; (* call stack *) type src_info = { } expr : Expr. t ; (* current expr *) atoms : src_info_atom list ; more : ( unit -> Expr.t) option ; (* even more costly info *) type t = { name : string ; (* node name *) lang : string ; (* e.g., " lutin " or " lustre " *) inputs : var list ; outputs : var list ; sinfo : ( unit -> src_info ) option ; (* Runtime info *) nb : int ; step : int ; depth : int ; data : Data. subst list ; kind : kind ; (* Call, Exit, MicroStep *) (* Navigation *) next : unit -> t ; terminate : unit -> unit } rdbg a Reactive programs DeBuGger 24 May 2016 < 14 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 15 / 48 > run : args -> Event.t that s all! Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 16 / 48 > Plan The User point of view The User point of view What can be done with this small kernel Step forward The User point of view 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion Move forward and Backwards Conditional breakpoints gdb like Breakpoints Debugger Customisation Adding hooks custom traces custom commands Profiling, monitoring let ( next : Event.t -> Event.t)= fun e -> e. next () let ( next : Event.t -> Event.t)= fun e -> print_event e ; e. next () let rec ( nexti : Event.t -> int -> Event.t)= fun e cpt -> if cpt > 0 then nexti ( next e ) (cpt -1) else e let rec ( goto_i : Event.t -> int -> Event.t)= fun e i -> if e.nb < i then goto_i ( next e ) i else e let rec ( goto_s : Event.t -> int -> Event.t)= fun e i -> if e. step < i then goto_s ( next e ) i else e rdbg a Reactive programs DeBuGger 24 May 2016 < 17 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 18 / 48 > Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 19 / 48 >

3 The User point of view Conditional breakpoints Moving backwards The User point of view The User point of view Adding hooks to next let rec ( next_cond : Event.t -> ( Event.t -> bool ) -> Event. t ) = fun e cond -> let ne = next e in if cond ne then ne else next_cond ne cond ex : spot the time when an invariant is violated Demo let rev_cond e (p: Event.t -> bool ) = let rec rev_aux e i = (* search if there exist an event e2 in ]e. nb ;i[ s.t. p e2 *) let e = if p e then e else next_cond e ( fun e -> p e e. nb = i) in if p e then rev_aux_last e e i (* search for a more recent one *) else (* e. nb = i *) let x = (e. nb /! ckpt_rate - 1) in if x < 0 then ( print_string " No suitable event found \n"; Event. set_nb 1; Hashtbl. find ckpt_tbl 0) else let e = Hashtbl. find ckpt_tbl x in Event. set_nb e. nb ; rev_aux e (( x +1) *! ckpt_rate -1) and rev_aux_last e e_good i = (* search if there exist an event e in ] e_good.n;i[ s.t. p e *) if e. nb = i then e_good else let e = next_cond e ( fun e -> p e e. nb = i) in rev_aux_last e ( fun j -> if p e then e else e_good j) i in if e. nb = 1 then failwith " Cannot move backwards from the first event.\ n" else let last_e = Hashtbl. find ckpt_tbl (( e. nb - 1) /! ckpt_rate ) in Event. set_nb last_e. nb ; rev_aux last_e (e.nb -1) (* move backwards until a breakpoint is reached *) let ( rev : Event.t -> Event.t) = fun e -> let stop e = List. exists ( break_matches e)! breakpoints in rev_cond e stop let ( hooks : ( string * ( Event.t -> unit ) ) list ref ) = ref [( " print_event ", print_event ) ] let rec ( next : Event.t -> Event.t) = fun e -> let ne = e. next () in List. iter ( fun (_, f ) -> f ne )! hooks ; ne let ( add_hooks : string * ( Event.t -> unit ) -> unit ) = fun h -> hooks := (h ::! hooks ) let ( del_hooks : string -> unit ) = fun str -> hooks := List. remove_assoc str! hooks rdbg a Reactive programs DeBuGger 24 May 2016 < 20 / 48 > Custom traces The User point of view } rdbg a Reactive programs DeBuGger 24 May 2016 < 21 / 48 > Shortcuts The User point of view Monitoring rdbg a Reactive programs DeBuGger 24 May 2016 < 22 / 48 > The User point of view let m y _ p r i n t _ e v ent e = [...] ;; del_hooks " print_event " ;; add_hooks ( " print_event ", m y _print_event ) ;; Demo let e = ref ( run () ) let n () = e := next! e let ni i = e := nexti! e i let r () = e := ref ( run () )... let cpt = ref 0 let rec count e = match getb_val " b ", getr_val " x " in Some b, Some x -> if ( b and 3 < x and x < 10) then c := c +1; _, _ -> () ; count ( e. next () ) Everything can also be compiled to native code for efficiency rdbg a Reactive programs DeBuGger 24 May 2016 < 23 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 24 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 25 / 48 > The User point of view gdb like Breakpoints The User point of view gdb like Breakpoints (cont) Profiling The User point of view Set breakpoints via strings the form : node or file::line let brkpts = ref [] let ( break : string -> unit ) = fun str -> brkpts := str ::! brkpts let ( delete : unit -> unit ) = fun () -> brkpts := [] let ( continue : Event.t -> Event.t) = fun e -> let stop e = List. exists ( brk_matches e )! brkpts in next_cond e stop let ( brk_matches : Event.t -> string -> bool ) = fun e b -> let s i_match_file str si = (si. file = str basename si. file = str ) in let s i_match_line ln { line =(d,f)} = ( d <= ios && ios i <= f ) in match e.sinfo, Str. split ( Str. regexp " :: " ) b with None, _ _, [] -> false (* no more BP *) Some src, str :: tail -> let src = src () in match tail with [ln ] -> List. exists ( fun si -> s i_match_file str si && si_match_line ln si ) src. atoms [] -> List. exists ( si_match_file str ) src. atoms _ -> false let prof_tbl = Hashtbl. create 50 let incr_prof si = try let cpt = Hashtbl. find prof_tbl si in Hashtbl. replace prof_tbl si ( cpt +1) with Not_found -> Hashtbl. add prof_tbl si 1 let ( prof_add : Event.t -> unit ) = fun e -> match to_lut_evt e. kind, e. sinfo with ( Sat Nsat ), Some src -> List. iter incr_prof ( src () ). atoms _ -> () let set_profiler on = if on then add_hooks ( " profile ",prof_add ) else del_hooks " profile " rdbg a Reactive programs DeBuGger 24 May 2016 < 26 / 48 > Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 27 / 48 > Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 28 / 48 >

4 Time Profiling The User point of view Plan The Compiler designer point of view The Compiler designer point of view The rdbg Plugin Mechanism Save the Unix.time() at call events Accumulate the difference at exit events rdbg a Reactive programs DeBuGger 24 May 2016 < 29 / 48 > 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 30 / 48 > To plug onto rdbg, one just need to provide cma/cmxs (dynamic ocamlopt code library) that implements this interface : type sl = ( string * Data.v) list (* substitutions *) type e = Event. t (* a shortcut for the remaining *) type t = { } inputs :( Data. ident * Data.t) list ; (* name and type *) outputs : ( Data. ident * Data.t) list ; (* ditto *) init_inputs : sl ; init_outputs : sl ; step : ( sl -> sl ) ; (* Lurette step *) step_dbg : ( sl -> e -> ( sl -> e -> e ) -> e ) ; (* RDBG step *) kill : string -> unit ; opam install rdbg git clone rdbg a Reactive programs DeBuGger 24 May 2016 < 31 / 48 > Plan Design issues Design issues Programmable debuggers Design issues Debuggers - Coroutine 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion To navigate through the event list, two primitives are necessary one that retrieves runtime information one to go one step forward But in order to avoid context switches, it s better to do the computations in the debuggee process Debugger / debuggee Processes communicate via signals/ptrace (gdb) pipes or sockets (camldebug, jdwp,... ) Objective : avoid context switches! rdbg a Reactive programs DeBuGger 24 May 2016 < 32 / 48 > Design issues Debuggers - how to avoid context switches rdbg a Reactive programs DeBuGger 24 May 2016 < 33 / 48 > Design issues Transform the interpreter code into CPS [1/2] rdbg a Reactive programs DeBuGger 24 May 2016 < 34 / 48 > Design issues Transform the interpreter code into CPS [2/2] Runtime instrumentation of the debuggee dynamic bytecode loading for ocamldebug ptrace for gdb But of course the instrumentation code is very simple (breakpoints) In particular, no debugger-user code For the Lustre and the Lutin plugin, we have chosen to implement the coroutine using continuations -- Vanilla lurette top loop let p a b = a + b let step_env a = p a 1 let step_sut a = p a 2 let rec loop i a = if i >42 then raise ( End a ) else let b = step_env a in let c = step_sut b in loop ( i +1) c -- lurettop loop -- CPS version let p a b = a + b let p a b ct = ct ( a + b ) let step_env a = p a 1 let step_env a ct = p a 1 ct let step_sut a = p a 2 let step_sut a ct = p a 2 ct let rec loop i a = let rec loop i a = if i >42 then if i > 42 then raise ( End a ) else raise ( End a ) else let b = step_env a in step_env a ( loop2 i ) let c = step_sut b in and loop2 i b = step_sut b loop (i +1) c ( loop (i +1) ) rdbg a Reactive programs DeBuGger 24 May 2016 < 35 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 36 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 37 / 48 >

5 Adding Events [1/2] Design issues Adding Events [2/2] Design issues Design issues Design issues - Advantages of continuations The CPS functions never return Hence it s easy to add events at each event locations type event = } { cont : unit -> event ; msg : string ; -- step : int ; -- depth : int ; -- data : substs ; -- src : string ; let plus a b cont = { msg = sprintf("%i+%i" a b); cont = fun () -> cont (a+b) } let step_env a cont = { msg = "step_env" ; cont = fun () -> plus a 1 cont } let step_sut a cont = { msg = "step_sut" ; cont = fun () -> plus a 2 cont } let rec loop2 i b = step_sut b (loop (i+1)) and loop i a = if a > 42 then raise (End a) else { msg = "top"; cont = fun () ->step_env a (loop2 i)} No msg writing/parsing between the 2 entities No context switches, which matters for debugging programs that interact at each step with the debuggee Very easy instrumentation (for code written in CPS... ) (Very easy access to all the internal data structures) rdbg a Reactive programs DeBuGger 24 May 2016 < 38 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 39 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 40 / 48 > Design issues Design issues Performance Design issues demo Design issues 1. Transform Lurettetop into an ocaml top-level (5 seconds) 2. Transform part of Lurettetop/Lutin interpreters into CPS (1 week) 3. Instrument this with Event.t (a few minutes) 4. Add source level information to Event.t (a few days) 5. Write Rdbg_utils on top of that (cf previous slides) 6. Fix evil details (... ) let rec finish e = finish (e. next () ) Less than 1% of penalty : on a simple Lutin program that performs 4 node calls (worst case?) Native versus bytecode : x5 but a native toplevel exists (ocamlnat) profiler : 30% penalty rdbg-top : ocaml top-level + rdbg libs Demo! nb : an ocaml-top wrapper so that it looks as a normal debugger auto-loads libs generates initial sessions communicates with rdbg-top via pipes add () and ; ; a blank a as first character inhibits this wrapping rdbg a Reactive programs DeBuGger 24 May 2016 < 41 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 42 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 43 / 48 > Plan Conclusion 3 orthogonal ideas Conclusion Conclusion Conclusion 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 44 / 48 > Programmable debugger coroutine via continuations for reactive programs rdbg a Reactive programs DeBuGger 24 May 2016 < 45 / 48 > Cons Pros Possible because Lutin is interpreted, and Lustre has an interpreter Need to modify (pollute?) an interpreter that ought to be written in ocaml! (but the idea would apply for any other language equipped with a read-eval-print interpretation loop) Lightweight implementation (1 week to get a first kernel) Efficient (well... ok, it s kind of a lie) Programmable! Separation of concerns a tiny kernel : run : Rdbg.args -> Event.t a simple plugin API : YourGreatLanguage.run : Rdbg.args -> Event.t a rich set of commands easily build on top of it which could be reused on other kernels rdbg a Reactive programs DeBuGger 24 May 2016 < 46 / 48 >

6 Conclusion Conclusion The end Coverage Thanks for your attention The previous profiler generates the covered code Another tool is needed to compute the set of code sites to be covered rdbg a Reactive programs DeBuGger 24 May 2016 < 47 / 48 > rdbg a Reactive programs DeBuGger 24 May 2016 < 48 / 48 >

7 Outline 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 2 / 48 >

8 Debugging Reactive Programs Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 3 / 48 >

9 Debugging Reactive Programs 3 orthogonal ideas Programmable debugger coroutine via continuations for reactive programs rdbg a Reactive programs DeBuGger 24 May 2016 < 4 / 48 >

10 Debugging Reactive Programs Programming Reactive systems Reactive systems in continuous interaction with their environments often critical Synchronous languages Lustre clean semantics w.r.t. time (discrete) and parallelism (perfect) compiled into statically scheduled tasks typically embedded in OS-free systems bounded memory and execution time (no while loop) program-level formal verification Generalised synchronous circuits : wires hold numerics types and clocks (when to compute) Scade (Esterel-Technologies) rdbg a Reactive programs DeBuGger 24 May 2016 < 5 / 48 >

11 Debugging Reactive Programs Testing Reactive Programs formal verification can be too costly But formal descriptions of the environment and expected properties can be used for black-box automated testing Lurette : the tool that performs all the red tape (plumbering) between the SUT, its env, and the oracles Lutin : a language to program non-deterministic reactive systems Lustre + control-structure + stochastic choices Stimulus (Argosim ; 2013 ) rdbg a Reactive programs DeBuGger 24 May 2016 < 6 / 48 >

12 Debugging Reactive Programs Debugging Reactive Programs What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline Need to program reactive programs environments That s precisely what Lurette and Lutin do The idea is to reuse the Lurette infrastructure nb : Lutin environments models are also programs that needs debugging rdbg targets any kind of reactive languages, but currently works with Lustre and Lutin rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 >

13 Debugging Reactive Programs Debugger A program execution = list of events (observation points) An event is a tuple of runtime information (execution) an event out to be defined w.r.t. to the operational semantics of the language (e.g., an instruction for imperative languages) in gdb an event is a line in the source A debugger is a program that works in coroutine with the debuggee, and that is able to inspect event contents and to navigate through the event list rdbg a Reactive programs DeBuGger 24 May 2016 < 8 / 48 >

14 Debugging Reactive Programs Designing Programmable debugger easily Why programmable? because debugger users are programmers (always) because debugging can be difficult moreover it s not hard to do! How 1. Given a pre-defined instrumentation of the debuggee process, providing an API that lets one inspect the debuggee runtime state (event) with well-chosen information at well-chosen observation point go to the next event 2. Given a host language equipped with a good library an interactive interpreter (i.e., a read-eval-print toplevel loop) Claim : then one can easily obtain a full-fledged extensible debugger by programming its own custom primitives that navigate through the event list custom primitives that perform runtime analysis (monitors) rdbg a Reactive programs DeBuGger 24 May 2016 < 9 / 48 >

15 rdbg : a programmable debugger for reactive programs Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 10 / 48 >

16 rdbg : a programmable debugger for reactive programs Which host language? The Lutin interpreter and the Lustre V6 compiler are programmed in Ocaml Lurette is programmed in Ocaml too Ocaml has good libraries and a good interactive read-eval-print toplevel interpreter It sounds like a good candidate for the host language rdbg a Reactive programs DeBuGger 24 May 2016 < 11 / 48 >

17 rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next ENV SUT oracle PRE LUCIOLE.rif sim2chro ocamlkmktop an interactive interpreter with all Lurette modules 2 functions run : Rdbg.args -> Event.t next : Event.t -> Event.t args is made of Lurette parameters : sut names, env names, oracle names, test length, rif file name, etc. Demonstration rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 >

18 rdbg : a programmable debugger for reactive programs Defining events An event is an observation point The most difficult part Closely related to the language semantics A trade-off between completeness and efficiency Two dimensions : where to put events what an event contains rdbg a Reactive programs DeBuGger 24 May 2016 < 13 / 48 >

19 rdbg : a programmable debugger for reactive programs Events Kind of events : call : when entering a node exit : when exiting a node microstep(string) : holds info related to the sub-lang micro-step Events specific to Lutin : microstep("try") : a choice is performed in the control structure microstep("sat") : the chosen constraint is satisfiable microstep("unsat") : the chosen constraint is unsatisfiable rdbg a Reactive programs DeBuGger 24 May 2016 < 14 / 48 >

20 rdbg : a programmable debugger for reactive programs The rdbg API [1/2] type kind = Ltop Call Exit MicroStep of string type s rc_info_atom = { file : string ; line : int * int ; (* line nb begin / end in file *) char : int * int ; (* char nb begin / end in file *) stack : src_info option ; (* call stack *) } type src_info = { expr : Expr. t ; (* current expr *) atoms : src_info_atom list ; more : ( unit -> Expr. t ) option ; (* even more costly info *) } rdbg a Reactive programs DeBuGger 24 May 2016 < 15 / 48 >

21 rdbg : a programmable debugger for reactive programs The rdbg API [2/2] type t = { name : string ; (* node name *) lang : string ; (* e.g., " lutin " or " lustre " *) inputs : var list ; outputs : var list ; sinfo : ( unit -> src_info ) option ; (* Runtime info *) nb : int ; step : int ; depth : int ; data : Data. subst list ; kind : kind ; (* Call, Exit, MicroStep *) (* Navigation *) next : unit -> t ; terminate : unit -> unit } run : args -> Event.t that s all! Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 16 / 48 >

22 The User point of view Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 17 / 48 >

23 The User point of view What can be done with this small kernel Move forward and Backwards Conditional breakpoints gdb like Breakpoints Debugger Customisation Adding hooks custom traces custom commands Profiling, monitoring rdbg a Reactive programs DeBuGger 24 May 2016 < 18 / 48 >

24 The User point of view Step forward let ( next : Event. t -> Event. t ) = fun e -> e. next () let ( next : Event. t -> Event. t ) = fun e -> print_event e ; e. next () let rec ( nexti : Event. t -> int -> Event. t ) = fun e cpt -> if cpt > 0 then nexti ( next e ) ( cpt -1) else e let rec ( goto_i : Event. t -> int -> Event. t ) = fun e i -> if e. nb < i then goto_i ( next e ) i else e let rec ( goto_s : Event. t -> int -> Event. t ) = fun e i -> if e. step < i then goto_s ( next e ) i else e Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 19 / 48 >

25 The User point of view Conditional breakpoints let rec ( next_cond : Event. t -> ( Event. t -> bool ) -> Event. t ) = fun e cond -> let ne = next e in if cond ne then ne else next_cond ne cond ex : spot the time when an invariant is violated Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 20 / 48 >

26 Moving backwards The User point of view let rev_cond e ( p : Event.t - > bool ) = let rec rev_aux e i = (* search if there exist an event e2 in ]e. nb ;i[ s.t. p e2 *) let e = if p e then e else next_cond e ( fun e -> p e e. nb = i) in if p e then rev_aux_last e e i (* search for a more recent one *) else (* e. nb = i *) let x = (e. nb /! ckpt_rate - 1) in if x < 0 then ( print_string " No suitable event found \n"; Event. set_nb 1; Hashtbl. find ckpt_tbl 0) else let e = Hashtbl. find ckpt_tbl x in Event. set_nb e. nb ; rev_aux e (( x +1) *! ckpt_rate -1) and rev_aux_last e e_good i = (* search if there exist an event e in ] e_good.n;i[ s.t. p e *) if e. nb = i then e_ good else let e = next_cond e ( fun e -> p e e. nb = i) in rev_aux_last e ( fun j -> if p e then e else e_good j) i in if e. nb = 1 then failwith " Cannot move backwards from the first event.\ n" else let last_e = Hashtbl. find ckpt_tbl (( e. nb - 1) /! ckpt_rate ) in Event. set_nb last_e. nb ; rev_aux last_e (e.nb -1) (* move backwards until a breakpoint is reached *) let ( rev : Event.t -> Event.t) = fun e -> let stop e = List. exists ( break_matches e)! breakpoints in rev_cond e stop } rdbg a Reactive programs DeBuGger 24 May 2016 < 21 / 48 >

27 The User point of view Adding hooks to next let ( hooks : ( string * ( Event. t -> unit ) ) list ref ) = ref [( " print_event ", print_event ) ] let rec ( next : Event. t -> Event. t ) = fun e -> let ne = e. next () in List. iter ( fun (_, f ) -> f ne )! hooks ; ne let ( add_hooks : string * ( Event. t -> unit ) -> unit ) = fun h -> hooks := ( h ::! hooks ) let ( del_hooks : string -> unit ) = fun str -> hooks := List. remove_assoc str! hooks rdbg a Reactive programs DeBuGger 24 May 2016 < 22 / 48 >

28 The User point of view Custom traces let m y _ p r i n t _ e v ent e = [...] ;; del_hooks " print_event " ;; add_hooks ( " print_event ", m y _ p r i n t _ e v e n t ) ;; Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 23 / 48 >

29 The User point of view Shortcuts let e = ref ( run () ) let n () = e := next! e let ni i = e := nexti! e i let r () = e := ref ( run () )... rdbg a Reactive programs DeBuGger 24 May 2016 < 24 / 48 >

30 The User point of view Monitoring let cpt = ref 0 let rec count e = match getb_val " b ", getr_val " x " in Some b, Some x -> if ( b and 3 < x and x < 10) then c := c +1; _, _ -> () ; count ( e. next () ) Everything can also be compiled to native code for efficiency rdbg a Reactive programs DeBuGger 24 May 2016 < 25 / 48 >

31 The User point of view gdb like Breakpoints Set breakpoints via strings the form : node or file::line let brkpts = ref [] let ( break : string -> unit ) = fun str -> brkpts := str ::! brkpts let ( delete : unit -> unit ) = fun () -> brkpts := [] let ( continue : Event. t -> Event. t ) = fun e -> let stop e = List. exists ( brk_matches e )! brkpts in next_cond e stop rdbg a Reactive programs DeBuGger 24 May 2016 < 26 / 48 >

32 The User point of view gdb like Breakpoints (cont) let ( brk_matches : Event. t -> string -> bool ) = fun e b -> let s i_match_file str si = ( si. file = str basename si. file = str ) in let s i_match_line ln { line =( d, f ) } = ( d <= ios && ios i <= f ) in match e. sinfo, Str. split ( Str. regexp " :: " ) b with None, _ _, [] -> false (* no more BP *) Some src, str :: tail -> let src = src () in match tail with [ ln ] -> List. exists ( fun si -> s i_match_file str si && si_match_line ln si ) src. atoms [] -> List. exists ( si_match_file str ) src. atoms _ -> false Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 27 / 48 >

33 The User point of view Profiling let prof_tbl = Hashtbl. create 50 let incr_prof si = try let cpt = Hashtbl. find prof_tbl si in Hashtbl. replace prof_tbl si ( cpt +1) with Not_found -> Hashtbl. add prof_tbl si 1 let ( prof_add : Event. t -> unit ) = fun e -> match to_lut_evt e. kind, e. sinfo with ( Sat Nsat ), Some src -> List. iter incr_prof ( src () ). atoms _ -> () let set_profiler on = if on then add_hooks ( " profile ", prof_add ) else del_hooks " profile " Demo rdbg a Reactive programs DeBuGger 24 May 2016 < 28 / 48 >

34 The User point of view Time Profiling Save the Unix.time() at call events Accumulate the difference at exit events rdbg a Reactive programs DeBuGger 24 May 2016 < 29 / 48 >

35 The Compiler designer point of view Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 30 / 48 >

36 The Compiler designer point of view The rdbg Plugin Mechanism To plug onto rdbg, one just need to provide cma/cmxs (dynamic ocamlopt code library) that implements this interface : type sl = ( string * Data. v ) list (* substitutions *) type e = Event. t (* a shortcut for the remaining *) type t = { inputs :( Data. ident * Data. t ) list ; (* name and type *) outputs : ( Data. ident * Data. t ) list ; (* ditto *) init_inputs : sl ; init_outputs : sl ; step : ( sl -> sl ) ; (* Lurette step *) step_dbg : ( sl -> e -> ( sl -> e -> e ) -> e ) ; (* RDBG step *) kill : string -> unit ; } opam install rdbg git clone rdbg a Reactive programs DeBuGger 24 May 2016 < 31 / 48 >

37 Design issues Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 32 / 48 >

38 Design issues Programmable debuggers To navigate through the event list, two primitives are necessary one that retrieves runtime information one to go one step forward But in order to avoid context switches, it s better to do the computations in the debuggee process rdbg a Reactive programs DeBuGger 24 May 2016 < 33 / 48 >

39 Design issues Debuggers - Coroutine Debugger / debuggee Processes communicate via signals/ptrace (gdb) pipes or sockets (camldebug, jdwp,... ) Objective : avoid context switches! rdbg a Reactive programs DeBuGger 24 May 2016 < 34 / 48 >

40 Design issues Debuggers - how to avoid context switches Runtime instrumentation of the debuggee dynamic bytecode loading for ocamldebug ptrace for gdb But of course the instrumentation code is very simple (breakpoints) In particular, no debugger-user code For the Lustre and the Lutin plugin, we have chosen to implement the coroutine using continuations rdbg a Reactive programs DeBuGger 24 May 2016 < 35 / 48 >

41 Design issues Transform the interpreter code into CPS [1/2] -- Vanilla lurette top loop let p a b = a + b let step_env a = p a 1 let step_sut a = p a 2 let rec loop i a = if i >42 then raise ( End a ) else let b = step_env a in let c = step_sut b in loop ( i +1) c rdbg a Reactive programs DeBuGger 24 May 2016 < 36 / 48 >

42 Design issues Transform the interpreter code into CPS [2/2] -- lurettop loop -- CPS version let p a b = a + b let p a b ct = ct ( a + b ) let step_env a = p a 1 let step_env a ct = p a 1 ct let step_sut a = p a 2 let step_sut a ct = p a 2 ct let rec loop i a = let rec loop i a = if i >42 then if i > 42 then raise ( End a ) else raise ( End a ) else let b = step_env a in step_env a ( loop2 i ) let c = step_sut b in and loop2 i b = step_sut b loop ( i +1) c ( loop ( i +1) ) rdbg a Reactive programs DeBuGger 24 May 2016 < 37 / 48 >

43 Adding Events [1/2] Design issues The CPS functions never return Hence it s easy to add events at each event locations type event = { cont : unit -> event ; msg : string ; -- step : int ; -- depth : int ; -- data : substs ; -- src : string ; } rdbg a Reactive programs DeBuGger 24 May 2016 < 38 / 48 >

44 Adding Events [2/2] Design issues let plus a b cont = { msg = sprintf("%i+%i" a b); cont = fun () -> cont (a+b) } let step_env a cont = { msg = "step_env" ; cont = fun () -> plus a 1 cont } let step_sut a cont = { msg = "step_sut" ; cont = fun () -> plus a 2 cont } let rec loop2 i b = step_sut b (loop (i+1)) and loop i a = if a > 42 then raise (End a) else { msg = "top"; cont = fun () ->step_env a (loop2 i)} rdbg a Reactive programs DeBuGger 24 May 2016 < 39 / 48 >

45 Design issues Design issues - Advantages of continuations No msg writing/parsing between the 2 entities No context switches, which matters for debugging programs that interact at each step with the debuggee Very easy instrumentation (for code written in CPS... ) (Very easy access to all the internal data structures) rdbg a Reactive programs DeBuGger 24 May 2016 < 40 / 48 >

46 Design issues Design issues 1. Transform Lurettetop into an ocaml top-level (5 seconds) 2. Transform part of Lurettetop/Lutin interpreters into CPS (1 week) 3. Instrument this with Event.t (a few minutes) 4. Add source level information to Event.t (a few days) 5. Write Rdbg_utils on top of that (cf previous slides) 6. Fix evil details (... ) rdbg a Reactive programs DeBuGger 24 May 2016 < 41 / 48 >

47 Design issues Performance let rec finish e = finish ( e. next () ) Less than 1% of penalty : on a simple Lutin program that performs 4 node calls (worst case?) Native versus bytecode : x5 but a native toplevel exists (ocamlnat) profiler : 30% penalty rdbg a Reactive programs DeBuGger 24 May 2016 < 42 / 48 >

48 Design issues demo rdbg-top : ocaml top-level + rdbg libs Demo! nb : an ocaml-top wrapper so that it looks as a normal debugger auto-loads libs generates initial sessions communicates with rdbg-top via pipes add () and ; ; a blank a as first character inhibits this wrapping rdbg a Reactive programs DeBuGger 24 May 2016 < 43 / 48 >

49 Conclusion Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 44 / 48 >

50 Conclusion 3 orthogonal ideas Programmable debugger coroutine via continuations for reactive programs rdbg a Reactive programs DeBuGger 24 May 2016 < 45 / 48 >

51 Conclusion Conclusion Cons Pros Possible because Lutin is interpreted, and Lustre has an interpreter Need to modify (pollute?) an interpreter that ought to be written in ocaml! (but the idea would apply for any other language equipped with a read-eval-print interpretation loop) Lightweight implementation (1 week to get a first kernel) Efficient (well... ok, it s kind of a lie) Programmable! Separation of concerns a tiny kernel : run : Rdbg.args -> Event.t a simple plugin API : YourGreatLanguage.run : Rdbg.args -> Event.t a rich set of commands easily build on top of it which could be reused on other kernels rdbg a Reactive programs DeBuGger 24 May 2016 < 46 / 48 >

52 Conclusion The end Thanks for your attention rdbg a Reactive programs DeBuGger 24 May 2016 < 47 / 48 >

53 Conclusion Coverage The previous profiler generates the covered code Another tool is needed to compute the set of code sites to be covered rdbg a Reactive programs DeBuGger 24 May 2016 < 48 / 48 >

54 Outline 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 2 / 48 >

55 Debugging Reactive Programs Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 3 / 48 >

56 Debugging Reactive Programs 3 orthogonal ideas Programmable debugger rdbg a Reactive programs DeBuGger 24 May 2016 < 4 / 48 >

57 Debugging Reactive Programs 3 orthogonal ideas Programmable debugger for reactive programs rdbg a Reactive programs DeBuGger 24 May 2016 < 4 / 48 >

58 Debugging Reactive Programs 3 orthogonal ideas Programmable debugger coroutine via continuations for reactive programs rdbg a Reactive programs DeBuGger 24 May 2016 < 4 / 48 >

59 Debugging Reactive Programs Programming Reactive systems Reactive systems in continuous interaction with their environments often critical rdbg a Reactive programs DeBuGger 24 May 2016 < 5 / 48 >

60 Debugging Reactive Programs Programming Reactive systems Reactive systems in continuous interaction with their environments often critical Synchronous languages clean semantics w.r.t. time (discrete) and parallelism (perfect) compiled into statically scheduled tasks typically embedded in OS-free systems bounded memory and execution time (no while loop) program-level formal verification rdbg a Reactive programs DeBuGger 24 May 2016 < 5 / 48 >

61 Debugging Reactive Programs Programming Reactive systems Reactive systems in continuous interaction with their environments often critical Synchronous languages Lustre clean semantics w.r.t. time (discrete) and parallelism (perfect) compiled into statically scheduled tasks typically embedded in OS-free systems bounded memory and execution time (no while loop) program-level formal verification Generalised synchronous circuits : wires hold numerics types and clocks (when to compute) Scade (Esterel-Technologies) rdbg a Reactive programs DeBuGger 24 May 2016 < 5 / 48 >

62 Debugging Reactive Programs Testing Reactive Programs formal verification can be too costly But formal descriptions of the environment and expected properties can be used for black-box automated testing Lurette : the tool that performs all the red tape (plumbering) between the SUT, its env, and the oracles Lutin : a language to program non-deterministic reactive systems Lustre + control-structure + stochastic choices Stimulus (Argosim ; 2013 ) rdbg a Reactive programs DeBuGger 24 May 2016 < 6 / 48 >

63 Debugging Reactive Programs Debugging Reactive Programs What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 >

64 Debugging Reactive Programs Debugging Reactive Programs What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline Need to program reactive programs environments That s precisely what Lurette and Lutin do rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 >

65 Debugging Reactive Programs Debugging Reactive Programs What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline Need to program reactive programs environments That s precisely what Lurette and Lutin do The idea is to reuse the Lurette infrastructure rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 >

66 Debugging Reactive Programs Debugging Reactive Programs What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline Need to program reactive programs environments That s precisely what Lurette and Lutin do The idea is to reuse the Lurette infrastructure nb : Lutin environments models are also programs that needs debugging rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 >

67 Debugging Reactive Programs Debugging Reactive Programs What is specific to reactive/synchronous programs? We need a lot of inputs The feedback loop makes it difficult to provide realistic inputs offline Need to program reactive programs environments That s precisely what Lurette and Lutin do The idea is to reuse the Lurette infrastructure nb : Lutin environments models are also programs that needs debugging rdbg targets any kind of reactive languages, but currently works with Lustre and Lutin rdbg a Reactive programs DeBuGger 24 May 2016 < 7 / 48 >

68 Debugging Reactive Programs Debugger A program execution = list of events (observation points) An event is a tuple of runtime information (execution) rdbg a Reactive programs DeBuGger 24 May 2016 < 8 / 48 >

69 Debugging Reactive Programs Debugger A program execution = list of events (observation points) An event is a tuple of runtime information (execution) an event out to be defined w.r.t. to the operational semantics of the language (e.g., an instruction for imperative languages) in gdb an event is a line in the source rdbg a Reactive programs DeBuGger 24 May 2016 < 8 / 48 >

70 Debugging Reactive Programs Debugger A program execution = list of events (observation points) An event is a tuple of runtime information (execution) an event out to be defined w.r.t. to the operational semantics of the language (e.g., an instruction for imperative languages) in gdb an event is a line in the source A debugger is a program that works in coroutine with the debuggee, and that is able to inspect event contents and to navigate through the event list rdbg a Reactive programs DeBuGger 24 May 2016 < 8 / 48 >

71 Debugging Reactive Programs Designing Programmable debugger easily Why programmable? because debugger users are programmers (always) because debugging can be difficult moreover it s not hard to do! rdbg a Reactive programs DeBuGger 24 May 2016 < 9 / 48 >

72 Debugging Reactive Programs Designing Programmable debugger easily Why programmable? because debugger users are programmers (always) because debugging can be difficult moreover it s not hard to do! How 1. Given a pre-defined instrumentation of the debuggee process, providing an API that lets one inspect the debuggee runtime state (event) with well-chosen information at well-chosen observation point go to the next event rdbg a Reactive programs DeBuGger 24 May 2016 < 9 / 48 >

73 Debugging Reactive Programs Designing Programmable debugger easily Why programmable? because debugger users are programmers (always) because debugging can be difficult moreover it s not hard to do! How 1. Given a pre-defined instrumentation of the debuggee process, providing an API that lets one inspect the debuggee runtime state (event) with well-chosen information at well-chosen observation point go to the next event 2. Given a host language equipped with a good library an interactive interpreter (i.e., a read-eval-print toplevel loop) rdbg a Reactive programs DeBuGger 24 May 2016 < 9 / 48 >

74 Debugging Reactive Programs Designing Programmable debugger easily Why programmable? because debugger users are programmers (always) because debugging can be difficult moreover it s not hard to do! How 1. Given a pre-defined instrumentation of the debuggee process, providing an API that lets one inspect the debuggee runtime state (event) with well-chosen information at well-chosen observation point go to the next event 2. Given a host language equipped with a good library an interactive interpreter (i.e., a read-eval-print toplevel loop) Claim : then one can easily obtain a full-fledged extensible debugger by programming its own custom primitives that navigate through the event list custom primitives that perform runtime analysis (monitors) rdbg a Reactive programs DeBuGger 24 May 2016 < 9 / 48 >

75 rdbg : a programmable debugger for reactive programs Plan 1 Debugging Reactive Programs 2 rdbg : a programmable debugger for reactive programs 3 The User point of view 4 The Compiler designer point of view 5 Design issues 6 Conclusion rdbg a Reactive programs DeBuGger 24 May 2016 < 10 / 48 >

76 rdbg : a programmable debugger for reactive programs Which host language? The Lutin interpreter and the Lustre V6 compiler are programmed in Ocaml Lurette is programmed in Ocaml too Ocaml has good libraries and a good interactive read-eval-print toplevel interpreter rdbg a Reactive programs DeBuGger 24 May 2016 < 11 / 48 >

77 rdbg : a programmable debugger for reactive programs Which host language? The Lutin interpreter and the Lustre V6 compiler are programmed in Ocaml Lurette is programmed in Ocaml too Ocaml has good libraries and a good interactive read-eval-print toplevel interpreter It sounds like a good candidate for the host language rdbg a Reactive programs DeBuGger 24 May 2016 < 11 / 48 >

78 rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next ENV SUT PRE LUCIOLE rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 >

79 rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next ENV SUT oracle PRE LUCIOLE rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 >

80 rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next ENV SUT oracle PRE LUCIOLE.rif sim2chro rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 >

81 rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next ENV SUT oracle PRE LUCIOLE.rif sim2chro ocamlkmktop an interactive interpreter with all Lurette modules 2 functions run : Rdbg.args -> Event.t next : Event.t -> Event.t rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 >

82 rdbg : a programmable debugger for reactive programs rdbg : a Lurette ocaml toplevel + run + next ENV SUT oracle PRE LUCIOLE.rif sim2chro ocamlkmktop an interactive interpreter with all Lurette modules 2 functions run : Rdbg.args -> Event.t next : Event.t -> Event.t args is made of Lurette parameters : sut names, env names, oracle names, test length, rif file name, etc. Demonstration rdbg a Reactive programs DeBuGger 24 May 2016 < 12 / 48 >

83 rdbg : a programmable debugger for reactive programs Defining events An event is an observation point The most difficult part Closely related to the language semantics A trade-off between completeness and efficiency rdbg a Reactive programs DeBuGger 24 May 2016 < 13 / 48 >

84 rdbg : a programmable debugger for reactive programs Defining events An event is an observation point The most difficult part Closely related to the language semantics A trade-off between completeness and efficiency Two dimensions : where to put events what an event contains rdbg a Reactive programs DeBuGger 24 May 2016 < 13 / 48 >

85 rdbg : a programmable debugger for reactive programs Events Kind of events : call : when entering a node exit : when exiting a node microstep(string) : holds info related to the sub-lang micro-step rdbg a Reactive programs DeBuGger 24 May 2016 < 14 / 48 >

86 rdbg : a programmable debugger for reactive programs Events Kind of events : call : when entering a node exit : when exiting a node microstep(string) : holds info related to the sub-lang micro-step Events specific to Lutin : microstep("try") : a choice is performed in the control structure microstep("sat") : the chosen constraint is satisfiable microstep("unsat") : the chosen constraint is unsatisfiable rdbg a Reactive programs DeBuGger 24 May 2016 < 14 / 48 >

87 rdbg : a programmable debugger for reactive programs The rdbg API [1/2] type kind = Ltop Call Exit MicroStep of string rdbg a Reactive programs DeBuGger 24 May 2016 < 15 / 48 >

Recap: Functions as first-class values

Recap: Functions as first-class values Recap: Functions as first-class values Arguments, return values, bindings What are the benefits? Parameterized, similar functions (e.g. Testers) Creating, (Returning) Functions Iterator, Accumul, Reuse

More information

Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode

Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode Damien Ciabrini Manuel Serrano firstname.lastname@sophia.inria.fr INRIA Sophia Antipolis 2004 route des Lucioles - BP 93 F-06902

More information

CS3210: Tutorial Session 2. Kyuhong Park-- edited by Kyle Harrigan

CS3210: Tutorial Session 2. Kyuhong Park-- edited by Kyle Harrigan 1 CS3210: Tutorial Session 2 Kyuhong Park-- edited by Kyle Harrigan 2 Overview Goal: Understand C and GDB Part1: C Programming Part2: GDB Part3: In-class Exercises 3 Revised Tutorial Format Recommended

More information

Debug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args>

Debug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args> Page 1 of 5 Debug for GDB Users Basic Control To be useful, a debugger must be capable of basic process control. This functionally allows the user to create a debugging session and instruct the process

More information

Parsing Scheme (+ (* 2 3) 1) * 1

Parsing Scheme (+ (* 2 3) 1) * 1 Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes

More information

Testing and Debugging C Programming and Software Tools. N.C. State Department of Computer Science

Testing and Debugging C Programming and Software Tools. N.C. State Department of Computer Science Testing and Debugging C Programming and Software Tools N.C. State Department of Computer Science Introduction Majority of software development is testing, debugging, and bug fixing The best software developers

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language

More information

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values CSE 130: Programming Languages Environments & Closures News PA 3 due THIS Friday (5/1) Midterm NEXT Friday (5/8) Ranjit Jhala UC San Diego Recap: Functions as first-class values Arguments, return values,

More information

<Insert Picture Here> Multi-language JDI? You're Joking, Right?

<Insert Picture Here> Multi-language JDI? You're Joking, Right? Multi-language JDI? You're Joking, Right? Jim Laskey Multi-language Lead Java Language and Tools Group The following is intended to outline our general product direction. It is intended

More information

Debugging in LISP. trace causes a trace to be printed for a function when it is called

Debugging in LISP. trace causes a trace to be printed for a function when it is called trace causes a trace to be printed for a function when it is called ;;; a function that works like reverse (defun rev (list) (cons (first (last list)) (rev (butlast list)))) USER: (trace rev) ; note trace

More information

Introduction to Problem Solving and Programming in Python.

Introduction to Problem Solving and Programming in Python. Introduction to Problem Solving and Programming in Python http://cis-linux1.temple.edu/~tuf80213/courses/temple/cis1051/ Overview Types of errors Testing methods Debugging in Python 2 Errors An error in

More information

Programming Embedded Systems

Programming Embedded Systems Programming Embedded Systems Lecture 10 An introduction to Lustre Wednesday Feb 15, 2012 Philipp Rümmer Uppsala University Philipp.Ruemmer@it.uu.se 1/34 Course topic: programming lang. Which language to

More information

Programming Languages and Compilers (CS 421)

Programming Languages and Compilers (CS 421) Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illinois.edu/cs421 Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul Agha 9/18/17

More information

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Interpreters. Prof. Clarkson Fall Today s music: Step by Step by New Kids on the Block

Interpreters. Prof. Clarkson Fall Today s music: Step by Step by New Kids on the Block Interpreters Prof. Clarkson Fall 2017 Today s music: Step by Step by New Kids on the Block Review Previously in 3110: functional programming modular programming data structures Today: new unit of course:

More information

n What is its running time? 9/18/17 2 n poor_rev [1,2,3] = n (poor_rev [1] = n ((poor_rev [1] =

n What is its running time? 9/18/17 2 n poor_rev [1,2,3] = n (poor_rev [1] = n ((poor_rev  [1] = Recall Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illinois.edu/cs421 Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul Agha

More information

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 21, 2016

Midterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 21, 2016 Name: Midterm 2 CMSC 430 Introduction to Compilers Fall 2016 November 21, 2016 Instructions This exam contains 7 pages, including this one. Make sure you have all the pages. Write your name on the top

More information

Testing. Lydie du Bousquet, Ioannis Parissis. TAROT Summer School July (TAROT 2009)

Testing. Lydie du Bousquet, Ioannis Parissis. TAROT Summer School July (TAROT 2009) Testing TAROT Summer School Lustre/SCADE programs 2009 - July 6-10 Lydie du Bousquet, Ioannis Parissis 1 (TAROT 2009) Synchrone Scade/Lustre Siesta Issues 2 Synchronous / safety-critical software control/command

More information

GDB QUICK REFERENCE GDB Version 4

GDB QUICK REFERENCE GDB Version 4 GDB QUICK REFERENCE GDB Version 4 Essential Commands gdb program [core] debug program [using coredump core] b [file:]function run [arglist] bt p expr c n s set breakpoint at function [in file] start your

More information

Konzepte von Programmiersprachen

Konzepte von Programmiersprachen Konzepte von Programmiersprachen Chapter 5: Continuation-Passing Interpreters Stefan Wehr Universität Freiburg 8. Juni 2009 Konzepte von Programmiersprachen 1 / 43 Motivation Continuations: abstraction

More information

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni Using the Debugger Michael Jantz Dr. Prasad Kulkarni 1 Debugger What is it a powerful tool that supports examination of your program during execution. Idea behind debugging programs. Creates additional

More information

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017 Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017 Goal: write programs in a high-level (ML-style) language, prove them correct interactively,

More information

Static Analysis of Dynamically Typed Languages made Easy

Static Analysis of Dynamically Typed Languages made Easy Static Analysis of Dynamically Typed Languages made Easy Yin Wang School of Informatics and Computing Indiana University Overview Work done as two internships at Google (2009 summer and 2010 summer) Motivation:

More information

Hard deadline: 3/28/15 1:00pm. Using software development tools like source control. Understanding the environment model and type inference.

Hard deadline: 3/28/15 1:00pm. Using software development tools like source control. Understanding the environment model and type inference. CS 3110 Spring 2015 Problem Set 3 Version 0 (last modified March 12, 2015) Soft deadline: 3/26/15 11:59pm Hard deadline: 3/28/15 1:00pm Overview In this assignment you will implement several functions

More information

Variables and Bindings

Variables and Bindings Net: Variables Variables and Bindings Q: How to use variables in ML? Q: How to assign to a variable? # let = 2+2;; val : int = 4 let = e;; Bind the value of epression e to the variable Variables and Bindings

More information

Metaprogramming assignment 3

Metaprogramming assignment 3 Metaprogramming assignment 3 Optimising embedded languages Due at noon on Thursday 29th November 2018 This exercise uses the BER MetaOCaml compiler, which you can install via opam. The end of this document

More information

OCaml Programming Tools. Letterio Galletta AP Lecture 03/10/2016

OCaml Programming Tools. Letterio Galletta AP Lecture 03/10/2016 OCaml Programming Tools Letterio Galletta AP Lecture 03/10/2016 Today s lecture: tools for OCaml development tryocaml ocaml opam ocamlc ocamlopt ocamlrun ocamlmktop ocamlbuild ocamlcp/ocamloptp ocamlprof

More information

Chapter 1. Fundamentals of Higher Order Programming

Chapter 1. Fundamentals of Higher Order Programming Chapter 1 Fundamentals of Higher Order Programming 1 The Elements of Programming Any powerful language features: so does Scheme primitive data procedures combinations abstraction We will see that Scheme

More information

Debugger Copyright Ericsson AB. All Rights Reserved. Debugger September 24, 2018

Debugger Copyright Ericsson AB. All Rights Reserved. Debugger September 24, 2018 Debugger Copyright 1997-2018 Ericsson AB. All Rights Reserved. Debugger 4.2.6 September 24, 2018 Copyright 1997-2018 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the

More information

Software Engineering

Software Engineering Software Engineering Lecture 16: Testing and Debugging Debugging Peter Thiemann University of Freiburg, Germany SS 2014 Today s Topic This Lecture Execution observation Tracking causes and effects Central

More information

Understanding the Program Run

Understanding the Program Run 0/45 Understanding the Program Run Andreas Zeller Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken Isolating Failure Causes 1/45 So far, we have seen how to isolate causes in the environment

More information

Intel Parallel Studio XE 2017 Composer Edition BETA C++ - Debug Solutions Release Notes

Intel Parallel Studio XE 2017 Composer Edition BETA C++ - Debug Solutions Release Notes Developer Zone Intel Parallel Studio XE 2017 Composer Edition BETA C++ - Debug Solutions Release Notes Submitted by Georg Z. (Intel) on August 5, 2016 This page provides the current Release Notes for the

More information

The Environment Model. Nate Foster Spring 2018

The Environment Model. Nate Foster Spring 2018 The Environment Model Nate Foster Spring 2018 Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax: BNF Formal semantics: dynamic: small-step substitution model static semantics

More information

OCaml. ML Flow. Complex types: Lists. Complex types: Lists. The PL for the discerning hacker. All elements must have same type.

OCaml. ML Flow. Complex types: Lists. Complex types: Lists. The PL for the discerning hacker. All elements must have same type. OCaml The PL for the discerning hacker. ML Flow Expressions (Syntax) Compile-time Static 1. Enter expression 2. ML infers a type Exec-time Dynamic Types 3. ML crunches expression down to a value 4. Value

More information

An Introduction to Lustre

An Introduction to Lustre An Introduction to Lustre Monday Oct 06, 2014 Philipp Rümmer Uppsala University Philipp.Ruemmer@it.uu.se 1/35 ES Programming languages Which language to write embedded software in? Traditional: low-level

More information

Streams, Delayed Evaluation and a Normal Order Interpreter. CS 550 Programming Languages Jeremy Johnson

Streams, Delayed Evaluation and a Normal Order Interpreter. CS 550 Programming Languages Jeremy Johnson Streams, Delayed Evaluation and a Normal Order Interpreter CS 550 Programming Languages Jeremy Johnson 1 Theme This lecture discusses the stream model of computation and an efficient method of implementation

More information

CSC 533: Programming Languages. Spring 2015

CSC 533: Programming Languages. Spring 2015 CSC 533: Programming Languages Spring 2015 Functional programming LISP & Scheme S-expressions: atoms, lists functional expressions, evaluation, define primitive functions: arithmetic, predicate, symbolic,

More information

Abram Hindle Kitchener Waterloo Perl Monger October 19, 2006

Abram Hindle Kitchener Waterloo Perl Monger   October 19, 2006 OCaml Tutorial Abram Hindle Kitchener Waterloo Perl Monger http://kw.pm.org abez@abez.ca October 19, 2006 Abram Hindle 1 OCaml Functional Language Multiple paradigms: Imperative, Functional, Object Oriented

More information

CS Lecture 14: Hash tables. Prof. Clarkson Spring Today s music: Re-hash by Gorillaz

CS Lecture 14: Hash tables. Prof. Clarkson Spring Today s music: Re-hash by Gorillaz CS 3110 Lecture 14: Hash tables Prof. Clarkson Spring 2015 Today s music: Re-hash by Gorillaz Review Recently: Data abstractions Lists, stacks, queues, dictionaries, polynomials,... Imperative features

More information

Programming Languages

Programming Languages CSE 130 : Spring 2011 Programming Languages Lecture 3: Crash Course Ctd, Expressions and Types Ranjit Jhala UC San Diego A shorthand for function binding # let neg = fun f -> fun x -> not (f x); # let

More information

Getting Started with Python

Getting Started with Python Fundamentals of Programming (Python) Getting Started with Python Sina Sajadmanesh Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science

More information

SMBC: Engineering a Fast Solver in OCaml

SMBC: Engineering a Fast Solver in OCaml SMBC: Engineering a Fast Solver in OCaml Simon Cruanes Veridis, Inria Nancy https://cedeela.fr/~simon/ 28th of March, 2017 Simon Cruanes SMBC 28th of March, 2017 1 / 17 Summary 1 Presentation of SMBC (

More information

Software Engineering

Software Engineering Software Engineering Lecture 12: Testing and Debugging Debugging Peter Thiemann University of Freiburg, Germany 13.06.2013 Today s Topic Last Lecture Bug tracking Program control Design for Debugging Input

More information

HotPy (2) Binary Compatible High Performance VM for Python. Mark Shannon

HotPy (2) Binary Compatible High Performance VM for Python. Mark Shannon HotPy (2) Binary Compatible High Performance VM for Python Mark Shannon Who am I? Mark Shannon PhD thesis on building VMs for dynamic languages During my PhD I developed: GVMT. A virtual machine tool kit

More information

The Lustre Language Synchronous Programming Pascal Raymond, Nicolas Halbwachs Verimag-CNRS

The Lustre Language Synchronous Programming Pascal Raymond, Nicolas Halbwachs Verimag-CNRS The Lustre Language Synchronous Programming Pascal Raymond, Nicolas Halbwachs Verimag-CNRS Data-flow approach 2 A program = a network of operators connected by wires Rather classical (control theory, circuits)

More information

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. OS and Computer Architecture Last class: OS and Architecture OS and Computer Architecture OS Service Protection Interrupts System Calls IO Scheduling Synchronization Virtual Memory Hardware Support Kernel/User Mode Protected Instructions

More information

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components Last class: OS and Architecture Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation

More information

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, "hi", 3.2), c 4, a 1, b 5} 9/10/2017 4

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, hi, 3.2), c 4, a 1, b 5} 9/10/2017 4 Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a # true;; - : bool = true # false;; - : bool

More information

Unit- and Sequence Test Generation with HOL-TestGen

Unit- and Sequence Test Generation with HOL-TestGen Unit- and Sequence Test Generation with HOL-TestGen Tests et Methodes Formelles Prof. Burkhart Wolff Univ - Paris-Sud / LRI 16.6.2015 B.Wolff - HOL-TestGen 1 Overview HOL-TestGen and its Business-Case

More information

InterprocStack analyzer for recursive programs with finite-type and numerical variables

InterprocStack analyzer for recursive programs with finite-type and numerical variables InterprocStack analyzer for recursive programs with finite-type and numerical variables Bertrand Jeannet Contents 1 Invoking InterprocStack 1 2 The Simple language 2 2.1 Syntax and informal semantics.........................

More information

Introduction to Programming (Java) 2/12

Introduction to Programming (Java) 2/12 Introduction to Programming (Java) 2/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Monolingual probabilistic programming using generalized coroutines

Monolingual probabilistic programming using generalized coroutines Monolingual probabilistic programming using generalized coroutines Oleg Kiselyov FNMOC oleg@pobox.com Chung-chieh Shan Rutgers University ccshan@cs.rutgers.edu 19 June 2009 This session... programming

More information

Threads and Continuations COS 320, David Walker

Threads and Continuations COS 320, David Walker Threads and Continuations COS 320, David Walker Concurrency Concurrency primitives are an important part of modern programming languages. Concurrency primitives allow programmers to avoid having to specify

More information

Overview of the Ruby Language. By Ron Haley

Overview of the Ruby Language. By Ron Haley Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,

More information

Recap. Recap. If-then-else expressions. If-then-else expressions. If-then-else expressions. If-then-else expressions

Recap. Recap. If-then-else expressions. If-then-else expressions. If-then-else expressions. If-then-else expressions Recap Epressions (Synta) Compile-time Static Eec-time Dynamic Types (Semantics) Recap Integers: +,-,* floats: +,-,* Booleans: =,

More information

The Environment Model

The Environment Model The Environment Model Prof. Clarkson Fall 2017 Today s music: Selections from Doctor Who soundtracks by Murray Gold Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax: BNF

More information

CS 314 Principles of Programming Languages. Lecture 9

CS 314 Principles of Programming Languages. Lecture 9 CS 314 Principles of Programming Languages Lecture 9 Zheng Zhang Department of Computer Science Rutgers University Wednesday 5 th October, 2016 Zheng Zhang 1 CS@Rutgers University Class Information Homework

More information

A native compiler for Coq: current status, perspectives and discussion 1

A native compiler for Coq: current status, perspectives and discussion 1 A native compiler for Coq A native compiler for Coq: current status, perspectives and discussion 1 Maxime Dénès, jww M. Boespflug and B. Grégoire Marelle Team, INRIA Sophia-Antipolis February 19, 2013

More information

CS4215 Programming Language Implementation

CS4215 Programming Language Implementation CS4215 Programming Language Implementation You have 45 minutes to complete the exam. Use a B2 pencil to fill up the provided MCQ form. Leave Section A blank. Fill up Sections B and C. After finishing,

More information

Program Design: Using the Debugger

Program Design: Using the Debugger rogram Design, February 2, 2004 1 Program Design: Using the Debugger A debugger is an alternative to putting print (printf in C) statements in your program, recompiling and trying to find out what values

More information

Laboratory 1 Semester 1 11/12

Laboratory 1 Semester 1 11/12 CS2106 National University of Singapore School of Computing Laboratory 1 Semester 1 11/12 MATRICULATION NUMBER: In this lab exercise, you will get familiarize with some basic UNIX commands, editing and

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

CS 360 Programming Languages Interpreters

CS 360 Programming Languages Interpreters CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like

More information

Side note: Tail Recursion. Begin at the beginning. Side note: Tail Recursion. Base Types. Base Type: int. Base Type: int

Side note: Tail Recursion. Begin at the beginning. Side note: Tail Recursion. Base Types. Base Type: int. Base Type: int Begin at the beginning Epressions (Synta) Compile-time Static Eec-time Dynamic Types Values (Semantics) 1. Programmer enters epression 2. ML checks if epression is well-typed Using a precise set of rules,

More information

Programs as data first-order functional language type checking

Programs as data first-order functional language type checking Programs as data first-order functional language type checking Copyright 2013-18, Peter Sestoft and Cesare Tinelli. Created by Cesare Tinelli at the University of Iowa from notes originally developed by

More information

Tail Recursion: Factorial. Begin at the beginning. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial

Tail Recursion: Factorial. Begin at the beginning. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial Begin at the beginning Epressions (Synta) Compile-time Static Eec-time Dynamic Types Values (Semantics) 1. Programmer enters epression 2. ML checks if epression is well-typed Using a precise set of rules,

More information

Background. From my PhD (2009): Verified Lisp interpreter in ARM, x86 and PowerPC machine code

Background. From my PhD (2009): Verified Lisp interpreter in ARM, x86 and PowerPC machine code Certification of high-level and low-level programs, IHP, Paris, 2014 CakeML A verified implementation of ML Ramana Kumar Magnus Myreen Michael Norrish Scott Owens Background From my PhD (2009): Verified

More information

LECTURE 16. Functional Programming

LECTURE 16. Functional Programming LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative

More information

CMSC 330: Organization of Programming Languages. OCaml Expressions and Functions

CMSC 330: Organization of Programming Languages. OCaml Expressions and Functions CMSC 330: Organization of Programming Languages OCaml Expressions and Functions CMSC330 Spring 2018 1 Lecture Presentation Style Our focus: semantics and idioms for OCaml Semantics is what the language

More information

DEBUGGING: DYNAMIC PROGRAM ANALYSIS

DEBUGGING: DYNAMIC PROGRAM ANALYSIS DEBUGGING: DYNAMIC PROGRAM ANALYSIS WS 2017/2018 Martina Seidl Institute for Formal Models and Verification System Invariants properties of a program must hold over the entire run: integrity of data no

More information

Programming Languages and Compilers (CS 421)

Programming Languages and Compilers (CS 421) Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illinois.edu/cs421 Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul Agha 9/11/17

More information

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages Call-by-value Operational Semantics

More information

Fundamentals of Programming (Python) Getting Started with Programming

Fundamentals of Programming (Python) Getting Started with Programming Fundamentals of Programming (Python) Getting Started with Programming Ali Taheri Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science

More information

Testing, Debugging, Program Verification

Testing, Debugging, Program Verification Testing, Debugging, Program Verification Debugging Programs, Part II Wolfgang Ahrendt & Vladimir Klebanov & Moa Johansson & Gabriele Paganelli 14 November 2012 TDV: Debugging II /GU 2011-11-09 1 / 32 Today

More information

JDB - QUICK GUIDE JDB - INTRODUCTION

JDB - QUICK GUIDE JDB - INTRODUCTION http://www.tutorialspoint.com/jdb/jdb_quick_guide.htm JDB - QUICK GUIDE Copyright tutorialspoint.com JDB - INTRODUCTION Debugging is a technical procedure to find and remove bugs or defects in a program

More information

Checkpointing using DMTCP, Condor, Matlab and FReD

Checkpointing using DMTCP, Condor, Matlab and FReD Checkpointing using DMTCP, Condor, Matlab and FReD Gene Cooperman (presenting) High Performance Computing Laboratory College of Computer and Information Science Northeastern University, Boston gene@ccs.neu.edu

More information

CMSC 330: Organization of Programming Languages. Rust Basics

CMSC 330: Organization of Programming Languages. Rust Basics CMSC 330: Organization of Programming Languages Rust Basics CMSC330 Spring 2018 1 Organization It turns out that a lot of Rust has direct analogues in OCaml So we will introduce its elements with comparisons

More information

Programs as data Parsing cont d; first-order functional language, type checking

Programs as data Parsing cont d; first-order functional language, type checking Programs as data Parsing cont d; first-order functional language, type checking Peter Sestoft Monday 2009-09-14 Plan for today Exercises week 2 Parsing: LR versus LL How does an LR parser work Hand-writing

More information

A brief tour of history

A brief tour of history Introducing Racket λ A brief tour of history We wanted a language that allowed symbolic manipulation Scheme The key to understanding LISP is understanding S-Expressions Racket List of either atoms or

More information

Forward Recursion. Programming Languages and Compilers (CS 421) Mapping Recursion. Forward Recursion: Examples. Folding Recursion.

Forward Recursion. Programming Languages and Compilers (CS 421) Mapping Recursion. Forward Recursion: Examples. Folding Recursion. Forward Recursion Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://www.cs.uiuc.edu/class/cs421/ Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul

More information

Modular code generation from synchronous models:

Modular code generation from synchronous models: Modular code generation from synchronous models: modularity vs. reusability vs. code size Stavros Tripakis Joint work with Roberto Lublinerman, Penn State CHESS seminar, Berkeley, Feb 2009 1 Semantics-preserving

More information

Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Booleans and Short-Circuit Evaluation. Tuples as Values.

Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Booleans and Short-Circuit Evaluation. Tuples as Values. Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421d # true;; - : bool = true # false;; - : bool =

More information

Functional Languages. Hwansoo Han

Functional Languages. Hwansoo Han Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm

More information

Adam Chlipala University of California, Berkeley ICFP 2006

Adam Chlipala University of California, Berkeley ICFP 2006 Modular Development of Certified Program Verifiers with a Proof Assistant Adam Chlipala University of California, Berkeley ICFP 2006 1 Who Watches the Watcher? Program Verifier Might want to ensure: Memory

More information

COS 326 David Walker Princeton University

COS 326 David Walker Princeton University Functional Abstractions over Imperative Infrastructure and Lazy Evaluation COS 326 David Walker Princeton University slides copyright 2013-2015 David Walker and Andrew W. Appel permission granted to reuse

More information

CVO103: Programming Languages. Lecture 5 Design and Implementation of PLs (1) Expressions

CVO103: Programming Languages. Lecture 5 Design and Implementation of PLs (1) Expressions CVO103: Programming Languages Lecture 5 Design and Implementation of PLs (1) Expressions Hakjoo Oh 2018 Spring Hakjoo Oh CVO103 2018 Spring, Lecture 5 April 3, 2018 1 / 23 Plan Part 1 (Preliminaries):

More information

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of

More information

Using gdb to find the point of failure

Using gdb to find the point of failure gdb gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and g++, this is accomplished using the -g option,

More information

Lecture 2: Big-Step Semantics

Lecture 2: Big-Step Semantics Lecture 2: Big-Step Semantics 1 Representing Abstract Syntax These are examples of arithmetic expressions: 2 * 4 1 + 2 + 3 5 * 4 * 2 1 + 2 * 3 We all know how to evaluate these expressions in our heads.

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

Reverse Engineering with IDA Pro. CS4379/5375 Software Reverse Engineering Dr. Jaime C. Acosta

Reverse Engineering with IDA Pro. CS4379/5375 Software Reverse Engineering Dr. Jaime C. Acosta 1 Reverse Engineering with IDA Pro CS4379/5375 Software Reverse Engineering Dr. Jaime C. Acosta 2 Reversing Techniques Static Analysis Dynamic Analysis 3 Reversing Techniques Static Analysis (e.g., strings,

More information

CS 11 Ocaml track: lecture 2

CS 11 Ocaml track: lecture 2 Today: CS 11 Ocaml track: lecture 2 comments algebraic data types more pattern matching records polymorphic types ocaml libraries exception handling Previously... ocaml interactive interpreter compiling

More information

The Lurette V2 User Guide

The Lurette V2 User Guide Unité Mixte de Recherche 5104 CNRS - INPG - UJF Centre Equation 2, avenue de VIGNATE F-38610 GIERES tel : +33 456 52 03 40 fax : +33 456 52 03 50 http://www-verimag.imag.fr Report n o TR-2004-5 Initial

More information

Review of Scientific Programming in C and Fortran. Michael McLennan Software Architect HUBzero Platform for Scientific Collaboration

Review of Scientific Programming in C and Fortran. Michael McLennan Software Architect HUBzero Platform for Scientific Collaboration Review of Scientific Programming in C and Fortran Michael McLennan Software Architect HUBzero Platform for Scientific Collaboration Monte Carlo Simulator Simulate by randomly generating thousands of tracks?

More information

Java: framework overview and in-the-small features

Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Announcements. Working on requirements this week Work on design, implementation. Types. Lecture 17 CS 169. Outline. Java Types

Announcements. Working on requirements this week Work on design, implementation. Types. Lecture 17 CS 169. Outline. Java Types Announcements Types Working on requirements this week Work on design, implementation Lecture 17 CS 169 Prof. Brewer CS 169 Lecture 16 1 Prof. Brewer CS 169 Lecture 16 2 Outline Type concepts Where do types

More information

Benefits of object-orientationorientation

Benefits of object-orientationorientation ITEC 136 Business Programming Concepts Week 14, Part 01 Overview 1 Week 14 Overview Week 13 review What is an object? (three parts) State (properties) Identity (location in memory) Behavior (methods) 2

More information

Modules and Representation Invariants

Modules and Representation Invariants Modules and Representation Invariants COS 326 Andrew W. Appel Princeton University slides copyright 2013-2015 David Walker and Andrew W. Appel In previous classes: Reasoning about individual OCaml expressions.

More information

THE CONCEPT OF OBJECT

THE CONCEPT OF OBJECT THE CONCEPT OF OBJECT An object may be defined as a service center equipped with a visible part (interface) and an hidden part Operation A Operation B Operation C Service center Hidden part Visible part

More information

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018 CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018 Typical workflow concrete syntax (string) "(fn x => x + x) 4" Parsing Possible errors / warnings

More information