`rb_bug` prints a newline after the message

This commit is contained in:
Nobuyoshi Nakada 2023-05-20 14:00:14 +09:00
Родитель 87217f26f1
Коммит 8d242a33af
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
14 изменённых файлов: 51 добавлений и 51 удалений

Просмотреть файл

@ -39,7 +39,7 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
size_t size;
const unsigned char *bin = builtin_lookup(feature_name, &size);
if (! bin) {
rb_bug("builtin_lookup: can not find %s\n", feature_name);
rb_bug("builtin_lookup: can not find %s", feature_name);
}
// load binary

14
debug.c
Просмотреть файл

@ -508,14 +508,14 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
if (debug_log.show_pid) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "pid:%d\t", getpid());
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
// message title
if (func_name && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "%s\t", func_name);
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
@ -534,7 +534,7 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
// C location
if (file && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "\t%s:%d", pretty_filename(file), line);
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
@ -551,7 +551,7 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
else {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
}
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
@ -559,7 +559,7 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
// native thread information
if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tnt:%d", ruby_nt_serial);
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
#endif
@ -575,7 +575,7 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%d/%u",
cr ? (int)rb_ractor_id(cr) : -1, GET_VM()->ractor.cnt);
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
}
@ -593,7 +593,7 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
else {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
}
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
}

Просмотреть файл

@ -14,20 +14,20 @@ force_unpack_check(struct checker *c, st_data_t key, st_data_t val)
if (c->nr == 0) {
st_data_t i;
if (c->tbl->bins != NULL) rb_bug("should be packed\n");
if (c->tbl->bins != NULL) rb_bug("should be packed");
/* force unpacking during iteration: */
for (i = 1; i < expect_size; i++)
st_add_direct(c->tbl, i, i);
if (c->tbl->bins == NULL) rb_bug("should be unpacked\n");
if (c->tbl->bins == NULL) rb_bug("should be unpacked");
}
if (key != c->nr) {
rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)key, (VALUE)c->nr);
rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")", (VALUE)key, (VALUE)c->nr);
}
if (val != c->nr) {
rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)val, (VALUE)c->nr);
rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")", (VALUE)val, (VALUE)c->nr);
}
c->nr++;
@ -60,7 +60,7 @@ unp_fec_i(st_data_t key, st_data_t val, st_data_t args, int error)
st_data_t v;
if (!st_delete(c->tbl, &k, &v)) {
rb_bug("failed to delete\n");
rb_bug("failed to delete");
}
if (v != 0) {
rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
@ -84,21 +84,21 @@ unp_fec(VALUE self, VALUE test)
st_add_direct(tbl, 0, 0);
if (tbl->bins != NULL) rb_bug("should still be packed\n");
if (tbl->bins != NULL) rb_bug("should still be packed");
st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1);
if (c.test == ID2SYM(rb_intern("delete2"))) {
if (c.nr != 1) {
rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
}
}
else if (c.nr != expect_size) {
rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")\n",
rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")",
(VALUE)c.nr, (VALUE)expect_size);
}
if (tbl->bins == NULL) rb_bug("should be unpacked\n");
if (tbl->bins == NULL) rb_bug("should be unpacked");
st_free_table(tbl);
@ -120,14 +120,14 @@ unp_fe_i(st_data_t key, st_data_t val, st_data_t args)
st_data_t v;
if (!st_delete(c->tbl, &k, &v)) {
rb_bug("failed to delete\n");
rb_bug("failed to delete");
}
if (v != 0) {
rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
}
return ST_CONTINUE;
}
rb_bug("should never get here\n");
rb_bug("should never get here");
}
rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
@ -145,21 +145,21 @@ unp_fe(VALUE self, VALUE test)
st_add_direct(tbl, 0, 0);
if (tbl->bins != NULL) rb_bug("should still be packed\n");
if (tbl->bins != NULL) rb_bug("should still be packed");
st_foreach(tbl, unp_fe_i, (st_data_t)&c);
if (c.test == ID2SYM(rb_intern("unpack_delete"))) {
if (c.nr != 1) {
rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
}
}
else if (c.nr != expect_size) {
rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)\n",
rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)",
(VALUE)c.nr, (VALUE)expect_size);
}
if (tbl->bins == NULL) rb_bug("should be unpacked\n");
if (tbl->bins == NULL) rb_bug("should be unpacked");
st_free_table(tbl);

Просмотреть файл

@ -102,7 +102,7 @@ monitor_exit(VALUE monitor)
struct rb_monitor *mc = monitor_ptr(monitor);
if (mc->count <= 0) rb_bug("monitor_exit: count:%d\n", (int)mc->count);
if (mc->count <= 0) rb_bug("monitor_exit: count:%d", (int)mc->count);
mc->count--;
if (mc->count == 0) {

12
gc.c
Просмотреть файл

@ -3398,7 +3398,7 @@ obj_free_object_id(rb_objspace_t *objspace, VALUE obj)
st_delete(objspace->id_to_obj_tbl, &id, NULL);
}
else {
rb_bug("Object ID seen, but not in mapping table: %s\n", obj_info(obj));
rb_bug("Object ID seen, but not in mapping table: %s", obj_info(obj));
}
}
@ -5578,7 +5578,7 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
* The sweep cursor and compact cursor move in
* opposite directions, and when they meet references will
* get updated and "during_compacting" should get disabled */
rb_bug("T_MOVED shouldn't be seen until compaction is finished\n");
rb_bug("T_MOVED shouldn't be seen until compaction is finished");
}
gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp));
ctx->empty_slots++;
@ -7970,11 +7970,11 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
if (0) {
/* free_slots may not equal to free_objects */
if (page->free_slots != free_objects) {
rb_bug("page %p's free_slots should be %d, but %d\n", (void *)page, page->free_slots, free_objects);
rb_bug("page %p's free_slots should be %d, but %d", (void *)page, page->free_slots, free_objects);
}
}
if (page->final_slots != zombie_objects) {
rb_bug("page %p's final_slots should be %d, but %d\n", (void *)page, page->final_slots, zombie_objects);
rb_bug("page %p's final_slots should be %d, but %d", (void *)page, page->final_slots, zombie_objects);
}
return remembered_old_objects;
@ -10767,7 +10767,7 @@ static void
root_obj_check_moved_i(const char *category, VALUE obj, void *data)
{
if (gc_object_moved_p(&rb_objspace, obj)) {
rb_bug("ROOT %s points to MOVED: %p -> %s\n", category, (void *)obj, obj_info(rb_gc_location(obj)));
rb_bug("ROOT %s points to MOVED: %p -> %s", category, (void *)obj, obj_info(rb_gc_location(obj)));
}
}
@ -10776,7 +10776,7 @@ reachable_object_check_moved_i(VALUE ref, void *data)
{
VALUE parent = (VALUE)data;
if (gc_object_moved_p(&rb_objspace, ref)) {
rb_bug("Object %s points to MOVED: %p -> %s\n", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
rb_bug("Object %s points to MOVED: %p -> %s", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
}
}

Просмотреть файл

@ -151,7 +151,7 @@ mprotect_exec(rb_execution_context_t *ec, VALUE self, VALUE rb_mem_block, VALUE
if (mem_size == 0) return Qfalse; // Some platforms return an error for mem_size 0.
if (mprotect(mem_block, mem_size, PROT_READ | PROT_EXEC)) {
rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s\n",
rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s",
mem_block, (unsigned long)mem_size, strerror(errno));
}
return Qtrue;

Просмотреть файл

@ -122,7 +122,7 @@ shape_alloc(void)
if (shape_id == MAX_SHAPE_ID) {
// TODO: Make an OutOfShapesError ??
rb_bug("Out of shapes\n");
rb_bug("Out of shapes");
}
return &GET_SHAPE_TREE()->shape_list[shape_id];
@ -451,7 +451,7 @@ rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t *value)
return false;
case SHAPE_OBJ_TOO_COMPLEX:
case SHAPE_FROZEN:
rb_bug("Ivar should not exist on transition\n");
rb_bug("Ivar should not exist on transition");
}
}
shape = rb_shape_get_parent(shape);
@ -516,7 +516,7 @@ rb_shape_traverse_from_new_root(rb_shape_t *initial_shape, rb_shape_t *dest_shap
case SHAPE_T_OBJECT:
break;
case SHAPE_OBJ_TOO_COMPLEX:
rb_bug("Unreachable\n");
rb_bug("Unreachable");
break;
}
@ -553,7 +553,7 @@ rb_shape_rebuild_shape(rb_shape_t * initial_shape, rb_shape_t * dest_shape)
case SHAPE_T_OBJECT:
break;
case SHAPE_OBJ_TOO_COMPLEX:
rb_bug("Unreachable\n");
rb_bug("Unreachable");
break;
}

Просмотреть файл

@ -1869,7 +1869,7 @@ ubf_timer_create(rb_serial_t fork_gen)
rb_atomic_t prev = timer_state_exchange(RTIMER_DISARM);
if (prev != RTIMER_DEAD) {
rb_bug("timer_posix was not dead: %u\n", (unsigned)prev);
rb_bug("timer_posix was not dead: %u", (unsigned)prev);
}
timer_posix.fork_gen = fork_gen;
}
@ -1931,7 +1931,7 @@ ubf_timer_disarm(void)
return;
case RTIMER_DEAD: return; /* stay dead */
default:
rb_bug("UBF_TIMER_POSIX bad state: %u\n", (unsigned)prev);
rb_bug("UBF_TIMER_POSIX bad state: %u", (unsigned)prev);
}
#elif UBF_TIMER == UBF_TIMER_PTHREAD

Просмотреть файл

@ -297,12 +297,12 @@ transient_heap_block_alloc(struct transient_heap* theap)
block = mmap(NULL, TRANSIENT_HEAP_BLOCK_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
if (block == MAP_FAILED) rb_bug("transient_heap_block_alloc: err:%d\n", errno);
if (block == MAP_FAILED) rb_bug("transient_heap_block_alloc: err:%d", errno);
#else
if (theap->arena == NULL) {
theap->arena = rb_aligned_malloc(TRANSIENT_HEAP_BLOCK_SIZE, TRANSIENT_HEAP_TOTAL_SIZE);
if (theap->arena == NULL) {
rb_bug("transient_heap_block_alloc: failed\n");
rb_bug("transient_heap_block_alloc: failed");
}
}
@ -529,7 +529,7 @@ alloc_header_to_block(struct transient_heap *theap, struct transient_alloc_heade
block = alloc_header_to_block_verbose(theap, header);
if (block == NULL) {
transient_heap_dump(theap);
rb_bug("alloc_header_to_block: not found in mark_blocks (%p)\n", header);
rb_bug("alloc_header_to_block: not found in mark_blocks (%p)", header);
}
#else
block = (void *)((intptr_t)header & ~(TRANSIENT_HEAP_BLOCK_SIZE-1));
@ -560,7 +560,7 @@ rb_transient_heap_mark(VALUE obj, const void *ptr)
}
else if (header->obj != obj) {
// transient_heap_dump(theap);
rb_bug("rb_transient_heap_mark: unmatch (%s is stored, but %s is given)\n",
rb_bug("rb_transient_heap_mark: unmatch (%s is stored, but %s is given)",
rb_obj_info(header->obj), rb_obj_info(obj));
}
}
@ -608,7 +608,7 @@ transient_heap_ptr(VALUE obj, int error)
break;
default:
if (error) {
rb_bug("transient_heap_ptr: unknown obj %s\n", rb_obj_info(obj));
rb_bug("transient_heap_ptr: unknown obj %s", rb_obj_info(obj));
}
}
@ -709,7 +709,7 @@ transient_heap_block_evacuate(struct transient_heap* theap, struct transient_hea
asan_unpoison_memory_region(header, sizeof *header, true);
VALUE obj = header->obj;
TH_ASSERT(header->magic == TRANSIENT_HEAP_ALLOC_MAGIC);
if (header->magic != TRANSIENT_HEAP_ALLOC_MAGIC) rb_bug("transient_heap_block_evacuate: wrong header %p %s\n", (void *)header, rb_obj_info(obj));
if (header->magic != TRANSIENT_HEAP_ALLOC_MAGIC) rb_bug("transient_heap_block_evacuate: wrong header %p %s", (void *)header, rb_obj_info(obj));
if (TRANSIENT_HEAP_DEBUG >= 3) fprintf(stderr, " * transient_heap_block_evacuate %p %s\n", (void *)header, rb_obj_info(obj));
@ -727,7 +727,7 @@ transient_heap_block_evacuate(struct transient_heap* theap, struct transient_hea
rb_struct_transient_heap_evacuate(obj, !TRANSIENT_HEAP_DEBUG_DONT_PROMOTE);
break;
default:
rb_bug("unsupported: %s\n", rb_obj_info(obj));
rb_bug("unsupported: %s", rb_obj_info(obj));
}
header->obj = Qundef; /* for debug */
}

