diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-07-19 22:38:30 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2015-07-19 22:38:30 +0200 |
commit | 4889f730c1fa5db8cea2780eaa1d2156c92b298a (patch) | |
tree | db15dda9f3bece0057cadae0f53048eac191371d /winsup/cygwin/pinfo.cc | |
parent | 93a8435f826453396f0d30f1f0ee07098aa78530 (diff) | |
download | cygnal-4889f730c1fa5db8cea2780eaa1d2156c92b298a.tar.gz cygnal-4889f730c1fa5db8cea2780eaa1d2156c92b298a.tar.bz2 cygnal-4889f730c1fa5db8cea2780eaa1d2156c92b298a.zip |
Reduce stack pressure throughout Cygwin
* dcrt0.cc (initial_env): Reduce size of local path buffers to
PATH_MAX. Allocate debugger_command from process heap.
(init_windows_system_directory): Very early initialize new global
variable global_progname.
* dll_init.cc (dll_list::alloc): Make path buffer static. Explain why.
(dll_list::populate_deps): Use tmp_pathbuf for local path buffer.
* exceptions.cc (debugger_command): Convert to PWCHAR.
(error_start_init): Allocate debugger_command and fill with wide char
strings. Only allocate if NULL.
(try_to_debug): Just check if debugger_command is a NULL pointer to
return. Drop conversion from char to WCHAR and drop local variable
dbg_cmd.
* globals.cc (global_progname): New global variable to store Windows
application path.
* pinfo.cc (pinfo_basic::pinfo_basic): Just copy progname over from
global_progname.
(pinfo::status_exit): Let path_conv create the POSIX path to
avoid local buffer.
* pseudo_reloc.cc (__report_error): Utilize global_progname, drop local
buffer.
* smallprint.cc (__small_vsprintf): Just utilize global_progname for
%P format specifier.
(__small_vswprintf): Ditto.
* strace.cc (PROTECT): Change to reflect x being a pointer. Reformat.
(CHECK): Ditto. Reformat.
(strace::activate): Utilize global_progname, drop local buffer.
Fix formatting.
(strace::vsprntf): Reduce size of local progname buffer to NAME_MAX.
Copy and, if necessary, convert only the last path component to
progname.
(strace_buf_guard): New muto.
(buf): New static pointer.
(strace::vprntf): Use buf under strace_buf_guard lock only. Allocate
buffer space for buf on Windows heap.
* wow64.cc (wow64_respawn_process): Utilize global_progname, drop
local path buffer.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r-- | winsup/cygwin/pinfo.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 038937e15..d0b4cd9a4 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -38,7 +38,9 @@ public: pinfo_basic::pinfo_basic () { pid = dwProcessId = GetCurrentProcessId (); - GetModuleFileNameW (NULL, progname, sizeof (progname) / sizeof (WCHAR)); + PWCHAR pend = wcpncpy (progname, global_progname, + sizeof (progname) / sizeof (WCHAR) - 1); + *pend = L'\0'; /* Default uid/gid are needed very early to initialize shared user info. */ uid = ILLEGAL_UID; gid = ILLEGAL_GID; @@ -120,20 +122,18 @@ pinfo::status_exit (DWORD x) { case STATUS_DLL_NOT_FOUND: { - char posix_prog[NT_MAX_PATH]; path_conv pc; if (!procinfo) - pc.check ("/dev/null"); + pc.check ("/dev/null", PC_NOWARN | PC_POSIX); else { UNICODE_STRING uc; RtlInitUnicodeString(&uc, procinfo->progname); - pc.check (&uc, PC_NOWARN); + pc.check (&uc, PC_NOWARN | PC_POSIX); } - mount_table->conv_to_posix_path (pc.get_win32 (), posix_prog, 1); small_printf ("%s: error while loading shared libraries: %s: cannot " "open shared object file: No such file or directory\n", - posix_prog, find_first_notloaded_dll (pc)); + pc.get_posix (), find_first_notloaded_dll (pc)); x = 127 << 8; } break; |