Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X86-64 kernel backtrace #4

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6fb3df2
x86_64 | paging: expose the PDE.PS bit and the leaf-ness test
deepfire Dec 14, 2016
b25cee3
x86: add rdrip() and rdrsp()
deepfire Dec 14, 2016
a1aae48
x86_64 | mem_to_local_phys: fix docstring
deepfire Dec 14, 2016
c9a85f5
x86_64 | kernel | debug: recognize non-4k pages in debug_vaddr_identify
deepfire Dec 14, 2016
fe1bf2b
kernel | hake: drop an apparently obsolete comment
deepfire Dec 16, 2016
a06227c
kernel | x86-64: provide _start_kernel_text
deepfire Dec 19, 2016
f3023ff
hake: add a config option for stack trace functionality
deepfire Dec 19, 2016
f362eb1
kernel | x86: provide all symbols in .dynsyms, if Config.stack_trace
deepfire Dec 19, 2016
1943e38
kernel | x86: compile with frame pointer, if Config.stack_trace
deepfire Dec 19, 2016
db4d8ca
kernel: add qsort.c, if Config.stack_trace
deepfire Dec 19, 2016
92cdb5e
kernel | x86-64 | debug: backtrace implementation
deepfire Dec 19, 2016
9e293c2
kernel | x86-64 | init: enable stack tracing, if Config.stack_trace
deepfire Dec 19, 2016
9d2a528
kernel | x86: print backtrace on __stack_chk_fail()
deepfire Dec 18, 2016
26eaa3b
nix: provisionally switch to gdb-multitarget
Dec 23, 2016
701e047
qemu-wrapper: use gdb-multiarch where available, fall back to plain gdb
Dec 23, 2016
c23c34f
kernel | x86_64 | init: relocate dynsyms later
Jan 12, 2017
8b4662b
x86 | debug: qemu_debug_puts()
deepfire Dec 19, 2016
c78e6bc
x86 | debug: qemu_debug_printf ()
deepfire Dec 19, 2016
25010f0
kernel | x86_64 | debug: IDT dumping facility
deepfire Dec 18, 2016
333db58
kernel | x86_64 | stackwalker: print the address delta
Jan 12, 2017
2dfa4f0
kernel | x86_64 | stackwalker: avoid misattributions due to local sy…
Jan 12, 2017
86db9bd
qemu-wrapper: write QEMU debug port output to debugcon.out
deepfire Dec 14, 2016
3ee9d31
qemu-wrapper: --display option to allow QEMU show target display
deepfire Dec 18, 2016
ba95644
kernel | x86_64 | stackwalker: use more specific address types, as p…
Jan 12, 2017
5040d46
kernel | x86.h: use more specific address types for rdr{i,s}p(), as …
Jan 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
, cpio
, curl
, gcc5
, gdb
, gdb-multitarget
, git
, gmp
, gnugrep
Expand Down Expand Up @@ -47,7 +47,7 @@ let src-repo = fetchgit {
cpio
curl
gcc5
gdb
gdb-multitarget
git
gmp
gnugrep
Expand Down
5 changes: 5 additions & 0 deletions hake/Config.hs.template
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ microbenchmarks = False
trace :: Bool
trace = False

-- Include code for a runtime stacktrace
stack_trace :: Bool
stack_trace = True

-- Enable QEMU networking. (ie. make network work in small memory)
support_qemu_networking :: Bool
support_qemu_networking = False
Expand Down Expand Up @@ -368,6 +372,7 @@ defines :: [RuleToken]
defines = [ Str ("-D" ++ d) | d <- [
if microbenchmarks then "CONFIG_MICROBENCHMARKS" else "",
if trace then "CONFIG_TRACE" else "",
if stack_trace then "CONFIG_KERNEL_STACK_TRACE" else "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't delete trace/CONFIG_TRACE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antiguru, I have welded in a patch that rectifies this travesty, sorry!

if support_qemu_networking then "CONFIG_QEMU_NETWORK" else "",
if trace_network_subsystem then "NETWORK_STACK_TRACE" else "",
if trace_disable_lrpc then "TRACE_DISABLE_LRPC" else "",
Expand Down
6 changes: 4 additions & 2 deletions hake/X86_32.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ kernelCFlags = [ Str s | s <- [ "-fno-builtin",
"-mno-sse4.2",
"-mno-sse4",
"-mno-sse4a",
"-mno-3dnow" ]]
"-mno-3dnow" ]
++ [ "-fno-omit-frame-pointer" | Config.stack_trace ]]

kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
"-pie",
"-fno-builtin",
"-nostdlib",
"-Wl,--fatal-warnings",
"-m32" ] ]
"-m32" ]
++ [ "-rdynamic" | Config.stack_trace ] ]

--
-- Compilers
Expand Down
8 changes: 5 additions & 3 deletions hake/X86_64.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ kernelCFlags = [ Str s | s <- [ "-fno-builtin",
"-mno-sse4.2",
"-mno-sse4",
"-mno-sse4a",
"-mno-3dnow" ]]
"-mno-3dnow" ]
++ [ "-fno-omit-frame-pointer" | Config.stack_trace ] ]

kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
"-pie",
"-fno-builtin",
"-fno-builtin",
"-nostdlib",
"-Wl,--fatal-warnings",
"-m64" ] ]
"-m64" ]
++ [ "-rdynamic" | Config.stack_trace ] ]


------------------------------------------------------------------------
Expand Down
13 changes: 1 addition & 12 deletions kernel/Hakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
--
--------------------------------------------------------------------------

--
-- Missing from this new Hakefile is the rule to build kernel debug
-- symbols, since this requires some thinking about naming
-- conventions. Here is the rule we need:
--
-- Rule ( [ Str "OBJDUMP=objdump",
-- In SrcTree "src" "/tools/gen-gdbscript.sh",
-- In SrcTree "src" "/tools/debug.gdb.in",
-- In BuildTree arch "../sbin/cpu",
-- Str ">", Out arch "/debug.gdb"
-- ] )

let
scheduler = case Config.scheduler of
Config.RR -> "schedule_rr.c"
Expand All @@ -49,6 +37,7 @@ let
"useraccess.c",
"coreboot.c",
"systime.c" ]
++ (if Config.stack_trace then ["qsort.c"] else [])
++ (if Config.microbenchmarks then ["microbenchmarks.c"] else [])
++ (if Config.oneshot_timer then ["timer.c"] else [])
common_libs = [ "getopt", "mdb_kernel" ]
Expand Down
4 changes: 4 additions & 0 deletions kernel/arch/x86/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ wait_cycles(uint64_t duration)
*/
void __stack_chk_fail(void); // Existence implied by (certainly configured) GCC.

void dump_stack (void);

void __stack_chk_fail (void)
{
printf ("FATAL: stack smashed.\n");
dump_stack ();
panic("finally reached __stack_chk_fail()");
}
Loading