Commit Graph

134 Commits

Author SHA1 Message Date
Marc-André Lureau
bff76bc36f gmessages: make _g_log_abort() do only breakpoints again
Commit e53caad4 makes _g_log_abort() noreturn by calling abort()
unconditionally.

However, it is useful to be able to skip some log_abort() with a
debugger, to reach a point of interest. Revert back to previous
behaviour. Make g_assert_warning() noreturn by calling abort().

https://bugzilla.gnome.org/show_bug.cgi?id=711800
2013-12-03 15:56:47 +01:00
Dan Winship
e53caad4f1 Fix a warning about _g_log_abort()
G_BREAKPOINT is not noreturn, so make it so that we abort() if it
returns, to make _g_log_abort() be properly noreturn again.
2013-11-27 10:57:43 -05:00
Dan Winship
695070b52e Fix the gtestutils core dump prevention again
The previous patch was preventing core dumps on failed assertions, but
not on g_error()s.
2013-11-27 10:42:32 -05:00
Dan Winship
3d70db0750 Reorganize the "don't dump core from test subprocesses" code.
g_test_init() was calling _g_messages_set_exit_on_fatal() from
subprocesses, to make fatal log messages call _exit() rather than
abort(), but the function name is sort of confusing, and we don't
really need it anyway, since g_log() can just call g_test_subprocess()
instead and decide for itself.

Likewise, update g_assertion_message() to do the check itself, rather
than calling into gmessages to do it, and fix
g_assertion_message_expr() to also check whether it should exit or
abort. (Previously it always called abort(), although this didn't
actually matter since that was dead code until
test_nonfatal_assertions was added.)

https://bugzilla.gnome.org/show_bug.cgi?id=711800
2013-11-24 15:14:13 -05:00
Dan Winship
158dde0507 Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.

Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:25:39 -05:00
Stef Walter
36f1a4ce7e gmessages: Add g_info macro for G_LOG_LEVEL_INFO
For completeness. Although less used than others, projects want
to use this, and end up having to define it awkwardly themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=711103
2013-11-19 08:08:14 +01:00
Stef Walter
44f13124c9 test: g_debug messages shouldn't affect g_assert_expected_messages
Debug messages are meant to give insight into how a process is
proceeding, and are unpredictable in nature. They also often have
line numbers in them.

This patch ignores debug messages in g_test_assert_expected_messages().

https://bugzilla.gnome.org/show_bug.cgi?id=710991
2013-10-28 21:31:34 +01:00
Ryan Lortie
8dfb070329 Don't g_test_assert_expected_messages for g_error
Don't allow the user to assert for expected g_error().  They need to use
subprocess for this.

