Merge pull request #1 from jiegec/master

Fix AArch64 toolchain downloading in Travis CI
toolchain_update
Chen 6 years ago committed by GitHub
commit 3690a4ea3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,9 +40,9 @@ install:
fi fi
- if [ $ARCH = aarch64 ]; then - if [ $ARCH = aarch64 ]; then
if [ $TRAVIS_OS_NAME = linux ]; then if [ $TRAVIS_OS_NAME = linux ]; then
wget https://web.stanford.edu/class/cs140e/files/aarch64-none-elf-linux-x64.tar.gz; wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2018.11/gcc-arm-8.2-2018.11-x86_64-aarch64-elf.tar.xz;
tar -xzvf aarch64-none-elf-linux-x64.tar.gz; tar -xvf gcc-arm-8.2-2018.11-x86_64-aarch64-elf.tar.xz;
export PATH=$PATH:$PWD/aarch64-none-elf/bin; export PATH=$PATH:$PWD/gcc-arm-8.2-2018.11-x86_64-aarch64-elf/bin;
elif [ $TRAVIS_OS_NAME = osx ]; then elif [ $TRAVIS_OS_NAME = osx ]; then
brew tap SergioBenitez/osxct; brew tap SergioBenitez/osxct;
brew install aarch64-none-elf; brew install aarch64-none-elf;

@ -5,6 +5,7 @@
# make doc Generate docs # make doc Generate docs
# make asm Open the deassemble file of the last build # make asm Open the deassemble file of the last build
# make header Open 'objdump -h' of the last build # make header Open 'objdump -h' of the last build
# make addr2line Use addr2line to recover line info in backtrace
# make clean Clean # make clean Clean
# #
# Options: # Options:
@ -141,6 +142,9 @@ else ifeq ($(arch), riscv64)
prefix := riscv64-unknown-elf- prefix := riscv64-unknown-elf-
else ifeq ($(arch), aarch64) else ifeq ($(arch), aarch64)
prefix ?= aarch64-none-elf- prefix ?= aarch64-none-elf-
ifeq (,$(shell which $(prefix)ld))
prefix := aarch64-elf-
endif
endif endif
ld := $(prefix)ld ld := $(prefix)ld
@ -258,4 +262,8 @@ ifeq ($(board), k210)
install: $(bin) install: $(bin)
## baudrate no more than 600000 ## baudrate no more than 600000
@python3 ../tools/k210/kflash.py $(bin) -b 600000 @python3 ../tools/k210/kflash.py $(bin) -b 600000
endif endif
.PHONY:
addr2line:
@python3 ../tools/addr2line.py $(prefix)addr2line $(arch)

@ -102,6 +102,9 @@ then
elif [[ -d $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.4 ]] elif [[ -d $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.4 ]]
then then
COMPILER_BUILTINS_PATH=$CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.4 COMPILER_BUILTINS_PATH=$CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.4
elif [[ -d $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.5 ]]
then
COMPILER_BUILTINS_PATH=$CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.5
else else
echo "Cannot find compiler_builtins crate! Please file an issue report" echo "Cannot find compiler_builtins crate! Please file an issue report"
fi fi

@ -0,0 +1,66 @@
use core::mem::size_of;
extern "C" {
fn stext();
fn etext();
}
/// Returns the current frame pointer.
#[inline(always)]
#[cfg(any(target_arch = "aarch64", target_arch = "riscv32", target_arch = "riscv64"))]
pub fn fp() -> usize {
let ptr: usize;
#[cfg(target_arch = "aarch64")]
unsafe {
asm!("mov $0, x29" : "=r"(ptr));
}
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
unsafe {
asm!("mv $0, s0" : "=r"(ptr));
}
ptr
}
/// Returns the current link register.
#[inline(always)]
#[cfg(any(target_arch = "aarch64", target_arch = "riscv32", target_arch = "riscv64"))]
pub fn lr() -> usize {
let ptr: usize;
#[cfg(target_arch = "aarch64")]
unsafe {
asm!("mov $0, x30" : "=r"(ptr));
}
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
unsafe {
asm!("mv $0, ra" : "=r"(ptr));
}
ptr
}
// Print the backtrace starting from the caller
pub fn backtrace() {
#[cfg(any(target_arch = "aarch64", target_arch = "riscv32", target_arch = "riscv64"))]
unsafe {
let mut current_pc = lr();
let mut current_fp = fp();
let mut stack_num = 0;
while current_pc >= stext as usize && current_pc <= etext as usize && current_fp as usize != 0 {
println!("#{} {:#018X} fp {:#018X}", stack_num, current_pc - size_of::<usize>(), current_fp);
stack_num = stack_num + 1;
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
{
current_fp = *(current_fp as *const usize).offset(-2);
current_pc = *(current_fp as *const usize).offset(-1);
}
#[cfg(target_arch = "aarch64")]
{
current_fp = *(current_fp as *const usize);
if current_fp != 0 {
current_pc = *(current_fp as *const usize).offset(1);
}
}
}
}
}

@ -3,6 +3,7 @@
use core::panic::PanicInfo; use core::panic::PanicInfo;
use core::alloc::Layout; use core::alloc::Layout;
use log::*; use log::*;
use crate::backtrace;
#[lang = "eh_personality"] #[lang = "eh_personality"]
extern fn eh_personality() { extern fn eh_personality() {
@ -13,6 +14,7 @@ fn panic(info: &PanicInfo) -> ! {
let location = info.location().unwrap(); let location = info.location().unwrap();
let message = info.message().unwrap(); let message = info.message().unwrap();
error!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message); error!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message);
backtrace::backtrace();
loop { crate::arch::cpu::halt() } loop { crate::arch::cpu::halt() }
} }

@ -28,6 +28,7 @@ mod fs;
mod sync; mod sync;
mod trap; mod trap;
mod shell; mod shell;
mod backtrace;
#[allow(dead_code)] #[allow(dead_code)]
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]

@ -31,5 +31,6 @@
"target-endian": "little", "target-endian": "little",
"target-pointer-width": "64", "target-pointer-width": "64",
"target-family": "unix", "target-family": "unix",
"disable-redzone": true "disable-redzone": true,
"eliminate-frame-pointer": false
} }

@ -31,5 +31,6 @@
"ptx-kernel", "ptx-kernel",
"msp430-interrupt", "msp430-interrupt",
"x86-interrupt" "x86-interrupt"
] ],
"eliminate-frame-pointer": false
} }

@ -31,5 +31,6 @@
"ptx-kernel", "ptx-kernel",
"msp430-interrupt", "msp430-interrupt",
"x86-interrupt" "x86-interrupt"
] ],
"eliminate-frame-pointer": false
} }

@ -0,0 +1,19 @@
#!/usr/bin/env python3
import sys
import re
import subprocess
print('Paste backtrace here, and then input EOF(Ctrl-D or Ctrl-Z) to get annotated backtrace.')
lines = sys.stdin.readlines()
addrline = sys.argv[1]
arch = sys.argv[2]
print('--------------------------------------')
for line in lines:
match = re.search('(#[0-9]+ )(0x[0-9A-F]+)( fp 0x[0-9A-F]+)', line)
if match:
addr = match.group(2)
process = subprocess.run([addrline, '-e', 'target/{0}/debug/rcore'.format(arch), '-f', '-C', addr], capture_output=True)
res = process.stdout.decode('utf-8')
print('{0}{1}{3} {2}'.format(match.group(1), match.group(2), res.strip(), match.group(3)))
else:
print(line, end='')
Loading…
Cancel
Save