summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-11-08 15:44:20 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-11-08 15:44:20 -0300
commit71a8a4f6e36547bb060dbcc961ea9b57420f7190 (patch)
tree3abd0dc46c18cc7400933fb2ef3f19d3e8f3f28a /src/include
parent3dcffb381c81c9c8f8254100feacac256b9e75a6 (diff)
Add backtrace support for error reporting
Add some support for automatically showing backtraces in certain error situations in the server. Backtraces are shown on assertion failure; also, a new setting backtrace_functions can be set to a list of C function names, and all ereport()s and elog()s from the mentioned functions will have backtraces generated. Finally, the function errbacktrace() can be manually added to an ereport() call to generate a backtrace for that call. Authors: Peter Eisentraut, Álvaro Herrera Discussion: https://postgr.es/m//5f48cb47-bf1e-05b6-7aae-3bf2cd01586d@2ndquadrant.com Discussion: https://postgr.es/m/CAMsr+YGL+yfWE=JvbUbnpWtrRZNey7hJ07+zT4bYJdVp4Szdrg@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/pg_config.h.in6
-rw-r--r--src/include/utils/elog.h3
-rw-r--r--src/include/utils/guc.h2
3 files changed, 11 insertions, 0 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 2bf506033df..a56161cf289 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -96,6 +96,9 @@
/* Define to 1 if you have the <atomic.h> header file. */
#undef HAVE_ATOMIC_H
+/* Define to 1 if you have the `backtrace_symbols' function. */
+#undef HAVE_BACKTRACE_SYMBOLS
+
/* Define to 1 if you have the `BIO_get_data' function. */
#undef HAVE_BIO_GET_DATA
@@ -198,6 +201,9 @@
/* Define to 1 if you have the `explicit_bzero' function. */
#undef HAVE_EXPLICIT_BZERO
+/* Define to 1 if you have the <execinfo.h> header file. */
+#undef HAVE_EXECINFO_H
+
/* Define to 1 if you have the `fdatasync' function. */
#undef HAVE_FDATASYNC
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 47412a831f0..9ab4b5470b7 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -189,6 +189,8 @@ extern int errcontext_msg(const char *fmt,...) pg_attribute_printf(1, 2);
extern int errhidestmt(bool hide_stmt);
extern int errhidecontext(bool hide_ctx);
+extern int errbacktrace(void);
+
extern int errfunction(const char *funcname);
extern int errposition(int cursorpos);
@@ -392,6 +394,7 @@ typedef struct ErrorData
char *detail_log; /* detail error message for server log only */
char *hint; /* hint message */
char *context; /* context message */
+ char *backtrace; /* backtrace */
const char *message_id; /* primary message's id (original string) */
char *schema_name; /* name of schema */
char *table_name; /* name of table */
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 9aa3d025965..50098e63fea 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -256,6 +256,8 @@ extern int log_min_duration_statement;
extern int log_temp_files;
extern double log_statement_sample_rate;
extern double log_xact_sample_rate;
+extern char *backtrace_functions;
+extern char *backtrace_symbol_list;
extern int temp_file_limit;