https://bugzilla.gnome.org/show_bug.cgi?id=709615
2013-10-21 14:33:06 -04:00
Philip Withnall
1b04954cd0 gmessages: Clarify new-line behaviour of message functions
Mention that g_printerr() and friends don’t append a trailing new-line
character to printed messages, but g_log() and friends do.
2013-10-21 15:30:47 +01:00
Dan Winship
f8bb08305c gmessages: fix g_test_expect_message() with NULL domains
Allow passing a NULL domain to g_test_expect_message(), and more
importantly, don't crash if a message with a NULL domain gets logged
while there is an expected message.
2013-08-31 11:51:07 -04:00
Dan Winship
4b94c0831e Use 'dumb quotes' rather than `really dumb quotes'
Back in the far-off twentieth century, it was normal on unix
workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
APOSTROPHE to be drawn as "’". This led to the convention of using
them as poor-man's ‛smart quotes’ in ASCII-only text.

However, "'" is now universally drawn as a vertical line, and "`" at a
45-degree angle, making them an `odd couple' when used together.

Unfortunately, there are lots of very old strings in glib, and also
lots of new strings in which people have kept up the old tradition,
perhaps entirely unaware that it used to not look stupid.

Fix this by just using 'dumb quotes' everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=700746
2013-05-21 11:23:22 -03:00
Colin Walters
f2a9a6142c gmessages: Fix up testing commit to handle fatal masquerading
This makes glib/tests/testing pass again.
2013-05-21 00:07:18 +01:00
Colin Walters
714cbbea52 gtestutils: Ensure test subprocesses don't dump core
Since we expect them to crash, let's not spam the system
core dump collection (systemd, abrt).  At the moment
systemd is not very robust against programs crashing
in loops.

Instead of aborting, we exit(1).

https://bugzilla.gnome.org/show_bug.cgi?id=700714
2013-05-20 19:07:55 +01:00
Dan Winship
960f5500e2 gtestutils: add g_test_trap_subprocess()
g_test_trap_fork() doesn't work on Windows and is potentially flaky on
unix anyway given the fork-but-don't-exec. Replace it with
g_test_trap_subprocess(), which re-spawns the same program with
arguments telling it to run a specific (otherwise-ignored) test case.

Make the existing g_test_trap_fork() unit tests be unix-only (they
never passed on Windows anyway), and add a parallel set of
g_test_trap_subprocess() tests.

Also fix the logic of gtestutils's "-p" argument (which is used by the
subprocess tests); previously if you had tests "/foo/bar" and
"/foo/bar/baz", and ran the test program with "-p /foo/bar/baz", it
would run "/foo/bar" too. Fix that and add tests.

https://bugzilla.gnome.org/show_bug.cgi?id=679683
2013-05-13 12:10:52 -04:00
Colin Walters
090f874626 Handle EINTR for a few more write() calls
https://bugzilla.gnome.org/show_bug.cgi?id=682819
2013-01-25 11:23:48 -05:00
Matthias Clasen
08dce819cc Revert "gtestutils: add g_test_trap_subprocess(), deprecate g_test_trap_fork()"
This reverts commit e3a29184d5.
2012-12-19 15:20:45 -05:00
Dan Winship
e3a29184d5 gtestutils: add g_test_trap_subprocess(), deprecate g_test_trap_fork()
g_test_trap_fork() doesn't work on Windows and is potentially flaky on
unix anyway given the fork-but-don't-exec. Replace it with
g_test_trap_subprocess(), which re-spawns the same program with
arguments telling it to run a specific (otherwise-ignored) test case.

Make the existing g_test_trap_fork() unit tests be unix-only (they
never passed on Windows anyway), and add a parallel set of
g_test_trap_subprocess() tests.

https://bugzilla.gnome.org/show_bug.cgi?id=679683
2012-12-19 14:35:08 -05:00
Dan Winship
e97a2f4195 win32: suppress fatal error dialog box when running tests
When running a test program (ie, if g_test_init() has been called),
don't pop up a dialog box when a fatal error occurs. Just print the
message to stderr and exit.

https://bugzilla.gnome.org/show_bug.cgi?id=679683
2012-12-05 11:15:19 -05:00
Dan Winship
b55e1820a9 g_test_expect_message: fix pattern syntax in example code 2012-11-26 10:47:34 -05:00
Aleksander Morgado
0d22609fe9 gmessages: fix minor typo in documentation 2012-10-30 13:15:23 +01:00
Ryan Lortie
d06c7a911e g_test_expect_message: add some g_return_if_fail
NULL domain is not supported and some might expect this to work, so make
sure they don't get the wrong idea...
2012-08-20 16:26:25 -04:00
Dan Winship
25ac137c0a gtestutils: add g_text_expect_message()
Add g_test_expect_message() and g_test_assert_expected_messages(), to
allow tests of warnings, error messages, return-if-fails, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=679556
2012-08-20 13:54:52 -04:00
Dan Winship
78a8aecbb3 g_logv: only expand the message once
Hoist the g_strdup_printf()'ing out of the loop, since the message is
the same for every handler that gets called.

https://bugzilla.gnome.org/show_bug.cgi?id=679556
2012-08-20 13:49:06 -04:00
Robert Ancell
4143842eb4 Add missing allow-none annotations for function parameters.
Found using:
find . -name '*.c' | xargs grep 'or %NULL' | grep ' \* @' | grep -v '@error' | grep -v allow-none
2012-03-31 20:34:28 +11:00
Ryan Lortie
fbbdf98668 g_log: mask log level before checking prefix flags
We check if the log level is in the "prefixed" list by checking it
against the g_log_msg_prefix bitfield.

Unfortunately we were failing to mask by G_LOG_LEVEL_MASK first, so if
the FATAL bit was set (for example) then it would never match.  This was
the case for g_error().

https://bugzilla.gnome.org/show_bug.cgi?id=672026
2012-03-13 20:15:21 -04:00
Stef Walter
7e92997539 documentation fixes
Fixes for gtk-doc warnings.

http://bugzilla.gnome.org/show_bug.cgi?id=66469

https://bugzilla.gnome.org/show_bug.cgi?id=664699
2011-12-13 23:01:51 -05:00
Matthias Clasen
1a08591c3a Deal gracefully with NULL log domains 2011-11-16 21:42:28 -05:00
Matthias Clasen
d2d62ecfcd Make the default log handler more useful
We make the default log handler only print default and informational
messages if the log domain is explicitly requested.

https://bugzilla.gnome.org/show_bug.cgi?id=661926
2011-11-03 01:50:29 -04:00
Ryan Lortie
2a98cc635e The usual docs unbreaking... 2011-10-19 15:07:22 -04:00
Matthias Clasen
6c1d768f7b Also clean up includes 2011-10-16 18:43:22 -04:00
Matthias Clasen
6ab1c77270 Pass correct data to fatal log handlers
This was pointed out by John Ralls in bug 653052.
He also provided the test case.
2011-10-16 16:24:20 -04:00
Matthias Clasen
6613b2f8fd Move more docs inline 2011-10-12 22:29:53 -04:00
Ryan Lortie
2e5cb6f522 win32 fixes from g_thread_init() deprecation
I can't even begin to imagine how these fell through the cracks...
2011-10-04 15:44:48 -04:00
Ryan Lortie
47444dacc0 Deprecate g_thread_init()
Move the last few things that needed thread-safe initialisation to a
global ctor.

https://bugzilla.gnome.org/show_bug.cgi?id=660744
2011-10-04 15:31:49 -04:00
Ryan Lortie
310c3ed4cc Clean up process of calling g_debug_init()
Make sure that it calls absolutely nothing that may ever recurse back
into GLib again:

  - g_ascii_strcasecmp() is unsafe because it has g_return_if_fail() at
    the top.  As far as I know, the only ASCII character letter that
    would get special treatment here is "i" and that appears in neither
    "help" nor "all".

  - g_getenv() is very complicated on Windows, so use a simple version
    that is sufficient for our purposes.

Now that it's completely safe, we can just call it from g_logv() in the
usual way without all of the hacks.

https://bugzilla.gnome.org/show_bug.cgi?id=660744
2011-10-04 15:31:49 -04:00
Ryan Lortie
2a677d1370 locks: drop _INIT macros
All locks are now zero-initialised, so we can drop the G_*_INIT macros
for them.

Adjust various users around GLib accordingly and change the docs.

https://bugzilla.gnome.org/show_bug.cgi?id=659866
2011-10-02 22:33:10 -04:00
Ryan Lortie
8e43470c38 Stop dithering over GPrivate
Take out the half-private g_private_init() stuff and replace it with a
G_PRIVATE_INIT macro that allows specifying a GDestroyNotify.

Expose the GPrivate structure in a public header.

Add a g_private_replace() to (sort of) match the functionality of
g_static_mutex_set().

Improve the documentation.

Deprecate g_private_new().
2011-10-02 20:04:03 -04:00
Matthias Clasen
ed325b1879 One forgotten moved doc 2011-10-01 23:38:52 -04:00
Ryan Lortie
4596dfbc75 gmessages: do implicit GPrivate initialisation
Initialise the GPrivate implicitly at the site of first use rather than
explicitly from the thread initialisation function.
2011-09-21 16:06:53 -04:00
Ryan Lortie
90679997ec Continue GPrivate rework
We remove the macros while at the same time switching all libglib users
from g_private_new() to g_private_init().  We deal with the strange
expectations of the libglib code that g_private_* should work before the
GPrivate has been initialised with a temporary shim.
2011-09-21 16:06:53 -04:00
Ryan Lortie
2c7388c19a libglib: stop using g_mutex_new
Use G_MUTEX_INIT or g_mutex_init() as appropriate.
2011-09-21 15:55:36 -04:00
Ryan Lortie
43254e8c4c gmessage.c: mark a private function static 2011-09-21 15:27:47 -04:00
Ryan Lortie
8b03fed0cf Remove unused header gdebug.h
This was only included from gmessages.c.  Nuke the unused parts and
merge the rest into gmessages.c.
2011-09-18 22:08:05 -04:00
Ryan Lortie
5dbc12e9f1 Replace @Varargs with @...
to make gtk-doc happy.
2011-07-22 15:47:24 +02:00
Matthias Clasen
4c64e75ec5 Drop the warnings.sgml template 2011-07-19 20:40:28 -04:00
Colin Walters
a04efe6afb Use SIGTRAP (via G_BREAKPOINT()) if G_DEBUG=fatal-warnings
On Linux with gdb, it's much more convenient to debug programs using
G_DEBUG=fatal-warnings if we send SIGTRAP instead of abort() by
default.  The default handler for both is to terminate the process.

In particular this makes it more easily possible to debug a warning
that's not the first in a program; you can skip past it and
go to the warning you care about.

The "aborting..." message is removed since it's no longer accurate,
and anyways was never very useful; crashes should show up in ABRT/apport
type crash catching systems.

https://bugzilla.gnome.org/show_bug.cgi?id=648423
2011-04-28 14:48:48 -04:00
Murray Cumming
30fdc1a799 Docs: Changed can not to cannot. 2011-03-24 09:33:55 +01:00
Matthias Clasen
4368a07e02 Avoid more compiler warnings 2011-02-08 07:41:49 -05:00
Chun-wei Fan
9806040455 Added and Moved checks for includes
Moved checks for G_OS_WIN32 after GLib header includes and added other checks
required for Windows/MSVC builds
2010-11-09 09:53:12 +08:00
Matthias Clasen
5681809448 Remove excessive header inclusions 2010-09-03 20:51:08 -04:00