Skip to content

Commit

Permalink
respect RUBY_DEBUG.
Browse files Browse the repository at this point in the history
see RUBY_DEBUG for each debug options.
  • Loading branch information
ko1 committed Jul 15, 2019
1 parent d02f2fc commit c23e597
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,10 @@ ar_empty_entry(ar_table_entry *entry)
#define RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)
#define RHASH_AR_TABLE_REF(hash, n) (&RHASH_AR_TABLE(hash)->entries[n])

#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(1, expr, #expr)

#if HASH_DEBUG
#define hash_verify(hash) hash_verify_(hash, __FILE__, __LINE__)
#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(1, expr, #expr)

void
rb_hash_dump(VALUE hash)
Expand Down Expand Up @@ -471,7 +472,6 @@ hash_verify_(VALUE hash, const char *file, int line)

#else
#define hash_verify(h) ((void)0)
#define HASH_ASSERT(e) ((void)0)
#endif

static inline int
Expand Down
2 changes: 1 addition & 1 deletion internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ VALUE rb_gvar_defined(struct rb_global_entry *);
/* array.c */

#ifndef ARRAY_DEBUG
#define ARRAY_DEBUG 0
#define ARRAY_DEBUG (0+RUBY_DEBUG)
#endif

#ifdef ARRAY_DEBUG
Expand Down
7 changes: 5 additions & 2 deletions vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* 1: enable local assertions.
*/
#ifndef VM_CHECK_MODE
#define VM_CHECK_MODE 0

// respect RUBY_DUBUG: if given n is 0, then use RUBY_DEBUG
#define N_OR_RUBY_DEBUG(n) (((n) > 0) ? (n) : RUBY_DEBUG)

#define VM_CHECK_MODE N_OR_RUBY_DEBUG(0)
#endif

/**
Expand Down Expand Up @@ -46,7 +50,6 @@

#if VM_CHECK_MODE > 0
#define VM_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(VM_CHECK_MODE > 0, expr, #expr)

#define VM_UNREACHABLE(func) rb_bug(#func ": unreachable")

#else
Expand Down

0 comments on commit c23e597

Please sign in to comment.