Skip to content

Commit

Permalink
Add debug_codegen configure flag for instr_size debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgilchrist committed Nov 12, 2024
1 parent 630145a commit 6a2d917
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ MKMAINDLL=@mkmaindll@
MKEXEDEBUGFLAG=@mkexedebugflag@

RUNTIMED=@debug_runtime@
DEBUG_CODEGEN=@debug_codegen@
INSTRUMENTED_RUNTIME=@instrumented_runtime@
INSTRUMENTED_RUNTIME_LIBS=@instrumented_runtime_libs@
WITH_DEBUGGER=@with_debugger@
Expand Down
16 changes: 10 additions & 6 deletions asmcomp/arm64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,15 +1104,19 @@ let emit_instr_debug env i =
` .endif\n`
let rec emit_all env lbl_start acc i =
let debug = Config.debug_codegen in
match i.desc with
| Lend ->
(* acc measures in units of 32-bit instructions *)
let sz = acc * 4 in
` .ifne (. - {emit_label lbl_start}) - {emit_int sz}\n`;
` .error \"Emit.instr_size: instruction length mismatch\"\n`;
` .endif\n`;
if debug then begin
(* acc measures in units of 32-bit instructions *)
let sz = acc * 4 in
` .ifne (. - {emit_label lbl_start}) - {emit_int sz}\n`;
` .error \"Emit.instr_size: instruction length mismatch\"\n`;
` .endif\n`;
end
else
()
| _ ->
let debug = false in
if debug then emit_instr_debug env i else emit_instr env i;
emit_all env lbl_start (acc + Size.instr_size env.f i.desc) i.next
Expand Down
21 changes: 21 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ AC_SUBST([natdynlinkopts])
AC_SUBST([natdynlink_archive])
AC_SUBST([cmxs])
AC_SUBST([debug_runtime])
AC_SUBST([debug_codegen])
AC_SUBST([instrumented_runtime])
AC_SUBST([instrumented_runtime_libs])
AC_SUBST([otherlibraries])
Expand Down Expand Up @@ -361,6 +362,12 @@ AC_ARG_ENABLE([debug-runtime],
[AS_HELP_STRING([--disable-debug-runtime],
[do not build runtime with debugging support])])

AC_ARG_ENABLE([debug-codegen],
[AS_HELP_STRING([--enable-debug-codegen],
[build codegen with debugging support @<:@default=no@:>@])],
[],
[enable_debug_codegen=no])

AC_ARG_ENABLE([ocamldebug],
[AS_HELP_STRING([--enable-ocamldebug],
[build ocamldebug @<:@default=auto@:>@])],
Expand Down Expand Up @@ -2370,6 +2377,11 @@ AS_CASE([$enable_debug_runtime],
[no], [debug_runtime=false],
[debug_runtime=true])

## Should the codegen with debugging support be built
AS_CASE([$enable_debug_codegen],
[no], [debug_codegen=true],
[debug_codegen=false])

## Determine how to link with the POSIX threads library

AS_CASE([$host],
Expand Down
1 change: 1 addition & 0 deletions utils/config.common.ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ let configuration_variables () =
p_bool "supports_shared_libraries" supports_shared_libraries;
p_bool "native_dynlink" native_dynlink;
p_bool "naked_pointers" naked_pointers;
p_bool "debug_codegen" debug_codegen;

p "exec_magic_number" exec_magic_number;
p "cmi_magic_number" cmi_magic_number;
Expand Down
1 change: 1 addition & 0 deletions utils/config.fixed.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ let system = "unknown"
let asm = boot_cannot_call "the assembler"
let asm_cfi_supported = false
let with_frame_pointers = false
let debug_codegen = false
let reserved_header_bits = 0
let ext_exe = ".ex_The boot compiler should not be using Config.ext_exe"
let ext_obj = ".o_The boot compiler cannot process C objects"
Expand Down
1 change: 1 addition & 0 deletions utils/config.generated.ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ let flexdll_dirs = [@flexdll_dir@]
let ar_supports_response_files = @ar_supports_response_files@

let tsan = @tsan@
let debug_codegen = @debug_codegen@
3 changes: 3 additions & 0 deletions utils/config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ val ar_supports_response_files: bool
val tsan : bool
(** Whether ThreadSanitizer instrumentation is enabled *)

val debug_codegen : bool
(** Whether codegen debug information is enabled. *)

(** Access to configuration values *)
val print_config : out_channel -> unit

Expand Down

0 comments on commit 6a2d917

Please sign in to comment.