From b72b0c2f114d983adc0b1f6d5b5108cdfadf54ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Thu, 4 Oct 2018 16:29:54 +0200 Subject: [PATCH] feat: test des breakpoint par DRx --- include/shell.h | 2 ++ lib/interrupts.c | 9 ++++++++- lib/shell.c | 19 ++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/shell.h b/include/shell.h index 9f01423..ba2043e 100644 --- a/include/shell.h +++ b/include/shell.h @@ -24,3 +24,5 @@ int invalidop(); int segfault(); int int3(); int generalfault(); +int breakpoint(); +void testing(void); diff --git a/lib/interrupts.c b/lib/interrupts.c index b3c7b68..d23e05c 100755 --- a/lib/interrupts.c +++ b/lib/interrupts.c @@ -181,7 +181,14 @@ void exception0() void exception1() { - cpuerror("debug exception",NULL); + cli(); + save_stack dump; + exception_stack_noerror *current = getESP()+0x28+sizeof(save_stack); + dump_cpu(&dump); + dump.eip=current->eip; + dump.cs=current->cs; + dump.esp=(current+1); + cpuerror("debug exception",&dump); } void exception2() diff --git a/lib/shell.c b/lib/shell.c index ceff109..0747ce2 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -28,7 +28,9 @@ static command commands[] = { {"INVALIDOP","", &invalidop}, {"INT3" , "", &int3}, {"GENERALFAULT" , "", &generalfault}, - {"SEGFAULT","", &segfault} + {"SEGFAULT","", &segfault}, + {"BREAKPOINT","", &breakpoint}, + {"TESTING","", &testing} }; /*******************************************************************************/ @@ -62,6 +64,21 @@ void shell() } } +void testing(void) +{ + print("Fonction de test !\r\n"); +} + +/*******************************************************************************/ +/* Génère un breakpoint */ +int breakpoint() +{ + print("Creation d'un breakpoint !\r\n"); + asm("movl %[address],%%dr0 \n \ + movl $0x00000003, %%eax\n \ + movl %%eax, %%dr7"::[address] "a" (&testing):); +} + /*******************************************************************************/ /* Génère une interruption 3 */ int int3()