1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 16:55: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.MIGDBShow;
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.MIEvent;
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.MIGDBShowSolibSearchPathInfo;
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.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@ -86,21 +88,41 @@ public class SharedLibraryManager extends Manager {
MIShared[] getMIShareds(MISession miSession) throws CDIException {
MIShared[] miLibs = new MIShared[0];
CommandFactory factory = miSession.getCommandFactory();
CLIInfoSharedLibrary infoShared = factory.createCLIInfoSharedLibrary();
try {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(false);
miSession.postCommand(infoShared);
CLIInfoSharedLibraryInfo info = infoShared.getMIInfoSharedLibraryInfo();
if (info == null) {
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
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);
}
miLibs = info.getMIShared();
} catch (MIException e) {
throw new MI2CDIException(e);
} finally {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true);
}
else
{
CLIInfoSharedLibrary infoShared = factory.createCLIInfoSharedLibrary();
try {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(false);
miSession.postCommand(infoShared);
CLIInfoSharedLibraryInfo info = infoShared.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);
} finally {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true);
}
}
return miLibs;
}

View file

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

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.debug.mi.core.command;
import java.io.File;
import org.eclipse.cdt.core.IAddress;
@ -428,4 +430,12 @@ public class CommandFactory {
public MIGDBSetNewConsole createMIGDBSetNewConsole() {
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;
import java.io.File;
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;
public class StandardMacOSCommandFactory extends StandardCommandFactory {
@ -22,6 +25,10 @@ public class StandardMacOSCommandFactory extends StandardCommandFactory {
super();
}
public String getWorkingDirectory(File cwd) {
return "--cd=" + '"' + cwd.getAbsolutePath() + '"'; //$NON-NLS-1$
}
/**
* Constructor for StandardMacOSCommandFactory.
*/
@ -33,4 +40,8 @@ public class StandardMacOSCommandFactory extends StandardCommandFactory {
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) {
String[] strbits = str.split("\\s");
String[] strbits = str.split("\\s"); //$NON-NLS-1$
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]);
}
else
if (strbits[i].equals("starts"))
if (strbits[i].equals("starts")) //$NON-NLS-1$
{
startAddress = new BigInteger(strbits[i+3].substring(2), 16);
startLocation = strbits[i+4];
}
else
if (strbits[i].equals("ends"))
if (strbits[i].equals("ends")) //$NON-NLS-1$
{
endAddress = new BigInteger(strbits[i+2].substring(2), 16);
endLocation = strbits[i+3];
}
}
strbits = str.split("\"");
strbits = str.split("\""); //$NON-NLS-1$
for (int i = 0; i < strbits.length; i++) {
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 {
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 {