Skip to content

Commit 5baf51c

Browse files
ricarkolhannesm
authored andcommittedJul 27, 2017
Adding --gdb argument for ukvm (#847)
Adding -g argument for debugging
1 parent ec83799 commit 5baf51c

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed
 

‎lib/mirage.ml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,9 @@ let configure i =
16821682
let target = Key.(get ctx target) in
16831683
Log.info (fun m -> m "Configuring for target: %a" Key.pp_target target);
16841684
let opam_name = unikernel_name target name in
1685+
let target_debug = Key.(get ctx target_debug) in
1686+
if target_debug && target <> `Ukvm then
1687+
Log.warn (fun m -> m "-g not supported for target: %a" Key.pp_target target);
16851688
configure_myocamlbuild () >>= fun () ->
16861689
configure_opam ~name:opam_name i >>= fun () ->
16871690
configure_makefile ~opam_name >>= fun () ->
@@ -1798,7 +1801,7 @@ let ldflags pkg = pkg_config pkg ["--variable=ldflags"]
17981801

17991802
let ldpostflags pkg = pkg_config pkg ["--variable=ldpostflags"]
18001803

1801-
let link info name target =
1804+
let link info name target target_debug =
18021805
let libs = Info.libraries info in
18031806
match target with
18041807
| `Unix | `MacOSX ->
@@ -1862,7 +1865,7 @@ let link info name target =
18621865
| "mirage-net-solo5" -> "net" :: acc
18631866
| "mirage-block-solo5" -> "blk" :: acc
18641867
| _ -> acc)
1865-
[] libs
1868+
[] libs @ (if target_debug then ["gdb"] else [])
18661869
in
18671870
pkg_config "solo5-kernel-ukvm" ["--variable=libdir"] >>= function
18681871
| [ libdir ] ->
@@ -1879,9 +1882,10 @@ let build i =
18791882
let warn_error = Key.(get ctx warn_error) in
18801883
let target = Key.(get ctx target) in
18811884
let libs = Info.libraries i in
1885+
let target_debug = Key.(get ctx target_debug) in
18821886
check_entropy libs >>= fun () ->
18831887
compile libs warn_error target >>= fun () ->
1884-
link i name target >>| fun out ->
1888+
link i name target target_debug >>| fun out ->
18851889
Log.info (fun m -> m "Build succeeded: %s" out)
18861890

18871891
let clean i =
@@ -1928,6 +1932,7 @@ module Project = struct
19281932
method! keys = [
19291933
Key.(abstract target);
19301934
Key.(abstract warn_error);
1935+
Key.(abstract target_debug);
19311936
]
19321937
method! packages =
19331938
let common = [

‎lib/mirage_key.ml

+7
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ let warn_error =
156156
let key = Arg.(opt ~stage:`Configure bool false doc) in
157157
Key.create "warn_error" key
158158

159+
let target_debug =
160+
let doc = "Enables target-specific support for debugging. Supported \
161+
targets: ukvm (compiles ukvm-bin with GDB server support)." in
162+
let doc = Arg.info ~docs:mirage_section ~docv:"DEBUG" ~doc ["g"] in
163+
let key = Arg.flag ~stage:`Configure doc in
164+
Key.create "target_debug" key
165+
159166
(** {3 Tracing} *)
160167

161168
let tracing_size default =

‎lib/mirage_key.mli

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ val warn_error: bool key
5050
(** [--warn-error]. Enable {i -warn-error} for OCaml sources. Set to [false] by
5151
default, but might might enabled by default in later releases. *)
5252

53+
val target_debug: bool key
54+
(** Enables target-specific support for debugging. *)
55+
5356
val tracing_size: int -> int key
5457
(** [--tracing-size]: Key setting the tracing ring buffer size. *)
5558

0 commit comments

Comments
 (0)
Please sign in to comment.