mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 456807 - Update Tracepoint tests to handle both 32bit and 64bit
architectures Change-Id: I4325fadfec95efc263b72db8dbe446de31154169 Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/39006
This commit is contained in:
parent
c0ea87636e
commit
6a765aed3b
6 changed files with 264 additions and 809 deletions
|
@ -24,10 +24,10 @@ Export-Package: org.eclipse.cdt.dsf.gdb,
|
||||||
org.eclipse.cdt.dsf.gdb.internal.commands;x-friends:="org.eclipse.cdt.dsf.gdb.ui",
|
org.eclipse.cdt.dsf.gdb.internal.commands;x-friends:="org.eclipse.cdt.dsf.gdb.ui",
|
||||||
org.eclipse.cdt.dsf.gdb.internal.memory;x-internal:=true,
|
org.eclipse.cdt.dsf.gdb.internal.memory;x-internal:=true,
|
||||||
org.eclipse.cdt.dsf.gdb.internal.service.command.commands;x-internal:=true,
|
org.eclipse.cdt.dsf.gdb.internal.service.command.commands;x-internal:=true,
|
||||||
|
org.eclipse.cdt.dsf.gdb.internal.service.command.events;x-internal:=true,
|
||||||
org.eclipse.cdt.dsf.gdb.internal.service.command.output;x-internal:=true,
|
org.eclipse.cdt.dsf.gdb.internal.service.command.output;x-internal:=true,
|
||||||
org.eclipse.cdt.dsf.gdb.internal.service.control;x-internal:=true,
|
org.eclipse.cdt.dsf.gdb.internal.service.control;x-internal:=true,
|
||||||
org.eclipse.cdt.dsf.gdb.internal.service.command.events;x-internal:=true,
|
org.eclipse.cdt.dsf.gdb.internal.tracepointactions;x-friends:="org.eclipse.cdt.dsf.gdb.ui,org.eclipse.cdt.tests.dsf.gdb",
|
||||||
org.eclipse.cdt.dsf.gdb.internal.tracepointactions;x-friends:="org.eclipse.cdt.dsf.gdb.ui",
|
|
||||||
org.eclipse.cdt.dsf.gdb.launching,
|
org.eclipse.cdt.dsf.gdb.launching,
|
||||||
org.eclipse.cdt.dsf.gdb.service,
|
org.eclipse.cdt.dsf.gdb.service,
|
||||||
org.eclipse.cdt.dsf.gdb.service.command,
|
org.eclipse.cdt.dsf.gdb.service.command,
|
||||||
|
|
|
@ -12,8 +12,8 @@ COREFILE = $(BINDIR)/core
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|
||||||
CFLAGS = -g
|
CFLAGS = -g3 -O0
|
||||||
CXXFLAGS = -g
|
CXXFLAGS = -g3 -O0
|
||||||
|
|
||||||
# Don't try to use pthread on Windows
|
# Don't try to use pthread on Windows
|
||||||
# The OS environment variable exists on Windows
|
# The OS environment variable exists on Windows
|
||||||
|
|
|
@ -1,154 +1,41 @@
|
||||||
#ifdef __MINGW32__
|
/*
|
||||||
#include <process.h> // MinGW has no POSIX support; use MSVC runtime
|
* This program should be compiled with -g3 -O0 to try to always obtain
|
||||||
#else
|
* the proper instruction sizes at the expected location.
|
||||||
#include <pthread.h>
|
* The instruction sizes matter for tests that set tracepoints
|
||||||
#endif
|
*/
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "Sleep.h"
|
|
||||||
#define NUM_THREADS 5
|
|
||||||
|
|
||||||
int gIntVar = 543;
|
int bar() {
|
||||||
double gDoubleVar = 543.543;
|
|
||||||
char gCharVar = 'g';
|
|
||||||
bool gBoolVar = false;
|
|
||||||
|
|
||||||
int gIntArray[2] = {987, 654};
|
|
||||||
double gDoubleArray[2] = {987.654, 654.321};
|
|
||||||
char gCharArray[2] = {'g', 'd'};
|
|
||||||
bool gBoolArray[2] = {true, false};
|
|
||||||
|
|
||||||
int *gIntPtr = &gIntVar;
|
|
||||||
double *gDoublePtr = &gDoubleVar;
|
|
||||||
char *gCharPtr = &gCharVar;
|
|
||||||
bool *gBoolPtr = &gBoolVar;
|
|
||||||
|
|
||||||
int *gIntPtr2 = (int*)0x8;
|
|
||||||
double *gDoublePtr2 = (double*)0x5432;
|
|
||||||
char *gCharPtr2 = (char*)0x4321;
|
|
||||||
bool *gBoolPtr2 = (bool*)0x12ABCDEF;
|
|
||||||
|
|
||||||
class bar {
|
|
||||||
public:
|
|
||||||
int d;
|
|
||||||
private:
|
|
||||||
int e[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
class bar2 {
|
|
||||||
public:
|
|
||||||
int f;
|
|
||||||
private:
|
|
||||||
int g[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
class foo: public bar, bar2 {
|
|
||||||
public:
|
|
||||||
int a[2];
|
|
||||||
bar b;
|
|
||||||
private:
|
|
||||||
int c;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Z {
|
|
||||||
public:
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
struct childStruct {
|
|
||||||
public:
|
|
||||||
Z z;
|
|
||||||
};
|
|
||||||
|
|
||||||
#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
|
|
||||||
{
|
|
||||||
long tid = (long)threadid;
|
|
||||||
printf("Hello World! It's me, thread #%ld!\n", tid);
|
|
||||||
|
|
||||||
int lIntVar = 12345;
|
|
||||||
double lDoubleVar = 12345.12345;
|
|
||||||
char lCharVar = 'm';
|
|
||||||
bool lBoolVar = false;
|
|
||||||
|
|
||||||
int lIntArray[2] = {6789, 12345};
|
|
||||||
double lDoubleArray[2] = {456.789, 12345.12345};
|
|
||||||
char lCharArray[2] = {'i', 'm'};
|
|
||||||
bool lBoolArray[2] = {true, false};
|
|
||||||
|
|
||||||
int *lIntPtr = &lIntVar;
|
|
||||||
double *lDoublePtr = &lDoubleVar;
|
|
||||||
char *lCharPtr = &lCharVar;
|
|
||||||
bool *lBoolPtr = &gBoolVar;
|
|
||||||
|
|
||||||
int *lIntPtr2 = (int*)0x1;
|
|
||||||
double *lDoublePtr2 = (double*)0x2345;
|
|
||||||
char *lCharPtr2 = (char*)0x1234;
|
|
||||||
bool *lBoolPtr2 = (bool*)0x123ABCDE;
|
|
||||||
|
|
||||||
int counter = 0;
|
|
||||||
// Small loop
|
|
||||||
for (counter=0; counter<10;) {
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("counter is now #%d!\n", counter);
|
|
||||||
|
|
||||||
// Large loop
|
|
||||||
for (; counter<10000;) {
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int foo(int a)
|
||||||
|
{
|
||||||
|
int x = a;
|
||||||
|
|
||||||
|
while(x < 5) { // 2-byte on both 32bit and 64bit
|
||||||
|
|
||||||
|
if (x != a) { // 3-byte on both 32bit and 64bit
|
||||||
|
|
||||||
|
++x; // 4-byte on both 32bit and 64bit
|
||||||
|
|
||||||
|
bar(); // 5-byte on both 32bit and 64bit
|
||||||
|
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} // 1-byte on both 32bit and 64bit
|
||||||
|
|
||||||
|
int gIntVar = 0;
|
||||||
|
bool gBoolVar = true;
|
||||||
|
|
||||||
|
void lastCall() {}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
foo(0);
|
||||||
|
|
||||||
|
lastCall(); // This method should be called last
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2012 Ericsson and others.
|
* Copyright (c) 2012, 2014 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
|
||||||
|
@ -11,7 +11,6 @@
|
||||||
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -21,6 +20,7 @@ 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.eclipse.core.runtime.Platform;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@ -34,9 +34,12 @@ public class GDBRemoteTracepointsTest_7_4 extends GDBRemoteTracepointsTest_7_3 {
|
||||||
@Override
|
@Override
|
||||||
protected boolean acceptsFastTpOnFourBytes() {
|
protected boolean acceptsFastTpOnFourBytes() {
|
||||||
// With GDB 7.4, fast tracepoints only need an
|
// With GDB 7.4, fast tracepoints only need an
|
||||||
// instruction of 4 bytes or more, instead of 5.
|
// instruction of 4 bytes or more when on a 32bit architecture, instead of 5.
|
||||||
|
if (Platform.getOS().equals(Platform.ARCH_X86)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test sets the different types of tracepoints and then sets some string collection actions
|
* This test sets the different types of tracepoints and then sets some string collection actions
|
||||||
|
@ -70,13 +73,14 @@ public class GDBRemoteTracepointsTest_7_4 extends GDBRemoteTracepointsTest_7_3 {
|
||||||
delta.put(MIBreakpoints.COMMANDS, action2.getName());
|
delta.put(MIBreakpoints.COMMANDS, action2.getName());
|
||||||
updateBreakpoint(fTracepoints[4], delta);
|
updateBreakpoint(fTracepoints[4], delta);
|
||||||
|
|
||||||
ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
|
TracepointData[] dataArray = new TracepointData[] {
|
||||||
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, action1.toString(), false));
|
new TracepointData(LINE_NUMBER_1_BYTE_INSTR, NO_CONDITION, 0, true, action1.toString(), false),
|
||||||
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, action2.toString(), false));
|
new TracepointData(LINE_NUMBER_2_BYTE_INSTR, NO_CONDITION, 0, true, action2.toString(), false),
|
||||||
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, action1.toString(), true));
|
new TracepointData(LINE_NUMBER_3_BYTE_INSTR, NO_CONDITION, 0, true, action1.toString(), false),
|
||||||
dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, action1.toString(), true));
|
new TracepointData(LINE_NUMBER_4_BYTE_INSTR, NO_CONDITION, 0, true, action1.toString(), acceptsFastTpOnFourBytes()),
|
||||||
dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, action2.toString(), acceptsFastTpOnFourBytes()));
|
new TracepointData(LINE_NUMBER_5_BYTE_INSTR, NO_CONDITION, 0, true, action2.toString(), true),
|
||||||
|
};
|
||||||
|
|
||||||
checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
|
checkTracepoints(dataArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,12 @@ import org.junit.runners.MethodSorters;
|
||||||
public class TraceFileTest_7_4 extends BaseTestCase {
|
public class TraceFileTest_7_4 extends BaseTestCase {
|
||||||
|
|
||||||
private final static String FILE_NAME = "TracepointTestApp.cc";
|
private final static String FILE_NAME = "TracepointTestApp.cc";
|
||||||
private final static int LINE_NUMBER_1 = 97;
|
private final static String EXECUTABLE_PATH = "data/launch/bin/TracepointTestApp.exe";
|
||||||
private final static int LINE_NUMBER_2 = 102;
|
private final static int LINE_NUMBER_1 = 17;
|
||||||
private final static String TEVAL_STRING = "lBoolPtr2";
|
private final static int LINE_NUMBER_2 = 24;
|
||||||
private final static String COLLECT_STRING1 = "counter";
|
private final static String END_FUNCTION = "lastCall";
|
||||||
|
private final static String TEVAL_STRING = "a";
|
||||||
|
private final static String COLLECT_STRING1 = "x";
|
||||||
private final static String COLLECT_STRING2 = "$regs";
|
private final static String COLLECT_STRING2 = "$regs";
|
||||||
private final static String TRACE_FILE = "data/launch/bin/trace";
|
private final static String TRACE_FILE = "data/launch/bin/trace";
|
||||||
|
|
||||||
|
@ -119,9 +121,8 @@ public class TraceFileTest_7_4 extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* This test implements the following steps.
|
* This test implements the following steps.
|
||||||
* 1. Starts a remote session
|
* 1. Starts a remote session
|
||||||
* 2. Sets two tracepoints at data/launch/src/TracepointTestApp.cc:97
|
* 2. Sets two tracepoints in data/launch/src/TracepointTestApp.cc
|
||||||
* and data/launch/src/TracepointTestApp.cc:102.
|
* The first tracepoint's command is "teval a".
|
||||||
* The first tracepoint's command is "teval lBoolPtr2".
|
|
||||||
* The second tracepoint's commands are "collect counter" and "collect $regs".
|
* The second tracepoint's commands are "collect counter" and "collect $regs".
|
||||||
* 3. Sets a regular breakpoint at the end of the source file.
|
* 3. Sets a regular breakpoint at the end of the source file.
|
||||||
* 4. Starts tracing
|
* 4. Starts tracing
|
||||||
|
@ -261,7 +262,7 @@ public class TraceFileTest_7_4 extends BaseTestCase {
|
||||||
private void startRemoteSession() throws Throwable {
|
private void startRemoteSession() throws Throwable {
|
||||||
// Set launch attributes
|
// Set launch attributes
|
||||||
super.setLaunchAttributes();
|
super.setLaunchAttributes();
|
||||||
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/TracepointTestApp.exe");
|
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EXECUTABLE_PATH);
|
||||||
// GDB tracepoints are only supported on a remote target (e.g., using gdbserver)
|
// GDB tracepoints are only supported on a remote target (e.g., using gdbserver)
|
||||||
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
|
IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
|
||||||
|
@ -347,7 +348,7 @@ public class TraceFileTest_7_4 extends BaseTestCase {
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||||
attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
|
attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
|
||||||
attributes.put(MIBreakpoints.FILE_NAME, FILE_NAME);
|
attributes.put(MIBreakpoints.FILE_NAME, FILE_NAME);
|
||||||
attributes.put(MIBreakpoints.LINE_NUMBER, 152);
|
attributes.put(MIBreakpoints.FUNCTION, END_FUNCTION);
|
||||||
IBreakpointDMContext bptDMC = insertBreakpoint(fBreakpointsDmc, attributes);
|
IBreakpointDMContext bptDMC = insertBreakpoint(fBreakpointsDmc, attributes);
|
||||||
assertTrue(bptDMC instanceof MIBreakpointDMContext);
|
assertTrue(bptDMC instanceof MIBreakpointDMContext);
|
||||||
return (MIBreakpointDMContext)bptDMC;
|
return (MIBreakpointDMContext)bptDMC;
|
||||||
|
|
Loading…
Add table
Reference in a new issue