[libcxx-commits] [PATCH] D142176: [libunwind] On Darwin, add a callback-based lookup scheme for JIT'd unwind info.

Lang Hames via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 20 11:44:46 PST 2023


lhames updated this revision to Diff 490929.
lhames added a comment.

Expand comments for new SPI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142176/new/

https://reviews.llvm.org/D142176

Files:
  libunwind/src/libunwind_ext.h


Index: libunwind/src/libunwind_ext.h
===================================================================
--- libunwind/src/libunwind_ext.h
+++ libunwind/src/libunwind_ext.h
@@ -60,6 +60,26 @@
 
 #ifdef __APPLE__
 
+// Holds a description of the object-format-header (if any) and unwind info
+// sections for a given address:
+//
+// * dso_base should point to a header for the JIT'd object containing the
+//   given address. The header's type should match the format type that
+//   libunwind was compiled for (so a mach_header or mach_header_64 on Darwin).
+//   A value of zero indicates that no such header exists.
+//
+// * dwarf_section and dwarf_section_length hold the address range of a DWARF
+//   eh-frame section associated with the given address, if any. If the
+//   dwarf_section_length field is zero it indicates that no such section
+//   exists (and in this case dwarf_section should also be set to zero).
+//
+// * compact_unwind_section and compact_unwind_section_length hold the address
+//   range of a compact-unwind info section associated with the given address,
+//   if any. If the compact_unwind_section_length field is zero it indicates
+//   that no such section exists (and in this case compact_unwind_section
+//   should also be set to zero).
+//
+// See the unw_find_dynamic_unwind_sections type below for more details.
 struct unw_dynamic_unwind_sections {
   unw_word_t dso_base;
   unw_word_t dwarf_section;
@@ -68,16 +88,34 @@
   size_t     compact_unwind_section_length;
 };
 
+// Typedef for unwind-info lookup callbacks. Functions of this type can be
+// registered and deregistered using __unw_add_find_dynamic_unwind_sections
+// and __unw_remove_find_dynamic_unwind_sections respectively.
+//
+// An unwind-info lookup callback should return 1 to indicate that it found
+// unwind-info for the given address, or 0 to indicate that it did not find
+// unwind-info for the given address. If found, the callback should populate
+// some or all of the fields of the info argument (which is guaranteed to be
+// non-null with all fields zero-initialized):
 typedef int (*unw_find_dynamic_unwind_sections)(
     unw_word_t addr, struct unw_dynamic_unwind_sections *info);
 
-// Returns 0 if successfully registered, -1 to indicate too many
-// registrations.
+// Register a dynamic unwind-info lookup callback. If libunwind does not find
+// unwind info for a given frame in the executable program or normal dynamic
+// shared objects then it will call all registered dynamic lookup functions
+// in registration order until either one of them returns true, or the end
+// of the list is reached. This lookup will happen before libunwind searches
+// any eh-frames registered via __register_frame or
+// __unw_add_dynamic_eh_frame_section.
+//
+// This registration function will return 0 if the callback is successfully
+// registered, or -1 to indicate too many registrations.
 extern int __unw_add_find_dynamic_unwind_sections(
     unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);
 
-// Returns 0 if successfully registered, -1 to indicate no such
-// registration.
+// Deregister a dynacim unwind-info lookup callback.
+// Returns 0 if successfully deregistered, or -1 to indicate that no such
+// registration existed.
 extern int __unw_remove_find_dynamic_unwind_sections(
     unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142176.490929.patch
Type: text/x-patch
Size: 3404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230120/61b64a48/attachment-0001.bin>


More information about the libcxx-commits mailing list