Commit Graph

907 Commits

Author SHA1 Message Date
Corinna Vinschen 603f880cb7 Cygwin: cygcheck: simplify output when fetching setup.ini
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-29 17:51:42 +01:00
Corinna Vinschen c67e6570ee Cygwin: cygcheck: add human readable package size output
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-29 17:21:28 +01:00
Corinna Vinschen 022665af17 Cygwin: cygcheck: package info / available package search, take 2
- if the user has no perms to write to /etc/setup, don't try
  to fetch user homedir from Cygwin (crashes galore).  Use
  LOCALAPPDATA path instead.
- info is more rpm like
- print info of installed package
- added info selectors --inst, --curr, --prev, --test
- add installation date

TODO:

- Human-readable filesize
- url and license needs to be added to setup.ini yet
-

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-29 14:13:25 +01:00
Corinna Vinschen 76d2053ec8 Cygwin: cygcheck: package info / available package search, take 1
cygcheck -i == dnf info <pattern...>
cygcheck -e == dnf search <pattern...>

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-28 14:59:39 +01:00
Corinna Vinschen 28594480df Cygwin: cygcheck: split out fetching data from cygwin.com
In preparation of new functionality, split fetching data
from cygwin.com out of the package_grep() function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-26 19:58:30 +01:00
Corinna Vinschen 1d4110e347 Cygwin: fix build of cygcheck and strace
adding <target>_LDFLAGS overrides AM_LDFLAGS and thus fails to
build cygcheck and strace statically.  Fix it.

Fixes: 8d318bf142 ("Cygwin: disable high-entropy VA for cygcheck and strace")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-19 18:28:16 +01:00
Corinna Vinschen 8d318bf142 Cygwin: disable high-entropy VA for cygcheck and strace
It's not a good idea to enable high-entropy VA for tools loading the
Cygwin DLL dynamically.  The addresses used by HEVA tend to collide with
fixed address areas managed by Cygwin.

Fixes: 60675f1a7e ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-17 18:41:10 +01:00
Corinna Vinschen 8bd56ec873 Cygwin: newgrp: first full version
- add '-' option
- make group argument optional
- drop ability to take a numerical group argument
- simplify usage output to bare minimum
- Add manpage and documentation

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-14 17:47:48 +01:00
Corinna Vinschen c8ddd03cb0 Cygwin: add very simple newgrp(1) tool
This tool allows to change the primary group for a child process.
The new primary group MUST be part of the supplementary group list
of newgrp's user token.

The command started as child process is specified on the command line.
If it's missing, start the user's default shell with the new primary
group.

TODO: Implement '-' option.
      Add command description to documentation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-13 20:59:29 +01:00
Corinna Vinschen 1fc3014728 Cygwin: utils: drop 32 bit considerations
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-10-28 11:37:02 +02:00
Corinna Vinschen f51e76da0a Cygwin: regtool: drop 32 bit hint from help output
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-10-28 11:01:56 +02:00
Corinna Vinschen 1b3a0effd4 Cygwin: profiler: Fix linking when building with -DDEBUGGING
CloseHandle gets redefined to a macro calling an internal function
in debug.h when building with -DDEBUGGING, but profiler has no access
to that function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-20 21:14:57 +02:00
Corinna Vinschen 007e23d639 Cygwin: Reorganize cygwin source dir
Create subdirs and move files accordingly:

- DevDocs:  doc files
- fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc
- local_includes: local include files
- scripts:  scripts called during build
- sec:      security sources

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:02:11 +02:00
Mark Geisert aa460cc0ca Cygwin: Have gmondump support ssp-generated gmon.out
Cygwin tool ssp generates gmon.out files with different address
resolution than other tools do. Two address bytes per bucket rather than
the usual four address bytes. Gprof can deal with the difference but
gmondump can't because the latter's gmon.out header validation fails.

- Remove the offending portion of the header validation code.
- Make sure all code can handle differing address resolutions.
- Display address resolution in verbose data dumps.
- Change "rawarc" to "struct rawarc" in certain sizeof expressions to
  avoid buffer overrun faults.
- When "-v" (verbose) is specified, note when there is missing bucket
  data or rawarc data.
