Пример #1
0
int nativeExtraArg(MethodBlock *mb) {
    int params = (mb->args_count + 1 +
                 ((mb->access_flags & ACC_STATIC) ? 1 : 0) + 7 + 6) * -sizeof(uintptr_t);

#ifdef DEBUG_DLL
    jam_printf("<nativExtraArg %s%s : %d>\n", mb->name, mb->type, params);
#endif

    return params;
}
Пример #2
0
void dumpThreadsLoop(Thread *self) {
    //return;                     // do nothing for now
    //assert(false);

    char buffer[256];
    Thread *thread;
    sigset_t mask;
    int sig;

    sigemptyset(&mask);
    sigaddset(&mask, SIGQUIT);
    sigaddset(&mask, SIGINT);

    disableSuspend0(self, &self);
    for(;;) {
        sigwait(&mask, &sig);

        /* If it was an interrupt (e.g. Ctrl-C) terminate the VM */
        if(sig == SIGINT)
            exitVM(0);

        /* It must be a SIGQUIT.  Do a thread dump */

        suspendAllThreads(self);
        jam_printf("\n------ JamVM version %s Full Thread Dump -------\n", VERSION);

        for(thread = &main_thread; thread != NULL; thread = thread->next) {
            //uintptr_t *thr_data = INST_DATA(thread->ee->thread);
            uintptr_t *thr_data = INST_DATA(thread->thread);
            int priority = thr_data[priority_offset];
            int daemon = thr_data[daemon_offset];
            assert(false);
            //Frame *last = thread->ee->last_frame;
            Frame* last = threadSelf()->get_current_spmt_thread()->get_current_mode()->frame;

            /* Get thread name; we don't use String2Cstr(), as this mallocs memory
               and may deadlock with a thread suspended in malloc/realloc/free */
            String2Buff((Object*)thr_data[name_offset], buffer, sizeof(buffer));

            jam_printf("\n\"%s\"%s %p priority: %d tid: %p id: %d state: %s (%d)\n",
                  buffer, daemon ? " (daemon)" : "", thread, priority, thread->tid,
                  thread->id, getThreadStateString(thread), thread->state);

            while(last->prev != NULL) {
                for(; last->mb != NULL; last = last->prev) {
                    MethodBlock *mb = last->mb;
                    ClassBlock *cb = CLASS_CB(mb->classobj);

                    /* Convert slashes in class name to dots.  Similar to above,
                       we don't use slash2dots(), as this mallocs memory */
                    slash2dots2buff(cb->name, buffer, sizeof(buffer));
                    jam_printf("\tat %s.%s(", buffer, mb->name);

                    if(mb->is_native())
                        jam_printf("Native method");
                    else
                        if(cb->source_file_name == NULL)
                            jam_printf("Unknown source");
                        else {
                            int line = mapPC2LineNo(mb, last->last_pc);
                            jam_printf("%s", cb->source_file_name);
                            if(line != -1)
                                jam_printf(":%d", line);
                        }
                    jam_printf(")\n");
                }
                last = last->prev;
            }
        }
        resumeAllThreads(self);
    }
}