Page MenuHomePhabricator

[sanitizer_common] Enable external tool to register PrintfAndReportCallback
Needs ReviewPublic

Authored by protze.joachim on Dec 2 2015, 8:19 AM.

Details

Reviewers
kcc
Summary

This patch enables an external tool to register PrintfAndReportCallback.
The function needs to end up in the dynamic symbol table, so that a dynamic library can call the function.

Diff Detail

Event Timeline

protze.joachim retitled this revision from to [sanitizer_common] Suspend output to stdout/file if callback is set.
protze.joachim updated this object.
protze.joachim added a reviewer: kcc.
kcc edited edge metadata.Dec 2 2015, 11:35 AM

The logic is too complex.
If you want to disable colors, just disable them with a separate flag.
If you want to disable logging to a file, just use log_file=/dev/null

protze.joachim edited edge metadata.

I cannot find a log_file option, only a log_path option. And this option is not compatible with /dev/null, since it adds ".$PID" to the path prefix.

I reduced the patch to just suppress the output to file for a registered output callback.

With some compiler versions, SetPrintfAndReportCallback gets the .hidden flag. I need to access the symbol from a 3rd party library.
So I added SANITIZER_INTERFACE_ATTRIBUTE to have the symbol visible.

@kcc I would still be interested in this change :)

kcc edited edge metadata.Nov 27 2017, 4:55 PM
  • I see two independent changes here. If so, please split them into two patches
  • most changes need tests.
  • Maybe instead of doing this, introduce some logic to treat log_path=/dev/null as a special supported case?
protze.joachim retitled this revision from [sanitizer_common] Suspend output to stdout/file if callback is set to [sanitizer_common] Enable external tool to register PrintfAndReportCallback.
protze.joachim edited the summary of this revision. (Show Details)

I updated this differential to only export the function.

To make the function available with all sanitizers, I created a new extra file that is included for all sanitizers.