-if not get_option('disable_libunwind')
- unwind_dep = dependency('libunwind', required : false)
- dw_dep = dependency('libdw', required: false)
- backtrace_deps = [unwind_dep, dw_dep]
- if unwind_dep.found()
- cdata.set('HAVE_UNWIND', 1)
- if dw_dep.found()
- cdata.set('HAVE_DW', 1)
- else
- message('Support for backtraces is partial only.')
- endif
+unwind_dep = dependency('libunwind', required : get_option('libunwind'))
+dw_dep = dependency('libdw', required: get_option('libdw'))
+dbghelp_option = get_option('dbghelp')
+if dbghelp_option.enabled() and building_for_uwp
+ error('DbgHelp is not supported for UWP')
+endif
+have_dbghelp = cc.has_header('dbghelp.h', required: dbghelp_option) and cc.has_header('tlhelp32.h', required: dbghelp_option)
+backtrace_deps = [unwind_dep, dw_dep]
+backtrace_source_info = false
+backtrace_minimal = false
+# MSVC debug stack trace support
+if host_system == 'windows' and have_dbghelp and not building_for_uwp
+ cdata.set('HAVE_DBGHELP', 1)
+ backtrace_source_info = true
+# DWARF stack trace support with libunwind and elf-utils
+elif unwind_dep.found()
+ cdata.set('HAVE_UNWIND', 1)
+ if dw_dep.found()
+ cdata.set('HAVE_DW', 1)
+ backtrace_source_info = true
+ endif
+ backtrace_minimal = true
+# Basic backtrace() stack trace support
+elif cc.has_function('backtrace')
+ cdata.set('HAVE_BACKTRACE', 1)
+ backtrace_minimal = true
+endif
+# Print messages about what was enabled
+if not backtrace_source_info
+ if not backtrace_minimal
+ message('NO support for stack traces.')