1
0
Fork 0
dosbox-staging/include/logging.h
diaxen cf4685e7aa Add gdb server to debugger
Here is a patch which allows using the GNU debugger as an alternative to
the DOSBox built-in debugger. The built-in debugger may be more
convenient to show x86 specific information about execution state,
whereas Gdb is useful for C and C++ source level debugging.

This patch applies against svn revision 3761. Once applied the configure
script can be used with a new option:

./autogen.sh
./configure --enable-debug=gdbserver

DOSBox then listen on TCP port 1234 and a Gdb client compiled for x86_64
or i686 targets can be connected:

$ gdb
(gdb) target remote localhost:1234

The gdb architecture must be set depending on the code your are trying
to disassemble (16 or 32 bits), for instance:

(gdb) set architecture i8086
(gdb) x/32i $eip

Breakpoints and watchpoints are supported and some DOSBox specific
features are available through the gdb "monitor" command.

This patch adds the following files:
- src/debug/gdb_server.cpp file
- src/debug/debug_log.cpp
- src/debug/debug_helpers.cpp

The debug.cpp file has been split in 3 files so that the original file
now contains built-in debugger stuff only and
debug_log.cpp/debug_helpers.cpp files contain common code used by both
built-in and Gdb debuggers. Some variables which were previously local
to debug.cpp have been prefixed by DEBUG_ and debug.h has been updated
accordingly.

Tested under GNU/Linux.

Co-authored-by: ykhwong
Imported-from: https://www.vogons.org/viewtopic.php?p=259378#p259378
2020-05-11 17:59:02 -04:00

95 lines
3 KiB
C++

/*
* Copyright (C) 2002-2011 The DOSBox Team
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef DOSBOX_LOGGING_H
#define DOSBOX_LOGGING_H
enum LOG_TYPES {
LOG_ALL,
LOG_VGA, LOG_VGAGFX,LOG_VGAMISC,LOG_INT10,
LOG_SB,LOG_DMACONTROL,
LOG_FPU,LOG_CPU,LOG_PAGING,
LOG_FCB,LOG_FILES,LOG_IOCTL,LOG_EXEC,LOG_DOSMISC,
LOG_PIT,LOG_KEYBOARD,LOG_PIC,
LOG_MOUSE,LOG_BIOS,LOG_GUI,LOG_MISC,
LOG_IO,
LOG_PCI,
LOG_MAX
};
enum LOG_SEVERITIES {
LOG_NORMAL,
LOG_WARN,
LOG_ERROR
};
#if C_DEBUG || C_GDBSERVER
struct _LogGroup {
char const* front;
bool enabled;
};
class LOG
{
LOG_TYPES d_type;
LOG_SEVERITIES d_severity;
public:
LOG (LOG_TYPES type , LOG_SEVERITIES severity):
d_type(type),
d_severity(severity)
{}
void operator() (char const* buf, ...) GCC_ATTRIBUTE(__format__(__printf__, 2, 3)); //../src/debug/debug_log.cpp
};
void DEBUG_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, 2));
#define LOG_MSG DEBUG_ShowMsg
#else //C_DEBUG || C_GDBSERVER
struct LOG
{
LOG(LOG_TYPES , LOG_SEVERITIES ) { }
void operator()(char const* ) { }
void operator()(char const* , double ) { }
void operator()(char const* , double , double ) { }
void operator()(char const* , double , double , double ) { }
void operator()(char const* , double , double , double , double ) { }
void operator()(char const* , double , double , double , double , double ) { }
void operator()(char const* , double , double , double , double , double , double ) { }
void operator()(char const* , double , double , double , double , double , double , double) { }
void operator()(char const* , char const* ) { }
void operator()(char const* , char const* , double ) { }
void operator()(char const* , char const* , double ,double ) { }
void operator()(char const* , double , char const* ) { }
void operator()(char const* , double , double, char const* ) { }
void operator()(char const* , char const*, char const*) { }
void operator()(char const* , double , double , double , char const* ) { }
}; //add missing operators to here
//try to avoid anything smaller than bit32...
void GFX_ShowMsg(char const* format,...) GCC_ATTRIBUTE(__format__(__printf__, 1, 2));
#define LOG_MSG GFX_ShowMsg
#endif //C_DEBUG || C_GDBSERVER
#endif //DOSBOX_LOGGING_H