2022-06-10 12:12:26 +02:00
Ken Brown 30c5411d07 Cygwin: remove most occurrences of __stdcall and __cdecl
These have no effect on x86_64.  Retain a few occurrences of __cdecl
in files imported from other sources.

Also retain all occurrences of WINAPI, even though the latter is
simply a macro that expands to __stdcall.  Most of these occurrences
are associated with Windows API functions, and removing them might
make the code confusing instead of simpler.
2022-06-06 12:00:45 -04:00
Jon Turney f36dd40275
Cygwin: Drop use of loadlib.h in regtool
Link directly with RegDeleteKeyExW(), available since Vista.

(It's unclear the LoadLibrary wrapper was ever doing anything useful
here, as (i) DLL lookup in PATH was avoided as advapi32 is already
loaded into the process, and (ii) advapi32 is a 'known DLL' which is
only ever loaded from system directory)
2022-06-06 11:21:44 +01:00
Jon Turney f344134a19
Cygwin: Drop pointless loadlib.h includes in utilities
These utilities used to LoadLibrary()/GetProcAddress(), but don't
anymore.
2022-06-06 11:21:43 +01:00
Takashi Yano faf1e11592 Cygwin: pty: Fix script command crash on console in Win7.
- Previously, the command "cmd /c script -c cmd" in console of Win7
  crashes. This seems to be due to a bug (?) of AttachConsole().
  This patch adds workaround for this issue.

  Currently, pty reattaches to the console of the process which is
  predetermined by ConsoleProcessList() after temporarily attaching
  to another console. After that, the console output handle opened
  with the name "CONOUT$" may not be accessible in Win7.
  This seems to happen when the attached process does not have the
  same handle even if the console attached is the same. With this
  patch, cygwin-console-helper which is started when pty master is
  opened in console, is utilized to be a target process to which
  pty reattaches if the OS is Win7.
2022-05-15 07:25:56 +09:00
Corinna Vinschen 4f034daba7 Cygwin: utils: drop unnecessary wow64 checks
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:34:20 +02:00
Corinna Vinschen d4fa3b4abb Cygwin: config.h: stop including auto-generated tlsoffsets.h file
This was a hack to begin with.  Clean this mess up:

- Move definition of CYGTLS_PADSIZE to cygwin/config.h and drop
  local cygtls_padsize.h
- Rename CYGTLS_PADSIZE to __CYGTLS_PADSIZE__ to keep namespace
  clean.  Redefine as macro, rather than as const.
- Move struct _reent first in struct _cygtls to allow using
  __CYGTLS_PADSIZE__ as offset in __getreent().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:58:39 +02:00
Mark Geisert 3976513b99 Cygwin: Fix gmondump formatting goofs
The rewrite of %X to %p was malhandled.  Fix that/them.
2022-03-17 10:14:23 +01:00
Corinna Vinschen 35ba7d147d Cygwin: getconf: align -a output to glibc getconf
glibc getconf doesn't print "undefined" for undefined values
in -a output.  It just prints the empty string.  Do it the
same way.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 22:15:02 +01:00
Corinna Vinschen b794f2c603 Cygwin: drop support for systems not supporting RFC 4646 locales
i. e. Vista/2008.  This drops support for the sr_CS locale.

Regenerate LC_MESSAGES and LC_TIME ERA data from more recent Linux

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:45 +02:00
Corinna Vinschen 548f124698 Cygwin: update cygcheck OS information
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-21 18:33:35 +02:00
Ken Brown 9b0841aa78 Cygwin: statically link the tools in winsup/utils/mingw
This fixes the problem reported here:

  https://cygwin.com/pipermail/cygwin-developers/2021-September/012375.html
