GitHub PullRequestReviewCommentEvent at 2014-02-06 23:50:31
Repository: rust
Actor: FlaPer87
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla/rust/pulls/comments/9524747","id":9524747,"diff_hunk":"@@ -0,0 +1,491 @@\n+// Copyright 2014 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+#[allow(non_camel_case_types)];\n+\n+use char::Char;\n+use container::Container;\n+use from_str::from_str;\n+use io::{IoResult, Writer};\n+use iter::Iterator;\n+use option::{Some, None};\n+use result::{Ok, Err};\n+use str::StrSlice;\n+\n+pub use self::imp::write;\n+\n+// This function is defined in this module so that the way to enable logging of\n+// backtraces has the word 'backtrace' in it: std::rt::backtrace.\n+pub fn log_enabled() -> bool {\n+    log_enabled!(::logging::DEBUG)\n+}\n+\n+#[cfg(target_word_size = \"64\")] static HEX_WIDTH: uint = 18;\n+#[cfg(target_word_size = \"32\")] static HEX_WIDTH: uint = 10;\n+\n+// All rust symbols are in theory lists of \"::\"-separated identifiers. Some\n+// assemblers, however, can't handle these characters in symbol names. To get\n+// around this, we use C++-style mangling. The mangling method is:\n+//\n+// 1. Prefix the symbol with \"_ZN\"\n+// 2. For each element of the path, emit the length plus the element\n+// 3. End the path with \"E\"\n+//\n+// For example, \"_ZN4testE\" => \"test\" and \"_ZN3foo3bar\" => \"foo::bar\".\n+//\n+// We're the ones printing our backtraces, so we can't rely on anything else to\n+// demangle our symbols. It's *much* nicer to look at demangled symbols, so\n+// this function is implemented to give us nice pretty output.\n+//\n+// Note that this demangler isn't quite as fancy as it could be. We have lots\n+// of other information in our symbols like hashes, version, type information,\n+// etc. Additionally, this doesn't handle glue symbols at all.\n+fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {\n+    // First validate the symbol. If it doesn't look like anything we're\n+    // expecting, we just print it literally. Note that we must handle non-rust\n+    // symbols because we could have any function in the backtrace.\n+    let mut valid = true;\n+    if s.len() > 4 && s.starts_with(\"_ZN\") && s.ends_with(\"E\") {\n+        let mut chars = s.slice(3, s.len() - 1).chars();\n+        while valid {","path":"src/libstd/rt/backtrace.rs","position":57,"original_position":57,"commit_id":"5024ad95c0bd115febc5cbea3e64059004a0dbe8","original_commit_id":"5024ad95c0bd115febc5cbea3e64059004a0dbe8","user":{"login":"FlaPer87","id":13816,"avatar_url":"https://gravatar.com/avatar/3d4433e1428f01376f97cc6194e0f071?d=https%3A%2F%2Fidenticons.github.com%2F43b136e4e130934ebda7768e3e728671.png&r=x","gravatar_id":"3d4433e1428f01376f97cc6194e0f071","url":"https://api.github.com/users/FlaPer87","html_url":"https://github.com/FlaPer87","followers_url":"https://api.github.com/users/FlaPer87/followers","following_url":"https://api.github.com/users/FlaPer87/following{/other_user}","gists_url":"https://api.github.com/users/FlaPer87/gists{/gist_id}","starred_url":"https://api.github.com/users/FlaPer87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlaPer87/subscriptions","organizations_url":"https://api.github.com/users/FlaPer87/orgs","repos_url":"https://api.github.com/users/FlaPer87/repos","events_url":"https://api.github.com/users/FlaPer87/events{/privacy}","received_events_url":"https://api.github.com/users/FlaPer87/received_events","type":"User","site_admin":false},"body":"I think this and the `while` below could be merged into a single loop and still print the symbol as-is in case it is not valid. Any reason why you decided to split them?","created_at":"2014-02-06T23:50:31Z","updated_at":"2014-02-06T23:50:31Z","html_url":"https://github.com/mozilla/rust/pull/12070#discussion_r9524747","pull_request_url":"https://api.github.com/repos/mozilla/rust/pulls/12070","_links":{"self":{"href":"https://api.github.com/repos/mozilla/rust/pulls/comments/9524747"},"html":{"href":"https://github.com/mozilla/rust/pull/12070#discussion_r9524747"},"pull_request":{"href":"https://api.github.com/repos/mozilla/rust/pulls/12070"}}}}