[vala] linux: improve backtrace bindings



commit 646ad7e1bd8e152229615da0b709a14dabf36c89
Author: Evan Nemerson <evan nemerson com>
Date:   Wed Aug 13 11:11:24 2014 -0700

    linux: improve backtrace bindings
    
    Some minor improvements have been made to backtrace_symbols; we no
    longer leak the return value and it is marked as nullable. This also
    adds a Backtrace namespace for some better bindings which treat the
    backtrace as an array of void* instead of just a void*.

 vapi/linux.vapi |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/vapi/linux.vapi b/vapi/linux.vapi
index ffa7ce4..5cceea1 100644
--- a/vapi/linux.vapi
+++ b/vapi/linux.vapi
@@ -1025,15 +1025,30 @@ namespace Linux {
         DT_WHT
     }
 
-    [CCode (cheader_filename = "execinfo.h")]
+    [Deprecated (since = "vala-0.26", replacement = "Backtrace.get"), CCode (cheader_filename = 
"execinfo.h")]
     public int backtrace (void* buffer, int size);
 
-    [CCode (cheader_filename = "execinfo.h", array_length = false)]
-    public unowned string[] backtrace_symbols (void* buffer, int size);
+    [Deprecated (since = "vala-0.26", replacement = "Backtrace.symbols"), CCode (cheader_filename = 
"execinfo.h", array_length = false)]
+    public (unowned string)[]? backtrace_symbols (void* buffer, int size);
 
-    [CCode (cheader_filename = "execinfo.h")]
+    [Deprecated (since = "vala-0.26", replacement = "Backtrace.symbols_fd"), CCode (cheader_filename = 
"execinfo.h")]
     public void backtrace_symbols_fd (void* buffer, int size, int fd);
 
+    namespace Backtrace {
+      [CCode (cname = "backtrace", cheader_filename = "execinfo.h")]
+      public int @get (void*[] buffer);
+      [CCode (cname = "backtrace_symbols", cheader_filename = "execinfo.h", array_length = false)]
+      private (unowned string)[]? _symbols (void*[] buffer);
+      [CCode (cname = "_vala_backtrace_symbols")]
+      public (unowned string)[]? symbols (void*[] buffer) {
+        (unowned string)[]? s = _symbols (buffer);
+        s.length = buffer.length;
+        return s;
+      }
+      [CCode (cheader_filename = "execinfo.h")]
+      public void symbols_fd (void*[] buffer, int fd);
+    }
+
     [CCode (cheader_filename = "unistd.h")]
     public int sethostname (string name, size_t len);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]