2021-09-17 21:38:07 -04:00
Corinna Vinschen 88c0276358 Cygwin: Allow using CFLAGS also for C++ files
This was used before switching to automake to allow easy tweaking
of optimization and debugging settings from the command line during
testing.  Reenable.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-08-26 22:21:53 +02:00
Corinna Vinschen 3ca80b360c Cygwin: dumper: fix up GCC pragma for g++ 11.2
The GCC diagnostic ignored "-Wstringop-overflow" pragma doesn't work
as expected anymore.  Use the still working expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-08-26 22:15:49 +02:00
Corinna Vinschen 8169e39abf Cygwin: C++17: register keyword is deprecated
The register keyword was already deprecated with C++11, but
with C++17 it has been entirely removed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-08-26 22:14:11 +02:00
Mark Geisert 94ead7b76d Cygwin: More profiler format + small issue fixes
Make sure to cast to ulong all DWORD values displayed with format "%lu".
More instances are fixed here than in either my earlier unused patch or
Corinna's patch. I decided to use typedef..ulong for more compact code.

Address jturney's reported small issues:
- Remove explicit external ref for cygwin_internal() as it is already
  provided by <sys/cygwin.h>.
- Leave intact ref for cygwin_dll_path[] as it is required by function(s)
  in path.cc that profiler uses. Added comment to that effect.
- Delete existing main() wrapper. Rename main2() to main(). This because
  profiler is now a Cygwin program and doesn't need to dynamically load
  cygwin1.dll.
- Documentation issues will be addressed in a separate xml patch.

(I would have linked message-ids of Corinna's and Jon's messages for
proper theading but I no longer have their original emails and the mail
archives don't show msgids any more.)
2021-08-03 10:05:50 +02:00
Mark Geisert 99a4b087d4 Cygwin: Make gmondump conform to its doc + adjust doc
The doc for gmondump says 1 or more FILENAME are expected, but 0 is
handled. That's an oversight. Make invocation with 0 FILENAMEs print a
one-line help message.

Reword the beginning of profiler's description doc to clarify target's
child processes are run but only optionally profiled.
2021-08-03 10:00:56 +02:00
Corinna Vinschen ad8730cc91 Cygwin: utils: refresh tzmap.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-07-28 22:19:37 +02:00
Corinna Vinschen 4f999b4eab Cygwin: utils: tzmap-from-unicode.org: enforce sorting order for LANG=C
Generating the tzmap.h file requires to use the default sorting order.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-07-28 22:18:38 +02:00
Corinna Vinschen bf8f2a95df Cygwin: profiler: Fix formatting warnings
DWORD has different types on 32 and 64 bit.  Use a common cast to
unsigned long to use %lu format for DWORD values throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-07-21 10:07:22 +02:00
Mark Geisert ff9c2b3ab9
Cygwin: updates to wire in profiler, gmondump
These are updates to wire into the build tree the new tools profiler and
gmondump, and to supply documentation for the tools.

The documentation for profiler and ssp now mention each other but do not
discuss their similarities or differences.  That will be handled in a
future update to the "Profiling Cygwin Programs" section of the Cygwin
User's Guide, to be supplied.
2021-07-19 13:29:34 +01:00
Mark Geisert 4ad5b0ca31
Cygwin: New tool: gmondump
This new tool was formerly part of 'profiler' but was spun out thanks to
Jon T's reasonable review comment.  Gmondump is more of a debugging tool
than something users might have need for.  Users would more likely use
gprof to make use of symbolic info like function names and source line
numbers.
2021-07-19 13:29:13 +01:00
Mark Geisert 9bd6c0b2b1
Cygwin: New tool: profiler
The new tool formerly known as cygmon is renamed to 'profiler'.  For the
name I considered 'ipsampler' and could not think of any others.  I'm open
to a different name if any is suggested.

I decided that a discussion of the pros and cons of this profiler vs the
existing ssp should probably be in the "Profiling Cygwin Programs" section
of the Cygwin User's Guide rather than in the help for either.  That
material will be supplied at some point.

CONTEXT buffers are made child-specific and thus thread-specific since
there is one profiler thread for each child program being profiled.

The SetThreadPriority() warning comment has been expanded.

chmod() works on Cygwin so the "//XXX ineffective" comment is gone.

I decided to make the "sample all executable sections" and "sample
dynamically generated code" suggestions simply expanded comments for now.

The profiler program is now a Cygwin exe rather than a native exe.
2021-07-19 13:28:37 +01:00
Jon Turney 9a231073a5
Cygwin: Define PSAPI_VERSION as 1 before including psapi.h
The default PSAPI_VERSION is controlled by WIN32_WINNT, which we set to
0x0a00 when building utils since 48a76190 (and is the default in w32api
>= 9.0.0)

In order for the built executables to run on Windows Vista, we must also
define PSAPI_VERSION as 1 (otherwise '#define GetModuleFileNameExA
K32GetModuleFileNameExA' causes a 'The procedure entry point
K32GetModuleFilenameExA could not be located in the dynamic link library
kernel32.dll' error at run time).

Also drop uneeded psapi.h from dlfcn.cc (31ddf45d), resource.cc
(34a6eeab) and ps.cc (1def2148).
2021-07-09 13:24:08 +01:00
Corinna Vinschen fd84f6cf51 Cygwin: utils: enable -idirafter to fetch Cygwin headers from mingw sources
Get rid of the last dreaded relative paths pointing to the cygwin dir.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-26 11:01:32 +02:00
Corinna Vinschen 48a76190e8 Cygwin: utils: set _WIN32_WINNT and NTDDI_VERSION via Makefile
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-26 11:01:32 +02:00
Jon Turney a9c8050c36
Cygwin: Ensure PSAPI_VERSION is 1 when building ldd
The default PSAPI_VERSION is controlled by WIN32_WINNT, which we set to
0x0a00 when building ldd, which gets PSAPI_VERSION=2.

This causes K32GetModuleFileNameEx to be used for GetModuleFileNameEx,
which isn't available on Windows Vista.

Define PSAPI_VERSION as 1 for the built executable to work on Windows
Vista.
2021-05-22 16:06:51 +01:00
Christian Franke c0949782b7 Cygwin: utils: chattr: Allow to clear all attributes with '='.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2021-05-21 12:56:59 +02:00
Corinna Vinschen 6462a0844d Cygwin: utils: ldd: use GetFinalPathNameByHandleW
drop replacement function GetFileNameFromHandle which was
only required pre-Vista.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-20 23:07:05 +02:00
Corinna Vinschen 8c6c9b097d Cygwin: utils: avoid warning when building path_testsuite-path.o
Avoid this warning:

[...]/winsup/utils/mingw/../path.cc:569:1: warning: 'void read_mounts() ' defined but not used [-Wunused-function]
  569 | read_mounts ()
      | ^~~~~~~~~~~

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-20 22:47:44 +02:00
Corinna Vinschen 3053632389 Cygwin: utils: chattr: do not default to CWD
Drop the unexpected behaviour to run chattr in the CWD if no file has
been specified on the command line.  Bail out with usage info instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-20 22:39:25 +02:00
Corinna Vinschen f8eecf22db Cygwin: utils: chattr: fix recursive behaviour
chattr [mode] dir

incorrectly recurses one level into the given directory, even if the
--recursive option has not been used.  This patch adds a test to avoid
this bug.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-20 22:32:37 +02:00
Christian Franke cb674a4ad1 Cygwin: utils: chattr: Improve option parsing, fix some messages.
Allow multiple characters also in first '-mode' argument.
Use '-H' instead of '-h' for '--help' to fix ambiguity with
hidden attribute.  Fix help and usage texts and documentation.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2021-05-20 22:29:58 +02:00
Jon Turney 71e8b45007
Get rid of relative include paths in strace.cc 2021-05-10 14:41:41 +01:00
Jon Turney b8bd9d1b01
Move source files used in utils/mingw/ into that subdirectory
Move all the source files used in utils/mingw/ into that subdirectory,
so the built objects are in the expected place.

(path.cc requires some more unpicking, and even then there is genuinely
some shared code, so use a trivial file which includes the real path.cc
so the object file is generated where expected)
2021-05-10 14:41:40 +01:00
Jon Turney 9ce70bf450
Unpick cygpath TESTSUITE
Rather than having testsuite.h do various things, depending on defines,
just have it do one thing, and then explicitly redirect to test stubs in
path.cc when building test.
2021-05-10 14:41:39 +01:00
Corinna Vinschen cf25b55902 Cygwin: automake: change @INCLUDES@ to @AM_CPPFLAGS@ to avoid warnings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 11:28:14 +02:00