make including the debugger a compilation option WITH_DEBUGGER

This commit is contained in:
Gwenhael Le Moine 2023-05-18 23:11:40 +02:00
parent ffdb73a83d
commit 63412e14d3
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
8 changed files with 90 additions and 26 deletions

View file

@ -10,9 +10,12 @@ CC = gcc
CFLAGS = -g -O2 -I./src/ -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DPATCHLEVEL=$(PATCHLEVEL) -DCOMPILE_VERSION=$(COMPILE_VERSION)
LIBS = -lm -lhistory -lreadline
#possible values: x11, sdl1
# possible values: x11, sdl1
GUI = x11
# possible values: yes, no
WITH_DEBUGGER = no
ifeq ($(GUI), x11)
CFLAGS += $(shell pkg-config --cflags x11 xext readline) -D_GNU_SOURCE=1 -DGUI_IS_X11=1
LIBS += $(shell pkg-config --libs x11 xext readline)
@ -27,6 +30,27 @@ ifeq ($(FULL_WARNINGS), yes)
CFLAGS += -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap
endif
DOTOS = src/main.o \
src/hp48_device.o \
src/hp48_emulate.o \
src/hp48_init.o \
src/hp48_serial.o \
src/hp48emu_actions.o \
src/hp48emu_memory.o \
src/hp48emu_register.o \
src/romio.o \
src/timer.o \
src/x48_errors.o \
src/x48_resources.o \
src/x48.o
ifeq ($(WITH_DEBUGGER), yes)
DOTOS += src/x48_debugger.o \
src/x48_debugger_disasm.o \
src/x48_debugger_rpl.o
CFLAGS += -DWITH_DEBUGGER=1
endif
.PHONY: all clean clean-all pretty-code install
all: dist/mkcard dist/checkrom dist/dump2rom dist/x48ng
@ -41,22 +65,7 @@ dist/dump2rom: src/tools/dump2rom.o
dist/checkrom: src/tools/checkrom.o src/romio.o
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
dist/x48ng: src/main.o \
src/hp48emu_actions.o \
src/x48_debugger.o \
src/hp48_device.o \
src/x48_debugger_disasm.o \
src/hp48_emulate.o \
src/x48_errors.o \
src/hp48_init.o \
src/hp48emu_memory.o \
src/hp48emu_register.o \
src/x48_resources.o \
src/romio.o \
src/x48_debugger_rpl.o \
src/hp48_serial.o \
src/timer.o \
src/x48.o
dist/x48ng: $(DOTOS)
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
# Cleaning

View file

@ -11,6 +11,7 @@ This is my fork of x48-0.6.4 where I deviate from the original code and do my ow
2. removed the code supporting Solaris, HP-UX, etc.
3. removed the autotools-based build system and wrote a simple Makefile instead
4. added a x48ng.desktop file and an icon
5. make including the debugger an option at compilation
## Bugs to fix
@ -26,12 +27,19 @@ See https://github.com/gwenhael-le-moine/x48ng/issues
## Compilation
### GUI
By default the X11 version is built. It is the most complete UI-wise.
To build the X11 version run `make GUI=x11`
To build the SDL1 version run `make GUI=sdl1`
### Debugger
Debugger is not built by default.
To build the debugger compile with `make WITH_DEBUGGER=yes`
## Installation
1. Run `sudo make install PREFIX=/usr DOCDIR=/usr/doc/x48ng MANDIR=/usr/man DESTDIR=/tmp/package` filling in your own values for PREFIX, DOCDIR, MANDIR and DESTDIR.

View file

@ -5,7 +5,10 @@
#include "hp48emu.h"
#include "timer.h"
#include "x48.h"
#include "x48_debugger.h"
#if defined( WITH_DEBUGGER )
#include "x48_debugger.h" /* enter_debugger, TRAP_INSTRUCTION, ILLEGAL_INSTRUCTION */
#endif
extern int throttle;
@ -2195,7 +2198,9 @@ inline int step_instruction( void ) {
op3 = read_nibbles( saturn.PC + 4, 1 );
saturn.PC += 5;
if ( op3 != 0 ) {
#if defined( WITH_DEBUGGER )
enter_debugger |= TRAP_INSTRUCTION;
#endif
return 1;
}
} else {
@ -2219,8 +2224,10 @@ inline int step_instruction( void ) {
}
instructions++;
#if defined( WITH_DEBUGGER )
if ( stop )
enter_debugger |= ILLEGAL_INSTRUCTION;
#endif
return stop;
}
@ -2430,5 +2437,11 @@ void emulate( void ) {
}
if ( schedule_event-- <= 0 )
schedule();
} while ( !enter_debugger );
} while (
#if defined( WITH_DEBUGGER )
!enter_debugger
#else
1
#endif
);
}

View file

