This commit is contained in:
Stefan Arentz 2017-10-15 02:42:48 +00:00 committed by GitHub
commit 138ea163f3
5 changed files with 977 additions and 88 deletions

View File

@ -14,8 +14,8 @@ set(CPU_SOURCES cpu.c mem.c fmt.c ins.c utl.c)
set(SDL_SOURCES sdl.c)
set(BOO_SOURCES boo.c tty.c chr.c)
set(ONE_SOURCES one.c tty.c chr.c pia.c)
set(TWO_SOURCES two.c scr.c dsk.c chr.c alc.c)
set(ONE_SOURCES one.c tty.c chr.c pia.c dbg.c)
set(TWO_SOURCES two.c scr.c dsk.c chr.c alc.c dbg.c)
add_executable(cpu_test ${CPU_SOURCES} cpu_test.c)

File diff suppressed because it is too large Load Diff

24
src/dbg.c Normal file
View File

@ -0,0 +1,24 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Stefan Arentz - http://github.com/st3fan/ewm
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "dbg.h"

26
src/dbg.h Normal file
View File

@ -0,0 +1,26 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Stefan Arentz - http://github.com/st3fan/ewm
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef EWM_DBG_H
#define EWM_DBG_H
#endif // EWM_DBG_H

View File

@ -31,6 +31,7 @@
#include "mem.h"
#include "pia.h"
#include "tty.h"
#include "dbg.h"
#include "one.h"
static void ewm_one_pia_callback(struct ewm_pia_t *pia, void *obj, uint8_t ddr, uint8_t v) {
@ -176,6 +177,7 @@ static bool ewm_one_step_cpu(struct ewm_one_t *one, int cycles) {
#define EWM_ONE_OPT_MEMORY (2)
#define EWM_ONE_OPT_TRACE (3)
#define EWM_ONE_OPT_STRICT (4)
#define EWM_ONE_OPT_DEBUG (5)
static struct option one_options[] = {
{ "help", no_argument, NULL, EWM_ONE_OPT_HELP },
@ -183,6 +185,7 @@ static struct option one_options[] = {
{ "memory", required_argument, NULL, EWM_ONE_OPT_MEMORY },
{ "trace", optional_argument, NULL, EWM_ONE_OPT_TRACE },
{ "strict", no_argument, NULL, EWM_ONE_OPT_STRICT },
{ "debug", no_argument, NULL, EWM_ONE_OPT_DEBUG },
{ NULL, 0, NULL, 0 }
};
@ -192,6 +195,7 @@ static void usage() {
fprintf(stderr, " --memory <region> add memory region (ram|rom:address:path)\n");
fprintf(stderr, " --trace <file> trace cpu to file\n");
fprintf(stderr, " --strict run emulator in strict mode\n");
fprintf(stderr, " --debug <port> run debugger on port (default: 6502)\n");
fprintf(stderr, "\n");
fprintf(stderr, "Supported models:\n");
fprintf(stderr, " apple1 Classic Apple 1, 6502, 8KB RAM, Woz Monitor\n");
@ -204,6 +208,7 @@ int ewm_one_main(int argc, char **argv) {
struct ewm_memory_option_t *extra_memory = NULL;
char *trace_path = NULL;
bool strict = false;
int debug_port = 0;
int ch;
while ((ch = getopt_long_only(argc, argv, "", one_options, NULL)) != -1) {
@ -240,6 +245,14 @@ int ewm_one_main(int argc, char **argv) {
strict = true;
break;
}
case EWM_ONE_OPT_DEBUG: {
debug_port = optarg ? atoi(optarg) : 6502;
if (debug_port == 0) {
fprintf(stderr, "Invalid debugger port\n");
exit(1);
}
break;
}
default: {
usage();
exit(1);