Просмотреть файл

@ -1667,7 +1667,7 @@ iterate_over_shapes_with_callback(rb_shape_t *shape, rb_ivar_foreach_callback_fu
iterate_over_shapes_with_callback(rb_shape_get_parent(shape), callback, itr_data);
return;
case SHAPE_OBJ_TOO_COMPLEX:
rb_bug("Unreachable\n");
rb_bug("Unreachable");
}
}

Просмотреть файл

@ -1363,7 +1363,7 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
populate_cache(index, next_shape_id, id, iseq, ic, cc, is_attr);
}
else {
rb_bug("didn't find the id\n");
rb_bug("didn't find the id");
}
return val;

Просмотреть файл

@ -2113,7 +2113,7 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini
case VM_METHOD_TYPE_ALIAS:
break;
}
rb_bug("rb_method_definition_eq: unsupported type: %d\n", d1->type);
rb_bug("rb_method_definition_eq: unsupported type: %d", d1->type);
}
static st_index_t
@ -2148,7 +2148,7 @@ rb_hash_method_definition(st_index_t hash, const rb_method_definition_t *def)
case VM_METHOD_TYPE_ALIAS:
break; /* unreachable */
}
rb_bug("rb_hash_method_definition: unsupported method type (%d)\n", def->type);
rb_bug("rb_hash_method_definition: unsupported method type (%d)", def->type);
}
st_index_t

Просмотреть файл

@ -1713,7 +1713,7 @@ rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void
case PJRR_SUCCESS : return 1;
case PJRR_FULL : return 0;
case PJRR_INTERRUPTED: goto begin;
default: rb_bug("unreachable\n");
default: rb_bug("unreachable");
}
}
@ -1742,7 +1742,7 @@ rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func,
case PJRR_SUCCESS : return 1;
case PJRR_FULL : return 0;
case PJRR_INTERRUPTED: goto begin;
default: rb_bug("unreachable\n");
default: rb_bug("unreachable");
}
}

2
yjit.c
Просмотреть файл

@ -85,7 +85,7 @@ rb_yjit_mark_executable(void *mem_block, uint32_t mem_size)
return;
}
if (mprotect(mem_block, mem_size, PROT_READ | PROT_EXEC)) {
rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s\n",
rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s",
mem_block, (unsigned long)mem_size, strerror(errno));
}
}