{"action":"created","comment":{"url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/comments/74806715","id":74806715,"diff_hunk":"@@ -0,0 +1,145 @@\n+// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT\n+// file at the top-level directory of this distribution and at\n+// http://rust-lang.org/COPYRIGHT.\n+//\n+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your\n+// option. This file may not be copied, modified, or distributed\n+// except according to those terms.\n+\n+use std::os::raw::{c_void, c_char, c_int};\n+use std::ffi::{CStr, OsStr};\n+use std::path::Path;\n+use std::os::unix::prelude::*;\n+use std::ptr;\n+use libc::getpid;\n+\n+use {Symbol, SymbolName};\n+\n+// since we are quite defensive here we want to use dladdr as a\n+// fallback for OS X in case we cannot load the core symbolication\n+// framework.\n+#[cfg(feature = \"dladdr\")]\n+#[path=\"dladdr.rs\"]\n+mod dladdr_fallback;\n+\n+#[cfg(feature = \"dladdr\")]\n+use self::dladdr_fallback::resolve as fallback_resolve;\n+\n+#[cfg(not(feature = \"dladdr\"))]\n+fn fallback_resolve(_addr: *mut c_void, _cb: &mut FnMut(&Symbol)) {}\n+\n+#[repr(C)]\n+#[derive(Copy, Clone, PartialEq)]\n+pub struct CSTypeRef {\n+    cpp_data: *const c_void,\n+    cpp_obj: *const c_void\n+}\n+\n+const CS_NOW: u64 = 0x80000000;\n+const CSREF_NULL: CSTypeRef = CSTypeRef {\n+    cpp_data: 0 as *const c_void,\n+    cpp_obj: 0 as *const c_void,\n+};\n+\n+#[repr(C)]\n+struct Info {\n+    path: *const c_char,\n+    lineno: u32,\n+    name: *const c_char,\n+    addr: *mut c_void,\n+}\n+\n+impl Symbol for Info {\n+    fn name(&self) -> Option<SymbolName> {\n+        if self.name.is_null() {\n+            None\n+        } else {\n+            Some(SymbolName::new(unsafe {\n+                CStr::from_ptr(self.name).to_bytes()\n+            }))\n+        }\n+    }\n+\n+    fn addr(&self) -> Option<*mut c_void> {\n+        Some(self.addr)\n+    }\n+\n+    fn filename(&self) -> Option<&Path> {\n+        if self.path.is_null() {\n+            None\n+        } else {\n+            Some(Path::new(OsStr::from_bytes(unsafe {\n+                CStr::from_ptr(self.path).to_bytes()\n+            })))\n+        }\n+    }\n+\n+    fn lineno(&self) -> Option<u32> {\n+        if self.lineno == 0 {\n+            None\n+        } else {\n+            Some(self.lineno)\n+        }\n+    }\n+}\n+\n+shared_library!(Cs,\n+    fn CSSymbolicatorCreateWithPid(pid: c_int) -> CSTypeRef,\n+    fn CSRelease(rf: CSTypeRef),\n+    fn CSSymbolicatorGetSymbolWithAddressAtTime(\n+        cs: CSTypeRef, addr: *const c_void, time: u64) -> CSTypeRef,\n+    fn CSSymbolicatorGetSourceInfoWithAddressAtTime(\n+        cs: CSTypeRef, addr: *const c_void, time: u64) -> CSTypeRef,\n+    fn CSSourceInfoGetLineNumber(info: CSTypeRef) -> c_int,\n+    fn CSSourceInfoGetPath(info: CSTypeRef) -> *const c_char,\n+    fn CSSourceInfoGetSymbol(info: CSTypeRef) -> CSTypeRef,\n+    fn CSSymbolGetName(sym: CSTypeRef) -> *const c_char,\n+    fn CSSymbolGetSymbolOwner(sym: CSTypeRef) -> CSTypeRef,\n+    fn CSSymbolOwnerGetBaseAddress(symowner: CSTypeRef) -> *mut c_void,\n+);\n+\n+pub fn resolve(addr: *mut c_void, cb: &mut FnMut(&Symbol)) {\n+    let lib = match Cs::open(Path::new(\n+        \"/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication\")) {","path":"src/symbolize/coresymbolication.rs","position":105,"original_position":105,"commit_id":"40e0fdbb392fca53f6bb3403cabdf8c12738aaec","original_commit_id":"40e0fdbb392fca53f6bb3403cabdf8c12738aaec","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"Also, is there perhaps a version of some kind we could check here to ensure that the ABI hasn't changed much since we last looked?","created_at":"2016-08-15T18:16:20Z","updated_at":"2016-08-15T18:16:20Z","html_url":"https://github.com/alexcrichton/backtrace-rs/pull/15#discussion_r74806715","pull_request_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/comments/74806715"},"html":{"href":"https://github.com/alexcrichton/backtrace-rs/pull/15#discussion_r74806715"},"pull_request":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15","id":81271438,"html_url":"https://github.com/alexcrichton/backtrace-rs/pull/15","diff_url":"https://github.com/alexcrichton/backtrace-rs/pull/15.diff","patch_url":"https://github.com/alexcrichton/backtrace-rs/pull/15.patch","issue_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues/15","number":15,"state":"open","locked":false,"title":"Implemented basic support for core symbolication","user":{"login":"mitsuhiko","id":7396,"avatar_url":"https://avatars.githubusercontent.com/u/7396?v=3","gravatar_id":"","url":"https://api.github.com/users/mitsuhiko","html_url":"https://github.com/mitsuhiko","followers_url":"https://api.github.com/users/mitsuhiko/followers","following_url":"https://api.github.com/users/mitsuhiko/following{/other_user}","gists_url":"https://api.github.com/users/mitsuhiko/gists{/gist_id}","starred_url":"https://api.github.com/users/mitsuhiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitsuhiko/subscriptions","organizations_url":"https://api.github.com/users/mitsuhiko/orgs","repos_url":"https://api.github.com/users/mitsuhiko/repos","events_url":"https://api.github.com/users/mitsuhiko/events{/privacy}","received_events_url":"https://api.github.com/users/mitsuhiko/received_events","type":"User","site_admin":false},"body":"This adds very basic support for core symbolication which means that we get proper filenames and line numbers on OS X.\r\n\r\n~~The main issue I have with the current implementation is that it links against a private framework. It would probably be better loading the framework at runtime and falling back to dladdr in case it cannot be found.~~\r\n\r\nThoughts?","created_at":"2016-08-15T05:22:24Z","updated_at":"2016-08-15T18:16:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf883f6ed1b0b6fd72035fc26d40d3f66a53ce2d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15/commits","review_comments_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15/comments","review_comment_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues/15/comments","statuses_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/statuses/40e0fdbb392fca53f6bb3403cabdf8c12738aaec","head":{"label":"mitsuhiko:feature/coresymbolication","ref":"feature/coresymbolication","sha":"40e0fdbb392fca53f6bb3403cabdf8c12738aaec","user":{"login":"mitsuhiko","id":7396,"avatar_url":"https://avatars.githubusercontent.com/u/7396?v=3","gravatar_id":"","url":"https://api.github.com/users/mitsuhiko","html_url":"https://github.com/mitsuhiko","followers_url":"https://api.github.com/users/mitsuhiko/followers","following_url":"https://api.github.com/users/mitsuhiko/following{/other_user}","gists_url":"https://api.github.com/users/mitsuhiko/gists{/gist_id}","starred_url":"https://api.github.com/users/mitsuhiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitsuhiko/subscriptions","organizations_url":"https://api.github.com/users/mitsuhiko/orgs","repos_url":"https://api.github.com/users/mitsuhiko/repos","events_url":"https://api.github.com/users/mitsuhiko/events{/privacy}","received_events_url":"https://api.github.com/users/mitsuhiko/received_events","type":"User","site_admin":false},"repo":{"id":65704179,"name":"backtrace-rs","full_name":"mitsuhiko/backtrace-rs","owner":{"login":"mitsuhiko","id":7396,"avatar_url":"https://avatars.githubusercontent.com/u/7396?v=3","gravatar_id":"","url":"https://api.github.com/users/mitsuhiko","html_url":"https://github.com/mitsuhiko","followers_url":"https://api.github.com/users/mitsuhiko/followers","following_url":"https://api.github.com/users/mitsuhiko/following{/other_user}","gists_url":"https://api.github.com/users/mitsuhiko/gists{/gist_id}","starred_url":"https://api.github.com/users/mitsuhiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitsuhiko/subscriptions","organizations_url":"https://api.github.com/users/mitsuhiko/orgs","repos_url":"https://api.github.com/users/mitsuhiko/repos","events_url":"https://api.github.com/users/mitsuhiko/events{/privacy}","received_events_url":"https://api.github.com/users/mitsuhiko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mitsuhiko/backtrace-rs","description":"Backtraces in Rust","fork":true,"url":"https://api.github.com/repos/mitsuhiko/backtrace-rs","forks_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/forks","keys_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/teams","hooks_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/hooks","issue_events_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/issues/events{/number}","events_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/events","assignees_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/assignees{/user}","branches_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/branches{/branch}","tags_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/tags","blobs_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/languages","stargazers_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/stargazers","contributors_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/contributors","subscribers_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/subscribers","subscription_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/subscription","commits_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/contents/{+path}","compare_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/merges","archive_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/downloads","issues_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/issues{/number}","pulls_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/labels{/name}","releases_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/releases{/id}","deployments_url":"https://api.github.com/repos/mitsuhiko/backtrace-rs/deployments","created_at":"2016-08-15T04:20:10Z","updated_at":"2016-08-15T04:20:12Z","pushed_at":"2016-08-15T06:05:04Z","git_url":"git://github.com/mitsuhiko/backtrace-rs.git","ssh_url":"git@github.com:mitsuhiko/backtrace-rs.git","clone_url":"https://github.com/mitsuhiko/backtrace-rs.git","svn_url":"https://github.com/mitsuhiko/backtrace-rs","homepage":null,"size":952,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"alexcrichton:master","ref":"master","sha":"c886ae9b63a75eaf9f0e775597996b65f6ff2ca9","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"repo":{"id":37171746,"name":"backtrace-rs","full_name":"alexcrichton/backtrace-rs","owner":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexcrichton/backtrace-rs","description":"Backtraces in Rust","fork":false,"url":"https://api.github.com/repos/alexcrichton/backtrace-rs","forks_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/forks","keys_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/teams","hooks_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/hooks","issue_events_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues/events{/number}","events_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/events","assignees_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/assignees{/user}","branches_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/branches{/branch}","tags_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/tags","blobs_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/languages","stargazers_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/stargazers","contributors_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/contributors","subscribers_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/subscribers","subscription_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/subscription","commits_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/contents/{+path}","compare_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/merges","archive_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/downloads","issues_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues{/number}","pulls_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/labels{/name}","releases_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/releases{/id}","deployments_url":"https://api.github.com/repos/alexcrichton/backtrace-rs/deployments","created_at":"2015-06-10T02:49:08Z","updated_at":"2016-08-15T07:49:13Z","pushed_at":"2016-08-15T18:11:26Z","git_url":"git://github.com/alexcrichton/backtrace-rs.git","ssh_url":"git@github.com:alexcrichton/backtrace-rs.git","clone_url":"https://github.com/alexcrichton/backtrace-rs.git","svn_url":"https://github.com/alexcrichton/backtrace-rs","homepage":null,"size":944,"stargazers_count":15,"watchers_count":15,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":1,"forks":8,"open_issues":1,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15"},"html":{"href":"https://github.com/alexcrichton/backtrace-rs/pull/15"},"issue":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues/15"},"comments":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/alexcrichton/backtrace-rs/statuses/40e0fdbb392fca53f6bb3403cabdf8c12738aaec"}}}}
{"actor":{"display_login":"alexcrichton"}}