Bug #62005 add support for userland dtrace on FreeBSD
Submitted: 27 Jul 2011 12:33 Modified: 27 Feb 9:26
Reporter: Alex Samorukov Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:MySQL Community Server 5.5.14 OS:FreeBSD
Assigned to: CPU Architecture:Any
Tags: DTrace, freebsd
Triage: Needs Triage: D5 (Feature request)

[27 Jul 2011 12:33] Alex Samorukov
Description:
FreeBSD recently added support for the userland dtrace applications. This patch adds support for it. Also it contain workaround for bug found in dtrace/freebsd, where second invocation of dtrace -G on the already modified object producing broken output. 

How to repeat:
build on FreeBSD with ENABLE_DTRACE option. Build will fail.

Suggested fix:
Apply fix in the attach
[27 Jul 2011 12:35] Alex Samorukov
dtrace.cmake patch for the FreeBSD

Attachment: dtrace.cmake.patch (text/x-patch), 2.54 KiB.

[27 Jul 2011 12:35] Alex Samorukov
dtrace_prelink.cmake.patch for the FreeBSD

Attachment: dtrace_prelink.cmake.patch (text/x-patch), 1.26 KiB.

[27 Jul 2011 12:49] Valeriy Kravchuk
Thank you for the feature request and code contributed.
[27 Jul 2011 23:01] Vladislav Vaintroub
Alex, did you try that on FreeBSD8.0? Just curious, because when I wrote dtrace.cmake initially it I only had FreeBSD 8.0 to try,  and attempt to use dtrace utility on that OS failed, because there was no usermode trace support at that time. 

If I have not done anything wrong back then, this would mean that this patch would not work on 8.0 either and needs some CMAKE_SYSTEM_VERSION massaging to work correctly.
[28 Jul 2011 3:11] Alex Samorukov
> did you try that on FreeBSD8.0

No, i did not, But i believe that in FreeBSD 8.0 there where no userland dtrace support at all, it was added recently. And ENABLE_DTRACE is an optional and not default setting so i do not see anything bad if someone will try it on FreeBSD 8.0 and it will fail - its just not supported. Also build with DTRACE will fail if system DTRACE support was not configured in the build time - because "dtrace -G -s .."depends on it.
[28 Jul 2011 3:56] Vladislav Vaintroub
your patch has a hunk (below), that enables dtrace by default on FreeBSDs. That explicitely disables on in the past (because it did nto work, even if utility named dtrace existet in FreeBSD8.x and was found by FIND_PROGRAM).

Saying that ENABLE_DTRACE is not default, would not be, strictly speaking, incorrect, because you made it default ;)

- # On FreeBSD, dtrace does not handle userland tracing yet
- IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
-     AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
+ IF(DTRACE AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
    SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
  ENDIF()
[28 Jul 2011 6:15] Alex Samorukov
Thank you for this comment, i think i misunderstand this code. From my personal view DTrace should not be enabled by default on a FreeBSD because it is still experimental feature. I will update the patch. Also i can add FreeBSD specific test to check that dtrace compiler is really working, because if dtrace support is not compiled into the kernel it will fail.
[27 Feb 9:26] Jon Olav Hauglid
As of 8.0.1, support for DTrace probes has been removed from MySQL.