1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 346320: Add support for fast tracepoints

This commit is contained in:
Marc Khouzam 2011-07-20 09:25:29 -04:00
parent 03824cc6ca
commit d592d691aa
9 changed files with 1380 additions and 733 deletions

View file

@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* Ericsson - Modified for DSF
* Sergey Prigogin (Google)
* Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
@ -30,9 +31,11 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
@ -53,6 +56,14 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
protected Button fReverseCheckBox;
protected Button fUpdateThreadlistOnSuspend;
protected Button fDebugOnFork;
/**
* A combo box to let the user choose if fast tracepoints should be used or not.
*/
protected Combo fTracepointModeCombo;
protected static final String TP_FAST_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_fast"); //$NON-NLS-1$
protected static final String TP_SLOW_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_slow"); //$NON-NLS-1$
protected static final String TP_AUTOMATIC = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_auto"); //$NON-NLS-1$
private IMILaunchConfigurationComponent fSolibBlock;
private boolean fIsInitializing = false;
@ -82,7 +93,9 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK,
IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_ON_FORK_DEFAULT);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT);
if (fSolibBlock != null)
fSolibBlock.setDefaults(configuration);
}
@ -141,10 +154,46 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
fReverseCheckBox.setSelection(reverseEnabled);
fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend);
fDebugOnFork.setSelection(debugOnFork);
updateTracepointModeFromConfig(configuration);
setInitializing(false);
}
protected void updateTracepointModeFromConfig(ILaunchConfiguration config) {
if (fTracepointModeCombo != null) {
String tracepointMode = getStringAttr(config, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT);
if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) {
fTracepointModeCombo.setText(TP_SLOW_ONLY);
} else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) {
fTracepointModeCombo.setText(TP_FAST_ONLY);
} else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) {
fTracepointModeCombo.setText(TP_AUTOMATIC);
} else {
assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$
fTracepointModeCombo.setText(TP_SLOW_ONLY);
}
}
}
protected String getSelectedTracepointMode() {
if (fTracepointModeCombo != null) {
int selectedIndex = fTracepointModeCombo.getSelectionIndex();
if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_SLOW_ONLY)) {
return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY;
} else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_FAST_ONLY)) {
return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY;
} else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_AUTOMATIC)) {
return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW;
} else {
assert false : "Unknown Tracepoint mode: " + fTracepointModeCombo.getItem(selectedIndex); //$NON-NLS-1$
}
}
return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT;
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
fGDBCommandText.getText().trim());
@ -158,6 +207,12 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
fUpdateThreadlistOnSuspend.getSelection());
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK,
fDebugOnFork.getSelection());
if (fTracepointModeCombo != null) {
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
getSelectedTracepointMode());
}
if (fSolibBlock != null)
fSolibBlock.performApply(configuration);
}
@ -307,6 +362,30 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer {
PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$
fDebugOnFork = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.Automatically_debug_forked_processes")); //$NON-NLS-1$
createTracepointModeCombo(subComp);
}
protected void createTracepointModeCombo(Composite parent) {
// Add a combo to choose the type of tracepoint mode to use
Label label = ControlFactory.createLabel(parent, LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_label")); //$NON-NLS-1$
label.setLayoutData(new GridData());
fTracepointModeCombo = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
fTracepointModeCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
fTracepointModeCombo.add(TP_SLOW_ONLY);
fTracepointModeCombo.add(TP_FAST_ONLY);
fTracepointModeCombo.add(TP_AUTOMATIC);
fTracepointModeCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
fTracepointModeCombo.select(0);
}
public void createSolibTab(TabFolder tabFolder) {

View file

@ -8,6 +8,7 @@
# Contributors:
# QNX Software Systems - initial API and implementation
# Ericsson - Updated for DSF
# Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320)
###############################################################################
GDBDebuggerPage.gdb_executable_not_specified=Debugger executable must be specified.
@ -25,6 +26,10 @@ GDBDebuggerPage.nonstop_mode=Non-stop mode (Note: Requires non-stop GDB)
GDBDebuggerPage.reverse_Debugging=Enable Reverse Debugging at startup (Note: Requires Reverse GDB)
GDBDebuggerPage.update_thread_list_on_suspend=Force thread list update on suspend
GDBDebuggerPage.Automatically_debug_forked_processes=Automatically debug forked processes (Note: Requires Multi Process GDB)
GDBDebuggerPage.tracepoint_mode_label=Tracepoint mode:
GDBDebuggerPage.tracepoint_mode_fast=Fast
GDBDebuggerPage.tracepoint_mode_slow=Slow
GDBDebuggerPage.tracepoint_mode_auto=Automatic
StandardGDBDebuggerPage.0=Debugger executable must be specified.
StandardGDBDebuggerPage.1=GDB Debugger Options
StandardGDBDebuggerPage.2=Main

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Ericsson - initial API and implementation
* Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb;
@ -104,7 +105,13 @@ public class IGDBLaunchConfigurationConstants {
* @since 4.0
*/
public static final String ATTR_DEBUGGER_DEBUG_ON_FORK = GdbPlugin.PLUGIN_ID + ".DEBUG_ON_FORK"; //$NON-NLS-1$
/**
* Launch configuration attribute key. The value is a String specifying the type of Tracepoint mode
* that should be used for this launch.
* @since 4.1
*/
public static final String ATTR_DEBUGGER_TRACEPOINT_MODE = GdbPlugin.PLUGIN_ID + ".TRACEPOINT_MODE"; //$NON-NLS-1$
/**
* Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
@ -174,6 +181,33 @@ public class IGDBLaunchConfigurationConstants {
* @since 4.0
*/
public static final boolean DEBUGGER_DEBUG_ON_FORK_DEFAULT = false;
/**
* Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
* Indicates that only slow tracepoints should be used.
* @since 4.1
*/
public static final String DEBUGGER_TRACEPOINT_SLOW_ONLY = "TP_SLOW_ONLY"; //$NON-NLS-1$
/**
* Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
* Indicates that only fast tracepoints should be used.
* @since 4.1
*/
public static final String DEBUGGER_TRACEPOINT_FAST_ONLY = "TP_FAST_ONLY"; //$NON-NLS-1$
/**
* Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
* Indicates that slow tracepoints should be used whenever a fast tracepoint
* cannot be inserted.
* @since 4.1
*/
public static final String DEBUGGER_TRACEPOINT_FAST_THEN_SLOW = "TP_FAST_THEN_SLOW"; //$NON-NLS-1$
/**
* Default attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
* @since 4.1
*/
public static final String DEBUGGER_TRACEPOINT_MODE_DEFAULT = DEBUGGER_TRACEPOINT_SLOW_ONLY;
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Ericsson - Initial API and implementation
* Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service;
@ -20,24 +21,32 @@ import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
/**
* Breakpoint service for GDB 7.2.
* It support MI for tracepoints.
* It also support for fast vs slow tracepoints.
*
* @since 4.1
*/
public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0
{
private IMICommandControl fConnection;
private enum TracepointMode { FAST_THEN_SLOW, FAST_ONLY, SLOW_ONLY };
private TracepointMode fTracepointMode = TracepointMode.SLOW_ONLY;
public GDBBreakpoints_7_2(DsfSession session) {
super(session);
@ -60,6 +69,8 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0
// Get the services references
fConnection = getServicesTracker().getService(IMICommandControl.class);
setTracepointMode();
// Register this service
register(new String[] { IBreakpoints.class.getName(),
IBreakpointsExtension.class.getName(),
@ -76,36 +87,50 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0
unregister();
super.shutdown(requestMonitor);
}
private void setTracepointMode() {
ILaunch launch = (ILaunch)getSession().getModelAdapter(ILaunch.class);
String tpMode = IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT;
try {
tpMode = launch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT);
} catch (CoreException e) {
}
/**
* Add a tracepoint using MI
*/
@Override
protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
{
if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) {
fTracepointMode = TracepointMode.FAST_ONLY;
} else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) {
fTracepointMode = TracepointMode.SLOW_ONLY;
} else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) {
fTracepointMode = TracepointMode.FAST_THEN_SLOW;
} else {
assert false : "Invalid tracepoint mode: " + tpMode; //$NON-NLS-1$
fTracepointMode = TracepointMode.SLOW_ONLY;
}
}
protected void sendTracepointCommand(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, boolean isFastTracepoint, final DataRequestMonitor<IBreakpointDMContext> drm) {
// Select the context breakpoints map
final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
if (contextBreakpoints == null) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
return;
}
// Extract the relevant parameters (providing default values to avoid potential NPEs)
final String location = formatLocation(attributes);
if (location.equals(NULL_STRING)) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
drm.done();
return;
}
final Boolean enabled = (Boolean) getProperty(attributes, MIBreakpoints.IS_ENABLED, true);
final Boolean isHardware = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_HARDWARE, false);
final String condition = (String) getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING);
fConnection.queueCommand(
fConnection.getCommandFactory().createMIBreakInsert(context, false, isHardware, condition, 0, location, 0, !enabled, true),
fConnection.getCommandFactory().createMIBreakInsert(context, false, isFastTracepoint, condition, 0, location, 0, !enabled, true),
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), drm) {
@Override
protected void handleSuccess() {
@ -127,20 +152,20 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0
contextBreakpoints.put(reference, newBreakpoint);
// Format the return value
MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference);
drm.setData(dmc);
MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference);
drm.setData(dmc);
// Flag the event
getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
// Tracepoints are created with no passcount (passcount are not
// the same thing as ignore-count, which is not supported by
// tracepoints). We have to set the passcount manually now.
// Same for commands.
Map<String,Object> delta = new HashMap<String,Object>();
delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0));
delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$
modifyBreakpoint(dmc, delta, drm, false);
// Flag the event
getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
// Tracepoints are created with no passcount (passcount are not
// the same thing as ignore-count, which is not supported by
// tracepoints). We have to set the passcount manually now.
// Same for commands.
Map<String,Object> delta = new HashMap<String,Object>();
delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0));
delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$
modifyBreakpoint(dmc, delta, drm, false);
}
@Override
@ -150,4 +175,37 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0
}
});
}
/**
* Add a tracepoint using MI. We have three settings:
* 1- set only a fast tracepoint but if it fails, set a slow tracepoint
* 2- only set a fast tracepoint even if it fails
* 3- only set a slow tracepoint even if a fast tracepoint could have been used
*/
@Override
protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm) {
// Unless we should only set slow tracepoints, we try to set a fast tracepoint.
boolean isFastTracepoint = fTracepointMode != TracepointMode.SLOW_ONLY;
sendTracepointCommand(context, attributes, isFastTracepoint, new DataRequestMonitor<IBreakpointDMContext>(ImmediateExecutor.getInstance(), drm) {
@Override
protected void handleSuccess() {
// Tracepoint was set successfully.
drm.setData(getData());
drm.done();
}
@Override
protected void handleError() {
// Tracepoint failed to be set.
if (fTracepointMode == TracepointMode.FAST_THEN_SLOW) {
// In this case, we failed to set a fast tracepoint, but we should try to set a slow one.
sendTracepointCommand(context, attributes, false, drm);
} else {
// We either failed to set a fast tracepoint and we should not try to set a slow one,
// or we failed to set a slow one. Either way, we are done.
drm.setStatus(getStatus());
drm.done();
}
}
});
}
}

View file

@ -100,7 +100,9 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
@Override
protected IBreakpoints createBreakpointService(DsfSession session) {
if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) {
// This service is available for GDB 7.2 but there is a pre-release of GDB that
// supports the same features and has version of 6.8.50.20090414
if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$
return new GDBBreakpoints_7_2(session);
}
if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
@ -192,8 +194,8 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
/** @since 3.0 */
protected IGDBTraceControl createTraceControlService(DsfSession session, ILaunchConfiguration config) {
// This service is available for GDB 7.2. But until that GDB is itself available
// there is a pre-release that has a version of 6.8.50.20090414
// This service is available for GDB 7.2 but there is a pre-release of GDB that
// supports the same features and has version of 6.8.50.20090414
if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$
return new GDBTraceControl_7_2(session, config);
}

View file

@ -17,6 +17,8 @@ package org.eclipse.cdt.dsf.mi.service.command.output;
import java.util.StringTokenizer;
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager;
/**
* Contain info about the GDB/MI breakpoint.
*
@ -497,8 +499,29 @@ public class MIBreakpoint {
cond = str;
} else if (var.equals("pending")) { //$NON-NLS-1$
// Only supported starting with GDB 6.8
pending = true;
pending = true;
} else if (var.equals("script")) { //$NON-NLS-1$
if (value instanceof MITuple) {
parseCommands((MITuple)value);
}
}
}
}
void parseCommands(MITuple tuple) {
MIValue[] values = tuple.getMIValues();
StringBuffer cmds = new StringBuffer();
for (int i = 0; i < values.length; i++) {
MIValue value = values[i];
if (value != null && value instanceof MIConst) {
if (i > 0) {
// Insert a delimiter
cmds.append(TracepointActionManager.TRACEPOINT_ACTION_DELIMITER);
}
cmds.append(((MIConst)value).getCString());
}
}
setCommands(cmds.toString());
}
}

View file

@ -1,4 +1,12 @@
#ifdef __MINGW32__
#include <process.h> // MinGW has no POSIX support; use MSVC runtime
#else
#include <pthread.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "Sleep.h"
#define NUM_THREADS 5
int gIntVar = 543;
double gDoubleVar = 543.543;
@ -52,8 +60,21 @@ public:
Z z;
};
void testTracepoints() {
printf("Running TracepointTest App\n");
#ifdef __MINGW32__
typedef unsigned int TID;
#else
typedef pthread_t TID;
#endif
#ifdef __MINGW32__
unsigned int __stdcall testTracepoints(void *threadid)
#else
void *testTracepoints(void *threadid)
#endif
{
int tid = (int)threadid;
printf("Hello World! It's me, thread #%d!\n", tid);
int lIntVar = 12345;
double lDoubleVar = 12345.12345;
@ -81,16 +102,53 @@ void testTracepoints() {
counter++;
}
counter = 185;
printf("counter is now #%d!\n", counter);
// Large loop
for (counter=0; counter<10000;) {
for (; counter<10000;) {
counter++;
}
}
int main() {
testTracepoints();
SLEEP(2); // keep this thread around for a bit; the tests will check for its existence while the main thread is stopped at a breakpoint
#ifdef __MINGW32__
return 0;
#else
pthread_exit(NULL);
#endif
}
int main()
{
TID threads[NUM_THREADS];
int t;
for(t=0; t < NUM_THREADS; t++)
{
printf("In main: creating thread %d\n", t);
#ifdef __MINGW32__
{
uintptr_t rc = _beginthreadex(NULL, 0, testTracepoints, (void*)t, 0, &threads[t]);
SLEEP(1); // debugger should for sure receive thread creation event after stepping over this sleep; not guaranteed to happen simply stepping over the thread creation call
if (rc == 0)
{
printf("ERROR; _beginthreadex() failed. errno = %d\n", errno);
exit(-1);
}
}
#else
{
int rc = pthread_create(&threads[t], NULL, testTracepoints, (void *)t);
SLEEP(1); // debugger should for sure receive thread creation event after stepping over this sleep; not guaranteed to happen simply stepping over the thread creation call
if (rc)
{
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
#endif
}
SLEEP(2); // keep this thread around for a bit
return 0;
}

View file

@ -23,4 +23,7 @@ public class GDBRemoteTracepointsTest_7_2 extends GDBRemoteTracepointsTest_7_1 {
public static void beforeClassMethod_7_2() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
}
@Override
protected boolean fastTracepointsSupported() { return true; }
}