本文整理汇总了C++中rb_bug函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_bug函数的具体用法?C++ rb_bug怎么用?C++ rb_bug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_bug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_check_type
void
rb_check_type(VALUE x, int t)
{
int xt;
if (x == Qundef) {
rb_bug("undef leaked to the Ruby space");
}
xt = TYPE(x);
if (xt != t || (xt == T_DATA && RTYPEDDATA_P(x))) {
const char *tname = rb_builtin_type_name(t);
if (tname) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
builtin_class_name(x), tname);
}
if (xt > T_MASK && xt <= 0x3f) {
rb_fatal("unknown type 0x%x (0x%x given, probably comes from extension library for ruby 1.8)", t, xt);
}
rb_bug("unknown type 0x%x (0x%x given)", t, xt);
}
}
示例2: w32_error
static void
w32_error(void)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) & lpMsgBuf, 0, NULL);
rb_bug("%s", (char*)lpMsgBuf);
}
示例3: make_errno_exc_str
static VALUE
make_errno_exc_str(VALUE mesg)
{
int n = errno;
errno = 0;
if (!mesg) mesg = Qnil;
if (n == 0) {
const char *s = !NIL_P(mesg) ? RSTRING_PTR(mesg) : "";
rb_bug("rb_sys_fail_str(%s) - errno == 0", s);
}
return rb_syserr_new_str(n, mesg);
}
示例4: rb_check_type
void
rb_check_type(VALUE x, int t)
{
const struct types *type = builtin_types;
const struct types *const typeend = builtin_types +
sizeof(builtin_types) / sizeof(builtin_types[0]);
if (x == Qundef) {
rb_bug("undef leaked to the Ruby space");
}
if (TYPE(x) != t) {
while (type < typeend) {
if (type->type == t) {
const char *etype;
if (NIL_P(x)) {
etype = "nil";
}
else if (FIXNUM_P(x)) {
etype = "Fixnum";
}
else if (SYMBOL_P(x)) {
etype = "Symbol";
}
else if (rb_special_const_p(x)) {
etype = RSTRING_PTR(rb_obj_as_string(x));
}
else {
etype = rb_obj_classname(x);
}
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
etype, type->name);
}
type++;
}
rb_bug("unknown type 0x%x (0x%x given)", t, TYPE(x));
}
}
示例5: sigbus
static RETSIGTYPE
sigbus(int sig SIGINFO_ARG)
{
/*
* Mac OS X makes KERN_PROTECTION_FAILURE when thread touch guard page.
* and it's delivered as SIGBUS instaed of SIGSEGV to userland. It's crazy
* wrong IMHO. but anyway we have to care it. Sigh.
*/
#if defined __APPLE__
CHECK_STACK_OVERFLOW();
#endif
rb_bug("Bus Error");
}
示例6: rbgobj_define_class
VALUE
rbgobj_define_class(GType gtype, const gchar *name, VALUE module, void *mark, void *free, VALUE parent)
{
RGObjClassInfo* cinfo;
if (gtype == 0)
rb_bug("rbgobj_define_class: Invalid gtype [%s]\n", name);
cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(gtype, parent);
cinfo->mark = mark;
cinfo->free = free;
rb_define_const(module, name, cinfo->klass);
return cinfo->klass;
}
示例7: rb_add_method
rb_method_entry_t *
rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex)
{
rb_thread_t *th;
rb_control_frame_t *cfp;
int line;
rb_method_entry_t *me = rb_method_entry_make(klass, mid, type, 0, noex);
rb_method_definition_t *def = ALLOC(rb_method_definition_t);
me->def = def;
def->type = type;
def->original_id = mid;
def->alias_count = 0;
switch (type) {
case VM_METHOD_TYPE_ISEQ:
def->body.iseq = (rb_iseq_t *)opts;
break;
case VM_METHOD_TYPE_CFUNC:
def->body.cfunc = *(rb_method_cfunc_t *)opts;
break;
case VM_METHOD_TYPE_ATTRSET:
case VM_METHOD_TYPE_IVAR:
def->body.attr.id = (ID)opts;
def->body.attr.location = Qfalse;
th = GET_THREAD();
cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp && (line = rb_vm_get_sourceline(cfp))) {
VALUE location = rb_ary_new3(2, cfp->iseq->filename, INT2FIX(line));
def->body.attr.location = rb_ary_freeze(location);
}
break;
case VM_METHOD_TYPE_BMETHOD:
def->body.proc = (VALUE)opts;
break;
case VM_METHOD_TYPE_NOTIMPLEMENTED:
def->body.cfunc.func = rb_f_notimplement;
def->body.cfunc.argc = -1;
break;
case VM_METHOD_TYPE_OPTIMIZED:
def->body.optimize_type = (enum method_optimized_type)opts;
break;
case VM_METHOD_TYPE_ZSUPER:
case VM_METHOD_TYPE_UNDEF:
break;
default:
rb_bug("rb_add_method: unsupported method type (%d)\n", type);
}
if (type != VM_METHOD_TYPE_UNDEF) {
method_added(klass, mid);
}
return me;
}
示例8: rb_tracearg_object
VALUE
rb_tracearg_object(rb_trace_arg_t *trace_arg)
{
if (trace_arg->event & (RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ)) {
/* ok */
}
else {
rb_raise(rb_eRuntimeError, "not supported by this event");
}
if (trace_arg->data == Qundef) {
rb_bug("tp_attr_raised_exception_m: unreachable");
}
return trace_arg->data;
}
示例9: virtualmachine_vme_eax
VALUE virtualmachine_vme_eax(VALUE self)
{
VALUE vctx = rb_iv_get(self, "@ctx");
VALUE vvme = rb_iv_get(self, "@vmexit");
struct vmctx *ctx;
struct vm_exit *vme;
Data_Get_Struct(vctx, struct vmctx, ctx);
if (!ctx)
rb_bug("ctx is null");
Data_Get_Struct(vvme, struct vm_exit, vme);
if (!vme)
tb_bug("vme is null");
return INT2FIX(vme->u.inout.eax);
}
示例10: virtualmachine_vme_rip
VALUE virtualmachine_vme_rip(VALUE self)
{
VALUE vctx = rb_iv_get(self, "@ctx");
VALUE vvme = rb_iv_get(self, "@vmexit");
struct vmctx *ctx;
struct vm_exit *vme;
Data_Get_Struct(vctx, struct vmctx, ctx);
if (!ctx)
rb_bug("ctx is null");
Data_Get_Struct(vvme, struct vm_exit, vme);
if (!vme)
tb_bug("vme is null");
return ULL2NUM(vme->rip);
}
示例11: virtualmachine_load_binary
VALUE virtualmachine_load_binary(VALUE self, VALUE program)
{
VALUE vctx = rb_iv_get(self, "@ctx");
struct vmctx *ctx;
unsigned char *entry;
Data_Get_Struct(vctx, struct vmctx, ctx);
if (!ctx)
rb_bug("ctx is null");
entry = _vm_map_gpa(ctx, ADDR_ENTRY, RSTRING_LEN(program));
memcpy(entry, StringValuePtr(program), RSTRING_LEN(program));
_vm_set_register(ctx, 0, VM_REG_GUEST_RIP, ADDR_ENTRY);
return Qnil;
}
示例12: native_cond_signal
static void
native_cond_signal(rb_thread_cond_t *cond)
{
/* cond is guarded by mutex */
struct cond_event_entry *e = cond->next;
if (e) {
cond->next = e->next;
SetEvent(e->event);
}
else {
rb_bug("native_cond_signal: no pending threads");
}
}
示例13: sigsegv
static RETSIGTYPE
sigsegv(int sig)
{
if (segv_received) {
fprintf(stderr, "SEGV recieved in SEGV handler\n");
exit(EXIT_FAILURE);
}
else {
extern int ruby_disable_gc_stress;
segv_received = 1;
ruby_disable_gc_stress = 1;
rb_bug("Segmentation fault");
}
}
示例14: rb_sys_fail
void
rb_sys_fail(const char *mesg)
{
int n = errno;
VALUE arg;
errno = 0;
if (n == 0) {
rb_bug("rb_sys_fail(%s) - errno == 0", mesg ? mesg : "");
}
arg = mesg ? rb_str_new2(mesg) : Qnil;
rb_exc_raise(rb_class_new_instance(1, &arg, get_syserr(n)));
}
示例15: rb_tracearg_return_value
VALUE
rb_tracearg_return_value(rb_trace_arg_t *trace_arg)
{
if (trace_arg->event & (RUBY_EVENT_RETURN | RUBY_EVENT_C_RETURN | RUBY_EVENT_B_RETURN)) {
/* ok */
}
else {
rb_raise(rb_eRuntimeError, "not supported by this event");
}
if (trace_arg->data == Qundef) {
rb_bug("tp_attr_return_value_m: unreachable");
}
return trace_arg->data;
}