-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
Reviewed-by: jbechberger, egahlin, dholmes
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -939,6 +939,13 @@ | |
<Field type="ulong" contentType="address" name="topAddress" label="Top Address" description="Ending address of the module, if available" /> | ||
</Event> | ||
|
||
<Event name="NativeLibraryLoad" category="Java Virtual Machine, Runtime" label="Native Library Load" thread="false" stackTrace="true" startTime="true" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
MBaesken
Author
Member
|
||
description="Information about a dynamic library or other native image load operation"> | ||
<Field type="string" name="name" label="Name" /> | ||
<Field type="boolean" name="success" label="Success" description="Success or failure of the load operation" /> | ||
<Field type="string" name="errorMessage" label="Error Message" description="In case of a load error, error description" /> | ||
</Event> | ||
|
||
<Event name="ModuleRequire" category="Java Virtual Machine, Runtime, Modules" label="Module Require" thread="false" period="everyChunk" | ||
description="A directed edge representing a dependency"> | ||
<Field type="Module" name="source" label="Source Module" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
package jdk.jfr.event.runtime; | ||
|
||
import static jdk.test.lib.Asserts.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import jdk.jfr.Recording; | ||
import jdk.jfr.consumer.RecordedEvent; | ||
import jdk.test.lib.Platform; | ||
import jdk.test.lib.jfr.EventNames; | ||
import jdk.test.lib.jfr.Events; | ||
|
||
/** | ||
* @test | ||
* @bug 8313251 | ||
* @key jfr | ||
* @requires vm.hasJFR | ||
* @library /test/lib | ||
* @run main/othervm jdk.jfr.event.runtime.TestNativeLibraryLoadEvent | ||
*/ | ||
public class TestNativeLibraryLoadEvent { | ||
|
||
private final static String EVENT_NAME = EventNames.NativeLibraryLoad; | ||
|
||
public static void main(String[] args) throws Throwable { | ||
try (Recording recording = new Recording()) { | ||
recording.enable(EVENT_NAME); | ||
recording.start(); | ||
System.loadLibrary("instrument"); | ||
recording.stop(); | ||
|
||
List<String> expectedLibs = getExpectedLibs(); | ||
for (RecordedEvent event : Events.fromRecording(recording)) { | ||
System.out.println("Event:" + event); | ||
String lib = Events.assertField(event, "name").notEmpty().getValue(); | ||
Events.assertField(event, "success"); | ||
for (String expectedLib : new ArrayList<>(expectedLibs)) { | ||
if (lib.contains(expectedLib)) { | ||
expectedLibs.remove(expectedLib); | ||
} | ||
} | ||
} | ||
assertTrue(expectedLibs.isEmpty(), "Missing libraries:" + expectedLibs.stream().collect(Collectors.joining(", "))); | ||
} | ||
} | ||
|
||
private static List<String> getExpectedLibs() throws Throwable { | ||
String libTemplate = null; | ||
if (Platform.isWindows()) { | ||
libTemplate = "%s.dll"; | ||
} else if (Platform.isOSX()) { | ||
libTemplate = "lib%s.dylib"; | ||
} else if (Platform.isLinux()) { | ||
libTemplate = "lib%s.so"; | ||
} else if (Platform.isAix()) { | ||
libTemplate = "lib%s.so"; | ||
} | ||
|
||
if (libTemplate == null) { | ||
throw new Exception("Unsupported OS"); | ||
} | ||
|
||
List<String> libs = new ArrayList<String>(); | ||
String[] names = { "instrument" }; | ||
for (String name : names) { | ||
libs.add(String.format(libTemplate, name)); | ||
} | ||
return libs; | ||
} | ||
|
||
} |
3 comments
on commit 5d23295
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/backport jdk21u
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MBaesken the backport was successfully created on the branch MBaesken-backport-5d232959 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:
The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
Hi all,
This pull request contains a backport of commit 5d232959 from the openjdk/jdk repository.
The commit being backported was authored by Matthias Baesken on 4 Aug 2023 and was reviewed by Johannes Bechberger, Erik Gahlin and David Holmes.
Thanks!
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:
$ git fetch https://github.com/openjdk-bots/jdk21u.git MBaesken-backport-5d232959:MBaesken-backport-5d232959
$ git checkout MBaesken-backport-5d232959
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git MBaesken-backport-5d232959
Why were the events declared without thread information but including a stack trace?