static int coff_add_file(struct CoffFileSet* coff_files, struct module* module, const char* filename) { struct CoffFile* file; if (coff_files->nfiles + 1 >= coff_files->nfiles_alloc) { if (coff_files->files) { coff_files->nfiles_alloc *= 2; coff_files->files = HeapReAlloc(GetProcessHeap(), 0, coff_files->files, coff_files->nfiles_alloc * sizeof(struct CoffFile)); } else { coff_files->nfiles_alloc = 16; coff_files->files = HeapAlloc(GetProcessHeap(), 0, coff_files->nfiles_alloc * sizeof(struct CoffFile)); } } file = coff_files->files + coff_files->nfiles; file->startaddr = 0xffffffff; file->endaddr = 0; file->compiland = symt_new_compiland(module, 0, source_new(module, NULL, filename)); file->linetab_offset = -1; file->linecnt = 0; file->entries = NULL; file->neps = file->neps_alloc = 0; return coff_files->nfiles++; }
/* if_layout: Update the layout of the screen based on current terminal size. * ---------- * * Return Value: Zero on success, non-zero on failure. */ static int if_layout() { /* Verify the window size is reasonable */ validate_window_sizes(); /* Initialize the GDB I/O window */ if (gdb_win == NULL) { gdb_win = scr_new(get_gdb_row(), get_gdb_col(), get_gdb_height(), get_gdb_width()); if (gdb_win == NULL) return 2; } else { /* Resize the GDB I/O window */ if (get_gdb_height() > 0) scr_move(gdb_win, get_gdb_row(), get_gdb_col(), get_gdb_height(), get_gdb_width()); } /* Initialize TTY I/O window */ if (tty_win == NULL) { tty_win = scr_new(get_tty_row(), get_tty_col(), get_tty_height(), get_tty_width()); if (tty_win == NULL) return 2; } else { /* Resize the GDB I/O window */ if (get_tty_height() > 0) scr_move(tty_win, get_tty_row(), get_tty_col(), get_tty_height(), get_tty_width()); } /* Initialize the source viewer window */ if (src_win == NULL) { src_win = source_new(get_src_row(), get_src_col(), get_src_height(), get_src_width()); if (src_win == NULL) return 3; } else { /* Resize the source viewer window */ if (get_src_height() > 0) source_move(src_win, get_src_row(), get_src_col(), get_src_height(), get_src_width()); } /* Initialize the status bar window */ status_win = newwin(get_src_status_height(), get_src_status_width(), get_src_status_row(), get_src_status_col()); /* Initialize the tty status bar window */ if (tty_win_on) tty_status_win = newwin(get_tty_status_height(), get_tty_status_width(), get_tty_status_row(), get_tty_status_col()); if_draw(); return 0; }
/* if_layout: Update the layout of the screen based on current terminal size. * ---------- * * Return Value: Zero on success, -1 on failure. */ static int if_layout() { SWINDOW *gdb_scroller_win = NULL; SWINDOW *src_viewer_win = NULL; if (!curses_initialized) return -1; /* Verify the window size is reasonable */ validate_window_sizes(); /* Resize the source viewer window */ create_swindow(&src_viewer_win, get_src_height(), get_src_width(), get_src_row(), get_src_col()); if (src_viewer) { source_move(src_viewer, src_viewer_win); } else { src_viewer = source_new(src_viewer_win); } /* Resize the GDB I/O window */ create_swindow(&gdb_scroller_win, get_gdb_height(), get_gdb_width(), get_gdb_row(), get_gdb_col()); if (gdb_scroller) { scr_move(gdb_scroller, gdb_scroller_win); } else { gdb_scroller = scr_new(gdb_scroller_win); } /* Initialize the status bar window */ create_swindow(&status_win, get_src_status_height(), get_src_status_width(), get_src_status_row(), get_src_status_col()); /* Redraw the interface */ if_draw(); return 0; }
_export struct dsp_node_t *dsp_node_new(unsigned int incnt, unsigned int outcnt, dsp_flow_f func, void *arg) { struct dsp_node_t *node; unsigned int i; node = mem_alloc(sizeof(struct dsp_node_t)); node->flow = NULL; node->incnt = incnt; node->outcnt = outcnt; node->func = func; node->arg = arg; node->sink = mem_alloc(incnt * sizeof(void *)); for(i = 0; i < incnt; i++) node->sink[i] = sink_new(node); node->source = mem_alloc(outcnt * sizeof(void *)); for(i = 0; i < outcnt; i++) node->source[i] = source_new(node); return node; }
_export void dsp_node_resize(struct dsp_node_t *node, unsigned int incnt, unsigned int outcnt) { unsigned int i; for(i = incnt; i < node->incnt; i++) sink_delete(node->sink[i]); for(i = outcnt; i < node->outcnt; i++) source_delete(node->source[i]); node->sink = mem_realloc(node->sink, incnt * sizeof(void *)); node->source = mem_realloc(node->source, outcnt * sizeof(void *)); for(i = node->incnt; i < incnt; i++) node->sink[i] = sink_new(node); for(i = node->outcnt; i < outcnt; i++) node->source[i] = source_new(node); node->incnt = incnt; node->outcnt = outcnt; }
struct source *source_new_pathspec(const char *type, const char *pathspec, const char *pkg_prefix) { struct source *src; const char *path, *p; char *name, *q, *spec_type, *opts = NULL; int len; unsigned flags = 0; if (*pathspec == '\0') return NULL; if ((spec_type = parse_cmdl_pathspec(pathspec, &path))) pathspec = path; p = pathspec; while (*p && *p != '|' && *p != '#' && !isspace(*p)) p++; if (*p == '\0') { /* path only */ path = pathspec; name = NULL; } else { path = p + 1; while (isspace(*path)) path++; len = p - pathspec; name = alloca(len + 1); memcpy(name, pathspec, len); name[len] = '\0'; if (*name == '[') name++; if ((q = strrchr(name, ']'))) *q = '\0'; if ((q = strchr(name, ','))) { *q = '\0'; opts = ++q; } if (*name == '\0') name = NULL; } src = source_new(name, type ? type : spec_type, path, pkg_prefix); if (src == NULL) return NULL; src->flags |= flags; if (spec_type != NULL) free(spec_type); if (opts) { const char **tl, **t; tl = t = n_str_tokl(opts, ","); n_assert(tl); while (*t) { int n = 0; while (source_options[n].name != NULL) { struct src_option *opt = &source_options[n]; if (opt->len == 0) opt->len = strlen(opt->name); if (opt->flag & PKGSRC_OPTION_SUBOPT) { if (strncmp(*t, opt->name, opt->len) == 0) { if (get_subopt(src, opt, *t, name)) src->flags |= opt->flag; break; } } else if (strcmp(*t, opt->name) == 0) { src->flags |= opt->flag; break; } n++; } if (source_options[n].name == NULL) logn(LOGWARN, _("%s: %s unknown option"), name, *t); t++; } n_str_tokl_free(tl); } setup_langs(src); return src; }
/****************************************************************** * pe_load_coff_symbol_table * * Load public symbols out of the COFF symbol table (if any). */ static BOOL pe_load_coff_symbol_table(struct module* module) { struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap; const IMAGE_SYMBOL* isym; int i, numsym, naux; const char* strtable; char tmp[9]; const char* name; const char* lastfilename = NULL; struct symt_compiland* compiland = NULL; const IMAGE_SECTION_HEADER* sect; const char* mapping; numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols; if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym) return TRUE; if (!(mapping = pe_map_full(fmap, NULL))) return FALSE; isym = (const IMAGE_SYMBOL*)((const char*)mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable); /* FIXME: no way to get strtable size */ strtable = (const char*)&isym[numsym]; sect = IMAGE_FIRST_SECTION(RtlImageNtHeader((HMODULE)mapping)); for (i = 0; i < numsym; i+= naux, isym += naux) { if (isym->StorageClass == IMAGE_SYM_CLASS_FILE) { lastfilename = (const char*)(isym + 1); compiland = NULL; } if (isym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL && isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections) { if (isym->N.Name.Short) { name = memcpy(tmp, isym->N.ShortName, 8); tmp[8] = '\0'; } else name = strtable + isym->N.Name.Long; if (name[0] == '_') name++; if (!compiland && lastfilename) compiland = symt_new_compiland(module, 0, source_new(module, NULL, lastfilename)); if (!(dbghelp_options & SYMOPT_NO_PUBLICS)) symt_new_public(module, compiland, name, FALSE, module->module.BaseOfImage + sect[isym->SectionNumber - 1].VirtualAddress + isym->Value, 1); } naux = isym->NumberOfAuxSymbols + 1; } module->module.SymType = SymCoff; module->module.LineNumbers = FALSE; module->module.GlobalSymbols = FALSE; module->module.TypeInfo = FALSE; module->module.SourceIndexed = FALSE; module->module.Publics = TRUE; pe_unmap_full(fmap); return TRUE; }