Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register names for instrtrace primitives when using embedded bytecode library #5597

Closed
vicuna opened this issue Apr 20, 2012 · 2 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Apr 20, 2012

Original bug ID: 5597
Reporter: @avsm
Assigned to: meyer
Status: closed (set by @xavierleroy on 2015-12-11T18:08:00Z)
Resolution: fixed
Priority: low
Severity: feature
Version: 3.12.1
Target version: 4.00.1+dev
Fixed in version: 4.00.0+dev
Category: runtime system and C interface

Bug description

When using caml_trace_flag=1 with an embedded bytecode application (linked with ocamlc -output-obj -o x.c), the names of primitives are not registered in caml_startup_code. Thus the instrtrace looks like:

4801 PUSHACC1
4802 C_CALL1 unknown primitive 204
4804 SUBINT
4805 PUSHACC2
4806 GTINT
4807 BRANCHIFNOT 8
4816 ACC2
4817 C_CALL1 unknown primitive 205
4819 PUSHACC3
4820 PUSHCONST0
4821 PUSHACC2
4822 PUSHACC5
4823 PUSHACC5
4824 C_CALL5 unknown primitive 215

and after registering them, looks like:

4801 PUSHACC1
4802 C_CALL1 caml_ml_string_length
4804 SUBINT
4805 PUSHACC2
4806 GTINT
4807 BRANCHIFNOT 8
4816 ACC2
4817 C_CALL1 caml_create_string
4819 PUSHACC3
4820 PUSHCONST0
4821 PUSHACC2
4822 PUSHACC5
4823 PUSHACC5
4824 C_CALL5 caml_blit_string

Steps to reproduce

./run.sh in the attached tar ball will show the before after.

The only way to activate caml_trace_flag is via manually compiling the debug libasmrun.d and setting the flag, as parsing command line parameters is not done by caml_startup_code. Would a patch to add "t" to OCAMLRUNPARAM for debug bytecode builds be ok?

Additional information

diff --git a/byterun/dynlink.c b/byterun/dynlink.c
index 7df594d..729abe3 100644
--- a/byterun/dynlink.c
+++ b/byterun/dynlink.c
@@ -184,8 +184,15 @@ void caml_build_primitive_table_builtin(void)
{
int i;
caml_ext_table_init(&caml_prim_table, 0x180);

  • for (i = 0; caml_builtin_cprim[i] != 0; i++)
    +#ifdef DEBUG
  • caml_ext_table_init(&caml_prim_name_table, 0x180);
    +#endif
  • for (i = 0; caml_builtin_cprim[i] != 0; i++) {
    caml_ext_table_add(&caml_prim_table, (void *) caml_builtin_cprim[i]);
    +#ifdef DEBUG
  • caml_ext_table_add(&caml_prim_name_table, strdup(caml_names_of_builtin_cprim[i]));
    +#endif
    +}
    }

#endif /* NATIVE_CODE */

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 9, 2012

Comment author: @damiendoligez

I've applied the patch to 4.00 (commit 12677) and trunk (commit 12679).

Would a patch to add "t" to OCAMLRUNPARAM for debug bytecode builds be ok?

Yes. If you provide such a patch, we'll most probably apply it.

@vicuna
Copy link
Author

vicuna commented Sep 2, 2012

Comment author: meyer

I've added "t" to OCAMLRUNPARAM with r12904.

@vicuna vicuna closed this as completed Dec 11, 2015
@vicuna vicuna added the stdlib label Mar 14, 2019
@vicuna vicuna added this to the 4.00.1 milestone Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant