aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo/main.rs
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2016-07-29 13:08:21 -0500
committerAlan Jeffrey <ajeffrey@mozilla.com>2016-08-10 17:39:29 -0700
commit341b9de43b1c2bc05f73e08cb1e0155de86c63eb (patch)
treefad0ad39f4149449405f26e33f68e62d8e095a2d /components/servo/main.rs
parent0f1a9f109deedfa9c059da1ee7413f0894503fba (diff)
downloadservo-341b9de43b1c2bc05f73e08cb1e0155de86c63eb.tar.gz
servo-341b9de43b1c2bc05f73e08cb1e0155de86c63eb.zip
Print backtraces for panics, even if the constellation has closed.
Diffstat (limited to 'components/servo/main.rs')
-rw-r--r--components/servo/main.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/components/servo/main.rs b/components/servo/main.rs
index 7da24dd1dc2..321c41f9716 100644
--- a/components/servo/main.rs
+++ b/components/servo/main.rs
@@ -34,10 +34,12 @@ extern crate servo;
#[macro_use]
extern crate sig;
+use backtrace::Backtrace;
use servo::Browser;
use servo::compositing::windowing::WindowEvent;
use servo::util::opts::{self, ArgumentParsingResult};
use servo::util::servo_version;
+use std::env;
use std::panic;
use std::process;
use std::rc::Rc;
@@ -97,8 +99,8 @@ fn main() {
None
};
- // TODO: once log-panics is released, this can be replaced by
- // log_panics::init();
+ // TODO: once log-panics is released, can this be replaced by
+ // log_panics::init()?
panic::set_hook(Box::new(|info| {
warn!("Panic hook called.");
let msg = match info.payload().downcast_ref::<&'static str>() {
@@ -111,10 +113,15 @@ fn main() {
let current_thread = thread::current();
let name = current_thread.name().unwrap_or("<unnamed>");
if let Some(location) = info.location() {
- error!("{} (thread {}, at {}:{})", msg, name, location.file(), location.line());
+ println!("{} (thread {}, at {}:{})", msg, name, location.file(), location.line());
} else {
- error!("{} (thread {})", msg, name);
+ println!("{} (thread {})", msg, name);
}
+ if env::var("RUST_BACKTRACE").is_ok() {
+ println!("{:?}", Backtrace::new());
+ }
+
+ error!("{}", msg);
}));
setup_logging();