1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

Better MI support on Mac OS: MI version of shared lib info, also allow CommandFactory to provide initial directory specification so it can be quoted.

This commit is contained in:
Ken Ryall 2007-05-04 21:12:39 +00:00
parent aa25f29965
commit 27043fdba7
8 changed files with 153 additions and 21 deletions

View file

@ -43,6 +43,7 @@ import org.eclipse.cdt.debug.mi.core.command.MIGDBSetSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetStopOnSolibEvents; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetStopOnSolibEvents;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShow; import org.eclipse.cdt.debug.mi.core.command.MIGDBShow;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath; import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.MIInfoSharedLibrary;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIEvent; import org.eclipse.cdt.debug.mi.core.event.MIEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MISharedLibChangedEvent;
@ -53,6 +54,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowInfo; import org.eclipse.cdt.debug.mi.core.output.MIGDBShowInfo;
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowSolibSearchPathInfo; import org.eclipse.cdt.debug.mi.core.output.MIGDBShowSolibSearchPathInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfoSharedLibraryInfo;
import org.eclipse.cdt.debug.mi.core.output.MIShared; import org.eclipse.cdt.debug.mi.core.output.MIShared;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -86,6 +88,24 @@ public class SharedLibraryManager extends Manager {
MIShared[] getMIShareds(MISession miSession) throws CDIException { MIShared[] getMIShareds(MISession miSession) throws CDIException {
MIShared[] miLibs = new MIShared[0]; MIShared[] miLibs = new MIShared[0];
CommandFactory factory = miSession.getCommandFactory(); CommandFactory factory = miSession.getCommandFactory();
MIInfoSharedLibrary infoSharedMI = factory.createMIInfoSharedLibrary();
if (infoSharedMI != null)
{
try {
miSession.postCommand(infoSharedMI);
MIInfoSharedLibraryInfo info = infoSharedMI.getMIInfoSharedLibraryInfo();
if (info == null) {
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
}
miLibs = info.getMIShared();
} catch (MIException e) {
throw new MI2CDIException(e);
}
}
else
{
CLIInfoSharedLibrary infoShared = factory.createCLIInfoSharedLibrary(); CLIInfoSharedLibrary infoShared = factory.createCLIInfoSharedLibrary();
try { try {
RxThread rxThread = miSession.getRxThread(); RxThread rxThread = miSession.getRxThread();
@ -102,6 +122,8 @@ public class SharedLibraryManager extends Manager {
RxThread rxThread = miSession.getRxThread(); RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true); rxThread.setEnableConsole(true);
} }
}
return miLibs; return miLibs;
} }

View file

@ -19,7 +19,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
public class CLIInfoLine extends CLICommand { public class CLIInfoLine extends CLICommand {
public CLIInfoLine(IAddress address) { public CLIInfoLine(IAddress address) {
super("info line *" + address.toHexAddressString()); super("info line *" + address.toHexAddressString()); //$NON-NLS-1$
} }
public CLIInfoLineInfo getMIInfoLineInfo() throws MIException { public CLIInfoLineInfo getMIInfoLineInfo() throws MIException {

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.debug.mi.core.command; package org.eclipse.cdt.debug.mi.core.command;
import java.io.File;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
@ -428,4 +430,12 @@ public class CommandFactory {
public MIGDBSetNewConsole createMIGDBSetNewConsole() { public MIGDBSetNewConsole createMIGDBSetNewConsole() {
return new MIGDBSetNewConsole(getMIVersion()); return new MIGDBSetNewConsole(getMIVersion());
} }
public MIInfoSharedLibrary createMIInfoSharedLibrary() {
return null;
}
public String getWorkingDirectory(File cwd) {
return "--cd=" + cwd.getAbsolutePath(); //$NON-NLS-1$
}
} }

View file

@ -0,0 +1,30 @@
package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfoSharedLibraryInfo;
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
public class MIInfoSharedLibrary extends MICommand {
public MIInfoSharedLibrary(String miVersion) {
super(miVersion, "info sharedlibrary"); //$NON-NLS-1$
}
public MIInfo getMIInfo() throws MIException {
MIInfo info = null;
MIOutput out = getMIOutput();
if (out != null) {
info = new MIInfoSharedLibraryInfo(out);
if (info.isError()) {
throwMIException(info, out);
}
}
return info;
}
public MIInfoSharedLibraryInfo getMIInfoSharedLibraryInfo() throws MIException {
return (MIInfoSharedLibraryInfo) getMIInfo();
}
}

View file

@ -10,7 +10,10 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.mi.core.command.factories.macos; package org.eclipse.cdt.debug.mi.core.command.factories.macos;
import java.io.File;
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD; import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
import org.eclipse.cdt.debug.mi.core.command.MIInfoSharedLibrary;
import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory; import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory;
public class StandardMacOSCommandFactory extends StandardCommandFactory { public class StandardMacOSCommandFactory extends StandardCommandFactory {
@ -22,6 +25,10 @@ public class StandardMacOSCommandFactory extends StandardCommandFactory {
super(); super();
} }
public String getWorkingDirectory(File cwd) {
return "--cd=" + '"' + cwd.getAbsolutePath() + '"'; //$NON-NLS-1$
}
/** /**
* Constructor for StandardMacOSCommandFactory. * Constructor for StandardMacOSCommandFactory.
*/ */
@ -33,4 +40,8 @@ public class StandardMacOSCommandFactory extends StandardCommandFactory {
return new MacOSMIEnvironmentCD(getMIVersion(), pathdir); return new MacOSMIEnvironmentCD(getMIVersion(), pathdir);
} }
public MIInfoSharedLibrary createMIInfoSharedLibrary() {
return new MIInfoSharedLibrary(getMIVersion());
}
} }

View file

@ -71,27 +71,27 @@ public class CLIInfoLineInfo extends MIInfo {
} }
protected void parseLineInfo(String str, List aList) { protected void parseLineInfo(String str, List aList) {
String[] strbits = str.split("\\s"); String[] strbits = str.split("\\s"); //$NON-NLS-1$
for (int i = 0; i < strbits.length; i++) { for (int i = 0; i < strbits.length; i++) {
if (strbits[i].equals("Line")) if (strbits[i].equals("Line")) //$NON-NLS-1$
{ {
lineNumber = Integer.parseInt(strbits[i+1]); lineNumber = Integer.parseInt(strbits[i+1]);
} }
else else
if (strbits[i].equals("starts")) if (strbits[i].equals("starts")) //$NON-NLS-1$
{ {
startAddress = new BigInteger(strbits[i+3].substring(2), 16); startAddress = new BigInteger(strbits[i+3].substring(2), 16);
startLocation = strbits[i+4]; startLocation = strbits[i+4];
} }
else else
if (strbits[i].equals("ends")) if (strbits[i].equals("ends")) //$NON-NLS-1$
{ {
endAddress = new BigInteger(strbits[i+2].substring(2), 16); endAddress = new BigInteger(strbits[i+2].substring(2), 16);
endLocation = strbits[i+3]; endLocation = strbits[i+3];
} }
} }
strbits = str.split("\""); strbits = str.split("\""); //$NON-NLS-1$
for (int i = 0; i < strbits.length; i++) { for (int i = 0; i < strbits.length; i++) {
fileName = strbits[1]; fileName = strbits[1];
} }

View file

@ -0,0 +1,58 @@
package org.eclipse.cdt.debug.mi.core.output;
import java.util.ArrayList;
public class MIInfoSharedLibraryInfo extends MIInfo {
MIShared[] shared = new MIShared[0];
public MIInfoSharedLibraryInfo(MIOutput record) {
super(record);
parse();
}
private void parse() {
if (isDone()) {
ArrayList aList = new ArrayList();
MIOutput out = getMIOutput();
MIResultRecord rr = out.getMIResultRecord();
if (rr != null) {
MIResult[] results = rr.getMIResults();
for (int i = 0; i < results.length; i++) {
String var = results[i].getVariable();
if (var.equals("shlib-info")) { //$NON-NLS-1$
MIValue val = results[i].getMIValue();
if (val instanceof MITuple)
{
MIResult[] libResults = ((MITuple)val).getMIResults();
String from = ""; //$NON-NLS-1$
String to = ""; //$NON-NLS-1$
boolean syms = true;
String name = ""; //$NON-NLS-1$
for (int j = 0; j < libResults.length; j++) {
if (libResults[j].getVariable().equals("description")) //$NON-NLS-1$
{
name = libResults[j].getMIValue().toString();
}
if (libResults[j].getVariable().equals("loaded_addr")) //$NON-NLS-1$
{
from = libResults[j].getMIValue().toString();
to = from;
}
}
MIShared s = new MIShared(from, to, syms, name);
aList.add(s);
}
}
}
}
shared = (MIShared[]) aList.toArray(new MIShared[aList.size()]);
}
}
public MIShared[] getMIShared() {
return shared;
}
}

View file

@ -236,7 +236,8 @@ public class GDBCDIDebugger2 extends AbstractGDBCDIDebugger {
protected String getWorkingDirectory( ILaunchConfiguration config ) throws CoreException { protected String getWorkingDirectory( ILaunchConfiguration config ) throws CoreException {
File cwd = getProjectPath( config ).toFile(); File cwd = getProjectPath( config ).toFile();
return "--cd=" + cwd.getAbsolutePath(); //$NON-NLS-1$ CommandFactory factory = getCommandFactory( config );
return factory.getWorkingDirectory(cwd);
} }
protected String getCommandFile( ILaunchConfiguration config ) throws CoreException { protected String getCommandFile( ILaunchConfiguration config ) throws CoreException {