summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Elmenthaler2012-08-31 15:14:13 (EDT)
committerMarc-Andre Laperle2013-10-28 20:43:43 (EDT)
commita7321b3293acc45dd06f4264c835e861ee994f61 (patch)
tree61041114de9b1b9d2587bfed19dfae6fa92a6420
parent642d4c3975ab78920d07c9351ed45fa2236c8c9e (diff)
downloadorg.eclipse.cdt-a7321b3293acc45dd06f4264c835e861ee994f61.zip
org.eclipse.cdt-a7321b3293acc45dd06f4264c835e861ee994f61.tar.gz
org.eclipse.cdt-a7321b3293acc45dd06f4264c835e861ee994f61.tar.bz2
Bug 341336: fix empty names for functions in anonymous namespaces withrefs/changes/54/7554/4
GDB 7.2 or newer. Change-Id: I9aace64c84d92987fa679f809e4c89d1d53499e4 Signed-off-by: Jens Elmenthaler <jens.elmenthaler@advantest.com> Reviewed-on: https://git.eclipse.org/r/7554 Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> IP-Clean: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIFrame.java35
1 files changed, 27 insertions, 8 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIFrame.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIFrame.java
index 8e31544..521ad19 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIFrame.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIFrame.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * Copyright (c) 2000, 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - Modified for new DSF Reference Implementation
+ * Jens Elmenthaler (Advantest) - Fix empty names for functions in anonymous namespaces (bug 341336)
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.output;
@@ -108,13 +109,18 @@ public class MIFrame {
func = ""; //$NON-NLS-1$
else
{
- // In some situations gdb returns the function names that include parameter types.
- // To make the presentation consistent truncate the parameters. PR 46592
- int end = str.indexOf( '(' );
- if ( end != -1 )
- func = str.substring( 0, end );
- else
- func = str;
+ func = str;
+ // In some situations gdb returns the function names that include parameter types.
+ // To make the presentation consistent truncate the parameters. PR 46592
+ // However PR180059: only cut it if it is last brackets represent parameters,
+ // because gdb can return: func="(anonymous namespace)::func2((anonymous namespace)::Test*)"
+ int closing = str.lastIndexOf(')');
+ if (closing == str.length() - 1) {
+ int end = getMatchingBracketIndex(str, closing - 1);
+ if (end >= 0) {
+ func = str.substring(0, end);
+ }
+ }
}
}
} else if (var.equals("file")) { //$NON-NLS-1$
@@ -135,4 +141,17 @@ public class MIFrame {
}
}
}
+
+ private int getMatchingBracketIndex(String str, int end) {
+ int depth = 1;
+ for (;end>=0;end--) {
+ int c = str.charAt(end);
+ if (c=='(') {
+ depth--;
+ if (depth==0) break;
+ } else if (c==')')
+ depth++;
+ }
+ return end;
+ }
}