diff options
author | Pedro Alves <palves@redhat.com> | 2010-03-16 17:47:52 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2010-03-16 17:47:52 +0000 |
commit | e92d13d5bcf6a7d365fcbaae5af81ad80648fe8f (patch) | |
tree | 71ac9c810f41ac867f425f508ee10f7be9061305 /gdb/gdbserver/server.h | |
parent | 46956e396d10846a7ab0374a71bb1204bdd4d0d5 (diff) | |
download | gdb-e92d13d5bcf6a7d365fcbaae5af81ad80648fe8f.zip gdb-e92d13d5bcf6a7d365fcbaae5af81ad80648fe8f.tar.gz gdb-e92d13d5bcf6a7d365fcbaae5af81ad80648fe8f.tar.bz2 |
gdb/gdbserver/
* server.h (internal_error): Declare.
(gdb_assert, ASSERT_FUNCTION, gdb_assert_fail): Define.
* utils.c (internal_error): New function.
Diffstat (limited to 'gdb/gdbserver/server.h')
-rw-r--r-- | gdb/gdbserver/server.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index f46ee60..1823295 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -407,9 +407,39 @@ void freeargv (char **argv); void perror_with_name (const char *string); void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); void fatal (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); +void internal_error (const char *file, int line, const char *, ...) + ATTR_NORETURN ATTR_FORMAT (printf, 3, 4); void warning (const char *string,...) ATTR_FORMAT (printf, 1, 2); char *paddress (CORE_ADDR addr); +#define gdb_assert(expr) \ + ((void) ((expr) ? 0 : \ + (gdb_assert_fail (#expr, __FILE__, __LINE__, ASSERT_FUNCTION), 0))) + +/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' + which contains the name of the function currently being defined. + This is broken in G++ before version 2.6. + C9x has a similar variable called __func__, but prefer the GCC one since + it demangles C++ function names. */ +#if (GCC_VERSION >= 2004) +#define ASSERT_FUNCTION __PRETTY_FUNCTION__ +#else +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#define ASSERT_FUNCTION __func__ +#endif +#endif + +/* This prints an "Assertion failed" message, and exits. */ +#if defined (ASSERT_FUNCTION) +#define gdb_assert_fail(assertion, file, line, function) \ + internal_error (file, line, "%s: Assertion `%s' failed.", \ + function, assertion) +#else +#define gdb_assert_fail(assertion, file, line, function) \ + internal_error (file, line, "Assertion `%s' failed.", \ + assertion) +#endif + /* Maximum number of bytes to read/write at once. The value here is chosen to fill up a packet (the headers account for the 32). */ #define MAXBUFBYTES(N) (((N)-32)/2) |