本文整理汇总了C++中BeamOp函数的典型用法代码示例。如果您正苦于以下问题:C++ BeamOp函数的具体用法?C++ BeamOp怎么用?C++ BeamOp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BeamOp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: erts_is_native_break
int
erts_is_native_break(BeamInstr *pc) {
#ifdef HIPE
ASSERT(pc[-5] == (BeamInstr) BeamOp(op_i_func_info_IaaI));
return pc[0] == (BeamInstr) BeamOp(op_hipe_trap_call)
|| pc[0] == (BeamInstr) BeamOp(op_hipe_trap_call_closure);
#else
return 0;
#endif
}
示例2: erts_install_breakpoints
void
erts_install_breakpoints(BpFunctions* f)
{
Uint i;
Uint n = f->matched;
BeamInstr br = (BeamInstr) BeamOp(op_i_generic_breakpoint);
for (i = 0; i < n; i++) {
BeamInstr* pc = f->matching[i].pc;
GenericBp* g = (GenericBp *) pc[-4];
if (*pc != br && g) {
Module* modp = f->matching[i].mod;
/*
* The breakpoint must be disabled in the active data
* (it will enabled later by switching bp indices),
* and enabled in the staging data.
*/
ASSERT(g->data[erts_active_bp_ix()].flags == 0);
ASSERT(g->data[erts_staging_bp_ix()].flags != 0);
/*
* The following write is not protected by any lock. We
* assume that the hardware guarantees that a write of an
* aligned word-size (or half-word) writes is atomic
* (i.e. that other processes executing this code will not
* see a half pointer).
*/
*pc = br;
modp->curr.num_breakpoints++;
}
}
}
示例3: signed_val
/* Empty loop body */
}
for (i = specified; i < 3; i++) {
if (mfa[i] != am_Underscore) {
goto error;
}
}
if (is_small(mfa[2])) {
mfa[2] = signed_val(mfa[2]);
}
if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD2(bif_export[BIF_erts_debug_breakpoint_2],
BIF_P, BIF_ARG_1, BIF_ARG_2);
}
erts_smp_proc_unlock(p, ERTS_PROC_LOCK_MAIN);
erts_smp_thr_progress_block();
erts_bp_match_functions(&f, mfa, specified);
if (boolean == am_true) {
erts_set_debug_break(&f);
erts_install_breakpoints(&f);
erts_commit_staged_bp();
} else {
erts_clear_debug_break(&f);
erts_commit_staged_bp();
erts_uninstall_breakpoints(&f);
}
erts_consolidate_bp_data(&f, 1);
res = make_small(f.matched);
erts_bp_free_matched_functions(&f);
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(p, ERTS_PROC_LOCK_MAIN);
erts_release_code_write_permission();
return res;
error:
BIF_ERROR(p, BADARG);
}
#if 0 /* Kept for conveninence when hard debugging. */
void debug_dump_code(BeamInstr *I, int num)
{
BeamInstr *code_ptr = I;
BeamInstr *end = code_ptr + num;
erts_dsprintf_buf_t *dsbufp;
BeamInstr instr;
int i;
dsbufp = erts_create_tmp_dsbuf(0);
while (code_ptr < end) {
erts_print(ERTS_PRINT_DSBUF, (void *) dsbufp, HEXF ": ", code_ptr);
instr = (BeamInstr) code_ptr[0];
for (i = 0; i < NUM_SPECIFIC_OPS; i++) {
if (instr == (BeamInstr) BeamOp(i) && opc[i].name[0] != '\0') {
code_ptr += print_op(ERTS_PRINT_DSBUF, (void *) dsbufp,
i, opc[i].sz-1, code_ptr+1) + 1;
break;
}
}
if (i >= NUM_SPECIFIC_OPS) {
erts_print(ERTS_PRINT_DSBUF, (void *) dsbufp,
"unknown " HEXF "\n", instr);
code_ptr++;
}
}
dsbufp->str[dsbufp->str_len] = 0;
erts_fprintf(stderr,"%s", dsbufp->str);
erts_destroy_tmp_dsbuf(dsbufp);
}
示例4: erts_trace_break
/*
* SMP NOTE: Process p may have become exiting on return!
*/
BeamInstr
erts_trace_break(Process *p, BeamInstr *pc, Eterm *args,
Uint32 *ret_flags, Eterm *tracer_pid) {
Eterm tpid1, tpid2;
BpData **bds = (BpData **) (pc)[-4];
BpDataTrace *bdt = NULL;
ASSERT(bds);
ASSERT(pc[-5] == (BeamInstr) BeamOp(op_i_func_info_IaaI));
bdt = (BpDataTrace *) bds[bp_sched2ix_proc(p)];
ASSERT(bdt);
bdt = (BpDataTrace *) bdt->next;
ASSERT(bdt);
ASSERT(ret_flags);
ASSERT(tracer_pid);
ErtsSmpBPLock(bdt);
tpid1 = tpid2 = bdt->tracer_pid;
ErtsSmpBPUnlock(bdt);
*ret_flags = erts_call_trace(p, pc-3/*mfa*/, bdt->match_spec, args,
1, &tpid2);
*tracer_pid = tpid2;
if (tpid1 != tpid2) {
ErtsSmpBPLock(bdt);
bdt->tracer_pid = tpid2;
ErtsSmpBPUnlock(bdt);
}
bds[bp_sched2ix_proc(p)] = (BpData *) bdt;
return bdt->orig_instr;
}
示例5: set_module_break
static int set_module_break(Module *modp, Eterm mfa[3], int specified,
Binary *match_spec, Uint break_op,
enum erts_break_op count_op, Eterm tracer_pid) {
Uint** code_base;
Uint* code_ptr;
int num_processed = 0;
Uint i,n;
ASSERT(break_op);
ASSERT(modp);
code_base = (Uint **) modp->code;
if (code_base == NULL) {
return 0;
}
n = (Uint) code_base[MI_NUM_FUNCTIONS];
for (i = 0; i < n; ++i) {
code_ptr = code_base[MI_FUNCTIONS+i];
ASSERT(code_ptr[0] == (Uint) BeamOp(op_i_func_info_IaaI));
if ((specified < 2 || mfa[1] == ((Eterm) code_ptr[3])) &&
(specified < 3 || ((int) mfa[2]) == ((int) code_ptr[4]))) {
Uint *pc = code_ptr+5;
num_processed +=
set_function_break(modp, pc, match_spec,
break_op, count_op, tracer_pid);
}
}
return num_processed;
}
示例6: ASSERT
/*
** Searches (linear forward) the breakpoint ring for a specified opcode
** and returns a pointer to the breakpoint data structure or NULL if
** not found. If the specified opcode is 0, the last breakpoint is
** returned. The program counter must point to the first executable
** (breakpoint) instruction of the function.
*/
static BpData *is_break(Uint *pc, Uint break_op) {
ASSERT(pc[-5] == (Uint) BeamOp(op_i_func_info_IaaI));
if (! erts_is_native_break(pc)) {
BpData *bd = (BpData *) pc[-4];
if (break_op == 0) {
return bd;
}
if (*pc == break_op) {
ASSERT(bd);
return bd->next;
}
if (! bd){
return NULL;
}
bd = bd->next;
while (bd != (BpData *) pc[-4]) {
ASSERT(bd);
if (bd->orig_instr == break_op) {
bd = bd->next;
ASSERT(bd);
return bd;
} else {
bd = bd->next;
}
}
}
return NULL;
}
示例7: erts_trace_break
/*
* SMP NOTE: Process p may have become exiting on return!
*/
Uint
erts_trace_break(Process *p, Uint *pc, Eterm *args,
Uint32 *ret_flags, Eterm *tracer_pid) {
Eterm tpid1, tpid2;
BpDataTrace *bdt = (BpDataTrace *) pc[-4];
ASSERT(pc[-5] == (Uint) BeamOp(op_i_func_info_IaaI));
ASSERT(bdt);
bdt = (BpDataTrace *) bdt->next;
ASSERT(bdt);
ASSERT(ret_flags);
ASSERT(tracer_pid);
ErtsSmpBPLock(bdt);
tpid1 = tpid2 = bdt->tracer_pid;
ErtsSmpBPUnlock(bdt);
*ret_flags = erts_call_trace(p, pc-3/*mfa*/, bdt->match_spec, args,
1, &tpid2);
*tracer_pid = tpid2;
if (tpid1 != tpid2) {
ErtsSmpBPLock(bdt);
bdt->tracer_pid = tpid2;
ErtsSmpBPUnlock(bdt);
}
pc[-4] = (Uint) bdt;
return bdt->orig_instr;
}
示例8: erts_set_mtrace_break
int
erts_set_mtrace_break(Eterm mfa[3], int specified, Binary *match_spec,
Eterm tracer_pid) {
ERTS_SMP_LC_ASSERT(erts_smp_is_system_blocked(0));
return set_break(mfa, specified, match_spec,
(Uint) BeamOp(op_i_mtrace_breakpoint), 0, tracer_pid);
}
示例9: erts_set_mtrace_break
int
erts_set_mtrace_break(Eterm mfa[3], int specified, Binary *match_spec,
Eterm tracer_pid) {
ERTS_SMP_LC_ASSERT(erts_smp_thr_progress_is_blocking());
return set_break(mfa, specified, match_spec,
(BeamInstr) BeamOp(op_i_mtrace_breakpoint), 0, tracer_pid);
}
示例10: erts_is_time_break
int erts_is_time_break(Process *p, BeamInstr *pc, Eterm *retval) {
Uint i, ix;
bp_time_hash_t hash;
Uint size;
Eterm *hp, t;
bp_data_time_item_t *item = NULL;
BpDataTime *bdt = (BpDataTime *) is_break(pc, (BeamInstr) BeamOp(op_i_time_breakpoint));
if (bdt) {
if (retval) {
/* collect all hashes to one hash */
bp_hash_init(&hash, 64);
/* foreach threadspecific hash */
for (i = 0; i < bdt->n; i++) {
bp_data_time_item_t *sitem;
/* foreach hash bucket not NIL*/
for(ix = 0; ix < bdt->hash[i].n; ix++) {
item = &(bdt->hash[i].item[ix]);
if (item->pid != NIL) {
sitem = bp_hash_get(&hash, item);
if (sitem) {
BP_TIME_ADD(sitem, item);
} else {
bp_hash_put(&hash, item);
}
}
}
}
/* *retval should be NIL or term from previous bif in export entry */
if (hash.used > 0) {
size = (5 + 2)*hash.used;
hp = HAlloc(p, size);
for(ix = 0; ix < hash.n; ix++) {
item = &(hash.item[ix]);
if (item->pid != NIL) {
t = TUPLE4(hp, item->pid,
make_small(item->count),
make_small(item->s_time),
make_small(item->us_time));
hp += 5;
*retval = CONS(hp, t, *retval); hp += 2;
}
}
}
bp_hash_delete(&hash);
}
return !0;
}
return 0;
}
示例11: erts_is_count_break
int
erts_is_count_break(BeamInstr *pc, Sint *count_ret) {
BpDataCount *bdc =
(BpDataCount *) is_break(pc, (BeamInstr) BeamOp(op_i_count_breakpoint));
if (bdc) {
if (count_ret) {
*count_ret = (Sint) erts_smp_atomic_read_nob(&bdc->acount);
}
return !0;
}
return 0;
}
示例12: erts_find_function
Export*
erts_find_function(Eterm m, Eterm f, unsigned int a, ErtsCodeIndex code_ix)
{
struct export_templ templ;
struct export_entry* ee;
ee = hash_get_ext(&export_tables[code_ix].htable,
init_template(&templ, m, f, a), &fun);
if (ee == NULL ||
(ee->ep->addressv[code_ix] == ee->ep->code+3 &&
ee->ep->code[3] != (BeamInstr) BeamOp(op_i_generic_breakpoint))) {
return NULL;
}
return ee->ep;
}
示例13: erts_is_count_break
int
erts_is_count_break(Uint *pc, Sint *count_ret) {
BpDataCount *bdc =
(BpDataCount *) is_break(pc, (Uint) BeamOp(op_i_count_breakpoint));
if (bdc) {
if (count_ret) {
ErtsSmpBPLock(bdc);
*count_ret = bdc->count;
ErtsSmpBPUnlock(bdc);
}
return !0;
}
return 0;
}
示例14: erts_bp_match_export
void
erts_bp_match_export(BpFunctions* f, ErtsCodeMFA *mfa, int specified)
{
ErtsCodeIndex code_ix = erts_active_code_ix();
int i;
int num_exps = export_list_size(code_ix);
int ne;
f->matching = (BpFunction *) Alloc(num_exps*sizeof(BpFunction));
ne = 0;
for (i = 0; i < num_exps; i++) {
Export* ep = export_list(i, code_ix);
BeamInstr* pc;
switch (specified) {
case 3:
if (mfa->arity != ep->info.mfa.arity)
continue;
case 2:
if (mfa->function != ep->info.mfa.function)
continue;
case 1:
if (mfa->module != ep->info.mfa.module)
continue;
case 0:
break;
default:
ASSERT(0);
}
pc = ep->beam;
if (ep->addressv[code_ix] == pc) {
if ((*pc == (BeamInstr) em_apply_bif ||
*pc == (BeamInstr) em_call_error_handler)) {
continue;
}
ASSERT(*pc == (BeamInstr) BeamOp(op_i_generic_breakpoint));
} else if (erts_is_function_native(erts_code_to_codeinfo(ep->addressv[code_ix]))) {
continue;
}
f->matching[ne].ci = &ep->info;
f->matching[ne].mod = erts_get_module(ep->info.mfa.module, code_ix);
ne++;
}
f->matched = ne;
}
示例15: uninstall_breakpoint
static void
uninstall_breakpoint(BeamInstr* pc)
{
if (*pc == (BeamInstr) BeamOp(op_i_generic_breakpoint)) {
GenericBp* g = (GenericBp *) pc[-4];
if (g->data[erts_active_bp_ix()].flags == 0) {
/*
* The following write is not protected by any lock. We
* assume that the hardware guarantees that a write of an
* aligned word-size (or half-word) writes is atomic
* (i.e. that other processes executing this code will not
* see a half pointer).
*/
*pc = g->orig_instr;
}
}
}