mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 373707: [tracepoints] Make use of the new 'collect /s' command
Change-Id: I60689b73dd1f081fa3e3b53807e52800c9c03006 Reviewed-on: https://git.eclipse.org/r/5576 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
6abf9e1a42
commit
3964dbeab6
11 changed files with 383 additions and 68 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Ericsson and others.
|
* Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Ericsson - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Added support for collecting char pointers as strings (bug 373707)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.tracepointactions;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.tracepointactions;
|
||||||
|
|
||||||
|
@ -14,9 +15,16 @@ import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction;
|
||||||
import org.eclipse.cdt.debug.ui.breakpointactions.IBreakpointActionPage;
|
import org.eclipse.cdt.debug.ui.breakpointactions.IBreakpointActionPage;
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.CollectAction;
|
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.CollectAction;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
import org.eclipse.jface.fieldassist.ControlDecoration;
|
||||||
|
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
@ -26,7 +34,20 @@ import org.eclipse.swt.widgets.Text;
|
||||||
*/
|
*/
|
||||||
public class CollectActionPage extends PlatformObject implements IBreakpointActionPage {
|
public class CollectActionPage extends PlatformObject implements IBreakpointActionPage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception to indicate that the user-specified string limit is invalid
|
||||||
|
*/
|
||||||
|
private class IllegalCollectStringLimitException extends Exception {
|
||||||
|
private static final long serialVersionUID = -2087722354642237691L;
|
||||||
|
public IllegalCollectStringLimitException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Text fCollectString;
|
private Text fCollectString;
|
||||||
|
private Button fTreatCharPtrAsStrings;
|
||||||
|
private Text fTreatCharPtrAsStringsLimit;
|
||||||
|
|
||||||
private CollectAction fCollectAction;
|
private CollectAction fCollectAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,14 +57,73 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi
|
||||||
Composite composite = new Composite(parent, style);
|
Composite composite = new Composite(parent, style);
|
||||||
composite.setLayout(new GridLayout(2, false));
|
composite.setLayout(new GridLayout(2, false));
|
||||||
|
|
||||||
|
// The label asking for what to collect
|
||||||
final Label collectLabel = new Label(composite, SWT.NONE);
|
final Label collectLabel = new Label(composite, SWT.NONE);
|
||||||
collectLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
|
collectLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
|
||||||
collectLabel.setText(MessagesForTracepointActions.TracepointActions_Collect_Label);
|
collectLabel.setText(MessagesForTracepointActions.TracepointActions_Collect_Label);
|
||||||
|
|
||||||
|
// The user-specified string of what to collect
|
||||||
fCollectString = new Text(composite, SWT.BORDER);
|
fCollectString = new Text(composite, SWT.BORDER);
|
||||||
fCollectString.setText(fCollectAction.getCollectString());
|
fCollectString.setText(fCollectAction.getCollectString());
|
||||||
fCollectString.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
fCollectString.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
|
||||||
|
|
||||||
|
// An option to collect character pointers as strings
|
||||||
|
fTreatCharPtrAsStrings = new Button(composite, SWT.CHECK);
|
||||||
|
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
|
||||||
|
gd.verticalIndent = 15;
|
||||||
|
// Store the button width before we add the text as we only care about the checkbox width
|
||||||
|
int buttonWidth = fTreatCharPtrAsStrings.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
|
||||||
|
fTreatCharPtrAsStrings.setText(MessagesForTracepointActions.TracepointActions_Collect_Strings_Label);
|
||||||
|
fTreatCharPtrAsStrings.setLayoutData(gd);
|
||||||
|
fTreatCharPtrAsStrings.setSelection(fCollectAction.getCharPtrAsStrings());
|
||||||
|
fTreatCharPtrAsStrings.addSelectionListener(new SelectionListener() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
// Disable/enable the limit field
|
||||||
|
fTreatCharPtrAsStringsLimit.setEnabled(fTreatCharPtrAsStrings.getSelection());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
// Disable/enable the limit field
|
||||||
|
fTreatCharPtrAsStringsLimit.setEnabled(fTreatCharPtrAsStrings.getSelection());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// A label asking for an optional limit of bytes of collected strings
|
||||||
|
final Label limitLabel = new Label(composite, SWT.NONE);
|
||||||
|
gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
|
||||||
|
gd.horizontalIndent = buttonWidth;
|
||||||
|
limitLabel.setLayoutData(gd);
|
||||||
|
limitLabel.setText(MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Label);
|
||||||
|
|
||||||
|
// A user-specified limit of bytes
|
||||||
|
fTreatCharPtrAsStringsLimit = new Text(composite, SWT.BORDER);
|
||||||
|
fTreatCharPtrAsStringsLimit.setText(getCharPtrAsStringLimit(fCollectAction.getCharPtrAsStringsLimit()));
|
||||||
|
|
||||||
|
gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||||
|
gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
|
||||||
|
fTreatCharPtrAsStringsLimit.setLayoutData(gd);
|
||||||
|
fTreatCharPtrAsStringsLimit.setEnabled(fTreatCharPtrAsStrings.getSelection());
|
||||||
|
|
||||||
|
final ControlDecoration decoration = new ControlDecoration(fTreatCharPtrAsStringsLimit, SWT.TOP | SWT.LEFT, composite );
|
||||||
|
decoration.hide();
|
||||||
|
fTreatCharPtrAsStringsLimit.addModifyListener(new ModifyListener() {
|
||||||
|
@Override
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
try {
|
||||||
|
getCharPtrAsStringLimit(fTreatCharPtrAsStringsLimit.getText());
|
||||||
|
decoration.hide();
|
||||||
|
} catch (IllegalCollectStringLimitException exception) {
|
||||||
|
decoration.setImage(
|
||||||
|
FieldDecorationRegistry.getDefault().getFieldDecoration(
|
||||||
|
FieldDecorationRegistry.DEC_ERROR).getImage());
|
||||||
|
decoration.setDescriptionText(exception.getMessage());
|
||||||
|
decoration.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +138,14 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi
|
||||||
@Override
|
@Override
|
||||||
public void actionDialogOK() {
|
public void actionDialogOK() {
|
||||||
fCollectAction.setCollectString(fCollectString.getText());
|
fCollectAction.setCollectString(fCollectString.getText());
|
||||||
|
fCollectAction.setCharPtrAsStrings(fTreatCharPtrAsStrings.getSelection());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Integer limit = getCharPtrAsStringLimit(fTreatCharPtrAsStringsLimit.getText());
|
||||||
|
fCollectAction.setCharPtrAsStringsLimit(limit);
|
||||||
|
} catch (IllegalCollectStringLimitException e) {
|
||||||
|
// ignore and keep old value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,4 +154,37 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi
|
||||||
return createCollectActionComposite(composite, style);
|
return createCollectActionComposite(composite, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the user-specified string into an integer.
|
||||||
|
* If the string is not valid, disable the limit by using null.
|
||||||
|
* @param limitStr The string provided by the user
|
||||||
|
* @return An non-negative integer limit, or null for no limit.
|
||||||
|
*/
|
||||||
|
private Integer getCharPtrAsStringLimit(String limitStr) throws IllegalCollectStringLimitException {
|
||||||
|
limitStr = limitStr.trim();
|
||||||
|
Integer limit = null;
|
||||||
|
try {
|
||||||
|
limit = Integer.parseInt(limitStr);
|
||||||
|
if (limit < 0) {
|
||||||
|
throw new IllegalCollectStringLimitException(MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Error);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
if (!limitStr.isEmpty()) {
|
||||||
|
// We only accept an empty string, which means no limit
|
||||||
|
throw new IllegalCollectStringLimitException(MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the integer limit into a string.
|
||||||
|
* If the string is not valid, disable the limit by using null.
|
||||||
|
* @param limit The integer limit to convert. Can be null for no limit.
|
||||||
|
* @return The limit as a string, where no limit or a negative limit is the empty string.
|
||||||
|
*/
|
||||||
|
private String getCharPtrAsStringLimit(Integer limit) {
|
||||||
|
if (limit == null || limit < 0) return ""; //$NON-NLS-1$
|
||||||
|
return Integer.toString(limit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Ericsson and others.
|
* Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Ericsson - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Added support for collecting char pointers as strings (bug 373707)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.tracepointactions;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.tracepointactions;
|
||||||
|
|
||||||
|
@ -39,6 +40,9 @@ class MessagesForTracepointActions extends NLS {
|
||||||
public static String TracepointActions_Collect_Label;
|
public static String TracepointActions_Collect_Label;
|
||||||
public static String TracepointActions_Evaluate_Label;
|
public static String TracepointActions_Evaluate_Label;
|
||||||
public static String TracepointActions_WhileStepping_Sub_Actions;
|
public static String TracepointActions_WhileStepping_Sub_Actions;
|
||||||
|
public static String TracepointActions_Collect_Strings_Label;
|
||||||
|
public static String TracepointActions_Collect_Strings_Limit_Label;
|
||||||
|
public static String TracepointActions_Collect_Strings_Limit_Error;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2010 Ericsson and others.
|
# Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Ericsson - initial API and implementation
|
# Ericsson - initial API and implementation
|
||||||
|
# Marc Khouzam (Ericsson) - Added support for collecting char pointers as strings (bug 373707)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
TracepointActions_Actions_for_this_tracepoint=Actions for this tracepoint:
|
TracepointActions_Actions_for_this_tracepoint=Actions for this tracepoint:
|
||||||
|
@ -29,3 +30,6 @@ TracepointActions_ActionDialog_Type=Action type:
|
||||||
TracepointActions_Collect_Label=Data to collect (comma-separated list):
|
TracepointActions_Collect_Label=Data to collect (comma-separated list):
|
||||||
TracepointActions_Evaluate_Label=Expressions to evaluate (comma-separated list):
|
TracepointActions_Evaluate_Label=Expressions to evaluate (comma-separated list):
|
||||||
TracepointActions_WhileStepping_Sub_Actions=Sub-actions for While-stepping
|
TracepointActions_WhileStepping_Sub_Actions=Sub-actions for While-stepping
|
||||||
|
TracepointActions_Collect_Strings_Label=Collect all character pointers as strings
|
||||||
|
TracepointActions_Collect_Strings_Limit_Label=with optional string size limit (bytes):
|
||||||
|
TracepointActions_Collect_Strings_Limit_Error=Only non-negative integers can be used. Current value will be ignored.
|
||||||
|
|
|
@ -159,4 +159,45 @@ public class GdbPlugin extends Plugin {
|
||||||
return traceBuilder.toString();
|
return traceBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method which returns the unique identifier of this plugin.
|
||||||
|
*/
|
||||||
|
public static String getUniqueIdentifier() {
|
||||||
|
if (getDefault() == null) {
|
||||||
|
// If the default instance is not yet initialized,
|
||||||
|
// return a static identifier. This identifier must
|
||||||
|
// match the plugin id defined in plugin.xml
|
||||||
|
return PLUGIN_ID;
|
||||||
|
}
|
||||||
|
return getDefault().getBundle().getSymbolicName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs the specified status with this plug-in's log.
|
||||||
|
*
|
||||||
|
* @param status
|
||||||
|
* status to log
|
||||||
|
*/
|
||||||
|
public static void log(IStatus status) {
|
||||||
|
getDefault().getLog().log(status);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Logs an internal error with the specified message.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* the error message to log
|
||||||
|
*/
|
||||||
|
public static void logErrorMessage(String message) {
|
||||||
|
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs an internal error with the specified throwable
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the exception to be logged
|
||||||
|
*/
|
||||||
|
public static void log(Throwable e) {
|
||||||
|
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Ericsson and others.
|
* Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Ericsson - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Added support for collecting char pointers as strings (bug 373707)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
||||||
|
|
||||||
|
@ -21,21 +22,43 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Action used to tell GDB to collect different values from a tracepoint.
|
||||||
|
* It corresponds to GDB's 'collect' action.
|
||||||
|
*
|
||||||
|
* As for GDB 7.4:
|
||||||
|
* collect[/s] EXPRESSIONS
|
||||||
|
* The tracepoint collect command now takes an optional modifier "/s"
|
||||||
|
* that directs it to dereference pointer-to-character types and
|
||||||
|
* collect the bytes of memory up to a zero byte. The behavior is
|
||||||
|
* similar to what you see when you use the regular print command on a
|
||||||
|
* string. An optional integer following the "/s" sets a bound on the
|
||||||
|
* number of bytes that will be collected.
|
||||||
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class CollectAction extends AbstractTracepointAction {
|
public class CollectAction extends AbstractTracepointAction {
|
||||||
|
|
||||||
private static final String COLLECT_ACTION_ID = "org.eclipse.cdt.dsf.gdb.tracepointactions.CollectAction"; //$NON-NLS-1$
|
private static final String COLLECT_ACTION_ID = "org.eclipse.cdt.dsf.gdb.tracepointactions.CollectAction"; //$NON-NLS-1$
|
||||||
|
private static final String COLLECT_ACTION_ELEMENT_NAME = "collectData"; //$NON-NLS-1$
|
||||||
|
private static final String COLLECT_STRING_ATTR = "collectString"; //$NON-NLS-1$
|
||||||
|
private static final String COLLECT_AS_STRING_ATTR = "collectAsString"; //$NON-NLS-1$
|
||||||
|
private static final String COLLECT_AS_STRING_LIMIT_ATTR = "collectAsStringLimit"; //$NON-NLS-1$
|
||||||
|
|
||||||
private String fCollectString = ""; //$NON-NLS-1$
|
private String fCollectString = ""; //$NON-NLS-1$
|
||||||
|
/** Indicates if we should ask GDB to collect character pointers as strings */
|
||||||
|
private boolean fCharPtrAsStrings;
|
||||||
|
/**
|
||||||
|
* Optional limit of the size of the string to collect for character pointers.
|
||||||
|
* Null will indicate that no limit is to be used.
|
||||||
|
* This value should be non-negative. */
|
||||||
|
private Integer fCharPtrAsStringsLimit;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultName() {
|
public String getDefaultName() {
|
||||||
|
@ -50,6 +73,45 @@ public class CollectAction extends AbstractTracepointAction {
|
||||||
fCollectString = str;
|
fCollectString = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this collect action will treat character pointers as strings.
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public boolean getCharPtrAsStrings() {
|
||||||
|
return fCharPtrAsStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify if this collect action should treat character pointers as strings.
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public void setCharPtrAsStrings(boolean enable) {
|
||||||
|
fCharPtrAsStrings = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the maximum number of bytes that should be collected
|
||||||
|
* when treating character pointers as strings
|
||||||
|
* @return null if no limit is to be used
|
||||||
|
* @return a non-negative integer indicating the limit
|
||||||
|
*
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public Integer getCharPtrAsStringsLimit() {
|
||||||
|
return fCharPtrAsStringsLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the maximum number of bytes that should be collected when
|
||||||
|
* when treating character pointers as strings.
|
||||||
|
* @param limit A non-negative integer, or null of no limit should be used.
|
||||||
|
*
|
||||||
|
* @since 4.1
|
||||||
|
*/
|
||||||
|
public void setCharPtrAsStringsLimit(Integer limit) {
|
||||||
|
fCharPtrAsStringsLimit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return COLLECT_ACTION_ID;
|
return COLLECT_ACTION_ID;
|
||||||
|
@ -65,8 +127,12 @@ public class CollectAction extends AbstractTracepointAction {
|
||||||
docBuilder = dfactory.newDocumentBuilder();
|
docBuilder = dfactory.newDocumentBuilder();
|
||||||
Document doc = docBuilder.newDocument();
|
Document doc = docBuilder.newDocument();
|
||||||
|
|
||||||
Element rootElement = doc.createElement("collectData"); //$NON-NLS-1$
|
Element rootElement = doc.createElement(COLLECT_ACTION_ELEMENT_NAME);
|
||||||
rootElement.setAttribute("collectString", fCollectString); //$NON-NLS-1$
|
|
||||||
|
// Store the different attributes of this collect action
|
||||||
|
rootElement.setAttribute(COLLECT_STRING_ATTR, fCollectString);
|
||||||
|
rootElement.setAttribute(COLLECT_AS_STRING_ATTR, Boolean.toString(fCharPtrAsStrings));
|
||||||
|
rootElement.setAttribute(COLLECT_AS_STRING_LIMIT_ATTR, fCharPtrAsStringsLimit == null ? "" : fCharPtrAsStringsLimit.toString()); //$NON-NLS-1$
|
||||||
|
|
||||||
doc.appendChild(rootElement);
|
doc.appendChild(rootElement);
|
||||||
|
|
||||||
|
@ -84,14 +150,29 @@ public class CollectAction extends AbstractTracepointAction {
|
||||||
collectData = s.toString("UTF8"); //$NON-NLS-1$
|
collectData = s.toString("UTF8"); //$NON-NLS-1$
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
GdbPlugin.log(e);
|
||||||
}
|
}
|
||||||
return collectData;
|
return collectData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return MessageFormat.format(MessagesForTracepointActions.TracepointActions_Collect_text, new Object[] { fCollectString });
|
// Return the exact format that will be sent to GDB.
|
||||||
|
|
||||||
|
StringBuffer collectCmd = new StringBuffer("collect "); //$NON-NLS-1$
|
||||||
|
if (fCharPtrAsStrings) {
|
||||||
|
collectCmd.append("/s"); //$NON-NLS-1$
|
||||||
|
if (fCharPtrAsStringsLimit != null) {
|
||||||
|
// No space between /s and the limit
|
||||||
|
collectCmd.append(fCharPtrAsStringsLimit.toString());
|
||||||
|
}
|
||||||
|
// Now add the space before we append what to collect.
|
||||||
|
collectCmd.append(" "); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
// Finally, actually add what to collect
|
||||||
|
collectCmd.append(fCollectString);
|
||||||
|
|
||||||
|
return collectCmd.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,16 +188,33 @@ public class CollectAction extends AbstractTracepointAction {
|
||||||
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
parser.setErrorHandler(new DefaultHandler());
|
parser.setErrorHandler(new DefaultHandler());
|
||||||
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
|
root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();
|
||||||
fCollectString = root.getAttribute("collectString"); //$NON-NLS-1$
|
|
||||||
if (fCollectString == null)
|
fCollectString = root.getAttribute(COLLECT_STRING_ATTR);
|
||||||
throw new Exception();
|
if (fCollectString == null) fCollectString = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
String asStrings = root.getAttribute(COLLECT_AS_STRING_ATTR);
|
||||||
|
if (asStrings != null) {
|
||||||
|
fCharPtrAsStrings = Boolean.valueOf(asStrings);
|
||||||
|
} else {
|
||||||
|
fCharPtrAsStrings = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fCharPtrAsStringsLimit = null;
|
||||||
|
String asStringsLimit = root.getAttribute(COLLECT_AS_STRING_LIMIT_ATTR);
|
||||||
|
if (asStringsLimit != null) {
|
||||||
|
try {
|
||||||
|
fCharPtrAsStringsLimit = Integer.valueOf(asStringsLimit);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// leave as null to disable
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
GdbPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return MessageFormat.format(MessagesForTracepointActions.TracepointActions_Collect_text, new Object[] { fCollectString });
|
return getSummary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Ericsson and others.
|
* Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,8 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Ericsson - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Don't use translatable strings for the command summary
|
||||||
|
* since it will be send directly to GDB
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
||||||
|
|
||||||
|
@ -21,13 +23,12 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
|
@ -83,14 +84,15 @@ public class EvaluateAction extends AbstractTracepointAction {
|
||||||
collectData = s.toString("UTF8"); //$NON-NLS-1$
|
collectData = s.toString("UTF8"); //$NON-NLS-1$
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
GdbPlugin.log(e);
|
||||||
}
|
}
|
||||||
return collectData;
|
return collectData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return MessageFormat.format(MessagesForTracepointActions.TracepointActions_Evaluate_text, new Object[] { fEvalString });
|
// Create command to be sent to GDB
|
||||||
|
return String.format("teval %s", fEvalString); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,12 +112,12 @@ public class EvaluateAction extends AbstractTracepointAction {
|
||||||
if (fEvalString == null)
|
if (fEvalString == null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
GdbPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return MessageFormat.format(MessagesForTracepointActions.TracepointActions_Evaluate_text, new Object[] { fEvalString });
|
return getSummary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Ericsson and others.
|
* Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Ericsson - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Remove strings that should not be translated
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
||||||
|
|
||||||
|
@ -25,9 +26,6 @@ class MessagesForTracepointActions extends NLS {
|
||||||
public static String TracepointActions_Collect_Name;
|
public static String TracepointActions_Collect_Name;
|
||||||
public static String TracepointActions_Evaluate_Name;
|
public static String TracepointActions_Evaluate_Name;
|
||||||
public static String TracepointActions_WhileStepping_Name;
|
public static String TracepointActions_WhileStepping_Name;
|
||||||
public static String TracepointActions_Collect_text;
|
|
||||||
public static String TracepointActions_Evaluate_text;
|
|
||||||
public static String TracepointActions_WhileStepping_text;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010 Ericsson and others.
|
* Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,8 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ericsson - initial API and implementation
|
* Ericsson - initial API and implementation
|
||||||
|
* Marc Khouzam (Ericsson) - Don't use translatable strings for the command summary
|
||||||
|
* since it will be send directly to GDB
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
package org.eclipse.cdt.dsf.gdb.internal.tracepointactions;
|
||||||
|
|
||||||
|
@ -21,13 +23,12 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
|
@ -120,14 +121,15 @@ public class WhileSteppingAction extends AbstractTracepointAction {
|
||||||
collectData = s.toString("UTF8"); //$NON-NLS-1$
|
collectData = s.toString("UTF8"); //$NON-NLS-1$
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
GdbPlugin.log(e);
|
||||||
}
|
}
|
||||||
return collectData;
|
return collectData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return MessageFormat.format(MessagesForTracepointActions.TracepointActions_WhileStepping_text, new Object[] { fStepCount, fSubActionContent });
|
// Create command to be sent to GDB
|
||||||
|
return String.format("while-stepping %s %s", fStepCount, fSubActionContent); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,12 +151,12 @@ public class WhileSteppingAction extends AbstractTracepointAction {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
setSubActionsContent(fSubActionNames);
|
setSubActionsContent(fSubActionNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
GdbPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return MessageFormat.format(MessagesForTracepointActions.TracepointActions_WhileStepping_text, new Object[] { fStepCount, fSubActionContent });
|
return getSummary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2010 Ericsson and others.
|
# Copyright (c) 2010, 2012 Ericsson and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -16,8 +16,3 @@ TracepointActions_Untitled_WhileStepping=Untitled While-Stepping Action
|
||||||
TracepointActions_Collect_Name=Collect Action
|
TracepointActions_Collect_Name=Collect Action
|
||||||
TracepointActions_Evaluate_Name=Evaluate Action
|
TracepointActions_Evaluate_Name=Evaluate Action
|
||||||
TracepointActions_WhileStepping_Name=While-Stepping Action
|
TracepointActions_WhileStepping_Name=While-Stepping Action
|
||||||
# START NON-TRANSLATABLE
|
|
||||||
TracepointActions_Collect_text=collect {0}
|
|
||||||
TracepointActions_Evaluate_text=teval {0}
|
|
||||||
TracepointActions_WhileStepping_text=while-stepping {0} {1}
|
|
||||||
# END NON-TRANSLATABLE
|
|
||||||
|
|
|
@ -68,33 +68,33 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL);
|
IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DsfSession fSession;
|
protected DsfSession fSession;
|
||||||
private DsfServicesTracker fServicesTracker;
|
protected DsfServicesTracker fServicesTracker;
|
||||||
private IBreakpoints fBreakpointService;
|
protected IBreakpoints fBreakpointService;
|
||||||
// private ITraceControl fTraceService;
|
// private ITraceControl fTraceService;
|
||||||
private IBreakpointsTargetDMContext fBreakpointsDmc;
|
protected IBreakpointsTargetDMContext fBreakpointsDmc;
|
||||||
// private ITraceTargetDMContext fTraceTargetDmc;
|
// private ITraceTargetDMContext fTraceTargetDmc;
|
||||||
|
|
||||||
// private int fTotalTracingBufferSize = 0;
|
// private int fTotalTracingBufferSize = 0;
|
||||||
|
|
||||||
private static final String SOURCE_FILE = "TracepointTestApp.cc";
|
protected static final String SOURCE_FILE = "TracepointTestApp.cc";
|
||||||
private static final String METHOD_NAME = "testTracepoints";
|
protected static final String METHOD_NAME = "testTracepoints";
|
||||||
private static final int LINE_NUMBER_1 = 97;
|
protected static final int LINE_NUMBER_1 = 97;
|
||||||
private static final int LINE_NUMBER_2 = 75;
|
protected static final int LINE_NUMBER_2 = 75;
|
||||||
private static final int LINE_NUMBER_3 = 76;
|
protected static final int LINE_NUMBER_3 = 76;
|
||||||
private static final int LINE_NUMBER_4 = 85;
|
protected static final int LINE_NUMBER_4 = 85;
|
||||||
private static final int LINE_LOOP_2 = 109;
|
protected static final int LINE_LOOP_2 = 109;
|
||||||
private static final String NO_CONDITION = "";
|
protected static final String NO_CONDITION = "";
|
||||||
private static final String NO_COMMANDS = "";
|
protected static final String NO_COMMANDS = "";
|
||||||
// private static final int LAST_LINE_NUMBER = 94;
|
// private static final int LAST_LINE_NUMBER = 94;
|
||||||
//
|
//
|
||||||
// private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;
|
// private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;
|
||||||
|
|
||||||
private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
|
protected final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
|
||||||
private final static String[] CONDITIONS = {"gIntVar == 543", "gBoolVar == false", "counter == 3", "counter > 4", "counter > 2 && lIntVar == 12345"};
|
protected final static String[] CONDITIONS = {"gIntVar == 543", "gBoolVar == false", "counter == 3", "counter > 4", "counter > 2 && lIntVar == 12345"};
|
||||||
|
|
||||||
private static CollectAction[] COLLECT_ACTIONS = new CollectAction[10];
|
protected static CollectAction[] COLLECT_ACTIONS = new CollectAction[10];
|
||||||
private static EvaluateAction[] EVAL_ACTIONS = new EvaluateAction[10];
|
protected static EvaluateAction[] EVAL_ACTIONS = new EvaluateAction[10];
|
||||||
// private static WhileSteppingAction[] STEPPING_ACTION_1 = new WhileSteppingAction[3];
|
// private static WhileSteppingAction[] STEPPING_ACTION_1 = new WhileSteppingAction[3];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -248,7 +248,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears the counters
|
// Clears the counters
|
||||||
private void clearEventCounters() {
|
protected void clearEventCounters() {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
for (int i = 0; i < fBreakpointEvents.length; i++) {
|
for (int i = 0; i < fBreakpointEvents.length; i++) {
|
||||||
fBreakpointEvents[i] = 0;
|
fBreakpointEvents[i] = 0;
|
||||||
|
@ -259,7 +259,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the breakpoint hit count
|
// Get the breakpoint hit count
|
||||||
private int getBreakpointEventCount(int event) {
|
protected int getBreakpointEventCount(int event) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
count = fBreakpointEvents[event];
|
count = fBreakpointEvents[event];
|
||||||
|
@ -269,7 +269,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
|
|
||||||
// Suspends the thread until an event is flagged
|
// Suspends the thread until an event is flagged
|
||||||
// NOTE: too simple for real life but good enough for this test suite
|
// NOTE: too simple for real life but good enough for this test suite
|
||||||
private void waitForBreakpointEvent() {
|
protected void waitForBreakpointEvent() {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
while (!fBreakpointEvent) {
|
while (!fBreakpointEvent) {
|
||||||
try {
|
try {
|
||||||
|
@ -291,7 +291,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
// Breakpoint service methods (to use with tracepoints).
|
// Breakpoint service methods (to use with tracepoints).
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
|
|
||||||
private IBreakpointDMContext insertBreakpoint(final IBreakpointsTargetDMContext context,
|
protected IBreakpointDMContext insertBreakpoint(final IBreakpointsTargetDMContext context,
|
||||||
final Map<String,Object> attributes) throws InterruptedException
|
final Map<String,Object> attributes) throws InterruptedException
|
||||||
{
|
{
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
@ -317,7 +317,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
return (IBreakpointDMContext)wait.getReturnInfo();
|
return (IBreakpointDMContext)wait.getReturnInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException
|
protected void removeBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException
|
||||||
{
|
{
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
assertTrue(wait.getMessage(), wait.isOK());
|
assertTrue(wait.getMessage(), wait.isOK());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBreakpoint(final IBreakpointDMContext breakpoint,
|
protected void updateBreakpoint(final IBreakpointDMContext breakpoint,
|
||||||
final Map<String, Object> delta) throws InterruptedException
|
final Map<String, Object> delta) throws InterruptedException
|
||||||
{
|
{
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
@ -360,7 +360,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
assertTrue(wait.getMessage(), wait.isOK());
|
assertTrue(wait.getMessage(), wait.isOK());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBreakpointDMData getBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException
|
protected IBreakpointDMData getBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException
|
||||||
{
|
{
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
return (IBreakpointDMData)wait.getReturnInfo();
|
return (IBreakpointDMData)wait.getReturnInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBreakpointDMContext[] getBreakpoints(final IBreakpointsTargetDMContext context) throws InterruptedException
|
protected IBreakpointDMContext[] getBreakpoints(final IBreakpointsTargetDMContext context) throws InterruptedException
|
||||||
{
|
{
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
// Below are the tests for the control of tracepoints.
|
// Below are the tests for the control of tracepoints.
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
|
|
||||||
private IBreakpointDMContext[] fTracepoints = null;
|
protected IBreakpointDMContext[] fTracepoints = null;
|
||||||
|
|
||||||
// private void checkTraceStatus(boolean supported, boolean active, int frames,
|
// private void checkTraceStatus(boolean supported, boolean active, int frames,
|
||||||
// STOP_REASON_ENUM reason, Integer stoppingTracepoint) throws Throwable {
|
// STOP_REASON_ENUM reason, Integer stoppingTracepoint) throws Throwable {
|
||||||
|
@ -592,7 +592,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
// GDB 7.0 does not support fast tracepoints, but GDB 7.2 will
|
// GDB 7.0 does not support fast tracepoints, but GDB 7.2 will
|
||||||
protected boolean fastTracepointsSupported() { return false; }
|
protected boolean fastTracepointsSupported() { return false; }
|
||||||
|
|
||||||
private class TracepointData {
|
protected class TracepointData {
|
||||||
String sourceFile;
|
String sourceFile;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
String condition;
|
String condition;
|
||||||
|
@ -616,7 +616,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTracepoints(TracepointData[] dataArray) throws Throwable {
|
protected void checkTracepoints(TracepointData[] dataArray) throws Throwable {
|
||||||
int numTracepoints = dataArray.length;
|
int numTracepoints = dataArray.length;
|
||||||
|
|
||||||
// Fetch the tp list from the backend
|
// Fetch the tp list from the backend
|
||||||
|
|
|
@ -11,10 +11,18 @@
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
|
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.CollectAction;
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager;
|
||||||
|
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
|
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3.GDBRemoteTracepointsTest_7_3;
|
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3.GDBRemoteTracepointsTest_7_3;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@RunWith(BackgroundRunner.class)
|
@RunWith(BackgroundRunner.class)
|
||||||
|
@ -30,4 +38,46 @@ public class GDBRemoteTracepointsTest_7_4 extends GDBRemoteTracepointsTest_7_3 {
|
||||||
// instruction of 4 bytes or more, instead of 5.
|
// instruction of 4 bytes or more, instead of 5.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test sets the different types of tracepoints and then sets some string collection actions
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void tracepointActionsWithCollectStrings() throws Throwable {
|
||||||
|
TracepointActionManager tracepointActionMgr = TracepointActionManager.getInstance();
|
||||||
|
|
||||||
|
CollectAction action1 = new CollectAction();
|
||||||
|
action1.setCollectString("/s $locals");
|
||||||
|
action1.setName("Collect string locals");
|
||||||
|
tracepointActionMgr.addAction(action1);
|
||||||
|
|
||||||
|
CollectAction action2 = new CollectAction();
|
||||||
|
action2.setCollectString("/s3 $locals, $reg");
|
||||||
|
action2.setName("Collect string locals, reg");
|
||||||
|
tracepointActionMgr.addAction(action2);
|
||||||
|
|
||||||
|
createTracepoints();
|
||||||
|
|
||||||
|
Map<String, Object> delta = new HashMap<String, Object>();
|
||||||
|
// Set conditions for all tracepoints
|
||||||
|
delta.put(MIBreakpoints.COMMANDS, action1.getName());
|
||||||
|
updateBreakpoint(fTracepoints[0], delta);
|
||||||
|
delta.put(MIBreakpoints.COMMANDS, action2.getName());
|
||||||
|
updateBreakpoint(fTracepoints[1], delta);
|
||||||
|
delta.put(MIBreakpoints.COMMANDS, action1.getName());
|
||||||
|
updateBreakpoint(fTracepoints[2], delta);
|
||||||
|
delta.put(MIBreakpoints.COMMANDS, action1.getName());
|
||||||
|
updateBreakpoint(fTracepoints[3], delta);
|
||||||
|
delta.put(MIBreakpoints.COMMANDS, action2.getName());
|
||||||
|
updateBreakpoint(fTracepoints[4], delta);
|
||||||
|
|
||||||
|
ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
|
||||||
|
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, action1.toString(), false));
|
||||||
|
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, action2.toString(), false));
|
||||||
|
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, action1.toString(), true));
|
||||||
|
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, action1.toString(), true));
|
||||||
|
dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, action2.toString(), acceptsFastTpOnFourBytes()));
|
||||||
|
|
||||||
|
checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue