#include <errno.h>
#endif
+#include "emulator.h"
#include "debug_ch.h"
+// DEBUGCH file is located in binary directory.
+char bin_dir[256] = {0,};
+
static char logpath[512] = {0,};
-static char debugchfile[256] = {0, };
+static char debugchfile[512] = {0, };
#ifdef _WIN32
static HANDLE handle;
#endif
strcpy(debugchfile, get_etc_path());
strcat(debugchfile, "/DEBUGCH");
#endif
- strcpy(debugchfile, "DEBUGCH");
+ if ( 0 == strlen( bin_dir ) ) {
+ strcpy( debugchfile, "DEBUGCH" );
+ } else {
+ strcat( debugchfile, bin_dir );
+#ifdef _WIN32
+ strcat( debugchfile, "\\" );
+#else
+ strcat( debugchfile, "/" );
+#endif
+ strcat( debugchfile, "DEBUGCH" );
+ }
fp= fopen(debugchfile, "r");
if( fp == NULL){
(dbg_log(__DBCL##dbcl,(dbch), "") == -1)) ? \
(void)0 : (void)dbg_printf
*/
+
+extern char bin_dir[256];
+
extern unsigned char _dbg_get_channel_flags( struct _debug_channel *channel );
extern int _dbg_set_channel_flags( struct _debug_channel *channel,
unsigned char set, unsigned char clear );
}
}
+static void get_bin_dir( char* exec_argv ) {
+
+ if ( !exec_argv ) {
+ return;
+ }
+
+ char* data = strdup( exec_argv );
+ if ( !data ) {
+ fprintf( stderr, "Fail to strdup for paring a binary directory.\n" );
+ return;
+ }
+
+ char* p = NULL;
+#ifdef _WIN32
+ p = strrchr( data, '\\' );
+ if ( !p ) {
+ p = strrchr( data, '/' );
+ }
+#else
+ p = strrchr( data, '/' );
+#endif
+ if ( !p ) {
+ return;
+ }
+
+ strncpy( bin_dir, data, strlen( data ) - strlen( p ) );
+
+ free( data );
+
+}
+
void set_image_and_log_path(char* qemu_argv)
{
int i;
int main(int argc, char* argv[])
{
parse_options(argc, argv, &skin_argc, &skin_argv, &qemu_argc, &qemu_argv);
+ get_bin_dir( qemu_argv[0] );
socket_init();
extract_info(qemu_argc, qemu_argv);