long test1c() { unsigned char *pages; size_t page_size = PAGE_SIZE; size_t addr_size = page_size * PAGE_NUM; int wcount[PAGE_NUM], ret; bzero(wcount, PAGE_NUM * sizeof(int)); pages = mmap(ADDR_START, addr_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); if (pages == MAP_FAILED) return -errno; fprintf(stderr, "pages = %lx\n", (unsigned long)pages); ret = start_trace((unsigned long)pages, addr_size); if (ret) { fprintf(stderr, "start_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "start_trace\n"); ret = start_trace((unsigned long)pages, addr_size); if (!ret || errno != EINVAL) { fprintf(stderr, "the 2nd start_trace should fail\n"); return -1; } ret = get_trace(getpid(), wcount); if (ret) { fprintf(stderr, "get_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "get_trace\n"); ret = stop_trace(); if (ret) { fprintf(stderr, "stop_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "stop_trace\n"); ret = stop_trace(); if (!ret || errno != EINVAL) { fprintf(stderr, "the 2nd stop_trace should fail\n"); return -1; } ret = get_trace(getpid(), wcount); if (!ret || errno != EINVAL) { fprintf(stderr, "the 2nd get_trace should fail\n"); return -1; } return 0; }
int main(void) { int rc; L=lua_open(0); lua_baselibopen(L); lua_iolibopen(L); lua_strlibopen(L); lua_mathlibopen(L); lua_dblibopen(L); start_trace(stderr); rc=lua_dofile(L,0); stop_trace(); return rc; }
/** * handle_IRQ_event - irq action chain handler * @irq: the interrupt number * @action: the interrupt action chain for this irq * * Handles the action chain of an irq event */ irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action) { irqreturn_t ret, retval = IRQ_NONE; unsigned int status = 0; #ifdef __i386__ if (debug_direct_keyboard && irq == 1) lockdep_off(); #endif handle_dynamic_tick(action); /* * Unconditionally enable interrupts for threaded * IRQ handlers: */ if (!hardirq_count() || !(action->flags & IRQF_DISABLED)) local_irq_enable(); do { unsigned int preempt_count = preempt_count(); ret = action->handler(irq, action->dev_id); if (preempt_count() != preempt_count) { stop_trace(); print_symbol("BUG: unbalanced irq-handler preempt count in %s!\n", (unsigned long) action->handler); printk("entered with %08x, exited with %08x.\n", preempt_count, preempt_count()); dump_stack(); preempt_count() = preempt_count; } if (ret == IRQ_HANDLED) status |= action->flags; retval |= ret; action = action->next; } while (action); if (status & IRQF_SAMPLE_RANDOM) { local_irq_enable(); add_interrupt_randomness(irq); } local_irq_disable(); #ifdef __i386__ if (debug_direct_keyboard && irq == 1) lockdep_on(); #endif return retval; }
/** * handle_IRQ_event - irq action chain handler * @irq: the interrupt number * @regs: pointer to a register structure * @action: the interrupt action chain for this irq * * Handles the action chain of an irq event */ irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, struct irqaction *action) { irqreturn_t ret, retval = IRQ_NONE; unsigned int status = 0; MARK(kernel_irq_entry, "%u %u", irq, (regs)?(!user_mode(regs)):(1)); handle_dynamic_tick(action); /* * Unconditionally enable interrupts for threaded * IRQ handlers: */ if (!hardirq_count() || !(action->flags & IRQF_DISABLED)) local_irq_enable(); do { unsigned int preempt_count = preempt_count(); ret = action->handler(irq, action->dev_id, regs); if (preempt_count() != preempt_count) { stop_trace(); print_symbol("BUG: unbalanced irq-handler preempt count in %s!\n", (unsigned long) action->handler); printk("entered with %08x, exited with %08x.\n", preempt_count, preempt_count()); dump_stack(); preempt_count() = preempt_count; } if (ret == IRQ_HANDLED) status |= action->flags; retval |= ret; action = action->next; } while (action); if (status & IRQF_SAMPLE_RANDOM) { local_irq_enable(); add_interrupt_randomness(irq); } local_irq_disable(); MARK(kernel_irq_exit, MARK_NOARGS); return retval; }
int trace_vsx(pid_t child) { unsigned long vsx[VSX_MAX]; unsigned long vmx[VMX_MAX + 2][2]; FAIL_IF(start_trace(child)); FAIL_IF(show_vsx(child, vsx)); FAIL_IF(validate_vsx(vsx, fp_load)); FAIL_IF(show_vmx(child, vmx)); FAIL_IF(validate_vmx(vmx, fp_load)); memset(vsx, 0, sizeof(vsx)); memset(vmx, 0, sizeof(vmx)); load_vsx_vmx(fp_load_new, vsx, vmx); FAIL_IF(write_vsx(child, vsx)); FAIL_IF(write_vmx(child, vmx)); FAIL_IF(stop_trace(child)); return TEST_PASS; }
/* * Have got an event to handle: */ fastcall int handle_IRQ_event(unsigned int irq, struct pt_regs *regs, struct irqaction *action) { int ret, retval = 0, status = 0; /* * Unconditionally enable interrupts for threaded * IRQ handlers: */ if (!hardirq_count() || !(action->flags & SA_INTERRUPT)) local_irq_enable(); do { unsigned int preempt_count = preempt_count(); ret = action->handler(irq, action->dev_id, regs); if (preempt_count() != preempt_count) { stop_trace(); print_symbol("BUG: unbalanced irq-handler preempt count in %s!\n", (unsigned long) action->handler); printk("entered with %08x, exited with %08x.\n", preempt_count, preempt_count()); dump_stack(); preempt_count() = preempt_count; } if (ret == IRQ_HANDLED) status |= action->flags; retval |= ret; action = action->next; } while (action); if (status & SA_SAMPLE_RANDOM) { local_irq_enable(); add_interrupt_randomness(irq); } local_irq_disable(); return retval; }
long test2b() { unsigned char *pages; size_t page_size = PAGE_SIZE; size_t addr_size = page_size; int wcount[1], wcount2[1], i, ret; void *args[2]; pthread_t thread; bzero(wcount, sizeof(int)); bzero(wcount2, sizeof(int)); pages = mmap(ADDR_START, addr_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); if (pages == MAP_FAILED) return -errno; fprintf(stderr, "pages = %lx\n", (unsigned long)pages); bzero(pages, addr_size); ret = start_trace((unsigned long)pages, addr_size); if (ret) { fprintf(stderr, "start_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "start_trace\n"); args[0] = pages; args[1] = wcount2; pthread_create(&thread, NULL, thread2b, args); usleep(1); for (i = 0 ; i < 10 ; i++) { pages[0]++; usleep(20); } pthread_join(thread, NULL); ret = get_trace(gettid(), wcount); if (ret) { fprintf(stderr, "get_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "get_trace\n"); printf("wcount[0]=%02d, wcount2[0]=%02d, page[0]=%d\n", wcount[0], wcount2[0], pages[0]); ret = stop_trace(); if (ret) { fprintf(stderr, "stop_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "stop_trace\n"); if (wcount[0] < 9 || wcount2[0] > 0) return -1; return 0; }
long test2a() { unsigned char *pages; size_t page_size = PAGE_SIZE; size_t addr_size = page_size * PAGE_NUM; int wcount[PAGE_NUM], ret, i, stat; unsigned long addr; pid_t pid; bzero(wcount, PAGE_NUM * sizeof(int)); pages = mmap(ADDR_START, addr_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); if (pages == MAP_FAILED) return -errno; fprintf(stderr, "pages = %lx\n", (unsigned long)pages); ret = start_trace((unsigned long)pages, addr_size); if (ret) { fprintf(stderr, "start_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "start_trace\n"); pid = fork(); if (pid < 0) { fprintf(stderr, "fork failed: %s\n", strerror(errno)); return -errno; } if (pid == 0) { for (i = 0 ; i < 10 ; i++) { for (addr = 0 ; addr < addr_size ; addr += page_size) pages[addr]++; usleep(20); } exit(0); } wait(&stat); for (i = 0 ; i < 10 ; i++) { for (addr = 0 ; addr < addr_size ; addr += page_size) pages[addr]++; usleep(20); } ret = get_trace(getpid(), wcount); if (ret) { fprintf(stderr, "get_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "get_trace\n"); for (i = 0 ; i < PAGE_NUM ; i++) printf("wcount[%d] = %d, page[%04X] = %d\n", i, wcount[i], i * page_size, pages[i * page_size]); ret = stop_trace(); if (ret) { fprintf(stderr, "stop_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "stop_trace\n"); for (i = 0 ; i < PAGE_NUM ; i++) if (pages[i * page_size] != 10) return -1; return 0; }
long test1a() { unsigned char *pages; size_t page_size = PAGE_SIZE; size_t addr_size = page_size * PAGE_NUM; unsigned long addr; int wcount[PAGE_NUM], i, ret; bzero(wcount, PAGE_NUM * sizeof(int)); pages = mmap(ADDR_START, addr_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); if (pages == MAP_FAILED) return -errno; fprintf(stderr, "pages = %lx\n", (unsigned long)pages); for (i = 0 ; i < 1000 ; i++) { for (addr = 0 ; addr < addr_size ; addr += page_size) pages[addr] = 0; usleep(1); } fprintf(stderr, "write each page 1000 times\n"); ret = start_trace((unsigned long)pages, addr_size); if (ret) { fprintf(stderr, "start_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "start_trace\n"); for (i = 0 ; i < 1000 ; i++) { for (addr = 0 ; addr < addr_size ; addr += page_size) pages[addr] = 0; usleep(1); } fprintf(stderr, "write each page 1000 times\n"); ret = get_trace(getpid(), wcount); if (ret) { fprintf(stderr, "get_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "get_trace\n"); for (i = 0 ; i < PAGE_NUM ; i++) printf("wcount[%d] = %d\n", i, wcount[i]); ret = stop_trace(); if (ret) { fprintf(stderr, "stop_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "stop_trace\n"); for (i = 0 ; i < PAGE_NUM ; i++) if (wcount[i] < 900) return -1; return 0; }
long test1b() { unsigned char *pages; size_t page_size = PAGE_SIZE; size_t addr_size = page_size * PAGE_NUM; unsigned long addr; int wcount[PAGE_NUM], wcount2[PAGE_NUM], i, ret; void *args[2]; pthread_t thread; bzero(wcount, PAGE_NUM * sizeof(int)); bzero(wcount2, PAGE_NUM * sizeof(int)); pages = mmap(ADDR_START, addr_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); if (pages == MAP_FAILED) return -errno; fprintf(stderr, "pages = %lx\n", (unsigned long)pages); bzero(pages, addr_size); ret = start_trace((unsigned long)pages, addr_size); if (ret) { fprintf(stderr, "start_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "start_trace\n"); args[0] = pages; args[1] = wcount2; pthread_create(&thread, NULL, thread1b, args); pthread_join(thread, NULL); usleep(10); for (i = 0 ; i < 10 ; i++) { for (addr = 0 ; addr < addr_size ; addr += page_size) pages[addr]++; usleep(20); } ret = get_trace(gettid(), wcount); if (ret) { fprintf(stderr, "get_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "get_trace\n"); for (i = 0 ; i < PAGE_NUM ; i++) printf("wcount[%d]=%02d, wcount2[%d]=%02d, page[%04X]=%d\n", i, wcount[i], i, wcount2[i], i * page_size, pages[i * page_size]); ret = stop_trace(); if (ret) { fprintf(stderr, "stop_trace failed: %s\n", strerror(errno)); return -errno; } fprintf(stderr, "stop_trace\n"); for (i = 0 ; i < PAGE_NUM ; i++) if (wcount[i] < 9 || wcount[i] > 10 || wcount2[i] < 9 || wcount[i] > 10) return -1; return 0; }
NORET_TYPE void panic(const char * fmt, ...) { long i; static char buf[1024]; va_list args; #if defined(CONFIG_S390) unsigned long caller = (unsigned long) __builtin_return_address(0); #endif stop_trace(); /* * It's possible to come here directly from a panic-assertion and not * have preempt disabled. Some functions called from here want * preempt to be disabled. No point enabling it later though... */ preempt_disable(); bust_spinlocks(1); va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); dump_stack(); bust_spinlocks(0); /* * If we have crashed and we have a crash kernel loaded let it handle * everything else. * Do we want to call this before we try to display a message? */ crash_kexec(NULL); #ifdef CONFIG_SMP /* * Note smp_send_stop is the usual smp shutdown function, which * unfortunately means it may not be hardened to work in a panic * situation. */ // smp_send_stop(); #endif atomic_notifier_call_chain(&panic_notifier_list, 0, buf); if (!panic_blink) panic_blink = no_blink; if (panic_timeout > 0) { /* * Delay timeout seconds before rebooting the machine. * We can't use the "normal" timers since we just panicked.. */ printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout); for (i = 0; i < panic_timeout*1000; ) { touch_nmi_watchdog(); i += panic_blink(i); mdelay(1); i++; } /* This will not be a clean reboot, with everything * shutting down. But if there is a chance of * rebooting the system it will be rebooted. */ emergency_restart(); } #ifdef __sparc__ { extern int stop_a_enabled; /* Make sure the user can actually press Stop-A (L1-A) */ stop_a_enabled = 1; printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n"); } #endif #if defined(CONFIG_S390) disabled_wait(caller); #endif local_irq_enable(); for (i = 0;;) { touch_softlockup_watchdog(); i += panic_blink(i); mdelay(1); i++; } }
void trace_stack (int argc, char **argv) { enum stack_type trace_type = STACK_REPORT; int c; if (argc < 2) usage(argv); if (strcmp(argv[1], "stack") != 0) usage(argv); for (;;) { int option_index = 0; static struct option long_options[] = { {"start", no_argument, NULL, OPT_start}, {"stop", no_argument, NULL, OPT_stop}, {"reset", no_argument, NULL, OPT_reset}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; c = getopt_long (argc-1, argv+1, "+h?", long_options, &option_index); if (c == -1) break; switch (c) { case 'h': usage(argv); break; case OPT_start: trace_type = STACK_START; break; case OPT_stop: trace_type = STACK_STOP; break; case OPT_reset: trace_type = STACK_RESET; break; default: usage(argv); } } test_available(); switch (trace_type) { case STACK_START: start_trace(); break; case STACK_STOP: stop_trace(); break; case STACK_RESET: reset_trace(); break; default: read_trace(); break; } return; }
bool CIPICOMConnectionV6::open(int nPort,const char * node_name) { static int once = 1; if(!ipicom) { ipicom = CIPICOMLibV6::Inst(); if (!ipicom) { LOGER((CLogger::DEBUG_ERROR,"Failed to initialize IPCS library!")); return false; } LOGER((CLogger::DEBUG_INFO,"Initialize IPCS library OK!")); if (once) { stop_trace(); /*no need trace **/ ipicom->sapn_set_node_name(node_name); once = 0; } } bCheckConnectionOK = false; char full_port[128]; char session_options[128]; sprintf_s(full_port, "COM%d", nPort); sprintf_s(session_options, "BAUD=115200;RTS=0;DTR=1"); LOGER((CLogger::DEBUG_INFO,"open data link(%s,%s,true)",full_port,session_options)); datalink_id = ipicom->datalink_open(full_port, session_options, true); if (datalink_id < 0) { datalink_id = 0; LOGER((CLogger::DEBUG_ERROR,"Failed to open data link")); return false; } LOGER((CLogger::DEBUG_INFO,"Data link opened")); // create shared socket socket_shared = ipicom->socket(PF_IPICOM, IPICOM_SOCKET_TYPE_DGRAM, IPICOM_AT_PROTO); if (socket_shared == IPICOM_SOCKET_INVALID_HANDLE) { LOGER((CLogger::DEBUG_ERROR,"Failed to create shared socket")); return false; } LOGER((CLogger::DEBUG_INFO,"Shared socket created")); timeout_count = 0; T_IPICOM_SOCK_ADDR_IN bind_addr; bind_addr.at.datalink_id = datalink_id; ipicom->socket_bind(socket_shared, &bind_addr, sizeof(T_IPICOM_AT_ADDRESS)); opened = 1; //E_LOG->TimeLine(eEngine, eLogTargetComm, "Configured socket %X as AT", socket_shared); // active shared channel channel_map[shared_channel] = socket_shared; active_channel = shared_channel; //stop_trace(); m_iPort = nPort; return true; }