Retire calltrace support in favor of the kernel debugger.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-08-05 00:39:59 +02:00
parent c24b5ee5a4
commit 35708fa900
14 changed files with 0 additions and 429 deletions

View File

@ -5,7 +5,6 @@ include ../dirs.mak
# Default values in case the user doesn't override these variables.
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CALLTRACE?=0
DISKWRITE?=1
CPPFLAGS?=
CXXFLAGS?=$(OPTLEVEL)
@ -20,7 +19,6 @@ ifeq ($(PANIC_SHORT),1)
CPPFLAGS:=$(CPPFLAGS) -DPANIC_SHORT
endif
CPPFLAGS:=$(CPPFLAGS) -DENABLE_DISKWRITE=$(DISKWRITE)
CPPFLAGS:=$(CPPFLAGS) -DENABLE_CALLTRACE=$(CALLTRACE)
ifdef VERSION
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
endif
@ -75,11 +73,9 @@ $(CPUOBJS) \
addralloc.o \
alarm.o \
ata.o \
calltrace.o \
clock.o \
com.o \
copy.o \
$(CPU)/calltrace.o \
$(CPU)/kthread.o \
crc32.o \
debugger.o \

View File

@ -1,44 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012, 2013.
This file is part of Sortix.
Sortix is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
calltrace.cpp
Traverses the stack and prints the callstack, which aids debugging.
*******************************************************************************/
#include <sortix/kernel/calltrace.h>
#include <sortix/kernel/kernel.h>
namespace Sortix {
namespace Calltrace {
extern "C" void calltrace(unsigned long ptr);
extern "C" void calltrace_print_function(size_t index, addr_t ip)
{
Log::PrintF("%zu: 0x%zx\n", index, ip);
}
void Perform(unsigned long ptr)
{
Log::PrintF("Calltrace:\n");
calltrace(ptr);
}
} // namespace Calltrace
} // namespace Sortix

View File

@ -1,36 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012, 2013.
This file is part of Sortix.
Sortix is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
sortix/kernel/calltrace.h
Traverses the stack and prints the callstack, which aids debugging.
*******************************************************************************/
#ifndef INCLUDE_SORTIX_KERNEL_CALLTRACE_H
#define INCLUDE_SORTIX_KERNEL_CALLTRACE_H
namespace Sortix {
namespace Calltrace {
void Perform(unsigned long ptr = 0);
} // namespace Calltrace
} // namespace Sortix
#endif

View File

@ -26,7 +26,6 @@
#include <errno.h>
#include <string.h>
#include <sortix/kernel/calltrace.h>
#include <sortix/kernel/cpu.h>
#include <sortix/kernel/debugger.h>
#include <sortix/kernel/interrupt.h>

View File

@ -25,7 +25,6 @@
#include <brand.h>
#include <string.h>
#include <sortix/kernel/calltrace.h>
#include <sortix/kernel/interrupt.h>
#include <sortix/kernel/kernel.h>
#include <sortix/kernel/log.h>
@ -116,18 +115,10 @@ void PanicInit()
longpanic ? PanicLogoLong() : PanicLogoShort();
}
static void PanicCalltrace()
{
Log::Print("\n");
Calltrace::Perform();
}
static void PanicHooks()
{
if ( doublepanic )
return;
if ( ENABLE_CALLTRACE )
PanicCalltrace();
}
extern "C" __attribute__((noreturn)) void Panic(const char* error)

View File

@ -1,57 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012, 2013.
This file is part of Sortix.
Sortix is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
x64/calltrace.S
Attempts to unwind the stack and prints the code locations where functions
were called. This greatly aids debugging.
*******************************************************************************/
.section .text
.global calltrace
.type calltrace, @function
calltrace:
push %rbp
push %rbx
movq %rsp, %rbp
push %rbx
movq %rdi, %rbx
testq %rbx, %rbx
jnz 1f
movq %rbp, %rbx
1:
xorl %edi, %edi
calltrace_unwind:
testq %rbx, %rbx
jz calltrace_done
movq 8(%rbx), %rsi # Previous RIP
movq 0(%rbx), %rbx # Previous RBP
pushq %rdi
call calltrace_print_function
popq %rdi
incq %rdi
jmp calltrace_unwind
calltrace_done:
popq %rbx
popq %rbp
retq
.size calltrace, . - calltrace

View File

@ -28,7 +28,6 @@
#include <stdint.h>
#include <string.h>
#include <sortix/kernel/calltrace.h>
#include <sortix/kernel/cpu.h>
#include <sortix/kernel/debugger.h>
#include <sortix/kernel/interrupt.h>
@ -104,8 +103,6 @@ namespace Interrupt {
extern "C" { unsigned long asm_is_cpu_interrupted = 0; }
const bool CALLTRACE_KERNEL = false;
const bool CALLTRACE_USER = false;
const bool RUN_DEBUGGER_ON_KERNEL_CRASH = false;
const bool RUN_DEBUGGER_ON_USER_CRASH = false;
@ -260,26 +257,11 @@ uintptr_t ExceptionLocation(const struct interrupt_context* intctx)
#endif
}
void CrashCalltrace(const struct interrupt_context* intctx)
{
#if defined(__x86_64__)
Calltrace::Perform(intctx->rbp);
#elif defined(__i386__)
Calltrace::Perform(intctx->ebp);
#else
#warning "Please provide a calltrace implementation for your CPU."
#endif
}
__attribute__((noreturn))
void KernelCrashHandler(struct interrupt_context* intctx)
{
Scheduler::SaveInterruptedContext(intctx, &CurrentThread()->registers);
// Walk and print the stack frames if this is a debug build.
if ( CALLTRACE_KERNEL )
CrashCalltrace(intctx);
// Possibly switch to the kernel debugger in event of a crash.
if ( RUN_DEBUGGER_ON_KERNEL_CRASH )
Debugger::Run(false);
@ -310,10 +292,6 @@ void UserCrashHandler(struct interrupt_context* intctx)
return Signal::DispatchHandler(intctx, NULL);
}
// Walk and print the stack frames if this is a debug build.
if ( CALLTRACE_USER )
CrashCalltrace(intctx);
// Possibly switch to the kernel debugger in event of a crash.
if ( RUN_DEBUGGER_ON_USER_CRASH )
Debugger::Run(false);

