main() { register total; putenv("_filesize_caps"); chdir(getenv("HOME")); ss_open(); co_open(); oc_open(); pr_open(); total = ss_size + co_size + oc_size + pr_size; printf("\n\n"); printf(" CAPS Shared Segment File Sizes\n"); printf(" ------------------------------\n"); printf(" ss segment is %7d bytes\n", ss_size); printf(" co segment is %7d bytes\n", co_size); printf(" oc segment is %7d bytes\n", oc_size); printf(" pr segment is %7d bytes\n", pr_size); printf(" -------\n"); printf(" total size is %7d bytes\n\n", total); pr_close(); co_close(); oc_close(); ss_close(); return; }
static int dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) { struct ps_prochandle *P = data; GElf_Sym sym; prsyminfo_t sip; dof_helper_t dh; GElf_Half e_type; const char *mname; const char *syms[] = { "___SUNW_dof", "__SUNW_dof" }; int i, fd = -1; /* * The symbol ___SUNW_dof is for lazy-loaded DOF sections, and * __SUNW_dof is for actively-loaded DOF sections. We try to force * in both types of DOF section since the process may not yet have * run the code to instantiate these providers. */ for (i = 0; i < 2; i++) { if (Pxlookup_by_name(P, PR_LMID_EVERY, oname, syms[i], &sym, &sip) != 0) { continue; } if ((mname = strrchr(oname, '/')) == NULL) mname = oname; else mname++; dt_dprintf("lookup of %s succeeded for %s\n", syms[i], mname); if (Pread(P, &e_type, sizeof (e_type), pmp->pr_vaddr + offsetof(Elf64_Ehdr, e_type)) != sizeof (e_type)) { dt_dprintf("read of ELF header failed"); continue; } dh.dofhp_dof = sym.st_value; dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), sip.prs_lmid, mname); if (fd == -1 && (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) { dt_dprintf("pr_open of helper device failed: %s\n", strerror(errno)); return (-1); /* errno is set for us */ } if (pr_ioctl(P, fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0) dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); } if (fd != -1) (void) pr_close(P, fd); return (0); }
/*{{{ bit_open.c*/ BITMAP *bit_open(char *name) { BITMAP *result; result = pr_open(name); # ifdef MOVIE if(result) log_open(result); # endif return result; }
/* ARGSUSED */ int main (int argc, char **argv, char **envp) { int skip_args = 0; #ifdef HAVE_PERSONALITY_LINUX32 /* See if there is a gap between the end of BSS and the heap. In that case, set personality and exec ourself again. */ if (!initialized && strcmp (argv[argc-1], "dump") == 0 && !getenv ("EMACS_HEAP_EXEC")) { /* Set this so we only do this once. */ putenv ("EMACS_HEAP_EXEC=true"); /* A flag to turn off address randomization which is introduced in linux kernel shipped with fedora core 4 */ personality (PER_LINUX32 | ADDR_NO_RANDOMIZE); execvp (argv[0], argv); /* If the exec fails, try to dump anyway. */ perror ("execvp"); } #endif /* HAVE_PERSONALITY_LINUX32 */ /* Map in shared memory, if we are using that. */ #ifdef HAVE_SHM if (argc > 1 && !strcmp (argv[1], "-nl")) { map_in_data (0); /* The shared memory was just restored, which clobbered this. */ skip_args = 1; } else { map_in_data (1); /* The shared memory was just restored, which clobbered this. */ skip_args = 0; } #endif #ifdef VMS /* If -map specified, map the data file in */ if (argc > 2 && ! strcmp (argv[1], "-map")) { skip_args = 2; mapin_data (argv[2]); } #ifdef LINK_CRTL_SHARE #ifdef SHAREABLE_LIB_BUG /* Bletcherous shared libraries! */ if (!stdin) stdin = fdopen (0, "r"); if (!stdout) stdout = fdopen (1, "w"); if (!stderr) stderr = fdopen (2, "w"); if (!environ) environ = envp; #endif /* SHAREABLE_LIB_BUG */ #endif /* LINK_CRTL_SHARE */ #endif /* VMS */ /* 92.11.4, 93.2.17 by M.Higashida */ #if defined(MSDOS) && defined(EMX) environ = envp; #endif #ifdef WIN32 environ = envp; #endif /* end of patch */ #ifdef USG_SHARED_LIBRARIES if (bss_end) brk (bss_end); #endif #ifdef NeXT extern int malloc_cookie; /* This helps out unexnext.c. */ if (initialized) { if (malloc_jumpstart (malloc_cookie) != 0) fatal("malloc jumpstart failed!\n"); } else { emacszone = NXCreateZone(ZONESIZE*vm_page_size,vm_page_size,1); if(emacszone == NX_NOZONE) fatal("can't create emacs zone.\n"); } #endif /* NeXT */ clearerr (stdin); #ifdef APOLLO #ifndef APOLLO_SR10 /* If USE_DOMAIN_ACLS environment variable exists, use ACLs rather than UNIX modes. */ if (egetenv ("USE_DOMAIN_ACLS")) default_acl (USE_DEFACL); #endif #endif /* APOLLO */ #ifndef SYSTEM_MALLOC /* Arrange for warnings when nearly out of space. */ malloc_init (0, malloc_warning); #endif /* 91.10.16 by S.Hirano */ #if defined(MSDOS) && defined(GO32) _fmode = O_BINARY; /* all of files are treated as binary files */ (stdin)->_flag &= ~_IOTEXT; /* also binary for stdio */ (stdout)->_flag &= ~_IOTEXT; (stderr)->_flag &= ~_IOTEXT; #endif /* MSDOS */ /* end of patch */ #ifdef HIGHPRI setpriority (PRIO_PROCESS, getpid (), HIGHPRI); setuid (getuid ()); #endif inhibit_window_system = 0; /* 92.3.31 by K.Handa, 92.10.21 by M.Higashida */ #if defined (HAVE_X_WINDOWS) || defined (HAVE_SUN_CONSOLE) || (defined(MSDOS) && defined(HAVE_VGA_ADAPTER)) || defined (WIN32) xargv = argv; xargc = argc; #endif /* Handle the -t switch, which specifies filename to use as terminal */ if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t")) { skip_args += 2; close (0); close (1); open (argv[skip_args], O_RDWR, 2 ); dup (0); fprintf (stderr, "Using %s\n", argv[skip_args]); /* 92.3.31 by K.Handa, 92.10.21 by M.Higashida */ #if defined (HAVE_X_WINDOWS) || defined (HAVE_SUN_CONSOLE) || (defined(MSDOS) && defined(HAVE_VGA_ADAPTER)) || defined (WIN32) inhibit_window_system = 1; /* -t => -nw */ #endif } #ifdef HAVE_X_WINDOWS /* Handle the -d switch, which means use a different display for X */ if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-d") || !strcmp (argv[skip_args + 1], "-display"))) { skip_args += 2; alternate_display = argv[skip_args]; } else alternate_display = 0; #endif /* HAVE_X_WINDOWS */ /* 92.3.31 by K.Handa */ #ifdef HAVE_SUN_CONSOLE if (skip_args + 1 < argc && (!strcmp (argv[skip_args + 1], "-sun"))) { extern Pixrect *screen; inhibit_window_system = -1; skip_args++; alternate_display = "/dev/fb"; if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-fb"))) { skip_args += 2; alternate_display = argv[skip_args]; } if (screen = pr_open(alternate_display)) /* Just a test. */ pr_close(screen); else alternate_display = 0; } #endif /* HAVE_SUN_CONSOLE */ /* end of patch */ /* 92.10.17, 93.2.17 by M.Higashida */ #if defined(MSDOS) && defined(HAVE_VGA_ADAPTER) if (skip_args + 1 < argc && (!strcmp (argv[skip_args + 1], "-vga"))) { inhibit_window_system = -1; skip_args++; } #endif /* MSDOS and HAVE_VGA_ADAPTER */ #ifdef WIN32 inhibit_window_system = -1; #endif /* end of patch */ if (skip_args + 1 < argc && (!strcmp (argv[skip_args + 1], "-nw"))) { skip_args += 1; inhibit_window_system = 1; } /* Handle the -batch switch, which means don't do interactive display. */ noninteractive = 0; if (skip_args + 1 < argc && !strcmp (argv[skip_args + 1], "-batch")) { skip_args += 1; noninteractive = 1; } #ifdef POSIX_SIGNALS init_signals (); #endif #ifdef HAVE_TZSET /* Reinitialize the time zone if it was initialized before dumping Emacs. */ if (initialized) tzset (); #endif #ifdef WIN32 /* 93.2.25 by M.Higashida */ _tzset (); #endif if ( #ifndef CANNOT_DUMP ! noninteractive || initialized #else 1 #endif ) { /* Don't catch these signals in batch mode if not initialized. On some machines, this sets static data that would make signal fail to work right when the dumped Emacs is run. */ /* 91.10.16 by S.Hirano, 92.11.4 by M.Higashida */ #ifdef MSDOS #ifdef GO32 /* Nothing */ #else #ifdef EMX signal (SIGBREAK, fatal_error_signal); signal (SIGQUIT, fatal_error_signal); #endif #endif #else /* not MSDOS */ signal (SIGHUP, fatal_error_signal); signal (SIGQUIT, fatal_error_signal); signal (SIGILL, fatal_error_signal); signal (SIGTRAP, fatal_error_signal); signal (SIGIOT, fatal_error_signal); #ifdef SIGEMT signal (SIGEMT, fatal_error_signal); #endif signal (SIGFPE, fatal_error_signal); signal (SIGBUS, fatal_error_signal); signal (SIGSEGV, fatal_error_signal); signal (SIGSYS, fatal_error_signal); signal (SIGTERM, fatal_error_signal); #ifdef SIGXCPU signal (SIGXCPU, fatal_error_signal); #endif #ifdef SIGXFSZ signal (SIGXFSZ, fatal_error_signal); #endif #endif /* not MSDOS and GO32 */ /* end of patch */ #ifdef AIX /* This used to run fatal_error_signal, but it isn't fatal. There's nothing Emacs can usefully do. Might as well let the system kill us if it insists. */ signal (SIGDANGER, SIG_IGN); signal (20, fatal_error_signal); signal (21, fatal_error_signal); signal (22, fatal_error_signal); signal (23, fatal_error_signal); signal (24, fatal_error_signal); #ifdef SIGIO signal (SIGAIO, fatal_error_signal); signal (SIGPTY, fatal_error_signal); #endif #ifdef SIGURG /* Note that SIGIOINT is the same as SIGIO on some machines, and the same as SIGURG on others. It seems ore reliable to use the name with a uniform meaning. */ signal (SIGURG, fatal_error_signal); #endif signal (SIGGRANT, fatal_error_signal); signal (SIGRETRACT, fatal_error_signal); signal (SIGSOUND, fatal_error_signal); signal (SIGMSG, fatal_error_signal); #endif /* AIX */ } noninteractive1 = noninteractive; /* Perform basic initializations (not merely interning symbols) */ if (!initialized) { init_alloc_once (); init_obarray (); init_eval_once (); init_mc_once (); /* 89.7.26, 91.10.19 by K.Handa */ init_syntax_once (); /* Create standard syntax table. */ init_category_once (); /* 91.12.7 by K.Handa */ /* Must be done before init_buffer */ init_buffer_once (); /* Create buffer table and some buffers */ init_minibuf_once (); /* Create list of minibuffers */ /* Must precede init_window_once */ init_window_once (); /* Init the window system */ /* 92.10.28 by M.Higashida */ #if defined (MSDOS) && defined (HAVE_VGA_ADAPTER) init_bdf_once (); /* Init the BDF font structure. */ #endif /* end of patch */ } init_alloc (); #ifdef MAINTAIN_ENVIRONMENT init_environ (); /* 92.3.25 by N.Hikichi */ #ifdef HAVE_X_WINDOWS if (alternate_display) set_environment_alist (build_string ("DISPLAY"), build_string (alternate_display)); #endif /* HAVE_X_WINDOWS */ /* end of patch */ #endif init_codeconv (); /* 92.1.7 by K.Handa */ init_eval (); init_data (); init_read (); init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */ init_buffer (); /* Init default directory of main buffer */ if (!noninteractive) { #ifdef VMS init_vms_input ();/* init_display calls get_screen_size, that needs this */ #endif /* VMS */ init_display (); /* Determine terminal type. init_sys_modes uses results */ } init_keyboard (); /* This too must precede init_sys_modes */ init_callproc (); /* And this too. */ init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.) */ init_xdisp (); init_macros (); init_editfns (); #ifdef VMS init_vmsfns (); #endif /* VMS */ #ifdef subprocesses init_process (); #endif /* subprocesses */ /* Intern the names of all standard functions and variables; define standard keys */ if (!initialized) { /* The basic levels of Lisp must come first */ /* And data must come first of all for the sake of symbols like error-message */ syms_of_data (); syms_of_alloc (); #ifdef MAINTAIN_ENVIRONMENT syms_of_environ (); #endif /* MAINTAIN_ENVIRONMENT */ syms_of_read (); syms_of_print (); syms_of_eval (); syms_of_fns (); syms_of_abbrev (); syms_of_buffer (); syms_of_bytecode (); syms_of_callint (); syms_of_casefiddle (); syms_of_callproc (); syms_of_category (); /* 91.11.11 by K.Handa */ syms_of_codeconv (); /* 92.1.7 by K.Handa */ syms_of_cmds (); #ifndef NO_DIR_LIBRARY syms_of_dired (); #endif /* not NO_DIR_LIBRARY */ syms_of_display (); syms_of_doc (); syms_of_editfns (); syms_of_emacs (); syms_of_fileio (); #ifdef CLASH_DETECTION syms_of_filelock (); #endif /* CLASH_DETECTION */ /* 92.11.1 by M.Higashida */ #ifdef FILE_TRANSLATION_MODE syms_of_transmode (); #endif /* FILE_TRANSLATION_MODE */ /* end of patch */ syms_of_indent (); syms_of_keyboard (); syms_of_keymap (); syms_of_macros (); syms_of_marker (); syms_of_minibuf (); syms_of_mocklisp (); #ifdef subprocesses syms_of_process (); #endif /* subprocesses */ syms_of_search (); syms_of_syntax (); syms_of_undo (); syms_of_window (); syms_of_xdisp (); #ifdef HAVE_X_WINDOWS syms_of_xfns (); #ifdef HAVE_X_MENU syms_of_xmenu (); #endif /* HAVE_X_MENU */ #endif /* HAVE_X_WINDOWS */ /* 87.6.8, 91.11.2, 92.3.31, 92.7.31 by K.Handa, 92.10.17, 93.2.17 by M.Higashida */ #ifdef HAVE_SUN_CONSOLE syms_of_sunterm (); #endif #if defined(MSDOS) && defined(HAVE_VGA_ADAPTER) syms_of_vgaterm (); #endif #ifdef WIN32 syms_of_win32term (); #endif syms_of_mc (); syms_of_ccl (); /* 93.5.14 by K.Handa */ #ifdef WNN4 syms_of_wnn (); #endif #ifdef CANNA syms_of_canna (); #endif /* CANNA */ /* end of patch */ #ifdef MCPATH syms_of_mcpath (); #endif /* MCPATH */ #ifdef SYMS_SYSTEM SYMS_SYSTEM; #endif #ifdef SYMS_MACHINE SYMS_MACHINE; #endif keys_of_casefiddle (); keys_of_cmds (); keys_of_buffer (); keys_of_keyboard (); keys_of_keymap (); keys_of_macros (); keys_of_minibuf (); keys_of_window (); } if (!initialized) { /* Handle -l loadup-and-dump, args passed by Makefile. */ if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l")) Vtop_level = Fcons (intern ("load"), Fcons (build_string (argv[2 + skip_args]), Qnil)); #ifdef CANNOT_DUMP /* Unless next switch is -nl, load "loadup.el" first thing. */ if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl"))) Vtop_level = Fcons (intern ("load"), Fcons (build_string ("loadup.el"), Qnil)); #endif /* CANNOT_DUMP */ } initialized = 1; /* Enter editor command loop. This never returns. */ Frecursive_edit (); /* NOTREACHED */ }
static int dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) { struct ps_prochandle *P = data; GElf_Sym sym; #if defined(sun) prsyminfo_t sip; GElf_Half e_type; #endif dof_helper_t dh; const char *mname; const char *syms[] = { "___SUNW_dof", "__SUNW_dof" }; int i; #if defined(windows) HANDLE fd = NULL; DWORD ret, gen; #endif #if !defined(sun) dof_hdr_t hdr; #endif /* * The symbol ___SUNW_dof is for lazy-loaded DOF sections, and * __SUNW_dof is for actively-loaded DOF sections. We try to force * in both types of DOF section since the process may not yet have * run the code to instantiate these providers. */ for (i = 0; i < 2; i++) { if (Pxlookup_by_name(P, PR_LMID_EVERY, oname, syms[i], &sym, NULL) != 0) { continue; } if ((mname = strrchr(oname, '/')) == NULL) mname = oname; else mname++; dt_dprintf("lookup of %s succeeded for %s\n", syms[i], mname); #if 0 if (Pread(P, &e_type, sizeof (e_type), pmp->pr_vaddr + offsetof(Elf64_Ehdr, e_type)) != sizeof (e_type)) { dt_dprintf("read of ELF header failed"); continue; } dh.dofhp_dof = sym.st_value; dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; #endif #if !defined(sun) dh.dofhp_addr = 0; dh.dofhp_dof = (uintptr_t) sym.st_value;; dh.dofhp_pid = Ppid(P); dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), 0, mname); if (fd == NULL && (fd = CreateFile("\\\\.\\DtraceHelper", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == NULL) { dt_dprintf("open of helper device failed: %s\n", strerror(errno)); return (-1); /* errno is set for us */ } if ((DeviceIoControl(fd, DTRACEHIOC_ADDDOF, &dh, 0, &gen, 0, &ret, NULL)) == 0) dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); else dt_dprintf("DOF was success for %s\n", dh.dofhp_mod); #else dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), sip.prs_lmid, mname); if (fd == -1 && (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) { dt_dprintf("pr_open of helper device failed: %s\n", strerror(errno)); return (-1); /* errno is set for us */ } if (pr_ioctl(P, fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0) dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); #endif } #if defined(sun) if (fd != -1) (void) pr_close(P, fd); #else if (fd != 0) CloseHandle(fd); #endif return (0); }