-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[XRay] Add support for instrumentation of DSOs on x86_64 #90959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
86e252c
[XRay] Add DSO support for XRay instrumentation on X86_64
sebastiankreutzer 1bd2ac0
fixup! [XRay] Add DSO support for XRay instrumentation on X86_64
sebastiankreutzer 1dc7361
fixup! [XRay] Add DSO support for XRay instrumentation on X86_64
sebastiankreutzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s | ||
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fpic -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s | ||
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s | ||
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fno-PIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PIC | ||
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fno-pic -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PIC | ||
|
||
// On 64 bit darwin, PIC is always enabled | ||
// RUN: %clang -### --target=x86_64-apple-darwin -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s | ||
|
||
// Check unsupported targets | ||
// RUN: not %clang -### --target=aarch64-pc-freebsd -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET | ||
// RUN: not %clang -### --target=arm64-apple-macos -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET | ||
|
||
// CHECK: "-cc1" {{.*}}"-fxray-instrument" {{.*}}"-fxray-shared" | ||
// ERR-TARGET: error: unsupported option '-fxray-shared' for target | ||
// ERR-PIC: error: option '-fxray-shared' cannot be specified without '-fPIC' | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,31 +93,74 @@ enum XRayPatchingStatus { | |
FAILED = 3, | ||
}; | ||
|
||
/// This tells XRay to patch the instrumentation points. See XRayPatchingStatus | ||
/// This tells XRay to patch the instrumentation points in all currently loaded objects. See XRayPatchingStatus | ||
/// for possible result values. | ||
extern XRayPatchingStatus __xray_patch(); | ||
|
||
/// This tells XRay to patch the instrumentation points in the given object. | ||
/// See XRayPatchingStatus for possible result values. | ||
extern XRayPatchingStatus __xray_patch_object(int32_t ObjId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: Is it possible to provide documentation to this and other added functions? |
||
|
||
/// Reverses the effect of __xray_patch(). See XRayPatchingStatus for possible | ||
/// result values. | ||
extern XRayPatchingStatus __xray_unpatch(); | ||
|
||
/// This patches a specific function id. See XRayPatchingStatus for possible | ||
/// Reverses the effect of __xray_patch_object. See XRayPatchingStatus for possible | ||
/// result values. | ||
extern XRayPatchingStatus __xray_unpatch_object(int32_t ObjId); | ||
|
||
/// This unpacks the given (packed) function id and patches | ||
/// the corresponding function. See XRayPatchingStatus for possible | ||
/// result values. | ||
extern XRayPatchingStatus __xray_patch_function(int32_t FuncId); | ||
|
||
/// This unpatches a specific function id. See XRayPatchingStatus for possible | ||
/// This patches a specific function in the given object. See XRayPatchingStatus for possible | ||
/// result values. | ||
extern XRayPatchingStatus __xray_patch_function_in_object(int32_t FuncId, | ||
int32_t ObjId); | ||
|
||
/// This unpacks the given (packed) function id and unpatches | ||
/// the corresponding function. See XRayPatchingStatus for possible | ||
/// result values. | ||
extern XRayPatchingStatus __xray_unpatch_function(int32_t FuncId); | ||
|
||
/// This function returns the address of the function provided a valid function | ||
/// id. We return 0 if we encounter any error, even if 0 may be a valid function | ||
/// This unpatches a specific function in the given object. | ||
/// See XRayPatchingStatus for possible result values. | ||
extern XRayPatchingStatus __xray_unpatch_function_in_object(int32_t FuncId, | ||
int32_t ObjId); | ||
|
||
/// This function unpacks the given (packed) function id and returns the address of the corresponding function. We return 0 if we encounter any error, even if 0 may be a valid function | ||
/// address. | ||
extern uintptr_t __xray_function_address(int32_t FuncId); | ||
|
||
/// This function returns the maximum valid function id. Returns 0 if we | ||
/// This function returns the address of the function in the given object provided valid function and object | ||
/// ids. We return 0 if we encounter any error, even if 0 may be a valid function | ||
/// address. | ||
extern uintptr_t __xray_function_address_in_object(int32_t FuncId, | ||
int32_t ObjId); | ||
|
||
/// This function returns the maximum valid function id for the main executable (object id = 0). Returns 0 if we | ||
/// encounter errors (when there are no instrumented functions, etc.). | ||
extern size_t __xray_max_function_id(); | ||
|
||
/// This function returns the maximum valid function id for the given object. Returns 0 if we | ||
/// encounter errors (when there are no instrumented functions, etc.). | ||
extern size_t __xray_max_function_id_in_object(int32_t ObjId); | ||
|
||
/// This function returns the number of previously registered objects (executable + loaded DSOs). | ||
/// Returns 0 if XRay has not been initialized. | ||
extern size_t __xray_num_objects(); | ||
|
||
/// Unpacks the function id from the given packed id. | ||
extern int32_t __xray_unpack_function_id(int32_t PackedId); | ||
|
||
/// Unpacks the object id from the given packed id. | ||
extern int32_t __xray_unpack_object_id(int32_t PackedId); | ||
|
||
/// Creates and returns a packed id from the given function and object ids. | ||
/// If the ids do not fit within the reserved number of bits for each part, the high bits are truncated. | ||
extern int32_t __xray_pack_id(int32_t FuncId, int32_t ObjId); | ||
|
||
/// Initialize the required XRay data structures. This is useful in cases where | ||
/// users want to control precisely when the XRay instrumentation data | ||
/// structures are initialized, for example when the XRay library is built with | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.