View File

@ -1,59 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012, 2013.
This file is part of Sortix.
Sortix is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
x86/calltrace.S
Attempts to unwind the stack and prints the code locations where functions
were called. This greatly aids debugging.
*******************************************************************************/
.section .text
.global calltrace
.type calltrace, @function
calltrace:
push %ebp
push %ebx
movl %esp, %ebp
push %ebx
movl 8(%ebp), %ebx
testl %ebx, %ebx
jnz 1f
movl %ebp, %ebx
1:
xorl %edi, %edi
calltrace_unwind:
testl %ebx, %ebx
jz calltrace_done
movl 4(%ebx), %esi # Previous EIP
movl 0(%ebx), %ebx # Previous EBP
pushl %esi
pushl %edi
call calltrace_print_function
popl %edi
addl $4, %esp
incl %edi
jmp calltrace_unwind
calltrace_done:
popl %ebx
popl %ebp
retl
.size calltrace, . - calltrace

View File

@ -313,8 +313,6 @@ arpa/inet/inet_addr.o \
arpa/inet/inet_ntoa.o \
arpa/inet/inet_ntop.o \
arpa/inet/inet_pton.o \
calltrace/calltrace.o \
$(CPUDIR)/calltrace.o \
$(CPUDIR)/fork.o \
$(CPUDIR)/setjmp.o \
$(CPUDIR)/signal.o \

View File

@ -1,44 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
calltrace/calltrace.cpp
Traverses the stack and prints the callstack.
*******************************************************************************/
#include <calltrace.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
extern "C" void asm_calltrace();
extern "C" void calltrace_print_function(size_t index, unsigned long ip)
{
fprintf(stdout, "[pid=%ji %s] %zu: 0x%lx\n", (intmax_t) getpid(),
program_invocation_short_name, index, ip);
}
extern "C" void calltrace()
{
fprintf(stdout, "[pid=%ji %s] Calltrace: (%s)\n", (intmax_t) getpid(),
program_invocation_short_name, program_invocation_name);
asm_calltrace();
}

View File

@ -1,36 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
calltrace.h
Traverses the stack and prints the callstack.
*******************************************************************************/
#ifndef _CALLTRACE_H
#define _CALLTRACE_H 1
#include <sys/cdefs.h>
__BEGIN_DECLS
void calltrace();
__END_DECLS
#endif

View File

@ -25,7 +25,6 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <calltrace.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
@ -44,12 +43,6 @@ extern "C" void abort(void)
extern "C" void abort(void)
{
struct stat st;
if ( stat("/etc/calltrace", &st) == 0 )
calltrace();
if ( stat("/etc/calltrace_loop", &st) == 0 )
while ( true );
sigset_t set_of_sigabrt;
sigemptyset(&set_of_sigabrt);
sigaddset(&set_of_sigabrt, SIGABRT);

View File

@ -1,53 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
x64/calltrace.S
Attempts to unwind the stack and prints the code locations where functions
were called. This greatly aids debugging.
*******************************************************************************/
.global asm_calltrace
.type asm_calltrace, @function
asm_calltrace:
push %rbp
mov %rsp, %rbp
push %rbx
push %r12
xor %r12, %r12
mov %rbp, %rbx
.Lasm_calltrace_unwind:
test %rbx, %rbx
jz .Lasm_calltrace_done
mov 8(%rbx), %rsi # Previous RIP
mov 0(%rbx), %rbx # Previous RBP
test %rsi, %rsi
jz .Lasm_calltrace_done
mov %r12, %rdi
call calltrace_print_function
inc %r12
jmp .Lasm_calltrace_unwind
.Lasm_calltrace_done:
pop %r12
pop %rbx
pop %rbp
ret
.size asm_calltrace, . - asm_calltrace

View File

@ -1,55 +0,0 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
x86/calltrace.S
Attempts to unwind the stack and prints the code locations where functions
were called. This greatly aids debugging.
*******************************************************************************/
.global asm_calltrace
.type asm_calltrace, @function
asm_calltrace:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
xor %esi, %esi
mov %ebp, %ebx
.Lasm_calltrace_unwind:
test %ebx, %ebx
jz .Lasm_calltrace_done
mov 4(%ebx), %ecx # Previous EIP
mov 0(%ebx), %ebx # Previous EBP
test %ecx, %ecx
jz .Lasm_calltrace_done
push %ecx
push %esi
call calltrace_print_function
add $8, %esp
inc %esi
jmp .Lasm_calltrace_unwind
.Lasm_calltrace_done:
pop %esi
pop %ebx
pop %ebp
ret
.size asm_calltrace, . - asm_calltrace