From 6ba8df52b256914544ba5cc78a661fa88c2f57f3 Mon Sep 17 00:00:00 2001 From: elaskavaia Date: Wed, 27 Mar 2013 16:25:42 -0400 Subject: [PATCH] PR 41476 Support for variable in shared libs paths for debugger Debugger in launch config stores absolute lib paths which totally not convinient for storing shared launch configs. This will allow to store variable and resolve the just before passing paths to debugger Change-Id: I368407783606c5a5697067afc235dba5dc03ae52 --- .../core/command/MIGDBSetSolibSearchPath.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIGDBSetSolibSearchPath.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIGDBSetSolibSearchPath.java index f47fdabaaa0..aaee7b3c6e4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIGDBSetSolibSearchPath.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIGDBSetSolibSearchPath.java @@ -11,6 +11,9 @@ package org.eclipse.cdt.debug.mi.core.command; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; + /** * * -gdb-set @@ -25,13 +28,22 @@ public class MIGDBSetSolibSearchPath extends MIGDBSet { String sep = System.getProperty("path.separator", ":"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer buffer = new StringBuffer(); for (int i = 0; i < paths.length; i++) { - if (buffer.length() == 0) { - buffer.append(paths[i]); - } else { - buffer.append(sep).append(paths[i]); + if (buffer.length() > 0) { + buffer.append(sep); } + buffer.append(resolve(paths[i])); } String[] p = new String [] {"solib-search-path", buffer.toString()}; //$NON-NLS-1$ setParameters(p); } + + protected String resolve(String path) { + try { + IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); + path = manager.performStringSubstitution(path, false); + } catch (Exception e) { + // if anything happens here just use the non-resolved one + } + return path; + } }