Skip to content

Commit 8517b69

Browse files
stilschersim642
authored andcommitted
initial goblint run with gobview enabled when starting server
1 parent 94e7900 commit 8517b69

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ A Web Frontend for Goblint.
55
It allows inspecting the analyzed files and results of an analysis run with Goblint.
66
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.
77

8+
## Goblint Http-Server
9+
10+
Http-Server for the communication between GobView and Goblint in server mode. It also serves the files for the web page.
11+
812
## Installing
913

1014
Follow the instructions in the [Read the Docs](https://goblint.readthedocs.io/en/latest/user-guide/inspecting/).

goblint-http-server/goblint.ml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let config goblint name value =
6666

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

69-
let analyze ?reanalyze goblint =
69+
let analyze ?reanalyze ?save_dir ?(gobview = false) goblint =
7070
let set_force_reanalyze () = match reanalyze with
7171
| Some `Functions xs ->
7272
config_raw goblint "incremental.force-reanalyze.funs" (`List (List.map (fun s -> `String s) xs))
@@ -77,6 +77,8 @@ let analyze ?reanalyze goblint =
7777
config_raw goblint "incremental.force-reanalyze.funs" (`List [])
7878
| _ -> Lwt.return_unit
7979
in
80+
let set_gobview () = if gobview then config_raw goblint "gobview" (`Bool true) else Lwt.return_unit in
81+
let reset_gobview () = if gobview then config_raw goblint "gobview" (`Bool false) else Lwt.return_unit in
8082
let analyze () =
8183
let reset = match reanalyze with
8284
| Some `All -> true
@@ -85,11 +87,17 @@ let analyze ?reanalyze goblint =
8587
let params = `Assoc [("reset", `Bool reset)] in
8688
Lwt.finalize
8789
(fun () ->
88-
let save_run = temp_dir () in
89-
let%lwt () = config_raw goblint "save_run" (`String save_run) in
90-
let%lwt () = set_force_reanalyze () in
91-
let%lwt resp = send goblint "analyze" (Some params) in
92-
assert_ok resp "Analysis failed";
93-
Lwt.return save_run)
94-
reset_force_reanalyze
90+
let save_run = match save_dir with
91+
| None -> temp_dir ()
92+
| Some d -> d in
93+
let%lwt () = config_raw goblint "save_run" (`String save_run) in
94+
let%lwt () = set_force_reanalyze () in
95+
let%lwt () = set_gobview () in
96+
let%lwt resp = send goblint "analyze" (Some params) in
97+
assert_ok resp "Analysis failed";
98+
Lwt.return save_run)
99+
(fun () ->
100+
let%lwt () = reset_force_reanalyze () in
101+
let%lwt () = reset_gobview () in
102+
Lwt.return_unit)
95103
in with_lock goblint analyze

goblint-http-server/goblint_http.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ let callback state _ req body =
147147

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

0 commit comments

Comments
 (0)