aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-02-16 23:28:24 +0000
committerFilippos Karapetis2009-02-16 23:28:24 +0000
commita3adca29f22ecebdd2a3d5388d5fe22327f73ec7 (patch)
tree62241625db7cb1fde9507fea1fc04f81b63c4073 /engines/sci/engine
parentd61b83814b9295d6fc4192344a96422fed2fe07d (diff)
downloadscummvm-rg350-a3adca29f22ecebdd2a3d5388d5fe22327f73ec7.tar.gz
scummvm-rg350-a3adca29f22ecebdd2a3d5388d5fe22327f73ec7.tar.bz2
scummvm-rg350-a3adca29f22ecebdd2a3d5388d5fe22327f73ec7.zip
Removed a lot of unused and compiler-specific debug code. Note that for MSVC, the corresponding checks are enabled by default in the debug build, so there's no need to set them again programmatically. Also, removed the "codebugging" related code
svn-id: r38387
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/savegame.cpp34
-rw-r--r--engines/sci/engine/scriptdebug.cpp170
2 files changed, 0 insertions, 204 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index daef5b331b..c7fc27d9ba 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -184,19 +184,6 @@ typedef mem_obj_t *mem_obj_ptr;
#include <stdarg.h> /* We need va_lists */
#include "sci/include/sci_memory.h"
-#ifdef CFSML_DEBUG_MALLOC
-/*
-#define free(p) dbg_sci_free(p)
-#define malloc(s) dbg_sci_malloc(s)
-#define calloc(n, s) dbg_sci_calloc(n, s)
-#define realloc(p, s) dbg_sci_realloc(p, s)
-*/
-#define free dbg_sci_free
-#define malloc dbg_sci_malloc
-#define calloc dbg_sci_calloc
-#define realloc dbg_sci_realloc
-#endif
-
static void
_cfsml_error(const char *fmt, ...)
{
@@ -225,28 +212,13 @@ _cfsml_free_pointer_references_recursively(struct _cfsml_pointer_refstruct *refs
{
if (!refs)
return;
- #ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
- #endif
_cfsml_free_pointer_references_recursively(refs->next, free_pointers);
- #ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
-
- fprintf(stderr,"Freeing ptrref %p [%p] %s\n", refs->ptr, refs, free_pointers?
- "ALL": "cleanup only");
- #endif
if (free_pointers)
free(refs->ptr);
- #ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
- #endif
free(refs);
- #ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
- #endif
}
static void
@@ -266,10 +238,6 @@ _cfsml_get_current_refpointer()
static void _cfsml_register_pointer(void *ptr)
{
struct _cfsml_pointer_refstruct *newref = (struct _cfsml_pointer_refstruct*)sci_malloc(sizeof (struct _cfsml_pointer_refstruct));
- #ifdef CFSML_DEBUG_MALLOC
- SCI_MEMTEST;
- fprintf(stderr,"Registering ptrref %p [%p]\n", ptr, newref);
- #endif
newref->next = *_cfsml_pointer_references_current;
newref->ptr = ptr;
*_cfsml_pointer_references_current = newref;
@@ -4859,14 +4827,12 @@ gamestate_save(state_t *s, char *dirname) {
/* Calculate the time spent with this game */
s->game_time = time(NULL) - s->game_start_time.tv_sec;
-SCI_MEMTEST;
#line 878 "savegame.cfsml"
/* Auto-generated CFSML data writer code */
_cfsml_write_state_t(fh, s);
fprintf(fh, "\n");
/* End of auto-generated CFSML data writer code */
#line 730 "savegame.cfsml"
-SCI_MEMTEST;
fclose(fh);
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 1796edb5de..9b56e6408b 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -1680,154 +1680,6 @@ c_vmvars(state_t *s) {
return 0;
}
-#ifdef HAVE_SYSV_IPC
-static int _codebug_pid = 0;
-static int _codebug_stdin[2];
-static int _codebug_stdout[2];
-static int _codebug_commands[2]; /* sends commands to intermediate process */
-
-/* Codebugging uses two child processes:
-** The first one only performs output "coloring", its child process
-** is an actual secondary freesci process
-*/
-
-#define CODEBUG_BUFSIZE 512
-static const char *_codebug_colstr = "\033[31m\033[1m";
-static const char *_codebug_uncolstr = "\033[0m";
-
-static void
-codebug_send_command(const char *cmd) {
- if (_codebug_pid)
- write(_codebug_commands[1], cmd, strlen(cmd));
-}
-
-static void
-_print_colored(int from_fd) {
- char buf[CODEBUG_BUFSIZE + 64];
- char *buf_offset;
- int br;
- int length_increment;
-
- strcpy(buf, _codebug_colstr);
- length_increment = strlen(_codebug_colstr);
- buf_offset = buf + length_increment;
- length_increment += strlen(_codebug_uncolstr);
-
- do {
- br = read(from_fd, buf_offset, CODEBUG_BUFSIZE);
- if (br > 0) {
- strcpy(buf_offset + br, _codebug_uncolstr);
- /* Atomic write with colors to nullify risk of
- ** interference from fg process */
- write(1, buf, br + length_increment);
- }
- } while (br == CODEBUG_BUFSIZE);
-}
-
-void
-_codebug_kill_children() {
- if (_codebug_pid)
- kill(_codebug_pid, SIGTERM);
-}
-
-void
-_codebug_sighandler(int i) {
- if (i == SIGPIPE || i == SIGTERM)
- kill(_codebug_pid, SIGTERM);
-
- write(1, _codebug_uncolstr, strlen(_codebug_uncolstr));
- fprintf(stderr, "Child process failed, aborting!\n");
- fprintf(stderr, "(if you're using the UNIX sound server, you'll probably get spurious"
- " warnings regarding the sound server now...)\n");
- exit(1);
-}
-
-static void
-do_codebug(char *path, char *datapath) {
- pipe(_codebug_stdin);
- pipe(_codebug_stdout);
- close(_codebug_commands[1]);
-
- _codebug_pid = fork();
- if (_codebug_pid) {
- fd_set fs;
- int max_n;
-
- /* parent process */
- close(_codebug_stdin[0]);
- close(_codebug_stdout[1]);
-
- max_n = _codebug_commands[0];
- if (max_n < _codebug_stdout[0])
- max_n = _codebug_stdout[0];
-
- signal(SIGCHLD, _codebug_sighandler);
- signal(SIGPIPE, _codebug_sighandler);
- signal(SIGTERM, _codebug_sighandler);
-
- while (1) { /* Until sigchild */
- FD_ZERO(&fs);
- FD_SET(_codebug_commands[0], &fs);
- FD_SET(_codebug_stdout[0], &fs);
-
- fflush(NULL);
- select(max_n + 1, &fs, NULL, NULL, NULL);
-
- if (FD_ISSET(_codebug_commands[0], &fs)) {
- char buf[CODEBUG_BUFSIZE];
- int br;
- do {
- br = read(_codebug_commands[0], buf, CODEBUG_BUFSIZE);
- if (br > 0)
- write(_codebug_stdin[1], buf, br);
- } while (br == CODEBUG_BUFSIZE);
- }
-
- if (FD_ISSET(_codebug_stdout[0], &fs))
- _print_colored(_codebug_stdout[0]);
-
- }
- } else {
- /* child */
- close(_codebug_stdin[1]);
- close(_codebug_stdout[0]);
-
- /* Re-associate stdin, stdout, stderr with i/o pipes */
- dup2(_codebug_stdin[0], 0);
- dup2(_codebug_stdout[1], 1);
- dup2(_codebug_stdout[1], 2);
-
- printf("Calling '%s' on data directory '%s'...\n", path, datapath);
- execlp(path, path, "-D", "-gnull", "-Pnull", "-Onull", "-Mmt32gm",
- "--disable-readline", "-d", datapath, NULL);
- perror("execlp of FreeSCI");
- exit(1);
- }
-}
-
-static int
-c_codebug(state_t *s) {
- char *path = cmd_params[0].str;
-
- if (_codebug_pid) {
- sciprintf("Already codebugging!\n");
- return 1;
- }
-
- pipe(_codebug_commands);
- _codebug_pid = fork();
-
- if (!_codebug_pid)
- do_codebug(path, s->resource_dir); /* Do codebugging in a child process */
- else {
- close(_codebug_commands[0]);
- sleep(1); /* Yield to the scheduler, at least a bit */
- atexit(_codebug_kill_children);
- }
- return 0;
-}
-#endif
-
static int
c_backtrace(state_t *s) {
int i;
@@ -3618,15 +3470,6 @@ script_debug(state_t *s, reg_t *pc, stack_ptr_t *sp, stack_ptr_t *pp, reg_t *obj
" s.1, snk.1, so.1, bpx.1");
con_hook_command(c_songlib_print, "songlib_print", "",
"");
-#ifdef HAVE_SYSV_IPC
- con_hook_command(c_codebug, "codebug", "!s",
- "Starts codebugging mode\n\nUSAGE\n\n"
- " codebug path/to/old/freesci\n\n"
- " A different version of FreeSCI may be\n"
- " spawned as a child process; all commands\n"
- " send to this debugger will also be sent to\n"
- " to the child process.\n\nSEE ALSO\n\n codebugging.3");
-#endif
con_hook_command(c_type, "type", "!a",
"Determines the type of a value\n\n"
"SEE ALSO\n\n addresses.3, vo.1");
@@ -3743,19 +3586,14 @@ script_debug(state_t *s, reg_t *pc, stack_ptr_t *sp, stack_ptr_t *pp, reg_t *obj
sfx_suspend(&s->sound, 1);
#ifdef WANT_CONSOLE
-# ifndef FORCE_CONSOLE
if (!have_windowed) {
-# endif
con_gfx_show(s->gfx_state);
input = con_gfx_read(s->gfx_state);
con_gfx_hide(s->gfx_state);
commandstring = input;
sciprintf("> %s\n", commandstring);
-# ifndef FORCE_CONSOLE
} else
-# endif
#endif
-#ifndef FORCE_CONSOLE
commandstring = _debug_get_input();
/* Check if a specific destination has been given */
@@ -3764,14 +3602,6 @@ script_debug(state_t *s, reg_t *pc, stack_ptr_t *sp, stack_ptr_t *pp, reg_t *obj
|| commandstring[0] == ':'))
skipfirst = 1;
-#endif
-#ifdef HAVE_SYSV_IPC
- if (commandstring
- && commandstring[0] != '.') {
- codebug_send_command(commandstring + skipfirst);
- codebug_send_command("\n");
- }
-#endif
if (commandstring
&& commandstring[0] != ':')
con_parse(s, commandstring + skipfirst);