Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
dtrace.vim146 linesDownload Raw Back to syntax
1" DTrace D script syntax file. To avoid confusion with the D programming2" language, I call this script dtrace.vim instead of d.vim.3" Language: D script as described in "Solaris Dynamic Tracing Guide",4"           http://docs.sun.com/app/docs/doc/817-62235" Version: 1.56" Last Change: 2008/04/057" Maintainer: Nicolas Weber <nicolasweber@gmx.de>8 9" dtrace lexer and parser are at10" http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libdtrace/common/dt_lex.l11" http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libdtrace/common/dt_grammar.y12 13" quit when a syntax file was already loaded14if exists("b:current_syntax")15  finish16endif17 18" Read the C syntax to start with19runtime! syntax/c.vim20unlet b:current_syntax21 22syn clear cCommentL  " dtrace doesn't support // style comments23 24" First line may start with #!, also make sure a '-s' flag is somewhere in25" that line.26syn match dtraceComment "\%^#!.*-s.*"27 28" Probe descriptors need explicit matches, so that keywords in probe29" descriptors don't show up as errors. Note that this regex detects probes30" as "something with three ':' in it". This works in practice, but it's not31" really correct. Also add special case code for BEGIN, END and ERROR, since32" they are common.33" Be careful not to detect '/*some:::node*/\n/**/' as probe, as it's34" commented out.35" XXX: This allows a probe description to end with ',', even if it's not36" followed by another probe.37" XXX: This doesn't work if followed by a comment.38let s:oneProbe = '\%(BEGIN\|END\|ERROR\|\S\{-}:\S\{-}:\S\{-}:\S\{-}\)\_s*'39exec 'syn match dtraceProbe "'.s:oneProbe.'\%(,\_s*'.s:oneProbe.'\)*\ze\_s\%({\|\/[^*]\|\%$\)"'40 41" Note: We have to be careful to not make this match /* */ comments.42" Also be careful not to eat `c = a / b; b = a / 2;`. We use the same43" technique as the dtrace lexer: a predicate has to be followed by {, ;, or44" EOF. Also note that dtrace doesn't allow an empty predicate // (we do).45" This regex doesn't allow a divison operator in the predicate.46" Make sure that this matches the empty predicate as well.47" XXX: This doesn't work if followed by a comment.48syn match dtracePredicate "/\*\@!\_[^/]*/\ze\_s*\%({\|;\|\%$\)"49  "contains=ALLBUT,dtraceOption  " this lets the region contain too much stuff50 51" Pragmas.52" dtrace seems not to support whitespace before or after the '='.  dtrace53" supports only one option per #pragma, and no continuations of #pragma over54" several lines with '\'.55" Note that dtrace treats units (Hz etc) as case-insenstive, we allow only56" sane unit capitalization in this script (ie 'ns', 'us', 'ms', 's' have to be57" small, Hertz can be 'Hz' or 'hz')58" XXX: "cpu" is always highlighted as builtin var, not as option59 60"   auto or manual: bufresize61syn match dtraceOption contained "bufresize=\%(auto\|manual\)\s*$"62 63"   scalar: cpu jstackframes jstackstrsize nspec stackframes stackindent ustackframes64syn match dtraceOption contained "\%(cpu\|jstackframes\|jstackstrsize\|nspec\|stackframes\|stackindent\|ustackframes\)=\d\+\s*$"65 66"   size: aggsize bufsize dynvarsize specsize strsize 67"   size defaults to something if no unit is given (ie., having no unit is ok)68syn match dtraceOption contained "\%(aggsize\|bufsize\|dynvarsize\|specsize\|strsize\)=\d\+\%(k\|m\|g\|t\|K\|M\|G\|T\)\=\s*$"69 70"   time: aggrate cleanrate statusrate switchrate71"   time defaults to hz if no unit is given72syn match dtraceOption contained "\%(aggrate\|cleanrate\|statusrate\|switchrate\)=\d\+\%(hz\|Hz\|ns\|us\|ms\|s\)\=\s*$"73 74"   No type: defaultargs destructive flowindent grabanon quiet rawbytes75syn match dtraceOption contained "\%(defaultargs\|destructive\|flowindent\|grabanon\|quiet\|rawbytes\)\s*$"76 77 78" Turn reserved but unspecified keywords into errors79syn keyword dtraceReservedKeyword auto break case continue counter default do80syn keyword dtraceReservedKeyword else for goto if import probe provider81syn keyword dtraceReservedKeyword register restrict return static switch while82 83" Add dtrace-specific stuff84syn keyword dtraceOperator   sizeof offsetof stringof xlate85syn keyword dtraceStatement  self inline xlate this translator86 87" Builtin variables88syn keyword dtraceIdentifier arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 89syn keyword dtraceIdentifier args caller chip cpu curcpu curlwpsinfo curpsinfo90syn keyword dtraceIdentifier curthread cwd epid errno execname gid id ipl lgrp91syn keyword dtraceIdentifier pid ppid probefunc probemod probename probeprov92syn keyword dtraceIdentifier pset root stackdepth tid timestamp uid uregs93syn keyword dtraceIdentifier vtimestamp walltimestamp94syn keyword dtraceIdentifier ustackdepth95 96" Macro Variables97syn match dtraceConstant     "$[0-9]\+"98syn match dtraceConstant     "$\(egid\|euid\|gid\|pgid\|ppid\)"99syn match dtraceConstant     "$\(projid\|sid\|target\|taskid\|uid\)"100 101" Data Recording Actions102syn keyword dtraceFunction   trace tracemem printf printa stack ustack jstack103 104" Process Destructive Actions105syn keyword dtraceFunction   stop raise copyout copyoutstr system106 107" Kernel Destructive Actions108syn keyword dtraceFunction   breakpoint panic chill109 110" Special Actions111syn keyword dtraceFunction   speculate commit discard exit112 113" Subroutines114syn keyword dtraceFunction   alloca basename bcopy cleanpath copyin copyinstr115syn keyword dtraceFunction   copyinto dirname msgdsize msgsize mutex_owned116syn keyword dtraceFunction   mutex_owner mutex_type_adaptive progenyof117syn keyword dtraceFunction   rand rw_iswriter rw_write_held speculation118syn keyword dtraceFunction   strjoin strlen119 120" Aggregating Functions121syn keyword dtraceAggregatingFunction count sum avg min max lquantize quantize122 123syn keyword dtraceType int8_t int16_t int32_t int64_t intptr_t124syn keyword dtraceType uint8_t uint16_t uint32_t uint64_t uintptr_t125syn keyword dtraceType string126syn keyword dtraceType pid_t id_t127 128 129" Define the default highlighting.130" We use `hi def link` directly, this requires 5.8.131hi def link dtraceReservedKeyword Error132hi def link dtracePredicate String133hi def link dtraceProbe dtraceStatement134hi def link dtraceStatement Statement135hi def link dtraceConstant Constant136hi def link dtraceIdentifier Identifier137hi def link dtraceAggregatingFunction dtraceFunction138hi def link dtraceFunction Function139hi def link dtraceType Type140hi def link dtraceOperator Operator141hi def link dtraceComment Comment142hi def link dtraceNumber Number143hi def link dtraceOption Identifier144 145let b:current_syntax = "dtrace"146 
codekingpro/portable-devtools · Team Ai