make including the debugger a compilation option WITH_DEBUGGER
This commit is contained in:
parent
ffdb73a83d
commit
63412e14d3
8 changed files with 90 additions and 26 deletions
43
Makefile
43
Makefile
|
@ -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)
|
CFLAGS = -g -O2 -I./src/ -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DPATCHLEVEL=$(PATCHLEVEL) -DCOMPILE_VERSION=$(COMPILE_VERSION)
|
||||||
LIBS = -lm -lhistory -lreadline
|
LIBS = -lm -lhistory -lreadline
|
||||||
|
|
||||||
#possible values: x11, sdl1
|
# possible values: x11, sdl1
|
||||||
GUI = x11
|
GUI = x11
|
||||||
|
|
||||||
|
# possible values: yes, no
|
||||||
|
WITH_DEBUGGER = no
|
||||||
|
|
||||||
ifeq ($(GUI), x11)
|
ifeq ($(GUI), x11)
|
||||||
CFLAGS += $(shell pkg-config --cflags x11 xext readline) -D_GNU_SOURCE=1 -DGUI_IS_X11=1
|
CFLAGS += $(shell pkg-config --cflags x11 xext readline) -D_GNU_SOURCE=1 -DGUI_IS_X11=1
|
||||||
LIBS += $(shell pkg-config --libs x11 xext readline)
|
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
|
CFLAGS += -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap
|
||||||
endif
|
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
|
.PHONY: all clean clean-all pretty-code install
|
||||||
|
|
||||||
all: dist/mkcard dist/checkrom dist/dump2rom dist/x48ng
|
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
|
dist/checkrom: src/tools/checkrom.o src/romio.o
|
||||||
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
|
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
|
||||||
|
|
||||||
dist/x48ng: src/main.o \
|
dist/x48ng: $(DOTOS)
|
||||||
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
|
|
||||||
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
|
$(CC) $(CFLAGS) $(LIBS) $^ -o $@
|
||||||
|
|
||||||
# Cleaning
|
# Cleaning
|
||||||
|
|
|
@ -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.
|
2. removed the code supporting Solaris, HP-UX, etc.
|
||||||
3. removed the autotools-based build system and wrote a simple Makefile instead
|
3. removed the autotools-based build system and wrote a simple Makefile instead
|
||||||
4. added a x48ng.desktop file and an icon
|
4. added a x48ng.desktop file and an icon
|
||||||
|
5. make including the debugger an option at compilation
|
||||||
|
|
||||||
## Bugs to fix
|
## Bugs to fix
|
||||||
|
|
||||||
|
@ -26,12 +27,19 @@ See https://github.com/gwenhael-le-moine/x48ng/issues
|
||||||
|
|
||||||
## Compilation
|
## Compilation
|
||||||
|
|
||||||
|
### GUI
|
||||||
|
|
||||||
By default the X11 version is built. It is the most complete UI-wise.
|
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 X11 version run `make GUI=x11`
|
||||||
|
|
||||||
To build the SDL1 version run `make GUI=sdl1`
|
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
|
## 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.
|
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.
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
#include "hp48emu.h"
|
#include "hp48emu.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "x48.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;
|
extern int throttle;
|
||||||
|
|
||||||
|
@ -2195,7 +2198,9 @@ inline int step_instruction( void ) {
|
||||||
op3 = read_nibbles( saturn.PC + 4, 1 );
|
op3 = read_nibbles( saturn.PC + 4, 1 );
|
||||||
saturn.PC += 5;
|
saturn.PC += 5;
|
||||||
if ( op3 != 0 ) {
|
if ( op3 != 0 ) {
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
enter_debugger |= TRAP_INSTRUCTION;
|
enter_debugger |= TRAP_INSTRUCTION;
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2219,8 +2224,10 @@ inline int step_instruction( void ) {
|
||||||
}
|
}
|
||||||
instructions++;
|
instructions++;
|
||||||
|
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
if ( stop )
|
if ( stop )
|
||||||
enter_debugger |= ILLEGAL_INSTRUCTION;
|
enter_debugger |= ILLEGAL_INSTRUCTION;
|
||||||
|
#endif
|
||||||
|
|
||||||
return stop;
|
return stop;
|
||||||
}
|
}
|
||||||
|
@ -2430,5 +2437,11 @@ void emulate( void ) {
|
||||||
}
|
}
|
||||||
if ( schedule_event-- <= 0 )
|
if ( schedule_event-- <= 0 )
|
||||||
schedule();
|
schedule();
|
||||||
} while ( !enter_debugger );
|
} while (
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
|
!enter_debugger
|
||||||
|
#else
|
||||||
|
1
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
#include "romio.h"
|
#include "romio.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "x48.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;
|
static int interrupt_called = 0;
|
||||||
extern long nibble_masks[ 16 ];
|
extern long nibble_masks[ 16 ];
|
||||||
|
@ -272,9 +275,11 @@ void do_shutdown( void ) {
|
||||||
saturn.int_pending = 0;
|
saturn.int_pending = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
if ( in_debugger )
|
if ( in_debugger )
|
||||||
wake = 1;
|
wake = 1;
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
wake = 0;
|
wake = 0;
|
||||||
|
|
||||||
alarms = 0;
|
alarms = 0;
|
||||||
|
@ -335,9 +340,10 @@ void do_shutdown( void ) {
|
||||||
alarms++;
|
alarms++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
if ( enter_debugger )
|
if ( enter_debugger )
|
||||||
wake = 1;
|
wake = 1;
|
||||||
|
#endif
|
||||||
} while ( wake == 0 );
|
} while ( wake == 0 );
|
||||||
|
|
||||||
stop_timer( IDLE_TIMER );
|
stop_timer( IDLE_TIMER );
|
||||||
|
|
13
src/main.c
13
src/main.c
|
@ -11,9 +11,12 @@
|
||||||
|
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
#include "x48.h"
|
#include "x48.h"
|
||||||
#include "x48_debugger.h"
|
|
||||||
#include "x48_resources.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 )
|
#if defined( GUI_IS_X11 )
|
||||||
char* progname;
|
char* progname;
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,9 +26,11 @@ char** saved_argv;
|
||||||
|
|
||||||
void signal_handler( int sig ) {
|
void signal_handler( int sig ) {
|
||||||
switch ( sig ) {
|
switch ( sig ) {
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
case SIGINT: /* Ctrl-C */
|
case SIGINT: /* Ctrl-C */
|
||||||
enter_debugger |= USER_INTERRUPT;
|
enter_debugger |= USER_INTERRUPT;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case SIGALRM:
|
case SIGALRM:
|
||||||
got_alarm = 1;
|
got_alarm = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -107,6 +112,7 @@ int main( int argc, char** argv ) {
|
||||||
#endif
|
#endif
|
||||||
sigaction( SIGALRM, &sa, ( struct sigaction* )0 );
|
sigaction( SIGALRM, &sa, ( struct sigaction* )0 );
|
||||||
|
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
sigemptyset( &set );
|
sigemptyset( &set );
|
||||||
sigaddset( &set, SIGINT );
|
sigaddset( &set, SIGINT );
|
||||||
sa.sa_handler = signal_handler;
|
sa.sa_handler = signal_handler;
|
||||||
|
@ -115,6 +121,7 @@ int main( int argc, char** argv ) {
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
#endif
|
#endif
|
||||||
sigaction( SIGINT, &sa, ( struct sigaction* )0 );
|
sigaction( SIGINT, &sa, ( struct sigaction* )0 );
|
||||||
|
#endif
|
||||||
|
|
||||||
sigemptyset( &set );
|
sigemptyset( &set );
|
||||||
sigaddset( &set, SIGPIPE );
|
sigaddset( &set, SIGPIPE );
|
||||||
|
@ -149,12 +156,16 @@ int main( int argc, char** argv ) {
|
||||||
/* Start emulation loop */
|
/* Start emulation loop */
|
||||||
/************************/
|
/************************/
|
||||||
do {
|
do {
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
if ( !exec_flags )
|
if ( !exec_flags )
|
||||||
|
#endif
|
||||||
emulate();
|
emulate();
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
else
|
else
|
||||||
emulate_debug();
|
emulate_debug();
|
||||||
|
|
||||||
debug();
|
debug();
|
||||||
|
#endif
|
||||||
} while ( 1 );
|
} while ( 1 );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -317,7 +317,11 @@ t1_t2_ticks get_t1_t2( void ) {
|
||||||
|
|
||||||
access_time -= stop;
|
access_time -= stop;
|
||||||
|
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
if ( adj_time_pending || in_debugger ) {
|
if ( adj_time_pending || in_debugger ) {
|
||||||
|
#else
|
||||||
|
if ( adj_time_pending ) {
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* We have been inside an interrupt for very long, maybe
|
* We have been inside an interrupt for very long, maybe
|
||||||
* or we are sleeping in the debugger.
|
* or we are sleeping in the debugger.
|
||||||
|
|
|
@ -6395,12 +6395,15 @@ int get_ui_event( void ) {
|
||||||
return 1;
|
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. */
|
/* TODO Make cut from the screen work. */
|
||||||
get_stack();
|
get_stack();
|
||||||
} else {
|
} else {
|
||||||
/* printf("In display %d\n", xev.xbutton.button); */
|
/* printf("In display %d\n", xev.xbutton.button); */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if ( xev.xbutton.button == Button1 ||
|
if ( xev.xbutton.button == Button1 ||
|
||||||
xev.xbutton.button == Button2 ||
|
xev.xbutton.button == Button2 ||
|
||||||
|
|
|
@ -4,10 +4,16 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "x48_debugger.h" /* `disassembler_mode` & `CLASS_MNEMONICS` */
|
|
||||||
#include "x48_errors.h"
|
#include "x48_errors.h"
|
||||||
#include "x48_resources.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 verbose;
|
||||||
int useTerminal;
|
int useTerminal;
|
||||||
int useSerial;
|
int useSerial;
|
||||||
|
@ -363,8 +369,10 @@ void get_resources( void ) {
|
||||||
useSerial = 0;
|
useSerial = 0;
|
||||||
initialize = 0;
|
initialize = 0;
|
||||||
resetOnStartup = 0;
|
resetOnStartup = 0;
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
useDebugger = 1;
|
useDebugger = 1;
|
||||||
disassembler_mode = CLASS_MNEMONICS; // HP_MNEMONICS
|
disassembler_mode = CLASS_MNEMONICS; // HP_MNEMONICS
|
||||||
|
#endif
|
||||||
netbook = 0;
|
netbook = 0;
|
||||||
throttle = 0;
|
throttle = 0;
|
||||||
|
|
||||||
|
@ -390,9 +398,11 @@ void get_resources( void ) {
|
||||||
romFileName = get_string_resource( "romFileName", "RomFileName" );
|
romFileName = get_string_resource( "romFileName", "RomFileName" );
|
||||||
homeDirectory = get_string_resource( "homeDirectory", "HomeDirectory" );
|
homeDirectory = get_string_resource( "homeDirectory", "HomeDirectory" );
|
||||||
|
|
||||||
|
#if defined( WITH_DEBUGGER )
|
||||||
useDebugger = get_boolean_resource( "useDebugger", "UseDebugger" );
|
useDebugger = get_boolean_resource( "useDebugger", "UseDebugger" );
|
||||||
disassembler_mode = get_mnemonic_resource( "disassemblerMnemonics",
|
disassembler_mode = get_mnemonic_resource( "disassemblerMnemonics",
|
||||||
"DisassemblerMnemonics" );
|
"DisassemblerMnemonics" );
|
||||||
|
#endif
|
||||||
|
|
||||||
netbook = get_boolean_resource( "netbook", "Netbook" );
|
netbook = get_boolean_resource( "netbook", "Netbook" );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue