mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 19:25:38 +02:00
Implemented get and adding to the gdb search source paths.
This commit is contained in:
parent
2e5306c7b2
commit
97fb504d21
4 changed files with 116 additions and 10 deletions
|
@ -6,8 +6,6 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISourceManager;
|
import org.eclipse.cdt.debug.core.cdi.ICDISourceManager;
|
||||||
|
@ -15,6 +13,8 @@ import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory;
|
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowDirectories;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowDirectoriesInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,11 +22,8 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
*/
|
*/
|
||||||
public class SourceManager extends SessionObject implements ICDISourceManager {
|
public class SourceManager extends SessionObject implements ICDISourceManager {
|
||||||
|
|
||||||
List sourcePaths;
|
|
||||||
|
|
||||||
public SourceManager(CSession session) {
|
public SourceManager(CSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
sourcePaths = new ArrayList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,16 +58,22 @@ public class SourceManager extends SessionObject implements ICDISourceManager {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.getMessage());
|
throw new CDIException(e.getMessage());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < dirs.length; i++) {
|
|
||||||
sourcePaths.add(dirs[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getSourcePaths()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getSourcePaths()
|
||||||
*/
|
*/
|
||||||
public String[] getSourcePaths() {
|
public String[] getSourcePaths() throws CDIException {
|
||||||
return (String[])sourcePaths.toArray(new String[0]);
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIGDBShowDirectories dir = factory.createMIGDBShowDirectories();
|
||||||
|
try {
|
||||||
|
mi.postCommand(dir);
|
||||||
|
MIGDBShowDirectoriesInfo info = dir.getMIGDBShowDirectoriesInfo();
|
||||||
|
return info.getDirectories();
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new CDIException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -171,6 +171,10 @@ public class CommandFactory {
|
||||||
return new MIGDBShowExitCode();
|
return new MIGDBShowExitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIGDBShowDirectories createMIGDBShowDirectories() {
|
||||||
|
return new MIGDBShowDirectories();
|
||||||
|
}
|
||||||
|
|
||||||
public MIStackInfoDepth createMIStackInfoDepth(int depth) {
|
public MIStackInfoDepth createMIStackInfoDepth(int depth) {
|
||||||
return new MIStackInfoDepth(depth);
|
return new MIStackInfoDepth(depth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.mi.core.command;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowDirectoriesInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* -gdb-show directories
|
||||||
|
*
|
||||||
|
* Show the current value of a GDB variable(directories).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIGDBShowDirectories extends MIGDBShow {
|
||||||
|
public MIGDBShowDirectories() {
|
||||||
|
super(new String[] { "directories" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIGDBShowDirectoriesInfo getMIGDBShowDirectoriesInfo() throws MIException {
|
||||||
|
return (MIGDBShowDirectoriesInfo)getMIInfo();
|
||||||
|
}
|
||||||
|
public MIInfo getMIInfo() throws MIException {
|
||||||
|
MIInfo info = null;
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
if (out != null) {
|
||||||
|
info = new MIGDBShowDirectoriesInfo(out);
|
||||||
|
if (info.isError()) {
|
||||||
|
throw new MIException(info.getErrorMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GDB/MI show parsing.
|
||||||
|
* (gdb)
|
||||||
|
* -gdb-show directories
|
||||||
|
* ~"Source directories searched: /tmp:$cdir:$cwd\n"
|
||||||
|
* ^done
|
||||||
|
*/
|
||||||
|
public class MIGDBShowDirectoriesInfo extends MIInfo {
|
||||||
|
|
||||||
|
String[] dirs = new String[0];
|
||||||
|
|
||||||
|
public MIGDBShowDirectoriesInfo(MIOutput o) {
|
||||||
|
super(o);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getDirectories() {
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIOOBRecord[] oobs = out.getMIOOBRecords();
|
||||||
|
for (int i = 0; i < oobs.length; i++) {
|
||||||
|
if (oobs[i] instanceof MIConsoleStreamOutput) {
|
||||||
|
MIStreamRecord cons = (MIStreamRecord)oobs[i];
|
||||||
|
String str = cons.getString();
|
||||||
|
if (str.startsWith("Source directories searched:")) {
|
||||||
|
int j = str.indexOf(':');
|
||||||
|
if (j != -1) {
|
||||||
|
String sub = str.substring(j + 1).trim();
|
||||||
|
parseDirectories(sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseDirectories(String d) {
|
||||||
|
String sep = System.getProperty("path.separator", ":");
|
||||||
|
StringTokenizer st = new StringTokenizer(d, sep);
|
||||||
|
int count = st.countTokens();
|
||||||
|
dirs = new String[count];
|
||||||
|
for (int i = 0; st.hasMoreTokens() && i < count; i++) {
|
||||||
|
dirs[i] = (String)st.nextToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue