Commit Graph

26 Commits

Author SHA1 Message Date
João Valverde 9cb759b38e Enable rpathification and working relocation on Linux (take 3)
Dumpcap depends on wsutil.so. The path to the shared library
is encoded in the RPATH (or RUNPATH) property of ELF binaries.
This is currently an absolute path on most Unixy systems.

Dumpcap could not be made to work with a relative RPATH because it
uses elevated privileges and some loaders will ignore relative
RPATHs and non-standard paths under those circumstances, because of
(justified) security concerns.

To enable relocation of the program we link dumpcap statically
with wsutil instead.

This provides a fully working relocatable installation on Linux
and other platforms that support relative RPATHs.
2023-02-13 00:24:21 +00:00
João Valverde c62aa67d2c Move ui/exit_codes.h to include/ 2023-02-07 10:12:08 +00:00
João Valverde d09460283b MinGW: Fix -Wattributes 2023-01-13 22:41:04 +00:00
Philipp Dittmann 9c68879a27 Windows: Fix Release (unused variables)
- ws_assert does not work, because _ASSERT_ENABLED is false and gets optimized
- add _U_ to unused variables because of compile flag /W3
- local variables need suppression of warning 4189
2023-01-11 17:50:42 +00:00
João Valverde 90084d8269 Add Wunused-parameter to DIAG_OFF_FLEX() 2023-01-04 15:50:07 +00:00
João Valverde b577b8a37f Add WS_WARN_UNUSED function attribute 2022-12-29 18:28:54 +00:00
João Valverde 79c3a77752 Add macros to control lemon diagnostics
Rename flex macros using parenthesis (mostly a style issue):

DIAG_OFF_FLEX -> DIAG_OFF_FLEX()
DIAG_ON_FLEX  -> DIAG_ON_FLEX()

Use the same kind of construct with lemon generated code using
DIAG_OFF_LEMON() and DIAG_ON_LEMON(). Use %include and %code
directives to enforce the desired order with generated code
in the middle in between pragmas.

Fix a clang-specific pragma to use DIAG_OFF_CLANG().

DIAG_OFF(unreachable-code) -> DIAG_OFF_CLANG(unreachable-code).

Apparently GCC is ignoring the -Wunreachable flag, that's why
it did not trigger an unknown pragma warning. From [1}:

  The -Wunreachable-code has been removed, because it was unstable: it
  relied on the optimizer, and so different versions of gcc would warn
  about different code.  The compiler still accepts and ignores the
  command line option so that existing Makefiles are not broken.  In some
  future release the option will be removed entirely. - Ian

[1] https://gcc.gnu.org/legacy-ml/gcc-help/2011-05/msg00360.html
2022-11-20 10:11:27 +00:00
João Valverde 90fb3ff438 Disable a compiler warning for Flex generated code
The flex+clang combination in the macOS Intel builder generates
-Wdocumentation warnings. Silence those warnings.
2022-11-17 17:36:32 +00:00
Guy Harris 1c9c1b5100 Add a #define for REPLACEMENT CHARACTER and use it.
Add UNICODE_REPLACEMENT_CHARACTER as a #define for the Unicode
REPLACEMENT CHARACTER code point (0x00FFFD), and use that instead of
0xfffd/0xFFFD/0x00FFFD in cases where that value refers to REPLACEMENT
CHARACTER.
2022-10-16 23:36:12 +00:00
João Valverde a19834b98c Windows: Store "gui.console_open" in the Windows registry
This removes the last dependency of the logging subsystem on the
preferences module. The latter is started much later than the former
and this is an issue.

The Windows-only preference "gui.console_open" is stored in the
registry as HKEY_LOCAL_USER\Software\Wireshark\ConsoleOpen. The semantics
are exactly the same. The preference is read by the logging subsystem
for initialization and then again by the preferences (read/write) so
the user can configure it as before.

The code to store the preference also in the preferences file was
kept, for backward compatibility and because it is not incompatible
with using the Registry concurrently.

The elimination of the prefs dependency also allows moving the Windows
console logic to wsutil and add the functionality to wslog directly,
thereby eliminating the superfluous Wireshark/Logray custom log handler.

To be able to read the ws_log_console_open global variable from
libwireshark it becomes necessary to add a new export macro
symbol called WSUTIL_EXPORT.
2022-10-11 14:25:04 +01:00
João Valverde 1b12dc4b9e Add WS_DEPRECATED_X() function attribute
This adds a new attribute that allows declaring Wireshark
functions as deprecated.

Also disabe -Werror with deprecated declarations  Deprecated
declarations can be introduced suddenly with a new version
of an external dependency or a new internal deprecation and
that has its own timeline to fix. We should still be able to
build with -Werror in that case.
2022-10-10 20:27:33 +00:00
João Valverde f6de88707c Add DIAG_WARN() diagnostic macros
This enable the warning at "warning" level (neither ignored nor
an error). This is used to selectively disable -Werror for a section
of code but keep the warning enabled as useful and relevant.

For example it can be used to defer replacing deprecated declarations
and still build with -Werror enabled globally.
2022-10-04 17:35:55 +00:00
João Valverde 32befe119d Add a log domain for encoding errors and lower the log level
Using a warning is probably too exalted for the current state
of the code, where UTF-8 errors are somewhat expected from
dissectors that are lax about input validation.

Use a debug level with its own "UTF-8" domain instead.

Using a dedicated domain allows to filter on encoding errors and
with some enhancements to the logging subsystem make them fatal
for tracking and debugging purposes.

Using a dedicated domain might have other drawbacks but for now
it seems like the best approach.
2022-09-28 14:57:51 +01:00
Guy Harris db27fb777a exceptions: make the exception handler stack per-thread.
This prevents the weird failures I saw on macOS in #17856; instead, it
should fail on *all* platforms with

    Unhandled exception ("epan/proto.c:8800: failed assertion "DISSECTOR_ASSERT_NOT_REACHED"", group=1, code=6)

(which it does on macOS 11.6/Xcode 12.5.1 and Windows 10/VS 2019
16.11.8; according to

https://en.wikipedia.org/w/index.php?title=Thread-local_storage&oldid=1064900318#C_and_C++

the major UN*X C compilers support __thread and the major Windows C
compilers support __declspec(thread).).

@jvalverde: on branches that require C11/C++11 support, we could perhaps
just use _Thread_local for C and thread_local for C++.  Note that
<thread.h> is optional in C11, and macOS 11.6/Xcode 12.5.1 does not
appear to include it.)

This does not *fix* the aforementioned issue; to do *that* we need to do
TRY in the register-dissectors thread code.  I'm committing this
separately because it fixes a bug in our exception package that could
cause all sorts of randomness now and in the future - what we're doing
now is Just Wrong.

(Yes, there's code to support per-thread exception handler stacks *on
platforms with pthreads*, but this is simpler *and* also works on
Windows.)
2022-01-11 05:00:42 +00:00
João Valverde 60533a55ff wslog: Add WS_DEBUG_HERE() macro
Add a LOG_LEVEL_ECHO that is always active and always non-fatal.

Use that to implement a WS_DEBUG_HERE() macro for quick print outs
during debugging sessions.
2021-12-29 15:21:46 +00:00
João Valverde 9a52634c5f Add ws_version.h to wireshark.h 2021-12-21 23:00:04 +00:00
João Valverde 4448b6494e Add a ws_posix_compat.h header
Currently used to define ssize_t on platforms that lack it.

Fix some Windows build errors caused by moving the definition into a
separate header.

Fix some narrowing warnings on Windows x64 from changing the definition
of ssize_t from long int to int64_t.

The casts in dumpcap are ugly but necessary. The whole code needs
to be rewritten for portability, or the warnings disabled.
2021-12-21 01:30:06 +00:00
João Valverde 64c0e166d1 Add string.h to wireshark.h
Wireshark development requires handling strings a lot. Add this
standard header to the base environment to avoid unnecessary repetition.
2021-12-18 20:28:54 +00:00
João Valverde f19c18a299 Add wmem.h to wireshark.h
Wmem is an alternative to GLib data structures so it should
have the same scope and be equally as convenient to use.

Wmem does not and cannot depend on anything else other than
GLib.
2021-12-18 20:28:54 +00:00
João Valverde d443197097 Prefer the portable _Noreturn attribute (C11)
Use _Noreturn, available with C11, instead of vendor specific
attributes. It's not compatible with C++ so we we must keep
the old code for now.
2021-12-18 18:54:08 +00:00
João Valverde 64e8a2817e Add wsutil/glib-compat.h to wireshark.h
We are already adding glib.h, we should include glib-compat.h
as well in the base environment.
2021-12-17 19:34:54 +00:00
João Valverde 689976477a Add inttypes.h to wireshark.h
For convenience, having to add this header constantly is annoying
and kind of pointless, now that we are relying more on stdio.h.
2021-12-17 19:34:54 +00:00
João Valverde cef5e81146 Define more log domains for extcaps 2021-12-05 00:28:26 +00:00
Moshe Kaplan 1c3a9af869 Add files with WS_DLL_PUBLIC to Doxygen
Add @file markers for most files that
contain functions exported with
WS_DLL_PUBLIC so that Doxygen will
generate documentation for them.
2021-11-29 21:27:45 +00:00
João Valverde 9bdccce574 More workarounds for Debian 2021-11-14 21:00:59 +00:00
João Valverde ca06d7e4fe Add an include sub-directory to the tree
Blind attempt to fix Debian package brokenness managing
headers separately from install rules.

Global public headers that don't fit any of the Wireshark
libraries should be placed in include/.

Eventually the C files in the root dir should be placed somewhere
else as well (like src/) but this is not a priority.

Fixes #17726.
2021-11-12 17:33:13 +00:00