Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] info shared

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.61
diff -u -r1.61 ChangeLog
--- ChangeLog	13 Jan 2003 22:19:34 -0000	1.61
+++ ChangeLog	16 Jan 2003 03:10:52 -0000
@@ -1,3 +1,11 @@
+2003-01-15 Alain Magloire
+
+	* src/.../mi/core/command/CommandFactory.java (createMIInfoSharedLibrary):
+	New method.
+	* src/../mi/core/command/MIInfoSharedLibrary.java: New file.
+	* src/../mi/core/output/MIInfoSharedLibraryInfo.java: New File.
+	* src/../mi/core/output/MIShared.java: new File.
+
 2003-01-13 Mikhail Khodjaiants
 	* CTarget.java: in the 'runUntil' method check if file name or function name length > 0, otherwise use address.
 
Index: src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java,v
retrieving revision 1.17
diff -u -r1.17 CommandFactory.java
--- src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java	14 Nov 2002 21:04:08 -0000	1.17
+++ src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java	16 Jan 2003 03:10:53 -0000
@@ -253,6 +253,10 @@
 		return new MIThreadSelect(threadNum);
 	}
 
+	public MIInfoSharedLibrary createMIInfoSharedLibrary() {
+		return new MIInfoSharedLibrary();
+	}
+
 	public MIVarCreate createMIVarCreate(String expression) {
 		return new MIVarCreate(expression);
 	}
Index: src/org/eclipse/cdt/debug/mi/core/command/MIInfoSharedLibrary.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/MIInfoSharedLibrary.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/MIInfoSharedLibrary.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/MIInfoSharedLibrary.java	16 Jan 2003 03:10:53 -0000
@@ -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.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIInfoSharedLibraryInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+
+/**
+ * 
+ *    info threads
+ *
+ */
+public class MIInfoSharedLibrary extends CLICommand 
+{
+	public MIInfoSharedLibrary() {
+		super("info sharedlibrary");
+	}
+
+	public MIInfoSharedLibraryInfo getMIInfoSharedLibraryInfo() throws MIException {
+		return (MIInfoSharedLibraryInfo)getMIInfo();
+	}
+
+	public MIInfo getMIInfo() throws MIException {
+		MIInfo info = null;
+		MIOutput out = getMIOutput();
+		if (out != null) {
+			info = new MIInfoSharedLibraryInfo(out);
+			if (info.isError()) {
+				throw new MIException(info.getErrorMsg());
+			}
+		}
+		return info;
+	}
+}
Index: src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java
diff -N src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java	16 Jan 2003 03:10:54 -0000
@@ -0,0 +1,91 @@
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.debug.mi.core.output;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * GDB/MI thread list parsing.
+&"info shared\n"
+~"From        To          Syms Read   Shared Object Library\n"
+~"0x40042fa0  0x4013ba9b  Yes         /lib/i686/libc.so.6\n"
+~"0x40001db0  0x4001321c  Yes         /lib/ld-linux.so.2\n"
+
+ */
+public class MIInfoSharedLibraryInfo extends MIInfo {
+
+	MIShared[] shared;
+
+	public MIInfoSharedLibraryInfo(MIOutput out) {
+		super(out);
+		parse();
+	}
+
+	public MIShared[] getMIShared() {
+		return shared;
+	}
+
+	void parse() {
+		List aList = new ArrayList();
+		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();
+					// We are interested in the shared info
+					parseShared(str.trim(), aList);
+				}
+			}
+		}
+		shared = new MIShared[aList.size()];
+		for (int i = 0; i < aList.size(); i++) {
+			shared[i] = (MIShared)aList.get(i);
+		}
+	}
+
+	void parseShared(String str, List aList) {
+		if (str.length() > 0) {
+			// Pass the header
+			if (Character.isDigit(str.charAt(0))) {
+				int index = -1;
+				long from = 0;
+				long to = 0;
+				boolean syms = false;
+
+				for (int i = 0; i < 3 && (index = str.indexOf(' ')) != -1; i++) {
+					String sub = str.substring(0, index).trim();
+					// advance to next column
+					str = str.substring(index).trim();
+					switch (i) {
+						case 0: // first column is "From"
+							try {
+								from = Long.decode(sub).longValue();
+							} catch (NumberFormatException e) {
+							}
+						break;
+						case 1: // second column is "To"
+							try {
+								to = Long.decode(sub).longValue();
+							} catch (NumberFormatException e) {
+							}
+						break;
+						case 2: // third column is "Syms Read"
+							if (sub.equalsIgnoreCase("Yes")) {
+								syms = true;
+							}
+						break;
+						default: // last column is "Shared object library"
+							i = 3; // bail out. use the entire string
+					}
+				}
+				MIShared s = new MIShared(from, to, syms, str.trim());
+				aList.add(s);
+			}
+		}
+	}
+}
Index: src/org/eclipse/cdt/debug/mi/core/output/MIShared.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/output/MIShared.java
diff -N src/org/eclipse/cdt/debug/mi/core/output/MIShared.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/output/MIShared.java	16 Jan 2003 03:10:54 -0000
@@ -0,0 +1,40 @@
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.debug.mi.core.output;
+
+
+/**
+ * GDB/MI shared information
+ */
+public class MIShared {
+
+	long from;
+	long to;
+	boolean isread;
+	String name;
+
+	public MIShared (long start, long end, boolean read, String location) {
+		from = start;
+		to = end;
+		isread = read;
+		name = location;
+	}
+
+	public long getFrom() {
+		return from;
+	}
+
+	public long getTo() {
+		return to;
+	}
+
+	public boolean isRead() {
+		return isread;
+	}
+
+	public String getName() {
+		return name;
+	}
+}



Back to the top