summaryrefslogtreecommitdiff
path: root/boost/stacktrace/detail/location_from_symbol.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/stacktrace/detail/location_from_symbol.hpp')
-rw-r--r--boost/stacktrace/detail/location_from_symbol.hpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/boost/stacktrace/detail/location_from_symbol.hpp b/boost/stacktrace/detail/location_from_symbol.hpp
index d20b0d6707..ed82ef50b6 100644
--- a/boost/stacktrace/detail/location_from_symbol.hpp
+++ b/boost/stacktrace/detail/location_from_symbol.hpp
@@ -20,8 +20,8 @@
namespace boost { namespace stacktrace { namespace detail {
-class location_from_symbol {
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+class location_from_symbol {
::Dl_info dli_;
public:
@@ -40,9 +40,19 @@ public:
const char* name() const BOOST_NOEXCEPT {
return dli_.dli_fname;
}
+};
+
+class program_location {
+public:
+ const char* name() const BOOST_NOEXCEPT {
+ return 0;
+ }
+};
+
#else
- BOOST_STATIC_CONSTEXPR boost::detail::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
+class location_from_symbol {
+ BOOST_STATIC_CONSTEXPR boost::detail::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
char file_name_[DEFAULT_PATH_SIZE_];
public:
@@ -68,9 +78,28 @@ public:
const char* name() const BOOST_NOEXCEPT {
return file_name_;
}
-#endif
};
+class program_location {
+ BOOST_STATIC_CONSTEXPR boost::detail::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
+ char file_name_[DEFAULT_PATH_SIZE_];
+
+public:
+ program_location() BOOST_NOEXCEPT {
+ file_name_[0] = '\0';
+
+ const boost::detail::winapi::HMODULE_ handle = 0;
+ if (!boost::detail::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) {
+ file_name_[0] = '\0';
+ }
+ }
+
+ const char* name() const BOOST_NOEXCEPT {
+ return file_name_[0] ? file_name_ : 0;
+ }
+};
+#endif
+
}}} // namespace boost::stacktrace::detail
#endif // BOOST_STACKTRACE_DETAIL_LOCATION_FROM_SYMBOL_HPP