Skip to content

Commit

Permalink
initial goblint run with gobview enabled when starting server
Browse files Browse the repository at this point in the history
  • Loading branch information
stilscher authored and sim642 committed May 26, 2023
1 parent 94e7900 commit 8517b69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ A Web Frontend for Goblint.
It allows inspecting the analyzed files and results of an analysis run with Goblint.
It is based on [jsoo-react](https://github.com/jchavarri/jsoo-react) and was originally developed by Alex Micheli for his Bachelor's thesis at TUM i2, significantly extended by Kerem Cakirer, and is now maintained by the Goblint team.

## Goblint Http-Server

Http-Server for the communication between GobView and Goblint in server mode. It also serves the files for the web page.

## Installing

Follow the instructions in the [Read the Docs](https://goblint.readthedocs.io/en/latest/user-guide/inspecting/).
24 changes: 16 additions & 8 deletions goblint-http-server/goblint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let config goblint name value =

let temp_dir () = Utils.temp_dir "goblint-http-server." ""

let analyze ?reanalyze goblint =
let analyze ?reanalyze ?save_dir ?(gobview = false) goblint =
let set_force_reanalyze () = match reanalyze with
| Some `Functions xs ->
config_raw goblint "incremental.force-reanalyze.funs" (`List (List.map (fun s -> `String s) xs))
Expand All @@ -77,6 +77,8 @@ let analyze ?reanalyze goblint =
config_raw goblint "incremental.force-reanalyze.funs" (`List [])
| _ -> Lwt.return_unit
in
let set_gobview () = if gobview then config_raw goblint "gobview" (`Bool true) else Lwt.return_unit in
let reset_gobview () = if gobview then config_raw goblint "gobview" (`Bool false) else Lwt.return_unit in
let analyze () =
let reset = match reanalyze with
| Some `All -> true
Expand All @@ -85,11 +87,17 @@ let analyze ?reanalyze goblint =
let params = `Assoc [("reset", `Bool reset)] in
Lwt.finalize
(fun () ->
let save_run = temp_dir () in
let%lwt () = config_raw goblint "save_run" (`String save_run) in
let%lwt () = set_force_reanalyze () in
let%lwt resp = send goblint "analyze" (Some params) in
assert_ok resp "Analysis failed";
Lwt.return save_run)
reset_force_reanalyze
let save_run = match save_dir with
| None -> temp_dir ()
| Some d -> d in
let%lwt () = config_raw goblint "save_run" (`String save_run) in
let%lwt () = set_force_reanalyze () in
let%lwt () = set_gobview () in
let%lwt resp = send goblint "analyze" (Some params) in
assert_ok resp "Analysis failed";
Lwt.return save_run)
(fun () ->
let%lwt () = reset_force_reanalyze () in
let%lwt () = reset_gobview () in
Lwt.return_unit)
in with_lock goblint analyze
2 changes: 2 additions & 0 deletions goblint-http-server/goblint_http.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ let callback state _ req body =

let main () =
let%lwt state = Goblint.spawn !goblint (!rest @ !paths) >|= State.make in
(* run Goblint once with option gobview enabled to copy the index.html and main.js files into the served directory *)
let%lwt _ = Goblint.analyze ~save_dir:!docroot ~gobview:true state.goblint in
let callback = callback state in
let server = Server.make ~callback () in
Server.create ~mode:(`TCP (`Port !port)) server
Expand Down

0 comments on commit 8517b69

Please sign in to comment.