diff -urpb dosbox-idados.orig/include/debug.h dosbox-idados/include/debug.h
--- dosbox-idados.orig/include/debug.h	2013-04-22 13:07:10 +0400
+++ dosbox-idados/include/debug.h	2013-05-05 00:47:11 +0400
@@ -21,7 +21,7 @@ void DEBUG_DrawScreen(void);
 bool DEBUG_Breakpoint(void);
 bool DEBUG_IntBreakpoint(Bit8u intNum);
 void DEBUG_Enable(bool pressed);
-void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off);
+void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off, char * name);
 bool DEBUG_ExitLoop(void);
 void DEBUG_RefreshPage(char scroll);
 Bitu DEBUG_EnableDebugger(void);
diff -urpb dosbox-idados.orig/src/debug/debug.cpp dosbox-idados/src/debug/debug.cpp
--- dosbox-idados.orig/src/debug/debug.cpp	2013-04-22 13:07:10 +0400
+++ dosbox-idados/src/debug/debug.cpp	2013-05-06 00:10:33 +0400
@@ -84,6 +84,7 @@ bool DEBUG_DelBreakPoint(PhysPt address)
 int DEBUG_Continue(void);
 int DEBUG_ContinueWithoutDebug();
 string DEBUG_GetFileName();
+bool DEBUG_ParseCommand(char* str);
 #endif
 
 char* AnalyzeInstruction(char* inst, bool saveSelector);
@@ -115,6 +116,8 @@ bool	exitLoop	= false;
 
 #ifdef C_IDA_DEBUG
 static string debug_filename;
+static bool debug_int3 = false;
+static bool debug_ep = false;
 #endif
 
 // Heavy Debugging Vars for logging
@@ -666,10 +669,22 @@ void CBreakpoint::ShowList(void)
 bool DEBUG_Breakpoint(void)
 {
 	/* First get the phyiscal address and check for a set Breakpoint */
+#ifndef C_IDA_DEBUG
 	if (!CBreakpoint::CheckBreakpoint(SegValue(cs),reg_eip)) return false;
+#else
+	if (!CBreakpoint::CheckBreakpoint(SegValue(cs),reg_eip)) {
+		if (debug_int3) reg_eip++;
+		else return false;
+	}
+#endif
 	// Found. Breakpoint is valid
 	PhysPt where=GetAddress(SegValue(cs),reg_eip);
 	CBreakpoint::ActivateBreakpoints(where,false);	// Deactivate all breakpoints
+
+#ifdef C_IDA_DEBUG
+	idados_hit_breakpoint(where);
+#endif
+
 	return true;
 };
 
@@ -1821,6 +1836,7 @@ Bitu DEBUG_Loop(void) {
 	return DEBUG_CheckKeys();
 #else
 	Bits ret;
+	static bool ida_connected = false;
 
 	//idados ret = DEBUG_RemoteHandleCMD();
 	ret = idados_handle_command();
@@ -1836,8 +1852,19 @@ Bitu DEBUG_Loop(void) {
 		}
 	}
 
-	if(idados_is_running())
+	if (idados_is_running()) {
 		DEBUG_Continue();
+		if (!ida_connected) {
+			// ida connected in idados_handle_command
+			ida_connected = true;
+			debug_int3 = true;
+			debug_ep = true;
+
+			// EP breakpoint
+			//CBreakpoint::ActivateBreakpoints((PhysPt) -1,true);
+			//ignoreAddressOnce = 0;
+		}
+	}
 
 	return 0;
 #endif
@@ -2104,6 +2131,7 @@ static void LogInstruction(Bit16u segVal
 		    << " CR0:" << setw(8) << cpu.cr0;	
 	}
 	out << endl;
+	fflush(stdout);
 };
 #endif
 
@@ -2135,6 +2163,15 @@ public:
 		Bit16u i	=2;
 		args[0]		= 0;
 		for (;cmd->FindCommand(i++,temp_line)==true;) {
+#ifdef C_IDA_DEBUG
+			if (i == 3 && temp_line.length() > 7 &&
+				temp_line.find("/DEBUG:") == 0)
+			{
+				// file to debug after INT 21,4B
+				debug_filename = temp_line.substr(7);
+				continue;
+			}
+#endif
 			strncat(args,temp_line.c_str(),256);
 			strncat(args," ",256);
 		}
@@ -2176,9 +2213,21 @@ private:
 	bool	active;
 };
 
-void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off)
+void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off, char * name)
 {
+#ifndef C_IDA_DEBUG
 	if (pDebugcom && pDebugcom->IsActive()) {
+#else
+	if ((pDebugcom && pDebugcom->IsActive()) || debug_ep) {
+		if (pDebugcom) {
+			int len = strlen(name);
+			int len_d = debug_filename.length();
+			if (len < len_d || stricmp(&name[len - len_d], debug_filename.c_str()) != 0)
+				return; // start debug only on needed file
+		}
+		printf("DEBUG_CheckExecuteBreakpoint\n");
+		fflush(stdout);
+#endif
 		CBreakpoint::AddBreakpoint(seg,off,true);		
 		CBreakpoint::ActivateBreakpoints(SegPhys(cs)+reg_eip,true);	
 
@@ -2186,7 +2235,7 @@ void DEBUG_CheckExecuteBreakpoint(Bit16u
 #ifdef C_IDA_DEBUG
 		//ERIC FIXME can we safely comment out this line so we can use pDebugcom in debug_remote_inc.h
 #endif
-	};
+	}
 };
 
 Bitu DEBUG_EnableDebugger(void)
@@ -2567,6 +2616,9 @@ void DEBUG_HeavyWriteLogInstruction(void
 };
 
 bool DEBUG_HeavyIsBreakpoint(void) {
+//	printf("DEBUG_HeavyIsBreakpoint: %x\n", GetAddress(SegValue(cs),reg_eip));
+//	if (GetAddress(SegValue(cs),reg_eip) == 0x33b4)
+//		reg_eip += 0;
 	static Bitu zero_count = 0;
 	if (cpuLog) {
 		if (cpuLogCounter>0) {
@@ -2602,7 +2654,6 @@ bool DEBUG_HeavyIsBreakpoint(void) {
 		if (mouselocked) GFX_CaptureMouse();
 
 		idados_hit_breakpoint(SegPhys(cs)+reg_eip);
-
 #endif
 		return true;
 	}
@@ -2615,6 +2666,7 @@ bool DEBUG_HeavyIsBreakpoint(void) {
 bool DEBUG_AddBreakPoint(Bit32u address, bool once)
 {
 	CBreakpoint::AddBreakpoint((Bit16u)(address / 0x10), (Bit32u)address % 0x10, once);
+	fflush(stdout);
 
 	return true;
 }
@@ -2622,6 +2674,7 @@ bool DEBUG_AddBreakPoint(Bit32u address,
 bool DEBUG_AddMemBreakPoint(Bit32u address)
 {
 	CBreakpoint::AddMemBreakpoint((Bit16u)(address / 0x10), (Bit32u)address % 0x10);
+	fflush(stdout);
 
 	return true;
 }
@@ -2630,6 +2683,7 @@ bool DEBUG_DelBreakPoint(PhysPt address)
 {
 	printf("delete breakpoint at %x\n", address);
 	CBreakpoint::DeleteBreakpoint(address);
+	fflush(stdout);
 
 	return true;
 }
@@ -2649,6 +2703,7 @@ Bits DEBUG_RemoteStep(void)
 	CBreakpoint::ignoreOnce = 0;
 
 	printf("Stepping. New CS:IP = %x\n", GetAddress(SegValue(cs), (unsigned long)reg_eip));
+	fflush(stdout);
 	return ret;
 }
 
@@ -2660,6 +2715,7 @@ int DEBUG_Continue(void)
 
 	ignoreAddressOnce = SegPhys(cs)+reg_eip;
 	DOSBOX_SetNormalLoop();
+	fflush(stdout);
 
 	return 1;
 }
@@ -2670,6 +2726,7 @@ int DEBUG_ContinueWithoutDebug()
 	CDebugVar::DeleteAll();
 	debugging = false;
 	DOSBOX_SetNormalLoop();
+	fflush(stdout);
 
 	return 1;
 }
@@ -2684,8 +2741,26 @@ void DEBUG_AppTerminated()
 	//idados remote_process_terminated();
 }
 
-#endif
+bool DEBUG_ParseCommand(char* str)
+{
+	int result = 0;
 
-#endif // DEBUG
+	if (strcmp(str, "BPINT3") == 0) {
+		debug_int3 = !debug_int3;
+		printf("BPINT3 %d\n", (int) debug_int3);
 
+	} else if (strcmp(str, "BPEP") == 0) {
+		debug_ep = !debug_ep;
+		printf("BPEP %d\n", (int) debug_ep);
 
+	} else {
+		result = ParseCommand(str);
+	}
+
+	fflush(stdout);
+	return result;
+}
+
+#endif
+
+#endif // DEBUG
diff -urpb dosbox-idados.orig/src/debug/server.cpp dosbox-idados/src/debug/server.cpp
--- dosbox-idados.orig/src/debug/server.cpp	2013-04-22 13:07:10 +0400
+++ dosbox-idados/src/debug/server.cpp	2013-05-01 20:16:12 +0400
@@ -5,7 +5,7 @@
 #include "server.h"
 #include "dosbox_debmod.h"
 
-#ifdef _MSC_VER
+#if defined (_MSC_VER) || defined (_WIN32)
 typedef int socklen_t;
 #endif
 
@@ -270,7 +270,7 @@ int handle_session(rpc_server_t *server)
 
   // Add the session to the list
   srv_lock_begin();
-  clients_list[server] = t;
+  clients_list[server] = (qthread_t) t;
   g_global_server = server;
   srv_lock_end();
 
diff -urpb dosbox-idados.orig/src/debug/server.h dosbox-idados/src/debug/server.h
--- dosbox-idados.orig/src/debug/server.h	2013-04-22 13:07:10 +0400
+++ dosbox-idados/src/debug/server.h	2013-05-01 20:16:12 +0400
@@ -39,4 +39,5 @@
 #error "Mixed mode servers do not make sense, they should not be compiled"
 #endif
 
+typedef std::map<rpc_server_t *, qthread_t> rpc_server_list_t;
 extern rpc_server_list_t clients_list;
diff -urpb dosbox-idados.orig/src/dos/dos_execute.cpp dosbox-idados/src/dos/dos_execute.cpp
--- dosbox-idados.orig/src/dos/dos_execute.cpp	2013-04-22 13:07:10 +0400
+++ dosbox-idados/src/dos/dos_execute.cpp	2013-05-05 00:47:31 +0400
@@ -482,7 +482,7 @@ bool DOS_Execute(char * name,PhysPt bloc
 		SegSet16(ds,pspseg);SegSet16(es,pspseg);
 #if C_DEBUG		
 		/* Started from debug.com, then set breakpoint at start */
-		DEBUG_CheckExecuteBreakpoint(RealSeg(csip),RealOff(csip));
+		DEBUG_CheckExecuteBreakpoint(RealSeg(csip),RealOff(csip),name);
 #endif
 		/* Add the filename to PSP and environment MCB's */
 		char stripname[8]= { 0 };Bitu index=0;
