We cannot use ARCH_INTNAT_PRINTF_FORMAT because it isn't guaranteed to
match values of type size_t.

Since this is debugging code, we go for the simple solution and cast
to long.
master
Damien Doligez 2016-01-30 10:55:07 +01:00
parent f9b8bc6d7c
commit 67d88cb9f9
1 changed files with 7 additions and 9 deletions

View File

@ -183,21 +183,20 @@ caml_trace_value_file (value v, code_t prog, int proglen, FILE * f)
if (prog && v % sizeof (int) == 0
&& (code_t) v >= prog
&& (code_t) v < (code_t) ((char *) prog + proglen))
fprintf (f, "=code@%" ARCH_INTNAT_PRINTF_FORMAT "d", (code_t) v - prog);
fprintf (f, "=code@%ld", (long) ((code_t) v - prog));
else if (Is_long (v))
fprintf (f, "=long%" ARCH_INTNAT_PRINTF_FORMAT "d", Long_val (v));
else if ((void*)v >= (void*)caml_stack_low
&& (void*)v < (void*)caml_stack_high)
fprintf (f, "=stack_%" ARCH_INTNAT_PRINTF_FORMAT "d",
(intnat*)caml_stack_high - (intnat*)v);
fprintf (f, "=stack_%ld", (long) ((intnat*)caml_stack_high - (intnat*)v));
else if (Is_block (v)) {
int s = Wosize_val (v);
int tg = Tag_val (v);
int l = 0;
switch (tg) {
case Closure_tag:
fprintf (f, "=closure[s%d,cod%" ARCH_INTNAT_PRINTF_FORMAT "d]",
s, (code_t) (Code_val (v)) - prog);
fprintf (f, "=closure[s%d,cod%ld]",
s, (long) ((code_t) (Code_val (v)) - prog));
goto displayfields;
case String_tag:
l = caml_string_length (v);
@ -252,12 +251,11 @@ caml_trace_accu_sp_file (value accu, value * sp, code_t prog, int proglen,
value *p;
fprintf (f, "accu=");
caml_trace_value_file (accu, prog, proglen, f);
fprintf (f, "\n sp=%#" ARCH_INTNAT_PRINTF_FORMAT "x "
"@%" ARCH_INTNAT_PRINTF_FORMAT "d:",
(intnat) sp, caml_stack_high - sp);
fprintf (f, "\n sp=%#" ARCH_INTNAT_PRINTF_FORMAT "x @%ld:",
(intnat) sp, (long) (caml_stack_high - sp));
for (p = sp, i = 0; i < 12 + (1 << caml_trace_level) && p < caml_stack_high;
p++, i++) {
fprintf (f, "\n[%ld] ", caml_stack_high - p);
fprintf (f, "\n[%ld] ", (long) (caml_stack_high - p));
caml_trace_value_file (*p, prog, proglen, f);
};
putc ('\n', f);