Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[dsdp-dd-dev] Progress on remote target debugging in Windows

Hi everybody,
I'd just thought I'd share my debugging progress. This will be a Long Mail (tm).

Here is my setup on the target side:
 o QEMU Arm running Linux 2.6.24
 o gdb 6.7.1

My setup on the host side:
  o Eclipse 3.4
  o CDT 5.0.0.200802111122
  o Latest (since yesterday evening Swedish time) from CVS for org.eclipse.dd and company:
      org.eclipse.core.filebuffers
      org.eclipse.dd.doc.dsf
      org.eclipse.dd.dsf
      org.eclipse.dd.dsf.debug
      org.eclipse.dd.dsf.debug.ui
      org.eclipse.dd.dsf.ui
      org.eclipse.dd.gdb
      org.eclipse.dd.gdb.ui
      org.eclipse.dd.mi
      org.eclipse.dd.tests.dsf
      org.eclipse.dd.tests.gdb
      org.eclipse.debug.core
      org.eclipse.debug.ui
  o Java 1.5
  o CodeSourcery GNU gdb (CodeSourcery Sourcery G++ Lite 2007q3-51) 6.6.50.20070821-cvs


The file I'm debugging - gdb_test.c:

#include <stdio.h>

int main()
{
	printf("LALALALALALA\n");
	return 0;
}


The steps to get it to work, and the problems I'm facing:

1. Create a debug session in the debug dialog (Debug configurations...)
2. Choose C++ Local Application (Experimental DSF) - New
3. Choose the project and the binary in the Main tab
4. In the Debugger tab:
4.1 Select gdbserver Debugger
4.2 Deselect "Stop on startup at:", otherwise the gdbserver quits immediately
4.3 Debugger options
4.3.1 Main tab - select the CodeSourcery debugger exe + verbode console mode
4.3.2 Connection tab - select TCP, the IP to the QEMU computer and the gdbserver port
4.4 Start the gdbserver in QEMU - "gdbserver 192.168.0.10:12345 ./gdb_test"
4.5 If everything works fine, the debugger should connect when pressing debug.
Output on console:
target remote 192.168.0.10:12345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Remote debugging using 192.168.0.10:12345
0x400007c0 in ?? ()
4.6 by manually setting the source directory from the console - "directory c:/workspace/test" I am then able to set a breakpoint manually
Output:
Source directories searched: c:/workspace/test;$cdir;$cwd
4.7 Manual breakpoint definition: "break c:/workspace/test/gdb_test.c:5"
Output:
Breakpoint 1 at 0x8370: file gdb_test.c, line 5.

Two days ago, I was able to set a breakpoint using Eclipse, but when I do it today, the following message is printed on console:
No source file named C:\workspace\test\gdb_test.c
My suspicion is that the back-slashes should be replaced by slashes.
Also, it only worked after manually setting the source directory using the "directory" command.

Here are my patches for getting remoting to work, remember that it is just a test:

Index: LaunchSequence.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.dd.dsf/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/launching/LaunchSequence.java,v
retrieving revision 1.1
diff -u -r1.1 LaunchSequence.java
--- LaunchSequence.java	13 Feb 2008 20:27:01 -0000	1.1
+++ LaunchSequence.java	15 Feb 2008 08:40:01 -0000
@@ -15,6 +15,7 @@
 import org.eclipse.cdt.debug.core.CDebugCorePlugin;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
+import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -41,9 +42,11 @@
 import org.eclipse.dd.mi.service.MIRegisters;
 import org.eclipse.dd.mi.service.MIStack;
 import org.eclipse.dd.mi.service.command.commands.MIBreakInsert;
+import org.eclipse.dd.mi.service.command.commands.MIConnectToTargetTCP;
 import org.eclipse.dd.mi.service.command.commands.MIExecRun;
 import org.eclipse.dd.mi.service.command.events.MIStoppedEvent;
 import org.eclipse.dd.mi.service.command.output.MIBreakInsertInfo;
+import org.eclipse.dd.mi.service.command.output.MIConnectToTargetTcpInfo;
 import org.eclipse.dd.mi.service.command.output.MIInfo;
 import org.eclipse.debug.core.DebugException;
 
@@ -82,7 +85,98 @@
                 fCommandControl.initialize(requestMonitor);
             }
         },
-        new Step() { @Override
+		/*
+		 * If starting remotely, add remote step
+		 * 
+		 */
+		new Step() {
+			private boolean launchRemote = false;
+			private String fRemoteTcpHost;
+			private String fRemoteTcpPort;
+
+			private boolean checkLaunchRemote(RequestMonitor requestMonitor) {
+				try {
+					launchRemote = fLaunch
+							.getLaunchConfiguration()
+							.getAttribute(
+									IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP,
+									false);
+				} catch (CoreException e) {
+					requestMonitor.setStatus(new Status(IStatus.ERROR,
+							GdbPlugin.PLUGIN_ID, -1,
+							"Cannot retrieve debugger mode", e)); //$NON-NLS-1$
+					requestMonitor.done();
+					return false;
+				}
+				return true;
+			}
+
+			private boolean getTcpHost(RequestMonitor requestMonitor) {
+				try {
+					fRemoteTcpHost = fLaunch
+							.getLaunchConfiguration()
+							.getAttribute(
+									IGDBServerMILaunchConfigurationConstants.ATTR_HOST,
+									"localhost");
+				} catch (CoreException e) {
+					requestMonitor.setStatus(new Status(IStatus.ERROR,
+							GdbPlugin.PLUGIN_ID, -1,
+							"Cannot retrieve remote TCP host", e)); //$NON-NLS-1$
+					requestMonitor.done();
+					return false;
+				}
+				return true;
+			}
+
+			private boolean getTcpPort(RequestMonitor requestMonitor) {
+				try {
+					fRemoteTcpPort = fLaunch
+							.getLaunchConfiguration()
+							.getAttribute(
+									IGDBServerMILaunchConfigurationConstants.ATTR_PORT,
+									"10000");
+				} catch (CoreException e) {
+					requestMonitor.setStatus(new Status(IStatus.ERROR,
+							GdbPlugin.PLUGIN_ID, -1,
+							"Cannot retrieve remote TCP port", e)); //$NON-NLS-1$
+					requestMonitor.done();
+					return false;
+
+				}
+				return true;
+			}
+
+			@Override
+			public void execute(final RequestMonitor requestMonitor) {
+				if (!checkLaunchRemote(requestMonitor)) {
+					return;
+				}
+				if (!launchRemote) {
+					requestMonitor.done();
+					return;
+				}
+				if (!getTcpHost(requestMonitor)) {
+					return;
+				}
+				if (!getTcpPort(requestMonitor)) {
+					return;
+				}
+				fCommandControl
+						.queueCommand(
+								new MIConnectToTargetTCP(fCommandControl
+										.getControlDMContext(),
+										fRemoteTcpHost, fRemoteTcpPort),
+								new DataRequestMonitor<MIConnectToTargetTcpInfo>(
+										getExecutor(), requestMonitor) {
+									@Override
+									protected void handleOK() {
+										System.out.println("Connected to: "
+												+ getData().getValue());
+										requestMonitor.done();
+									}
+								});
+			}
+		},        new Step() { @Override
         public void execute(RequestMonitor requestMonitor) {
             new GDBRunControl(fSession).initialize(requestMonitor);
         }},



Index: MIConnectToTargetTCP.java
===================================================================
RCS file: MIConnectToTargetTCP.java
diff -N MIConnectToTargetTCP.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MIConnectToTargetTCP.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,19 @@
+package org.eclipse.dd.mi.service.command.commands;
+
+import org.eclipse.dd.dsf.datamodel.IDMContext;
+import org.eclipse.dd.mi.service.command.output.MIConnectToTargetTcpInfo;
+import org.eclipse.dd.mi.service.command.output.MIOutput;
+
+public class MIConnectToTargetTCP extends MICommand<MIConnectToTargetTcpInfo> {
+
+	public MIConnectToTargetTCP(IDMContext ctx, String host, String port) {
+		super(ctx, "target remote " + host + ":" + port); //$NON-NLS-1$
+	}
+
+	@Override
+	public MIConnectToTargetTcpInfo getResult(MIOutput result) {
+		return new MIConnectToTargetTcpInfo(result);
+	}
+
+	
+}



Index: MIConnectToTargetTcpInfo.java
===================================================================
RCS file: MIConnectToTargetTcpInfo.java
diff -N MIConnectToTargetTcpInfo.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MIConnectToTargetTcpInfo.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,34 @@
+package org.eclipse.dd.mi.service.command.output;
+
+public class MIConnectToTargetTcpInfo extends MIInfo {
+
+	private String value;
+
+	public MIConnectToTargetTcpInfo(MIOutput record) {
+		super(record);
+    	if (isDone()) {
+    		MIOutput out = getMIOutput();
+    		MIResultRecord rr = out.getMIResultRecord();
+    		for (MIOOBRecord value : out.getMIOOBRecords()) {
+				System.out.println(value.toString());
+			}
+    		if (rr != null) {
+    			MIResult[] results =  rr.getMIResults();
+    			for (int i = 0; i < results.length; i++) {
+    				String var = results[i].getVariable();
+    				if (var.equals("value")) { //$NON-NLS-1$
+    					MIValue val = results[i].getMIValue();
+    					if (val instanceof MIConst) {
+    						value = ((MIConst)val).getCString();
+    					}
+    				}
+    			}
+    		}
+    	}
+	}
+
+	public String getValue() {
+		return value;
+	}
+	
+}





Back to the top