Files
nunuhara_xsystem4/src/debug-ffi.stub
T
Nunuhara Cabbage 9fbc9ec5b7 Implement simple command-based debugger interface
Add a new debugger interface using a simple command language. This is
less powerful than the scheme interface (which still exists) but more
ergonomic for interactive debugging.

This debugger has no external dependencies (it will however use readline
if available) and is included in builds by default.

A sample interaction might look like:

    xsystem4 --debug /path/to/game
    dbg(cmd)> breakpoint bar
    Set breakpoint at function 'bar' (0x00001234)
    dbg(cmd)> continue
    Hit breakpoint at function 'bar' (0x00001234)
    dbg(cmd)> backtrace
    #0 0x00001234 in bar
    #1 0x00002222 in foo
    #2 0x00004444 in main
    dbg(cmd)> locals
    [0] i: 2
    [1] s: "baz"
    dbg(cmd)> locals 1
    [0] j: 3
    [1] obj: { m_i = 0; m_s = "" }
    dbg(cmd)> quit
2022-04-01 19:38:55 -07:00

96 lines
4.0 KiB
Plaintext

;; Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
;;
;; This program 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 2 of the License, or
;; (at your option) any later version.
;;
;; This program 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 this program; if not, see <http://gnu.org/licenses/>.
(c-include "system4/ain.h")
(c-include "vm/page.h")
(c-include "vm.h")
(define-c-const int (type/void AIN_VOID))
(define-c-const int (type/int AIN_INT))
(define-c-const int (type/float AIN_FLOAT))
(define-c-const int (type/string AIN_STRING))
(define-c-const int (type/struct AIN_STRUCT))
(define-c-const int (type/array-int AIN_ARRAY_INT))
(define-c-const int (type/array-float AIN_ARRAY_FLOAT))
(define-c-const int (type/array-string AIN_ARRAY_STRING))
(define-c-const int (type/array-struct AIN_ARRAY_STRUCT))
(define-c-const int (type/ref-int AIN_REF_INT))
(define-c-const int (type/ref-float AIN_REF_FLOAT))
(define-c-const int (type/ref-string AIN_REF_STRING))
(define-c-const int (type/ref-struct AIN_REF_STRUCT))
(define-c-const int (type/ref-array-int AIN_REF_ARRAY_INT))
(define-c-const int (type/ref-array-float AIN_REF_ARRAY_FLOAT))
(define-c-const int (type/ref-array-string AIN_REF_ARRAY_STRING))
(define-c-const int (type/ref-array-struct AIN_REF_ARRAY_STRUCT))
(define-c-const int (type/imain-system AIN_IMAIN_SYSTEM))
(define-c-const int (type/func-type AIN_FUNC_TYPE))
(define-c-const int (type/array-func-type AIN_ARRAY_FUNC_TYPE))
(define-c-const int (type/ref-func-type AIN_REF_FUNC_TYPE))
(define-c-const int (type/ref-array-func-type AIN_REF_ARRAY_FUNC_TYPE))
(define-c-const int (type/bool AIN_BOOL))
(define-c-const int (type/array-bool AIN_ARRAY_BOOL))
(define-c-const int (type/ref-bool AIN_REF_BOOL))
(define-c-const int (type/ref-array-bool AIN_REF_ARRAY_BOOL))
(define-c-const int (type/long AIN_LONG_INT))
(define-c-const int (type/array-long AIN_ARRAY_LONG_INT))
(define-c-const int (type/ref-long AIN_REF_LONG_INT))
(define-c-const int (type/ref-array-long AIN_REF_ARRAY_LONG_INT))
(define-c-const int (type/delegate AIN_DELEGATE))
(define-c-const int (type/array-delegate AIN_ARRAY_DELEGATE))
(define-c-const int (type/ref-array-delegate AIN_REF_ARRAY_DELEGATE))
(define-c-const int (page-type/global GLOBAL_PAGE))
(define-c-const int (page-type/local LOCAL_PAGE))
(define-c-const int (page-type/struct STRUCT_PAGE))
(define-c-const int (page-type/array ARRAY_PAGE))
(define-c-struct page
predicate: page?
(int type page-type)
(int index page-type-index)
(int nr_vars page-nr-vars)
(int a_type array-data-type)
(int _page_struct_type array-struct-type)
(int _page_rank array-rank))
(define-c-union vm_value
predicate: vm-value?
(int i vm-value-int)
(float f vm-value-float))
(define-c (free string) (vm-value-string vm_value_string) (vm_value))
(define-c-struct variable
finalizer: free_variable
predicate: variable?
(int data_type variable-data-type)
(int struct_type variable-struct-type)
(string name variable-name)
(int varno variable-varno)
(vm_value value variable-vm-value))
(define-c void (backtrace dbg_print_stack_trace) ())
(define-c (maybe-null page) (get-page get_page) (int))
(define-c (maybe-null page) (frame-page frame_page) (int))
(define-c (free variable) (page-ref page_ref) (page int))
(define-c void (set-function-breakpoint set_function_breakpoint) (string sexp))
(define-c void (set-address-breakpoint set_address_breakpoint) (unsigned-int sexp))
(define-c (maybe-null (free variable)) (get-global-variable get_global_by_name) (string))
(define-c (maybe-null (free variable)) (get-local-variable get_local_by_name) (string))