@ -7,7 +7,10 @@
#include "romio.h"
#include "timer.h"
#include "x48.h"
#include "x48_debugger.h"
#if defined( WITH_DEBUGGER )
#include "x48_debugger.h" /* in_debugger, enter_debugger */
#endif
static int interrupt_called = 0;
extern long nibble_masks[ 16 ];
@ -272,9 +275,11 @@ void do_shutdown( void ) {
saturn.int_pending = 0;
}
#if defined( WITH_DEBUGGER )
if ( in_debugger )
wake = 1;
else
#endif
wake = 0;
alarms = 0;
@ -335,9 +340,10 @@ void do_shutdown( void ) {
alarms++;
}
#if defined( WITH_DEBUGGER )
if ( enter_debugger )
wake = 1;
#endif
} while ( wake == 0 );
stop_timer( IDLE_TIMER );

View file

@ -11,9 +11,12 @@
#include "hp48.h"
#include "x48.h"
#include "x48_debugger.h"
#include "x48_resources.h"
#if defined( WITH_DEBUGGER )
#include "x48_debugger.h" /* enter_debugger, USER_INTERRUPT, exec_flags, emulate_debug, debug */
#endif
#if defined( GUI_IS_X11 )
char* progname;
#endif
@ -23,9 +26,11 @@ char** saved_argv;
void signal_handler( int sig ) {
switch ( sig ) {
#if defined( WITH_DEBUGGER )
case SIGINT: /* Ctrl-C */
enter_debugger |= USER_INTERRUPT;
break;
#endif
case SIGALRM:
got_alarm = 1;
break;
@ -107,6 +112,7 @@ int main( int argc, char** argv ) {
#endif
sigaction( SIGALRM, &sa, ( struct sigaction* )0 );
#if defined( WITH_DEBUGGER )
sigemptyset( &set );
sigaddset( &set, SIGINT );
sa.sa_handler = signal_handler;
@ -115,6 +121,7 @@ int main( int argc, char** argv ) {
sa.sa_flags = SA_RESTART;
#endif
sigaction( SIGINT, &sa, ( struct sigaction* )0 );
#endif
sigemptyset( &set );
sigaddset( &set, SIGPIPE );
@ -149,12 +156,16 @@ int main( int argc, char** argv ) {
/* Start emulation loop */
/************************/
do {
#if defined( WITH_DEBUGGER )
if ( !exec_flags )
#endif
emulate();
#if defined( WITH_DEBUGGER )
else
emulate_debug();
debug();
#endif
} while ( 1 );
return 0;

View file

@ -317,8 +317,12 @@ t1_t2_ticks get_t1_t2( void ) {
access_time -= stop;
#if defined( WITH_DEBUGGER )
if ( adj_time_pending || in_debugger ) {
/*
#else
if ( adj_time_pending ) {
#endif
/*
* We have been inside an interrupt for very long, maybe
* or we are sleeping in the debugger.
* Don't adjust the time, can't come from user, anyhow.

View file

@ -6395,12 +6395,15 @@ int get_ui_event( void ) {
return 1;
}
}
} else if ( xev.xbutton.button == Button3 ) {
}
#if defined( WITH_DEBUGGER )
else if ( xev.xbutton.button == Button3 ) {
/* TODO Make cut from the screen work. */
get_stack();
} else {
/* printf("In display %d\n", xev.xbutton.button); */
}
}
#endif
} else {
if ( xev.xbutton.button == Button1 ||
xev.xbutton.button == Button2 ||

View file

@ -4,10 +4,16 @@
#include <unistd.h>
#include <ctype.h>
#include "x48_debugger.h" /* `disassembler_mode` & `CLASS_MNEMONICS` */
#include "x48_errors.h"
#include "x48_resources.h"
#if defined( WITH_DEBUGGER )
#include "x48_debugger.h" /* `disassembler_mode` & `CLASS_MNEMONICS` */
#else
#define HP_MNEMONICS 0
#define CLASS_MNEMONICS 1
#endif
int verbose;
int useTerminal;
int useSerial;
@ -363,8 +369,10 @@ void get_resources( void ) {
useSerial = 0;
initialize = 0;
resetOnStartup = 0;
#if defined( WITH_DEBUGGER )
useDebugger = 1;
disassembler_mode = CLASS_MNEMONICS; // HP_MNEMONICS
#endif
netbook = 0;
throttle = 0;
@ -390,9 +398,11 @@ void get_resources( void ) {
romFileName = get_string_resource( "romFileName", "RomFileName" );
homeDirectory = get_string_resource( "homeDirectory", "HomeDirectory" );
#if defined( WITH_DEBUGGER )
useDebugger = get_boolean_resource( "useDebugger", "UseDebugger" );
disassembler_mode = get_mnemonic_resource( "disassemblerMnemonics",
"DisassemblerMnemonics" );
#endif
netbook = get_boolean_resource( "netbook", "Netbook" );