diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_1.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_1.java index 91eb38e38c2..fae1cc3f2c2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_1.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_1.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Ericsson and others. + * Copyright (c) 2010, 2014 Ericsson 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: * Ericsson - initial API and implementation * Andy Jin (QNX) - Not output thread osId as a string when it is null (Bug 397039) + * Alvaro Sanchez-Leon - Bug 451396 - Improve extensibility to process MI "-thread-info" results *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.service; @@ -176,23 +177,7 @@ public class GDBProcesses_7_1 extends GDBProcesses_7_0 { if (getData().getThreadList().length != 0) { MIThread thread = getData().getThreadList()[0]; if (thread.getThreadId().equals(threadDmc.getId())) { - String id = ""; //$NON-NLS-1$ - if (thread.getOsId() != null) { - id = thread.getOsId(); - } - // append thread details (if any) to the thread ID - // as for GDB 6.x with CLIInfoThreadsInfo#getOsId() - final String details = thread.getDetails(); - if (details != null && details.length() > 0) { - if (!id.isEmpty()) id += " "; //$NON-NLS-1$ - id += "(" + details + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - // We must indicate and empty id by using null - if (id.isEmpty()) id = null; - - String core = thread.getCore(); - threadData = new MIThreadDMData_7_1("", id, //$NON-NLS-1$ - core == null ? null : new String[] { core }); + threadData = createThreadDMData(thread); } } @@ -210,6 +195,29 @@ public class GDBProcesses_7_1 extends GDBProcesses_7_0 { } } + /** + * @since 4.6 + */ + protected IGdbThreadDMData createThreadDMData(MIThread thread) { + String id = ""; //$NON-NLS-1$ + if (thread.getOsId() != null) { + id = thread.getOsId(); + } + // append thread details (if any) to the thread ID + // as for GDB 6.x with CLIInfoThreadsInfo#getOsId() + final String details = thread.getDetails(); + if (details != null && details.length() > 0) { + if (!id.isEmpty()) id += " "; //$NON-NLS-1$ + id += "(" + details + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } + // We must indicate and empty id by using null + if (id.isEmpty()) id = null; + + String core = thread.getCore(); + return new MIThreadDMData_7_1("", id, //$NON-NLS-1$ + core == null ? null : new String[] { core }); + } + @DsfServiceEventHandler public void eventDispatched_7_1(IResumedDMEvent e) { if (e instanceof IContainerResumedDMEvent) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java index cdbdc874d03..e5d302512be 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Ericsson and others. + * Copyright (c) 2008, 2014 Ericsson 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: * Ericsson - Initial API and implementation * Xavier Raynaud (Kalray) - MIThread can be overridden (Bug 429124) + * Alvaro Sanchez-Leon - Bug 451396 - Improve extensibility to process MI "-thread-info" results *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.output; @@ -316,7 +317,7 @@ public class MIListThreadGroupsInfo extends MIInfo { } } else if (var.equals("threads")) { //$NON-NLS-1$ // Re-use the MIThreadInfoInfo parsing - fThreadInfo = new MIThreadInfoInfo(out); + fThreadInfo = createMIThreadInfoInfo(out); } } } @@ -325,10 +326,17 @@ public class MIListThreadGroupsInfo extends MIInfo { fGroupList = new IThreadGroupInfo[0]; } if (fThreadInfo == null) { - fThreadInfo = new MIThreadInfoInfo(null); + fThreadInfo = createMIThreadInfoInfo(null); } } + /** + * @since 4.6 + */ + protected MIThreadInfoInfo createMIThreadInfoInfo(MIOutput output) { + return new MIThreadInfoInfo(output); + } + /** @since 4.4 */ protected void parseGroups(MIList list) { MIValue[] values = list.getMIValues(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThread.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThread.java index 9f6562570e4..1e299c4e029 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThread.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThread.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Ericsson and others. + * Copyright (c) 2008, 2014 Ericsson 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 @@ -10,6 +10,7 @@ * Wind River Systems - refactored to match pattern in package * John Dallaway - GDB 7.x getOsId() pattern match too restrictive (Bug 325552) * Xavier Raynaud (Kalray) - MIThread can be overridden (Bug 429124) + * Alvaro Sanchez-Leon - Bug 451396 - Improve extensibility to process MI "-thread-info" results *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.output; @@ -128,7 +129,10 @@ public class MIThread { private static Pattern fgOsIdPattern3 = Pattern.compile("[Tt][Hh][Rr][Ee][Aa][Dd]\\s*(\\S+)", 0); //$NON-NLS-1$ private static Pattern fgOsIdPattern4 = Pattern.compile("[Pp][Rr][Oo][Cc][Ee][Ss][Ss]\\s*(\\S+)", 0); //$NON-NLS-1$ - static String parseOsId(String str) { + /** + * @since 4.6 + */ + protected static String parseOsId(String str) { // General format: // "Thread 0xb7c8ab90 (LWP 7010)" // ^^^^ @@ -169,8 +173,9 @@ public class MIThread { * This is used to parse the same ID fed to {@link #parseOsId(String)}. The * difference is that we return the first portion when the ID is in format * "Thread pppp.tttt". If the ID is not in that format, we return null. + * @since 4.6 */ - static String parseParentId(String str) { + protected static String parseParentId(String str) { // General format: // "Thread 162.32942" // ^^^