[PATCH] D16797: Update clang support on recent Haiku

2016-02-01 Thread Jérôme Duval via cfe-commits
korli created this revision.
korli added a reviewer: rsmith.
korli added a subscriber: cfe-commits.
korli set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

[ Copied from [[ https://llvm.org/bugs/show_bug.cgi?id=26404 | 
https://llvm.org/bugs/show_bug.cgi?id=26404 ]] ]

clang support on Haiku is lagging a bit, and missing on x86_64.

This patch updates support for x86 and add support for x86_64. It should apply 
directly to trunk and it's harmless in the sense that it only affects Haiku.

Please consider reviewing.

Repository:
  rL LLVM

http://reviews.llvm.org/D16797

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Frontend/InitHeaderSearch.cpp

Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -267,38 +267,39 @@
   }
 
   case llvm::Triple::Haiku:
-AddPath("/boot/common/include", System, false);
-AddPath("/boot/develop/headers/os", System, false);
-AddPath("/boot/develop/headers/os/app", System, false);
-AddPath("/boot/develop/headers/os/arch", System, false);
-AddPath("/boot/develop/headers/os/device", System, false);
-AddPath("/boot/develop/headers/os/drivers", System, false);
-AddPath("/boot/develop/headers/os/game", System, false);
-AddPath("/boot/develop/headers/os/interface", System, false);
-AddPath("/boot/develop/headers/os/kernel", System, false);
-AddPath("/boot/develop/headers/os/locale", System, false);
-AddPath("/boot/develop/headers/os/mail", System, false);
-AddPath("/boot/develop/headers/os/media", System, false);
-AddPath("/boot/develop/headers/os/midi", System, false);
-AddPath("/boot/develop/headers/os/midi2", System, false);
-AddPath("/boot/develop/headers/os/net", System, false);
-AddPath("/boot/develop/headers/os/storage", System, false);
-AddPath("/boot/develop/headers/os/support", System, false);
-AddPath("/boot/develop/headers/os/translation", System, false);
-AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/develop/headers/cpp", System, false);
-AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
-AddPath("/boot/develop/headers/3rdparty", System, false);
-AddPath("/boot/develop/headers/bsd", System, false);
-AddPath("/boot/develop/headers/glibc", System, false);
-AddPath("/boot/develop/headers/posix", System, false);
-AddPath("/boot/develop/headers",  System, false);
+AddPath("/boot/system/non-packaged/develop/headers", System, false);
+AddPath("/boot/system/develop/headers/os", System, false);
+AddPath("/boot/system/develop/headers/os/app", System, false);
+AddPath("/boot/system/develop/headers/os/arch", System, false);
+AddPath("/boot/system/develop/headers/os/device", System, false);
+AddPath("/boot/system/develop/headers/os/drivers", System, false);
+AddPath("/boot/system/develop/headers/os/game", System, false);
+AddPath("/boot/system/develop/headers/os/interface", System, false);
+AddPath("/boot/system/develop/headers/os/kernel", System, false);
+AddPath("/boot/system/develop/headers/os/locale", System, false);
+AddPath("/boot/system/develop/headers/os/mail", System, false);
+AddPath("/boot/system/develop/headers/os/media", System, false);
+AddPath("/boot/system/develop/headers/os/midi", System, false);
+AddPath("/boot/system/develop/headers/os/midi2", System, false);
+AddPath("/boot/system/develop/headers/os/net", System, false);
+AddPath("/boot/system/develop/headers/os/opengl", System, false);
+AddPath("/boot/system/develop/headers/os/storage", System, false);
+AddPath("/boot/system/develop/headers/os/support", System, false);
+AddPath("/boot/system/develop/headers/os/translation", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);

Re: [PATCH] D16797: Update clang support on recent Haiku

2016-05-11 Thread Jérôme Duval via cfe-commits
korli added a comment.

Ping?


Repository:
  rL LLVM

http://reviews.llvm.org/D16797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16797: Update clang support on recent Haiku

2016-04-07 Thread Jérôme Duval via cfe-commits
korli removed rL LLVM as the repository for this revision.
korli updated this revision to Diff 52953.
korli added a comment.

Thanks for the review, and sorry for the late reply.

This updated diff takes rsmith's comments into account, adding a test 
test/Driver/haiku.c, a case for CST_Libcxx where applicable. This applies 
directly against today's trunk and clang builds then successfully.


http://reviews.llvm.org/D16797

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/haiku.c

Index: test/Driver/haiku.c
===
--- /dev/null
+++ test/Driver/haiku.c
@@ -0,0 +1,12 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86_64 -input-file %t.log %s
+
+// CHECK-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-haiku"
+// CHECK-X86_64: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
+
+// RUN: %clang -no-canonical-prefixes -target i586-pc-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86 -input-file %t.log %s
+
+// CHECK-X86: clang{{.*}}" "-cc1" "-triple" "i586-pc-haiku"
+// CHECK-X86: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
+
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -267,38 +267,39 @@
   }
 
   case llvm::Triple::Haiku:
-AddPath("/boot/common/include", System, false);
-AddPath("/boot/develop/headers/os", System, false);
-AddPath("/boot/develop/headers/os/app", System, false);
-AddPath("/boot/develop/headers/os/arch", System, false);
-AddPath("/boot/develop/headers/os/device", System, false);
-AddPath("/boot/develop/headers/os/drivers", System, false);
-AddPath("/boot/develop/headers/os/game", System, false);
-AddPath("/boot/develop/headers/os/interface", System, false);
-AddPath("/boot/develop/headers/os/kernel", System, false);
-AddPath("/boot/develop/headers/os/locale", System, false);
-AddPath("/boot/develop/headers/os/mail", System, false);
-AddPath("/boot/develop/headers/os/media", System, false);
-AddPath("/boot/develop/headers/os/midi", System, false);
-AddPath("/boot/develop/headers/os/midi2", System, false);
-AddPath("/boot/develop/headers/os/net", System, false);
-AddPath("/boot/develop/headers/os/storage", System, false);
-AddPath("/boot/develop/headers/os/support", System, false);
-AddPath("/boot/develop/headers/os/translation", System, false);
-AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/develop/headers/cpp", System, false);
-AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
-AddPath("/boot/develop/headers/3rdparty", System, false);
-AddPath("/boot/develop/headers/bsd", System, false);
-AddPath("/boot/develop/headers/glibc", System, false);
-AddPath("/boot/develop/headers/posix", System, false);
-AddPath("/boot/develop/headers",  System, false);
+AddPath("/boot/system/non-packaged/develop/headers", System, false);
+AddPath("/boot/system/develop/headers/os", System, false);
+AddPath("/boot/system/develop/headers/os/app", System, false);
+AddPath("/boot/system/develop/headers/os/arch", System, false);
+AddPath("/boot/system/develop/headers/os/device", System, false);
+AddPath("/boot/system/develop/headers/os/drivers", System, false);
+AddPath("/boot/system/develop/headers/os/game", System, false);
+AddPath("/boot/system/develop/headers/os/interface", System, false);
+AddPath("/boot/system/develop/headers/os/kernel", System, false);
+AddPath("/boot/system/develop/headers/os/locale", System, false);
+AddPath("/boot/system/develop/headers/os/mail", System, false);
+AddPath("/boot/system/develop/headers/os/media", System, false);
+AddPath("/boot/system/develop/headers/os/midi", System, false);
+AddPath("/boot/system/develop/headers/os/midi2", System, false);
+AddPath("/boot/system/develop/headers/os/net", System, false);
+AddPath("/boot/system/develop/headers/os/opengl", System, false);
+AddPath("/boot/system/develop/headers/os/storage", System, false);
+AddPath("/boot/system/develop/headers/os/support", System, false);
+AddPath("/boot/system/develop/headers/os/translation", System, false);
+AddPath("/boot/system/develop/headers/os/a

Re: [PATCH] D16797: Update clang support on recent Haiku

2016-04-12 Thread Jérôme Duval via cfe-commits
korli updated this revision to Diff 53464.
korli added a comment.

Updated patch against trunk (following changes in lib/Basic/Targets.cpp).


Repository:
  rL LLVM

http://reviews.llvm.org/D16797

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Frontend/InitHeaderSearch.cpp

Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -267,38 +267,39 @@
   }
 
   case llvm::Triple::Haiku:
-AddPath("/boot/common/include", System, false);
-AddPath("/boot/develop/headers/os", System, false);
-AddPath("/boot/develop/headers/os/app", System, false);
-AddPath("/boot/develop/headers/os/arch", System, false);
-AddPath("/boot/develop/headers/os/device", System, false);
-AddPath("/boot/develop/headers/os/drivers", System, false);
-AddPath("/boot/develop/headers/os/game", System, false);
-AddPath("/boot/develop/headers/os/interface", System, false);
-AddPath("/boot/develop/headers/os/kernel", System, false);
-AddPath("/boot/develop/headers/os/locale", System, false);
-AddPath("/boot/develop/headers/os/mail", System, false);
-AddPath("/boot/develop/headers/os/media", System, false);
-AddPath("/boot/develop/headers/os/midi", System, false);
-AddPath("/boot/develop/headers/os/midi2", System, false);
-AddPath("/boot/develop/headers/os/net", System, false);
-AddPath("/boot/develop/headers/os/storage", System, false);
-AddPath("/boot/develop/headers/os/support", System, false);
-AddPath("/boot/develop/headers/os/translation", System, false);
-AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/develop/headers/cpp", System, false);
-AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
-AddPath("/boot/develop/headers/3rdparty", System, false);
-AddPath("/boot/develop/headers/bsd", System, false);
-AddPath("/boot/develop/headers/glibc", System, false);
-AddPath("/boot/develop/headers/posix", System, false);
-AddPath("/boot/develop/headers",  System, false);
+AddPath("/boot/system/non-packaged/develop/headers", System, false);
+AddPath("/boot/system/develop/headers/os", System, false);
+AddPath("/boot/system/develop/headers/os/app", System, false);
+AddPath("/boot/system/develop/headers/os/arch", System, false);
+AddPath("/boot/system/develop/headers/os/device", System, false);
+AddPath("/boot/system/develop/headers/os/drivers", System, false);
+AddPath("/boot/system/develop/headers/os/game", System, false);
+AddPath("/boot/system/develop/headers/os/interface", System, false);
+AddPath("/boot/system/develop/headers/os/kernel", System, false);
+AddPath("/boot/system/develop/headers/os/locale", System, false);
+AddPath("/boot/system/develop/headers/os/mail", System, false);
+AddPath("/boot/system/develop/headers/os/media", System, false);
+AddPath("/boot/system/develop/headers/os/midi", System, false);
+AddPath("/boot/system/develop/headers/os/midi2", System, false);
+AddPath("/boot/system/develop/headers/os/net", System, false);
+AddPath("/boot/system/develop/headers/os/opengl", System, false);
+AddPath("/boot/system/develop/headers/os/storage", System, false);
+AddPath("/boot/system/develop/headers/os/support", System, false);
+AddPath("/boot/system/develop/headers/os/translation", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false);
+AddPath("/boot/system/develop/headers/3rdparty", System, false);
+AddPath("/boot/system/develop/headers/bsd", System, false);
+AddPath("/boot/system/develop/headers/glibc", System, false);
+AddPath("/boot/system/develop/headers/posix

Re: [PATCH] D16797: Update clang support on recent Haiku

2016-03-08 Thread Jérôme Duval via cfe-commits
korli added a comment.

Ping?


Repository:
  rL LLVM

http://reviews.llvm.org/D16797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16797: Update clang support on recent Haiku

2016-03-24 Thread Jérôme Duval via cfe-commits
korli updated this revision to Diff 51571.
korli added a comment.

This updated diff fixes the x86-32 Haiku target, which needs the target define 
__INTEL__.
This applies directly to today's trunk.


Repository:
  rL LLVM

http://reviews.llvm.org/D16797

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Frontend/InitHeaderSearch.cpp

Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -267,38 +267,39 @@
   }
 
   case llvm::Triple::Haiku:
-AddPath("/boot/common/include", System, false);
-AddPath("/boot/develop/headers/os", System, false);
-AddPath("/boot/develop/headers/os/app", System, false);
-AddPath("/boot/develop/headers/os/arch", System, false);
-AddPath("/boot/develop/headers/os/device", System, false);
-AddPath("/boot/develop/headers/os/drivers", System, false);
-AddPath("/boot/develop/headers/os/game", System, false);
-AddPath("/boot/develop/headers/os/interface", System, false);
-AddPath("/boot/develop/headers/os/kernel", System, false);
-AddPath("/boot/develop/headers/os/locale", System, false);
-AddPath("/boot/develop/headers/os/mail", System, false);
-AddPath("/boot/develop/headers/os/media", System, false);
-AddPath("/boot/develop/headers/os/midi", System, false);
-AddPath("/boot/develop/headers/os/midi2", System, false);
-AddPath("/boot/develop/headers/os/net", System, false);
-AddPath("/boot/develop/headers/os/storage", System, false);
-AddPath("/boot/develop/headers/os/support", System, false);
-AddPath("/boot/develop/headers/os/translation", System, false);
-AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/develop/headers/cpp", System, false);
-AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
-AddPath("/boot/develop/headers/3rdparty", System, false);
-AddPath("/boot/develop/headers/bsd", System, false);
-AddPath("/boot/develop/headers/glibc", System, false);
-AddPath("/boot/develop/headers/posix", System, false);
-AddPath("/boot/develop/headers",  System, false);
+AddPath("/boot/system/non-packaged/develop/headers", System, false);
+AddPath("/boot/system/develop/headers/os", System, false);
+AddPath("/boot/system/develop/headers/os/app", System, false);
+AddPath("/boot/system/develop/headers/os/arch", System, false);
+AddPath("/boot/system/develop/headers/os/device", System, false);
+AddPath("/boot/system/develop/headers/os/drivers", System, false);
+AddPath("/boot/system/develop/headers/os/game", System, false);
+AddPath("/boot/system/develop/headers/os/interface", System, false);
+AddPath("/boot/system/develop/headers/os/kernel", System, false);
+AddPath("/boot/system/develop/headers/os/locale", System, false);
+AddPath("/boot/system/develop/headers/os/mail", System, false);
+AddPath("/boot/system/develop/headers/os/media", System, false);
+AddPath("/boot/system/develop/headers/os/midi", System, false);
+AddPath("/boot/system/develop/headers/os/midi2", System, false);
+AddPath("/boot/system/develop/headers/os/net", System, false);
+AddPath("/boot/system/develop/headers/os/opengl", System, false);
+AddPath("/boot/system/develop/headers/os/storage", System, false);
+AddPath("/boot/system/develop/headers/os/support", System, false);
+AddPath("/boot/system/develop/headers/os/translation", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false);
+AddPath("/boot/system/develop/headers/3rdparty", System, false);
+AddPath("/boot/system/develop/headers/bsd", System, false);
+AddPath("/boot/system/develop/headers/glibc", System,

Re: [PATCH] D16797: Update clang support on recent Haiku

2016-03-24 Thread Jérôme Duval via cfe-commits
korli added a comment.

Yes, I don't have commit access.


Repository:
  rL LLVM

http://reviews.llvm.org/D16797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-11-08 Thread Jérôme Duval via cfe-commits

https://github.com/korli created 
https://github.com/llvm/llvm-project/pull/115462

* Signal frame unwinding on x86_64 from X512
* Header search for commpage_defs.h on non-standard paths

Unwind supported tests pass on Haiku x86_64

From faa99ee1a06a8139995bba31e6d783df164fb45d Mon Sep 17 00:00:00 2001
From: Trung Nguyen 
Date: Thu, 7 Jul 2022 22:19:34 +0700
Subject: [PATCH] [libunwind][Haiku] Improve support

* Signal frame unwinding on x86_64 from X512
* Header search for commpage_defs.h on non-standard paths
---
 libunwind/src/CMakeLists.txt   | 16 
 libunwind/src/UnwindCursor.hpp | 71 --
 2 files changed, 83 insertions(+), 4 deletions(-)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 2e18b109656331..e7ea57734cca97 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -113,6 +113,22 @@ if (HAIKU)
 
   add_compile_flags("-D_DEFAULT_SOURCE")
   add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME")
+
+  find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS
+"commpage_defs.h"
+PATHS ${CMAKE_SYSTEM_INCLUDE_PATH}
+PATH_SUFFIXES "/private/system"
+NO_DEFAULT_PATH
+REQUIRED)
+
+  include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}")
+  if (LIBUNWIND_TARGET_TRIPLE)
+if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64")
+  include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64")
+endif()
+  else()
+include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}")
+  endif()
 endif ()
 
 string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 32e6fb43d988ff..0019c1e62a7a65 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1010,6 +1010,9 @@ class UnwindCursor : public AbstractUnwindCursor{
   template  int stepThroughSigReturn(Registers &) {
 return UNW_STEP_END;
   }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+  bool setInfoForSigReturn();
+  int stepThroughSigReturn();
 #endif
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
@@ -1313,7 +1316,8 @@ class UnwindCursor : public AbstractUnwindCursor{
   unw_proc_info_t  _info;
   bool _unwindInfoMissing;
   bool _isSignalFrame;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   bool _isSigReturn = false;
 #endif
 };
@@ -2549,7 +2553,8 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 
 template 
 void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) {
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   _isSigReturn = false;
 #endif
 
@@ -2673,7 +2678,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   }
 #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   if (setInfoForSigReturn())
 return;
 #endif
@@ -2749,6 +2755,62 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
   _isSignalFrame = true;
   return UNW_STEP_SUCCESS;
 }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+
+#include 
+#include 
+
+extern "C" {
+extern void *__gCommPageAddress;
+}
+
+template 
+bool UnwindCursor::setInfoForSigReturn() {
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  addr_t signal_handler = 
(((addr_t*)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER]
+  + 
(addr_t)__gCommPageAddress);
+  addr_t signal_handler_ret = signal_handler + 45;
+#endif
+  pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  if (pc == signal_handler_ret) {
+_info = {};
+_info.start_ip = signal_handler;
+_info.end_ip = signal_handler_ret;
+_isSigReturn = true;
+return true;
+  }
+  return false;
+}
+
+template 
+int UnwindCursor::stepThroughSigReturn() {
+  _isSignalFrame = true;
+  pint_t sp = _registers.getSP();
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  vregs *regs = (vregs*)(sp + 0x70);
+
+  _registers.setRegister(UNW_REG_IP, regs->rip);
+  _registers.setRegister(UNW_REG_SP, regs->rsp);
+  _registers.setRegister(UNW_X86_64_RAX, regs->rax);
+  _registers.setRegister(UNW_X86_64_RDX, regs->rdx);
+  _registers.setRegister(UNW_X86_64_RCX, regs->rcx);
+  _registers.setRegister(UNW_X86_64_RBX, regs->rbx);
+  _registers.setRegister(UNW_X86_64_RSI, regs->rsi);
+  _registers.setRegister(UNW_X86_64_RDI, regs->rdi);
+  _registers.setRegister(UNW_X86_64_RBP, regs->rbp);
+  _registers.setRegi

[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-11-08 Thread Jérôme Duval via cfe-commits

https://github.com/korli updated 
https://github.com/llvm/llvm-project/pull/115462

From c88a3b1f8c8db4b222c0fdc306088a00bee54938 Mon Sep 17 00:00:00 2001
From: Trung Nguyen 
Date: Thu, 7 Jul 2022 22:19:34 +0700
Subject: [PATCH] [libunwind][Haiku] Improve support

* Signal frame unwinding on x86_64 from X512
* Header search for commpage_defs.h on non-standard paths
---
 libunwind/src/CMakeLists.txt   | 16 
 libunwind/src/UnwindCursor.hpp | 72 --
 2 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 2e18b109656331..e7ea57734cca97 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -113,6 +113,22 @@ if (HAIKU)
 
   add_compile_flags("-D_DEFAULT_SOURCE")
   add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME")
+
+  find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS
+"commpage_defs.h"
+PATHS ${CMAKE_SYSTEM_INCLUDE_PATH}
+PATH_SUFFIXES "/private/system"
+NO_DEFAULT_PATH
+REQUIRED)
+
+  include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}")
+  if (LIBUNWIND_TARGET_TRIPLE)
+if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64")
+  include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64")
+endif()
+  else()
+include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}")
+  endif()
 endif ()
 
 string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 32e6fb43d988ff..371f8dd647758f 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1010,6 +1010,9 @@ class UnwindCursor : public AbstractUnwindCursor{
   template  int stepThroughSigReturn(Registers &) {
 return UNW_STEP_END;
   }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+  bool setInfoForSigReturn();
+  int stepThroughSigReturn();
 #endif
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
@@ -1313,7 +1316,8 @@ class UnwindCursor : public AbstractUnwindCursor{
   unw_proc_info_t  _info;
   bool _unwindInfoMissing;
   bool _isSignalFrame;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   bool _isSigReturn = false;
 #endif
 };
@@ -2549,7 +2553,8 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 
 template 
 void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) {
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   _isSigReturn = false;
 #endif
 
@@ -2673,7 +2678,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   }
 #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   if (setInfoForSigReturn())
 return;
 #endif
@@ -2749,6 +2755,63 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
   _isSignalFrame = true;
   return UNW_STEP_SUCCESS;
 }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+
+#include 
+#include 
+
+extern "C" {
+extern void *__gCommPageAddress;
+}
+
+template 
+bool UnwindCursor::setInfoForSigReturn() {
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  addr_t signal_handler =
+  (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] +
+   (addr_t)__gCommPageAddress);
+  addr_t signal_handler_ret = signal_handler + 45;
+#endif
+  pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  if (pc == signal_handler_ret) {
+_info = {};
+_info.start_ip = signal_handler;
+_info.end_ip = signal_handler_ret;
+_isSigReturn = true;
+return true;
+  }
+  return false;
+}
+
+template 
+int UnwindCursor::stepThroughSigReturn() {
+  _isSignalFrame = true;
+  pint_t sp = _registers.getSP();
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  vregs *regs = (vregs *)(sp + 0x70);
+
+  _registers.setRegister(UNW_REG_IP, regs->rip);
+  _registers.setRegister(UNW_REG_SP, regs->rsp);
+  _registers.setRegister(UNW_X86_64_RAX, regs->rax);
+  _registers.setRegister(UNW_X86_64_RDX, regs->rdx);
+  _registers.setRegister(UNW_X86_64_RCX, regs->rcx);
+  _registers.setRegister(UNW_X86_64_RBX, regs->rbx);
+  _registers.setRegister(UNW_X86_64_RSI, regs->rsi);
+  _registers.setRegister(UNW_X86_64_RDI, regs->rdi);
+  _registers.setRegister(UNW_X86_64_RBP, regs->rbp);
+  _registers.setRegister(UNW_X86_64_R8, regs->r8);
+  _registers.setRegister(UNW_X86_64_R9, regs->r9);
+  _registers.setRegi

[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-11-29 Thread Jérôme Duval via cfe-commits

https://github.com/korli updated 
https://github.com/llvm/llvm-project/pull/115462

From c88a3b1f8c8db4b222c0fdc306088a00bee54938 Mon Sep 17 00:00:00 2001
From: Trung Nguyen 
Date: Thu, 7 Jul 2022 22:19:34 +0700
Subject: [PATCH 1/2] [libunwind][Haiku] Improve support

* Signal frame unwinding on x86_64 from X512
* Header search for commpage_defs.h on non-standard paths
---
 libunwind/src/CMakeLists.txt   | 16 
 libunwind/src/UnwindCursor.hpp | 72 --
 2 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 2e18b109656331..e7ea57734cca97 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -113,6 +113,22 @@ if (HAIKU)
 
   add_compile_flags("-D_DEFAULT_SOURCE")
   add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME")
+
+  find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS
+"commpage_defs.h"
+PATHS ${CMAKE_SYSTEM_INCLUDE_PATH}
+PATH_SUFFIXES "/private/system"
+NO_DEFAULT_PATH
+REQUIRED)
+
+  include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}")
+  if (LIBUNWIND_TARGET_TRIPLE)
+if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64")
+  include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64")
+endif()
+  else()
+include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}")
+  endif()
 endif ()
 
 string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 32e6fb43d988ff..371f8dd647758f 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1010,6 +1010,9 @@ class UnwindCursor : public AbstractUnwindCursor{
   template  int stepThroughSigReturn(Registers &) {
 return UNW_STEP_END;
   }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+  bool setInfoForSigReturn();
+  int stepThroughSigReturn();
 #endif
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
@@ -1313,7 +1316,8 @@ class UnwindCursor : public AbstractUnwindCursor{
   unw_proc_info_t  _info;
   bool _unwindInfoMissing;
   bool _isSignalFrame;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   bool _isSigReturn = false;
 #endif
 };
@@ -2549,7 +2553,8 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 
 template 
 void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) {
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   _isSigReturn = false;
 #endif
 
@@ -2673,7 +2678,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   }
 #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   if (setInfoForSigReturn())
 return;
 #endif
@@ -2749,6 +2755,63 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
   _isSignalFrame = true;
   return UNW_STEP_SUCCESS;
 }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+
+#include 
+#include 
+
+extern "C" {
+extern void *__gCommPageAddress;
+}
+
+template 
+bool UnwindCursor::setInfoForSigReturn() {
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  addr_t signal_handler =
+  (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] +
+   (addr_t)__gCommPageAddress);
+  addr_t signal_handler_ret = signal_handler + 45;
+#endif
+  pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  if (pc == signal_handler_ret) {
+_info = {};
+_info.start_ip = signal_handler;
+_info.end_ip = signal_handler_ret;
+_isSigReturn = true;
+return true;
+  }
+  return false;
+}
+
+template 
+int UnwindCursor::stepThroughSigReturn() {
+  _isSignalFrame = true;
+  pint_t sp = _registers.getSP();
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  vregs *regs = (vregs *)(sp + 0x70);
+
+  _registers.setRegister(UNW_REG_IP, regs->rip);
+  _registers.setRegister(UNW_REG_SP, regs->rsp);
+  _registers.setRegister(UNW_X86_64_RAX, regs->rax);
+  _registers.setRegister(UNW_X86_64_RDX, regs->rdx);
+  _registers.setRegister(UNW_X86_64_RCX, regs->rcx);
+  _registers.setRegister(UNW_X86_64_RBX, regs->rbx);
+  _registers.setRegister(UNW_X86_64_RSI, regs->rsi);
+  _registers.setRegister(UNW_X86_64_RDI, regs->rdi);
+  _registers.setRegister(UNW_X86_64_RBP, regs->rbp);
+  _registers.setRegister(UNW_X86_64_R8, regs->r8);
+  _registers.setRegister(UNW_X86_64_R9, regs->r9);
+  _registers.set

[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-11-29 Thread Jérôme Duval via cfe-commits


@@ -2917,7 +2980,8 @@ template  int UnwindCursor::step(bool stage2) {
 
   // Use unwinding info to modify register set as if function returned.
   int result;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))

korli wrote:

Right, removed the unneeded checks.

https://github.com/llvm/llvm-project/pull/115462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-11-15 Thread Jérôme Duval via cfe-commits


@@ -2917,7 +2980,8 @@ template  int UnwindCursor::step(bool stage2) {
 
   // Use unwinding info to modify register set as if function returned.
   int result;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))

korli wrote:

I suppose because signal frame unwinding is only tested on x86_64. 
@X547 

https://github.com/llvm/llvm-project/pull/115462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-12-03 Thread Jérôme Duval via cfe-commits

https://github.com/korli updated 
https://github.com/llvm/llvm-project/pull/115462

From c88a3b1f8c8db4b222c0fdc306088a00bee54938 Mon Sep 17 00:00:00 2001
From: Trung Nguyen 
Date: Thu, 7 Jul 2022 22:19:34 +0700
Subject: [PATCH 1/3] [libunwind][Haiku] Improve support

* Signal frame unwinding on x86_64 from X512
* Header search for commpage_defs.h on non-standard paths
---
 libunwind/src/CMakeLists.txt   | 16 
 libunwind/src/UnwindCursor.hpp | 72 --
 2 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 2e18b109656331..e7ea57734cca97 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -113,6 +113,22 @@ if (HAIKU)
 
   add_compile_flags("-D_DEFAULT_SOURCE")
   add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME")
+
+  find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS
+"commpage_defs.h"
+PATHS ${CMAKE_SYSTEM_INCLUDE_PATH}
+PATH_SUFFIXES "/private/system"
+NO_DEFAULT_PATH
+REQUIRED)
+
+  include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}")
+  if (LIBUNWIND_TARGET_TRIPLE)
+if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64")
+  include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64")
+endif()
+  else()
+include_directories(SYSTEM 
"${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}")
+  endif()
 endif ()
 
 string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 32e6fb43d988ff..371f8dd647758f 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1010,6 +1010,9 @@ class UnwindCursor : public AbstractUnwindCursor{
   template  int stepThroughSigReturn(Registers &) {
 return UNW_STEP_END;
   }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+  bool setInfoForSigReturn();
+  int stepThroughSigReturn();
 #endif
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
@@ -1313,7 +1316,8 @@ class UnwindCursor : public AbstractUnwindCursor{
   unw_proc_info_t  _info;
   bool _unwindInfoMissing;
   bool _isSignalFrame;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   bool _isSigReturn = false;
 #endif
 };
@@ -2549,7 +2553,8 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 
 template 
 void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) {
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   _isSigReturn = false;
 #endif
 
@@ -2673,7 +2678,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   }
 #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))
   if (setInfoForSigReturn())
 return;
 #endif
@@ -2749,6 +2755,63 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
   _isSignalFrame = true;
   return UNW_STEP_SUCCESS;
 }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+
+#include 
+#include 
+
+extern "C" {
+extern void *__gCommPageAddress;
+}
+
+template 
+bool UnwindCursor::setInfoForSigReturn() {
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  addr_t signal_handler =
+  (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] +
+   (addr_t)__gCommPageAddress);
+  addr_t signal_handler_ret = signal_handler + 45;
+#endif
+  pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  if (pc == signal_handler_ret) {
+_info = {};
+_info.start_ip = signal_handler;
+_info.end_ip = signal_handler_ret;
+_isSigReturn = true;
+return true;
+  }
+  return false;
+}
+
+template 
+int UnwindCursor::stepThroughSigReturn() {
+  _isSignalFrame = true;
+  pint_t sp = _registers.getSP();
+#if defined(_LIBUNWIND_TARGET_X86_64)
+  vregs *regs = (vregs *)(sp + 0x70);
+
+  _registers.setRegister(UNW_REG_IP, regs->rip);
+  _registers.setRegister(UNW_REG_SP, regs->rsp);
+  _registers.setRegister(UNW_X86_64_RAX, regs->rax);
+  _registers.setRegister(UNW_X86_64_RDX, regs->rdx);
+  _registers.setRegister(UNW_X86_64_RCX, regs->rcx);
+  _registers.setRegister(UNW_X86_64_RBX, regs->rbx);
+  _registers.setRegister(UNW_X86_64_RSI, regs->rsi);
+  _registers.setRegister(UNW_X86_64_RDI, regs->rdi);
+  _registers.setRegister(UNW_X86_64_RBP, regs->rbp);
+  _registers.setRegister(UNW_X86_64_R8, regs->r8);
+  _registers.setRegister(UNW_X86_64_R9, regs->r9);
+  _registers.set

[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-12-03 Thread Jérôme Duval via cfe-commits


@@ -2749,6 +2755,63 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
   _isSignalFrame = true;
   return UNW_STEP_SUCCESS;
 }
+#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)

korli wrote:

Done.

https://github.com/llvm/llvm-project/pull/115462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][Haiku] Fix signal frame unwinding (PR #135367)

2025-04-12 Thread Jérôme Duval via cfe-commits

korli wrote:

> Yes, tested on `x86_64` and only `x86_64` (though support for other archs can 
> be added by as easy as defining a few offsets and registers). Requires Haiku 
> `hrev58811` to fully work with `tests/signal_unwind.pass.cpp`.
> 
> This is also the same implementation used in my debugger ports for Haiku.

Does it build on r1beta5?

https://github.com/llvm/llvm-project/pull/135367
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][Haiku] Fix signal frame unwinding (PR #135367)

2025-04-12 Thread Jérôme Duval via cfe-commits

korli wrote:

Tested on x86_64? 

https://github.com/llvm/llvm-project/pull/135367
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits