Skip to content

Commit 4c4518d

Browse files
committed
small improvements in debug printing for runtime.c
1 parent bc65426 commit 4c4518d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

runtime.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void validate_vector(int64_t** scan_addr) {
179179
void collect(int64_t** rootstack_ptr, uint64_t bytes_requested)
180180
{
181181
#if 0
182-
printf("collecting, need %ld\n", bytes_requested);
182+
printf("collecting, need %" PRIu64 "\n", bytes_requested);
183183
print_heap(rootstack_ptr);
184184
#endif
185185

@@ -245,7 +245,7 @@ void collect(int64_t** rootstack_ptr, uint64_t bytes_requested)
245245
free(tospace_begin);
246246

247247
if (!(tospace_begin = malloc(new_bytes))) {
248-
printf("failed to malloc %ld byte fromspace", new_bytes);
248+
printf("failed to malloc %lu byte fromspace", new_bytes);
249249
exit(EXIT_FAILURE);
250250
}
251251

@@ -263,7 +263,7 @@ void collect(int64_t** rootstack_ptr, uint64_t bytes_requested)
263263
free(tospace_begin);
264264

265265
if (!(tospace_begin = malloc(new_bytes))) {
266-
printf("failed to malloc %ld byte tospace", new_bytes);
266+
printf("failed to malloc %lu byte tospace", new_bytes);
267267
exit(EXIT_FAILURE);
268268
}
269269

@@ -282,12 +282,12 @@ void collect(int64_t** rootstack_ptr, uint64_t bytes_requested)
282282
}
283283
}
284284
// All pointers in fromspace point to fromspace
285-
/*printf("validating pointers in fromspace [%lld, %lld)\n",
286-
(int64_t)fromspace_begin, (int64_t)fromspace_end);*/
285+
/*printf("validating pointers in fromspace [%p, %p)\n",
286+
fromspace_begin, fromspace_end);*/
287287
int64_t* scan_ptr = fromspace_begin;
288288
while (scan_ptr != free_ptr){
289289
validate_vector(&scan_ptr);
290-
#if 0
290+
#if 0 // this sanity test appears to be broken
291291
int64_t tag = *scan_ptr;
292292
unsigned char len = get_vector_length(tag);
293293
int64_t isPtrBits = get_vec_ptr_bitfield(tag);
@@ -536,7 +536,7 @@ void copy_vector(int64_t** vector_ptr_loc)
536536
return;
537537
old_vector_ptr = to_ptr(old_vector_ptr);
538538
#if 0
539-
printf("copy_vector %ll\n", (int64_t)old_vector_ptr);
539+
printf("copy_vector %p\n", old_vector_ptr);
540540
#endif
541541

542542
int64_t tag = old_vector_ptr[0];
@@ -545,7 +545,9 @@ void copy_vector(int64_t** vector_ptr_loc)
545545
// would have left a forwarding pointer.
546546

547547
if (is_forwarding(tag)) {
548-
//printf("\talready copied to %lld\n", tag);
548+
#if 0
549+
printf("\talready copied to %p\n", (int64_t*) tag);
550+
#endif
549551
// Since we left a forwarding pointer, we have already
550552
// moved this vector. All we need to do is update the pointer
551553
// that was pointing to the old vector. The
@@ -564,7 +566,7 @@ void copy_vector(int64_t** vector_ptr_loc)
564566
// The new vector is going to be where the free_ptr currently points.
565567
int64_t* new_vector_ptr = free_ptr;
566568
#if 0
567-
printf("\tto address: %ld\n", (int64_t)new_vector_ptr);
569+
printf("\tto address: %p\n", new_vector_ptr);
568570
#endif
569571

570572
// The tag we grabbed earlier contains some usefull info for
@@ -680,7 +682,7 @@ void print_heap(int64_t** rootstack_ptr)
680682
if (is_ptr(*root_loc)) {
681683
print_vector(to_ptr(*root_loc));
682684
} else {
683-
printf("%lld", (int64_t)*root_loc);
685+
printf("%" PRId64, (int64_t)*root_loc);
684686
}
685687
printf("\n");
686688
}
@@ -697,7 +699,7 @@ void print_vector(int64_t* vector_ptr)
697699
int64_t* scan_ptr = vector_ptr;
698700
int64_t* next_ptr = vector_ptr + len + 1;
699701

700-
printf("%lld=#(", (int64_t)vector_ptr);
702+
printf("%p=#(", vector_ptr);
701703
scan_ptr += 1;
702704
int64_t isPointerBits = get_vec_ptr_bitfield(tag);
703705
while (scan_ptr != next_ptr) {

0 commit comments

Comments
 (0)