Skip to content

Commit

Permalink
Do not force frame pointers by default, they're no longer needed with…
Browse files Browse the repository at this point in the history
… DWARF support
  • Loading branch information
kevinaboos committed Oct 4, 2019
1 parent dfcb813 commit da54328
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 9 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ fn main() {
println!("{}{}", CFG_PREFIX, s);
}

eprintln!("ran build script, configs: {}", configs);
// Since there is no known way to obtain cfg values for codegen options,
// we must manually add the ones used in Theseus.
// Currently, the only codegen option we need to know about is force-frame-pointers
if let Ok(rustflags) = std::env::var("RUSTFLAGS") {
if rustflags.contains("force-frame-pointers=yes") {
println!("{}{}", CFG_PREFIX, "frame_pointers");
}
}

eprintln!("ran build script, configs: {}", configs);
}


Expand Down
14 changes: 8 additions & 6 deletions cfg/Config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ CFG_DIR := $(ROOT_DIR)/cfg
KERNEL_PREFIX ?= k\#
APP_PREFIX ?= a\#

### NOTE: CURRENTLY FORCING RELEASE MODE UNTIL HASH-BASED SYMBOL RESOLUTION IS WORKING
## Build modes: debug is default (dev mode), release is release with full optimizations.
## Build modes: debug is development mode, release is with full optimizations.
## We build using release mode by default, because running in debug mode is prohibitively slow.
## You can set these on the command line like so: "make run BUILD_MODE=release"
# BUILD_MODE ?= debug
BUILD_MODE ?= release
Expand Down Expand Up @@ -60,7 +60,9 @@ RUSTFLAGS += -Z share-generics=no

## This forces frame pointers to be generated, i.e., the stack base pointer (RBP register on x86_64)
## will be used to store the starting address of the current stack frame.
## This is used for stack unwinding purposes, in order to trace back up the call stack.
## If/when we support using DWARF .debug_* sections to obtain the size of the current stack frame,
## we can remove/disable this, since we won't need to use RBP anymore.
RUSTFLAGS += -C force-frame-pointers=yes
## This can be used for obtaining a backtrace/stack trace,
## but isn't necessary because Theseus supports parsing DWARF .debug_* sections to handle stack unwinding.
## Note that this reduces the number of registers available to the compiler (by reserving RBP),
## so it often results in slightly lowered performance.
## By default, this is not enabled.
# RUSTFLAGS += -C force-frame-pointers=yes
2 changes: 2 additions & 0 deletions kernel/panic_wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub fn panic_wrapper(panic_info: &PanicInfo) -> Result<(), &'static str> {
// }
// }

#[cfg(frame_pointers)]
stack_trace_using_frame_pointer(
&mmi_ref.lock().page_table,
&|instruction_pointer: VirtualAddress| {
Expand Down Expand Up @@ -104,6 +105,7 @@ pub fn panic_wrapper(panic_info: &PanicInfo) -> Result<(), &'static str> {
/// If the compiler didn't emit frame pointers, then this function will not work.
///
/// This was adapted from Redox's stack trace implementation.
#[cfg(frame_pointers)]
#[inline(never)]
pub fn stack_trace_using_frame_pointer(
current_page_table: &PageTable,
Expand Down

0 comments on commit da54328

Please sign in to comment.