mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[247362] - [commands] -thread-info parsing not consistent with existing API.
This commit is contained in:
parent
8c9c3817e8
commit
c88706272b
7 changed files with 148 additions and 242 deletions
|
@ -50,9 +50,9 @@ import org.eclipse.dd.mi.service.command.commands.MITargetDetach;
|
|||
import org.eclipse.dd.mi.service.command.commands.MIThreadInfo;
|
||||
import org.eclipse.dd.mi.service.command.events.MIThreadGroupCreatedEvent;
|
||||
import org.eclipse.dd.mi.service.command.events.MIThreadGroupExitedEvent;
|
||||
import org.eclipse.dd.mi.service.command.output.IThreadInfo;
|
||||
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.dd.mi.service.command.output.MIListThreadGroupsInfo;
|
||||
import org.eclipse.dd.mi.service.command.output.MIThread;
|
||||
import org.eclipse.dd.mi.service.command.output.MIThreadInfoInfo;
|
||||
import org.eclipse.dd.mi.service.command.output.MIListThreadGroupsInfo.IThreadGroupInfo;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
@ -453,7 +453,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService implements IMIProcesses
|
|||
protected void handleSuccess() {
|
||||
IThreadDMData threadData = new MIThreadDMData("", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (getData().getThreadList().length != 0) {
|
||||
IThreadInfo thread = getData().getThreadList()[0];
|
||||
MIThread thread = getData().getThreadList()[0];
|
||||
if (thread.getThreadId().equals(threadDmc.getId())) {
|
||||
threadData = new MIThreadDMData("", thread.getOsId()); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService implements IMIProcesses
|
|||
// }
|
||||
}
|
||||
|
||||
private IExecutionDMContext[] makeExecutionDMCs(IContainerDMContext containerDmc, IThreadInfo[] threadInfos) {
|
||||
private IExecutionDMContext[] makeExecutionDMCs(IContainerDMContext containerDmc, MIThread[] threadInfos) {
|
||||
final IProcessDMContext procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
|
||||
|
||||
if (threadInfos.length == 0) {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.mi.service.command.output;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* @since 1.1
|
||||
*/
|
||||
public interface IThreadFrame {
|
||||
int getStackLevel();
|
||||
BigInteger getAddress();
|
||||
String getFucntion();
|
||||
Object[] getArgs();
|
||||
String getFileName();
|
||||
String getFullName();
|
||||
int getLineNumber();
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.mi.service.command.output;
|
||||
|
||||
|
||||
/**
|
||||
* @since 1.1
|
||||
*/
|
||||
public interface IThreadInfo {
|
||||
String getThreadId();
|
||||
String getTargetId();
|
||||
String getOsId();
|
||||
IThreadFrame getTopFrame();
|
||||
String getDetails();
|
||||
String getState();
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
* Wind River Systems - refactored to match pattern in package
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.mi.service.command.output;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* GDB/MI Thread tuple parsing.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@Immutable
|
||||
public class MIThread {
|
||||
|
||||
final private String fThreadId;
|
||||
final private String fTargetId;
|
||||
final private String fOsId;
|
||||
final private String fParentId;
|
||||
final private MIFrame fTopFrame;
|
||||
final private String fDetails;
|
||||
final private String fState;
|
||||
|
||||
private MIThread(String threadId, String targetId, String osId, String parentId,
|
||||
MIFrame topFrame, String details, String state) {
|
||||
fThreadId = threadId;
|
||||
fTargetId = targetId;
|
||||
fOsId = osId;
|
||||
fParentId = parentId;
|
||||
fTopFrame = topFrame;
|
||||
fDetails = details;
|
||||
fState = state;
|
||||
}
|
||||
|
||||
public String getThreadId() { return fThreadId; }
|
||||
public String getTargetId() { return fTargetId; }
|
||||
public String getOsId() { return fOsId; }
|
||||
public String getParentId() { return fParentId; }
|
||||
public MIFrame getTopFrame() { return fTopFrame; }
|
||||
public String getDetails() { return fDetails; }
|
||||
public String getState() { return fState; }
|
||||
|
||||
public static MIThread parse(MITuple tuple) {
|
||||
MIResult[] results = tuple.getMIResults();
|
||||
|
||||
String threadId = null;
|
||||
String targetId = null;
|
||||
String osId = null;
|
||||
String parentId = null;
|
||||
MIFrame topFrame = null;
|
||||
String state = null;
|
||||
String details = null;
|
||||
|
||||
for (int j = 0; j < results.length; j++) {
|
||||
MIResult result = results[j];
|
||||
String var = result.getVariable();
|
||||
if (var.equals("id")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
threadId = ((MIConst) val).getCString().trim();
|
||||
}
|
||||
}
|
||||
else if (var.equals("target-id")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
targetId = ((MIConst) val).getCString().trim();
|
||||
osId = parseOsId(targetId);
|
||||
parentId = parseParentId(targetId);
|
||||
}
|
||||
}
|
||||
else if (var.equals("frame")) { //$NON-NLS-1$
|
||||
MITuple val = (MITuple)results[j].getMIValue();
|
||||
topFrame = new MIFrame(val);
|
||||
}
|
||||
else if (var.equals("state")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
state = ((MIConst) val).getCString().trim();
|
||||
}
|
||||
}
|
||||
else if (var.equals("details")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
details = ((MIConst) val).getCString().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new MIThread(threadId, targetId, osId, parentId, topFrame, details, state);
|
||||
}
|
||||
|
||||
private static Pattern fgOsIdPattern1 = Pattern.compile("(Thread\\s*)(0x[0-9a-fA-F]+|-?\\d+)(\\s*\\(LWP\\s*)(\\d*)", 0); //$NON-NLS-1$
|
||||
private static Pattern fgOsIdPattern2 = Pattern.compile("(Thread\\s*)(0x[0-9a-fA-F]+|-?\\d+)(\\s*\\(LWP\\s*)(\\d*)", 0); //$NON-NLS-1$
|
||||
|
||||
private static String parseOsId(String str) {
|
||||
// General format:
|
||||
// "Thread 0xb7c8ab90 (LWP 7010)"
|
||||
// "Thread 162.32942"
|
||||
|
||||
Matcher matcher = fgOsIdPattern1.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(4);
|
||||
}
|
||||
|
||||
matcher = fgOsIdPattern2.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Pattern fgIdPattern = Pattern.compile("Thread\\s*(\\d+)\\.\\d+", 0); //$NON-NLS-1$
|
||||
|
||||
private static String parseParentId(String str) {
|
||||
// General format:
|
||||
// "Thread 0xb7c8ab90 (LWP 7010)"
|
||||
// "Thread 162.32942"
|
||||
|
||||
Matcher matcher = fgIdPattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,12 +7,11 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
* Wind River Systems - refactored to match pattern in package
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.mi.service.command.output;
|
||||
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* GDB/MI thread list parsing.
|
||||
|
@ -75,7 +74,7 @@ import java.util.regex.Pattern;
|
|||
public class MIThreadInfoInfo extends MIInfo {
|
||||
|
||||
private String fCurrentThread = null;
|
||||
private IThreadInfo[] fThreadList = null;
|
||||
private MIThread[] fThreadList = null;
|
||||
|
||||
public MIThreadInfoInfo(MIOutput out) {
|
||||
super(out);
|
||||
|
@ -86,7 +85,7 @@ public class MIThreadInfoInfo extends MIInfo {
|
|||
return fCurrentThread;
|
||||
}
|
||||
|
||||
public IThreadInfo[] getThreadList() {
|
||||
public MIThread[] getThreadList() {
|
||||
return fThreadList;
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,7 @@ public class MIThreadInfoInfo extends MIInfo {
|
|||
}
|
||||
}
|
||||
if (fThreadList == null) {
|
||||
fThreadList = new IThreadInfo[0];
|
||||
fThreadList = new MIThread[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,97 +125,11 @@ public class MIThreadInfoInfo extends MIInfo {
|
|||
// id="n",target-id="Thread 162.32942",details="...",frame={...},state="stopped"
|
||||
private void parseThreads(MIList list) {
|
||||
MIValue[] values = list.getMIValues();
|
||||
fThreadList = new IThreadInfo[values.length];
|
||||
fThreadList = new MIThread[values.length];
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
MITuple value = (MITuple) values[i];
|
||||
MIResult[] results = value.getMIResults();
|
||||
|
||||
String threadId = null;
|
||||
String targetId = null;
|
||||
String osId = null;
|
||||
String parentId = null;
|
||||
ThreadFrame topFrame = null;
|
||||
String state = null;
|
||||
String details = null;
|
||||
|
||||
for (int j = 0; j < results.length; j++) {
|
||||
MIResult result = results[j];
|
||||
String var = result.getVariable();
|
||||
if (var.equals("id")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
threadId = ((MIConst) val).getCString().trim();
|
||||
}
|
||||
}
|
||||
else if (var.equals("target-id")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
targetId = ((MIConst) val).getCString().trim();
|
||||
osId = parseOsId(targetId);
|
||||
parentId = parseParentId(targetId);
|
||||
}
|
||||
}
|
||||
else if (var.equals("frame")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
topFrame = parseFrame(val);
|
||||
}
|
||||
else if (var.equals("state")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
state = ((MIConst) val).getCString().trim();
|
||||
}
|
||||
}
|
||||
else if (var.equals("details")) { //$NON-NLS-1$
|
||||
MIValue val = results[j].getMIValue();
|
||||
if (val instanceof MIConst) {
|
||||
details = ((MIConst) val).getCString().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fThreadList[i] = new ThreadInfo(threadId, targetId, osId, parentId, topFrame, details, state);
|
||||
fThreadList[i] = MIThread.parse((MITuple) values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// General format:
|
||||
// "Thread 0xb7c8ab90 (LWP 7010)"
|
||||
// "Thread 162.32942"
|
||||
private String parseOsId(String str) {
|
||||
Pattern pattern = Pattern.compile("(Thread\\s*)(0x[0-9a-fA-F]+|-?\\d+)(\\s*\\(LWP\\s*)(\\d*)", 0); //$NON-NLS-1$
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(4);
|
||||
}
|
||||
|
||||
pattern = Pattern.compile("Thread\\s*\\d+\\.(\\d+)", 0); //$NON-NLS-1$
|
||||
matcher = pattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// General format:
|
||||
// "Thread 0xb7c8ab90 (LWP 7010)"
|
||||
// "Thread 162.32942"
|
||||
private String parseParentId(String str) {
|
||||
Pattern pattern = Pattern.compile("Thread\\s*(\\d+)\\.\\d+", 0); //$NON-NLS-1$
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// General format:
|
||||
// level="0",addr="0x08048bba",func="func",args=[...],file="file.cc",fullname="/path/file.cc",line="26"
|
||||
private ThreadFrame parseFrame(MIValue val) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.mi.service.command.output;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* @since 1.1
|
||||
*/
|
||||
@Immutable
|
||||
public class ThreadFrame implements IThreadFrame {
|
||||
final private int fStackLevel;
|
||||
final private BigInteger fAddress;
|
||||
final private String fFunction;
|
||||
final private Object[] fArgs;
|
||||
final private String fFileName;
|
||||
final private String fFullName;
|
||||
final private int fLineNumber;
|
||||
|
||||
public ThreadFrame(int stackLevel, BigInteger address, String function,
|
||||
Object[] args, String file, String fullName, int line)
|
||||
{
|
||||
fStackLevel = stackLevel;
|
||||
fAddress = address;
|
||||
fFunction = function;
|
||||
fArgs = args;
|
||||
fFileName = file;
|
||||
fFullName = fullName;
|
||||
fLineNumber = line;
|
||||
}
|
||||
|
||||
public int getStackLevel() { return fStackLevel; }
|
||||
public BigInteger getAddress() { return fAddress; }
|
||||
public String getFucntion() { return fFunction; }
|
||||
public Object[] getArgs() { return fArgs; }
|
||||
public String getFileName() { return fFileName; }
|
||||
public String getFullName() { return fFullName; }
|
||||
public int getLineNumber() { return fLineNumber; }
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.mi.service.command.output;
|
||||
|
||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* @since 1.1
|
||||
*/
|
||||
@Immutable
|
||||
public class ThreadInfo implements IThreadInfo {
|
||||
|
||||
final private String fThreadId;
|
||||
final private String fTargetId;
|
||||
final private String fOsId;
|
||||
final private String fParentId;
|
||||
final private IThreadFrame fTopFrame;
|
||||
final private String fDetails;
|
||||
final private String fState;
|
||||
|
||||
public ThreadInfo(String threadId, String targetId, String osId, String parentId,
|
||||
IThreadFrame topFrame, String details, String state) {
|
||||
fThreadId = threadId;
|
||||
fTargetId = targetId;
|
||||
fOsId = osId;
|
||||
fParentId = parentId;
|
||||
fTopFrame = topFrame;
|
||||
fDetails = details;
|
||||
fState = state;
|
||||
}
|
||||
|
||||
public String getThreadId() { return fThreadId; }
|
||||
public String getTargetId() { return fTargetId; }
|
||||
public String getOsId() { return fOsId; }
|
||||
public String getParentId() { return fParentId; }
|
||||
public IThreadFrame getTopFrame() { return fTopFrame; }
|
||||
public String getDetails() { return fDetails; }
|
||||
public String getState() { return fState; }
|
||||
}
|
Loading…
Add table
Reference in a new issue