Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] GDB/MI "info shared"

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.170
diff -u -r1.170 ChangeLog
--- ChangeLog	26 Aug 2003 15:38:13 -0000	1.170
+++ ChangeLog	26 Aug 2003 18:20:14 -0000
@@ -1,5 +1,16 @@
 2003-08-26 Alain Magloire
 
+	This is still a hack: "info shared"  the real solution
+	is to implement in GDB/MI the corresponding command.
+	So now we do weird parsing, that varies from platform
+	to platform.  For example Cygwin output of "info shared"
+	is totally different from the GNU/Linux one etc ...
+	We the best we can to cope ... but things will break.
+
+	* src/org/eclipse.cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java
+
+2003-08-26 Alain Magloire
+
 	Using the wrong method for toString() and we were returning
 	a overly verbose string.
 
Index: src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java,v
retrieving revision 1.2
diff -u -r1.2 MIInfoSharedLibraryInfo.java
--- src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java	18 Jan 2003 00:37:01 -0000	1.2
+++ src/org/eclipse/cdt/debug/mi/core/output/MIInfoSharedLibraryInfo.java	26 Aug 2003 18:20:15 -0000
@@ -63,7 +63,13 @@
 			parseWinShared(str, aList);
 		}
 	}
-	
+
+	/**
+	 * We do the parsing backward because on some Un*x system, the To or the From
+	 * and even the "Sym Read" can be empty....
+	 * @param str
+	 * @param aList
+	 */	
 	void parseUnixShared(String str, List aList) {
 		if (str.length() > 0) {
 			// Pass the header
@@ -72,34 +78,39 @@
 				long from = 0;
 				long to = 0;
 				boolean syms = false;
+				String name = "";
 
-				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) {
+				for (int i = 0; (index = str.lastIndexOf(' ')) != -1 || i <= 3; i++) {
+					if (index == -1) {
+						index = 0;
+					}
+					String sub = str.substring(index).trim();
+					// move to previous column
+					str = str.substring(0, index).trim();
+					switch(i) {
+						case 0:
+							name = sub;
+						break;
+						case 1:
+							if (sub.equalsIgnoreCase("Yes")) {
+								syms = true;
 							}
 						break;
-						case 1: // second column is "To"
+						case 2: // 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;
+						case 3: // first column is "From"
+							try {
+								from = Long.decode(sub).longValue();
+							} catch (NumberFormatException e) {
 							}
 						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());
+				MIShared s = new MIShared(from, to, syms, name);
 				aList.add(s);
 			}
 		}
@@ -113,7 +124,7 @@
 		int index = str.lastIndexOf(' ');
 		if (index > 0) {
 			String sub = str.substring(index).trim();
-			// Go figure they do not print the "0x" to indicate hexadicimal!!
+			// Go figure they do not print the "0x" to indicate hexadecimal!!
 			if (!sub.startsWith("0x")) {
 				sub = "0x" + sub;
 			}



Back to the top