Skip to content

Commit e4dbcd2

Browse files
uftrace contribution
Allow testing of uftrace traces Signed-off-by: Matthew Khouzam <[email protected]>
1 parent 3ddd1eb commit e4dbcd2

39 files changed

+4582
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<modules>
4747
<module>ctf</module>
4848
<module>ftrace</module>
49+
<module>uftrace</module>
4950
<module>update-site</module>
5051
</modules>
5152

uftrace/pom.xml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (C) 2021 Ericsson and others
4+
5+
All rights reserved. This program and the accompanying materials
6+
are made available under the terms of the Eclipse Public License 2.0
7+
which accompanies this distribution, and is available at
8+
https://www.eclipse.org/legal/epl-2.0/
9+
10+
SPDX-License-Identifier: EPL-2.0
11+
-->
12+
13+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
15+
<modelVersion>4.0.0</modelVersion>
16+
17+
<parent>
18+
<groupId>org.eclipse.tracecompass.testtraces</groupId>
19+
<artifactId>tracecompass-test-traces-parent</artifactId>
20+
<version>1.12.0-SNAPSHOT</version>
21+
</parent>
22+
23+
<licenses>
24+
<license>
25+
<name>Eclipse Public License 2.0</name>
26+
<comments>
27+
All rights reserved. This program and the accompanying materials are
28+
made available under the terms of the Eclipse Public License 2.0 which
29+
accompanies this distribution, and is available at
30+
https://www.eclipse.org/legal/epl-2.0/
31+
32+
SPDX-License-Identifier: EPL-2.0
33+
</comments>
34+
</license>
35+
</licenses>
36+
37+
<artifactId>tracecompass-test-traces-ftrace</artifactId>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>junit</groupId>
42+
<artifactId>junit</artifactId>
43+
<version>RELEASE</version>
44+
<scope>test</scope>
45+
</dependency>
46+
</dependencies>
47+
48+
<build>
49+
<plugins>
50+
<plugin>
51+
<groupId>org.apache.felix</groupId>
52+
<artifactId>maven-bundle-plugin</artifactId>
53+
<executions>
54+
<execution>
55+
<id>bundle-manifest</id>
56+
<phase>process-classes</phase>
57+
<goals>
58+
<goal>manifest</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-source-plugin</artifactId>
66+
<configuration>
67+
<excludeResources>true</excludeResources>
68+
</configuration>
69+
<executions>
70+
<execution>
71+
<id>attach-sources</id>
72+
<goals>
73+
<goal>jar</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
81+
</project>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
12+
package org.eclipse.tracecompass.testtraces.ftrace;
13+
14+
import java.net.URL;
15+
16+
/**
17+
* Here is the list of the available test traces for the Ftrace parser.
18+
*
19+
* @author Matthew Khouzam
20+
*/
21+
public enum UftraceTestTrace {
22+
/**
23+
* Example kernel trace
24+
*
25+
* <pre>
26+
* Trace Size: 240 K
27+
* Tracer: uftrace v0.9.3 ( dwarf python tui perf sched dynamic )
28+
* Event count: 16
29+
* Kernel version: 6.5
30+
* Trace length: 300 us
31+
* </pre>
32+
*
33+
* The file is obtained by running uftrace on foobar
34+
*/
35+
TEST_FOOBAR("uftrace-foobar-demo/uftrace.dat", 16, 1),
36+
37+
38+
private final String fTraceName;
39+
private final int fNbEvent;
40+
private int fDuration;
41+
42+
private FtraceTestTrace(String traceName, int nbEvent, int time) {
43+
fTraceName = traceName;
44+
fNbEvent = nbEvent;
45+
fDuration = time;
46+
}
47+
48+
public URL getTraceURL() {
49+
URL url = this.getClass().getResource(fTraceName);
50+
if (url == null) {
51+
/* Project configuration problem? */
52+
throw new IllegalStateException("Test trace not found");
53+
}
54+
return url;
55+
}
56+
57+
/**
58+
* Get the number of events for a trace
59+
*
60+
* @return the number of events, -1 if irrelevant
61+
*/
62+
public int getNbEvents() {
63+
return fNbEvent;
64+
}
65+
66+
/**
67+
* Get the duration in seconds of a trace
68+
*
69+
* @return the duration in seconds of a trace, -1 if irrelevant
70+
*/
71+
public int getDuration() {
72+
return fDuration;
73+
}
74+
}
16.1 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <pthread.h>
2+
3+
void *bar(void) {
4+
return NULL;
5+
}
6+
7+
void *foo(void *unused) {
8+
return bar();
9+
}
10+
11+
int main(int argc, char *argv[]) {
12+
pthread_t th;
13+
14+
foo(argv);
15+
pthread_create(&th, NULL, foo, NULL);
16+
pthread_join(th, NULL);
17+
return 0;
18+
}
Binary file not shown.
Binary file not shown.

uftrace/src/main/resources/uftrace-foobar-demo/uftrace.data/default.opts

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# symbols: 17
2+
# path name: /home/matthew/work/src/uftrace/foobar
3+
# build-id: 516f6190db510f47e9608d9cfd554300d2d61b6e
4+
000000000000038c 00000020 d __abi_tag
5+
0000000000001090 00000010 P __stack_chk_fail
6+
00000000000010a0 00000010 P __monstartup
7+
00000000000010b0 00000010 P pthread_create
8+
00000000000010c0 00000010 P __cxa_atexit
9+
00000000000010d0 00000010 P pthread_join
10+
00000000000010e0 00000026 T _start
11+
0000000000001110 00000041 T __gmon_start__
12+
0000000000001160 00000005 T _dl_relocate_static_pie
13+
0000000000001229 00000015 T bar
14+
000000000000123e 0000001d T foo
15+
000000000000125b 0000007d T main
16+
00000000000012e0 00000012 t atexit
17+
0000000000001300 0000000f T __stack_chk_fail_local
18+
0000000000002000 00000004 D _IO_stdin_used
19+
0000000000004010 00000004 d called.0
20+
0000000000004014 00000001 d completed.0
915 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)