From ddb696ec798833000a7cfe20d8244fb4367bc90a Mon Sep 17 00:00:00 2001 From: ocoursiere Date: Thu, 8 Jan 2004 23:41:24 +0000 Subject: [PATCH] debugger.pp is now working well (see also mydebugger.pp in the demos folder) --- .../bepascal/pas/src/be/kernel/debugger.pp | 160 ++++++--- .../bepascal/pas/src/be/posix/signal.pp | 321 ++++++++++++++++++ 2 files changed, 441 insertions(+), 40 deletions(-) create mode 100644 bepascal/source/bepascal/pas/src/be/posix/signal.pp diff --git a/bepascal/source/bepascal/pas/src/be/kernel/debugger.pp b/bepascal/source/bepascal/pas/src/be/kernel/debugger.pp index 9c0b56b..7900a2e 100644 --- a/bepascal/source/bepascal/pas/src/be/kernel/debugger.pp +++ b/bepascal/source/bepascal/pas/src/be/kernel/debugger.pp @@ -1,15 +1,31 @@ +{ BePascal - A pascal wrapper around the BeOS API + Copyright (C) 2002-2004 Oscar Lesta + Olivier Coursiere + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +} unit debugger; // Description: kernel interface for a debugger. interface uses -{.$ifdef CPUI386} -// signal, -{.$endif CPUI386} -// BeBuild, - OS, image, SupportDefs; - +{$ifdef CPUI386} + signal, +{$endif CPUI386} + {BeBuild,} OS, image, SupportDefs; // kernel calls function install_default_debugger(to_debugger_port : port_id) : status_t; @@ -21,6 +37,12 @@ function remove_team_debugger(team : team_id) : status_t; function debug_thread(thread : thread_id) : status_t; cdecl; external 'root' name 'debug_thread'; +// undocumented syscall to trace syscalls +// this function is used to configure the tracing level +// (see also DEBUG_* const at the end of this file) +function strace_init(thread : thread_id; flags : Cardinal) : status_t; + cdecl; external 'root' name '_kstrace_init_'; + { per-thread debugging flags (returned by the get_thread_debug_info request to the debugging nub) } const @@ -163,8 +185,7 @@ type general registers. } type cpu_state = packed record -// this one is in posix/signal.h -// xregs : extended_regs; // fpu/mmx/xmm registers + xregs : extended_regs; // fpu/mmx/xmm registers gs, reserved0, fs, @@ -183,11 +204,11 @@ type eax, trap_no, // trap or int number error_code, // trap error code - eip : Longword; // user eip + eip : Cardinal; // user eip cs, // user cs reserved4 : Word; eflags, // user elfags - uesp : Longword; // user esp + uesp : Cardinal; // user esp ss, // user ss reserved5 : Word; end; @@ -361,25 +382,64 @@ type // union of all stuctures passed to the nub to_nub_msg = packed record - nub_read_memory : nub_read_memory_msg; - nub_write_memory : nub_write_memory_msg; - nub_run_thread : nub_run_thread_msg; - nub_step_thread : nub_step_thread_msg; - nub_step_over_thread : nub_step_over_thread_msg; - nub_step_out_thread : nub_step_out_thread_msg; - nub_set_breakpoint : nub_set_breakpoint_msg; - nub_clear_breakpoint : nub_clear_breakpoint_msg; - nub_stop_new_threads : nub_stop_new_threads_msg; - nub_get_thread_debug_info : nub_get_thread_debug_info_msg; - nub_acknowlege_image_created : nub_acknowlege_image_created_msg; - nub_start_profiler : nub_start_profiler_msg; - nub_stop_profiler : nub_stop_profiler_msg; - nub_set_watchpoint : nub_set_watchpoint_msg; - nub_clear_watchpoint : nub_clear_watchpoint_msg; - nub_stop_on_debug : nub_stop_on_debug_msg; - nub_get_thread_stack_top : nub_get_thread_stack_top_msg; - nub_handoff : nub_handoff_msg; - nub_get_why_stopped : nub_get_why_stopped_msg; + case Integer of + 0: ( + nub_read_memory : nub_read_memory_msg; + ); + 1: ( + nub_write_memory : nub_write_memory_msg; + ); + 2: ( + nub_run_thread : nub_run_thread_msg; + ); + 3: ( + nub_step_thread : nub_step_thread_msg; + ); + 4: ( + nub_step_over_thread : nub_step_over_thread_msg; + ); + 5: ( + nub_step_out_thread : nub_step_out_thread_msg; + ); + 6: ( + nub_set_breakpoint : nub_set_breakpoint_msg; + ); + 7: ( + nub_clear_breakpoint : nub_clear_breakpoint_msg; + ); + 8: ( + nub_stop_new_threads : nub_stop_new_threads_msg; + ); + 9: ( + nub_get_thread_debug_info : nub_get_thread_debug_info_msg; + ); + 10: ( + nub_acknowlege_image_created : nub_acknowlege_image_created_msg; + ); + 11: ( + nub_start_profiler : nub_start_profiler_msg; + ); + 12: ( + nub_stop_profiler : nub_stop_profiler_msg; + ); + 13: ( + nub_set_watchpoint : nub_set_watchpoint_msg; + ); + 14: ( + nub_clear_watchpoint : nub_clear_watchpoint_msg; + ); + 15: ( + nub_stop_on_debug : nub_stop_on_debug_msg; + ); + 16: ( + nub_get_thread_stack_top : nub_get_thread_stack_top_msg; + ); + 17: ( + nub_handoff : nub_handoff_msg; + ); + 18: ( + nub_get_why_stopped : nub_get_why_stopped_msg; + ); end; { messages passed to the external debugger @@ -395,7 +455,8 @@ type {$ifdef POWERPC} B_PEF_IMAGE_CREATED, // pef image was created B_PEF_IMAGE_DELETED, // pef image was deleted -{$elif CPUI386} +{$endif} +{$ifdef CPUI386} B_ELF_IMAGE_CREATED, // pe image was created B_ELF_IMAGE_DELETED, // pe image was deleted {$endif} @@ -465,15 +526,34 @@ type // union of all structures passed to external debugger to_debugger_msg = packed record - thread_stopped : db_thread_stopped_msg; - team_created : db_team_created_msg; - team_deleted : db_team_deleted_msg; - pef_image_created : db_pef_image_created_msg; - pef_image_deleted : db_pef_image_deleted_msg; - thread_created : db_thread_created_msg; - thread_deleted : db_thread_deleted_msg; - get_profile_info : db_get_profile_info_msg; - syscall_post : db_syscall_post_msg; + case Integer of + 0: ( + thread_stopped : db_thread_stopped_msg; + ); + 1: ( + team_created : db_team_created_msg; + ); + 2: ( + team_deleted : db_team_deleted_msg; + ); + 3: ( + pef_image_created : db_pef_image_created_msg; + ); + 4: ( + pef_image_deleted : db_pef_image_deleted_msg; + ); + 5: ( + thread_created : db_thread_created_msg; + ); + 6: ( + thread_deleted : db_thread_deleted_msg; + ); + 7: ( + get_profile_info : db_get_profile_info_msg; + ); + 8: ( + syscall_post : db_syscall_post_msg; + ); end; { @@ -492,4 +572,4 @@ const implementation -end. \ No newline at end of file +end. diff --git a/bepascal/source/bepascal/pas/src/be/posix/signal.pp b/bepascal/source/bepascal/pas/src/be/posix/signal.pp new file mode 100644 index 0000000..f9689bb --- /dev/null +++ b/bepascal/source/bepascal/pas/src/be/posix/signal.pp @@ -0,0 +1,321 @@ +{ BePascal - A pascal wrapper around the BeOS API + Copyright (C) 2004 Olivier Coursiere + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +} +unit signal; + +interface + +(* +typedef struct packed_fp_stack { + unsigned char st0[10]; + unsigned char st1[10]; + unsigned char st2[10]; + unsigned char st3[10]; + unsigned char st4[10]; + unsigned char st5[10]; + unsigned char st6[10]; + unsigned char st7[10]; +} packed_fp_stack; +*) + +type + packed_fp_stack = packed record + st0 : array[0..9] of Byte; + st1 : array[0..9] of Byte; + st2 : array[0..9] of Byte; + st3 : array[0..9] of Byte; + st4 : array[0..9] of Byte; + st5 : array[0..9] of Byte; + st6 : array[0..9] of Byte; + st7 : array[0..9] of Byte; + end; + +(* +typedef struct packed_mmx_regs { + unsigned char mm0[10]; + unsigned char mm1[10]; + unsigned char mm2[10]; + unsigned char mm3[10]; + unsigned char mm4[10]; + unsigned char mm5[10]; + unsigned char mm6[10]; + unsigned char mm7[10]; +} packed_mmx_regs; +*) + +type + packed_mmx_regs = packed record + mm0 : array[0..9] of Byte; + mm1 : array[0..9] of Byte; + mm2 : array[0..9] of Byte; + mm3 : array[0..9] of Byte; + mm4 : array[0..9] of Byte; + mm5 : array[0..9] of Byte; + mm6 : array[0..9] of Byte; + mm7 : array[0..9] of Byte; + end; + +(* +typedef struct old_extended_regs { + unsigned short fp_control; + unsigned short _reserved1; + unsigned short fp_status; + unsigned short _reserved2; + unsigned short fp_tag; + unsigned short _reserved3; + unsigned long fp_eip; + unsigned short fp_cs; + unsigned short fp_opcode; + unsigned long fp_datap; + unsigned short fp_ds; + unsigned short _reserved4; + union { + packed_fp_stack fp; + packed_mmx_regs mmx; + } fp_mmx; +} old_extended_regs; +*) + +type + old_extended_regs = packed record + fp_control : word; + _reserved1 : word; + fp_status : word; + _reserved2 : word; + fp_tag : word; + _reserved3 : word; + fp_eip : cardinal; + fp_cs : word; + fp_opcode : word; + fp_datap : cardinal; + fp_ds : word; + _reserved4 : word; + case integer of + 1 : ( + fp : packed_fp_stack + ); + 2 : ( + mmx : packed_mmx_regs + ); + end; + +(* +typedef struct fp_stack { + unsigned char st0[10]; + unsigned char _reserved_42_47[6]; + unsigned char st1[10]; + unsigned char _reserved_58_63[6]; + unsigned char st2[10]; + unsigned char _reserved_74_79[6]; + unsigned char st3[10]; + unsigned char _reserved_90_95[6]; + unsigned char st4[10]; + unsigned char _reserved_106_111[6]; + unsigned char st5[10]; + unsigned char _reserved_122_127[6]; + unsigned char st6[10]; + unsigned char _reserved_138_143[6]; + unsigned char st7[10]; + unsigned char _reserved_154_159[6]; +} fp_stack; +*) + +type + fp_stack = packed record + st0 : array[0..9] of Byte; + _reserved_42_47 : array[0..5] of Byte; + st1 : array[0..9] of Byte; + _reserved_58_63 : array[0..5] of Byte; + st2 : array[0..9] of Byte; + _reserved_74_79 : array[0..5] of Byte; + st3 : array[0..9] of Byte; + _reserved_90_95 : array[0..5] of Byte; + st4 : array[0..9] of Byte; + _reserved_106_111 : array[0..5] of Byte; + st5 : array[0..9] of Byte; + _reserved_122_127 : array[0..5] of Byte; + st6 : array[0..9] of Byte; + _reserved_138_143 : array[0..5] of Byte; + st7 : array[0..9] of Byte; + _reserved_154_159 : array[0..5] of Byte; + end; + +(* +typedef struct mmx_regs { + unsigned char mm0[10]; + unsigned char _reserved_42_47[6]; + unsigned char mm1[10]; + unsigned char _reserved_58_63[6]; + unsigned char mm2[10]; + unsigned char _reserved_74_79[6]; + unsigned char mm3[10]; + unsigned char _reserved_90_95[6]; + unsigned char mm4[10]; + unsigned char _reserved_106_111[6]; + unsigned char mm5[10]; + unsigned char _reserved_122_127[6]; + unsigned char mm6[10]; + unsigned char _reserved_138_143[6]; + unsigned char mm7[10]; + unsigned char _reserved_154_159[6]; +} mmx_regs; +*) + +type + mmx_regs = packed record + mm0 : array[0..9] of Byte; + _reserved_42_47 : array[0..5] of Byte; + mm1 : array[0..9] of Byte; + _reserved_58_63 : array[0..5] of Byte; + mm2 : array[0..9] of Byte; + _reserved_74_79 : array[0..5] of Byte; + mm3 : array[0..9] of Byte; + _reserved_90_95 : array[0..5] of Byte; + mm4 : array[0..9] of Byte; + _reserved_106_111 : array[0..5] of Byte; + mm5 : array[0..9] of Byte; + _reserved_122_127 : array[0..5] of Byte; + mm6 : array[0..9] of Byte; + _reserved_138_143 : array[0..5] of Byte; + mm7 : array[0..9] of Byte; + _reserved_154_159 : array[0..5] of Byte; + end; +(* +typedef struct xmmx_regs { + unsigned char xmm0[16]; + unsigned char xmm1[16]; + unsigned char xmm2[16]; + unsigned char xmm3[16]; + unsigned char xmm4[16]; + unsigned char xmm5[16]; + unsigned char xmm6[16]; + unsigned char xmm7[16]; +} xmmx_regs; +*) + +type + xmmx_regs = packed record + xmm0 : array[0..15] of Byte; + xmm1 : array[0..15] of Byte; + xmm2 : array[0..15] of Byte; + xmm3 : array[0..15] of Byte; + xmm4 : array[0..15] of Byte; + xmm5 : array[0..15] of Byte; + xmm6 : array[0..15] of Byte; + xmm7 : array[0..15] of Byte; + end; +(* +typedef struct new_extended_regs { + unsigned short fp_control; + unsigned short fp_status; + unsigned short fp_tag; + unsigned short fp_opcode; + unsigned long fp_eip; + unsigned short fp_cs; + unsigned short res_14_15; + unsigned long fp_datap; + unsigned short fp_ds; + unsigned short _reserved_22_23; + unsigned long mxcsr; + unsigned long _reserved_28_31; + union { + fp_stack fp; + mmx_regs mmx; + } fp_mmx; + xmmx_regs xmmx; + unsigned char _reserved_288_511[224]; +} new_extended_regs; +*) + +type + new_extended_regs = packed record + fp_control : word; + fp_status : word; + fp_tag : word; + fp_opcode : word; + fp_eip : cardinal; + fp_cs : word; + res_14_15 : word; + fp_datap : cardinal; + fp_ds : word; + _reserved_22_23 : word; + mxcsr : cardinal; + _reserved_28_31 : cardinal; + fp_mmx : packed record + case integer of + 1 : ( + fp : fp_stack + ); + 2 : ( + mmx : mmx_regs + ); + end; + xmmx : xmmx_regs; + _reserved_288_511 : array[0..223] of Byte; + end; + +(* +typedef struct extended_regs { + union { + old_extended_regs old_format; + new_extended_regs new_format; + } state; + unsigned long format; +} extended_regs; +*) + +type + extended_regs = packed record + state : packed record + case integer of + 1 : (old_format : old_extended_regs); + 2 : (new_format : new_extended_regs); + end; + format : cardinal; + end; +(* +struct vregs { + unsigned long eip; + unsigned long eflags; + unsigned long eax; + unsigned long ecx; + unsigned long edx; + unsigned long esp; + unsigned long ebp; + unsigned long _reserved_1; + extended_regs xregs; + unsigned long _reserved_2[3]; +}; +*) + +type + vregs = packed record + eip : cardinal; + eflags : cardinal; + eax : cardinal; + ecx : cardinal; + edx : cardinal; + esp : cardinal; + ebp : cardinal; + _reserved_1 : cardinal; + xregs : extended_regs; + _reserved_2 : array[0..3] of cardinal; + end; + +implementation + +end.