pax_global_header00006660000000000000000000000064152672163160014523gustar00rootroot0000000000000052 comment=24e9fe60faffcbed50b44428067fcd9b03770584 bpftrace-0.27.1/000077500000000000000000000000001526721631600134005ustar00rootroot00000000000000bpftrace-0.27.1/.clang-format000066400000000000000000000053021526721631600157530ustar00rootroot00000000000000--- Language: Cpp # BasedOnStyle: LLVM AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Right AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: false BinPackParameters: false BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom BraceWrapping: AfterFunction: true BreakAfterAttributes: Leave BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true BreakConstructorInitializers: BeforeColon BreakStringLiterals: true ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false DerivePointerAlignment: true DisableFormat: false ForEachMacros: ['bpf_map__for_each', 'bpf_object__for_each_program'] FixNamespaceComments: true IncludeBlocks: Preserve IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|gmock|isl|json)/)' Priority: 3 - Regex: '.*' Priority: 1 IncludeIsMainRegex: '(Test)?$' IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 2 IndentWrappedFunctionNames: false InsertNewlineAtEOF: true KeepEmptyLinesAtTheStartOfBlocks: false MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None # Note: These penalties are not only relative to each other, but also to # penalties for more cases hardcoded into clang-format PenaltyBreakAssignment: 100 PenaltyBreakBeforeFirstCallParameter: 75 PenaltyBreakComment: 1 PenaltyBreakFirstLessLess: 50 PenaltyBreakString: 500 PenaltyExcessCharacter: 1000 PenaltyReturnTypeOnItsOwnLine: 1000000 PointerAlignment: Right ReflowComments: true SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 TabWidth: 8 UseTab: Never --- Language: Json DisableFormat: true --- Language: ObjC DisableFormat: true ... bpftrace-0.27.1/.clang-format-ignore000066400000000000000000000000771526721631600172400ustar00rootroot00000000000000tests/data/data_source.c tests/testprogs/*.c src/stdlib/**/*.c bpftrace-0.27.1/.clang-tidy000066400000000000000000000032241526721631600154350ustar00rootroot00000000000000Checks: - -* - bugprone-suspicious-memset-usage - bugprone-unchecked-optional-access - bugprone-undefined-memory-manipulation - bugprone-unused-raii - bugprone-use-after-move - google-readability-casting - misc-misleading-identifier - misc-misplaced-const - misc-non-copyable-objects - misc-throw-by-value-catch-by-reference - misc-redundant-expression - misc-unconventional-assign-operator - misc-static-assert - modernize-* - -modernize-avoid-c-arrays - -modernize-use-nodiscard - -modernize-use-integer-sign-comparison - -modernize-use-trailing-return-type - performance-unnecessary-copy-initialization - readability-* - -readability-avoid-nested-conditional-operator - -readability-braces-around-statements - -readability-convert-member-functions-to-static - -readability-else-after-return - -readability-enum-initial-value - -readability-function-cognitive-complexity - -readability-function-size - -readability-identifier-length - -readability-implicit-bool-conversion - -readability-isolate-declaration - -readability-magic-numbers - -readability-make-member-function-const - -readability-redundant-lambda-parameter-list - -readability-redundant-nested-if - -readability-suspicious-call-argument - -readability-trailing-comma CheckOptions: # gcc and llvm did not introduce when supporting C++20, so using # std::format is temporarily not allowed. # see issue https://github.com/bpftrace/bpftrace/issues/4185 modernize-use-std-format.ReplacementFormat: "DISALLOW" WarningsAsErrors: "*" UseColor: true HeaderFilterRegex: ".*" ExcludeHeaderFilterRegex: ".*/(parser\\.tab|location)\\.hh" bpftrace-0.27.1/.devcontainer/000077500000000000000000000000001526721631600161375ustar00rootroot00000000000000bpftrace-0.27.1/.devcontainer/Dockerfile000066400000000000000000000007671526721631600201430ustar00rootroot00000000000000FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye # Required nix install dependencies. RUN apt-get update && apt-get install -y curl bzip2 adduser direnv vim RUN su - vscode -c 'sh <(curl -L https://releases.nixos.org/nix/nix-2.26.3/install) --no-daemon' RUN su - vscode -c 'mkdir -p ~/.config/nix && echo "extra-experimental-features = nix-command flakes" > ~/.config/nix/nix.conf' RUN su - vscode -c 'nix-env -iA nixpkgs.direnv' RUN su - vscode -c 'direnv hook bash >> ~/.bashrc' USER vscode bpftrace-0.27.1/.devcontainer/devcontainer.json000066400000000000000000000004431526721631600215140ustar00rootroot00000000000000{ "build": { "dockerfile": "Dockerfile" }, "customizations": { "vscode": { "extensions": [ "mkhl.direnv", "llvm-vs-code-extensions.vscode-clangd", "ms-vscode.cmake-tools" ] } }, "postStartCommand": "nix develop -c true && direnv allow" } bpftrace-0.27.1/.editorconfig000066400000000000000000000003231526721631600160530ustar00rootroot00000000000000[*] end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 indent_style = space indent_size = 2 [*.py] indent_size = 4 [tools/*.bt] indent_style = tab indent_size = unset bpftrace-0.27.1/.envrc000066400000000000000000000000121526721631600145070ustar00rootroot00000000000000use flake bpftrace-0.27.1/.git-blame-ignore-revs000066400000000000000000000001221526721631600174730ustar00rootroot00000000000000# Move opening brace to starting context 453198bdabdaffdc1cb600038af60644e1326656 bpftrace-0.27.1/.gitattributes000066400000000000000000000001171526721631600162720ustar00rootroot00000000000000*.bt linguist-language=D *.bt linguist-vendored *.ll linguist-detectable=false bpftrace-0.27.1/.github/000077500000000000000000000000001526721631600147405ustar00rootroot00000000000000bpftrace-0.27.1/.github/CODEOWNERS000066400000000000000000000001651526721631600163350ustar00rootroot00000000000000# Request reviews automatically to speed up the PR workflow * @ajor @viktormalik @danobi @fbs @jordalgo @amscanne bpftrace-0.27.1/.github/FUNDING.yml000066400000000000000000000000321526721631600165500ustar00rootroot00000000000000open_collective: bpftrace bpftrace-0.27.1/.github/ISSUE_TEMPLATE/000077500000000000000000000000001526721631600171235ustar00rootroot00000000000000bpftrace-0.27.1/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000005271526721631600216210ustar00rootroot00000000000000--- name: Bug report about: Create a report to help us improve labels: bug --- ### What reproduces the bug? Provide code if possible. ### `bpftrace --info` output bpftrace-0.27.1/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000002601526721631600211110ustar00rootroot00000000000000blank_issues_enabled: true contact_links: - name: Community Support url: https://github.com/bpftrace/bpftrace/discussions about: Please ask and answer questions here bpftrace-0.27.1/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000004111526721631600226440ustar00rootroot00000000000000--- name: Feature request about: Suggest an idea for this project labels: enhancement --- ### Is your feature request related to a problem? Please describe. ### Describe the solution you'd like ### Describe alternative solutions or features you've considered bpftrace-0.27.1/.github/ISSUE_TEMPLATE/release.md000066400000000000000000000042561526721631600210740ustar00rootroot00000000000000--- name: Release tracker about: Create a tracker issue for the upcoming release. Should be used by maintainers only. --- ### Release progress - [ ] Mark the release in [CHANGELOG.md](https://github.com/bpftrace/bpftrace/blob/master/CHANGELOG.md) and create an "Unreleased" section - [ ] Set `bpftrace_VERSION_MINOR` to `` in [CMakeLists.txt](https://github.com/bpftrace/bpftrace/blob/master/CMakeLists.txt) - [ ] Add `v0.-rc0` tag to master - [ ] Create release branch `release/0..x` () - [ ] Add support for LLVM - [ ] Bump `MAX_LLVM_MAJOR` in [CMakeLists.txt](https://github.com/bpftrace/bpftrace/blob/master/CMakeLists.txt) - [ ] Add new Nix target in [flake.nix](https://github.com/bpftrace/bpftrace/blob/master/flake.nix) - [ ] Add CI job to [.github/workflows/ci.yml](https://github.com/bpftrace/bpftrace/blob/master/.github/workflows/ci.yml) - [ ] Drop support for LLVM - [ ] Update LLVM in Nixpkgs to .1.0 - [ ] **Release bpftrace 0..0 ()** - [ ] Add the current date to [CHANGELOG.md](https://github.com/bpftrace/bpftrace/blob/master/CHANGELOG.md) - [ ] Draft a new release in GitHub - [ ] Update the docs on the bpftrace website. [Instructions](https://github.com/bpftrace/website?#updating-the-docs). - [ ] Add a new tools version link on the [tools readme](https://github.com/bpftrace/bpftrace/blob/master/tools/README.md) to the master branch. - [ ] Forward-port [CHANGELOG.md](https://github.com/bpftrace/bpftrace/blob/master/CHANGELOG.md) changes to the master branch. See [Release Process](https://github.com/bpftrace/bpftrace/blob/master/docs/release_process.md) for general information on the release process. bpftrace-0.27.1/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000011161526721631600205400ustar00rootroot00000000000000 ##### Checklist - [ ] Language changes are updated in `docs/language.md`, `docs/stdlib.md`, or `man/adoc/bpftrace.adoc` - [ ] User-visible and non-trivial changes updated in `CHANGELOG.md` - [ ] The new behaviour is covered by tests bpftrace-0.27.1/.github/actions/000077500000000000000000000000001526721631600164005ustar00rootroot00000000000000bpftrace-0.27.1/.github/actions/configure_kvm/000077500000000000000000000000001526721631600212365ustar00rootroot00000000000000bpftrace-0.27.1/.github/actions/configure_kvm/action.yml000066400000000000000000000012431526721631600232360ustar00rootroot00000000000000name: Configure KVM Permissions description: Configure KVM permissions if KVM is available on host runs: using: "composite" steps: - name: Configure KVM group perms run: | # Only configure kvm perms if kvm is available if [[ -e /dev/kvm ]]; then echo "Updating KVM permissions" echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm else echo "KVM is not available on this system, skipping permission configuration" fi shell: bash bpftrace-0.27.1/.github/codeql/000077500000000000000000000000001526721631600162075ustar00rootroot00000000000000bpftrace-0.27.1/.github/codeql/codeql-config.yml000066400000000000000000000001001526721631600214330ustar00rootroot00000000000000paths-ignore: - tests/runtime/engine/cmake_vars.py - libbpf bpftrace-0.27.1/.github/include/000077500000000000000000000000001526721631600163635ustar00rootroot00000000000000bpftrace-0.27.1/.github/include/aot_allow.txt000066400000000000000000000143141526721631600211100ustar00rootroot00000000000000aot.basic.basic while loop aot.basic.clear count-map aot.basic.clear map aot.basic.exit code aot.basic.has_key exists aot.basic.has_key map keys and values aot.basic.has_key map value as key aot.basic.has_key no_exists aot.basic.increment/decrement map aot.basic.increment/decrement variable aot.basic.map strings are memset aot.basic.print large int aot.basic.variable strings are memset aot.btf.enum_value_reference aot.btf.kernel_module_tracepoint aot.btf.redefine_btf_type_missing_def aot.btf.tracepoint_nested_pointer_type_resolution aot.btf.tracepoint_pointer_type_resolution aot.btf.user_supplied_c_def_using_btf aot.builtin.arg aot.builtin.begin probe aot.builtin.cat aot.builtin.cat "no such file" aot.builtin.cat format str aot.builtin.cgroup aot.builtin.cpu aot.builtin.elapsed aot.builtin.func_kprobe aot.builtin.func_kretprobe aot.builtin.func_uprobe aot.builtin.func_uretprobe aot.builtin.gid aot.builtin.jiffies aot.builtin.kstack aot.builtin.nsecs aot.builtin.numaid aot.builtin.offsetof aot.builtin.pid aot.builtin.probe aot.builtin.rand aot.builtin.retval aot.builtin.sizeof_btf aot.builtin.sizeof_ints aot.builtin.sizeof_ints_pt2 aot.builtin.tid aot.builtin.uid aot.builtin.username aot.builtin.ustack aot.call.avg aot.call.buf_hist_map_key aot.call.buf_map_key aot.call.buf_map_value aot.call.buf_no_ascii aot.call.buf_no_ascii_no_escaping aot.call.cat aot.call.cat_more_args aot.call.clear on scalar map prevents printing aot.call.count aot.call.fmt_str_args_scratch_buf aot.call.hist aot.call.hist_2_values aot.call.hist_map_key_scratch_buf aot.call.hist_scalar_map_key_scratch_buf aot.call.kstack aot.call.kstack len aot.call.kstack perf mode aot.call.ksym aot.call.lhist aot.call.lhist_map_key_scratch_buf aot.call.lhist_scalar_map_key_scratch_buf aot.call.map len aot.call.map len keyless aot.call.map lencmp aot.call.map_val_scratch_buf aot.call.max aot.call.min aot.call.nsecs aot.call.nsecs_boot aot.call.nsecs_monotonic aot.call.nsecs_sw_tai aot.call.ntop static ip aot.call.percpu_kaddr aot.call.percpu_kaddr this cpu aot.call.print_avg_map_args aot.call.print_avg_map_with_large_top aot.call.print_hist_with_large_top_arg aot.call.print_hist_with_top_arg aot.call.print_map_item aot.call.print_non_map aot.call.printf aot.call.printf_argument aot.call.printf_char aot.call.printf_length_modifiers aot.call.printf_llu aot.call.printf_long_fmt aot.call.printf_more_arguments aot.call.pton ipv4 aot.call.pton ipv6 aot.call.scalar_map_scratch_buf aot.call.stats aot.call.str aot.call.str_big aot.call.str_big_print aot.call.str_big_read aot.call.str_big_strncmp aot.call.str_scratch_buf aot.call.sum aot.call.time aot.call.time_short aot.call.ustack aot.call.ustack len aot.call.ustack_stack_mode_env_bpftrace aot.call.ustack_stack_mode_env_override aot.call.ustack_stack_mode_env_perf aot.call.ustack_stack_mode_env_raw aot.call.usym aot.call.variable_probe_subprog_scratch_buf aot.call.variable_scratch_buf aot.for.map create map in body aot.for.map nested count aot.for.map one key elements aot.for.map stack key with a per cpu aggregation aot.for.variable context read only aot.for.variable context string aot.for.variable context update aot.other.avg can be cleared aot.other.exit exits immediately aot.other.hist can be cleared aot.other.if_gt aot.other.if_lt aot.other.ifelse_go_else aot.other.ifelse_go_if aot.other.ifelseif_go_elseif aot.other.ifelseifelse_go_else aot.other.lhist can be cleared aot.other.per_cpu_map_count_if aot.other.per_cpu_map_max_if aot.other.per_cpu_map_min_if aot.other.stats can be cleared aot.other.ternary aot.other.ternary_lnot aot.other.ternary_none_type aot.other.unroll aot.other.unroll_max_value aot.other.unroll_min_value aot.other.unroll_printf aot.precedence.operator_precedence_1 aot.precedence.operator_precedence_2 aot.precedence.operator_precedence_3 aot.precedence.operator_precedence_3 aot.probe.BEGIN aot.probe.BEGIN,END aot.probe.END_processing_after_exit aot.probe.bpf_programs_limit aot.probe.interval aot.probe.interval_probe_builtin aot.probe.interval_short_name aot.probe.kprobe aot.probe.kprobe_disallow_rcu_functions aot.probe.kprobe_func_missing aot.probe.kprobe_module aot.probe.kprobe_module_missing aot.probe.kprobe_module_wildcard aot.probe.kprobe_offset aot.probe.kprobe_short_name aot.probe.kprobe_warn_missing_probes aot.probe.kprobe_wildcard aot.probe.kretprobe aot.probe.kretprobe_short_name aot.probe.kretprobe_wildcard aot.probe.probe_builtin_scratch_buf aot.probe.profile aot.probe.profile_probe_builtin aot.probe.profile_short_name aot.probe.sanitise probe name aot.probe.software aot.probe.software_alias_probe_builtin aot.probe.software_probe_builtin aot.probe.tracepoint aot.probe.tracepoint args aot.probe.tracepoint args as pointer aot.probe.tracepoint_data_loc aot.probe.tracepoint_missing aot.probe.tracepoint_multiattach_missing aot.probe.tracepoint_short_name aot.probe.uprobe aot.probe.uprobe_address_fail_resolve aot.probe.uprobe_offset aot.probe.uprobe_offset aot.probe.uprobe_offset_fail_size aot.probe.uprobe_zero_size aot.probe.uretprobe aot.regression.access ctx struct field twice aot.regression.async_id_invalid_probe_expansion aot.regression.modulo_operator aot.regression.string compare with empty aot.regression.string compare with prefix aot.regression.strncmp with prefix aot.regression.strncmp_checks_for_nul aot.regression.strncmp_n_longer_than_buffer aot.regression.unaligned key with aligned value aot.signed_ints.avg cast negative values aot.signed_ints.avg with negative values aot.signed_ints.negative map value aot.signed_ints.stats with negative values aot.signed_ints.sum negative maps aot.signed_ints.sum with negative value aot.stdlib.delete count-map aot.stdlib.delete deprecated aot.stdlib.delete map aot.tuples.basic tuple aot.uprobe.uprobes - probe function in non-executable library aot.variable.32-bit tracepoint arg aot.variable.buf_equality aot.variable.global_associative_arrays aot.variable.global_buf aot.variable.global_int aot.variable.global_string aot.variable.local_buf aot.variable.local_int aot.variable.local_string aot.variable.map key string type resize aot.variable.map string type resize aot.variable.scratch aot.variable.variable declaration aot.variable.variable declaration not initialized aot.variable.variable declaration with unresolved type aot.variable.variable string type resize bpftrace-0.27.1/.github/include/ci.py000077500000000000000000000316341526721631600173420ustar00rootroot00000000000000#!/usr/bin/env -S python3 -u """ This script is the entrypoint for the CI. To make CI errors easier to reproduce locally, please limit this script to using only the standard library on a recent-ish python 3 release. Please also be conservative with what tools you expect on the host system when subprocessing out. Safe things to expect are `git` and `nix`. Note that when running subprocessing _inside_ the nix env you are free to use whatever the flake provides. """ from collections import namedtuple from enum import Enum from functools import lru_cache from io import StringIO import multiprocessing import os from pathlib import Path import shutil import subprocess import sys from typing import Callable, Dict, List, Optional, Union BUILD_DIR = "build-ci" # # Knobs CI might use. We choose to use env vars b/c it's less # messy than propagating flags everywhere. # # Default nix target is empty string which by convention is the # latest LLVM release we support NIX_TARGET = os.environ.get("NIX_TARGET", "") CMAKE_BUILD_TYPE = os.environ.get("CMAKE_BUILD_TYPE", "Release") RUN_TESTS = os.environ.get("RUN_TESTS", "1") RUN_AOT_TESTS = os.environ.get("RUN_AOT_TESTS", "0") CC = os.environ.get("CC", "cc") CXX = os.environ.get("CXX", "c++") CI = os.environ.get("CI", "false") NIX_TARGET_KERNEL = os.environ.get("NIX_TARGET_KERNEL", "") TOOLS_TEST_OLDVERSION = os.environ.get("TOOLS_TEST_OLDVERSION", "") TOOLS_TEST_DISABLE = os.environ.get("TOOLS_TEST_DISABLE", "") AOT_ALLOWLIST_FILE = os.environ.get("AOT_ALLOWLIST_FILE", "") RUNTIME_TESTS_FILTER = os.environ.get("RUNTIME_TESTS_FILTER", "") BUILD_ASAN = os.environ.get("BUILD_ASAN", "0") BUILD_UBSAN = os.environ.get("BUILD_UBSAN", "0") class TestStatus(Enum): PASSED = "passed" FAILED = "failed" SKIPPED = "skipped" TestResult = namedtuple("TestResult", ["test_name", "status"]) def truthy(value: str) -> bool: v = value.strip().lower() return v == "true" or v == "1" @lru_cache(maxsize=1) def root() -> Path: """Return the absolute path root of git repo""" output = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]) return Path(output.decode("utf-8").strip()) def _which(cmd: str) -> Path: p = shutil.which(cmd) if not p: raise RuntimeError(f"Failed to find binary: {cmd}") return Path(p) @lru_cache(maxsize=1) def nix() -> Path: """Return the absolute path of nix binary in host env""" return _which("nix") @lru_cache(maxsize=1) def sudo() -> Path: """Return the absolute path of sudo binary in host env""" return _which("sudo") class FoldOutput: """ GitHub Actions output folding context manager. Will automatically fold output for all operations. In an ideal world we'd like to leave the failed operations unfolded, but there's currently no way to do this in GHA without buffering output. """ def __init__(self, name: str): self.name = name self.in_ci = truthy(CI) def __enter__(self) -> "FoldOutput": if self.in_ci: # Start a collapsible section in GitHub Actions logs print(f"::group::{self.name}") else: print(f"\n======= {self.name} ======") return self def __exit__(self, exc_type, exc_val, exc_tb): if self.in_ci: print("::endgroup::") def shell( cmd: List[str], as_root: bool = False, cwd: Optional[Path] = None, env: Optional[Dict[str, str]] = None, ): """ Runs the specified command in the proper nix development environment. Note that output is sent to our inherited stderr/stdout and that any errors immediately raise an exception. """ c: List[Union[str, Path]] = [ nix(), "develop", ] if NIX_TARGET: c.append(NIX_TARGET) if not env: env = {} # Nix needs to know the home dir if "HOME" in os.environ: env["HOME"] = os.environ["HOME"] c.append("--command") if as_root: c += [ sudo(), # We need to preserve path so that default root PATH is not # generated. If that occurs, then commands run in nix env # can escape and use host system binaries. This creates some # very hard to debug errors in CI. # # And yes, I realize that we should probably be using nix's # sandboxing via checkPhase, but unfortunately that does not # play nice with root or writing temporary files. So that # requires further investigation. "--preserve-env=PATH", "--preserve-env=PYTHONPATH", "--preserve-env=" + ",".join([n for n in env]), ] c += cmd subprocess.run( c, cwd=cwd if cwd else root(), check=True, # Explicitly clear the environment so that any commands run # inside the nix environment cannot accidentally depend on # host environment. There are known very-hard-to-debug issues # that occur in CI when the envirionment escapes. env=env, ) def configure(): """Run cmake configure step""" with FoldOutput("configure"): # fmt: off c = [ "cmake", "-B", BUILD_DIR, # Dynamic configs f"-DCMAKE_C_COMPILER={CC}", f"-DCMAKE_CXX_COMPILER={CXX}", f"-DCMAKE_BUILD_TYPE={CMAKE_BUILD_TYPE}", f"-DBUILD_ASAN={BUILD_ASAN}", f"-DBUILD_UBSAN={BUILD_UBSAN}", # Static configs f"-DCMAKE_VERBOSE_MAKEFILE=1", f"-DBUILD_TESTING=1", f"-DENABLE_SKB_OUTPUT=1", f"-DHARDENED_STDLIB=1", ] # fmt: on shell(c) def build(): """Build everything""" with FoldOutput("build"): cpus = multiprocessing.cpu_count() shell(["make", "-C", BUILD_DIR, "-j", str(cpus)], env={"AFL_USE_ASAN": "1"}) def test_one(name: str, cond: Callable[[], bool], fn: Callable[[], None]) -> TestResult: """Runs a single test suite and returns the result""" status = TestStatus.PASSED if cond(): try: with FoldOutput(name): fn() except subprocess.CalledProcessError: status = TestStatus.FAILED else: status = TestStatus.SKIPPED return TestResult(test_name=name, status=status) def tests_finish(results: List[TestResult]): """Process test results and output status""" skipped = sum(1 for r in results if r.status == TestStatus.SKIPPED) passed = sum(1 for r in results if r.status == TestStatus.PASSED) failed = sum(1 for r in results if r.status == TestStatus.FAILED) failed_names = [r.test_name for r in results if r.status == TestStatus.FAILED] total_run = passed + failed output = StringIO() print("\n======= Results =======", file=output) if skipped: print(f"{skipped} suite(s) skipped", file=output) if failed: print(f"{failed}/{total_run} suites(s) failed: {failed_names}", file=output) else: print(f"{passed}/{total_run} suites(s) passed", file=output) print("=======================", file=output) if failed: raise RuntimeError(output.getvalue()) else: print(output.getvalue()) def run_with_kernel(script): if NIX_TARGET_KERNEL: # Bring kernel into nix store then grab the path subprocess.run([nix(), "build", NIX_TARGET_KERNEL], check=True) eval = subprocess.run( [nix(), "eval", "--raw", NIX_TARGET_KERNEL], check=True, capture_output=True, text=True, ) # nf_tables and xfs are necessary for testing kernel modules BTF support modules = ["kvm", "nf_tables", "xfs"] modprobe = f"modprobe -d {eval.stdout} -a {' '.join(modules)}" c = f"{modprobe} && {' '.join(script)}" cmd = ["vmtest", "-k", f"{eval.stdout}/bzImage", c] else: cmd = script shell( cmd, # Don't need root if running tests in a VM as_root=not NIX_TARGET_KERNEL, cwd=Path(BUILD_DIR), env={ "CI": CI, "RUNTIME_TEST_COLOR": "yes", # Disable UI to make CI and manual runs behave identically "VMTEST_NO_UI": "1", }, ) def run_self_tests(): """Runs self tests, under a controlled kernel if requested""" run_with_kernel(["./tests/self-tests.sh"]) def run_runtime_tests(): """Runs runtime tests, under a controlled kernel if requested""" cmd = ["./tests/runtime-tests.sh"] if RUNTIME_TESTS_FILTER: if NIX_TARGET_KERNEL: cmd.append(f"--filter='{RUNTIME_TESTS_FILTER}'") else: cmd.append(f"--filter={RUNTIME_TESTS_FILTER}") run_with_kernel(cmd) def fuzz(): """ Run a basic fuzz smoke test. """ # Make basic inputs and output directories. Path(BUILD_DIR, "inputs").mkdir(exist_ok=True) Path(BUILD_DIR, "outputs").mkdir(exist_ok=True) # For now, seed the inputs directly with a trivial program. These can be # codified differently in the future, but this is sufficient for a basic # fuzz smoke test. Actual fuzzing should have a wide variety of inputs. Path(BUILD_DIR, "inputs", "seed.bt").write_text("BEGIN {}") results = [ test_one( "fuzz", lambda: truthy(RUN_TESTS), lambda: shell( # fmt: off cmd = [ "afl-fuzz", "-M", "0", "-m", "none", "-i", "inputs", "-o", "outputs", "-E", "10", # 10 execs, smoke test only. "-t", "60000", "--", "src/bpftrace", "--test=codegen", "@@", ], env = { "AFL_NO_AFFINITY": "1", "ASAN_OPTIONS": "abort_on_error=1,symbolize=0", "BPFTRACE_BTF": "", "BPFTRACE_AVAILABLE_FUNCTIONS_TEST": "", # This setting [1] is used to skip the core pattern check, # so crashes may be missed. Since this is just a smoke # test, we use this rather than change the system state. # [1] https://github.com/mirrorer/afl/blob/master/docs/env_variables.txt "AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES": "", }, cwd=Path(BUILD_DIR), # fmt: on ), ), ] tests_finish(results) def test(): """ Run all requested tests Note we're not using `ctest` b/c it's kinda a pain to work with. We don't use any of it's advanced features but still suffer from it's limitations, like not being able to flexibly configure test runners (we need `sudo` for some suites). It also buffers output rather oddly. """ results = [] results.append( test_one( "bpftrace_test", lambda: truthy(RUN_TESTS), lambda: shell( ["gtest-parallel", "./tests/bpftrace_test"], cwd=Path(BUILD_DIR), env={"GTEST_COLOR": "yes"}, ), ) ) results.append( test_one( "self-tests.sh", lambda: truthy(RUN_TESTS), run_self_tests, ) ) results.append( test_one( "runtime-tests.sh", lambda: truthy(RUN_TESTS), run_runtime_tests, ) ) results.append( test_one( "tools-parsing-test.sh", lambda: truthy(RUN_TESTS), lambda: shell( [ "./tests/tools-parsing-test.sh", ], as_root=True, cwd=Path(BUILD_DIR), env={ "TOOLS_TEST_OLDVERSION": TOOLS_TEST_OLDVERSION, "TOOLS_TEST_DISABLE": TOOLS_TEST_DISABLE, }, ), ) ) results.append( test_one( "runtime-tests.sh (AOT)", lambda: truthy(RUN_AOT_TESTS), lambda: shell( ( [ "./tests/runtime-tests.sh", "--run-aot-tests", "--filter", "aot.*", ] + [ "--allowlist_file", f"{root()}/{AOT_ALLOWLIST_FILE}", ] if AOT_ALLOWLIST_FILE else [] ), as_root=True, cwd=Path(BUILD_DIR), env={ "CI": CI, "RUNTIME_TEST_COLOR": "yes", }, ), ) ) tests_finish(results) def main(): configure() build() if CC.startswith("afl-"): fuzz() else: test() if __name__ == "__main__": main() bpftrace-0.27.1/.github/include/static.sh000077500000000000000000000017131526721631600202130ustar00rootroot00000000000000#!/bin/bash # # This script is the entrypoint for the static build. # # To make CI errors easier to reproduce locally, please limit # this script to using only git, docker, and coreutils. set -eux IMAGE=bpftrace-static cd "$(git rev-parse --show-toplevel)" # Build the base image docker build -t "$IMAGE" -f docker/Dockerfile.static docker/ # Perform bpftrace static build docker run -v "$(pwd):$(pwd)" -w "$(pwd)" -i "$IMAGE" <<'EOF' set -eux BUILD_DIR=build-static cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTING=OFF -DSTATIC_LINKING=ON make -C "$BUILD_DIR" -j$(nproc) # Basic smoke test ./"$BUILD_DIR"/src/bpftrace --help # Validate that it's a mostly static binary except for libc EXPECTED="/lib/ld-musl-x86_64.so.1\nlibc.musl-x86_64.so.1" GOT=$(ldd "$BUILD_DIR"/src/bpftrace | awk '{print $1}') if ! diff <(echo -e "$EXPECTED") <(echo "$GOT"); then set +x >&2 echo "bpftrace incorrectly linked" exit 1 fi EOF bpftrace-0.27.1/.github/workflows/000077500000000000000000000000001526721631600167755ustar00rootroot00000000000000bpftrace-0.27.1/.github/workflows/binary.yml000066400000000000000000000023001526721631600207770ustar00rootroot00000000000000# This workflow builds and uploads the bpftrace appimage as a build artifact. # # This is useful for users who want to download the latest and greatest bpftrace # binary without going through a local build. name: Binary on: push: branches: - master - 'release/**' pull_request: workflow_dispatch: jobs: build-and-upload: name: ${{ (github.event_name == 'pull_request' && 'build' || 'build-and-upload') }} (${{ matrix.runner }}) strategy: matrix: runner: [ubuntu-latest, ubuntu-24.04-arm] runs-on: ${{ matrix.runner }} # For flakehub cache permissions: id-token: write contents: read steps: - uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: Build appimage run: | nix build .?submodules=1#appimage cp ./result bpftrace - name: Upload appimage if: github.event_name != 'pull_request' uses: actions/upload-artifact@v4 with: name: bpftrace-${{ runner.arch }} path: ./bpftrace bpftrace-0.27.1/.github/workflows/bpftrace-tidy.yml000066400000000000000000000013331526721631600222550ustar00rootroot00000000000000name: "Bpftrace Tidy" on: [ pull_request ] # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read pull-requests: write # For flakehub cache id-token: write steps: - uses: actions/checkout@v3 with: submodules: true - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: Run bpftrace-tidy run: ./scripts/bpftrace_tidy.sh bpftrace-0.27.1/.github/workflows/ci.yml000066400000000000000000000076551526721631600201300ustar00rootroot00000000000000name: CI on: push: branches: [ master, release/* ] pull_request: paths-ignore: - "man/**" - "docs/**" - "**/*.md" # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: clang-format: runs-on: ubuntu-latest # For flakehub cache permissions: id-token: write contents: read steps: - uses: actions/checkout@v2 with: fetch-depth: 0 submodules: true - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: clang-format run: nix develop --command git clang-format --diff origin/master --extensions cpp,h build_test: # TODO: back to ubuntu-latest once actions/runner-images#15003 is fixed runs-on: ${{ matrix.env.RUNS_ON || 'ubuntu-22.04' }} # For flakehub cache permissions: id-token: write contents: read continue-on-error: true strategy: matrix: env: - NAME: LLVM 19 CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm19 TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 20 CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm20 TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 21 CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm21 TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 22 CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm22 TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 23 Release CMAKE_BUILD_TYPE: Release NIX_TARGET: .#bpftrace-llvm23 TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 23 Release (arm64) CMAKE_BUILD_TYPE: Release NIX_TARGET: .#bpftrace-llvm23 TOOLS_TEST_DISABLE: runqlen.bt RUNS_ON: ubuntu-22.04-arm - NAME: LLVM 23 Debug CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm23 TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 23 Clang Debug CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm23 CC: clang CXX: clang++ TOOLS_TEST_DISABLE: runqlen.bt - NAME: LLVM 23 + sanitizers CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm23 BUILD_ASAN: 1 BUILD_UBSAN: 1 TOOLS_TEST_DISABLE: runqlen.bt RUNTIME_TESTS_FILTER: "-basic.it lists fentry params:-btf.user_supplied_c_def_using_btf:-strcontains.path:-list probes by pid$" - NAME: Fuzzing CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-fuzz CC: afl-clang-fast CXX: afl-clang-fast++ - NAME: Latest kernel (LLVM 23 Debug) CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm23 NIX_TARGET_KERNEL: .#kernel-6_14 TOOLS_TEST_DISABLE: runqlen.bt # Need host 6.14 kernel # These tests either causes soft lockups in the VM or timeout consistently RUNTIME_TESTS_FILTER: "-basic.parallel map access:-strcontains.path" - NAME: AOT (LLVM 23 Debug) CMAKE_BUILD_TYPE: Debug NIX_TARGET: .#bpftrace-llvm23 RUN_TESTS: 0 RUN_AOT_TESTS: 1 AOT_ALLOWLIST_FILE: .github/include/aot_allow.txt steps: - uses: actions/checkout@v2 with: submodules: true - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - uses: ./.github/actions/configure_kvm - name: Load kernel modules # nf_tables and xfs are necessary for testing kernel modules BTF support run: | sudo modprobe nf_tables sudo modprobe xfs - name: Build and test env: ${{matrix.env}} run: ./.github/include/ci.py bpftrace-0.27.1/.github/workflows/clang-tidy.yml000066400000000000000000000013221526721631600215510ustar00rootroot00000000000000name: "Clang Tidy" on: [ pull_request ] # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read pull-requests: write # For flakehub cache id-token: write steps: - uses: actions/checkout@v3 with: submodules: true - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: Run clang-tidy run: ./scripts/clang_tidy.sh bpftrace-0.27.1/.github/workflows/codeql.yml000066400000000000000000000032771526721631600210000ustar00rootroot00000000000000name: "CodeQL" on: push: branches: [ master, release/* ] pull_request: schedule: - cron: "19 22 * * 1" # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write # For flakehub cache id-token: write strategy: fail-fast: false matrix: language: [ python, cpp ] steps: - name: Checkout uses: actions/checkout@v3 with: submodules: recursive - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: Configure (cpp) if: ${{ matrix.language == 'cpp' }} run: | mkdir $GITHUB_WORKSPACE/build && cd $GITHUB_WORKSPACE/build nix develop --command cmake .. - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: config-file: ./.github/codeql/codeql-config.yml languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild uses: github/codeql-action/autobuild@v3 if: ${{ matrix.language == 'python' }} - name: Build cpp if: ${{ matrix.language == 'cpp' }} run: | cd $GITHUB_WORKSPACE/build nix develop --command make -j$(nproc) - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{ matrix.language }}" bpftrace-0.27.1/.github/workflows/distros.yml000066400000000000000000000013021526721631600212030ustar00rootroot00000000000000name: Distros on: push: branches: [ master, release/* ] workflow_dispatch: # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: build: runs-on: ubuntu-latest continue-on-error: true strategy: matrix: dockerfile: - docker/Dockerfile.alpine - docker/Dockerfile.debian - docker/Dockerfile.fedora - docker/Dockerfile.opensuse - docker/Dockerfile.ubuntu steps: - uses: actions/checkout@v2 with: submodules: true - name: Build run: docker build -f ${{ matrix.dockerfile }} . bpftrace-0.27.1/.github/workflows/flakehub.yml000066400000000000000000000015631526721631600213060ustar00rootroot00000000000000# This job pushes tagged releases to flakehub. name: Flakehub on: push: tags: - v?[0-9]+.[0-9]+.[0-9]+* workflow_dispatch: inputs: tag: description: The existing tag to publish to FlakeHub type: string required: true jobs: flakehub-publish: runs-on: ubuntu-latest permissions: id-token: write contents: read steps: - uses: actions/checkout@v4 with: ref: ${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || '' }} - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - uses: DeterminateSystems/flakehub-push@v5 with: visibility: public name: bpftrace/bpftrace tag: ${{ inputs.tag }} include-output-paths: true bpftrace-0.27.1/.github/workflows/issue-metrics.yml000066400000000000000000000036151526721631600223210ustar00rootroot00000000000000name: Generate Issue and PR Metrics on: workflow_dispatch: permissions: contents: read jobs: build: name: issue pr metrics runs-on: ubuntu-latest permissions: issues: write pull-requests: read steps: - name: Get dates for last month shell: bash run: | # Calculate the first day of the previous month first_day=$(date -d "last month" +%Y-%m-01) # Calculate the last day of the previous month last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) # Get the month name month_name=$(date -d "last month" +%B) #Set environment variables with the date range and month name echo "$first_day..$last_day" echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" echo "month_name=$month_name" >> "$GITHUB_ENV" - name: Run issue-metrics tool for issues uses: github-community-projects/issue-metrics@v3 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SEARCH_QUERY: 'repo:bpftrace/bpftrace is:issue created:${{ env.last_month }} -reason:"not planned"' HIDE_ASSIGNEE: true HIDE_TIME_TO_ANSWER: true REPORT_TITLE: Issue Metrics for ${{ env.month_name }} OUTPUT_FILE: issue_metrics.md - name: Run issue-metrics tool for PRs uses: github-community-projects/issue-metrics@v3 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SEARCH_QUERY: 'repo:bpftrace/bpftrace is:pr created:${{ env.last_month }} -reason:"not planned"' HIDE_ASSIGNEE: true HIDE_TIME_TO_ANSWER: true REPORT_TITLE: PR Metrics for ${{ env.month_name }} OUTPUT_FILE: pr_metrics.md - name: Generate metrics report shell: bash run: | cat ./issue_metrics.md >> $GITHUB_STEP_SUMMARY cat ./pr_metrics.md >> $GITHUB_STEP_SUMMARY bpftrace-0.27.1/.github/workflows/release.yml000066400000000000000000000030571526721631600211450ustar00rootroot00000000000000# This job listens for new releases and will build the appropriate artifacts # and upload them to the release. name: Release on: release: types: [published] workflow_dispatch: inputs: dry_run: description: 'Skip uploading artifacts (for testing the workflow)' type: boolean default: true release: description: 'Target release (tag) to upload artifacts to' required: false type: string default: '' jobs: build-upload: name: build-upload (${{ matrix.runner }}) strategy: fail-fast: false matrix: include: # Only the x86_64 runner builds the arch-independent assets - runner: ubuntu-latest build_shared: "1" - runner: ubuntu-24.04-arm build_shared: "0" runs-on: ${{ matrix.runner }} permissions: # For flakehub cache id-token: write # For artifact upload contents: write steps: - uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: Build artifacts run: nix develop --command bash -c "OUT=./assets BUILD_SHARED_ASSETS=${{ matrix.build_shared }} ./scripts/create-assets.sh" - name: Upload artifacts if: ${{ !inputs.dry_run }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release upload ${{ inputs.release || github.ref_name }} ./assets/* bpftrace-0.27.1/.github/workflows/shellcheck.yml000066400000000000000000000013221526721631600216230ustar00rootroot00000000000000name: "ShellCheck" on: [ pull_request ] # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read pull-requests: write # For flakehub cache id-token: write steps: - uses: actions/checkout@v3 with: submodules: true - uses: DeterminateSystems/nix-installer-action@v17 with: determinate: true - uses: DeterminateSystems/flakehub-cache-action@v2 - name: Run shellcheck run: ./scripts/shellcheck.sh bpftrace-0.27.1/.github/workflows/static.yml000066400000000000000000000006771526721631600210210ustar00rootroot00000000000000name: Static on: push: branches: [ master, release/* ] pull_request: # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: submodules: true - name: Build static bpftrace run: ./.github/include/static.sh bpftrace-0.27.1/.github/workflows/stdlib-docs.yml000066400000000000000000000021051526721631600217250ustar00rootroot00000000000000name: Standard Library Documentation Check on: push: branches: [ master, release/* ] pull_request: paths: - "src/stdlib/**/*.bt" - "scripts/generate_stdlib_docs.py" - "docs/stdlib.md" # Cancel previous run if a new one is started concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: check-stdlib-docs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.x' - name: Generate stdlib documentation run: ./scripts/generate_stdlib_docs.py - name: Check for changes in docs/stdlib.md run: | if git diff --exit-code docs/stdlib.md; then echo "✅ docs/stdlib.md is up to date" else echo "� docs/stdlib.md is out of date. Please run './scripts/generate_stdlib_docs.py src/stdlib/base.bt' and commit the changes." echo "Changes detected:" git diff docs/stdlib.md exit 1 fi bpftrace-0.27.1/.gitignore000066400000000000000000000003251526721631600153700ustar00rootroot00000000000000/.idea build/ build-*/ tests/runtime/*.pyc .direnv .vagrant .vmtest.log tests/**/*.bc *~ \#*\# .\#* [._]*.s[a-v][a-z] [._]*.sw[a-p] [._]s[a-rt-v][a-z] [._]ss[a-gi-z] [._]sw[a-p] *.btaot result ignored/ .claude/ bpftrace-0.27.1/.gitmodules000066400000000000000000000001201526721631600155460ustar00rootroot00000000000000[submodule "libbpf"] path = libbpf url = https://github.com/libbpf/libbpf.git bpftrace-0.27.1/.shellcheckrc000066400000000000000000000000541526721631600160320ustar00rootroot00000000000000external-sources=true source-path=SCRIPTDIR bpftrace-0.27.1/.vmtest.log000066400000000000000000000000001526721631600154710ustar00rootroot00000000000000bpftrace-0.27.1/.vscode/000077500000000000000000000000001526721631600147415ustar00rootroot00000000000000bpftrace-0.27.1/.vscode/settings.json000066400000000000000000000004101526721631600174670ustar00rootroot00000000000000{ "cmake.buildDirectory": "${workspaceFolder}/build-vscode", "clangd.arguments": [ "-background-index", "-compile-commands-dir=${workspaceFolder}/build-vscode" ], "editor.formatOnSave": true, "C_Cpp.clang_format_style": "file" }bpftrace-0.27.1/AGENTS.md000066400000000000000000000111141526721631600147010ustar00rootroot00000000000000# AGENTS.md This file provides context for AI agents when working on the bpftrace codebase. ## Project overview bpftrace is a high-level tracing language for Linux eBPF. It uses LLVM as a compiler backend to generate BPF bytecode, and libbpf/bcc for kernel interaction. The language prioritizes conciseness, readability, and clean abstraction over eBPF complexity. Written in C++20. ## Build See [docs/developers.md](docs/developers.md#building) for full build instructions. Before running any tests, verify the `build/` directory and test binaries exist. If they don't, build first. Quick reference (Nix, preferred): ``` nix develop # enter dev shell cmake -B build -DCMAKE_BUILD_TYPE=Debug make -C build -j$(nproc) ``` The built binary is at `build/src/bpftrace`. ## Tests All contributions must not break existing tests and should add new tests when relevant. See [tests/README.md](tests/README.md) for the full test reference (test types, directives, runtime variables, etc.). Quick reference: ``` ./build/tests/bpftrace_test # unit tests ./build/tests/bpftrace_test --gtest_filter='Parser.*' # filtered unit tests sudo ./build/tests/self-tests.sh # self tests sudo ./build/tests/runtime-tests.sh # runtime tests sudo ./build/tests/runtime-tests.sh --filter="^uprobe" # filtered runtime tests sudo ./build/tests/tools-parsing-test.sh # tool parsing tests ``` ## Code formatting - C++ code: `clang-format` with the repo's `.clang-format` config. Run `git clang-format upstream/master` to format changed code. Every commit must be correctly formatted (no separate "fix formatting" commits). - bpftrace scripts (`.bt` files): format with `bpftrace --fmt` or `scripts/bpftrace_tidy.sh`. ## Code style and conventions - C++ code: Run this script which will fix clang tidy issues: `./scripts/clang_tidy.sh -u` - C++20 standard, 80-column line limit, 2-space indentation. - Variables: `snake_case`. Private class members get a trailing underscore (`my_var_`). Public members and struct fields do not. - Structs: passive data only, all public fields, no methods. - Classes: everything else. - Comments: prefer C++ style (`//`) over C style (`/* */`). - Defer to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) for anything not specified here. ## Error handling - Recoverable errors: return values (`Result`, `std::optional`, `int`, `bool`). Do NOT use exceptions for recoverable errors. ## Logging Use the `LOG()` macro with these levels: - `DEBUG` - always logs (includes file/line info) - `V1` - only with `-v` flag; for common warnings like "BTF not available" - `HINT` - tips to resolve a problem (use after WARNING or ERROR) - `WARNING` - issues that allow execution to continue - `ERROR` - user errors causing exit; primarily used in `main.cpp` - `BUG` - aborts; indicates internal/unexpected issues (not user errors) ## Source architecture The compilation pipeline: 1. **Parser** (`src/parser.cpp`, `src/parser.h`) - recursive descent parser, generates AST 2. **AST passes** (`src/ast/passes/`) - semantic analysis, type checking, AST replacement, macro expansion 3. **Codegen** (`src/ast/passes/codegen_llvm.cpp`, `src/ast/irbuilderbpf.cpp`) - LLVM IR generation 4. **BPF bytecode** (`src/bpfbytecode.cpp`) - compiled BPF programs 5. **Runtime** (`src/bpftrace.cpp`, `src/attached_probe.cpp`) - probe attachment and event handling Key directories: - `src/ast/` - AST node definitions, visitors, pass manager - `src/ast/passes/` - all compiler passes (type_checker, codegen_llvm, field_analyser, etc.) - `src/stdlib/` - bpftrace standard library - `src/btf/` - BTF (BPF Type Format) support - `tests/` - unit tests (GoogleTest), self tests, runtime tests - `tools/` - example bpftrace tools/scripts - `docs/` - developer and language documentation ## Design principles - Prefer user experience elegance over implementation elegance. - Prefer boring, verbose, removable code over clever premature abstractions. - Substantial or breaking changes require the RFC process (see CONTRIBUTING.md). - Performance of BPF programs and runtime is on the critical path; elsewhere, simplicity and clarity matter more than performance. ## PR conventions - One commit per PR (squash + rebase, no merge commits). - Commit titles should be changelog-worthy. - User-impacting changes require a `CHANGELOG.md` entry. - Language changes must update `docs/language.md`, `docs/stdlib.md`, or `man/adoc/bpftrace.adoc`. To regenerate the `docs/stdlib.md` run `./scripts/generate_stdlib_docs.py` - New behavior must be covered by tests. bpftrace-0.27.1/CHANGELOG.md000066400000000000000000004407661526721631600152320ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.27.1] 2026-10-24 #### Breaking Changes #### Added #### Changed - Structs and arrays are copied for scratch variable assignment - [#5369](https://github.com/bpftrace/bpftrace/pull/5369) #### Deprecated #### Removed #### Fixed - Fix bitfield access on structs stored in maps. - [#5366](https://github.com/bpftrace/bpftrace/pull/5366) - Fix field access on structs inside tuples, records and map keys. - [#5367](https://github.com/bpftrace/bpftrace/pull/5367) - Resolve uprobe argument names inherited through DWARF abstract origins. - [#5344](https://github.com/bpftrace/bpftrace/issues/5344) - Fix crash printing a `hist()` map when the `print()` divisor scales every bucket to zero. - [#5346](https://github.com/bpftrace/bpftrace/pull/5346) - Report the BPF program that actually failed verification when using `-v` or `-d verifier`. - [#5388](https://github.com/bpftrace/bpftrace/issues/5388) - Fix scalar access for copied structs - [#5363](https://github.com/bpftrace/bpftrace/pull/5363) - Fix invalid BPF object with LLVM 23 when using strings with a large `max_strlen` - [#5372](https://github.com/bpftrace/bpftrace/pull/5372) - Print compile-time warnings to stderr instead of stdout so they don't corrupt JSON output - [#5376](https://github.com/bpftrace/bpftrace/pull/5376) - Align scratch variables to 8 bytes when they don't fit on the stack. - [#5377](https://github.com/bpftrace/bpftrace/pull/5377) - Zero `let` declarations without an assignment on every loop iteration. - [#5399](https://github.com/bpftrace/bpftrace/pull/5399) #### Security #### Docs #### Tools ## [0.27.0] 2026-09-10 #### Added - stdlib: add `str_concat()`. - [#5265](https://github.com/bpftrace/bpftrace/pull/5265) - Add reg("pc") as an alias for the instruction pointer - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Publish arm64/aarch64 release artifacts alongside x86_64. - [#5213](https://github.com/bpftrace/bpftrace/pull/5213) - Add support for type expression substitution for macros - [#5234](https://github.com/bpftrace/bpftrace/pull/5234) - stdlib: add `container_of` mirroring the libbpf macro - [#5236](https://github.com/bpftrace/bpftrace/pull/5236) - stdlib: add `config` to read bpftrace configuration variables - [#5241](https://github.com/bpftrace/bpftrace/pull/5241) #### Changed - List structure with module name in verbose mode - [#5212](https://github.com/bpftrace/bpftrace/pull/5212) - Warn if casting to the exact same type - [#5208](https://github.com/bpftrace/bpftrace/pull/5208) - Release assets are now suffixed with the architecture - [#5213](https://github.com/bpftrace/bpftrace/pull/5213) #### Fixed - Fix session probes support for kernel version 7.0 - [#5294](https://github.com/bpftrace/bpftrace/pull/5294) - Propagate address space for sized variable declarations - [#5294](https://github.com/bpftrace/bpftrace/pull/5294) - Ensure that string allocation and usage are consistent in size. - [#5279](https://github.com/bpftrace/bpftrace/pull/5279) - Fix crash caused by debug locations leaking between generated functions - [#5278](https://github.com/bpftrace/bpftrace/pull/5278) - Fix address space handling for map and variable addresses - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Fix uaddr() to preserve pointer type for correct dereference size - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Fix fentry/fexit argument decoding - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Set user address space for USDT arguments - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Fix strftime() on big endian systems - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Fix for loop variable type mismatch - [#5272](https://github.com/bpftrace/bpftrace/pull/5272) - Print zero values for empty scalar maps - [#5239](https://github.com/bpftrace/bpftrace/pull/5239) - Prefer vendored libbpf BPF UAPI headers over system ones - [#5288](https://github.com/bpftrace/bpftrace/pull/5288) - Fix large string allocations for casts - [#5286](https://github.com/bpftrace/bpftrace/pull/5286) - Fix `func` builtin for session probe return/exit branches - [#5302](https://github.com/bpftrace/bpftrace/issues/5302) - Fix formatting of MAC address bytes with the high bit set - [#5326](https://github.com/bpftrace/bpftrace/issues/5326) - Fix recursive BTF compat types - [#5322](https://github.com/bpftrace/bpftrace/pull/5322) ## [0.26.1] 2026-06-02 #### Fixed - Fix reval and argX for session probes - [#5195](https://github.com/bpftrace/bpftrace/pull/5195) - Fix self probe listing - [#5200](https://github.com/bpftrace/bpftrace/pull/5200) - Fix statement probes for some compiler versions - [#5201](https://github.com/bpftrace/bpftrace/pull/5201) ## [0.26.0] 2026-05-26 #### Breaking Changes - stdlib: Change `pcomm` to an alias of task.real_parent.comm instead of task.group_leader.comm. - [#5132](https://github.com/bpftrace/bpftrace/pull/5132) - Subtraction and decrement ops now produce an int64 instead of a uint64. - [#5138](https://github.com/bpftrace/bpftrace/pull/5138) #### Added - User defined C structs support using `__attribute__`s after the closing curly brace. - [#5153](https://github.com/bpftrace/bpftrace/pull/5153) - stdlib: add `leader_{tid,comm}` to retrieve the thread group leader. - [#5132](https://github.com/bpftrace/bpftrace/pull/5132) - stdlib: add signal_name(). - [#5098](https://github.com/bpftrace/bpftrace/pull/5098) - Add DWARF-based user-space stack unwinding via `dw_ustack()` for x86_64 (requires LLVM >= 21). - [#4964](https://github.com/bpftrace/bpftrace/pull/4964) - Extend support for DWARF formats - [#5095](https://github.com/bpftrace/bpftrace/pull/5095) - Ternary operator supports an empty second operand. - [#5077](https://github.com/bpftrace/bpftrace/pull/5077) - Add `uprobe` support for source location attach points. - [#4867](https://github.com/bpftrace/bpftrace/pull/4867) - Add printf specifier `%gr` to print GFP flags in human readable format - [#4832](https://github.com/bpftrace/bpftrace/issues/4832) - Add `write_user(dst, src, len)` function to write to user-space memory using `bpf_probe_write_user` (requires `--unsafe`) - [#3742](https://github.com/bpftrace/bpftrace/issues/3742) - Add `is_err` stdlib macro for detecting ERR_PTR return values - [#5086](https://github.com/bpftrace/bpftrace/pull/5086) #### Changed - Improved disambiguation for cast and typeof-style expressions - [#5092](https://github.com/bpftrace/bpftrace/pull/5092) - The default type for positive integer literals is now `int8` - [#5138](https://github.com/bpftrace/bpftrace/pull/5138) - Warn instead of error when there is an integer sign mismatch, except for integer literals that are out of range for the destination type - [#5148](https://github.com/bpftrace/bpftrace/pull/5148) - Stabilize root imports (remove 'unstable_import' flag) - [#5184](https://github.com/bpftrace/bpftrace/pull/5184) - Stabilize address-of operator `&` (remove 'unstable_addr' flag) - [#5185](https://github.com/bpftrace/bpftrace/pull/5185) #### Fixed - Silence warning hints when warnings are disabled (`--no-warnings`) - [#5151](https://github.com/bpftrace/bpftrace/pull/5151) - Fix kfunc/fentry probe listing incorrectly showing a `retval` parameter - [#5147](https://github.com/bpftrace/bpftrace/pull/5147) - stdlib: Fixed strerror() and signal_name() failing BPF verification - [#5145](https://github.com/bpftrace/bpftrace/pull/5145) - Fix boolean to integer cast on big-endian architectures - [#5143](https://github.com/bpftrace/bpftrace/pull/5143) - Fix per-cpu map aggregation on big-endian architectures - [#5130](https://github.com/bpftrace/bpftrace/pull/5130) - Add bitfield support when printing full structure using "print()" - [#2801](https://github.com/bpftrace/bpftrace/issues/2801) - Fix subtraction and decrement ops not producing the correct type - [#5138](https://github.com/bpftrace/bpftrace/pull/5138) - Fix for-loop variable scope causing type merging across loops - [#5157](https://github.com/bpftrace/bpftrace/pull/5157) - Fix verbose listing of some kernel struct types - [#5169](https://github.com/bpftrace/bpftrace/pull/5169) - Enable session probes for kprobes with exact function names (not only wildcards) - [#5104](https://github.com/bpftrace/bpftrace/pull/5104) - Fix un-aligned map key access for hist/lhist/tseries map types - [#5181](https://github.com/bpftrace/bpftrace/pull/5181) #### Tools - naptime.bt: Filter out failed calls and add clock_nanosleep support - [#5117](https://github.com/bpftrace/bpftrace/pull/5117) ## [0.25.1] 2026-03-25 #### Fixed - Fix crash for invalid if expressions - [#5080](https://github.com/bpftrace/bpftrace/pull/5080) - Fix crash when scripts have a trailing new line and there are clang warnings - [#5074](https://github.com/bpftrace/bpftrace/pull/5074) - Fix casting negative literals to unsigned types - [#5085](https://github.com/bpftrace/bpftrace/pull/5085) - Attach watchpoint probes to all threads of a process - [#5088](https://github.com/bpftrace/bpftrace/pull/5088) - Fix stdlib `strerror` error caused by exceeding the BPF stack limit. - [#5094](https://github.com/bpftrace/bpftrace/pull/5094) ## [0.25.0] 2026-03-13 #### Breaking Changes - `exit()` is no longer allowed inside loops. `return` was always disallowed, and `exit()` implicitly returns, which may result in undefined behavior. - [#4587](https://github.com/bpftrace/bpftrace/pull/4587) - Restrict bpftrace script licenses to those that are GPL compatible - [#4677](https://github.com/bpftrace/bpftrace/pull/4677) - Remove the deprecated `sarg` builtin - [#4686](https://github.com/bpftrace/bpftrace/pull/4686) - Benchmark formats changed slightly, to reflect gbenchmark - [#4753](https://github.com/bpftrace/bpftrace/pull/4753) - `args` in tracepoints now requires BTF - [#4864](https://github.com/bpftrace/bpftrace/pull/4864) - [Migration guide](docs/migration_guide.md##args-in-tracepoints-now-requires-btf) - Experimental `watchpoint:func+arg` and `asyncwatchpoint:func+arg` attach points are not supported anymore (for now, at least) - [#4890](https://github.com/bpftrace/bpftrace/pull/4890) - `BPFTRACE_DEBUG_OUTPUT` is removed, and errors are now propagated via the runtime error path - [#4976](https://github.com/bpftrace/bpftrace/pull/4976) #### Added - `getopt()` add optional description argument - [#4998](https://github.com/bpftrace/bpftrace/pull/4998) - Add `--probe-filter` CLI flag to selectively run probes matching a regex - [#5011](https://github.com/bpftrace/bpftrace/pull/5011) - Add `comm()` support for PID parameters. - [#4799](https://github.com/bpftrace/bpftrace/pull/4799) - Add `syscall_name()` to convert system call numbers into names. - [#4746](https://github.com/bpftrace/bpftrace/pull/4746) - Add `pcomm` to stdlib and `ppid` can be called without arguments. - [#4744](https://github.com/bpftrace/bpftrace/pull/4744) - Add support for indexing string types - [#4540](https://github.com/bpftrace/bpftrace/pull/4540) - Automatic dereferencing is supported via `.`, now the preferred access operator - [#4673](https://github.com/bpftrace/bpftrace/pull/4673) - Add `signal_thread()` to target the current thread - [#4700](https://github.com/bpftrace/bpftrace/pull/4700) - Add `probetype` builtin - [#4712](https://github.com/bpftrace/bpftrace/pull/4712) - Allow array-style access for tuples - [#4715](https://github.com/bpftrace/bpftrace/pull/4715) - Add `test` probes as means to improve runtime test latency - [#4753](https://github.com/bpftrace/bpftrace/pull/4753) - Multiple `begin` & `end` probes are now permitted - [#4789](https://github.com/bpftrace/bpftrace/pull/4789) - Probes may now be named (reserved for future use) - [#4752](https://github.com/bpftrace/bpftrace/pull/4752) - Add support for more vmlinux BTF types as identifiers - [#4853](https://github.com/bpftrace/bpftrace/pull/4853) - Add support for `--fmt` mode (automatic formatting) - [#4621](https://github.com/bpftrace/bpftrace/pull/4621) - Add `build_id` stack mode for getting build_id and offset - [#4912](https://github.com/bpftrace/bpftrace/pull/4912) - Add new Record primitive - [#4947](https://github.com/bpftrace/bpftrace/pull/4947) - Add `find` to get map value if it exists - [#4845](https://github.com/bpftrace/bpftrace/pull/4845) - Make `cpid` AOT friendly; using `cpid` while lacking a command is no longer a compile error and `has_cpid` has been added - [#4984](https://github.com/bpftrace/bpftrace/pull/4984) - Add `--traceable-functions` to allow the user to provide the list of kernel functions that can be probed - [#5014](https://github.com/bpftrace/bpftrace/pull/5014) - Add support for address kprobes - [#5041](https://github.com/bpftrace/bpftrace/pull/5041) - Allow probing arbitrary files with --unsafe - [#5053](https://github.com/bpftrace/bpftrace/pull/5053) - Support probing binaries stored in ZIP archives (e.g. Android APKs) - [#5053](https://github.com/bpftrace/bpftrace/pull/5053) #### Changed - Add helpers to check if a kfunc exists and is supported for particular probe types. - [#4857](https://github.com/bpftrace/bpftrace/pull/4857) - `uaddr` support PIE and dynamic library symbols. - [#4727](https://github.com/bpftrace/bpftrace/pull/4727) - Apply `-B` buffering semantics to file outputs. - [#4637](https://github.com/bpftrace/bpftrace/pull/4637) - Link against libbpf vendored from a submodule by default - [#4688](https://github.com/bpftrace/bpftrace/pull/4688) - Increase RLIMIT_NOFILE on startup as needed - [#4716](https://github.com/bpftrace/bpftrace/pull/4716) - Root user check replaced with check for required capabilities (CAP_BPF, CAP_PERFMON, CAP_DAC_READ_SEARCH, CAP_DAC_OVERRIDE) - [#4773](https://github.com/bpftrace/bpftrace/pull/4773) - Remove automatic type promotion for integers, making them more flexible - [#4768](https://github.com/bpftrace/bpftrace/pull/4768) - Stabilize macros (remove 'unstable_macro' flag) - [#4818](https://github.com/bpftrace/bpftrace/pull/4818) - Warn on all discarded expressions - [#4836](https://github.com/bpftrace/bpftrace/pull/4836) - Stabilize map declarations (remove 'unstable_map_decl' flag) - [#5005](https://github.com/bpftrace/bpftrace/pull/5005) #### Deprecated - `while` is now deprecated in favor of range-based for loops - [#4886](https://github.com/bpftrace/bpftrace/pull/4886) #### Removed - Drop support for LLVM 16 - [#4534](https://github.com/bpftrace/bpftrace/pull/4534) - Drop support for LLVM 17 - [#5067](https://github.com/bpftrace/bpftrace/pull/5067) #### Fixed - Fix interval probe attachment when CPU 0 is offline - [#4987](https://github.com/bpftrace/bpftrace/pull/4987) - Respect `missing_probes` config for bad `args` if the probe will be pruned - [#4915](https://github.com/bpftrace/bpftrace/pull/4915) - Improved tuple binop comparison - [#4523](https://github.com/bpftrace/bpftrace/pull/4523) - Stack type comparison and compatibility - [#4948](https://github.com/bpftrace/bpftrace/pull/4948) - Fix missing lines in stack resolution - [#4953](https://github.com/bpftrace/bpftrace/pull/4953) - Fix listing multi-probes error - [#5022](https://github.com/bpftrace/bpftrace/pull/5022) - Fix handling of void ptr and function ptr BTF types - [#5042](https://github.com/bpftrace/bpftrace/pull/5042) #### Security #### Docs #### Tools - undump.bt: Support dgram packet capture - [#4846](https://github.com/bpftrace/bpftrace/pull/4846) - opensnoop.bt: Fix multi-thread race condition of @paths - [#4837](https://github.com/bpftrace/bpftrace/pull/4837) - syscount.bt: Fix incorrect map printing - [#4831](https://github.com/bpftrace/bpftrace/pull/4831) - opensnoop.bt: support mount points - [#4822](https://github.com/bpftrace/bpftrace/pull/4822) - opensnoop.bt: support full file path - [#4601](https://github.com/bpftrace/bpftrace/pull/4601) - gethostlatency.bt: add more APIs support - [#4600](https://github.com/bpftrace/bpftrace/pull/4600) - oomkill.bt: support memory cgroup - [#4533](https://github.com/bpftrace/bpftrace/pull/4533) ## [0.24.2] 2025-12-12 #### Fixed - Fix off-by-one for function argument size comparison - [#4698](https://github.com/bpftrace/bpftrace/pull/4698) - Fix resolution of enum-typed tracepoint args - [#4714](https://github.com/bpftrace/bpftrace/pull/4714) - Fix block expression handling inside print statements - [#4704](https://github.com/bpftrace/bpftrace/issues/4704) - join(): Fix wrong index of GEP that was causing truncation - [#4786](https://github.com/bpftrace/bpftrace/pull/4786) - output: prevent crash when printing overflow-only lhist - [#4801](https://github.com/bpftrace/bpftrace/pull/4801) - codegen: Fix tid/pid in non-init namespaces - [#4813](https://github.com/bpftrace/bpftrace/issues/4813) - Fix segfault in printf ordering - [#4838](https://github.com/bpftrace/bpftrace/pull/4838) - Fix language part being overwritten in uprobe attachpoint parser - [#4856](https://github.com/bpftrace/bpftrace/pull/4856) - Fix automatic conversion of BTF char arrays to bpftrace strings - [#4871](https://github.com/bpftrace/bpftrace/pull/4871) - Fix anonymous struct/unions not resolving correctly from BTF - [#4732](https://github.com/bpftrace/bpftrace/pull/4732) - Fix getopt support for unsigned integers - [#4881](https://github.com/bpftrace/bpftrace/pull/4881) #### Changed - Disallow builtin and type idents as macro parameter names - [#4873](https://github.com/bpftrace/bpftrace/pull/4873) ## [0.24.1] 2025-10-03 #### Fixed - Fix missing location.hh build error on Alpine - [#4635](https://github.com/bpftrace/bpftrace/pull/4635) - Fix build with gcc-16 - [#4614](https://github.com/bpftrace/bpftrace/pull/4614) - ast: Avoid undefined behavior in literal folding - [#4649](https://github.com/bpftrace/bpftrace/pull/4649) - Fix missing map key buffers for map aggregate functions - [#4670](https://github.com/bpftrace/bpftrace/pull/4670) #### Docs - Fix docs for PERCPU map types - [#4646](https://github.com/bpftrace/bpftrace/pull/4646) ## [0.24.0] 2025-09-17 #### Breaking Changes - Drop majority of DWARF support. Only uprobe argument parsing remains. - [#3921](https://github.com/bpftrace/bpftrace/pull/3921) - [#3950](https://github.com/bpftrace/bpftrace/pull/3950) - Removed config option 'symbol_source' - it no longer has any effect - [#3925](https://github.com/bpftrace/bpftrace/pull/3925) - Rawtracepoints now require kernel BTF - [#3944](https://github.com/bpftrace/bpftrace/pull/3944) - Ustack and kstack symbols are automatically enhanced with debug info if available - [#3999](https://github.com/bpftrace/bpftrace/pull/3999) - Error by default if any probe fails to attach - [#4097](https://github.com/bpftrace/bpftrace/pull/4097) - Require BPF_MAP_TYPE_RINGBUF to be available - [#3974](https://github.com/bpftrace/bpftrace/pull/3974) - Require kernel uprobe ref counting to be available for USDTs with semaphores - [#4199](https://github.com/bpftrace/bpftrace/pull/4199) - `strcontains` and `has_key` now return boolean values instead of 1 and 0 - [#4280](https://github.com/bpftrace/bpftrace/pull/4280) - JSON serialization for unsupported and unknown types (e.g. `float`) may now use `null` now rather than the empty string - [#4302](https://github.com/bpftrace/bpftrace/pull/4302) - Text mode now emits all non-script generated output (e.g., errors, attached notifications) to `stderr` instead of `stdout` - [#4504](https://github.com/bpftrace/bpftrace/pull/4504) #### Added - Add ncpus builtin to get the number of CPUs. - [#4105](https://github.com/bpftrace/bpftrace/pull/4105) - Use blazesym for user space address symbolization - [#3884](https://github.com/bpftrace/bpftrace/pull/3884) - Add simple block expressions - [#3780](https://github.com/bpftrace/bpftrace/pull/3780) - Add map declaration syntax (behind an "unstable" config flag) - [#3863](https://github.com/bpftrace/bpftrace/pull/3863) - Add license config to specify BPF license - [#3905](https://github.com/bpftrace/bpftrace/pull/3905) - Rawtracepoints can now use `args` builtin and list params - [#3918](https://github.com/bpftrace/bpftrace/pull/3918) - Add ability to specify rawtracepoint modules - [#3944](https://github.com/bpftrace/bpftrace/pull/3944) - Add 'show_debug_info' config for blazesym - [#3999](https://github.com/bpftrace/bpftrace/pull/3999) - Add hygienic macros (behind an "unstable" config flag) - [#4037](https://github.com/bpftrace/bpftrace/pull/4037) - Add warning when unset or empty positional parameters are used - [#4095](https://github.com/bpftrace/bpftrace/pull/4095) - Support accessing up to 255 USDT probe args - [#4118](https://github.com/bpftrace/bpftrace/pull/4118) - Add new builtin "usermode" - [#4129](https://github.com/bpftrace/bpftrace/pull/4129) - Warn on discarded return values for specific builtin functions - [#4191](https://github.com/bpftrace/bpftrace/pull/4191) - For loops now support `..` ranges - [#4126](https://github.com/bpftrace/bpftrace/pull/4126) - For loops now support `break` and `continue` - [#4250](https://github.com/bpftrace/bpftrace/pull/4250) - For loops now support `return` - [#4255](https://github.com/bpftrace/bpftrace/pull/4255) - Add `pid` and `tid` functions for choosing between the initial or the current namespace - [#4254](https://github.com/bpftrace/bpftrace/pull/4254) - Add boolean values (`true` and `false`) - [#4280](https://github.com/bpftrace/bpftrace/pull/4280) - Add duration literals - suffixes include: `ns`, `us`, `ms`, `s`, `m`, `h`, `d` - [#4317](https://github.com/bpftrace/bpftrace/pull/4317) - Add `getopt` function to handle named command line program arguments - [#4258](https://github.com/bpftrace/bpftrace/pull/4258) - Add `socket_cookie` function to get the cookie of a socket - [#4345](https://github.com/bpftrace/bpftrace/pull/4345) - Introduce `tseries` for capturing time series data - [#3838](https://github.com/bpftrace/bpftrace/pull/3838) - Add ability to attach to running BPF programs and sub-programs via `fentry:bpf:prog_name` or `fentry:bpf:prog_id:prog_name` - [#4354](https://github.com/bpftrace/bpftrace/pull/4354) - Add `BENCH` for creating microbenchmarks - [#4343](https://github.com/bpftrace/bpftrace/pull/4343) - Add 'assert' and 'ppid' to the macro standard library - [#4366](https://github.com/bpftrace/bpftrace/pull/4366) - Add 'errorf' for printing error messages with the source location - [#4414](https://github.com/bpftrace/bpftrace/pull/4414) - Add ability to call most builtins with call-style syntax e.g. `comm()` - [#4420](https://github.com/bpftrace/bpftrace/pull/4420) - Allow non-constant array access - [#4491](https://github.com/bpftrace/bpftrace/pull/4491) - Add '0' flag for printf to fill with leading 0s - [#4510](https://github.com/bpftrace/bpftrace/pull/4510) - Add support for LLVM 21 - [#4528](https://github.com/bpftrace/bpftrace/pull/4528) #### Changed - kprobe: support verbose mode listing - [#4362](https://github.com/bpftrace/bpftrace/pull/4362) - `-p` CLI flag now applies to all probes (except BEGIN/END) - [#3800](https://github.com/bpftrace/bpftrace/pull/3800) - Introduce automatic session probes - [#3772](https://github.com/bpftrace/bpftrace/pull/3772) - Positional params can be used in any part of a probe string - [#3956](https://github.com/bpftrace/bpftrace/pull/3956) - Add signed type checking for map assignments - [#4132](https://github.com/bpftrace/bpftrace/pull/4132) - Add signed type checking for map keys - [#4136](https://github.com/bpftrace/bpftrace/pull/4136) - `delete` now returns 1 if successful, 0 if not - [#4186](https://github.com/bpftrace/bpftrace/pull/4186) - if `delete` fails it will only print a warning if return value is not handled - [#4186](https://github.com/bpftrace/bpftrace/pull/4186) - Change "Attaching N probes..." to "Attached N probes" - [#4194](https://github.com/bpftrace/bpftrace/pull/4194) - runqlat.bt: ignore idle task - [#4194](https://github.com/bpftrace/bpftrace/pull/4291) - Only cache symbols from targeted process - [#4315](https://github.com/bpftrace/bpftrace/pull/4315) - Automatically exit if only BEGIN/END probes are specified - [#4358](https://github.com/bpftrace/bpftrace/pull/4358) - Moved docs for builtins, functions, and map functions into stdlib.md and moved language docs into language.md - [#4367](https://github.com/bpftrace/bpftrace/pull/4367) - Make probe provider names case insensitive - [#4371](https://github.com/bpftrace/bpftrace/pull/4371) - If, for, while and unroll statements can have omitted parentheses for unary expressions - [#4503](https://github.com/bpftrace/bpftrace/pull/4503) #### Deprecated #### Removed #### Fixed - Fix build failures due to missing location.hh - [#3987](https://github.com/bpftrace/bpftrace/pull/3987) - Fix 32-bit build failures due to missing cast - [#4006](https://github.com/bpftrace/bpftrace/pull/4006) - Don't crash if kernel isn't built with PID namespaces - [#3976](https://github.com/bpftrace/bpftrace/pull/3976) - Allow sized_type idents to be used for field access - [#4064](https://github.com/bpftrace/bpftrace/pull/4064) - Fix per-cpu map update warning - [#4047](https://github.com/bpftrace/bpftrace/pull/4074) - Fix probe firing order for fexit and software - [#4113](https://github.com/bpftrace/bpftrace/pull/4113) - Fix type mismatch error for map assignments - [#4130](https://github.com/bpftrace/bpftrace/pull/4130) - Parse BTF for implicit kernel modules in kprobe/kretprobe - [#4137](https://github.com/bpftrace/bpftrace/pull/4137) - Fix execution watchpoints - [#4139](https://github.com/bpftrace/bpftrace/pull/4139) - Fix incorrect reporting of attached count for multi probes - [#4194](https://github.com/bpftrace/bpftrace/pull/4194) - Attach watchpoint probes to newly created threads - [#4239](https://github.com/bpftrace/bpftrace/pull/4239) - Fix reading of __data_loc tracepoint arguments - [#4238](https://github.com/bpftrace/bpftrace/pull/4238) - Fix kstack/ustack on big-endian systems - [#4244](https://github.com/bpftrace/bpftrace/pull/4244) - Report expanded probe name when trying to attach - [#4353](https://github.com/bpftrace/bpftrace/pull/4353) - Fix codegen optimization bug with the modulo operator - [#4383](https://github.com/bpftrace/bpftrace/pull/4383) #### Security #### Docs #### Tools - opensnoop.bt: support openat2 syscall - [#4310](https://github.com/bpftrace/bpftrace/pull/4310) - killsnoop.bt: display signal name instead of value - [#4234](https://github.com/bpftrace/bpftrace/pull/4234) - killsnoop.bt: support tkill() and tgkill() - [#4190](https://github.com/bpftrace/bpftrace/pull/4190) - Remove tools example usage txt files and move info to comments - [#4187](https://github.com/bpftrace/bpftrace/pull/4187) - Fix biosnoop.bt to print comm from block_io_start probe - [#4013](https://github.com/bpftrace/bpftrace/pull/4013) ## [0.23.0] 2025-03-25 #### Breaking Changes - Remove '-kk' command line opt, surface some BPF errors by default, and make '-k' surface probe read errors - [#3784](https://github.com/bpftrace/bpftrace/pull/3784) #### Added - `offsetof()` now supports sub fields e.g. `offsetof(struct Foo, bar.a.b);` - [#3761](https://github.com/bpftrace/bpftrace/pull/3761) - Pointers may now be used in if conditions, tenary conditions and as operands in logical AND and OR expressions - [#3656](https://github.com/bpftrace/bpftrace/pull/3656) - `len` now also accepts `ustack` and `kstack` as arguments - [#3769](https://github.com/bpftrace/bpftrace/pull/3769) - `blazesym` will be used for address symbolication if found during build - [#3760](https://github.com/bpftrace/bpftrace/pull/3760) - [#3787](https://github.com/bpftrace/bpftrace/pull/3787) - Published aarch64 appimage builds from master - [#3795](https://github.com/bpftrace/bpftrace/pull/3795) - Add ability to cast int to an enum - [#3812](https://github.com/bpftrace/bpftrace/pull/3812) - Added warning when strcontains() is used on strings that are too big and may cause verifier issues - [#3811](https://github.com/bpftrace/bpftrace/pull/3811) - Add support for LLVM 20 - [#3841](https://github.com/bpftrace/bpftrace/pull/3841) #### Changed - `probe` builtin is now represented as a string type - [#3638](https://github.com/bpftrace/bpftrace/pull/3638) - Change bpftrace help flag output from stderr to stdout - [#3678](https://github.com/bpftrace/bpftrace/pull/3678) - Change max_strlen default from 64 to 1024 - [#3713](https://github.com/bpftrace/bpftrace/pull/3713) - Add feature check for castable map reads - [#3752](https://github.com/bpftrace/bpftrace/pull/3752) - Increase default values for max_bpf_progs and max_probes - [#3808](https://github.com/bpftrace/bpftrace/pull/3808) - Allow use of variables before they are assigned - [#3832](https://github.com/bpftrace/bpftrace/pull/3832) #### Deprecated #### Removed - Drop support for LLVM 14 and 15 - [#3825](https://github.com/bpftrace/bpftrace/pull/3825) #### Fixed - Fix json output for none type - [#3692](https://github.com/bpftrace/bpftrace/pull/3692) - Fix bug where strftime() %f specifier could be off by up to 1s - [#3704](https://github.com/bpftrace/bpftrace/pull/3704) - Fix `pid`, `tid` and `ustack` when running bpftrace in containers with PID namespacing - [#3428](https://github.com/bpftrace/bpftrace/pull/3428) - Do not generate functions for empty attach points - [#3715](https://github.com/bpftrace/bpftrace/pull/3715) - Fix ternary expression to accept all types - [#3765](https://github.com/bpftrace/bpftrace/pull/3765) - Fix feature detection for tracing program types - [#3805](https://github.com/bpftrace/bpftrace/pull/3805) - Fix strcontains() correctness bug where matches could be lost if both strings are non-literal - [#3811](https://github.com/bpftrace/bpftrace/pull/3811) - Fix str() bug where optional size parameter did not count towards NUL terminator - [#3849](https://github.com/bpftrace/bpftrace/pull/3849) #### Security #### Docs #### Tools - Fix dcsnoop.bt on newer kernels - [#3715](https://github.com/bpftrace/bpftrace/pull/3715) ## [0.22.0] 2025-01-07 #### Breaking Changes - Return `uint32` instead of `uint64` for `pid` and `tid` builtins - [#3441](https://github.com/bpftrace/bpftrace/pull/3441) - [Migration guide](docs/migration_guide.md#pid-and-tid-builtins-return-uint32) - Remove multi-map `delete` functionality - [#3506](https://github.com/bpftrace/bpftrace/pull/3506) - [Migration guide](docs/migration_guide.md#multi-key-delete-removed) - Add lexical/block scoping for variables - [#3367](https://github.com/bpftrace/bpftrace/pull/3367) - [Migration guide](docs/migration_guide.md#added-block-scoping-for-scratch-variables) - Replace default map printing on `SIGUSR1` with custom signal handling probes - [#3522](https://github.com/bpftrace/bpftrace/pull/3522) - [Migration guide](docs/migration_guide.md#default-sigusr1-handler-removed) #### Added - Add env var to colorize bpftrace log output - [#3710](https://github.com/bpftrace/bpftrace/pull/3710) - Bump max supported LLVM version to 19 - [#3433](https://github.com/bpftrace/bpftrace/pull/3433) - Add `--dry-run` CLI option - [#3203](https://github.com/bpftrace/bpftrace/pull/3203) - Enable avg map reads in kernel space (implicit casting) - [#3268](https://github.com/bpftrace/bpftrace/pull/3268) - Enable for-loops in multiple probes - [#3285](https://github.com/bpftrace/bpftrace/pull/3285) - For-loops: Allow sharing variables between the main probe and the loop's body - [#3014](https://github.com/bpftrace/bpftrace/pull/3014) - Parse C++ Class and Inheritance from Debug Info - [#3094](https://github.com/bpftrace/bpftrace/pull/3094) - Add an optional `size` parameter to `path` - [#3401](https://github.com/bpftrace/bpftrace/pull/3401) - Allow tuples to be used as map keys - [#3390](https://github.com/bpftrace/bpftrace/pull/3390/) - Add `has_key` function for maps - [#3358](https://github.com/bpftrace/bpftrace/pull/3358) - Add ability to attach kprobes to inlined functions - [#3301](https://github.com/bpftrace/bpftrace/pull/3095) - Variable declarations with `let` - [#3461](https://github.com/bpftrace/bpftrace/pull/3461) - Support symbolizing enum values using `%s` specifier in `printf()` - [#3515](https://github.com/bpftrace/bpftrace/pull/3515) - Configuration option to suppress printing maps by default at program exit - [#3547](https://github.com/bpftrace/bpftrace/pull/3547) - Add `symbol_source` config to source uprobe locations from either DWARF or the Symbol Table - [#3504](https://github.com/bpftrace/bpftrace/pull/3504/) - Introduce builtin to access percpu kernel data - [#3596](https://github.com/bpftrace/bpftrace/pull/3596/) #### Changed - Merge output into `stdout` when `-lv` - [#3383](https://github.com/bpftrace/bpftrace/pull/3383) - Stream output when printing maps - [#3264](https://github.com/bpftrace/bpftrace/pull/3264) - Only print kernel headers not found message if parsing fails - [#3265](https://github.com/bpftrace/bpftrace/pull/3265) - Add mandatory "stage" argument to the `-d` CLI option - [#3203](https://github.com/bpftrace/bpftrace/pull/3203) - Allow simultaneous use of `-v` and `-d` - [#3203](https://github.com/bpftrace/bpftrace/pull/3203) - Remove length limitations for the `buf` builtin function - [#3249](https://github.com/bpftrace/bpftrace/pull/3249) - Change `delete` API to accept a map and key as separate args - [#3472](https://github.com/bpftrace/bpftrace/pull/3472) - Symbolize enums when used in maps - [#3539](https://github.com/bpftrace/bpftrace/pull/3539) - Supported LLVM version for static builds changed to LLVM 18 - [#3631](https://github.com/bpftrace/bpftrace/pull/3631) #### Deprecated #### Removed - Remove the `-dd` CLI option - [#3203](https://github.com/bpftrace/bpftrace/pull/3203) - Drop support for LLVM 12 and below - [#3325](https://github.com/bpftrace/bpftrace/pull/3325) - Remove `ALLOW_UNSAFE_PROBE` compiler flag - [#3476](https://github.com/bpftrace/bpftrace/pull/3476) #### Fixed - Fix verifier error when array indexing through pointer - [#3465](https://github.com/bpftrace/bpftrace/pull/3465) - Fix segfault for multi-tracepoint probes - [#3274](https://github.com/bpftrace/bpftrace/pull/3274) - Fix verifier error from misaligned stack access when using strings as map keys - [#3294](https://github.com/bpftrace/bpftrace/issues/3294) - Fix min/max map functions - [#3298](https://github.com/bpftrace/bpftrace/pull/3298) - Fix stack mode for stack builtin - [#3322](https://github.com/bpftrace/bpftrace/pull/3322) - Fix lldb support in appimage builds - #[3339](https://github.com/bpftrace/bpftrace/pull/3339) - Fix parsing large unsigned int strings as positional params - [#3336](https://github.com/bpftrace/bpftrace/pull/3336) - Fix json formatting for `strftime` function - [#3381](https://github.com/bpftrace/bpftrace/pull/3381) - Fix BTF/DWARF parsing for structs contained in arrays - [#3422](https://github.com/bpftrace/bpftrace/pull/3422) - Fix integer comparisons and auto casting for scratch variables - [#3416](https://github.com/bpftrace/bpftrace/pull/3416) - Fix tuple resizing - [#3443](https://github.com/bpftrace/bpftrace/pull/3443) - Handle invalid BTF without crashing - [#3453](https://github.com/bpftrace/bpftrace/pull/3453) - Fix json formatting for hex values - [#3475](https://github.com/bpftrace/bpftrace/pull/3475) - Fix binary operations on integers always returning 64 bit values - [#3517](https://github.com/bpftrace/bpftrace/pull/3517) - Fix verifier error when comparing result of len() - [#3308](https://github.com/bpftrace/bpftrace/issues/3308) - Fix type back propagation for map keys - [#3536](https://github.com/bpftrace/bpftrace/pull/3536) - Fix crash by adding checks for bad var/map assignments - [#3542](https://github.com/bpftrace/bpftrace/pull/3542) - Fix field access and offsetof for strings that are builtin types - [#3565](https://github.com/bpftrace/bpftrace/pull/3565) - Fix crash when using castable per-cpu map types as map keys - [#3594](https://github.com/bpftrace/bpftrace/pull/3594) - Fix loop values with per-cpu aggregations - [#3664](https://github.com/bpftrace/bpftrace/pull/3664) #### Security #### Docs - Remove mention of unsupported character literals - [#3283](https://github.com/bpftrace/bpftrace/pull/3283) #### Tools - Fix bashreadline tool probe for dynamically linked readline - [#3564](https://github.com/bpftrace/bpftrace/pull/3564) - Switch all bio* tools to tracepoints - [#3622](https://github.com/bpftrace/bpftrace/pull/3622) ## [0.21.0] 2024-06-21 #### Added - Add `lazy_symbolication` config option - [#2958](https://github.com/bpftrace/bpftrace/pull/2958) - Add ability to list all probes in a program - [#2969](https://github.com/bpftrace/bpftrace/pull/2969) - Add ability to call print() with indexed maps to print single map values - [#3027](https://github.com/bpftrace/bpftrace/pull/3027) - Add LLVM 18 support - [#3051](https://github.com/bpftrace/bpftrace/pull/3051) - Add ability to call delete() with multiple arguments - [#3046](https://github.com/bpftrace/bpftrace/pull/3046) - Add for-each loops for iterating over map elements - [#3003](https://github.com/bpftrace/bpftrace/pull/3003) - Add optional systemd support - [#3158](https://github.com/bpftrace/bpftrace/pull/3158) - Add ability to attach uprobes to inlined functions - [#3095](https://github.com/bpftrace/bpftrace/pull/3095) - Enable count, sum, min, and max map reads in kernel space (implicit casting) - [#3189](https://github.com/bpftrace/bpftrace/pull/3189) - [#3226](https://github.com/bpftrace/bpftrace/pull/3226) - Add config option for handling missing probes - [#3246](https://github.com/bpftrace/bpftrace/pull/3246) - Support large arguments for printf() and print() - [#3368](https://github.com/bpftrace/bpftrace/pull/3368) - Add ability to call exit() with an exit code - [#3501](https://github.com/bpftrace/bpftrace/pull/3501) #### Changed - Better error message for args in mixed probes - [#3047](https://github.com/bpftrace/bpftrace/pull/3047) - Reproducible Builds: Do not store timestamps in gzip header - [#3096](https://github.com/bpftrace/bpftrace/pull/3096) - Improve DWARF support, using liblldb instead of libdw - [#3042](https://github.com/bpftrace/bpftrace/pull/3042) - Use new hash function to reduce collisions when aggregating on stack traces - [#3060](https://github.com/bpftrace/bpftrace/pull/3060) - Disable func builtin for kretprobes and uretprobes when `get_func_ip` feature is not available - [#2645](https://github.com/bpftrace/bpftrace/pull/2645) - Move error printing from debug to verbose mode - [#3202](https://github.com/bpftrace/bpftrace/pull/3202) - Better error message when libbpf is too old - [#3212](https://github.com/bpftrace/bpftrace/pull/3212) - Allow trailing semicolons and empty blocks in config syntax - [#3077](https://github.com/bpftrace/bpftrace/pull/3077) - Allow attaching to `spin_lock` functions with mitigations to prevent deadlocks - [#3206](https://github.com/bpftrace/bpftrace/pull/3206) - Remove length limitations for strings coming out of `str()` and `path()` - [#3228](https://github.com/bpftrace/bpftrace/pull/3228) - [#3237](https://github.com/bpftrace/bpftrace/pull/3237) - [#3245](https://github.com/bpftrace/bpftrace/pull/3245) #### Deprecated - Deprecate `sarg` builtin - [#3095](https://github.com/bpftrace/bpftrace/pull/3095) #### Removed #### Fixed - Fix ability to interrupt bpftrace during probe attach - [#3053](https://github.com/bpftrace/bpftrace/pull/3053) - Fix field resolution on structs with anon union as first field - [#2964](https://github.com/bpftrace/bpftrace/pull/2964) - Fix alignment of atomic map counter update - [#3045](https://github.com/bpftrace/bpftrace/pull/3045) - Fix func builtin for kretprobes and uretprobes for kernels with working `get_func_ip` feature - [#2645](https://github.com/bpftrace/bpftrace/pull/2645) - Fix ustack missing the second-from-top stack frame in uprobes - [#3095](https://github.com/bpftrace/bpftrace/pull/3095) - Fix storing strings of differing lengths in a variable - [#3178](https://github.com/bpftrace/bpftrace/pull/3178) - Fix field resolution for structs in arrays - [#3024](https://github.com/bpftrace/bpftrace/pull/3024) - Fix error in dereferencing kernel double pointers - [#3024](https://github.com/bpftrace/bpftrace/pull/3024) - Fix variable corruption when used as map key - [#3195](https://github.com/bpftrace/bpftrace/pull/3195) - Fix crash when assigning a record type to a map - [#3220](https://github.com/bpftrace/bpftrace/pull/3220) - Fix type resolution for pointers with `BTF_KIND_TYPE_TAG` - [#3240](https://github.com/bpftrace/bpftrace/pull/3240) - Fix attachment of probes attaching to wildcarded and non-wildcarded kprobes - [#3246](https://github.com/bpftrace/bpftrace/pull/3246) #### Security - Don't unpack kernel headers or look in tmp - [#3156](https://github.com/bpftrace/bpftrace/pull/3156) #### Docs #### Tools - Ignore warnings for missing probes - [#3246](https://github.com/bpftrace/bpftrace/pull/3246) ## [0.20.0] 2024-01-22 #### Added - Add log2 histograms with finer granularity - [#2831](https://github.com/bpftrace/bpftrace/pull/2831) - Add a `jiffies` builtin for advanced usages - [#2769](https://github.com/bpftrace/bpftrace/pull/2769) - Emit better errors messages for invalid attachpoints - [#2781](https://github.com/bpftrace/bpftrace/pull/2781) - Add support for uprobe_multi link - [#2810](https://github.com/bpftrace/bpftrace/pull/2810) - Attach BTF to generated BPF programs - [#2804](https://github.com/bpftrace/bpftrace/pull/2804) - Add fentry/fexit aliases for kfunc/kretfunc - [#2844](https://github.com/bpftrace/bpftrace/pull/2844) - Add support for uprobe pid targeting - [#2830](https://github.com/bpftrace/bpftrace/pull/2830) - New builtin for getting the number of map elements - [#2840](https://github.com/bpftrace/bpftrace/pull/2840) - Add more helpful error messages for map operations - [#2905](https://github.com/bpftrace/bpftrace/pull/2905) - New config block syntax - [#2815](https://github.com/bpftrace/bpftrace/pull/2815) - Add support for kprobe:module:function - [#2897](https://github.com/bpftrace/bpftrace/pull/2897) #### Changed - Standardize config and env var names - [#2815](https://github.com/bpftrace/bpftrace/pull/2815) #### Deprecated #### Removed - Remove snapcraft support - [#2832](https://github.com/bpftrace/bpftrace/pull/2832) #### Fixed - Fix JSON output for cgroup_path - [#2793](https://github.com/bpftrace/bpftrace/pull/2793) - Fix silent truncation of 64-bit values in hist() - [#2822](https://github.com/bpftrace/bpftrace/pull/2822) - utils: use /data/local/tmp as temprary dir on Android - [#2828](https://github.com/bpftrace/bpftrace/pull/2828) - Fix uprobe multi probe for targets with wildcards - [#2851](https://github.com/bpftrace/bpftrace/pull/2851) - Fix symbolication on for 32-bit userspcae and 64-bit kernel - [#2869](https://github.com/bpftrace/bpftrace/pull/2869) - Fix retval for kretfunc/fexit - [#2864](https://github.com/bpftrace/bpftrace/pull/2864) - Fix attachment/listing of wildcarded module kfuncs - [#2914](https://github.com/bpftrace/bpftrace/pull/2914) - Fix uprobe attachment across container boundary - [#2662](https://github.com/bpftrace/bpftrace/pull/2662) - Fix generated BTF for older kernels - [#2934](https://github.com/bpftrace/bpftrace/pull/2934) #### Docs - Fix one-liner tutorial for systems with BTF - [#2919](https://github.com/bpftrace/bpftrace/pull/2919) - [#2924](https://github.com/bpftrace/bpftrace/pull/2924) #### Tools - Add PPID field to `execsnoop.bt` - [#2876](https://github.com/bpftrace/bpftrace/pull/2876) - Use `strftime` instead of `elapsed` in `execsnoop.bt` - [#2904](https://github.com/bpftrace/bpftrace/pull/2904) - Use `strftime` instead of `elapsed` in `threadsnoop.bt` - [#2917](https://github.com/bpftrace/bpftrace/pull/2917) - Increase PID field width and align to the right in `threadsnoop.bt` - [#2928](https://github.com/bpftrace/bpftrace/pull/2928) - Update runqlen.bt to remove `runnable_weight` field from cfs_rq struct. - [#2790](https://github.com/bpftrace/bpftrace/pull/2790) - Update mdflush.bt to use blkdev.h instead of genhd.h for non-BTF builds. - [#2849](https://github.com/bpftrace/bpftrace/pull/2849) - Add milliseconds to timestamp and align numbers to the right in `killsnoop.bt` - [#2936](https://github.com/bpftrace/bpftrace/pull/2936) ## [0.19.0] 2023-09-19 #### Added - Rawtracepoint support wildcards and list show - [#2588](https://github.com/bpftrace/bpftrace/pull/2588) - Support all iterators - [#2630](https://github.com/bpftrace/bpftrace/pull/2630) - Improve working with all probe params (kfunc, uprobe) - [#2477](https://github.com/bpftrace/bpftrace/pull/2477) - Support func builtin for k(ret)func probes - [#2692](https://github.com/bpftrace/bpftrace/pull/2692) - Support casting int <-> int array - [#2686](https://github.com/bpftrace/bpftrace/pull/2686) - Support targeting all running processes for USDTs - [#2734](https://github.com/bpftrace/bpftrace/pull/2734) - Support targeting all running processes for uprobes/uretprobes - [#2757](https://github.com/bpftrace/bpftrace/pull/2757) #### Changed - Make `args` a structure (instead of a pointer) - [#2578](https://github.com/bpftrace/bpftrace/pull/2578) - Improve user symbol resolution - [#2386](https://github.com/bpftrace/bpftrace/pull/2386) - uprobes: make C++ symbol demangling explicit - [#2657](https://github.com/bpftrace/bpftrace/pull/2657) - uprobe: improve C++ probes listing - [#2693](https://github.com/bpftrace/bpftrace/pull/2693) #### Removed - Delete embedded build support and surrounding infra - [#2742](https://github.com/bpftrace/bpftrace/pull/2742) #### Fixed - Fix resolving username for malformed /etc/passwd - [#2631](https://github.com/bpftrace/bpftrace/pull/2631) - Fix crashes when maps are concurrently modified - [#2623](https://github.com/bpftrace/bpftrace/pull/2623) - Fix alignment of byte arrays inside tuples - [#2625](https://github.com/bpftrace/bpftrace/pull/2625) - cmake: fix linking libbfd - [#2673](https://github.com/bpftrace/bpftrace/pull/2673) - Allow '+' in attach point path - [#2696](https://github.com/bpftrace/bpftrace/pull/2696) - Improve listing and 'probe' builtin for several probe types - [#2691](https://github.com/bpftrace/bpftrace/pull/2691) - Allow probe builtin with aliased software/hardware probes - [#2711](https://github.com/bpftrace/bpftrace/pull/2711) - Support executing symlinked binaries with `-c` - [#2708](https://github.com/bpftrace/bpftrace/pull/2708) - Add access to `CLOCK_MONOTONIC` with `nsecs(monotonic)` - [#2718](https://github.com/bpftrace/bpftrace/pull/2718) - iter: Skip structures with '__safe_trusted' suffix - [#2732](https://github.com/bpftrace/bpftrace/pull/2732) - Improve detection of unknown typedefs in ClangParser - [#2763](https://github.com/bpftrace/bpftrace/pull/2763) ## [0.18.0] 2023-05-15 #### Added - Add `iter:task_vma` iterators detection - [#2524](https://github.com/bpftrace/bpftrace/pull/2524) - Support parsing bitfields from BTF/DWARF - [#2505](https://github.com/bpftrace/bpftrace/pull/2505) - Support printing entire structs - [#2557](https://github.com/bpftrace/bpftrace/pull/2557) - BTF support for tracepoints defined in modules - [#2479](https://github.com/bpftrace/bpftrace/pull/2479) - Add trailer to truncated strings - [#2559](https://github.com/bpftrace/bpftrace/pull/2559) - Enable watchpoint support for PowerPC - [#2577](https://github.com/bpftrace/bpftrace/pull/2577) - Add new function, `offsetof`, get the offset of the element in the struct - [#2579](https://github.com/bpftrace/bpftrace/pull/2579) - Add 'StackMode::raw' for ustack and kstack formatting - [#2581](https://github.com/bpftrace/bpftrace/pull/2581) - Add 'BPFTRACE_STACK_MODE' env variable - [#2586](https://github.com/bpftrace/bpftrace/pull/2586) #### Changed - Improve attaching to uprobes with size 0 - [#2562](https://github.com/bpftrace/bpftrace/pull/2562) - Support ringbuf output - [#2475](https://github.com/bpftrace/bpftrace/pull/2475) #### Deprecated #### Removed #### Fixed - Simplify and fix probe index assignment - [#2482](https://github.com/bpftrace/bpftrace/pull/2482) - Handle colon in positional param used in attachpoint - [#2514](https://github.com/bpftrace/bpftrace/pull/2514) - Handle BPF load errors for multi-attachpoints - [#2521](https://github.com/bpftrace/bpftrace/pull/2521) - Respect BPFTRACE_STRLEN environment variable for all strings - [#2545](https://github.com/bpftrace/bpftrace/pull/2545) - Treat str() builtin's len parameter as int64 - [#2546](https://github.com/bpftrace/bpftrace/pull/2546) - arm64: define the KASAN_SHADOW_SCALE_SHIFT macro - [#2518](https://github.com/bpftrace/bpftrace/pull/2518) - Fix segfaults in dwarf_parser - [#2587](https://github.com/bpftrace/bpftrace/pull/2587) #### Docs #### Tools ## [0.17.0] 2023-01-30 #### Added - Support for 32-bit ARM systems - [#2360](https://github.com/bpftrace/bpftrace/pull/2360) - Support BTF for kernel modules - [#2315](https://github.com/bpftrace/bpftrace/pull/2315) - Add %rh option to print buffer as hex without \x - [#2445](https://github.com/bpftrace/bpftrace/pull/2445) - Add stdbool.h to built-in headers - [#2380](https://github.com/bpftrace/bpftrace/pull/2380) - Add `strcontains` builtin function, find a substring in a string - [#2393](https://github.com/bpftrace/bpftrace/pull/2393) #### Changed - Raise minimum versions for libbpf and bcc and vendor them for local builds - [#2369](https://github.com/bpftrace/bpftrace/pull/2369) - [#2370](https://github.com/bpftrace/bpftrace/pull/2370) - Support comparison for integer arrays - [#2387](https://github.com/bpftrace/bpftrace/pull/2387) #### Deprecated #### Removed - Drop Ubuntu 19.10 lockdown detection - [#2467](https://github.com/bpftrace/bpftrace/pull/2467) #### Fixed - Fix pointer/register loads on 32-bit architectures - [#2361](https://github.com/bpftrace/bpftrace/pull/2361) - Fix kprobe multi-attachment - [#2381](https://github.com/bpftrace/bpftrace/pull/2381) - Fix attaching to multiple USDT probes using the same wildcard - [#2456](https://github.com/bpftrace/bpftrace/pull/2456) - Fix pointer arithmetics codegen - [#2397](https://github.com/bpftrace/bpftrace/pull/2397) - Fix segfault for invalid AssignVarStatement visit - [#2423](https://github.com/bpftrace/bpftrace/pull/2423) - Better handling of missing function trace support files - [#2433](https://github.com/bpftrace/bpftrace/pull/2433) - Fix unroll ID reset - [#2439](https://github.com/bpftrace/bpftrace/pull/2439) - Support profile and interval probes in probe matcher - [#2443](https://github.com/bpftrace/bpftrace/pull/2443) - Fix BTF detection macro in tools/old/mdflush.bt - [#2444](https://github.com/bpftrace/bpftrace/pull/2444) #### Docs #### Tools ## [0.16.0] 2022-08-30 #### Added - Add builtin: `numaid` - [#2177](https://github.com/bpftrace/bpftrace/pull/2177) - Add helper verifier error handling - [#2279](https://github.com/bpftrace/bpftrace/pull/2279) - Add builtin: `pton` - [#2289](https://github.com/bpftrace/bpftrace/pull/2289) - Add builtin: `debugf` - [#2307](https://github.com/bpftrace/bpftrace/pull/2307) - Add builtin: `strerror` - [#2329](https://github.com/bpftrace/bpftrace/pull/2329) #### Changed - Move from BCC to libbpf - [#2265](https://github.com/bpftrace/bpftrace/pull/2265) - Add non-uprobe based BEGIN/END implementation - [#2264](https://github.com/bpftrace/bpftrace/pull/2264) - Helper errors (-k, -kk options) are now emitted to text or json output - [#2326](https://github.com/bpftrace/bpftrace/pull/2326) - kprobe offset verification is now optional, without requiring --unsafe - [#2332](https://github.com/bpftrace/bpftrace/pull/2332) #### Deprecated #### Removed #### Fixed - Disallow different lhist bounds in a single map - [#2204](https://github.com/bpftrace/bpftrace/pull/2204) - Serialize empty histogram as an empty JSON array - [#2250](https://github.com/bpftrace/bpftrace/pull/2250) - Handle enum values in tracepoint format defs - [#2236](https://github.com/bpftrace/bpftrace/pull/2236) - Fix compound assignments with non-unary expr - [#2291](https://github.com/bpftrace/bpftrace/pull/2293) - Fix invalid LLVM IR in join builtin - [#2296](https://github.com/bpftrace/bpftrace/pull/2296) - Fix lexer buffer size check - [#2313](https://github.com/bpftrace/bpftrace/pull/2313) - Fix invalid LLVM IR as detected by tests - [#2316](https://github.com/bpftrace/bpftrace/pull/2316) - Fix builds against libbfd(binutils) >=2.39 - [#2328](https://github.com/bpftrace/bpftrace/pull/2328) - Fix access to ctx - [#2343](https://github.com/bpftrace/bpftrace/pull/2343) #### Docs #### Tools - Add sslsnoop and ssllatency tools - [#2117](https://github.com/bpftrace/bpftrace/pull/2117) - Add undump tool. - [#2225](https://github.com/bpftrace/bpftrace/pull/2225) ## [0.15.0] 2022-05-24 The 0.15.0 release has basic support for LLVM 14 but not all features work yet, see [#2228](https://github.com/bpftrace/bpftrace/issues/2228) #### Added - Add option for unconditional hex output - [#2200](https://github.com/bpftrace/bpftrace/pull/2200) - Add builtin function: `cgroup_path` - [#2055](https://github.com/bpftrace/bpftrace/pull/2055) - Limit number of generated BPF programs - [#2141](https://github.com/bpftrace/bpftrace/pull/2141) - Support the octal format specifier (`%o`) in `printf` - [#2147](https://github.com/bpftrace/bpftrace/pull/2147) - Improve include paths resolution - [#2149](https://github.com/bpftrace/bpftrace/pull/2149) - Automatic type resolution from DWARF - [#2034](https://github.com/bpftrace/bpftrace/pull/2034) - Add builtin function: `bswap` - [#2166](https://github.com/bpftrace/bpftrace/pull/2166) - Print all maps to stdout on `SIGUSR1` - [#2203](https://github.com/bpftrace/bpftrace/pull/2203) - Add builtin function: `skb_output` - [#2223](https://github.com/bpftrace/bpftrace/pull/2223) #### Changed - Use auto-resolution of library paths for tools - [#2181](https://github.com/bpftrace/bpftrace/pull/2181) - Improve handling empty attach points - [#2179](https://github.com/bpftrace/bpftrace/pull/2179) #### Fixed - Fix precedence of multiplicative operations - [#2096](https://github.com/bpftrace/bpftrace/pull/2096) - Fix probe matching for uprobes with absolute address - [#2138](https://github.com/bpftrace/bpftrace/pull/2138) - Fix tools to work on new kernel versions - [#2136](https://github.com/bpftrace/bpftrace/pull/2136) - Fix uprobe target resolution - [#2180](https://github.com/bpftrace/bpftrace/pull/2180) - Fix using wildcards in kfunc - [#2208](https://github.com/bpftrace/bpftrace/pull/2208) - Improve handling of format strings - [#2164](https://github.com/bpftrace/bpftrace/pull/2164) - Fix codegen for buf - [#2217](https://github.com/bpftrace/bpftrace/pull/2217) #### Tools - Update biosnoop.bt for kernel >=5.17 - [#2207](https://github.com/bpftrace/bpftrace/pull/2207) ## [0.14.1] 2021-12-29 #### Fixed - Fix precedence of multiplicative operations - [#2096](https://github.com/bpftrace/bpftrace/pull/2096) ## [0.14.0] 2021-10-22 #### Added - Build time dependency on cereal - [#1893](https://github.com/bpftrace/bpftrace/pull/1893) - Build time dependency on asciidoctor for man page generation - [#1927] (https://github.com/bpftrace/bpftrace/pull/1927) - Support microsecond timestamps in stftime() - [#1922](https://github.com/bpftrace/bpftrace/pull/1922) - Add `_` as integer literal digit separator - [#1900](https://github.com/bpftrace/bpftrace/pull/1900) - Support for C style integer suffix in parser - [#1938](https://github.com/bpftrace/bpftrace/pull/1938) - Add C like pointer arithmetic - [#1881](https://github.com/bpftrace/bpftrace/pull/1881) - Automatic resolution of library paths for uprobes - [#1971](https://github.com/bpftrace/bpftrace/pull/1971) - Support positional parameters as integer literals - [#1982](https://github.com/bpftrace/bpftrace/pull/1982) - Access to uprobe arguments by name - [#1994](https://github.com/bpftrace/bpftrace/pull/1994) - Support variable strings size - [#2044](https://github.com/bpftrace/bpftrace/pull/2044) #### Changed - Prevent LLVM from unrolling loops - [#1967](https://github.com/bpftrace/bpftrace/pull/1967) #### Deprecated #### Removed #### Fixed - Fix memory leaks in struct types - [#1885](https://github.com/bpftrace/bpftrace/pull/1885) - Fix strncmp() when N is bigger than on-stack buffer - [#1974](https://github.com/bpftrace/bpftrace/pull/1974) - Fix strncmp() to check for NUL terminator - [#1974](https://github.com/bpftrace/bpftrace/pull/1974) - Fix unroll() with async calls - [#1972](https://github.com/bpftrace/bpftrace/pull/1972) - Fix string comparison codegen - [#1979](https://github.com/bpftrace/bpftrace/pull/1979) - Fix verifier error when accessing same tracepoint field twice - [#2008](https://github.com/bpftrace/bpftrace/pull/2008) - Fix reading too many bits for <64 bit kfunc args - [#2014](https://github.com/bpftrace/bpftrace/pull/2014) - Fix misaligned stack access for map keys - [#2012](https://github.com/bpftrace/bpftrace/pull/2012) #### Tools #### Documentation - Write new man page for `bpftrace(8)` - [#1711](https://github.com/bpftrace/bpftrace/pull/1711) ## [0.13.1] 2021-12-29 #### Fixed - Fix precedence of multiplicative operations - [#2096](https://github.com/bpftrace/bpftrace/pull/2096) ## [0.13.0] 2021-07-01 #### Added - Warn if attaching a kprobe to a non-traceable function - [#1835](https://github.com/bpftrace/bpftrace/pull/1835) - Support for `-k[k]` and `elapsed` in `iter` probes - [#1882](https://github.com/bpftrace/bpftrace/pull/1882) #### Changed - Disallow accessing common tracepoint fields - [#1810](https://github.com/bpftrace/bpftrace/pull/1810) - Improve JSON printing (nested structs) - [#1778](https://github.com/bpftrace/bpftrace/pull/1778) - Return 1 from tracepoint probes - [#1857](https://github.com/bpftrace/bpftrace/pull/1857) - Preserve original order of struct types - [#1850](https://github.com/bpftrace/bpftrace/pull/1850) - Forbid casting from/to struct types - [#1873](https://github.com/bpftrace/bpftrace/pull/1873) #### Deprecated #### Removed #### Fixed - Fix single arg wildcard probe listing - [#1775](https://github.com/bpftrace/bpftrace/pull/1775) - Fix --info reporting wrong libbpf build info - [#1776](https://github.com/bpftrace/bpftrace/pull/1776) - Reduce frequency of lost stack traces - [#1812](https://github.com/bpftrace/bpftrace/pull/1812) - Make kaddr() report failure for unknown kernel symbols - [#1836](https://github.com/bpftrace/bpftrace/pull/1836) - Fix false non-traceable function warnings - [#1866](https://github.com/bpftrace/bpftrace/pull/1866) - Fix memory leak in clang parser - [#1878](https://github.com/bpftrace/bpftrace/pull/1878) #### Tools #### Documentation ## [0.12.1] 2021-04-16 Incorrect --info output bug fix release ## [0.12.0] 2021-04-01 #### Added - Add path builtin - [#1492](https://github.com/bpftrace/bpftrace/pull/1492) - Allow wildcards for tracepoint categories - [#1445](https://github.com/bpftrace/bpftrace/pull/1445) - Add wildcard support for kfunc probe types - [#1410](https://github.com/bpftrace/bpftrace/pull/1410) - Add builtin function: `strftime` - [#1387](https://github.com/bpftrace/bpftrace/pull/1387) - Fix `printf` not allowing format specifiers to be directly followed by alphabetic characters - [#1414](https://github.com/bpftrace/bpftrace/pull/1414) - Fix `top` and `div` arguments of `print()` not working for Type::avg maps - [#1416](https://github.com/bpftrace/bpftrace/pull/1416) - Add an option to disable warning messages - [#1444](https://github.com/bpftrace/bpftrace/pull/1444) - Support scientific notation for integer literals - [#1476](https://github.com/bpftrace/bpftrace/pull/1476) - List retprobes - [#1484](https://github.com/bpftrace/bpftrace/pull/1484) - Resolve unknown typedefs using BTF and give a hint when a type cannot be found - [#1485](https://github.com/bpftrace/bpftrace/pull/1485) - Support multi-matched globbed targets for uprobe and ustd probes - [#1499](https://github.com/bpftrace/bpftrace/pull/1499) - Positional parameters: support numbers as strings and params as string literals - [#1514](https://github.com/bpftrace/bpftrace/pull/1514) - Support for tracepoint __data_loc fields - [#1542](https://github.com/bpftrace/bpftrace/pull/1542) - Set addrspace info for various builtins - [#1504](https://github.com/bpftrace/bpftrace/pull/1504) - Support watchpoint for kernel space address - [#1552](https://github.com/bpftrace/bpftrace/pull/1552) - Support for pointer to pointer - [#1557](https://github.com/bpftrace/bpftrace/pull/1557) - Support for uprobe refcounts - [#1567](https://github.com/bpftrace/bpftrace/pull/1567) - Add basic options and documentations for fuzzing - [#1601](https://github.com/bpftrace/bpftrace/pull/1601) - Disable `str($# + 1)` - [#1619](https://github.com/bpftrace/bpftrace/issues/1619) - Array improvements (support assignment to variables and usage as a map key) - [#1656](https://github.com/bpftrace/bpftrace/pull/1656) - Add builtin function: `macaddr` - [#1647](https://github.com/bpftrace/bpftrace/pull/1647) - Add support for usdt arguments utilising the index register and scale - [#1684](https://github.com/bpftrace/bpftrace/pull/1684) - Add basic mips64 support - [#1599](https://github.com/bpftrace/bpftrace/pull/1599) - Printing structures - [#1705](https://github.com/bpftrace/bpftrace/pull/1705) - Array indexing on pointers - [#1739](https://github.com/bpftrace/bpftrace/pull/1739) #### Changed - Warn if using `print` on `stats` maps with top and div arguments - [#1433](https://github.com/bpftrace/bpftrace/pull/1433) - Prefer BTF data if available to resolve tracepoint arguments - [#1439](https://github.com/bpftrace/bpftrace/pull/1439) - Improve error messages for kfunc probe types - [#1451](https://github.com/bpftrace/bpftrace/pull/1451) - Better handling of empty usdt namespaces - [#1486](https://github.com/bpftrace/bpftrace/pull/1486) - Switch `nsecs` to `ktime_get_boot_ns` - [#1475](https://github.com/bpftrace/bpftrace/pull/1475) - Tracepoint __data_loc fields are renamed from `args->data_loc_name` to `args->name` - [#1542](https://github.com/bpftrace/bpftrace/pull/1542) - Change a part of the message of '-v' output - [#1553](https://github.com/bpftrace/bpftrace/pull/1553) - Improve tuple assignment error message - [#1563](https://github.com/bpftrace/bpftrace/pull/1563) - Remove "BTF: using data from ..." message when using -v flag - [#1554](https://github.com/bpftrace/bpftrace/pull/1554) - Add -q option for quiet - [#1616](https://github.com/bpftrace/bpftrace/pull/1616) - Optimize unknown/incomplete types resolution - [#1571](https://github.com/bpftrace/bpftrace/pull/1571) - Do not check size of the format string of `printf` - [#1538](https://github.com/bpftrace/bpftrace/pull/1538) - Unify semantics of wildcards in probe listing and attachement - [#1549](https://github.com/bpftrace/bpftrace/pull/1549) - Improve codegen for structs and arrays - [#1705](https://github.com/bpftrace/bpftrace/pull/1705) - Do not unpack in-kernel headers if system has BTF - [#1740](https://github.com/bpftrace/bpftrace/pull/1740) #### Deprecated #### Removed - Disable some kfunc probes whose tracing crashes - [#1432](https://github.com/bpftrace/bpftrace/pull/1432) #### Fixed - Fix negative overflow bug and unstable tests in PR #1416 - [#1436](https://github.com/bpftrace/bpftrace/pull/1436) - Fix `print` outputs nothing when used on hist() maps with large top args - [#1437](https://github.com/bpftrace/bpftrace/pull/1437) - Fix array indexing regression - [#1457](https://github.com/bpftrace/bpftrace/pull/1457) - Fix type resolution for struct field access via variables - [#1450](https://github.com/bpftrace/bpftrace/pull/1450) - Fix wrong setting of vmlinux_location.raw when offset kprobe used - [#1530](https://github.com/bpftrace/bpftrace/pull/1530) - Fix pointer arithmetic for positional parameters - [#1514](https://github.com/bpftrace/bpftrace/pull/1514) - SEGV when using perf format for stacks - [#1524](https://github.com/bpftrace/bpftrace/pull/1524) - Fix llvm errors of PositonalParameter - [#1565](https://github.com/bpftrace/bpftrace/pull/1565) - Error if Positional Params num is zero - [#1568](https://github.com/bpftrace/bpftrace/issues/1568) - Fix LNOT - [#1570](https://github.com/bpftrace/bpftrace/pull/1570) - Fix invalid cast handling in tuple - [#1572](https://github.com/bpftrace/bpftrace/pull/1572) - Check string comparison size - [#1573](https://github.com/bpftrace/bpftrace/pull/1573) - Fix a possible integer overflow - [#1580](https://github.com/bpftrace/bpftrace/pull/1580) - Printing of small integers with `printf` - [#1532](https://github.com/bpftrace/bpftrace/pull/1532) - Fix bitfield access for big endian - [#1628](https://github.com/bpftrace/bpftrace/pull/1628) - Error if using negative length in str() and buf() - [#1621](https://github.com/bpftrace/bpftrace/pull/1621) - Only create int type Identifier when it is used in sizeof() - [#1622](https://github.com/bpftrace/bpftrace/pull/1622) - Check exponent value can be expressed in uint64_t - [#1623](https://github.com/bpftrace/bpftrace/pull/1623) - Fix tracing of usdt probes across namespaces - [#1637](https://github.com/bpftrace/bpftrace/pull/1637) - Disable reg() for kfunc - [#1646](https://github.com/bpftrace/bpftrace/pull/1646) - Fix several undefined behavior - [#1645](https://github.com/bpftrace/bpftrace/pull/1645) - Fix invalid size crash when using strftime() inside a tuple - [#1658](https://github.com/bpftrace/bpftrace/pull/1658) - Don't create a tuple if an element size if zero - [#1653](https://github.com/bpftrace/bpftrace/pull/1653) - Support clear() and delete() on a count()-based map without a key - [#1639](https://github.com/bpftrace/bpftrace/pull/1639) - Add workaround for too deep or long macros - [#1650](https://github.com/bpftrace/bpftrace/pull/1650) - Fix attaching to usdt probes in shared libraries - [#1600](https://github.com/bpftrace/bpftrace/pull/1600) - Fix attaching to multiple usdt probe locations with the same label - [#1681](https://github.com/bpftrace/bpftrace/pull/1681) - Fix signed extension of usdt arguments to the internal 64-bit integer type - [#1684](https://github.com/bpftrace/bpftrace/pull/1684) #### Tools - Hook up execsnoop.bt script onto `execveat` call - [#1490](https://github.com/bpftrace/bpftrace/pull/1490) - Support new capabilities for capable.bt - [#1498](https://github.com/bpftrace/bpftrace/pull/1498) - Add disk field to biosnoop - [#1660](https://github.com/bpftrace/bpftrace/pull/1660) #### Documentation - Document uptr() and kptr() function - [#1626](https://github.com/bpftrace/bpftrace/pull/1626) ## [0.11.4] 2020-11-14 Alpine build bug fix release ## [0.11.3] 2020-11-13 bcc 0.17 support release ### Changed Detect 7 arg bpf_attach_uprobe() API - [#1589](https://github.com/bpftrace/bpftrace/pull/1589) ## [0.11.2] 2020-10-30 LLVM 11 support release ### Added Add LLVM11 build support - [#1578](https://github.com/bpftrace/bpftrace/pull/1578) ## [0.11.1] 2020-09-22 Bug fix release for the [Docker build](https://quay.io/repository/bpftrace/bpftrace) ### Fixed - Don't strip END_trigger - [#1513](https://github.com/bpftrace/bpftrace/pull/1513) ## [0.11.0] 2020-07-15 ### All Changes #### Added - Allow uprobe placement on arbitrary addresses when --unsafe is used - [#1388](https://github.com/bpftrace/bpftrace/pull/1388) - Support for s390x - [#1241](https://github.com/bpftrace/bpftrace/pull/1241) - `buf` a new function that makes it possible to safely print arbitrary binary data - [#1107](https://github.com/bpftrace/bpftrace/pull/1107) - A new function, `sizeof`, which returns the size of an expression, similar to `sizeof` in C - [#1269](https://github.com/bpftrace/bpftrace/pull/1269) - C style while loop support, `while ($a < 100) { $a++ }` - [#1066](https://github.com/bpftrace/bpftrace/pull/1066) - Using a BTF enum value will pull in the entire enum definition - [#1274](https://github.com/bpftrace/bpftrace/pull/1274) - Add support of using positional params in unroll and increase the unroll limit to 100 - [#1286](https://github.com/bpftrace/bpftrace/pull/1286) - Support for piping scripts in via stdin - [#1310](https://github.com/bpftrace/bpftrace/pull/1310) - Don't require if --btf is specified - [#1315](https://github.com/bpftrace/bpftrace/pull/1315) - Silence errors about `modprobe` not being found - [#1314](https://github.com/bpftrace/bpftrace/pull/1314) - With --btf, do not use for resolving tracepoint defs - [#1318](https://github.com/bpftrace/bpftrace/pull/1318) - Add environment variable, BPFTRACE_PERF_RB_PAGES, to tune perf ring buffer size - [#1329](https://github.com/bpftrace/bpftrace/pull/1329) - Add --usdt-file-activation to activate usdt semaphores by file name - [#1317](https://github.com/bpftrace/bpftrace/pull/1317) - Introduce `-k` and `-kk` options. Emit a warning when a bpf helper returns an error - [#1276](https://github.com/bpftrace/bpftrace/pull/1276) - Add tuples to language - [#1326](https://github.com/bpftrace/bpftrace/pull/1326) - Add support for listing struct/union/enum definitions using BTF - [#1340](https://github.com/bpftrace/bpftrace/pull/1340) - Add libbpf build into in --info - [#1367](https://github.com/bpftrace/bpftrace/pull/1367) - Add support for time units `us` and `hz` for probe `interval` - [#1377](https://github.com/bpftrace/bpftrace/pull/1377) - Add support for non-map print() - [#1381](https://github.com/bpftrace/bpftrace/pull/1381) - Enable `printf`, `cat` and `system` to have more than 7 arguments - [#1404](https://github.com/bpftrace/bpftrace/pull/1404) - Enable the `ternary` operator to evaluate builtin calls - [#1405](https://github.com/bpftrace/bpftrace/pull/1405) #### Changed - Require C++17 and CMake 3.8 for building bpftrace - [#1200](https://github.com/bpftrace/bpftrace/pull/1200) - [#1259](https://github.com/bpftrace/bpftrace/pull/1259) - Allow positional parameters in probe attachpoint definitions - [#1328](https://github.com/bpftrace/bpftrace/pull/1328) - Only list uprobe and usdt probes when `-p` is given - [#1340](https://github.com/bpftrace/bpftrace/pull/1340) - Remove address space memory limit - [#1358](https://github.com/bpftrace/bpftrace/pull/1358) #### Deprecated #### Removed - Drop LLVM 5 support - [#1215](https://github.com/bpftrace/bpftrace/issues/1215) - Remove the --btf option - [#1669](https://github.com/bpftrace/bpftrace/pull/1669) #### Fixed - Various big endian related fixes - [#1241](https://github.com/bpftrace/bpftrace/pull/1241) - Type check the `cond` of if and ternary statements - [#1229](https://github.com/bpftrace/bpftrace/pull/1229) - Fix usdt reads in various architecture - [#1325](https://github.com/bpftrace/bpftrace/pull/1325) - Attach to duplicated USDT markers - [#1341](https://github.com/bpftrace/bpftrace/pull/1341) - Fix `KBUILD_MODNAME` - [#1352](https://github.com/bpftrace/bpftrace/pull/1352) - Fix `ntop()` not accepting tracepoint arguments - [#1365](https://github.com/bpftrace/bpftrace/pull/1365) - Fix attaching to usdt probes in multiple binaries - [#1356](https://github.com/bpftrace/bpftrace/pull/1356) - Decrement usdt semaphore count after bpftrace execution - [#1370](https://github.com/bpftrace/bpftrace/pull/1370) - Reduce high memory consumption when using usdt semaphore - [#1374](https://github.com/bpftrace/bpftrace/pull/1374) - Remove registers that are not in struct pt_regs (x86-64) - [#1383](https://github.com/bpftrace/bpftrace/issues/1383) - Ignore trailing kernel module annotation for k[ret]probe's - [#1413](https://github.com/bpftrace/bpftrace/pull/1413) #### Tools #### Documentation - Clean up README - [#1273](https://github.com/bpftrace/bpftrace/pull/1273) - Add missing `struct` keyword to examples in the one liner tutorial - [#1275](https://github.com/bpftrace/bpftrace/pull/1275) ## [0.10.0] 2020-04-12 ### Highlights #### kfuncs Improved kprobes which are near zero overhead and use BTF to derive argument names and types: ``` bpftrace -e 'kfunc:fget { printf("fd %d\n", args->fd); }' ``` #### C++ Symbol demangling bpftrace can now demangle C++ symbols in binaries: ``` bpftrace -e 'uprobe:./a.out:"foo()" {printf("ok\n");} ``` #### if else control flow Support for `if else` has been added, making it possible to write: ``` if (cond) { ... } else if (cond) { ... } ``` Instead of: ``` if (cond) { ... } else { if (cond) { ... } } ``` #### LLVM 9 & 10 Support for LLVM 9 and LLVM 10 has been added. #### Docker images Docker images containing a static build are now available on [quay.io](https://quay.io/repository/bpftrace/bpftrace). ### All Changes #### Added - Add kfunc/kretfunc description to docs/reference_guide.md (e3b9518b) by Jiri Olsa <jolsa@kernel.org> - Add kfunc/kretfunc probe tests (bbf2083a) by Jiri Olsa <jolsa@kernel.org> - Add test_btf class to setup BTF data (ecbd66b7) by Jiri Olsa <jolsa@kernel.org> - Fortify exported functions with has_data check (083bcf9f) by Jiri Olsa <jolsa@kernel.org> - Detect btf feature via BTF class (a9450425) by Jiri Olsa <jolsa@kernel.org> - Add support to filter kfunc list (a98b3f02) by Jiri Olsa <jolsa@kernel.org> - List kfunc functions (75a0f9c7) by Jiri Olsa <jolsa@kernel.org> - Generate load code for kfunc/kretfunc arguments (30f699b1) by Jiri Olsa <jolsa@kernel.org> - Resolve kfunc arguments in semantic analyser (de2f6c1d) by Jiri Olsa <jolsa@kernel.org> - Resolve kfunc arguments in BTF field analyser (8cd3fb50) by Jiri Olsa <jolsa@kernel.org> - Add single_provider_type function (3a6325e5) by Jiri Olsa <jolsa@kernel.org> - Factor out builtin_args_tracepoint function (e33c246e) by Jiri Olsa <jolsa@kernel.org> - Add BTF::resolve_args function to resolve kfunc arguments (69c8fd45) by Jiri Olsa <jolsa@kernel.org> - Load and attach kfunc/kretfunc programs (126a9edd) by Jiri Olsa <jolsa@kernel.org> - Add missing ProbeType::watchpoint to probetypeName function (343165b1) by Jiri Olsa <jolsa@kernel.org> - Allow to specify kernel include dirs (1e987f45) by Jiri Olsa <jolsa@kernel.org> - Feature detect `probe_read_{kernel,user}` (b7c236f9) by bas smit <bas@baslab.org> - Add support for using demangled symbols in uretprobe names (269033de) by Masanori Misono <m.misono760@gmail.com> - Implement `else if` control flow (34fc2801) by Daniel Xu <dxu@dxuuu.xyz> - detect lockdown mode (37d28c26) by bas smit <bas@baslab.org> - Extend info flag with system/build info (73abef68) by bas smit <bas@baslab.org> - Add support for C++ mangled symbols in uprobe names #687 (e8656cbd) by Augusto Caringi <acaringi@redhat.com> #### Changed - Allow hex/octal positional parameters (ef20128b) by bas smit <bas@baslab.org> - Allow negative positional parameters (babf057e) by bas smit <bas@baslab.org> - Make positionalparameters literal to avoid warnings (0859fc6b) by bas smit <bas@baslab.org> - Make `exit()` terminate current probe (6334c23d) by bas smit <bas@baslab.org> - Improve an error message when trying to use 'args' other than tracepoint (e303048c) by Masanori Misono <m.misono760@gmail.com> - Disable a symbol name cache if ASLR is enabled and `-c` option is not given (4651255b) by Masanori Misono <m.misono760@gmail.com> - Remove deprecated builtins (2667b8a2) by bas smit <bas@baslab.org> #### Fixed - reject invalid pid argument (cebc5978) by bas smit <bas@baslab.org> - Fix positional parameter error (1b4febee) by bas smit <bas@baslab.org> - Emit better tracepoint parser errors (f5217821) by Daniel Xu <dxu@dxuuu.xyz> - Fix if comparison (8f8c9cb4) by Masanori Misono <m.misono760@gmail.com> - Do not keep open BEGIN/END probes (19d90057) by Jiri Olsa <jolsa@kernel.org> - Check the length of ap.mode (a388dc14) by Masanori Misono <m.misono760@gmail.com> - Fix ternary comparison (360be8cf) by Masanori Misono <m.misono760@gmail.com> - Cast LNOT result (890f5930) by Masanori Misono <m.misono760@gmail.com> - Gracefully handle long position param overflow (6f26a863) by Vlad Artamonov <742047+vladdy@users.noreply.github.com> - Error if wildcards are used in "category" of tracepoint (3bfdec94) by Masanori Misono <m.misono760@gmail.com> - Fix reading USDT probe arguments on AArch64 (ee5314ba) by Nick Gasson <nick.gasson@arm.com> - Remove type qualifiers from a cast_type (4ad2bf19) by Masanori Misono <m.misono760@gmail.com> - Fix printf argument offsets (2d2f2332) by Alastair Robertson <alastair@ajor.co.uk> - Warn if Type::string size is not matched when assignment (4638b968) by Masanori Misono <m.misono760@gmail.com> - Print Type::string and Type::array size information along with type information (03a837e7) by Masanori Misono <m.misono760@gmail.com> - Consider a short Type::string value (684513ed) by Masanori Misono <m.misono760@gmail.com> - Consider a non null-terminated Type::string value (13614152) by Masanori Misono <m.misono760@gmail.com> #### Tools - oomkill: fix kprobe arg (675727a4) by Xiaozhou Liu <liuxiaozhou@bytedance.com> - Fix 'signed operands for /' warning in naptime.bt (c8f4a6d8) by Augusto Caringi <acaringi@redhat.com> #### Documentation - Fix example links to only search bpftrace repo (71c9d29e) by Martin Schmidt <martin.schmidt@epita.fr> - Remove example link to a runtime test (560454a1) by Martin Schmidt <martin.schmidt@epita.fr> - Add link to example for interval and BEGIN/END (badf5653) by Martin Schmidt <martin.schmidt@epita.fr> - Add link to example for profile (ea6f706a) by Martin Schmidt <martin.schmidt@epita.fr> - Add links to examples for tracepoints (f6a3d26a) by Martin Schmidt <martin.schmidt@epita.fr> - Add links to examples for uprobe/uretprobe (5dd4bd8d) by Martin Schmidt <martin.schmidt@epita.fr> - Add links to examples for kprobe/kretprobe (c580ef26) by Martin Schmidt <martin.schmidt@epita.fr> - When installing from source on ubuntu and Fedora, non-root users need to add 'sudo' when executing 'make install' (3030046b) by mazhen <mz1999@gmail.com> - docs: Add documentation for integer casts (f087abbd) by Daniel Xu <dxu@dxuuu.xyz> - Docs: Fix broken link (f76b8bbb) by Adam Jensen <acjensen@gmail.com> - Docs: Add missing builtin functions (fd08a932) by Adam Jensen <acjensen@gmail.com> #### Internal - Remove codegen tests warning (f18746af) by bas smit <bas@baslab.org> - build: document libbcc linking (#1252) (4dadd515) by bas smit <bas@baslab.org> - cmake: bail on unsupported architectures (4ae387f0) by Daniel Xu <dxu@dxuuu.xyz> - Revert "Only link agains libbpf if it exists (#1247)" (04ecb731) by bas smit <bas@baslab.org> - Only link agains libbpf if it exists (#1247) (a3febcb8) by bas smit <bas@baslab.org> - Align libbpf.h (229eef6c) by bas smit <bas@baslab.org> - Sync libbpf with v5.6 (0b369fe6) by bas smit <bas@baslab.org> - Add runtime tests for ternary (2efcdb29) by Masanori Misono <m.misono760@gmail.com> - Use BPFtrace::error for TracepointFormatParser errors (#1243) (9106e10c) by Martin Schmidt <martin.schmidt@epita.fr> - codegen: Send map id instead of ident string for async events (9a063adc) by bas smit <bas@baslab.org> - ci: Add LLVM 10 (696e16ce) by Masanori Misono <m.misono760@gmail.com> - Add codegen test for LLVM 10 (33fe3ee4) by Masanori Misono <m.misono760@gmail.com> - Suppress -Winconsistent-missing-override warning (2044c53d) by Masanori Misono <m.misono760@gmail.com> - Use CreateMemCpy that takes MaybeAlign in LLVM 10 (a67fd22d) by Masanori Misono <m.misono760@gmail.com> - Don't over-read usdt arguments (1711ec70) by Daniel Xu <dxu@dxuuu.xyz> - Add proper bcc prefix for bcc headers (977d5851) by Jiri Olsa <jolsa@kernel.org> - Use urandom instead of random (23603bfc) by Masanori Misono <m.misono760@gmail.com> - tests: fix llmv 5 tests (449b33a4) by bas smit <bas@baslab.org> - codegen: correctly copy and "usym" map (f7a9d9e2) by bas smit <bas@baslab.org> - codegen: Use map type in perf_event signature (0a27eeb5) by bas smit <bas@baslab.org> - codegen: avoid usym copy on map assignment (25116d21) by bas smit <bas@baslab.org> - codegen: deduplicate usym code (078a8236) by bas smit <bas@baslab.org> - codegen: fix `strncmp` type issues (e523e2c7) by bas smit <bas@baslab.org> - codegen: ensure `getmapkey` stores with equal types (1822cfde) by bas smit <bas@baslab.org> - codegen: fix deleteElem typing issues (0c6403bc) by bas smit <bas@baslab.org> - codegen: clang-format `join` (e641b115) by bas smit <bas@baslab.org> - codegen: memset takes an i8 value (d2a70f98) by bas smit <bas@baslab.org> - codegen: remove useless literal handling from `signal` (3bbbfe24) by bas smit <bas@baslab.org> - codegen: fix `probe_read` typing issue (eca43df2) by bas smit <bas@baslab.org> - codegen: fix sarg type issue (09152138) by bas smit <bas@baslab.org> - codegen: fix `probe_read_str` typing issues (914c87e2) by bas smit <bas@baslab.org> - codegen: fix reg typing issue (0c66f2f5) by bas smit <bas@baslab.org> - parser: Do not remove empty probe arguments (ae4fe7fb) by Daniel Xu <dxu@dxuuu.xyz> - cmake: Link against libz when searching for btf_dump__new (6323d8fb) by Daniel Xu <dxu@dxuuu.xyz> - snapcraft: add arm64 to build architectures (2b0faa3e) by Colin Ian King <colin.king@canonical.com> - cmake: Control manpages generation (ef39ed0f) by Ovidiu Panait <ovpanait@gmail.com> - Don't check str arg length for cgroupid (aa94d9b3) by Chris Hunt <chrahunt@gmail.com> - Track current function name during analysis (d1f23cab) by Chris Hunt <chrahunt@gmail.com> - Remove unused srclines_ (ce9c4179) by Chris Hunt <chrahunt@gmail.com> - Remove unused print_map_lhist (7c32b827) by Chris Hunt <chrahunt@gmail.com> - Remove leftover print_hist declaration (63f4f029) by Chris Hunt <chrahunt@gmail.com> - Remove leftover print_lhist declaration (8008c5a9) by Chris Hunt <chrahunt@gmail.com> - Add apt-transport-https for xenial build (8bcf0c04) by Dale Hamel <dale.hamel@shopify.com> - Add the snapcraft yaml rules to allow bpftrace to be built as a snap. (c2eceeb3) by Colin Ian King <colin.king@canonical.com> - Revert "Require C++17 to build" (24f97308) by bas smit <bas@baslab.org> - Fix tracepoint expansion regression (b4f0c204) by Daniel Xu <dxu@dxuuu.xyz> - codegen: fix `map` typing (11814f29) by bas smit <bas@baslab.org> - codegen: Update LLVM5 codegen tests (c4f147d3) by bas smit <bas@baslab.org> - codegen: fix argX type issue (c04bad20) by bas smit <bas@baslab.org> - codegen: Fix comm typing issues (5926429d) by bas smit <bas@baslab.org> - codegen: Fix stackid typing issues (a7ba4a1e) by bas smit <bas@baslab.org> - codegen: Fix exit typing issues (f676b9c5) by bas smit <bas@baslab.org> - codegen: Fix ntop typing issues (ac792f58) by bas smit <bas@baslab.org> - codegen: Fix usym typing issues (2e84b52d) by bas smit <bas@baslab.org> - irbuilder: Add struct storage (1fbccf1b) by bas smit <bas@baslab.org> - Strengthen tracepoint format parsing (a2e3d5db) by Jiri Olsa <jolsa@kernel.org> - cmake: use *_LIBRARIES when testing for libbfd version (b1200771) by Daniel Xu <dxu@dxuuu.xyz> - Handle escaped double quotes in AttachPointParser (b98b281d) by Daniel Xu <dxu@dxuuu.xyz> - Support `:`s in quoted string (c230fc42) by Daniel Xu <dxu@dxuuu.xyz> - Add parser tests for trailing non-numeric characters (c0b8644f) by Daniel Xu <dxu@dxuuu.xyz> - Update AttachPoint::name to print out watchpoints correctly (dd2312c7) by Daniel Xu <dxu@dxuuu.xyz> - Unify ast::AttachPoint::addr and ast::AttachPoint::address (71f4205f) by Daniel Xu <dxu@dxuuu.xyz> - Fix semantic analyser unit tests (39d4a493) by Daniel Xu <dxu@dxuuu.xyz> - Fix runtime tests (1612af97) by Daniel Xu <dxu@dxuuu.xyz> - Update callee interfaces (78c04b01) by Daniel Xu <dxu@dxuuu.xyz> - Move AttachPoint parsing logic out of bison (43a72e37) by Daniel Xu <dxu@dxuuu.xyz> - tests: cmake: Fix build with ninja (f1fc5190) by Ovidiu Panait <ovpanait@gmail.com> - bpffeature: move macros to header (860ac6d4) by bas smit <bas@baslab.org> - bpffeature: delete copy/move constructors/assign (ac5e0025) by bas smit <bas@baslab.org> - bpffeature: cleanup `report` (af780eb1) by bas smit <bas@baslab.org> - bpffeature: detect supported program types (ce5bbb78) by bas smit <bas@baslab.org> - bpffeature: detect supported map types (437df58d) by bas smit <bas@baslab.org> - bpffeature: remove boilerplate (ac4ad41c) by bas smit <bas@baslab.org> - Avoid calling "slow" regex constructor (fc88784e) by bas smit <bas@baslab.org> - CreateMemSet: llvm10: Fix compilation errors (6f81111c) by Ovidiu Panait <ovidiu.panait@windriver.com> - Discard return value for emitAndFinalize() (29caf4b7) by Daniel Xu <dxu@dxuuu.xyz> - Require C++17 to build (458bf66d) by Daniel Xu <dxu@dxuuu.xyz> - Make docker run command more generic (#1182) (c67730c4) by Connor Nelson <Connor@ConnorNelson.com> - Use host network when building docker image (23c29ff1) by Daniel Xu <dxu@dxuuu.xyz> - fix typo (92f25f95) by zeil <nonamezeil@gmail.com> - Resolve USDT binaries relative to mount namespace (3bb4a9fd) by Dale Hamel <dale.hamel@shopify.com> - Add docker images as options in install.md (30756be7) by Dale Hamel <dale.hamel@srvthe.net> - Add "edge" build, push master to :latest and :edge (b0e6bdc7) by Dale Hamel <dale.hamel@shopify.com> - ast: add missing parameter name (f156a0fb) by bas smit <bas@baslab.org> - Add the Japanese translation version of the one-liner tutorial (78621fb1) by Masanori Misono <m.misono760@gmail.com> - Revert "No need to promote scalars to 64-bit" (9a9d1451) by Dale Hamel <dale.hamel@shopify.com> - fix build error (ed48e795) by bas smit <bas@baslab.org> - Make BEFORE clause in runtime tests synchronous (77f93dbc) by Dale Hamel <dale.hamel@shopify.com> - Only need to rebuild codegen tests if C++ files change (d0792c06) by Alastair Robertson <alastair@ajor.co.uk> - Replace tabs with spaces (f4e377a1) by Alastair Robertson <alastair@ajor.co.uk> - No need to promote scalars to 64-bit (8af25ae9) by Alastair Robertson <alastair@ajor.co.uk> - Regenerate codegen_includes.cpp when files it references are updated (d6d0e836) by Alastair Robertson <alastair@ajor.co.uk> - ci: Add LLVM 9 (42dab3c9) by bas smit <bas@baslab.org> - codegen: add LLVM-9 rewriter exceptions (681d1850) by bas smit <bas@baslab.org> - codegen: LLVM9 rewriter (3ec8af95) by bas smit <bas@baslab.org> - codegen: Rewrite tests (aefc89e7) by bas smit <bas@baslab.org> - codegen: Remove version dependence from codegen (cd3ab819) by bas smit <bas@baslab.org> - Add STATIC_LIBC=ON to Docker build scripts (6ef3af3c) by Alastair Robertson <alastair@ajor.co.uk> - Support pushing docker images to quay.io from github actions (b8ab21ae) by Dale Hamel <dale.hamel@shopify.com> - Add xenial to CI build (153e61ef) by Ace Eldeib <alexeldeib@gmail.com> - Only send IRC notifications for build failures on master (471e79b7) by Alastair Robertson <alastair@ajor.co.uk> - vagrant: fix formatting (e8a14566) by bas smit <bas@baslab.org> - vagrant: Add fedora 31 (c2354a78) by bas smit <bas@baslab.org> - vagrant: Update ubuntu boxes (9610895c) by bas smit <bas@baslab.org> - Add Dockerfile.release for bpftrace docker image on quay.io (c2568ee5) by Dale Hamel <dale.hamel@shopify.com> - Mark context accesses as volatile (56d4721e) by Masanori Misono <m.misono760@gmail.com> - Cast ctx automatically depending on a program type (0e4282e1) by Masanori Misono <m.misono760@gmail.com> - Access context fields directly (3a910814) by Masanori Misono <m.misono760@gmail.com> - Error if trying to use context as a map key/value (b7d2510b) by Masanori Misono <m.misono760@gmail.com> - Introduce Type::ctx (f05b4cda) by Masanori Misono <m.misono760@gmail.com> - No need to check result of check_assignment (f04c1ad9) by Alastair Robertson <alastair@ajor.co.uk> - Add workaround to remove duplicate entries in uprobe symbols listing (8f5e90f4) by Augusto Caringi <acaringi@redhat.com> - cmake: add GNUInstallDirs support (2f380013) by Ovidiu Panait <ovpanait@gmail.com> - Allow running tests as non-root (again) (efa2da20) by Daniel Xu <dxu@dxuuu.xyz> - Report kernel instruction limit (76770de3) by bas smit <bas@baslab.org> - Add missing include to btf.h (145041ec) by Augusto Caringi <acaringi@redhat.com> ## [0.9.4] 2020-02-04 ### Highlights - New calls: `signal`, `override`, `strncmp` - Support for attaching to `kprobes` at an offset - Support for struct bitfields ### All Changes #### Added - Add support to attach kprobe to offset (e31e398) by Masanori Misono <m.misono760@gmail.com> - Add `--info` flag (afafbf5) by bas smit <bas@baslab.org> - Mark 'override_return' as unsafe (49cd031) by bas smit <bas@baslab.org> - Implement bpf_override_return (784c64e) by bas smit <bas@baslab.org> - arch: Add support for powerpc64 registers (472f5ed) by Sandipan Das <sandipan@linux.ibm.com> - Add source line information to error messages (46e62c0) by bas smit <bas@baslab.org> - Support octal and hexadecimal escape sequences in string (873d7ba) by Masanori Misono <m.misono760@gmail.com> - Implement `signal` (32bb577) by bas smit <bas@baslab.org> - Make `signal` unsafe (be676b5) by bas smit <bas@baslab.org> - Implement strncmp (a1d0263) by Jay Kamat <jaygkamat@gmail.com> - Add builtin: cpid (cae4dcf) by bas smit <bas@baslab.org> - Allow uprobe offset on quoted attach points (6432609) by bas smit <bas@baslab.org> - Allow string literals as signal specifiers (0230f98) by bas smit <bas@baslab.org> - Implement bitfield support (8822cc2) by Daniel Xu <dxu@dxuuu.xyz> #### Changed - Take first binary match for PATH lookup on uprobe and USDT (ec5c2c3) by Daniel Xu <dxu@dxuuu.xyz> - Infer `uaddr` pointer type from ELF symbol size (59b0659) by bas smit <bas@baslab.org> - Rename `override_return` to `override` (96cb4b5) by bas smit <bas@baslab.org> - Runtime feature testing (17f3c82) by bas smit <bas@baslab.org> - Silenced unsigned/signed comparison warning (75101f9) by Daniel Xu <dxu@dxuuu.xyz> - error message for verification buffer size (41c0ab8) by Gordon Marler <gmarler@bloomberg.net> - Reimplement `elapsed` using a hidden map (2613ea6) by bas smit <bas@baslab.org> - Remove dependency on 'command' shell builtin (3f7a94a) by Adam Jensen <acjensen@gmail.com> - Make parsing fail if lexing fails (d092cb1) by Alastair Robertson <alastair@ajor.co.uk> - Limit increment/decrement to variables (c126441) by bas smit <bas@baslab.org> - Only warn about missing BTF info in debug mode (f84ae5c) by Daniel Xu <dxu@dxuuu.xyz> - Allow uretprobe at an address (f0785b5) by bas smit <bas@baslab.org> - fix uprobe address on short name (f7ed963) by bas smit <bas@baslab.org> - Reverse return value of strncmp (384640e) by Jay Kamat <jaygkamat@gmail.com> - Make strcmp return 0 on match (8d9069c) by bas smit <bas@baslab.org> - Differentiate between regular structs and typedef'd structs (8d34209) by Alastair Robertson <alastair@ajor.co.uk> #### Fixed - Support "." in attach point function argument (c532159) by Daniel Xu <dxu@dxuuu.xyz> - clang_parser: workaround for asm_inline in 5.4+ kernel headers (c30e4dd) by Andreas Gerstmayr <agerstmayr@redhat.com> - Consider signed array (9bb6a8b) by Masanori Misono <m.misono760@gmail.com> - Support anonymous struct/union in BTF::type_of() (36d9914) by Masanori Misono <m.misono760@gmail.com> - Allow resolving binary paths in different mount ns (124e569) by Dale Hamel <dale.hamel@shopify.com> - Avoid useless allocations in strncmp (551664e) by bas smit <bas@baslab.org> - Avoid comparing past string length (b10dc32) by bas smit <bas@baslab.org> - Call llvm.lifetime.end after memcpy if the expression is not a variable (8b2d219) by Masanori Misono <m.misono760@gmail.com> - bug: Strip newlines from log message (361d1fc) by bas smit <bas@baslab.org> - Fix buggy signed binop warnings (e87897c) by Daniel Xu <dxu@dxuuu.xyz> - Reuse `cat` and `system` ID when expanding probes (79aada5) by bas smit <bas@baslab.org> - Remove unneeded `probe_read`s from `strcmp` (43b4e4c) by bas smit <bas@baslab.org> - Fix func variable in uprobe (d864f18) by Masanori Misono <m.misono760@gmail.com> - Add space for the error message about kernel.perf_event_max_stack (de2a7a8) by Kenta Tada <Kenta.Tada@sony.com> - Improve uprobe/usdt visitor error handling and messaging (5005902) by Adam Jensen <acjensen@gmail.com> - Fix some semantic analyser crashes (b11dc75) by Alastair Robertson <alastair@ajor.co.uk> - Fix codegen for modulo operation (fe0ed5a) by Daniel Xu <dxu@dxuuu.xyz> #### Documentation - Document `override_return` (b83b51d) by bas smit <bas@baslab.org> - Add documentation on BTF (6623f25) by Masanori Misono <m.misono760@gmail.com> - docs: limit to 105 chars (91e9dad) by bas smit <bas@baslab.org> - docs: Remove double shebang (da8b10c) by bas smit <bas@baslab.org> - docs: improve readability of code snippets (34a394a) by bas smit <bas@baslab.org> - docs: remove unneeded html elements (06d8662) by bas smit <bas@baslab.org> - Fix typos (e5ad6b9) by Michael Prokop <michael.prokop@synpro.solutions> - One-liner tutorial: Use "struct" when casting (7a5624c) by Alastair Robertson <alastair@ajor.co.uk> - docs: Add centos 7 repo (1b4cb8f) by bas smit <bas@baslab.org> - docs: Fix typo (b38dbd0) by bas smit <bas@baslab.org> - Move debug flags closer to each other in help message (df61049) by Daniel Xu <dxu@dxuuu.xyz> - Add binutils dependency to documentation (c57204c) by Daniel Xu <dxu@dxuuu.xyz> - Add documentation on release procedure (#981) (528fd6e) by Daniel Xu <dxu@dxuuu.xyz> - fix: Minor spelling correction (b3a6aee) by Jason Wohlgemuth <jhwohlgemuth@users.noreply.github.com> - Document `signal` (d5f3c75) by bas smit <bas@baslab.org> - INSTALL.md: Fix TOC link (1ab0a71) by Alastair Robertson <alastair@ajor.co.uk> - Amend sizes in documentation and provide date (ddd10fe) by Dale Hamel <dale.hamel@shopify.com> - Docs: add missing TOC entry (8c1d4e9) by bas smit <bas@baslab.org> - Add the chinese version for one liners tutorial (15a930e) by supersojo <suyanjun218@163.com> #### Internal - Reorganize tests/ directory (193177b) by Daniel Xu <dxu@dxuuu.xyz> - Fix typing issues in `CreateMapUpdateElem` (e86b9bb) by bas smit <bas@baslab.org> - Fix typing issues in `CreateMapLookup` (14af118) by bas smit <bas@baslab.org> - Fix build: Add namespace to BPF_FUNC_override_return (b6de734) by Alastair Robertson <alastair@ajor.co.uk> - Unify vmlinux and BTF location list (1d39776) by Masanori Misono <m.misono760@gmail.com> - Disable probe.kprobe_offset_fail_size runtime test in CI (1497434) by Masanori Misono <m.misono760@gmail.com> - fmt: update formatting in clang_parser.cpp (aefc424) by Andreas Gerstmayr <agerstmayr@redhat.com> - Use constexpr (b59c3a7) by Masanori Misono <m.misono760@gmail.com> - Make use of feature testing (b01f89c) by bas smit <bas@baslab.org> - Import libbpf (132e1ee) by bas smit <bas@baslab.org> - Rename BPFTRACE_BTF_TEST to BPFTRACE_BTF (5bbeb31) by Masanori Misono <m.misono760@gmail.com> - Add test for anonymous struct/union processing using BTF (240f59a) by Masanori Misono <m.misono760@gmail.com> - Switch tests suite to `bcc_foreach_sym` (a251477) by bas smit <bas@baslab.org> - Make resolve_binary_paths include non-executable shared objects in its return. (c3d1095) by Michał Gregorczyk <michalgr@fb.com> - Remove full static builds from travis (4fe9064) by Dale Hamel <dale.hamel@srvthe.net> - Move ast.h definitions into ast.cpp (f0dd0b4) by Daniel Xu <dxu@dxuuu.xyz> - Use subprocess.Popen text mode (47de78b) by Daniel Xu <dxu@dxuuu.xyz> - Fix debian libclang only linking (a9a2f0f) by Dale Hamel <dale.hamel@srvthe.net> - Build static+libc images using github actions (4794aba) by Dale Hamel <dale.hamel@srvthe.net> - Enable static+glibc builds and embedding LLVM deps (b1ae710) by Dale Hamel <dale.hamel@shopify.com> - Create StderrSilencer helper class to redirect stderr (b59b97a) by Daniel Xu <dxu@dxuuu.xyz> - Add missing semicolon (add4117) by Daniel Xu <dxu@dxuuu.xyz> - ast: codegen: Add abstraction for stack pointer offset (d19614d) by Sandipan Das <sandipan@linux.ibm.com> - clang-format: avoid breaking indent in irbuilderbpf.h (5b6d236) by bas smit <bas@baslab.org> - Non-invasive formatting of src/*.h (98328f1) by Alastair Robertson <alastair@ajor.co.uk> - Clang Format: Update line-break penalties (30d5b8d) by Alastair Robertson <alastair@ajor.co.uk> - correct for clang-format check (bb30265) by Gordon Marler <gmarler@bloomberg.net> - Add requested msg prefix (f3327bd) by Gordon Marler <gmarler@bloomberg.net> - add requested changes. (c9453b5) by Gordon Marler <gmarler@bloomberg.net> - Show current log size in msg as starting point (7942b9d) by Gordon Marler <gmarler@bloomberg.net> - Fix CI clang-format (13556f9) by Daniel Xu <dxu@dxuuu.xyz> - Make ninja work with build system (76bb97a) by Daniel Xu <dxu@dxuuu.xyz> - Clang Format: switch/case bracketing style fixes (f4e46b2) by Alastair Robertson <alastair@ajor.co.uk> - Clang Format: Don't wrap braces after namespace (4b26e3f) by Alastair Robertson <alastair@ajor.co.uk> - Add non-literal strncmp test (1c41333) by bas smit <bas@baslab.org> - Rename literal test (4295985) by bas smit <bas@baslab.org> - refactor CreateMapLookupElem (7b7ab95) by bas smit <bas@baslab.org> - Add a semantic and runtime test to test task_struct field accesses (8519550) by Masanori Misono <m.misono760@gmail.com> - Use `struct task_struct` instead of `task_struct` (d39db3a) by Masanori Misono <m.misono760@gmail.com> - BTF leftover for full type rename (5088682) by Jiri Olsa <jolsa@kernel.org> - Create a single is_numeric() function in utils (374ca46) by Alastair Robertson <alastair@ajor.co.uk> - Warn if cmake is less than 3.13 when building with ASAN (ad3b9f3) by Masanori Misono <m.misono760@gmail.com> - Remove unnecessary division (81b7c0a) by Daniel Xu <dxu@dxuuu.xyz> - Add build option, BUILD_ASAN, to turn on address sanitizer (04d015e) by Daniel Xu <dxu@dxuuu.xyz> - Properly indent cmake config (24a7695) by Daniel Xu <dxu@dxuuu.xyz> - Use mocks consistently in codegen tests so they don't require root to run (b261833) by Alastair Robertson <alastair@ajor.co.uk> - Enable -Werror on CI builds (2f0f5db) by Alastair Robertson <alastair@ajor.co.uk> - CMakeLists cleanups (6b8d7ad) by Alastair Robertson <alastair@ajor.co.uk> - Disable deprecated ORCv1 warning in llvm (607b8af) by Daniel Xu <dxu@dxuuu.xyz> - Normalize code (0878020) by Daniel Xu <dxu@dxuuu.xyz> - Pass location to uprobe+offset probe (8c1a355) by bas smit <bas@baslab.org> - Use symbolic constants instead of numeric literal (457aab9) by Daniel Xu <dxu@dxuuu.xyz> - Add clang-format rule to travis CI (3b9e959) by Daniel Xu <dxu@dxuuu.xyz> - Turn off clang-format for specific long lists (bcbfaa0) by Daniel Xu <dxu@dxuuu.xyz> - Add .clang-format file (b04e478) by Daniel Xu <dxu@dxuuu.xyz> - Change reinterpret_cast to static cast and fix formatting (03d2d67) by Alastair Robertson <alastair@ajor.co.uk> - Add PER_CPU detection helper (594fd34) by bas smit <bas@baslab.org> - Store the BPF map type in the map object (2e850c5) by bas smit <bas@baslab.org> - format: align parser (b3680e6) by bas smit <bas@baslab.org> - Make ASSERTs in helper functions fail the parent testcase (ddaa482) by Alastair Robertson <alastair@ajor.co.uk> - Add dependency on testprogs and bpftrace to runtime tests (7870091) by Daniel Xu <dxu@dxuuu.xyz> - Add custom target for testprogs (d799e83) by Daniel Xu <dxu@dxuuu.xyz> - Move testprogs cmake definition before runtime test definitions (6783448) by Daniel Xu <dxu@dxuuu.xyz> - Add tests for resolve_binary_path (8fb727a) by Adam Jensen <acjensen@gmail.com> - Fix tests to run without $PATH (c1c60c2) by Adam Jensen <acjensen@gmail.com> - Add runtime tests for ambiguous wildcard matches (cca9040) by Adam Jensen <acjensen@gmail.com> - Add regression tests for modulo operation (0a1cb65) by Daniel Xu <dxu@dxuuu.xyz> - Don't take reference of a pointer (61ba68a) by Daniel Xu <dxu@dxuuu.xyz> - Silence test suite (8d1f691) by bas smit <bas@baslab.org> - Disable builtin.cgroup runtime test in CI (8277876) by Daniel Xu <dxu@dxuuu.xyz> - Add a RUNTIME_TEST_DISABLE environment to runtime tests (6c984ea) by Daniel Xu <dxu@dxuuu.xyz> - Add script to compare tool codegen between builds (d95a2d1) by bas smit <bas@baslab.org> - Minor btf cleanups (a10479b) by Daniel Xu <dxu@dxuuu.xyz> - Add FieldAnalyser to the clang parser tests (13b06d2) by Jiri Olsa <jolsa@kernel.org> - Iterate only over detected types in BTF::c_def (409d7ad) by Jiri Olsa <jolsa@kernel.org> - Add BPFtrace::btf_set_ to replace global BTF type set (06a09ca) by Jiri Olsa <jolsa@kernel.org> - Add BTF::type_of function (4378e24) by Jiri Olsa <jolsa@kernel.org> - Adding FieldAnalyser class (ec3c621) by Jiri Olsa <jolsa@kernel.org> - Move BTF object into BPFtrace class (fdf3940) by Jiri Olsa <jolsa@kernel.org> - Add runtime test (db81d25) by Daniel Xu <dxu@dxuuu.xyz> - Add clang_parser test (6cae624) by Daniel Xu <dxu@dxuuu.xyz> - Use struct instead of class (fbe3bf6) by Daniel Xu <dxu@dxuuu.xyz> - Make `strncmp` codegen unsigned (af54c9b) by bas smit <bas@baslab.org> - Avoid shift/reduce warnings (3761904) by bas smit <bas@baslab.org> - Treat stackmode as identifier (e018da5) by bas smit <bas@baslab.org> - Define all `call`s in the lexer to avoid redefinition (b8ddf25) by bas smit <bas@baslab.org> - Remove `_` suffix from local variables (34d4654) by bas smit <bas@baslab.org> - Add regression test for #957 (253cfd6) by bas smit <bas@baslab.org> - Fix paths in tests (a8dcb02) by bas smit <bas@baslab.org> - Allow runtime tests to be ran from any directory (9139bed) by bas smit <bas@baslab.org> - Link libiberty during static builds (aa8c7ba) by Daniel Xu <dxu@dxuuu.xyz> - cpid vector -> single (52ff6e3) by bas smit <bas@baslab.org> - 0.9.3 Changelog (f4ea282) by bas smit <bas@baslab.org> - Bump to 0.9.3 (3d1e022) by bas smit <bas@baslab.org> - Add `signal` tests (95cba2b) by bas smit <bas@baslab.org> - Add missing kernel option in INSTALL.md (099d1c9) by Edouard Dausque <git@edouard.dausque.net> - Make printing the LLVM IR from a debugger easier (d534295) by bas smit <bas@baslab.org> - Make `uprobes - list probes by pid` test more quiet (b2a570a) by Daniel Xu <dxu@dxuuu.xyz> - vagrant: add binutils-dev dependency (2e73e04) by Matheus Marchini <mmarchini@netflix.com> - Fix maptype bugs (028c869) by bas smit <bas@baslab.org> - Disable -Winconsistent-missing-override in mock.h (d3cb095) by Masanori Misono <m.misono760@gmail.com> - Disable -Wcast-qual for bpf/btf.h (b308a9c) by Masanori Misono <m.misono760@gmail.com> - Import used headers (979992e) by Masanori Misono <m.misono760@gmail.com> - Fix modernize-deprecated-headers warnings (b09836b) by Masanori Misono <m.misono760@gmail.com> - Fix -Wcast-align (ce45470) by Masanori Misono <m.misono760@gmail.com> - Fix -Wdelete-abstract-non-virtual-dtor (cb78da3) by Masanori Misono <m.misono760@gmail.com> - Fix -Wstring-plus-int (3e52a3d) by Masanori Misono <m.misono760@gmail.com> - Fix -Wunreachable-code-loop-increment (f354911) by Masanori Misono <m.misono760@gmail.com> - Fix -Wbraced-scalar-init (6fc82ed) by Masanori Misono <m.misono760@gmail.com> - Fix -Wmismatched-tags (e29a4f2) by Masanori Misono <m.misono760@gmail.com> - Fix -Wformat-security (cc3ef62) by Masanori Misono <m.misono760@gmail.com> - Fix some compiler warnings (9a85f10) by Daniel Xu <dxu@dxuuu.xyz> ## [0.9.3] 2019-11-22 ### Highlights - Allow attaching to uprobes at an offset - BTF support - integer casts - integer pointer casts ### All Changes #### Added - Add support to cast to a pointer of integer (#942) (8b60006) by Masanori Misono <m.misono760@gmail.com> - Add sargX builtin (9dc6024) by Adam Jensen <acjensen@gmail.com> - Add support to specify symbol with offset to uprobe (33e887f) by Jiri Olsa <jolsa@kernel.org> - add threadsnoop tool (f021967) by Brendan Gregg <bgregg@netflix.com> - add tcpsynbl tool (0cbc301) by Brendan Gregg <bgregg@netflix.com> - add tcplife tool (51d8852) by Brendan Gregg <bgregg@netflix.com> - add swapin tool (c80753b) by Brendan Gregg <bgregg@netflix.com> - add setuids tool (439311a) by Brendan Gregg <bgregg@netflix.com> - add naptime tool (572de59) by Brendan Gregg <bgregg@netflix.com> - add biostacks tool (162bc63) by Brendan Gregg <bgregg@netflix.com> - Add check if uprobe is aligned (e2c65bd) by Jiri Olsa <jolsa@kernel.org> - Support wildcards in probe path (#879) (2a361cc) by Adam Jensen <acjensen@gmail.com> - Add --btf option (ec931fa) by Jiri Olsa <jolsa@kernel.org> - Introduce int casts (ee82e64) by bas smit <bas@baslab.org> - utils: unpack kheaders.tar.xz if necessary (#768) (896fafb) by Matt Mullins <mokomull@gmail.com> - Add support to check for libbpf package (8e0800c) by Jiri Olsa <jolsa@kernel.org> - Add signed types (53cf421) by bas smit <bas@baslab.org> - Add location support to builtins (a79e5a6) by bas smit <bas@baslab.org> - Add location support to calls (c1b2a91) by bas smit <bas@baslab.org> - Add location support to the AST (67c208d) by bas smit <bas@baslab.org> - Highlight bpftrace source files (cfbaa2f) by Paul Chaignon <paul.chaignon@orange.com> - Add travis CI build icon to README.md (50375e2) by Daniel Xu <dxu@dxuuu.xyz> - Add IRC badge to README (a20af57) by Daniel Xu <dxu@dxuuu.xyz> #### Changed - Use the same shebang for all tools (78eb451) by bas smit <bas@baslab.org> - Change exit() to send SIGTERM to child processes (649cc86) by Matheus Marchini <mmarchini@netflix.com> - Make `stats` and `avg` signed (809dc46) by bas smit <bas@baslab.org> - Refactor error printer to make severity level configurable (676a6a7) by bas smit <bas@baslab.org> - Make output line-buffered by default (#894) (78e64ba) by Daniel Xu <dxu@dxuuu.xyz> - cmake: don't use language extensions (like gnu++14) (4ce4afc) by Matheus Marchini <mmarchini@netflix.com> - add file extension on README (545901c) by sangyun-han <sangyun628@gmail.com> - build: don't set -std flag manually (3cbc482) by Matheus Marchini <mat@mmarchini.me> - Don't use random value on stack (b67452b) by Daniel Xu <dxu@dxuuu.xyz> - codegen: ensure logical OR and AND works with non-64-bit integers (69cbd85) by Matheus Marchini <mat@mmarchini.me> - Allow child process to exit on attach_probe failure (#868) (ecf1bc8) by Adam Jensen <acjensen@gmail.com> - json output: Make output more consistent (#874) (9d1269b) by Dan Xu <dxu@dxuuu.xyz> - Do not generate extra load for ++/-- for maps/variables (3f79fad) by Jiri Olsa <jolsa@kernel.org> #### Fixed - semantic_analyser: validate use of calls as map keys (b54c085) by Matheus Marchini <mat@mmarchini.me> - codegen: fix rhs type check for binop (2d87213) by Daniel Xu <dxu@dxuuu.xyz> - Fix map field access (a9acf92) by Jiri Olsa <jolsa@kernel.org> - Correctly parse enums (59d0b0d) by Daniel Xu <dxu@dxuuu.xyz> - Allow build from uncommon bcc installation (9986329) by Jiri Olsa <jolsa@kernel.org> - Fix sigint handling under heavy load (0058d41) by Augusto Caringi <acaringi@redhat.com> - Assign default value to elem_type to avoid undefined behavior. (a0b8722) by Florian Kuebler <kuebler@google.com> - Strip trailing newline from error message (5315eee) by bas smit <bas@baslab.org> - Use strerror to improve `cgroupid` error message (72de290) by bas smit <bas@baslab.org> - Initialize member variable (4dd8bb8) by Daniel Xu <dxu@dxuuu.xyz> - Fix umask build issue (#861) (24de62a) by Michael Würtinger <michael@wuertinger.de> - Handle SIGTERM gracefully (#857) (fb47632) by Dan Xu <dxu@dxuuu.xyz> - json output: suppress output if map is not initialized (348975b) by Andreas Gerstmayr <agerstmayr@redhat.com> - fix 'designated initializers' build errors (#847) (4910e75) by Alek P <alek-p@users.noreply.github.com> - remove invalid 'unused attribute' (9bf8204) by Matheus Marchini <mat@mmarchini.me> #### Documentation - Mention sargX builtin in docs (352e983) by Adam Jensen <acjensen@gmail.com> - Update reference guide (65c97fd) by Jiri Olsa <jolsa@kernel.org> - Docs: fix inconsistent install script option (a65e3d8) by Daniel T. Lee <danieltimlee@gmail.com> - docs: Fix mismatch between code and example (2499437) by bas smit <bas@baslab.org> - fix typo in example text - correct name of script (891021b) by sangyun-han <sangyun628@gmail.com> - Add openSUSE package status link into install.md (#859) (613b42f) by James Wang <jnwang@suse.com> - Fix a typo in reference_guide (e7420eb) by James Wang <jnwang@suse.com> - Ubuntu instructions: add minimum release version (413c1a0) by Peter Sanford <psanford@sanford.io> #### Internal - Add tests for sargX builtin (774a7a6) by Adam Jensen <acjensen@gmail.com> - Add test (0c08b1d) by Daniel Xu <dxu@dxuuu.xyz> - Avoid leaking state between cmake tests (625269f) by bas smit <bas@baslab.org> - Avoid testing for FOUR_ARGS_SIGNATURE on systems without bfd (cd1d231) by bas smit <bas@baslab.org> - Unset `CMAKE_REQUIRED_LIBRARIES` to avoid influencing tests (ab0665b) by bas smit <bas@baslab.org> - Define PACKAGE to make libbfd happy (d165396) by Daniel Xu <dxu@dxuuu.xyz> - Fix 'may be used uninitialized' build warning in bfd-disasm.cpp (ffd203b) by Augusto Caringi <acaringi@redhat.com> - Change "variable.tracepoint arg casts in predicates" runtime test (9aae057) by Jiri Olsa <jolsa@kernel.org> - bfd-disasm: fix LIBBFD_DISASM_FOUR_ARGS_SIGNATURE (7d62627) by Matheus Marchini <mmarchini@netflix.com> - semantic_analyser: fix gcc build error on xenial (0e6014a) by Matheus Marchini <mmarchini@netflix.com> - Prevent forks from notifying the IRC channel (ca93440) by Daniel Xu <dxu@dxuuu.xyz> - Add runtime tests for uprobe offset/address (d9c2bab) by Jiri Olsa <jolsa@kernel.org> - Bypass the uprobe align check in unsafe mode (18b9635) by Jiri Olsa <jolsa@kernel.org> - Adding tests for uprobe offset definitions (d894d0e) by Jiri Olsa <jolsa@kernel.org> - Add BfdDisasm class (8198628) by Jiri Olsa <jolsa@kernel.org> - Add Disasm class (6f7bc6f) by Jiri Olsa <jolsa@kernel.org> - Add support to check for libbfd/libopcodes libraries (542f2b9) by Jiri Olsa <jolsa@kernel.org> - Add resolve_offset_uprobe functions (7be4143) by Jiri Olsa <jolsa@kernel.org> - Add address and func_offset to ast::AttachPoint and Probe classes (893201a) by Jiri Olsa <jolsa@kernel.org> - Fix `sigint under heavy load` runtime test (4f7fd67) by Daniel Xu <dxu@dxuuu.xyz> - Notify irc channel on build failures (83b5684) by Daniel Xu <dxu@dxuuu.xyz> - Add BTF class (43530aa) by Jiri Olsa <jolsa@kernel.org> - Read every BTF type (67dbe3f) by Daniel Xu <dxu@dxuuu.xyz> - Disable codegen.logical_and_or_different_type test in alpine CI (5271e6c) by Daniel Xu <dxu@dxuuu.xyz> - Warn when doing signed division (#910) (fff3b05) by Daniel Xu <dxu@dxuuu.xyz> - Add short option for --btf and update usage (88dbe47) by Daniel Xu <dxu@dxuuu.xyz> - Add BTF tests (47621bb) by Jiri Olsa <jolsa@kernel.org> - Add ClangParser::parse_btf_definitions function (54cf4ab) by Jiri Olsa <jolsa@kernel.org> - Add SizedType::operator!= function (8cb79f9) by Jiri Olsa <jolsa@kernel.org> - Add ClangParserHandler::check_diagnostics function (3e75475) by Jiri Olsa <jolsa@kernel.org> - Add ClangParser::visit_children function (4842ccf) by Jiri Olsa <jolsa@kernel.org> - Add BTF::c_def function (02a2d0d) by Jiri Olsa <jolsa@kernel.org> - Add Expression::resolve string set (0779333) by Jiri Olsa <jolsa@kernel.org> - Add curtask task_struct cast type for field access (80cb0d7) by Jiri Olsa <jolsa@kernel.org> - test: fix watchpoint runtime test flakiness (88fc1b8) by Matheus Marchini <mmarchini@netflix.com> - Disable sign checking for division binop (8084463) by bas smit <bas@baslab.org> - Add ability to test for warnings (b19ebb6) by bas smit <bas@baslab.org> - Revert "Signed types (#834)" (6613a14) by Daniel Xu <dxu@dxuuu.xyz> - Signed types (#834) (446facb) by bas smit <bas@baslab.org> - test: fix flaky 32-bit tp runtime test (c0d94c8) by Matheus Marchini <mat@mmarchini.me> - travis: use bionic and enable runtime tests (57c5a55) by Matheus Marchini <mat@mmarchini.me> - test: print bpftrace script when codegen test fails (b0c4902) by Matheus Marchini <mat@mmarchini.me> - tests: add test for cat with fmt str (#842) (b3143a6) by Matheus Marchini <mat@mmarchini.me> - Fix tests (#844) (fd0ec92) by bas smit <bas@baslab.org> ## [0.9.2] 2019-07-31 ### Highlights - New environment variables (BPFTRACE_NO_USER_SYMBOLS, BPFTRACE_LOG_SIZE) - New probe type: memory `watchpoint` - Support for JSON output ### All Changes #### Added - Add vargs support for cat() builtin (similar to system) (7f1aa7b) by Augusto Caringi <acaringi@redhat.com> - Add memory watchpoint probe type (#790) (854cd4b) by Dan Xu <dxu@dxuuu.xyz> - Add support for Go symbol names to uaddr (#805) (e6eb3dd) by Jason Keene <jasonkeene@gmail.com> - add option for JSON output (5c6f20a) by Andreas Gerstmayr <andreas@gerstmayr.me> - Add $# for number of positional arguments (ec8b61a) by Mark Drayton <mdrayton@gmail.com> - Add BPFTRACE_NO_USER_SYMBOLS environment variable (#800) (41d2c9f) by Dan Xu <dxu@dxuuu.xyz> - Add line numbers to parser error messages (a584752, 2233ea7) by bas smit <bas@baslab.org> - Add new environment variable BPFTRACE_LOG_SIZE (2f7dc75, 7de1e84, 2f7dc75) by Ray Jenkins <ray.jenkins@segment.com> #### Changed - Terminate when map creation fails (6936ca6) by bas smit <bas@baslab.org> - Print more descriptive error message on uprobe stat failure (0737ec8) by Dan Xu <dxu@dxuuu.xyz> - Allow '#' in attach point path (2dfbc93) by Dan Xu <dxu@dxuuu.xyz> - Disable `func`, `retval` and `reg` for tracepoints since tracepoints can't access this information (7bfc0f8) by bas smit <bas@baslab.org> #### Fixed - Skip keys which were removed during iteration on `print` (bfd1c07) by Andreas Gerstmayr <agerstmayr@redhat.com> - Fix exiting prematurely on strace attach (a584752..0e97b2c) by Jay Kamat <jaygkamat@gmail.com> - Fix unused variable warnings (9d07eb5) by Daniel Xu <dxu@dxuuu.xyz> - Fix alignment issues on `ntop` (2006424) by Matheus Marchini <mat@mmarchini.me> - Fix BEGIN being triggered multiple times when bpftrace is run a second time (14bc835) by bas smit <bas@baslab.org> - Fix crash when using $0 (b41d66d) by Alastair Robertson <alastair@ajor.co.uk> - Fix tcp tools printing errors (206b36c) by bas smit <bas@baslab.org> #### Documentation - Update Ubuntu install instructions (4e3ffc3) by Brendan Gregg <bgregg@netflix.com> - Clarify help message for `-o` (d6e9478) by Daniel Xu <dxu@dxuuu.xyz> - `opensnoop.bt` was incorrectly linked to load.bt (d74fae0) by southpawflo <16946610+southpawflo@users.noreply.github.com> - Document multiple attach points for probes (21bc5bf) by Daniel Xu <dxu@dxuuu.xyz> - Fix incorrect reference to the `probe` key (83d473c) by Jeremy Baumont <jeremy.baumont@gmail.com> #### Internal - Fix failing test (086c018) by bas smit <bas@baslab.org> - Collapse bcc symbol resolvers by process executable (63ff8b0) by Daniel Xu <dxu@dxuuu.xyz> - Remove unneeded probe read (7d0aa99) by bas smit <bas@baslab.org> - Fix runtime test parser to not break with commented out tests (#824) (b73c963) by Augusto Mecking Caringi <acaringi@redhat.com> - bpftrace: optimize resolve_kname (#765) (ec5278d) by Matheus Marchini <mat@mmarchini.me> - Resolve symbol names using bcc_elf_foreach_sym (#811) (a2d9298) by Jason Keene <jasonkeene@gmail.com> - Add basic editorconfig for defining style (#775) (5b20829) by Jay Kamat <jaygkamat@gmail.com> - Auto-generate list of includes for codegen tests (e3b8ecd) by Alastair Robertson <alastair@ajor.co.uk> - Do not emit GEP instruction when pushing string literals to stack (#667) (e98530c) by Michał Gregorczyk <michalgr@users.noreply.github.com> - tool style tweaks (8bb0940) by Brendan Gregg <bgregg@netflix.com> - Clean up unused variable (#787) (8627e84) by Dan Xu <dxu@dxuuu.xyz> - Make member variables end with underscores (c76a8e4) by Alastair Robertson <alastair@ajor.co.uk> - Fail in case there's unresolved type in definitions (ecb7a1b, 2239756, a6a4fb3) by Jiri Olsa <jolsa@kernel.org> ## [0.9.1] 2019-06-25 ### Highlights - Introduce compound assignment operators (`+=` and friends) (7f26468) by Matheus Marchini <mat@mmarchini.me> - Add support for arrays and IPv6 for the `ntop` builtin function (c9dd10f) by Matheus Marchini <mat@mmarchini.me> - Add basic support to enums (treat them as constants) (e4cb6ce) by Matheus Marchini <mat@mmarchini.me> - Add macro definition support (8826470,af67b56,14e892b) by Matheus Marchini <mat@mmarchini.me>, Javier Honduvilla Coto <javierhonduco@gmail.com> - Add support for arrays and IPv6 for the `ntop` builtin function (c9dd10f) by Matheus Marchini <mat@mmarchini.me> - Allow comparison of two string variables (7c8e8ed) by williangaspar <williangaspar360@gmail.com> - Add pre and post behavior to ++ and -- operators (f2e1345...9fea147) by Alastair Robertson <alastair@ajor.co.uk> - [**BREAKING CHANGE**] Ban kprobes that cause CPU deadlocks (40cf190) by Javier Honduvilla Coto <javierhonduco@gmail.com> - [**BREAKING CHANGE**] Add unsafe-mode and make default execution mode safe-mode (981c3cf,4ce68cd) by Daniel Xu <dxu@dxuuu.xyz> ### All Changes #### Added - Introduce compound assignment operators (`+=` and friends) (7f26468) by Matheus Marchini <mat@mmarchini.me> - Add KBUILD_MODNAME (a540fba) by Brendan Gregg <bgregg@netflix.com> - Add flags for include paths and files (`--include` and `-I`, respectively) (632652f) by Matheus Marchini <mat@mmarchini.me> - List uprobes with -l (122ef6e) by Matheus Marchini <mat@mmarchini.me> - Add BPFTRACE_MAX_PROBES environment variable (ddb79df) by Matheus Marchini <mat@mmarchini.me> - Add option to redirect trace output to file (462a811) by bas smit <bas@baslab.org> - Add script to check kernel requirements (ac19743) by bas smit <bas@baslab.org> - Add USDT wildcard matching support (82dbe4e...3725edf,648a65a) by Dale Hamel <dale.hamel@srvthe.net> - Add support for arrays and IPv6 for the `ntop` builtin function (c9dd10f,24a463f) by Matheus Marchini <mat@mmarchini.me> - Add 'cat' builtin (ae1cfc9,ef9baf8) by Augusto Caringi <acaringi@redhat.com> - Add array indexing operator [] for one-dimensional, constant arrays (ec664a1) by Dale Hamel <dalehamel@users.noreply.github.com> - Allow dots to truncate fields in `printf` (0f636c9) by Brendan Gregg <bgregg@netflix.com> - Add `BPFTRACE_MAP_KEYS_MAX` environment variable, and increase default map keys limit to 4096 (fab8bf6) by Brendan Gregg <bgregg@netflix.com> - Add support for delimiters in join() statement (eb40386) by Jason Koch <jkoch@netflix.com> - Add basic support to enums (treat them as constants) (e4cb6ce) by Matheus Marchini <mat@mmarchini.me> - Add macro definition support (8826470,af67b56,14e892b) by Matheus Marchini <mat@mmarchini.me>, Javier Honduvilla Coto <javierhonduco@gmail.com> - Add hardware:branch-misses (9631623) by Jason Koch <jkoch@netflix.com> - Allow comparison of two string variables (7c8e8ed) by williangaspar <williangaspar360@gmail.com> #### Changed - Add pre and post behavior to ++ and -- operators (f2e1345...9fea147) by Alastair Robertson <alastair@ajor.co.uk> - Parse negative integer literals correctly (108068f) by Daniel Xu <dxu@dxuuu.xyz> - Tools improvements (9dbee04,a189c36) by Brendan Gregg <bgregg@netflix.com> - USAGE message trim (18d63b0) by Brendan Gregg <bgregg@netflix.com> - Allow `probe` builtin for `BEGIN` and `END` probes (3741efe) by bas smit <bas@baslab.org> - Default -d and -dd output to stdout (ecea569) by Jay Kamat <jaygkamat@gmail.com> - Return with error code if clang finds an error while parsing structs/enums/macros/includes (364849d) by Matheus Marchini <mat@mmarchini.me> - Restore map key validation (7826ee3) by Alastair Robertson <alastair@ajor.co.uk> - Add `/usr/include` to default header search path (32dd14b) by Javier Honduvilla Coto <javierhonduco@gmail.com> - More information in error message when failing to open script file (3b06e5f) by Alastair Robertson <alastair@ajor.co.uk> - [**BREAKING CHANGE**] Add unsafe-mode and make default execution mode safe-mode (981c3cf,4ce68cd) by Daniel Xu <dxu@dxuuu.xyz> - Safety measure for LLVM out of memory issue (6b53e4a) by Brendan Gregg <bgregg@netflix.com> - Allow non-zero lhist min value (51fdb6a) by bas smit <bas@baslab.org> - Improvements in startup speed (5ed8717,1ffb50f) by Matheus Marchini <mat@mmarchini.me> - When using -c, spawn the child process only when the tracing is ready (e442e9d) by Jiri Olsa <jolsa@kernel.org> - Allow more pointers as ints (3abc93e) by Brendan Gregg <bgregg@netflix.com> - Validate that PID (received via `-p`) is an integer (48206ad) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Promote map keys to 64-bit (e06e39d) by Brendan Gregg <bgregg@netflix.com> - Add hint when traced PID is not running (9edb3e1) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Allow pointers in printf, mapkeys, and filters (0202412,280f1c6) by Brendan Gregg <bgregg@netflix.com> - Allow ksym() lookups on function pointers (2139d46) by Brendan Gregg <bgregg@netflix.com> - [**BREAKING CHANGE**] Ban kprobes that cause CPU deadlocks (40cf190) by Javier Honduvilla Coto <javierhonduco@gmail.com> #### Fixed - Workaround for asm goto in Kernel 5+ headers (60263e1) by Matheus Marchini <mat@mmarchini.me> - Properly handle invalid `args` utilization (13c2e2e) by Augusto Caringi <acaringi@redhat.com> - Fix abort caused by lhist with incorrect number of arguments (41036b9) by bas smit <bas@baslab.org> - Fix anonymous struct parsing (ea63e8b) by Alastair Robertson <alastair@ajor.co.uk> - Fix code generation for bitwise and logical not on integer values (f522296) by synth0 <synthkaf@outlook.com> - Fix typo in type mismatch error message (83924f8) by Jay Kamat <jaygkamat@gmail.com> - Fix clearing action for some aggregations (dcd657e) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Fix possible crash if an invalid char is used in search (c4c6894) by Augusto Caringi <acaringi@redhat.com> - Fix headers includes by using -isystem rather than -I (32daaa2) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Fix exit() function bypassing END probe processing #228 (f63e1df,e4c418e,5cce746) by Augusto Caringi <acaringi@redhat.com> - Fix order in which probes fire (a4bf870) by John Gallagher <john.gallagher@delphix.com> - Stop throwing 'failed to initialize usdt context for path' error message (1fa3d3c) by Augusto Caringi <acaringi@redhat.com> - Fix stringification of ntop keys in maps (598050e) by Matheus Marchini <mat@mmarchini.me> - Fix parsing of forward-decl structs inside structs (354c919) by Matheus Marchini <mat@mmarchini.me> - Fix struct definition from headers (4564d55) by Matheus Marchini <mat@mmarchini.me> - Avoid crash if incorrect command line option is used (aa24f29) by Augusto Caringi <acaringi@redhat.com> - Fix clang_parser for LLVM 8+ (80ce138) by Matheus Marchini <mat@mmarchini.me> - Fix semicolon being required in some cases after if statements (13de974) by Matheus Marchini <mat@mmarchini.me> - Throw error message if argN or retval is used with incorrect probe type (b40354c) by Augusto Caringi <acaringi@redhat.com> - Fix USDT listing (`-l`) without a search pattern (af01fac) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Add missing space to error message (e1f5f14) by Alastair Robertson <alastair@ajor.co.uk> - Fix unroll in some cases (mostly when the generated code was large) (702145c) by Matheus Marchini <mat@mmarchini.me> #### Documentation - Added info on clang environment variables (7676530) by Richard Elling <Richard.Elling@RichardElling.com> - Fix snap instructions. (3877e46) by George Slavin <george.r.slavin@gmail.com> - Fix ustack documentation (5eeeb10) by Daniel Xu <dxu@dxuuu.xyz> - Replace stack with kstack (49e01e0) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Fix TOC in the reference guide (05eb170) by Alastair Robertson <alastair@ajor.co.uk> - Fix broken links in docs (c215c61,845f9b6) by Daniel Xu <dxu@dxuuu.xyz> - Fix inaccurate tutorial on listing (a4aeaa5) by Daniel Xu <dxu@dxuuu.xyz> - Add documentation for BEGIN/END probes (81de93a) by Daniel Xu <dxu@dxuuu.xyz> - Update build instructions for Ubuntu (38b9620) by bas smit <bas@baslab.org> - INSTALL.md: update required dependency for usdt (5fc438e) by Zi Shen Lim <zlim.lnx@gmail.com> - Fix ++ and -- text on undefined variables (47ab5cd) by Matheus Marchini <mat@mmarchini.me> - Reference guide small fixes (0d9c1a4) by Augusto Caringi <acaringi@redhat.com> - Add instructions to install on Gentoo (3c23187) by Patrick McLean <chutzpah@gentoo.org> - Add install instructions for Ubuntu snap package (0982bb6) by George Slavin <george.r.slavin@gmail.com> - Fix spelling mistake (a45869f) by George Slavin <george.r.slavin@gmail.com> - Fix 'one liners tutorial': use 'openat' instead of 'open' in examples (0cce55c) by Augusto Caringi <acaringi@redhat.com> - Add contributing section to the README (2a08468) by Alastair Robertson <alastair@ajor.co.uk> - Standardise documentation on the bpftrace name (135a4d3) by Alastair Robertson <alastair@ajor.co.uk> - Update install instructions (505b50a) by Alastair Robertson <alastair@ajor.co.uk> #### Internal - [tests] add missing tests to codegen.cpp (012ebda) by Matheus Marchini <mat@mmarchini.me> - tests: add runtime tests for regression bugs (ee57b6f) by Matheus Marchini <mat@mmarchini.me> - vagrant: add Ubuntu 19.04 box (60e6d0a) by Matheus Marchini <mat@mmarchini.me> - docker: add Fedora 30 (9ccafa0) by Zi Shen Lim <zlim.lnx@gmail.com> - Add Vagrantfile for ubuntu (b221f79) by bas smit <bas@baslab.org> - tests: fix and improve runtime tests (c7b3b2f) by Matheus Marchini <mat@mmarchini.me> - Clean up includes in clang_parser (374c240) by Daniel Xu <dxu@dxuuu.xyz> - Remove double `check_nargs` call (c226c10) by bas smit <bas@baslab.org> - Fix call.system runtime test (3b4f578) by Daniel Xu <dxu@dxuuu.xyz> - Fix call.str runtime test (8afbc22) by Daniel Xu <dxu@dxuuu.xyz> - Fix k[ret]probe_order runtime tests (27a334c) by Daniel Xu <dxu@dxuuu.xyz> - Remove old TODO (5be3752) by Alastair Robertson <alastair@ajor.co.uk> - Add clang_parser::parse_fail test (6fd7aac) by Jiri Olsa <jolsa@kernel.org> - Fix some bugs with positional parameters (13fb175) by Alastair Robertson <alastair@ajor.co.uk> - Fix runtime tests (a05ee59) by bas smit <bas@baslab.org> - Enable multiline matching for runtime test regex (c8763e4) by bas smit <bas@baslab.org> - Add environment var support to runtime tests (543513e) by bas smit <bas@baslab.org> - Disable codegen.printf_offsets test for LLVM5 CI build (ea8a7e4) by Alastair Robertson <alastair@ajor.co.uk> - Fix LLVM 5 tests (938e79b) by Alastair Robertson <alastair@ajor.co.uk> - Refactor find_wildcard_matches() to allow for proper testing (371c7cf) by Alastair Robertson <alastair@ajor.co.uk> - tests: Use Python 3 for integration tests + test fix (#651) (4b0e477) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Add --unsafe to more runtime tests (8b2234a) by Daniel Xu <dxu@dxuuu.xyz> - Fix 'ignoring return value' build warning (bdc9f16) by Augusto Caringi <acaringi@redhat.com> - Fix 'signed overflow' related build warning (0ece2a9) by Augusto Caringi <acaringi@redhat.com> - Fix UnboundLocalError on skipped test (03958cb) by John Gallagher <john.gallagher@delphix.com> - Use getopt_long instead of getopt (d732298) by Daniel Xu <dxu@dxuuu.xyz> - Fix docs typo (05bf095) by bas smit <bas@baslab.org> - check explicitly for systemtap sys/sdt.h and ignore if not present (831633d) by Jason Koch <jkoch@netflix.com> - Suppress build warning in GCC >=8 caused by #474 (71d1cd5) by Augusto Caringi <acaringi@redhat.com> - Remove more tabs (e9594dd) by Alastair Robertson <alastair@ajor.co.uk> - Convert tabs to spaces (585e8b5) by Alastair Robertson <alastair@ajor.co.uk> - Add existence tests for kstack, kstack() and ustack() (954d93d) by Alastair Robertson <alastair@ajor.co.uk> - [tests] more runtime tests enhancements (#586) (249c7a1) by Matheus Marchini <mat@mmarchini.me> - Codegen: Fix assigning non-struct "internal" values to maps (4020a5c) by Alastair Robertson <alastair@ajor.co.uk> - Fix typo on LLVM_REQUESTED_VERSION macro in CMakeLists.txt (82dbe4e) by Quentin Monnet <quentin.monnet@netronome.com> - Fix build warning (a77becb) by Alastair Robertson <alastair@ajor.co.uk> - [tests] allow tests to be skipped if a given condition is not met (59fa32a) by Matheus Marchini <mat@mmarchini.me> - [tests] make other.if_compare_and_print_string less flaky (840bbb3) by Matheus Marchini <mat@mmarchini.me> - Fix compile warnings and mark more functions as const (cfb058d) by Alastair Robertson <alastair@ajor.co.uk> - Misc readability fixes (9581e01) by Fangrui Song <i@maskray.me> - build: unify dockerfiles under a bionic image (445fb61) by Matheus Marchini <mat@mmarchini.me> - [tests] fix and enhance runtime tests (ea5deb9) by Matheus Marchini <mat@mmarchini.me> - [tests] add test script to run tools with -d (4ff113d) by Matheus Marchini <mat@mmarchini.me> - [clang_parser] decouple kernel cflags from the parser method (ad753d5) by Matheus Marchini <mat@mmarchini.me> - Address TODO items related to objdump dependency (382b9b7) by Adam Jensen <acjensen@gmail.com> - Fall back to objdump/grep if bcc is older (fdd02ec) by Adam Jensen <acjensen@gmail.com> - [clang_parser] pass BPFtrace as arg instead of StructMap (a0af75f) by Matheus Marchini <mat@mmarchini.me> - [ast] introduce Identifier type to AST (389d55f) by Matheus Marchini <mat@mmarchini.me> - use CMAKE_SYSTEM_PROCESSOR when selecting whether to include x86_64 or aarch64 sources (0ea7a63) by Michał Gregorczyk <michalgr@fb.com> - Clearify error message for mismatched llvm. (9b77fee) by George Slavin <george.r.slavin@gmail.com> - Add more info to LLVM mismatch error message (1e3b1be) by George Slavin <george.r.slavin@gmail.com> - Allow 0 as kernel version during first attempt to call bcc_prog_load (13499ac) by Michał Gregorczyk <michalgr@fb.com> - Fix bpftrace_VERSION_MINOR in CMakeLists.txt (8 -> 9) (13321eb) by Matheus Marchini <mat@mmarchini.me> - Fix version information when not building inside a git repo (#489) (1f33126) by Augusto Caringi <acaringi@redhat.com> - Do not try to load bpf program with unknown kernel version (2c00b7f) by Michał Gregorczyk <michalgr@fb.com> - Add better checks for llvm version (4fe081e) by George Slavin <george.r.slavin@gmail.com> - Fix deprecated stack warning in builtin_stack test (a1aaed8) by George Slavin <george.r.slavin@gmail.com> - add test for 32-bit tp args (77f7cb7) by Brendan Gregg <bgregg@netflix.com> - tests: add some basic integration tests (e9805af) by Javier Honduvilla Coto <javierhonduco@gmail.com> - Fix and simplify lexer.l (57bae63) by Fangrui Song <i@maskray.me> - Fix 2 clang warnings: -Wmismatched-tags and -Wpessimizing-move (18da040) by Fangrui Song <i@maskray.me> - Revert "Stop linking against bcc-loader-static" (5b6352c) by Alastair Robertson <alastair@ajor.co.uk> - fix typo on BPF_FUNC_get_current_cgroup_id missing message (27371c3) by Jason Koch <jkoch@netflix.com> - propagate HAVE_GET_CURRENT_CGROUP_ID to ast modules (57e30da) by Jason Koch <jkoch@netflix.com> - Add missing include (5763dc2) by Michał Gregorczyk <michalgr@fb.com> - No need for `if` when we're not doing anything (a65ad14) by Alastair Robertson <alastair@ajor.co.uk> - Make indirect* related data static (24d9dd2) by Jiri Olsa <jolsa@kernel.org> - Fix issues, add tests and improve reliability of positional parameters (acec163,f2e1345) by Matheus Marchini <mat@mmarchini.me> ## [0.9.0] 2019-03-16 ### Deprecated - **Deprecate `sym()`**. Use `ksym()` instead (50a66d2) by williangaspar - **Deprecate `stack`**. Use `kstack` instead (e8b99cd) by williangaspar ### Added - List usdt probes with -l (fa7d5f3) by Timothy J Fontaine - Introduce perf formatting for ustack()/kstack() (db910b9) by Matheus Marchini - Add increment and decrement operators (++/--) (c8d8a08, 6aa66a1, 223d8d8, 1f82aaf, 8c5c4ea) by Dale Hamel - Add changelog file to keep track of unreleased changes (d11fb01) by Matheus Marchini - Allow args with multiple tracepoints (a0a905f, 2df50d3, cddae1a) by Brendan Gregg - Add elapsed builtin (0fde181) by Brendan Gregg - Add support to demangle C++ symbols in userspace stack traces (872525c) by Augusto Caringi - allow \r (e7f0584) by Brendan Gregg - Use debuginfo files information when available (1132d42) by Augusto Caringi - Add ustack([int limit])/kstack([int limit]) calls (08da997) by Matheus Marchini - Allow custom provider name in USDT probe definition (361245c, 80d640a, 20ddfed, c3a6ff1) by Dale Hamel - Detect kernel headers even if they are splitted into source/ and build/ directories (4d76385) by Kirill Smelkov - Add support for arm64 (aarch64) (47fa8aa) by Ali Saidi - Allow customizing stdout buffering mode via -b (1663b84) by Hongli Lai (Phusion) - Add support to list tracepoint arguments (#323) (4a048fc) by Augusto Caringi - Add `ksym` as a replacement for `sym` (50a66d2) by williangaspar - Add `kstack` as a replacement for `stack` (e8b99cd, 840712b, f8f7ceb,6ec9a02) by williangaspar - cmake: add BUILD_TESTING support (a56ab12) by Aleksa Sarai - Add --version (61a4650, eab3675) by williangaspar - Add hint to install docs and normalize format (c0084a2) by Daniel Xu - Make bpftrace -l list sofware and hardware types (#44) (acd9a80) by Augusto Caringi - Print program ID when the verbose option is enabled. (8e8258d) by David Calavera ### Changed - Use `struct` when casting on docs and tools (e2ba048) by Brendan Gregg - Allow using the `struct` keyword when casting (df03256) by williangaspar - Make path optional on usdts when attaching to pid (c1c7c83) by Timothy J Fontaine - Resolve binary name from PATH for usdts and uprobes (28f0834) by Matheus Marchini - Use map lookups instead of sequential checks in tcpdrop.bt and tcpretrans.bt (cb0969c) by Slavomir Kaslev - Implicitly declare variables to 0 if used but not defined (a408cc2) by Matheus Marchini - Sort all integer maps by values, ascending (c378f57) by Dale Hamel - Change Ubuntu install to LLVM 6.0 (98353bf) by Brendan Gregg - ignore EFAULT stack IDs (f080bbf) by Brendan Gregg - Usage updates (6de4101) by Brendan Gregg - make map stack indentation 4 chars (c1dd418) by Brendan Gregg - Print error messages on all `abort()` calls (5c2ca5b) by williangaspar - Lesson 9: Replace "stack" to "kstack" (1ac56bd) by CavemanWork - Use structs with semicolons in tools and documentation (85dba93) by Brendan Gregg - Allow semicolon after struct definition (5982c74) by williangaspar - remove unnecessary newlines in -l (bb4a83c) by Brendan Gregg - list sw/hw probes with full names (6f3e1c4) by Brendan Gregg - hist: split negative, zero, and one into separate buckets (48c0afb) by Brendan Gregg - lhist: interval notation tweak (43e7974) by Brendan Gregg - runqlat.bt: remove if semicolon (c10c0dc) by Brendan Gregg - Probe list optimizations and improvements (7f84552) by Augusto Caringi - Link against system installed bcc (#327) (4c3fbad) by Dan Xu - Make semicolon optional after if and unroll blocks (d74d403) by williangaspar - Avoid crashing if mistakenly just '-d' or '-v' is used (f2f6732) by Augusto Caringi - Return cleanly after printing help (1d41717) by Daniel Xu ### Fixed - Make sure we create map keys when we have all the typing information (971bd77) by Matheus Marchini - Fix for new bpf_attach_kprobe signature (080bef8) by Matheus Marchini - Fix string comparison improperly deallocating variables (ffa173a) by williangaspar - Fix probe keys on maps when the map is used more than one time (df81736) by Matheus Marchini - Fix using same variable name on multiple programs (61a14f2) by williangaspar - Fix build on old compilers (644943a, 1b69272) by Kirill Smelkov - Fix build with latest bcc (d64b36a) by williangaspar - Don't throw warning for undefined types in tracepoint structure definition if `args` is not used (f2ebe1a) by Matheus Marchini - Fix for 'redefinition of tracepoint' warning message (baaeade) by Augusto Caringi - Minor fixes in our documentation (0667533) by Matheus Marchini - Fix string comparison (5e114dd, 63acdb6) by williangaspar - Prevent empty trigger functions to be optimized away with -O2 (#218) (9f2069b) by Augusto Caringi - Fix -l behavior with shortcut probe names (2d30e31) by williangaspar - Fix alpine docker build (#372) (2b83b67) by Dan Xu - Fix tracepoint wildcards (946c785) by Brendan Gregg - tests: fix codegen test fot call_hist (342fd6d) by Matheus Marchini - docs: fix trivial typos (3da1980) by Xiaozhou Liu - Fix symbol translation for func, sym, and stack (6276fb5) by Brendan Gregg - Fix wrong package name in Ubuntu Dockerfile (f8e67a9) by xbe - Fix wrong package name in build instructions (8e597de) by Daniel Xu - Fix arguments and error messages for tracepoint shortcut `t` (0eddba7) by williangaspar ### Internal - Fix 'different signedness' warning messages in codegen call_[uk]stack.cpp (cb25318) by Augusto Caringi - Fix 'signedness' warning message in tracepoint_format_parser.cpp (c3e562f) by Augusto Caringi - Stop linking against bcc-loader-static (5fbb7a7) by Daniel Xu - Speeding up runtime tests (60c5d96) by williangaspar - docker: make sure debugfs is mounted (7dcfc47) by Zi Shen Lim - Better coverage for variable_clear() (34fdded) by williangaspar - Add missing space (c65e7c1) by puyuegang - Ignore warnings on code generated by bison (a935942) by Matheus Marchini - Ignore warnings from LLVM headers (b6c4fd6) by Matheus Marchini - Downgrade back to c++14 (f6986d8) by Matheus Marchini - Fix 'parameter not used' warning (2401ab3) by Matheus Marchini - Fix new build warning msg after c++17 was enabled (e4cbe48) by Augusto Caringi - Get rid of cmake CMP0075 policy warning (9b8208a) by Augusto Caringi - Use C++17 instead of C++14 (4b4d5dc) by Alex Birch - Re-enable more build warnings, fix related warnings #316 (8c383dc) by Augusto Caringi - Define `__BPF_TRACING__` before building (required for kernel 4.19+) (e0bf01d) by Kirill Smelkov - Re-enable subset of build warnings and fix some related warnings #316 (f0f56b0) by Augusto Caringi - Cleanup enforce_infinite_rmlimits : removed getrlimit() : Added error description using strerror() (d76465f) by T K Sourab - use the new libbcc API: bcc_{create_map, prog_load} when possible (c03c39f) by Xiaozhou Liu - resources: generate c++ file instead of c file (5e1350b) by Matheus Marchini - docker: disable runtime tests on CI (0667b92) by Matheus Marchini - Hide -inl.h header from interface (10a43d0) by Daniel Xu ## [0.8.0] - 2019-01-06 This is a release to aid packaging. bpftrace has not reached a 1.0 release status yet, as there are still development changes and things to fix. But what is here should be tremendously useful, provided you bear in mind that there will be some changes made to the programming language and command line options between now and a 1.0 release, so any tools or documentation written will become out of date and require changes. If you are anxiously waiting a 1.0 release, please consider contributing so that it can be released sooner. bpftrace-0.27.1/CLAUDE.md000077700000000000000000000000001526721631600161552AGENTS.mdustar00rootroot00000000000000bpftrace-0.27.1/CMakeLists.txt000066400000000000000000000200341526721631600161370ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.14) project(bpftrace) cmake_policy(SET CMP0057 NEW) # bpftrace version number components. set(bpftrace_VERSION_MAJOR 0) set(bpftrace_VERSION_MINOR 27) set(bpftrace_VERSION_PATCH 1) include(GNUInstallDirs) set(WARNINGS_AS_ERRORS OFF CACHE BOOL "Build with -Werror") set(HARDENED_STDLIB OFF CACHE BOOL "Enable hardened definitions for standard library (for development use only)") set(STATIC_LINKING OFF CACHE BOOL "Build bpftrace as a statically linked executable") set(BUILD_ASAN OFF CACHE BOOL "Build bpftrace with -fsanitize=address") set(BUILD_UBSAN OFF CACHE BOOL "Build bpftrace with -fsanitize=undefined") set(ENABLE_MAN ON CACHE BOOL "Build man pages") set(BUILD_TESTING ON CACHE BOOL "Build test suite") set(ENABLE_SYSTEMD OFF CACHE BOOL "Enable systemd integration") set(KERNEL_HEADERS_DIR "" CACHE PATH "Hard-code kernel headers directory") set(SYSTEM_INCLUDE_PATHS "auto" CACHE STRING "Hard-code system include paths (colon separated, the default value \"auto\" queries clang at runtime)") set(USE_SYSTEM_LIBBPF OFF CACHE BOOL "Use system libbpf instead of vendoring it from a submodule") set(ENABLE_SKB_OUTPUT ON CACHE BOOL "Enable skb_output, will include libpcap") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set (CMAKE_CXX_STANDARD 20) set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_CXX_EXTENSIONS OFF) add_compile_options("-Wall") add_compile_options("-Wextra") add_compile_options("-Werror=undef") add_compile_options("-Wpointer-arith") add_compile_options("-Wcast-align") add_compile_options("-Wwrite-strings") add_compile_options("-Wcast-qual") add_compile_options("-Wunreachable-code") add_compile_options("-Wdisabled-optimization") # libbpf has a standardized macro which requires partial initialization. In # general this is well-specified [1] and will zero-initialize (or run default # constructors) for non-specified fields, which is what we want. Therefore, # we disable this warning broadly and allow this syntax. # [1]: https://en.cppreference.com/w/cpp/language/aggregate_initialization.html add_compile_options("-Wno-missing-field-initializers") add_compile_definitions( $<$:_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG> $<$:_GLIBCXX_ASSERTIONS> $<$,$>:_FORTIFY_SOURCE=3> ) add_compile_options($<$:-Werror>) # Clang compiler produces narrowing errors when calling BPF_LD_MAP_FD in the bcc library # Turning off them before bcc library fixes this add_compile_options($<$:-Wno-narrowing>) include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_BINARY_DIR}/src) include_directories(${CMAKE_BINARY_DIR}) # Ninja buffers output so gcc/clang think it's not an interactive session. # Colors are useful for compiler errors so force the color add_compile_options( $<$,$>:-fdiagnostics-color=always> $<$,$>:-fcolor-diagnostics> ) include(CTest) if(STATIC_LINKING) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_LINK_SEARCH_START_STATIC TRUE) set(CMAKE_LINK_SEARCH_END_STATIC TRUE) endif(STATIC_LINKING) set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE ) include_directories(SYSTEM ${KERNEL_INCLUDE_DIRS}) find_package(ZLIB REQUIRED) include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) find_package(LibBcc REQUIRED) include_directories(SYSTEM ${LIBBCC_INCLUDE_DIRS}) find_package(LibBpf REQUIRED) if(USE_SYSTEM_LIBBPF) include_directories(SYSTEM ${LIBBPF_INCLUDE_DIRS}) message(WARNING "Using system libbpf, please ensure that the version is greater than or equal to the submodule") else() include_directories(BEFORE SYSTEM ${LIBBPF_INCLUDE_DIRS}) endif() find_package(LibElf REQUIRED) include_directories(SYSTEM ${LIBELF_INCLUDE_DIRS}) find_package(LibCereal REQUIRED) include_directories(SYSTEM ${LIBCEREAL_INCLUDE_DIRS}) include(CheckSymbolExists) set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) check_symbol_exists(name_to_handle_at "sys/types.h;sys/stat.h;fcntl.h" HAVE_NAME_TO_HANDLE_AT) set(CMAKE_REQUIRED_DEFINITIONS) # Newer libbfd requires zstd so let's find that first find_library(LIBZSTD_LIBRARIES NAMES zstd PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) find_package(LibBfd) find_package(LibOpcodes) find_package(LibDw) if(ENABLE_SKB_OUTPUT) find_package(LibPcap) endif() if(ENABLE_SYSTEMD) find_package(PkgConfig) pkg_check_modules(libsystemd REQUIRED IMPORTED_TARGET libsystemd) endif() find_package(LibBlazesym) if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) endif() if(${LIBBFD_FOUND} AND ${LIBOPCODES_FOUND}) set(HAVE_BFD_DISASM TRUE) endif() # Some users have multiple versions of llvm installed and would like to specify # a specific llvm version. if(${LLVM_REQUESTED_VERSION}) find_package(LLVM ${LLVM_REQUESTED_VERSION} REQUIRED) else() find_package(LLVM REQUIRED) endif() set(MIN_LLVM_MAJOR 18) if(CMAKE_BUILD_TYPE STREQUAL "Debug") # We assume bpftrace is not being packaged when CMAKE_BUILD_TYPE=Debug. # So allow building with any LLVM version. This is purely for developers. # Packagers are highly discouraged from shipping bpftrace with untested LLVM # releases. set(MAX_LLVM_MAJOR 999) else() set(MAX_LLVM_MAJOR 23) endif() if((${LLVM_VERSION_MAJOR} VERSION_LESS ${MIN_LLVM_MAJOR}) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER ${MAX_LLVM_MAJOR})) message(SEND_ERROR "Unsupported LLVM version found via ${LLVM_INCLUDE_DIRS}: ${LLVM_VERSION_MAJOR}") message(SEND_ERROR "Only versions between ${MIN_LLVM_MAJOR} and ${MAX_LLVM_MAJOR} are supported") message(SEND_ERROR "Specify an LLVM major version using LLVM_REQUESTED_VERSION=") endif() message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}: ${LLVM_CMAKE_DIR}") include_directories(SYSTEM ${LLVM_INCLUDE_DIRS}) if(LLVM_DEFINITIONS MATCHES ";") set(LLVM_DEFINITIONS_LIST ${LLVM_DEFINITIONS}) else() separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND "${LLVM_DEFINITIONS}") endif() add_definitions(${LLVM_DEFINITIONS_LIST}) string(REGEX REPLACE "(-rc[0-9]+|git)" "" CLANG_VERSION ${LLVM_PACKAGE_VERSION}) find_package(Clang ${CLANG_VERSION} REQUIRED) include_directories(SYSTEM ${CLANG_INCLUDE_DIRS}) # DWARF-based user-space stack unwinding requires x86_64 and LLVM >= 21 if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64" AND LLVM_VERSION_MAJOR GREATER_EQUAL 21) set(HAVE_DW_UNWIND TRUE) endif() # BPFtrace compile definitions set(BPFTRACE_FLAGS) if(HAVE_NAME_TO_HANDLE_AT) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_NAME_TO_HANDLE_AT=1) endif(HAVE_NAME_TO_HANDLE_AT) if(HAVE_BFD_DISASM) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_BFD_DISASM) if(LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE) endif(LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE) endif(HAVE_BFD_DISASM) if(LIBDW_FOUND) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBDW) endif() if(LIBPCAP_FOUND) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBPCAP) endif(LIBPCAP_FOUND) if(ENABLE_SYSTEMD) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBSYSTEMD) endif() if(LIBBLAZESYM_FOUND) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_BLAZESYM) include_directories(SYSTEM ${LIBBLAZESYM_INCLUDE_DIRS}) endif() if(HAVE_DW_UNWIND) set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_DW_UNWIND) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(tests) endif() add_subdirectory(tools) if (ENABLE_MAN) add_subdirectory(man) endif(ENABLE_MAN) set(BASH_COMPLETION_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/bash-completion/bpftrace) install(FILES ${BASH_COMPLETION_PATH} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions) if(NOT TARGET uninstall) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CmakeUninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/CmakeUninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CmakeUninstall.cmake) endif() bpftrace-0.27.1/CONTRIBUTING.md000066400000000000000000000106541526721631600156370ustar00rootroot00000000000000# Contributing Contributions are welcome! Please see the [development section](#development) below for more information. * Bug reports and feature requests: [Issue Tracker](https://github.com/bpftrace/bpftrace/issues) * Development IRC: #bpftrace at irc.oftc.net * [Good first issues](https://github.com/bpftrace/bpftrace/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) ## Contributing Tools We encourage everyone to write and share bpftrace tools! Feel free to write your own tools and host them wherever you like. For tools that you'd like to share with the community, you may also submit them to the [user-tools repository](https://github.com/bpftrace/user-tools/blob/master/CONTRIBUTING.md). This repository serves as a community hub. The tools in this main bpftrace repository are a small collection of examples curated by the maintainers. These have been battle-tested in production and are packaged with bpftrace. They also serve for testing and validation purposes. ## Development * [Design Principles](docs/design_principles.md) * [Coding Guidelines](docs/coding_guidelines.md) * [RFC Process](#rfc-process) * [Development Guide](docs/developers.md) * [Development Roadmap](https://docs.google.com/document/d/17729Rlyo1xzlJObzHpFLDzeCVgvwRh0ktAmMEJLK-EU/edit) * [Fuzzing](docs/fuzzing.md) * [Nix](docs/nix.md) * [Release Process](docs/release_process.md) * [Tests](tests/README.md) * [DCO](#developers-certificate-of-origin) ## RFC Process This is for "substantial" or breaking changes. Bug fixes, doc updates, small features, and issues tagged with "good first issue" can utilize the normal github pull request workflow. 1. Create a new issue, where the title is prefixed with "RFC" and apply the RFC tag ([example](https://github.com/bpftrace/bpftrace/issues/2954)). Be sure to include the goal(s) of this change, potential downsides (if applicable), and other solutions you've considered. This issue is where discussions can be had about the overall design and approach. For the most part implementation details should NOT be discussed as they often lead to bike-shedding of the overall proposal. 1. If there is either positive signal from one or more of the maintainers or a lack of negative signal feel free to create a POC and, when you're ready, submit a pull request (linking to the original RFC). This is a good place to have others experiment with your POC and discuss implementation details. - It's entirely possible that this POC exposes underlying issues in the original, approved RFC. That's OK! Return to the original RFC and explain why the approved solution does not work or needs adjustment. If the changes are significant enough, the maintainers might ask for an additional approval of the new approach on the RFC. It's also possible that the RFC then gets rejected; these things happen and they are a normal part of the development process. - Depending on the change, you might be asked to gate this behind a "config flag". Meaning that users have to explicitly opt-in to this feature via the addition of a config flag in their script e.g. ```config = { unstable_my_feature=true }``` This allows us to increase development velocity and wait for more user feedback without permanently adding it to bpftrace. Now, it is possible that this feature still may end up getting removed and not added to the language due to user issues or changes in design direction. However, there will be plenty of communication between the maintainers and the original author if this is the case. 1. If the POC is approved by two or more maintainers, please follow the current pull request checklist: - add it to the CHANGELOG - update the adoc - ensure there are unit test and runtime tests **Note**: ## Developer's Certificate of Origin To improve tracking of who did what we’ve introduced a “sign-off� procedure. The sign-off is a simple line at the end of every commit, which certifies that you wrote it or otherwise have the right to pass it on as an open-source contribution. The rules are pretty simple: [Developer's Certificate of Origin](https://developercertificate.org/). If you can certify those rules then sign-off all commits with the `--signoff` option provided by `git commit`. For example: ``` git commit --signoff --message "This is the commit message" ``` This option adds a `Signed-off-by` trailer at the end of the commit log message. Please use your real name and an actual email address (sorry, no anonymous contributions, github logins, etc.). bpftrace-0.27.1/GOVERNANCE.md000066400000000000000000000236251526721631600153610ustar00rootroot00000000000000# Governance This document describes the governance model for bpftrace. It is intended to be a living document that is updated as the project evolves. ## Overview bpftrace is a meritocratic, consensus-based community project. Anyone with an interest in the project can join the community, contribute to the project design and participate in the decision making process. This document describes how that participation takes place and how to set about earning merit within the bpftrace community. ## Roles and responsibilities ### Users Users are community members who have a need for the project. They are the most important members of the community and without them the project would have no purpose. Anyone can be a user; there are no special requirements. The project asks its users to participate in the project and community as much as possible. User contributions enable the project team to ensure that they are satisfying the needs of those users. Common user contributions include (but are not limited to): - evangelising about the project (e.g. a link on a website and word-of-mouth awareness raising) - informing developers of strengths and weaknesses from a new user perspective - providing moral support (a ‘thank you’ goes a long way) Users who continue to engage with the project and its community will often become more and more involved. Such users may find themselves becoming contributors, as described in the next section. ### Contributors Contributors are community members who contribute in concrete ways to the project. Anyone can become a contributor. There is no expectation of commitment to the project, no specific skill requirements and no selection process. In addition to their actions as users, contributors may also find themselves doing one or more of the following: - supporting new users (existing users are often the best people to support new users) - reporting bugs - answering/responding to issues and discussions - identifying requirements - coding - assisting with project infrastructure (e.g. Github CI) - writing documentation - fixing bugs - adding features - facilitating distrubtion (e.g. packaging for distributions) Contributors primarily engage with the project through the mechanisms in Github. They submit changes to the project itself via Github Pull Requests, which will be considered for inclusion in the project by existing maintainers and committers (see sections below). The most appropriate place to ask for help when making a first contribution is on the issue itself; there is a curated [list of "good first issues"](https://github.com/bpftrace/bpftrace/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22). As contributors gain experience and familiarity with the project, their profile within, and commitment to, the community will increase. At some stage, they may find themselves being nominated for committership. ### Committers Committers are community members who have shown that they are committed to the continued development of the project through ongoing engagement with the community. Committership allows contributors to more easily carry on with their project related activities by giving them write access, meaning they can merge approved PRs themselves. This does not mean that a committer is free to do what they want. In fact, committers have no more authority over the project than contributors. While committership indicates a valued member of the community who has demonstrated a healthy respect for the project’s aims and objectives, their work continues to be reviewed by the maintainers before acceptance. The key difference between a committer and a contributor is when this approval is sought from the community. A committer seeks approval after the contribution is made, rather than before. Seeking approval after making a contribution is known as a commit-then-review process. It is more efficient to allow trusted people to make direct contributions, as the majority of those contributions will be accepted by the project. The project employs various communication mechanisms to ensure that all contributions are reviewed by the community as a whole. By the time a contributor is invited to become a committer, they will have become familiar with the project’s various tools as a user and then as a contributor. Anyone can become a committer; there are no special requirements, other than to have shown a willingness and ability to participate in the project as a team player. Typically, a potential committer will need to show that they have an understanding of the project, its objectives and its strategy. They will also have provided valuable contributions to the project over a period of time. New committers can be nominated by any existing maintainer (see below). Once they have been nominated, there will be an informal majority among the maintainers. It is important to recognise that commitership is a privilege, not a right. That privilege must be earned and once earned it can be removed by the maintainers in extreme circumstances. However, under normal circumstances committership exists for as long as the committer wishes to continue engaging with the project. A committer who shows an above-average level of contribution to the project, particularly with respect to its strategic direction and long-term health, may be nominated to become a maintainer. This role is described below. ### Maintainers The maintainers of bpftrace consist of those individuals identified as [‘code owners’](https://github.com/bpftrace/bpftrace/blob/master/.github/CODEOWNERS). Maintainers have additional responsibilities over and above those of a committer. These responsibilities ensure the smooth running of the project. Maintainers are expected to: - Review PRs. Since maintainer approval is required for any changes, the project's velocity hinges on speedy turnaround times for reviews. We also don’t want to discourage new contributors by having their PRs sit in Github purgatory. - Attend monthly office hours. - Respond to discussions, questions, and issues. Maintainers have a broader context than most and being responsive also keeps bpftrace users from getting discouraged. - Mentor and teach new developers. Guide these folks on first issues. - Participate in planning and larger design and project decisions. - Help triage and groom the issue backlog. Maintainers vote on new committers and new maintainers. They make decisions when community consensus cannot be reached. In addition, at least one approval from a maintainer is required for each submitted Pull Request. To become a maintainer, you have to first be a committer. Any maintainer can nominate a committer for maintainership. Once they have been nominated, there will be an informal majority vote amongst maintainers only over email (see details below about voting). ## Support All participants in the community are encouraged to provide support for new users within the project management infrastructure. This support is provided as a way of growing the community. Those seeking support should recognise that all support activity within the project is voluntary and is therefore provided as and when time allows. There are currently no mechanisms set up for users requiring guaranteed response times or results. ## Contribution process Anyone can contribute to the project, regardless of their skills. First time contributors should look through the [list of "good first issues"](https://github.com/bpftrace/bpftrace/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22) and ask questions on the issue(s) they are interested in picking up. Here is [a more detailed guide on contributing](CONTRIBUTING.md). ## Decision making process Decisions about the future of the project are made through discussion with all members of the community, from the newest user to the most experienced maintainer. All non-sensitive project management discussion takes place on the bpftrace Github project, often times in the [issues](https://github.com/bpftrace/bpftrace/issues) themselves. Occasionally, sensitive discussion occurs offline among the maintainers. ### Merging Code At least one approval from a maintainer is required for each submitted Pull Request; this also applies to maintainers in all cases where the changes are non-trivial. If there is a disagreement among maintainers (or changes requested despite an approval from another maintainer), please allow time for the maintainers to work out the issue amongst themselves or do your best to answer/address the concerns of the dissenting maintainer. ### Proposals and RFCS Any community member can make a proposal or RFC for consideration by the community via [this guide](CONTRIBUTING.md#rfc-process). In general, as long as nobody explicitly opposes a proposal or patch, it is recognised as having the support of the community. This is called lazy consensus - that is, those who have not stated their opinion explicitly have implicitly agreed to the implementation of the proposal. ### Voting Formal voting only occurs when the consensus-based process has been fully exhausted. Meaning if maintainers can't come to an agreement, there will be a vote amongst the maintainers. However, every member of the community is encouraged to express their opinions in all discussions, RFCs, and strategies. A simple majority wins the vote. If there is no majority the proposal or decision is rejected. Maintainers have 10 days to vote otherwise their vote is forfeit. ## Conclusion A clear and transparent governance document is a key part of any open development project. It defines the rules of engagement within the community and describes what level of influence a community member can expect to have over a project. In addition, it enables members to decide their level of involvement with that community. In the case of a meritocracy, it also provides a clear way to contribute and a highly visible reward system. Most of the language in this document was taken from [OSS Watch](http://oss-watch.ac.uk/resources/meritocraticgovernancemodel). bpftrace-0.27.1/LICENSE000066400000000000000000000261361526721631600144150ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. bpftrace-0.27.1/README.md000066400000000000000000000204231526721631600146600ustar00rootroot00000000000000

bpftrace

[![Build Status](https://github.com/bpftrace/bpftrace/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/bpftrace/bpftrace/actions/workflows/ci.yml) [![Latest Release](https://img.shields.io/github/v/release/bpftrace/bpftrace)](https://github.com/bpftrace/bpftrace/releases/latest) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/bpftrace/bpftrace/blob/master/LICENSE) bpftrace is a general purpose tracing tool and language for Linux. It leverages [eBPF](https://ebpf.io/what-is-ebpf/) to provide powerful, efficient tracing capabilities with minimal overhead. bpftrace uses [LLVM](https://llvm.org/) as a compiler backend, and [libbpf](https://github.com/libbpf/libbpf) for interacting with the Linux BPF subsystem, including kernel dynamic tracing ([kprobes](https://docs.kernel.org/trace/kprobes.html), [hardware and software perf events](https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_PERF_EVENT/)), user-level dynamic tracing ([USDT](https://docs.ebpf.io/linux/concepts/usdt/), [uprobes](https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_KPROBE/)), tracepoints ([regular](https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_TRACEPOINT/), [raw](https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_RAW_TRACEPOINT/)), and [more](https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_TRACING/). The bpftrace language is inspired by awk, C, and predecessor tracers such as DTrace and SystemTap. Visit **[bpftrace.org](https://bpftrace.org/)** for [tutorials](https://bpftrace.org/tutorial-one-liners), [documentation](https://bpftrace.org/docs), and [labs](https://bpftrace.org/hol/intro)! This respository also contains some [canonical tools](tools/README.md). For migrating from older versions, see the [migration guide](docs/migration_guide.md). ## Quick Start Get started with bpftrace in just a few minutes! To build from source, see the [development guide](docs/developers.md#building). However, you can often install it using your distribution's [package manager](https://pkgs.org/search/?q=bpftrace). > [!IMPORTANT] > When using a distribution package, be sure to verify `bpftrace --version` when referencing documentation.
Distributions Command
Ubuntu 22.04 Ubuntu 24.04 Ubuntu 25.04 Ubuntu 25.10 Debian 13 Debian 14 Debian Unstable
sudo apt install bpftrace
    
Fedora 42 Fedora 43 Fedora Rawhide CentOS 9 CentOS 10
sudo dnf install bpftrace
Alpine 3.21 Alpine 3.22 Alpine Edge
sudo apk add bpftrace
Arch Linux
sudo pacman -S bpftrace
Gentoo
sudo emerge -av bpftrace
nixpkgs
nix-shell -p bpftrace
openSUSE Tumbleweed
sudo zypper install bpftrace
AppImage (nightly)
declare -A suffixes=([x86_64]="X64" [amd64]="AMD64");
declare prefix="bpftrace/bpftrace/workflows/binary/master/bpftrace";
declare url="https://nightly.link/${prefix}-${suffixes[$(uname -m)]}.zip";
curl -L -o bpftrace.zip "${url}" && unzip bpftrace.zip
## Contributing See our [contributing guide](CONTRIBUTING.md) for details on how to contribute, and our [governance](GOVERNANCE.md) document for details on how the project is run. If you have tools built with bpftrace that you'd like to submit, please contribute to the [user-tools repository](https://github.com/bpftrace/user-tools/blob/master/CONTRIBUTING.md). ## Building For full build instructions (Nix or distro-native), see the [development guide](docs/developers.md#building). ## Community & Support bpftrace is built and maintained by a diverse community of contributors, users, and organizations who rely on it for production tracing and debugging. **Get help or get involved:** - 💬 [GitHub Discussions](https://github.com/bpftrace/bpftrace/discussions) - Ask questions - ðŸ�› [Issue Tracker](https://github.com/bpftrace/bpftrace/issues) - Report bugs and request features - 📅 [Monthly Office Hours](https://docs.google.com/document/d/1nt010RfL4s4gydhCPSJ-Z5mnFMFuD4NrcpVmUcyvu2E/edit?usp=sharing) - Open to everyone - 💬 [Discord](https://discord.gg/3tnjU2fTWr) - Open to everyone (if the link expired, write to #4916) bpftrace-0.27.1/cmake/000077500000000000000000000000001526721631600144605ustar00rootroot00000000000000bpftrace-0.27.1/cmake/BuildBPF.cmake000066400000000000000000000141741526721631600170600ustar00rootroot00000000000000# Functions to build intermediate BPF modules. # # The `bpf` function will produce bitcode, an object as well as the BTF type # information for a given file. find_program(GCC gcc REQUIRED) find_program(BPFTOOL bpftool REQUIRED) find_program(PAHOLE pahole REQUIRED) find_program(NM nm REQUIRED) find_program(AWK awk REQUIRED) find_program(LLVM_OBJCOPY NAMES llvm-objcopy llvm-objcopy-${LLVM_VERSION_MAJOR} llvm${LLVM_VERSION_MAJOR}-objcopy REQUIRED) find_program(CLANG NAMES clang-${LLVM_VERSION_MAJOR} REQUIRED) function(bpf NAME) cmake_parse_arguments( ARG "" "BITCODE;OBJECT;BINARY;BTF;SOURCE;BTF_BASE;FUNCTIONS" "DEPENDS" ${ARGN} ) if (NOT DEFINED ARG_SOURCE) set(ARG_SOURCE "${NAME}.c") endif () if (NOT DEFINED ARG_OBJECT) set(ARG_OBJECT "${NAME}.o") endif () add_custom_target(${NAME}) # The joys of BPF & debug tooling 101. # # The purpose for this function is to generate various types of output for a # given source file, for testing and embedding purposes: # * LLVM bitcode file compatible with our major version of LLVM. # * A binary annotated with DWARF type information. # * Encoded BTF type information for this source unit. # * A list of functions defined in the file. # # Naturally, you'd assume that this could be implementated mostly as a chain # of steps, save the intermediate results along the way. Wrong! Unfortunately, # each of these steps has their own happy path. # # First, the bitcode. This is actually straight-forward! We need to ensure # that this gets built with the correct version of LLVM (not whatever # compiler CMAKE has selected) so that it is compatible with the LLVM # libraries that we are linking against. We can even correctly select bpf as # our target, to get the extent that there is any early specialization. # # Next, you might assume that taking this bitcode and turning it into a BPF # object is the logical thing to do, in order to ensure that all the types # are compatible and consistent. In fact, this even *seems* to work. But # after banging your head on the keyboard for a while, you'll realize that # something is broken. As you contort clang, and try building from scratch, # you'll realize that clang seems to generate proper annotations and # relocations for loadable programs (the happy path for that!), but fails to # generate the same types for base types. In fact, in doesn't even generate # named arguments without an explicit `-O2`. Oh well, I suppose that the # common path for the kernel is to build with `gcc` and then rely on the # `pahole` conversion. Let's do that. # # But hold on a second, we said that we wanted to build a BPF target? Turns # out that `gcc` can't do that very well. So `clang` can't build our BPF # target because of incorrect BTF, and `gcc` can't build the BPF target. So # we need to build the source natively, use `pahole` to generate the BTF # data, and then extract that separately. This makes some sense, as it is the # kernel happy path. # # But at least what we built above has the DWARF data, right? Wrong! If we # were to link the full binary, too much gets stripped out to generate the # full set of BTF information. So we need to generate just the object, add # BTF information, and separately link that single object into a binary to # have the DWARF data in a ELF binary that we're looking for. # # Finally, we can breath a sight of relief and generate our list of # functions. Like the bitcode, this works as expected. if (DEFINED ARG_BITCODE) add_custom_command( OUTPUT ${ARG_BITCODE} DEPENDS ${ARG_SOURCE} ${ARG_DEPENDS} COMMAND ${CLANG} -emit-llvm -g -target bpf -D__TARGET_ARCH_x86 -I ${CMAKE_CURRENT_BINARY_DIR} -c ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${ARG_BITCODE} VERBATIM ) add_custom_target(${NAME}_gen_bitcode DEPENDS ${ARG_BITCODE}) add_dependencies(${NAME} ${NAME}_gen_bitcode) endif() add_custom_command( OUTPUT ${ARG_OBJECT} DEPENDS ${ARG_SOURCE} ${ARG_DEPENDS} # See above: fresh compilation and the use of `gcc`. COMMAND ${GCC} -Wno-attributes -g -I ${CMAKE_CURRENT_BINARY_DIR} -c ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} COMMAND cmake -E env LLVM_OBJCOPY=${LLVM_OBJCOPY} ${PAHOLE} -J ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} VERBATIM ) # You should never depend on the output of a custom command more than once. # Therefore, we define an intermediate target for the object, and depend on # this instead. See [1]. # [1] https://discourse.cmake.org/t/how-to-avoid-parallel-build-race-conditions/727 add_custom_target( ${NAME}_gen_object DEPENDS ${ARG_OBJECT} ) add_dependencies(${NAME} ${NAME}_gen_object) if (DEFINED ARG_BINARY) add_custom_command( OUTPUT ${ARG_BINARY} DEPENDS ${ARG_SOURCE} ${NAME}_gen_object COMMAND ${GCC} -g -o ${CMAKE_CURRENT_BINARY_DIR}/${ARG_BINARY} ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} COMMAND cmake -E env LLVM_OBJCOPY=${LLVM_OBJCOPY} ${PAHOLE} -J ${CMAKE_CURRENT_BINARY_DIR}/${ARG_BINARY} VERBATIM ) add_custom_target(${NAME}_gen_binary DEPENDS ${ARG_BINARY}) add_dependencies(${NAME} ${NAME}_gen_binary) endif() if (DEFINED ARG_BTF) add_custom_command( OUTPUT ${ARG_BTF} DEPENDS ${ARG_SOURCE} ${NAME}_gen_object # See above re: the use of the `gcc`-compiled object, ignoring the binary. COMMAND ${LLVM_OBJCOPY} --dump-section .BTF=${CMAKE_CURRENT_BINARY_DIR}/${ARG_BTF} ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} VERBATIM ) add_custom_target(${NAME}_gen_btf DEPENDS ${ARG_BTF}) add_dependencies(${NAME} ${NAME}_gen_btf) endif () if (DEFINED ARG_FUNCTIONS) add_custom_command( OUTPUT ${ARG_FUNCTIONS} DEPENDS ${ARG_SOURCE} ${NAME}_gen_object COMMAND ${NM} ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OBJECT} | ${AWK} -v ORS=\\\\n "$2 == \"T\" { print $3 }" > ${CMAKE_CURRENT_BINARY_DIR}/${ARG_FUNCTIONS} VERBATIM ) add_custom_target(${NAME}_gen_functions DEPENDS ${ARG_FUNCTIONS}) add_dependencies(${NAME} ${NAME}_gen_functions) endif () endfunction() bpftrace-0.27.1/cmake/CmakeUninstall.cmake.in000066400000000000000000000017501526721631600210040ustar00rootroot00000000000000# SPDX-License-Identifier: GPL-2.0-or-later # # Ref: # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake # if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") endif() file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") execute_process( COMMAND @CMAKE_COMMAND@ -E remove $ENV{DESTDIR}${file} OUTPUT_VARIABLE rm_out RESULT_VARIABLE rm_retval ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") endif() else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") message(STATUS "File $ENV{DESTDIR}${file} does not exist.") endif() endforeach() bpftrace-0.27.1/cmake/Embed.cmake000066400000000000000000000021771526721631600165050ustar00rootroot00000000000000# Functions to embed source files. find_program(XXD xxd REQUIRED) function(embed NAME SOURCE) cmake_parse_arguments( ARG "" "OUTPUT;HEX;VAR" "DEPENDS" ${ARGN} ) if (NOT DEFINED ARG_HEX) set(ARG_HEX "${NAME}.hex") endif () if (NOT DEFINED ARG_VAR) set(ARG_VAR "${NAME}") endif () if (NOT DEFINED ARG_OUTPUT) set(ARG_OUTPUT "${NAME}.h") endif () add_custom_command( OUTPUT ${ARG_HEX} COMMAND ${XXD} -i < ${SOURCE} > ${ARG_HEX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${SOURCE} ${ARG_DEPENDS} VERBATIM ) add_custom_command( OUTPUT ${ARG_OUTPUT} COMMAND ${CMAKE_COMMAND} -DSOURCE=${CMAKE_CURRENT_BINARY_DIR}/${ARG_HEX} -DVAR=${ARG_VAR} -DNAMESPACE=${ARG_NAMESPACE} -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/${ARG_OUTPUT} -DTEMPLATE=${CMAKE_SOURCE_DIR}/cmake/Embed.tmpl -P ${CMAKE_SOURCE_DIR}/cmake/EmbedRun.cmake DEPENDS ${ARG_HEX} ${CMAKE_SOURCE_DIR}/cmake/EmbedRun.cmake ${CMAKE_SOURCE_DIR}/cmake/Embed.tmpl VERBATIM ) add_custom_target( ${NAME} DEPENDS ${ARG_OUTPUT} ) endfunction() bpftrace-0.27.1/cmake/Embed.tmpl000066400000000000000000000001531526721631600163710ustar00rootroot00000000000000#pragma once namespace ${NAMESPACE} { constexpr unsigned char ${VAR}[] = { ${DATA} }; } // ${NAMESPACE} bpftrace-0.27.1/cmake/EmbedRun.cmake000066400000000000000000000004221526721631600171610ustar00rootroot00000000000000# This logic needs to be in a separate cmake script b/c file() runs # at cmake configuration stage and _not_ during build. So this script # is wrapped in a custom command so that it's only run when necessary. file(READ ${SOURCE} DATA) configure_file(${TEMPLATE} ${OUTPUT}) bpftrace-0.27.1/cmake/FindGMock.cmake000066400000000000000000000107451526721631600172720ustar00rootroot00000000000000# Locate the Google C++ Mocking Framework. # (This file is almost an identical copy of the original FindGTest.cmake file, # feel free to use it as it is or modify it for your own needs.) # # # Defines the following variables: # # GMOCK_FOUND - Found the Google Testing framework # GMOCK_INCLUDE_DIRS - Include directories # # Also defines the library variables below as normal # variables. These contain debug/optimized keywords when # a debugging library is found. # # GMOCK_BOTH_LIBRARIES - Both libgmock & libgmock-main # GMOCK_LIBRARIES - libgmock # GMOCK_MAIN_LIBRARIES - libgmock-main # # Accepts the following variables as input: # # GMOCK_ROOT - (as a CMake or environment variable) # The root directory of the gmock install prefix # # GMOCK_MSVC_SEARCH - If compiling with MSVC, this variable can be set to # "MD" or "MT" to enable searching a gmock build tree # (defaults: "MD") # #----------------------- # Example Usage: # # find_package(GMock REQUIRED) # include_directories(${GMOCK_INCLUDE_DIRS}) # # add_executable(foo foo.cc) # target_link_libraries(foo ${GMOCK_BOTH_LIBRARIES}) # #============================================================================= # This file is released under the MIT licence: # # Copyright (c) 2011 Matej Svec # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. #============================================================================= function(_gmock_append_debugs _endvar _library) if(${_library} AND ${_library}_DEBUG) set(_output optimized ${${_library}} debug ${${_library}_DEBUG}) else() set(_output ${${_library}}) endif() set(${_endvar} ${_output} PARENT_SCOPE) endfunction() function(_gmock_find_library _name) find_library(${_name} NAMES ${ARGN} HINTS $ENV{GMOCK_ROOT} ${GMOCK_ROOT} PATH_SUFFIXES ${_gmock_libpath_suffixes} ) mark_as_advanced(${_name}) endfunction() if(NOT DEFINED GMOCK_MSVC_SEARCH) set(GMOCK_MSVC_SEARCH MD) endif() set(_gmock_libpath_suffixes lib) if(MSVC) if(GMOCK_MSVC_SEARCH STREQUAL "MD") list(APPEND _gmock_libpath_suffixes msvc/gmock-md/Debug msvc/gmock-md/Release) elseif(GMOCK_MSVC_SEARCH STREQUAL "MT") list(APPEND _gmock_libpath_suffixes msvc/gmock/Debug msvc/gmock/Release) endif() endif() find_path(GMOCK_INCLUDE_DIR gmock/gmock.h HINTS $ENV{GMOCK_ROOT}/include ${GMOCK_ROOT}/include ) mark_as_advanced(GMOCK_INCLUDE_DIR) if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD") # The provided /MD project files for Google Mock add -md suffixes to the # library names. _gmock_find_library(GMOCK_LIBRARY gmock-md gmock) _gmock_find_library(GMOCK_LIBRARY_DEBUG gmock-mdd gmockd) _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main-md gmock_main) _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_main-mdd gmock_maind) else() _gmock_find_library(GMOCK_LIBRARY gmock) _gmock_find_library(GMOCK_LIBRARY_DEBUG gmockd) _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main) _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_maind) endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY GMOCK_INCLUDE_DIR GMOCK_MAIN_LIBRARY) if(GMOCK_FOUND) set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR}) _gmock_append_debugs(GMOCK_LIBRARIES GMOCK_LIBRARY) _gmock_append_debugs(GMOCK_MAIN_LIBRARIES GMOCK_MAIN_LIBRARY) set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES}) endif() bpftrace-0.27.1/cmake/FindLibBcc.cmake000066400000000000000000000056151526721631600174100ustar00rootroot00000000000000# - Try to find libbcc # Once done this will define # # LIBBCC_FOUND - system has libbcc # LIBBCC_INCLUDE_DIRS - the libbcc include directory # LIBBCC_LIBRARIES - Link these to use libbcc # LIBBCC_DEFINITIONS - Compiler switches required for using libbcc # LIBBCC_BPF_LIBRARIES - libbcc runtime library # LIBBCC_LOADER_LIBRARY_STATIC - libbcc helper static library (for static compilation) # LIBBCC_BPF_CONTAINS_RUNTIME - whether libbcc_bpf.so has been expanded to contain everything !llvm & !clang # # Note that the shared libbcc binary has libbpf and bcc_loader already compiled in but # the static doesn't. So when creating a static build those have to be included too. if (LIBBCC_LIBRARIES AND LIBBCC_INCLUDE_DIRS) set (LibBcc_FIND_QUIETLY TRUE) endif (LIBBCC_LIBRARIES AND LIBBCC_INCLUDE_DIRS) find_path (LIBBCC_INCLUDE_DIRS NAMES bcc/bcc_syms.h PATHS ENV CPATH ) find_library (LIBBCC_LIBRARIES NAMES bcc PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH ) find_library (LIBBCC_BPF_LIBRARIES NAMES bcc_bpf PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) find_library (LIBBCC_LOADER_LIBRARY_STATIC NAMES bcc-loader-static PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) set(LIBBCC_ERROR_MESSAGE "Please install the bcc library package, which is required. Depending on your distro, it may be called bpfcclib or bcclib (Ubuntu), bcc-devel (Fedora), or something else. If unavailable, install bcc from source (github.com/iovisor/bcc).") include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBBCC_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBcc ${LIBBCC_ERROR_MESSAGE} LIBBCC_LIBRARIES LIBBCC_INCLUDE_DIRS) # Check bpf_attach_kprobe signature if(${LIBBCC_FOUND}) if(STATIC_LINKING) # libbcc.a is not statically linked with libbpf.a, libelf.a, libz.a, and liblzma.a. # If we do a static bpftrace build, we must link them in. find_package(LibLzma) if(ANDROID) # libz is part of the Android NDK; link against it dynamically SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_BPF_LIBRARIES} ${LIBBPF_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBLZMA_LIBRARIES}) SET(CMAKE_REQUIRED_LINK_OPTIONS "-lz") else() find_package(LibZ) SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_BPF_LIBRARIES} ${LIBBPF_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBLZMA_LIBRARIES} ${LIBZ_LIBRARIES}) endif() else() SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_LIBRARIES} ${LIBBPF_LIBRARIES}) endif() INCLUDE(CheckCXXSourceCompiles) SET(CMAKE_REQUIRED_INCLUDES ${LIBBCC_INCLUDE_DIRS}) SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_BPF_LIBRARIES}) include(CheckSymbolExists) # N.B. we don't use bcc_usdt_foreach - it's just a proxy for seeing if the libbcc runtime exists check_symbol_exists(bcc_usdt_foreach ${LIBBCC_INCLUDE_DIRS}/bcc/bcc_usdt.h LIBBCC_BPF_CONTAINS_RUNTIME) SET(CMAKE_REQUIRED_LIBRARIES) SET(CMAKE_REQUIRED_INCLUDES) endif(${LIBBCC_FOUND}) bpftrace-0.27.1/cmake/FindLibBfd.cmake000066400000000000000000000054731526721631600174160ustar00rootroot00000000000000# - Try to find libbfd # Once done this will define # # LIBBFD_FOUND - system has libbfd # LIBBFD_INCLUDE_DIRS - the libbfd include directory # LIBBFD_LIBRARIES - Link these to use libbfd # LIBBFD_DEFINITIONS - Compiler switches required for using libbfd # LIBIBERTY_LIBRARIES - libiberty static library (for static compilation) # LIBZ_LIBRARIES - libz static library (for static compilation) #if (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS) # set (LibBpf_FIND_QUIETLY TRUE) #endif (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS) find_path (LIBBFD_INCLUDE_DIRS NAMES bfd.h PATHS ENV CPATH) find_library (LIBBFD_LIBRARIES NAMES bfd PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) if (${LIBBFD_LIBRARIES} MATCHES ".*libbfd.a$") set(LIBBFD_STATIC TRUE) else() set(LIBBFD_STATIC FALSE) endif() include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBBFD_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBfd "Please install the libbfd development package" LIBBFD_LIBRARIES LIBBFD_INCLUDE_DIRS) mark_as_advanced(LIBBFD_INCLUDE_DIRS LIBBFD_LIBRARIES) if(${LIBBFD_FOUND}) find_package(LibOpcodes) SET(CMAKE_REQUIRED_LIBRARIES ${LIBBFD_LIBRARIES} ${LIBOPCODES_LIBRARIES}) if (LIBZSTD_LIBRARIES) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBZSTD_LIBRARIES}) endif(LIBZSTD_LIBRARIES) if(STATIC_LINKING OR LIBBFD_STATIC) # libbfd.so is linked with the required libraries but libbfd.a is not. # So if we do a static bpftrace build or libbfd.so is not available (e.g. on # openSUSE), we must link them manually. # Furthermore, libbfd uses some libc symbols that we must manually link # against if we're not using static libc (which includes such symbols). message(STATUS "Using static libbfd, need to link additional libraries.") find_package(ZLIB) find_library (LIBIBERTY_LIBRARIES NAMES iberty PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) find_library (LIBSFRAME_LIBRARIES NAMES sframe PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBIBERTY_LIBRARIES} ${ZLIB_LIBRARIES}) if (LIBSFRAME_LIBRARIES) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBSFRAME_LIBRARIES}) endif(LIBSFRAME_LIBRARIES) if (LIBZSTD_LIBRARIES) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBZSTD_LIBRARIES}) endif(LIBZSTD_LIBRARIES) set(CMAKE_REQUIRED_FLAGS "-Wl,--start-group -Wl,-Bdynamic -Wl,-Bdynamic -lpthread -Wl,-Bdynamic -ldl") endif() INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES(" // See comment in bfd-disasm.cpp for why this needs to exist #define PACKAGE \"bpftrace-test\" #include int main(void) { init_disassemble_info(NULL, NULL, NULL, NULL); return 0; } " LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE) SET(CMAKE_REQUIRED_LIBRARIES) endif() bpftrace-0.27.1/cmake/FindLibBlazesym.cmake000066400000000000000000000012551526721631600205030ustar00rootroot00000000000000# - Try to find libblazesym # Once done this will define # # LIBBLAZESYM_FOUND - system has libblazesym # LIBBLAZESYM_INCLUDE_DIRS - the libblazesym include directory # LIBBLAZESYM_LIBRARIES - Link these to use libblazesym # find_path (LIBBLAZESYM_INCLUDE_DIRS NAMES blazesym.h PATHS ENV CPATH) find_library (LIBBLAZESYM_LIBRARIES NAMES blazesym_c PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBlazesym "Please install the libblazesym development package" LIBBLAZESYM_LIBRARIES LIBBLAZESYM_INCLUDE_DIRS) mark_as_advanced(LIBBLAZESYM_INCLUDE_DIRS LIBBLAZESYM_LIBRARIES) bpftrace-0.27.1/cmake/FindLibBpf.cmake000066400000000000000000000077371526721631600174370ustar00rootroot00000000000000# LIBBPF_FOUND - system has libbpf # LIBBPF_INCLUDE_DIRS - the libbpf include directory # LIBBPF_LIBRARIES - Link these to use libbpf # LIBBPF_DEFINITIONS - Compiler switches required for using libbpf # LIBBPF_VERSION_MAJOR - Libbpf major version # LIBBPF_VERSION_MINOR - Libbpf minor version if (USE_SYSTEM_LIBBPF) find_path (LIBBPF_INCLUDE_DIRS NAMES bpf/bpf.h bpf/btf.h bpf/libbpf.h PATHS ENV CPATH) # We require that `libbpf` be linked statically, as we will implicitly vendor # the header into embedded code. See #4151 for more information. find_library (LIBBPF_LIBRARIES NAMES libbpf.a PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) set(LIBBPF_ERROR_MESSAGE "Please set -DUSE_SYSTEM_LIBBPF=Off to use the libbpf stored as a submodule (preferred) or install the libbpf.a static library") else() set(LIBBPF_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/libbpf/src) file(GLOB LIBBPF_SRCS ${LIBBPF_SOURCE}/*) set(LIBBPF_BUILD ${CMAKE_CURRENT_BINARY_DIR}/libbpf) set(LIBBPF_LIBRARY ${LIBBPF_BUILD}/lib64/libbpf.a) # We need to install headers during configure phase for two reasons: # 1. To parse libbpf version from libbpf_version.h below. # 2. For bpftrace's stdlib since libbpf headers are included in stdlib bpf.c # files (and the rules to embed them are generated in configure phase). execute_process( COMMAND make PREFIX=${LIBBPF_BUILD} install_headers install_uapi_headers WORKING_DIRECTORY ${LIBBPF_SOURCE} OUTPUT_QUIET) # Build and install libbpf from source. This needs to be done in a rather # complicated way to ensure proper dependency between the exported # LIBBPF_LIBRARIES and the built libbpf.a. Note that we cannot use # add_custom_target with COMMAND since CMake considers the target as always # outdated, forcing rebuild of libbpf (and transitively of the entire bpftrace # every time). add_custom_command( OUTPUT ${LIBBPF_LIBRARY} # -fPIE here is needed by latest binutils when building with Clang COMMAND make PREFIX=${LIBBPF_BUILD} EXTRA_CFLAGS="-fPIE" install > /dev/null WORKING_DIRECTORY ${LIBBPF_SOURCE} DEPENDS ${LIBBPF_SRCS} COMMENT "Building libbpf" VERBATIM) add_custom_target(libbpf_build DEPENDS ${LIBBPF_LIBRARY}) add_library(libbpf_static STATIC IMPORTED GLOBAL) set_target_properties(libbpf_static PROPERTIES IMPORTED_LOCATION ${LIBBPF_LIBRARY}) add_dependencies(libbpf_static libbpf_build) # Set the output variables directly set(LIBBPF_LIBRARIES libbpf_static) set(LIBBPF_INCLUDE_DIRS ${LIBBPF_BUILD}/include) endif() include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBBPF_FOUND to TRUE if all listed variables are TRUE. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBpf ${LIBBPF_ERROR_MESSAGE} LIBBPF_LIBRARIES LIBBPF_INCLUDE_DIRS) # Parse version information out of libbpf_version.h if(EXISTS "${LIBBPF_INCLUDE_DIRS}/bpf/libbpf_version.h") file(READ "${LIBBPF_INCLUDE_DIRS}/bpf/libbpf_version.h" version_header) string(REGEX MATCH "LIBBPF_MAJOR_VERSION[ \t]+([0-9]+)" major_match "${version_header}") string(REGEX MATCH "LIBBPF_MINOR_VERSION[ \t]+([0-9]+)" minor_match "${version_header}") string(REGEX REPLACE "LIBBPF_MAJOR_VERSION[ \t]+" "" LIBBPF_VERSION_MAJOR "${major_match}") string(REGEX REPLACE "LIBBPF_MINOR_VERSION[ \t]+" "" LIBBPF_VERSION_MINOR "${minor_match}") else() set(LIBBPF_VERSION_MAJOR 0) set(LIBBPF_VERSION_MINOR 0) if (USE_SYSTEM_LIBBPF) message(SEND_ERROR "Libbpf version is too old and does not have libbpf_version.h, which was introduced in v0.6") else() message(SEND_ERROR "Failed to build libbpf, the submodule does not seem to be checked out") endif() endif() mark_as_advanced(LIBBPF_INCLUDE_DIRS LIBBPF_LIBRARIES LIBBPF_VERSION_MAJOR LIBBPF_VERSION_MINOR) INCLUDE(CheckCXXSourceCompiles) SET(CMAKE_REQUIRED_INCLUDES ${LIBBPF_INCLUDE_DIRS}) SET(CMAKE_REQUIRED_LIBRARIES ${LIBBPF_LIBRARIES} elf z) SET(CMAKE_REQUIRED_INCLUDES) SET(CMAKE_REQUIRED_LIBRARIES) bpftrace-0.27.1/cmake/FindLibBz2.cmake000066400000000000000000000006421526721631600173510ustar00rootroot00000000000000# - Try to find libbz2 # Once done this will define # # LIBBZ2_FOUND - system has libbz2 # LIBBZ2_LIBRARIES - Link these to use libbz2 find_library(LIBBZ2_LIBRARIES NAMES libbz2.a PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBz2 "Please install the libbz2 package" LIBBZ2_LIBRARIES) mark_as_advanced(LIBBZ2_LIBRARIES) bpftrace-0.27.1/cmake/FindLibCereal.cmake000066400000000000000000000007051526721631600201070ustar00rootroot00000000000000# - Try to find libcereal # Once done this will define # # LIBCEREAL_FOUND - system has libcereal # LIBCEREAL_INCLUDE_DIRS - the libcereal include directory find_path (LIBCEREAL_INCLUDE_DIRS NAMES cereal/cereal.hpp PATHS ENV CPATH) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibCereal "Please install the libcereal development package" LIBCEREAL_INCLUDE_DIRS) mark_as_advanced(LIBCEREAL_INCLUDE_DIRS) bpftrace-0.27.1/cmake/FindLibDw.cmake000066400000000000000000000017121526721631600172650ustar00rootroot00000000000000# - Try to find libdw # Once done this will define # # LIBDW_FOUND - system has libdw # LIBDW_INCLUDE_DIRS - the libdw include directory # LIBDW_LIBRARIES - Link these to use libdw # LIBDW_DEFINITIONS - Compiler switches required for using libdw # if (LIBDW_LIBRARIES AND LIBDW_INCLUDE_DIRS) set (LibDw_FIND_QUIETLY TRUE) endif (LIBDW_LIBRARIES AND LIBDW_INCLUDE_DIRS) find_path (LIBDW_INCLUDE_DIRS NAMES libdw.h libdwfl.h PATH_SUFFIXES elfutils libdw PATHS ENV CPATH) find_library (LIBDW_LIBRARIES NAMES dw PATH_SUFFIXES elfutils libdw PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBDW_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDw "Please install the libdw development package" LIBDW_LIBRARIES LIBDW_INCLUDE_DIRS) mark_as_advanced(LIBDW_INCLUDE_DIRS LIBDW_LIBRARIES) bpftrace-0.27.1/cmake/FindLibEbl.cmake000066400000000000000000000007161526721631600174200ustar00rootroot00000000000000# - Try to find libebl static library # Once done this will define # # LIBEBL_FOUND - system has libebl # LIBEBL_LIBRARIES - Link these to use libebl find_library(LIBEBL_LIBRARIES NAMES ebl PATH_SUFFIXES libebl PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibEbl "Please install the libebl static library" LIBEBL_LIBRARIES) mark_as_advanced(LIBEBL_LIBRARIES) bpftrace-0.27.1/cmake/FindLibElf.cmake000066400000000000000000000022271526721631600174230ustar00rootroot00000000000000# - Try to find libelf # Once done this will define # # LIBELF_FOUND - system has libelf # LIBELF_INCLUDE_DIRS - the libelf include directory # LIBELF_LIBRARIES - Link these to use libelf # LIBELF_DEFINITIONS - Compiler switches required for using libelf # # Copyright (c) 2008 Bernhard Walle # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS) set (LibElf_FIND_QUIETLY TRUE) endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS) find_path (LIBELF_INCLUDE_DIRS NAMES libelf.h PATH_SUFFIXES libelf PATHS ENV CPATH) find_library (LIBELF_LIBRARIES NAMES elf PATH_SUFFIXES libelf PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf "Please install the libelf development package" LIBELF_LIBRARIES LIBELF_INCLUDE_DIRS) mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES) bpftrace-0.27.1/cmake/FindLibLzma.cmake000066400000000000000000000006551526721631600176230ustar00rootroot00000000000000# - Try to find liblzma # Once done this will define # # LIBLZMA_FOUND - system has liblzma # LIBLZMA_LIBRARIES - Link these to use liblzma find_library(LIBLZMA_LIBRARIES NAMES liblzma.a PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLzma "Please install the liblzma package" LIBLZMA_LIBRARIES) mark_as_advanced(LIBLZMA_LIBRARIES) bpftrace-0.27.1/cmake/FindLibOpcodes.cmake000066400000000000000000000017461526721631600203160ustar00rootroot00000000000000# - Try to find libopcodes # Once done this will define # # LIBOPCODES_FOUND - system has libopcodes # LIBOPCODES_INCLUDE_DIRS - the libopcodes include directory # LIBOPCODES_LIBRARIES - Link these to use libopcodes # LIBOPCODES_DEFINITIONS - Compiler switches required for using libopcodes #if (LIBOPCODES_LIBRARIES AND LIBOPCODES_INCLUDE_DIRS) # set (LibBpf_FIND_QUIETLY TRUE) #endif (LIBOPCODES_LIBRARIES AND LIBOPCODES_INCLUDE_DIRS) find_path (LIBOPCODES_INCLUDE_DIRS NAMES dis-asm.h PATHS ENV CPATH) find_library (LIBOPCODES_LIBRARIES NAMES opcodes PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBOPCODES_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibOpcodes "Please install the libopcodes development package" LIBOPCODES_LIBRARIES LIBOPCODES_INCLUDE_DIRS) mark_as_advanced(LIBOPCODES_INCLUDE_DIRS LIBOPCODES_LIBRARIES) bpftrace-0.27.1/cmake/FindLibPcap.cmake000066400000000000000000000016001526721631600175720ustar00rootroot00000000000000# - Try to find libpcap # Once done this will define # # LIBPCAP_INCLUDE_DIRS - where to find pcap/pcap.h # LIBPCAP_LIBRARIES - List of libraries when using pcap # LIBPCAP_FOUND - True if pcap found. find_path(LIBPCAP_INCLUDE_DIRS NAMES pcap/pcap.h PATHS /usr/include /usr/local/include /opt/local/include /sw/include ENV CPATH ) find_library(LIBPCAP_LIBRARIES NAMES pcap PATHS /usr/lib /usr/lib64 /usr/local/lib /opt/local/lib /sw/lib ENV LIBRARY_PATH ENV LD_LIBRARY_PATH ) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBPCAP_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibPcap "Please install the libpcap development package" LIBPCAP_LIBRARIES LIBPCAP_INCLUDE_DIRS) mark_as_advanced(LIBPCAP_INCLUDE_DIRS LIBPCAP_LIBRARIES) bpftrace-0.27.1/cmake/FindLibZ.cmake000066400000000000000000000007651526721631600171330ustar00rootroot00000000000000# - Try to find libz # Once done this will define # # LIBZ_FOUND - system has libz # LIBZ_LIBRARIES - Link these to use libz find_library(LIBZ_LIBRARIES NAMES libz.a PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBZ_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibZ "Please install the libz package" LIBZ_LIBRARIES) mark_as_advanced(LIBZ_LIBRARIES) bpftrace-0.27.1/cmake/Util.cmake000066400000000000000000000010741526721631600164010ustar00rootroot00000000000000# Workaround to remove dynamic libs from static library dependencies function(unlink_transitive_dependency targets dep_to_remove) foreach(tgt ${targets}) if(NOT TARGET ${tgt}) continue() endif() get_target_property(int_link_libs ${tgt} INTERFACE_LINK_LIBRARIES) if(NOT(int_link_libs MATCHES "-NOTFOUND$")) list(REMOVE_ITEM int_link_libs "${dep_to_remove}") set_target_properties(${tgt} PROPERTIES INTERFACE_LINK_LIBRARIES "${int_link_libs}") endif() endforeach(tgt ${targets}) endfunction(unlink_transitive_dependency) bpftrace-0.27.1/cmake/Version.cmake000066400000000000000000000020701526721631600171060ustar00rootroot00000000000000# This file generates the file "version.h", containing an up-to-date version # string on each build. # Inputs: # File names: # VERSION_H_IN - name of template source file # VERSION_H - name of populated file to be generated # Fallback version numbers when not building in a Git repository: # bpftrace_VERSION_MAJOR # bpftrace_VERSION_MINOR # bpftrace_VERSION_PATCH # Check if we're in a git repo execute_process( COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${bpftrace_SOURCE_DIR} OUTPUT_VARIABLE GIT_SHORT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE retcode ) set(BPFTRACE_BASE_VERSION "v${bpftrace_VERSION_MAJOR}.${bpftrace_VERSION_MINOR}.${bpftrace_VERSION_PATCH}") # Append git hash if we're in a git repository if(retcode EQUAL 0) set(BPFTRACE_VERSION "${BPFTRACE_BASE_VERSION}-${GIT_SHORT_HASH}") else() set(BPFTRACE_VERSION "${BPFTRACE_BASE_VERSION}") endif() set(MIN_KERNEL_VERSION_MAJOR 5) set(MIN_KERNEL_VERSION_MINOR 15) set(MIN_KERNEL_VERSION_PATCH 0) configure_file(${VERSION_H_IN} ${VERSION_H} @ONLY) bpftrace-0.27.1/docker/000077500000000000000000000000001526721631600146475ustar00rootroot00000000000000bpftrace-0.27.1/docker/Dockerfile.alpine000066400000000000000000000023051526721631600201100ustar00rootroot00000000000000# This Dockerfile is used to both document and test building bpftrace on the # development version of Alpine. We attempt to catch bugs as early as possible # which is why we are using the edge repository. FROM alpine:edge ARG LLVM_VERSION=20 RUN apk add --update \ asciidoctor \ bcc-dev \ binutils-dev \ bison \ blazesym \ build-base \ cereal \ clang$LLVM_VERSION-dev \ clang$LLVM_VERSION-extra-tools \ clang$LLVM_VERSION-static \ cmake \ elfutils-dev \ flex-dev \ libbpf-dev \ linux-headers \ llvm$LLVM_VERSION-dev \ llvm$LLVM_VERSION-gtest \ llvm$LLVM_VERSION-static \ samurai \ libxml2-dev \ zip RUN ln -s "clang${LLVM_VERSION}" /usr/lib/cmake/clang COPY . /src WORKDIR /src # We set USE_SYSTEM_LIBBPF=On to test that bpftrace can build with system libbpf # (i.e. not using libbpf from the submodule) RUN cmake -B /build -G Ninja \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_BUILD_TYPE=MinSizeRel \ -DBUILD_TESTING=OFF \ -DCMAKE_PREFIX_PATH=/usr/lib/llvm${LLVM_VERSION}/lib/cmake \ -DLLVM_REQUESTED_VERSION="$(/usr/lib/llvm${LLVM_VERSION}/bin/llvm-config --version)" \ -DUSE_SYSTEM_LIBBPF=1 RUN cmake --build /build -j$(nproc) ENTRYPOINT ["/build/src/bpftrace"] bpftrace-0.27.1/docker/Dockerfile.debian000066400000000000000000000017731526721631600200720ustar00rootroot00000000000000# This Dockerfile is used to both document and test building bpftrace on the # upcoming debian release. We attempt to catch bugs as early as possible which # is why we are using sid/unstable. FROM debian:sid ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ asciidoctor \ bpftool \ binutils-dev \ bison \ build-essential \ clang \ cmake \ flex \ libbpf-dev \ libbpfcc-dev \ libcereal-dev \ libdw-dev \ libelf-dev \ libiberty-dev \ libpcap-dev \ llvm-dev \ libclang-dev \ libclang-cpp-dev \ pahole \ xxd \ zip \ zlib1g-dev COPY . /src WORKDIR /src # Use CMAKE_BUILD_TYPE=Release if you don't plan on developing bpftrace # We set USE_SYSTEM_LIBBPF=On to test that bpftrace can build with system libbpf # (i.e. not using libbpf from the submodule) RUN cmake -B /build -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug -DUSE_SYSTEM_LIBBPF=On RUN make -C /build -j$(nproc) ENTRYPOINT ["/build/src/bpftrace"] bpftrace-0.27.1/docker/Dockerfile.fedora000066400000000000000000000021331526721631600200770ustar00rootroot00000000000000# This Dockerfile is used to both document and test building bpftrace on the # development version of fedora. We attempt to catch bugs as early as possible # which is why we are using rawhide. FROM fedora:rawhide RUN dnf install -y \ awk \ asciidoctor \ bcc-devel \ bison \ binutils-devel \ bpftool \ cereal-devel \ clang-devel \ cmake \ elfutils-devel \ elfutils-libelf-devel \ elfutils-libs \ flex \ gcc \ gcc-c++ \ libpcap-devel \ libbpf-devel \ libbpf-static \ libzstd-devel \ llvm-devel \ make \ pahole \ xxd \ zip \ zlib-devel COPY . /src WORKDIR /src # Use CMAKE_BUILD_TYPE=Release if you don't plan on developing bpftrace # We set USE_SYSTEM_LIBBPF=On to test that bpftrace can build with system libbpf # (i.e. not using libbpf from the submodule) RUN cmake -B /build -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug -DUSE_SYSTEM_LIBBPF=On RUN make -C /build -j$(nproc) ENTRYPOINT ["/build/src/bpftrace"] bpftrace-0.27.1/docker/Dockerfile.opensuse000066400000000000000000000020641526721631600205030ustar00rootroot00000000000000# This Dockerfile is used to both document and test building bpftrace on the # latest version of OpenSUSE Tumbleweed. We attempt to catch bugs as early as # possible which is why we are using latest. FROM opensuse/tumbleweed:latest RUN zypper install --no-recommends -y \ awk \ bcc-devel \ bison \ binutils-devel \ bpftool \ cereal-devel \ clang-devel \ cmake \ elfutils \ flex \ gcc \ gcc-c++ \ libpcap-devel \ libbpf-devel \ libbpf-devel-static \ libzstd-devel \ llvm-devel \ make \ pahole \ xxd \ zip \ zlib-devel COPY . /src WORKDIR /src # Use CMAKE_BUILD_TYPE=Release if you don't plan on developing bpftrace # We set USE_SYSTEM_LIBBPF=On to test that bpftrace can build with system libbpf # (i.e. not using libbpf from the submodule) RUN cmake -B /build -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug -DUSE_SYSTEM_LIBBPF=On RUN make -C /build -j$(nproc) ENTRYPOINT ["/build/src/bpftrace"] bpftrace-0.27.1/docker/Dockerfile.static000066400000000000000000000024121526721631600201260ustar00rootroot00000000000000# This Dockerfile is used to test STATIC_LINKING=ON builds in the CI FROM alpine:3.22 RUN apk add --update \ asciidoctor \ argp-standalone \ bash \ bcc-dev \ bcc-static \ binutils-dev \ bison \ blazesym-dev \ blazesym-static \ bpftool \ bzip2-static \ build-base \ cereal \ clang18-dev \ clang18-extra-tools \ clang18-static \ cmake \ elfutils-dev \ flex-dev \ git \ libbpf-dev \ libelf-static \ libpcap-dev \ libc6-compat \ linux-headers \ llvm18-dev \ llvm18-gtest \ llvm18-static \ musl-obstack-dev \ openssl-dev \ pahole \ procps \ python3 \ wget \ xxd \ xz-static \ zip \ zlib-dev \ zlib-static \ zstd-dev \ zstd-static # It looks like llvm18 prefers to dynamically link against zstd. Extremely # unclear why. Work around it by modifying LLVMExports.cmake. RUN sed -i 's/libzstd_shared/libzstd_static/g' /usr/lib/llvm18/lib/cmake/llvm/LLVMExports.cmake # bcc-static needs clang/llvm 18 instead of the latest 19. As a consequence, # CMake reports errors as that it cannot find files in /usr/lib/cmake/clang/ as # it's a symlink for /usr/lib/cmake/clangXX/ which is only created when the # latest clang is installed. To fix this, create the symlink manually. RUN ln -s 'clang18' /usr/lib/cmake/clang bpftrace-0.27.1/docker/Dockerfile.ubuntu000066400000000000000000000020071526721631600201610ustar00rootroot00000000000000# This Dockerfile is used to both document and test building bpftrace on the # development version of ubuntu. We attempt to catch bugs as early as possible # which is why we are using devel. FROM ubuntu:devel ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ asciidoctor \ binutils-dev \ bison \ build-essential \ clang \ cmake \ flex \ libbpf-dev \ libbpfcc-dev \ libcereal-dev \ libdw-dev \ libelf-dev \ libiberty-dev \ libpcap-dev \ llvm-dev \ libclang-dev \ libclang-cpp-dev \ linux-tools-common \ pahole \ xxd \ zip \ zlib1g-dev COPY . /src WORKDIR /src # Use CMAKE_BUILD_TYPE=Release if you don't plan on developing bpftrace # We set USE_SYSTEM_LIBBPF=On to test that bpftrace can build with system libbpf # (i.e. not using libbpf from the submodule) RUN cmake -B /build -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug -DUSE_SYSTEM_LIBBPF=On RUN make -C /build -j$(nproc) ENTRYPOINT ["/build/src/bpftrace"] bpftrace-0.27.1/docs/000077500000000000000000000000001526721631600143305ustar00rootroot00000000000000bpftrace-0.27.1/docs/coding_guidelines.md000066400000000000000000000102131526721631600203220ustar00rootroot00000000000000# Coding guidelines The goal of this document is to establish some common understanding of what language features should and should not be used. This helps reduce mental overhead while reading, developing, and reviewing code. In some cases, it also helps present a more consistent user experience. Discussions about this document should occur in a pull request making changes to the text of this document. This helps keep track of why things are the way they are. As well as providing a structured environment to participate. If something is not called out in this document, defer to [the C++ core guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). In other words, this document supersedes the core guidelines. Note that the checked in code may not adhere to these guidelines yet. This document is intended to be referenced for new code. Ideally we also modify checked-in code to follow these guidelines (if/when there is time). ## Error handling and exceptions If an error is recoverable (meaning downstream callers of the code should be able to selectively handle, ignore, or further propagate), pass the error through the return value of the function. Appropriate language features for this include: * `std:optional` * `int` * `bool` If an error is **not** recoverable, prefer throwing `FatalUserException`. Exceptions **should not** be used for recoverable errors. ### Examples An example of a recoverable error would be failure to write an entry into a map. There are a number of reasons why writing to a map could fail (map is full, insufficient privileges, map does not exist yet, etc.) and we can't know for sure at the point of failure what the reason is. Additionally, this type of error might not be a reason fail the whole program. So we need to propagate the error. An example of an unrecoverable error would be if `debugfs` is not mounted. If debugfs isn't mounted, all bets are off b/c we cannot interact with the kernel debug facilities. And we probably should not be mounting filesystems on behalf of the user. So at the point of failure, we should just throw an exception and let the user know their system is not ready for bpftrace. ## Struct vs. Class Use a struct only for passive objects that carry data; everything else is a class. All fields in a struct should be public. The struct must not have invariants that imply relationships between different fields, since direct user access to those fields may break those invariants. Structs should not have any associated methods (including constructors and destructors). ## Variable naming Variables should be in `snake_case` (all lowercase, with underscores between words). Private members should have a trailing underscore. Public members should not have a trailing underscore. Struct data members should _not_ have a trailing underscore. Examples: ```c++ class Foo { public: int snake_case; // good int secondone; // bad int var_; // bad int camelCase; // bad private: int another_var_; // good int private_var; // bad int priv_; // good }; struct Bar { int var; // good int tailing_; // bad }; ``` ## Log Messages Below are details about when to use each kind of log level: - `DEBUG`: log info regardless of log level; like using stdout (comes with file and line number) - `V1`: log info only if verbose logging is enabled (-v); use this (among others) for printing warnings which may occur on every bpftrace execution (like BTF is not available) - `HINT`: log info that could give tips on how the user can resolve a problem they have encountered. This would normally be used immediately after a LOG(WARNING) or LOG(ERROR). - `WARNING`: log info that might affect bpftrace behavior or output but allows the run to continue; like using stderr - `ERROR`: log info to indicate that the user did something invalid, which will (eventually) cause bpftrace to exit (via `exit(1)`); this should primarily get used in main.cpp after catching `FatalUserException` from deeper parts of the code base - `BUG`: abort and log info to indicate that there is an internal/unexpected issue (not caused by invalid user program code or CLI use) bpftrace-0.27.1/docs/dependency_support.md000066400000000000000000000062471526721631600205750ustar00rootroot00000000000000# Dependency support policy This document outlines our policy for supporting bpftrace's major dependencies. Our support policy for minor dependencies are done on a case by case basis, usually at distro/user request. ## Linux kernel **Minimum kernel version: 6.1** The linux kernel is bpftrace's biggest runtime dependency. While we would like to support the oldest LTS kernel version, we also want to make sure bpftrace is keeping up with the latest features. As a compromise bpftrace supports stable kernels and the 4 most recent LTS kernels. Users that require support on older kernels can often simply use [older versions of bpftrace](https://github.com/bpftrace/bpftrace/releases). The source of truth on EOL dates and LTS kernels is https://www.kernel.org/. For features that have clear boundaries (eg. new builtins or helpers), bpftrace is free to opportunistically depend on newer kernels as long as there is a reasonable runtime fallback strategy or detailed error message. ### Required configuration The kernel needs to be built with the following options: ``` CONFIG_BPF=y CONFIG_BPF_SYSCALL=y CONFIG_BPF_JIT=y CONFIG_HAVE_EBPF_JIT=y CONFIG_BPF_EVENTS=y CONFIG_FTRACE_SYSCALLS=y CONFIG_FUNCTION_TRACER=y CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE=y CONFIG_HAVE_KPROBES=y CONFIG_KPROBES=y CONFIG_KPROBE_EVENTS=y CONFIG_ARCH_SUPPORTS_UPROBES=y CONFIG_UPROBES=y CONFIG_UPROBE_EVENTS=y CONFIG_DEBUG_FS=y ``` This can be verified by running the `check_kernel_features` script from the `scripts` directory. ## LLVM (dynamically linked) LLVM is bpftrace's biggest build time dependency. The project always supports the latest LLVM release as soon as it's practical (available in CI). On top of that, we support 4 previous LLVM releases (i.e. 5 LLVM versions in total). ## LLVM (statically linked) In contrast to dynamically linked LLVM, statically linked LLVM is significantly more difficult to maintain. As a consequence, we only support a single LLVM release in the static build configuration. We do not yet have a policy on when the LLVM version is updated, but we will document any changes in the release notes. Please consult [static.sh][static] for the source of truth. ## libbpf bpftrace relies on libbpf for most of the tasks related to management of BPF programs, particularly loading and attachment. Occasionally, it is necessary to introduce patches to libbpf to enable some bpftrace functionality or to fix bugs. For this reason, we require a very recent, often unreleased, version of libbpf. To simplify development and building, bpftrace vendors libbpf as a submodule and by default links against the vendored version statically. Since linking against vendored library versions is not preferred by most distributions, we also allow building against system libbpf by using `-DUSE_SYSTEM_LIBBPF=On` in CMake. Note that it is the responsibility of the builder to ensure that the linked libbpf contains all the necessary patches. The general recommendation is that the linked libbpf should be at or beyond the commit referenced by the libbpf submodule, which will be kept up to date when required patches change. [static]: https://github.com/bpftrace/bpftrace/blob/master/.github/include/static.sh bpftrace-0.27.1/docs/design_principles.md000066400000000000000000000076161526721631600203650ustar00rootroot00000000000000# Design Principles This document exists so that there is a clear understanding of what bpftrace does and does not do. While we are excited to see community contributions, we are not likely to choose a path that goes against these principles. This document is as much for current and future maintainers as it is for new and existing contributors. This is a living document and subject to change. ## bpftrace Mission Statement Provide a quick and easy way for people to write observability-based BPF programs, especially for people unfamiliar with the complexities of eBPF (e.g. the verifier, kernel/userspace interaction, attachment, program loading, memory access, and the various types of BPF maps). ## Language Goals These are in priority order: 1. conciseness / one-liners 1. readability / easy to understand 1. clean abstraction from eBPF 1. ability to quickly iterate 1. composability 1. good performance in both kernel and userspace 1. speed of program initialization/start-up ## Language Non-Goals 1. testability 1. debuggability (no gdb or self-tracing) 1. dynamic typing 1. Classes / Inheritance 1. metaprogramming 1. exception handling 1. BPF security, LSM, XDP, Scheduling 1. BPF concepts that don't pertain to observability or can’t be abstracted cleanly ## Stability We value API stability and we would like bpftrace to work on as many past versions of the Linux kernel as possible ([dependency support](./dependency_support.md)). However, due to the speed of kernel development, especially in the BPF space, we need to ~~keep up~~ PUSH the community forward, which means sometimes we need to break things. We prefer the stability in the sense of “It is heavily used in production, and when something changes, there is a clear migration pathâ€� e.g. this [migration guide](./migration_guide.md). When we deprecate a pattern, we study its usage and, when appropriate, add deprecation warnings in an upcoming release before removing/changing it completely. We don’t deprecate anything without a good reason. We recognize that sometimes deprecations warnings cause frustration but we add them because deprecations clean up the road for the improvements and new features that we and many people in the community consider valuable. ## Implementation We try to provide an elegant, intuitive, and surprise-free experience when users are writing/running bpftrace scripts. We are less concerned with the implementation being elegant. The real world is far from perfect, and to a reasonable extent we prefer to write ugly code if it means the user does not have to write it. When we evaluate new code, we are looking for an implementation that is correct, performant, tested, and will not lead to mounds of tech debt. We prefer boring code to clever code. Code is disposable and often changes. So it is important that it doesn’t introduce new internal abstractions unless absolutely necessary. Verbose code that is easy to move around, change, and remove is preferred to elegant code that is prematurely abstracted and hard to change. ## Design Review Many changes, including bug fixes and documentation improvements can be implemented and reviewed via the normal GitHub pull request workflow. Some changes, though, are "substantial" or breaking, and we ask that these be put through the [RFC process](../CONTRIBUTING.md#rfc-process) and produce a consensus among bpftrace's maintainers. This process is intended to provide a consistent and controlled path for changes to bpftrace so that all stakeholders can be confident about the direction of the project. ## Evolution Like many open source projects, bpftrace is evolving. As we learn more about our customers and what they need from a tool that promises fast kernel-based observability/tracing, we will adapt and grow bpftrace to meet those needs. We also want to grow the bpftrace community with transparency, responsiveness, kindness, and collaboration. Let's build something awesome together! bpftrace-0.27.1/docs/developers.md000066400000000000000000000213431526721631600170250ustar00rootroot00000000000000# bpftrace development guide This document features basic guidelines and recommendations on how to do bpftrace development. Please read it carefully before submitting pull requests to simplify reviewing and speed up the merge process. ## Building bpftrace uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules), so ensure they are initialized when checking out the code: ```bash git clone --recurse-submodules https://github.com/bpftrace/bpftrace cd bpftrace ``` For minimum kernel version requirements, see our [dependency support policy](dependency_support.md#linux-kernel). Your kernel should be built with the necessary BPF options enabled. Verify this by running the `check_kernel_features` script from the `scripts` directory. ### Nix build (recommended) [Nix](https://nixos.org/nix/) is the most convenient way to build and test bpftrace. Nix manages all build and runtime dependencies automatically. It is also used by CI, so you are more likely to catch errors before submitting your change. All build and test commands using Nix must be run inside the Nix dev shell (e.g., `nix develop --command bash -c ""`), or from within an active `nix develop` session. ```bash nix develop # enter dev shell mkdir build cmake -B build -DCMAKE_BUILD_TYPE=Debug make -C build -j$(nproc) ``` To develop with a different LLVM version: `nix develop .#bpftrace-llvm21` For more Nix examples (static builds, fuzzing, flake management), see [nix.md](./nix.md). ### Distro build The distro build relies on you installing all of bpftrace's build and runtime dependencies on your host and then calling `cmake`. Please be aware that bpftrace has strict dependencies on new versions of `libbpf` and `bcc`. We track their upstream closely, so while the distro build works well on distros with newer packages, developers on distros that lag behind (e.g. Debian) may want to use the Nix build or manually build and install `bcc` and `libbpf`. For a suitable build environment, see our Dockerfiles for detailed dependency examples: - [Ubuntu](https://github.com/bpftrace/bpftrace/blob/master/docker/Dockerfile.ubuntu) - [Fedora](https://github.com/bpftrace/bpftrace/blob/master/docker/Dockerfile.fedora) - [Debian](https://github.com/bpftrace/bpftrace/blob/master/docker/Dockerfile.debian) Once all dependencies are installed: ```bash mkdir build cmake -B build -DCMAKE_BUILD_TYPE=Release make -C build -j$(nproc) ``` Key cmake options: `-DBUILD_TESTING=ON` (default), `-DLLVM_REQUESTED_VERSION=`. ### Build output The built binary is at `build/src/bpftrace`. ### Troubleshooting **Kernel Lockdown:** If your system has kernel lockdown enabled (often with Secure Boot), bpftrace will be blocked. To disable: - Disable Secure Boot in UEFI, or - Run `sudo mokutil --disable-validation` and reboot, or - Temporarily lift lockdown with `SysRQ+x` (until next boot) ## [Tests](../tests/README.md) Every contribution should (1) not break the existing tests and (2) introduce new tests if relevant. See existing tests for inspiration on how to write new ones. [Read more on the different kinds and how to run them](../tests/README.md). ## Performance We aim to not be wasteful, but always keep in mind that performance of the BPF programs and runtime are the things in the critical path. Often, simplicity and understandability on non-critical paths is often more important than performance. That said, occasionally it is useful to measure the performance of different parts of the pipeline. You may run bpftrace using `--mode compiler-bench` in order to see the performance of the various passes during compilation. Similarly, you may benchmark the code generated by bpftrace using `BENCH` probes and `--mode bench`: ``` $ bpftrace --mode bench -e 'BENCH:my_benchmark { @a++; }' Attached 1 probe +--------------+--------------+ | BENCHMARK | AVERAGE TIME | +--------------+--------------+ | my_benchmark | 270ns | +--------------+--------------+ ``` ## Continuous integration CI executes the above tests in a matrix of different LLVM versions on NixOS. The jobs are defined in `.github/workflows/ci.yml`. ### Running the CI CI is automatically run on all branches and pull requests on the main repo. We recommend to enable the CI (GitHub Actions) on your own fork, too, which will allow you to run the CI against your testing branches. ### Debugging CI failures It may often happen that tests pass on your local setup but fail in one of the CI environments. In such a case, it is useful to reproduce the environment to debug the issue. To reproduce the NixOS jobs (from `.github/workflows/ci.yml`): 1. Acquire the job environment from the GHA UI: ![](../images/ci_job_env.png) 1. Run `.github/include/ci.py` with the relevant environment variables set Example `ci.py` invocations: ``` $ NIX_TARGET=.#bpftrace-llvm10 ./.github/include/ci.py ``` ``` $ NIX_TARGET=.#bpftrace-llvm11 \ CMAKE_BUILD_TYPE=Release \ RUNTIME_TEST_DISABLE="probe.kprobe_offset_fail_size,usdt.usdt probes - file based semaphore activation multi process" \ ./.github/include/ci.py ``` ### Virtual machine tests (vmtests) In CI we run a subset of runtime tests under a controlled kernel by taking advantage of nested virtualization on CI runners. For these tests, we use [vmtest](https://github.com/danobi/vmtest) to manage the virtual machine. The instructions in the above "Debugging CI failures" section also work for the vmtest-ed runtime tests. But if you want to manually try something quick and dirty in a CI kernel, you can do something like the following: ```bash $ nix develop (nix:nix-shell-env) $ vmtest -k $(nix build --print-out-paths .#kernel-6_12)/bzImage -- ./build/src/bpftrace -V => bzImage ===> Booting ===> Setting up VM ===> Running command bpftrace v0.21.0-344-g3acb ``` While we'll defer to `vmtest` documentation for full details, one neat fact worth pointing out is that `vmtest` will map the current running userspace into the VM. This means you can run binaries built on your host from inside the guest, eg. your development build of bpftrace. ## Coding guidelines This is not about the formatting of the source code (we have `clang-format` for that). Rather, it's about the semantics of the code and what language features we try to use / avoid. Please see [coding_guidelines.md](./coding_guidelines.md) for a full treatment on the topic. ## Code style We use clang-format with our custom config for formatting code. [git clang-format](https://github.com/llvm/llvm-project/blob/main/clang/tools/clang-format/git-clang-format) can be used to easily format commits, e.g. `git clang-format upstream/master`. For bpftrace code (standard library and scripts), it should be formatted by bpftrace itself. You can use `bpftrace --fmt` or `scripts/bpftrace_tidy.sh`. Note that these are both checked by tests; if the changes don't adhere to our style CI jobs will fail. ### Avoid 'fix formatting' commits We want to avoid `fix formatting` commits. Instead every commit should be formatted correctly. ### Comment style Strongly prefer C++-style comments for single line and block comments. C-style comments are still useable for nested comments within a single line, e.g. to leave an annotation on a specific argument or parameter. In the future, there may be considerations for automated documentation based on comments, but this is not currently done. `bpftrace` itself supports both C-style and C++-style comment blocks. There is currently no decision on recommended comment style, and both are used freely. ## Merging pull requests Please squash + rebase all pull requests (with no merge commit). In other words, there should be one commit in master per pull request. This makes generating changelogs both trivial and precise with the least amount of noise. The exception to this is PRs with complicated changes. If this is the case and the commits are well structured, a rebase + merge (no merge commit) is acceptable. The rule of thumb is the commit titles should make sense in a changelog. ## Changelog The changelog is for end users. It should provide them with a quick summary of all changes important to them. Internal changes like refactoring or test changes do not belong to it. ### Maintaining the changelog To avoid having write a changelog when we do a release (which leads to useless changelog or a lot of work) we write them as we go. That means that every PR that has a user impacting change must also include a changelog entry. As we include the PR number in the changelog format this can only be done after the PR has been opened. If it is a single commit PR we include the changelog in that commit, when the PR consists of multiple commits it is OK to add a separate commit for the changelog. ## bpftrace internals For more details on bpftrace internals, see [internals_development.md](internals_development.md). bpftrace-0.27.1/docs/fuzzing.md000066400000000000000000000102251526721631600163460ustar00rootroot00000000000000# Fuzzing bpftrace This document is for `bpftrace` developers. ## Introduction Fuzzing is a method to find bugs in a program automatically. In fuzzing, a fuzzer generates the program input and give it and observes whether the program crashes or not. The most commonly used fuzzing method is called gray box fuzzing, which uses coverage (which parts the program executes) information to generate input efficiently. Fuzzing can be divided into two types according to the target of fuzzing: one that targets the entire program for fuzzing, such as AFL, and the other that targets a specific function, such as libFuzzer. In the former case, a fuzzer generates and supplies the program's input, so you don't need to modify the program. This is not always efficient for large programs, but still can find many bugs. The latter is efficient for a function to be fuzzed because a fuzzer directly targets the function, but we need to write some glue code to connect a fuzzer and the function. ## Options ## Fuzzing with AFL Before starting, it is highly recommended to read the [AFL][AFL] or [AFLPlusPlus][AFL++] documentation. ### Setup The fuzzing setup relies on `nix`. See the [nix instructions](./nix.md). ### Compile To use AFL, we need to compile the program with the AFL compiler. If you are using `nix`, you would enter a development shell and build as follows: ``` nix develop #.bpftrace-fuzz CC=afl-clang-fast CXX=afl-clang-fast++ cmake -B build-fuzz -DCMAKE_BUILD_TYPE=Debug -DBUILD_ASAN=1 ``` then, in order to build the tree: ``` cd build-fuzz && AFL_USE_ASAN=1 make -j$(nproc) ``` Note that the address sanitizer might take a lot of memory. If you want to fuzz without it, please remove `AFL_USE_ASAN` and `-DBUILD_ASAN`. ### Running AFL recommends some settings for efficient fuzzing: ``` echo core | sudo tee -a /proc/sys/kernel/core_pattern cd /sys/devices/system/cpu echo performance | sudo tee cpu*/cpufreq/scaling_governor ``` Then, fuzz away! AFL and the address sanitizer have a lot of settings, so please read documentation for the details. The currently recommended way to run the fuzzer is by using the `--test=codegen` mode and providing overrides: ``` AFL_NO_AFFINITY=1 \ ASAN_OPTIONS=abort_on_error=1,symbolize=0 \ BPFTRACE_BTF= \ afl-fuzz -a text -M 0 -m none -i ./input -o ./output -t 3000 -- \ src/bpftrace --test=codegen @@ 2>/dev/null ``` In the above, `-i` specifics the input directory, and `-o` specifies the output directory. In the input directory, you need to put something to start fuzzing. The most simple example is `echo a > input/a`. More sophisticated inputs can be created by using sample `bpftrace` programs from the source directory, tests or other locations. If some inputs that cause a program crash is found, `output/crashes` contains them. The timeout for each execution (in milliseconds) is provided by `-t`. Finally, '@@' will be replaced by the input file generated by the fuzzer. ## Found bugs ### AFL - [#1623](https://github.com/bpftrace/bpftrace/pull/1623) - [#1619](https://github.com/bpftrace/bpftrace/pull/1619) - [#1580](https://github.com/bpftrace/bpftrace/pull/1580) - [#1573](https://github.com/bpftrace/bpftrace/pull/1573) - [#1572](https://github.com/bpftrace/bpftrace/pull/1572) - [#1570](https://github.com/bpftrace/bpftrace/pull/1570) - [#1568](https://github.com/bpftrace/bpftrace/pull/1568) - [#1286](https://github.com/bpftrace/bpftrace/pull/1286) - [#1245](https://github.com/bpftrace/bpftrace/pull/1245) - [#1234](https://github.com/bpftrace/bpftrace/pull/1234) - [#1229](https://github.com/bpftrace/bpftrace/pull/1229) - [#1224](https://github.com/bpftrace/bpftrace/pull/1224) - [#1222](https://github.com/bpftrace/bpftrace/pull/1222) - [#1221](https://github.com/bpftrace/bpftrace/pull/1221) - [#1210](https://github.com/bpftrace/bpftrace/pull/1210) - [#1205](https://github.com/bpftrace/bpftrace/pull/1205) ### libFuzzer - [#1653](https://github.com/bpftrace/bpftrace/pull/1653) - [#1650](https://github.com/bpftrace/bpftrace/pull/1650) - [#1622](https://github.com/bpftrace/bpftrace/pull/1622) - [#1621](https://github.com/bpftrace/bpftrace/pull/1621) [AFL]: https://github.com/google/AFL [AFL++]: https://github.com/AFLplusplus/AFLplusplus bpftrace-0.27.1/docs/internals_development.md000066400000000000000000000676571526721631600213000ustar00rootroot00000000000000# bpftrace Internals This document is for bpftrace internals developers. **WARNING:** The information below may be out of date. The codegen tips are still helpful but some of the generated code and verifier errors might have changed. # Codegen This is the most difficult part of bpftrace. It involves writing code like this (from ast/codegen_llvm.cpp): ```C++ AllocaInst *buf = b_.CreateAllocaBPF(call.type, "usym"); b_.CreateMemSet(buf, b_.getInt8(0), call.type.size, 1); Value *pid = b_.CreateLShr(b_.CreateGetPidTgid(), 32); Value *addr_offset = b_.CreateGEP(buf, b_.getInt64(0)); Value *pid_offset = b_.CreateGEP(buf, {b_.getInt64(0), b_.getInt64(8)}); call.vargs->front()->accept(*this); b_.CreateStore(expr_, addr_offset); b_.CreateStore(pid, pid_offset); expr_ = buf; ``` These are llvm [Intermediate Representation](https://en.wikipedia.org/wiki/Intermediate_representation) \(IR\) functions that emit an llvm assembly-like language which can be compiled directly to BPF, thanks to llvm's BPF support. If you use bpftrace -d, you'll see this llvm assembly: ```shell bpftrace -d -e 'kprobe:do_nanosleep { printf("%s is sleeping\n", comm); }' ``` Produces: ```ll ... define i64 @"kprobe:do_nanosleep"(i8*) local_unnamed_addr section "s_kprobe:do_nanosleep" { entry: %comm = alloca [64 x i8], align 1 %printf_args = alloca %printf_t, align 8 %1 = bitcast %printf_t* %printf_args to i8* call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %1) store i64 0, %printf_t* %printf_args, align 8 %2 = getelementptr inbounds [64 x i8], [64 x i8]* %comm, i64 0, i64 0 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2) call void @llvm.memset.p0i8.i64(i8* nonnull %2, i8 0, i64 64, i32 1, i1 false) %get_comm = call i64 inttoptr (i64 16 to i64 (i8*, i64)*)([64 x i8]* nonnull %comm, i64 64) %3 = getelementptr inbounds %printf_t, %printf_t* %printf_args, i64 0, i32 1, i64 0 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %3, i8* nonnull %2, i64 64, i32 1, i1 false) %pseudo = call i64 @llvm.bpf.pseudo(i64 1, i64 1) %get_cpu_id = call i64 inttoptr (i64 8 to i64 ()*)() %perf_event_output = call i64 inttoptr (i64 25 to i64 (i8*, i8*, i64, i8*, i64)*)(i8* %0, i64 %pseudo, i64 %get_cpu_id, %printf_t* nonnull %printf_args, i64 72) call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %1) ret i64 0 } ... ``` ## References Reference documentation for the codegen_llvm.cpp IR calls: - [llvm::IRBuilderBase Class Reference](https://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html) - [llvm::IRBuilder Class Template Reference](https://llvm.org/doxygen/classllvm_1_1IRBuilder.html) Reference documentation for the llvm assembly: - [LLVM Language Reference Manual](https://llvm.org/docs/LangRef.html) Reference documentation for eBPF kernel helpers: - [Kernel Helpers](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md#helpers) - [`bpf.h`](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/bpf.h) Reference for eBPF syscall and data structures (e.g. maps): - [`bpf(2)` man page](http://man7.org/linux/man-pages/man2/bpf.2.html) ## Gotchas If there's one gotcha I would like to mention, it's the use of CreateGEP() (Get Element Pointer). It's needed when dereferencing at an offset in a buffer, and it's tricky to use. Here is [a good video](https://www.youtube.com/watch?v=m8G_S5LwlTo&t=1753s) on how GEP works. ## Verifier BPF programs are submitted to Linux's in-kernel BPF verifier. Read the large comment at the start of the source; it provides a good explanation. Source code: https://github.com/torvalds/linux/blob/master/kernel/bpf/verifier.c Self-tests: https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/test_verifier.c If you see an error, it's often educational to look up the error message inside the source code or tests. The reasoning is easily understood if you work your way backwards from the message. If you find a test which expects your error message: the name of the test may reveal a better explanation for what the error means. You may also find that nearby tests reveal the criteria for success. Reading BPF instructions is difficult, but if you compare "successful tests" against their various "failure tests": you may see patterns and differences. For example, a successful test may perform a bitmask or conditional logic to provide guarantees about what range of inputs is possible. Mostly the verifier is trying to check "are you allowed to read/write this memory?". Usually there's a notion of "if your read begins inside the BPF stack, it needs to end inside the BPF stack as well", or suchlike. For example: if you've stack-allocated a buffer of 64 bytes for writing strings into, and you intend to parameterise "how many bytes might I copy into this buffer": you will need to add some minimum and maximum conditions, to constrain whichever variable is used to determine the length of data copied. BPF load and store instructions may be picky about what locations they're happy to read/write to. For example, probe_read_str() will only permit writes into a PTR_TO_STACK. I've documented some common errors you may encounter when the verifier bounds-checks your program. Most of this was learned during https://github.com/bpftrace/bpftrace/pull/241. ### min value is negative ``` R2 min value is negative, either use unsigned or 'var &= const' ``` Probably you are using a variable to determine "how far should I jump, relative to this pointer". You need to prove that your variable is always positive. You could try casting to unsigned integer (my notes say that this did not result in any improvement, but it feels like it's worth another try): ```c++ // where expr_ is the problematic Value* b_.CreateIntCast( expr_, b_.getInt64Ty(), false) ``` Or you could bitmask it such that no negative number is possible: ```c++ b_.CreateAnd( expr_, 0x7fffffffffffffff) // 64-bit number with all bits except the first set to 1 ``` Or you could try [CreateMaxNum()](https://llvm.org/docs/LangRef.html#llvm-maxnum-intrinsic) (my notes say that this segfaulted, but it feels like it's worth another try): ```c++ b_.CreateMaxNum( b_.getInt64(0), expr_, "ensure_positive"), ``` Or you could try using if/else to provide bounds hints (my notes say that this did not result in any improvement, but it feels like it's worth another try): ```c++ // where expr_ is the problematic Value* // allocate a variable in which to store your final result, after comparisons are completed AllocaInst *mycoolvar = b_.CreateAllocaBPF(b_.getInt64Ty(), "mycoolvar"); Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *positive = BasicBlock::Create(module_->getContext(), "positive", parent); BasicBlock *negative = BasicBlock::Create(module_->getContext(), "negative", parent); BasicBlock *done = BasicBlock::Create(module_->getContext(), "done", parent); b_.CreateCondBr( b_.CreateICmpUGE(expr_, b_.getInt64(0), "if_positive"), positive, negative); // if expr_ is positive, store it into mycoolvar b_.SetInsertPoint(positive); b_.CreateStore(expr_, mycoolvar); b_.CreateBr(done); // if expr_ is negative, store a 0 into mycoolvar (or whatever you want to do) b_.SetInsertPoint(negative); b_.CreateStore(b_.getInt64(0), mycoolvar); b_.CreateBr(done); b_.SetInsertPoint(done); ``` **My favoured approach is to select the result of an unsigned comparison:** ```c++ // largest number we'll allow. choosing arbitrary maximum // since this example just wants to take advantage of the comparison's unsignedness Value *max = b_.getInt64(1024); // integer comparison: unsigned less-than-or-equal-to CmpInst::Predicate P = CmpInst::ICMP_ULE; // check whether expr_ is less-than-or-equal-to maximum Value *Cmp = b_.CreateICmp(P, expr_, max, "str.min.cmp"); // Select will contain expr_ if expr_ is sufficiently low, otherwise it will contain max Value *Select = b_.CreateSelect(Cmp, expr_, max, "str.min.select"); ``` ### unbounded memory access ``` R2 unbounded memory access, use 'var &= const' or 'if (var < const)' ``` You need to prove that you don't jump too far from your pointer. This re-uses techniques from "min value is negative"; you just need to tighten the range even further. How far is too far? You need to [stay below `BPF_MAX_VAR_SIZ`](https://github.com/bpftrace/bpftrace/pull/241#issuecomment-440274294), `1ULL << 29`. So, you could bitmask your variable with `(1ULL << 29) - 1` = `0x1FFFFFFF`: ```c++ b_.CreateAnd( expr_, 0x1fffffff) // (1ULL << 29) - 1 ``` ### invalid stack ``` invalid stack type R1 off=-72 access_size=536870911 ``` This means that it's possible for us to jump so far that we'd overflow our stack. Keep re-using techniques from above, and tighten the range even further. But more likely, you have a fundamental problem: perhaps you're trying to allocate a buffer of arbitrary size (determined at runtime), and do arbitrarily-sized writes into it (determined at runtime). If indeed that's what you're trying to do: you'll have to change your architecture. The BPF stack (512 bytes) can only accommodate tiny allocations and jumps. You need to move towards storing your data in BPF maps. Consider this ongoing discussion on how to rearchitect to store stack data in a map: https://github.com/bpftrace/bpftrace/issues/305 ### expected=PTR_TO_STACK; actual=PTR_TO_MAP_VALUE ``` R1 type=map_value_or_null expected=fp ``` This was encountered when I invoked `probe_read_str(void *dst, int size, const void *unsafe_ptr)` with a `*dst` that pointed to a BPF map value. It refused; `probe_read_str(3)` will only write into stack-allocated memory. The workaround is probably to write data onto the BPF stack _first_, then transfer from BPF stack into BPF map. If you've a lot of data, then this will take a few trips. ### stack limit exceeded ``` Looks like the BPF stack limit of 512 bytes is exceeded. Please move large on stack variables into BPF per-cpu array map. ``` You're trying to stack-allocate a really big variable. Sadly you'll need to rearchitect; see above. ### call to 'memset' is not supported. A call to built-in function 'memset' is not supported. This occurs when you attempt to zero out a large amount of memory, e.g. 1024 bytes. Probably the real problem is that you stack-allocated a really big variable. It just happens that (at large numbers): you'll get the error about memset _before_ you get the error about the allocation. ## Examples. ### 1. Codegen: Sum We can explore and get the hang of llvm assembly by writing some simple C programs and compiling them using clang. Since llvm assembly maps to llvm IR, I've sometimes prototyped my codegen_llvm.cpp IR this way: writing a C program to produce the llvm assembly, and then manually mapping it back to llvm IR. test.c: ```C int test(int arg_a, int arg_b) { int sum; sum = arg_a + arg_b; return sum; } ``` Compiling into llvm assembly: ``` # /usr/bin/clang-6.0 -cc1 test.c -emit-llvm ``` Produces test.ll: ```ll ; ModuleID = 'test.c' source_filename = "test.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" ; Function Attrs: noinline nounwind optnone define i32 @test(i32 %arg_a, i32 %arg_b) #0 { %arg_a.addr = alloca i32, align 4 %arg_b.addr = alloca i32, align 4 %sum = alloca i32, align 4 store i32 %arg_a, i32* %arg_a.addr, align 4 store i32 %arg_b, i32* %arg_b.addr, align 4 %1 = load i32, i32* %arg_a.addr, align 4 %2 = load i32, i32* %arg_b.addr, align 4 %add = add nsw i32 %1, %2 store i32 %add, i32* %sum, align 4 %3 = load i32, i32* %sum, align 4 ret i32 %3 } attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } !llvm.module.flags = !{!0} !llvm.ident = !{!1} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{!"clang version 6.0.1-svn334776-1~exp1~20180726133222.87 (branches/release_60)"} ``` You can imagine now mapping this back, line by line, to IR. Eg: ```ll %arg_a.addr = alloca i32, align 4 %arg_b.addr = alloca i32, align 4 %sum = alloca i32, align 4 ``` Becomes: ```C++ AllocaInst *arg_a_alloc = b_.CreateAllocaBPF(CreateUInt32(), "arg_a"); AllocaInst *arg_b_alloc = b_.CreateAllocaBPF(CreateUInt32(), "arg_b"); AllocaInst *sum_alloc = b_.CreateAllocaBPF(CreateUInt32(), "sum"); ``` And then: ```ll store i32 %arg_a, i32* %arg_a.addr, align 4 store i32 %arg_b, i32* %arg_b.addr, align 4 ``` Becomes: ```C++ Value *arg_a = test->arg_begin()+0; // haven't explained this bit yet Value *arg_b = test->arg_begin()+1; // " " b_.CreateStore(arg_a, arg_a_alloc); b_.CreateStore(arg_b, arg_b_alloc); ``` And then: ```ll %1 = load i32, i32* %arg_a.addr, align 4 %2 = load i32, i32* %arg_b.addr, align 4 %add = add nsw i32 %1, %2 store i32 %add, i32* %sum, align 4 ``` Becomes: ``` Value *arg_a_load = b_.CreateLoad(arg_a_alloc); Value *arg_b_load = b_.CreateLoad(arg_b_alloc); Value *add = b_.CreateAdd(arg_a_load, arg_b_load); b_.CreateStore(add, sum_alloc); ``` Although I'd probably have written that on one line as: ``` b_.CreateStore(b_.CreateAdd(b_.CreateLoad(arg_a_alloc, arg_b_alloc)), sum_alloc); ``` Finally: ```ll %3 = load i32, i32* %sum, align 4 ret i32 %3 ``` Becomes (I'll just do this on one line as well): ``` b_.CreateRet(b_.CreateLoad(sum_alloc)); ``` That's just my mental conversion. I haven't tested this and it may have a bug. But this should be enough to illustrate the idea. ### 2. Codegen: curtask If you need to add support to a BPF kernel function that bpftrace does not yet call, this is a simple example. It adds a `curtask` builtin that calls BPF_FUNC_get_current_task. See [bcc Kernel Versions](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md) for documentation on these BPF functions. The commit is: https://github.com/bpftrace/bpftrace/commit/895ea46f2c800e2f283339d0c96b3c8209590498 The diff is as simple as such an addition gets, and shows the different files and locations that need to be updated: ```diff diff --git a/README.md b/README.md index 6d72e2a..9cf4d8b 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,7 @@ Variables: - `arg0`, `arg1`, ... etc. - Arguments to the function being traced - `retval` - Return value from function being traced - `func` - Name of the function currently being traced +- `curtask` - Current task_struct as a u64. Functions: - `hist(int n)` - Produce a log2 histogram of values of `n` diff --git a/src/ast/codegen_llvm.cpp b/src/ast/codegen_llvm.cpp index 27fa477..d3dd1ff 100644 --- a/src/ast/codegen_llvm.cpp +++ b/src/ast/codegen_llvm.cpp @@ -70,6 +70,10 @@ void CodegenLLVM::visit(Builtin &builtin) { expr_ = b_.CreateGetCpuId(); } + else if (builtin.ident == "curtask") + { + expr_ = b_.CreateGetCurrentTask(); + } else if (builtin.ident == "comm") { AllocaInst *buf = b_.CreateAllocaBPF(builtin.type, "comm"); diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp index ccae94c..3ccf1e6 100644 --- a/src/ast/irbuilderbpf.cpp +++ b/src/ast/irbuilderbpf.cpp @@ -307,6 +307,19 @@ CallInst *IRBuilderBPF::CreateGetCpuId() return CreateCall(getcpuid_func, {}, "get_cpu_id"); } +CallInst *IRBuilderBPF::CreateGetCurrentTask() +{ + // u64 bpf_get_current_task(void) + // Return: current task_struct + FunctionType *getcurtask_func_type = FunctionType::get(getInt64Ty(), false); + PointerType *getcurtask_func_ptr_type = PointerType::get(getcurtask_func_type, 0); + Constant *getcurtask_func = ConstantExpr::getCast( + Instruction::IntToPtr, + getInt64(BPF_FUNC_get_current_task), + getcurtask_func_ptr_type); + return CreateCall(getcurtask_func, {}, "get_cur_task"); +} + CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, bool ustack, size_t limit) { Value *map_ptr = CreateBpfPseudoCall(bpftrace_.stackid_maps_[limit]->mapfd_); diff --git a/src/ast/irbuilderbpf.h b/src/ast/irbuilderbpf.h index 0321e9a..ce2e3b6 100644 --- a/src/ast/irbuilderbpf.h +++ b/src/ast/irbuilderbpf.h @@ -36,6 +36,7 @@ public: CallInst *CreateGetPidTgid(); CallInst *CreateGetUidGid(); CallInst *CreateGetCpuId(); + CallInst *CreateGetCurrentTask(); CallInst *CreateGetStackId(Value *ctx, bool ustack); CallInst *CreateGetJoinMap(Value *ctx); void CreateGetCurrentComm(AllocaInst *buf, size_t size); diff --git a/src/ast/semantic_analyser.cpp b/src/ast/semantic_analyser.cpp index 8eb5744..64c9411 100644 --- a/src/ast/semantic_analyser.cpp +++ b/src/ast/semantic_analyser.cpp @@ -32,6 +32,7 @@ void SemanticAnalyser::visit(Builtin &builtin) builtin.ident == "uid" || builtin.ident == "gid" || builtin.ident == "cpu" || + builtin.ident == "curtask" || builtin.ident == "retval") { builtin.type = CreateUInt64(); } diff --git a/src/lexer.l b/src/lexer.l index c5996b6..3bec616 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -38,7 +38,7 @@ header <(\\.|[_\-\./a-zA-Z0-9])*> {vspace}+ { loc.lines(yyleng); loc.step(); } "//".*$ // Comments -pid|tid|uid|gid|nsecs|cpu|comm|stack|ustack|arg[0-9]|retval|func|name { +pid|tid|uid|gid|nsecs|cpu|comm|stack|ustack|arg[0-9]|retval|func|name|curtask { return Parser::make_BUILTIN(yytext, loc); } {ident} { return Parser::make_IDENT(yytext, loc); } {path} { return Parser::make_PATH(yytext, loc); } diff --git a/tests/codegen.cpp b/tests/codegen.cpp index 38918ca..c00d25f 100644 --- a/tests/codegen.cpp +++ b/tests/codegen.cpp @@ -489,6 +489,42 @@ attributes #1 = { argmemonly nounwind } )EXPECTED"); } +TEST(codegen, builtin_curtask) +{ + test("kprobe:f { @x = curtask }", + +R"EXPECTED(; Function Attrs: nounwind +declare i64 @llvm.bpf.pseudo(i64, i64) #0 + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 + +define i64 @"kprobe:f"(i8* nocapture readnone) local_unnamed_addr section "s_kprobe:f" { +entry: + %"@x_val" = alloca i64, align 8 + %"@x_key" = alloca i64, align 8 + %get_cur_task = tail call i64 inttoptr (i64 35 to i64 ()*)() + %1 = bitcast i64* %"@x_key" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %1) + store i64 0, i64* %"@x_key", align 8 + %2 = bitcast i64* %"@x_val" to i8* + call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2) + store i64 %get_cur_task, i64* %"@x_val", align 8 + %pseudo = tail call i64 @llvm.bpf.pseudo(i64 1, i64 1) + %update_elem = call i64 inttoptr (i64 2 to i64 (i8*, i8*, i8*, i64)*)(i64 %pseudo, i64* nonnull %"@x_key", i64* nonnull %"@x_val", i64 0) + call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %1) + call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %2) + ret i64 0 +} + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 + +attributes #0 = { nounwind } +attributes #1 = { argmemonly nounwind } +)EXPECTED"); +} + TEST(codegen, builtin_comm) { test("kprobe:f { @x = comm }", diff --git a/tests/parser.cpp b/tests/parser.cpp index cff201b..49b83be 100644 --- a/tests/parser.cpp +++ b/tests/parser.cpp @@ -29,6 +29,7 @@ TEST(Parser, builtin_variables) test("kprobe:f { gid }", "Program\n kprobe:f\n builtin: gid\n"); test("kprobe:f { nsecs }", "Program\n kprobe:f\n builtin: nsecs\n"); test("kprobe:f { cpu }", "Program\n kprobe:f\n builtin: cpu\n"); + test("kprobe:f { curtask }", "Program\n kprobe:f\n builtin: curtask\n"); test("kprobe:f { comm }", "Program\n kprobe:f\n builtin: comm\n"); test("kprobe:f { stack }", "Program\n kprobe:f\n builtin: stack\n"); test("kprobe:f { ustack }", "Program\n kprobe:f\n builtin: ustack\n"); diff --git a/tests/semantic_analyser.cpp b/tests/semantic_analyser.cpp index d6e26b8..d9b24e2 100644 --- a/tests/semantic_analyser.cpp +++ b/tests/semantic_analyser.cpp @@ -67,6 +67,7 @@ TEST(semantic_analyser, builtin_variables) test("kprobe:f { gid }", 0); test("kprobe:f { nsecs }", 0); test("kprobe:f { cpu }", 0); + test("kprobe:f { curtask }", 0); test("kprobe:f { comm }", 0); test("kprobe:f { stack }", 0); test("kprobe:f { ustack }", 0); ``` ### 3. Codegen: arguments & return value See the implementation of `lhist()` for an example of pulling in arguments. Commit: https://github.com/bpftrace/bpftrace/commit/6bdd1198e04392aa468b12357a051816f2cc50e4 You'll also notice that the builtins finish by setting `expr_` to the final result. This is taking the node in the AST and replacing it with the computed expression. Calls don't necessarily do this: for example, `reg()` sets `expr_` since it returns a value, but `printf()` sets `expr_` to `nullptr`, since it does not return a value. ### 4. Codegen: sum(), min(), max(), avg(), stats() These are examples of adding new map functions, and the required components. Since the functions themselves are simple, they are good examples of codegen. They were all added in a single commit: https://github.com/bpftrace/bpftrace/commit/0746ff9c048ed503c606b736ad3a78e141c22890 This also shows the bpftrace components that were added to support these: `BPFtrace::print_map_stats()`, `BPFtrace::max_value()`, `BPFtrace::min_value()`. # Probes Probes are reasonably straightforward. We use libbpf/libbcc, both from [bcc](https://github.com/iovisor/bcc), to create the probes via functions such as `bpf_attach_kprobe()`, `bpf_attach_uprobe()`, and `bpf_attach_tracepoint()`. We also use USDT helpers such as `bcc_usdt_enable_probe()` ## 1. Probes: Interval The addition of the `interval` probe type is a simple example of adding a probe, and the components required: https://github.com/bpftrace/bpftrace/commit/c1e7b05be917ad6fa23a210d047bf9387745bf32 diff: ```diff diff --git a/README.md b/README.md index b73a6d1..4654f65 100644 --- a/README.md +++ b/README.md @@ -157,8 +157,8 @@ Attach script to a statically defined tracepoint in the kernel: Tracepoints are guaranteed to be stable between kernel versions, unlike kprobes. -### timers -Run the script at specified time intervals: +### profile +Run the script on all CPUs at specified time intervals: `profile:hz:99 { ... }` @@ -168,6 +168,13 @@ Run the script at specified time intervals: `profile:us:1500 { ... }` +### interval +Run the script once per interval, for printing interval output: + +`interval:s:1 { ... }` + +`interval:ms:20 { ... }` + ### Multiple attachment points A single probe can be attached to multiple events: diff --git a/src/ast/semantic_analyser.cpp b/src/ast/semantic_analyser.cpp index a08eaf7..2a79553 100644 --- a/src/ast/semantic_analyser.cpp +++ b/src/ast/semantic_analyser.cpp @@ -478,6 +478,15 @@ void SemanticAnalyser::visit(AttachPoint &ap) else if (ap.freq <= 0) err_ << "profile frequency should be a positive integer" << std::endl; } + else if (ap.provider == "interval") { + if (ap.target == "") + err_ << "interval probe must have unit of time" << std::endl; + else if (ap.target != "ms" && + ap.target != "s") + err_ << ap.target << " is not an accepted unit of time" << std::endl; + if (ap.func != "") + err_ << "interval probe must have an integer frequency" << std::endl; + } else if (ap.provider == "BEGIN" || ap.provider == "END") { if (ap.target != "" || ap.func != "") err_ << "BEGIN/END probes should not have a target" << std::endl; diff --git a/src/attached_probe.cpp b/src/attached_probe.cpp index 598ecdc..991111b 100644 --- a/src/attached_probe.cpp +++ b/src/attached_probe.cpp @@ -36,6 +36,7 @@ bpf_prog_type progtype(ProbeType t) case ProbeType::uretprobe: return BPF_PROG_TYPE_KPROBE; break; case ProbeType::tracepoint: return BPF_PROG_TYPE_TRACEPOINT; break; case ProbeType::profile: return BPF_PROG_TYPE_PERF_EVENT; break; + case ProbeType::interval: return BPF_PROG_TYPE_PERF_EVENT; break; default: abort(); } } @@ -61,6 +62,9 @@ AttachedProbe::AttachedProbe(Probe &probe, std::tuple &fun case ProbeType::profile: attach_profile(); break; + case ProbeType::interval: + attach_interval(); + break; default: abort(); } @@ -93,6 +97,7 @@ AttachedProbe::~AttachedProbe() err = bpf_detach_tracepoint(probe_.path.c_str(), eventname().c_str()); break; case ProbeType::profile: + case ProbeType::interval: break; default: abort(); @@ -279,4 +284,35 @@ void AttachedProbe::attach_profile() } } +void AttachedProbe::attach_interval() +{ + int pid = -1; + int group_fd = -1; + int cpu = 0; + + uint64_t period, freq; + if (probe_.path == "s") + { + period = probe_.freq * 1e9; + freq = 0; + } + else if (probe_.path == "ms") + { + period = probe_.freq * 1e6; + freq = 0; + } + else + { + abort(); + } + + int perf_event_fd = bpf_attach_perf_event(progfd_, PERF_TYPE_SOFTWARE, + PERF_COUNT_SW_CPU_CLOCK, period, freq, pid, cpu, group_fd); + + if (perf_event_fd < 0) + throw std::runtime_error("Error attaching probe: " + probe_.name); + + perf_event_fds_.push_back(perf_event_fd); +} + } // namespace bpftrace diff --git a/src/attached_probe.h b/src/attached_probe.h index 86b610c..97036e3 100644 --- a/src/attached_probe.h +++ b/src/attached_probe.h @@ -27,6 +27,7 @@ private: void attach_uprobe(); void attach_tracepoint(); void attach_profile(); + void attach_interval(); Probe &probe_; std::tuple &func_; diff --git a/src/types.cpp b/src/types.cpp index 6813c72..2abaad6 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -57,6 +57,8 @@ ProbeType probetype(const std::string &type) return ProbeType::tracepoint; else if (type == "profile") return ProbeType::profile; + else if (type == "interval") + return ProbeType::interval; abort(); } diff --git a/src/types.h b/src/types.h index 4c4524a..6c94eac 100644 --- a/src/types.h +++ b/src/types.h @@ -52,6 +52,7 @@ enum class ProbeType uretprobe, tracepoint, profile, + interval, }; std::string typestr(Type t); diff --git a/tests/bpftrace.cpp b/tests/bpftrace.cpp index 3c3b036..50b6538 100644 --- a/tests/bpftrace.cpp +++ b/tests/bpftrace.cpp @@ -59,6 +59,14 @@ void check_profile(Probe &p, const std::string &unit, int freq, const std::strin EXPECT_EQ("profile:" + unit + ":" + std::to_string(freq), p.name); } +void check_interval(Probe &p, const std::string &unit, int freq, const std::string &prog_name) +{ + EXPECT_EQ(ProbeType::interval, p.type); + EXPECT_EQ(freq, p.freq); + EXPECT_EQ(prog_name, p.prog_name); + EXPECT_EQ("interval:" + unit + ":" + std::to_string(freq), p.name); +} + void check_special_probe(Probe &p, const std::string &attach_point, const std::string &prog_name) { EXPECT_EQ(ProbeType::uprobe, p.type); @@ -309,6 +317,22 @@ TEST(bpftrace, add_probes_profile) check_profile(bpftrace.get_probes().at(0), "ms", 997, probe_prog_name); } +TEST(bpftrace, add_probes_interval) +{ + ast::AttachPoint a("interval", "s", 1); + ast::AttachPointList attach_points = { &a }; + ast::Probe probe(&attach_points, nullptr, nullptr); + + StrictMock bpftrace; + + EXPECT_EQ(0, bpftrace.add_probe(probe)); + EXPECT_EQ(1, bpftrace.get_probes().size()); + EXPECT_EQ(0, bpftrace.get_special_probes().size()); + + std::string probe_prog_name = "interval:s:1"; + check_interval(bpftrace.get_probes().at(0), "s", 1, probe_prog_name); +} + std::pair, std::vector> key_value_pair_int(std::vector key, int val) { std::pair, std::vector> pair; diff --git a/tests/parser.cpp b/tests/parser.cpp index 786f3d0..d2db79b 100644 --- a/tests/parser.cpp +++ b/tests/parser.cpp @@ -260,6 +260,14 @@ TEST(Parser, profile_probe) " int: 1\n"); } +TEST(Parser, interval_probe) +{ + test("interval:s:1 { 1 }", + "Program\n" + " interval:s:1\n" + " int: 1\n"); +} + TEST(Parser, multiple_attach_points_kprobe) { test("BEGIN,kprobe:sys_open,uprobe:/bin/sh:foo,tracepoint:syscalls:sys_enter_* { 1 }", ``` bpftrace-0.27.1/docs/language.md000066400000000000000000002333061526721631600164440ustar00rootroot00000000000000# The bpftrace Language The `bpftrace` (`bt`) language is inspired by the D language used by `dtrace` and uses a similar program structure. Each section is optional but must appear in this order: 1. **[C Definitions](#structs)** — `#include` directives, `#define` macros, and `struct`/`union`/`enum` type definitions. Must come before everything else (aside from a shebang line). 2. **[Config Block](#config-block) and [Imports](#imports)** — a `config` block and any `import` statements. These can appear in any order relative to each other, but must appear after C definitions and before action blocks, map declarations, and macros. 3. **[Action Blocks](#action-blocks), [Macros](#macros), and [Map Declarations](#map-declarations)** — the main body of the script. These can appear in any order relative to each other. For example: ``` #include #define RED "\033[31m" struct S { int x; } config = { stack_mode=perf } let @a = lruhash(100); macro greet { print("hi"); } kprobe:do_nanosleep { greet!(); } ``` ## Action Blocks Each action block consists of three parts: ``` [name=]probe[,probe] /predicate/ { action } ``` * **Probes**\ A probe specifies the event and event type to attach to. See [the probes section](#probes) for more detail. * **Predicate**\ The predicate is an optional condition that must be met for the action to be executed. * **Action**\ Actions are the programs that run when an event fires (and the predicate is met). An action is a semicolon (`;`) separated list of statements and always enclosed by brackets `{}`. A basic script that traces the `open(2)` and `openat(2)` system calls can be written as follows: ``` begin { printf("Tracing open syscalls... Hit Ctrl-C to end.\n"); } tracepoint:syscalls:sys_enter_open, tracepoint:syscalls:sys_enter_openat { printf("%-6d %-16s %s\n", pid, comm, str(args.filename)); } ``` The above script has two action blocks and a total of 3 probes. The first action block uses the special `begin` probe, which fires once during `bpftrace` startup. This probe is used to print a header, indicating that the tracing has started. The second action block uses two probes, one for `open` and one for `openat`, and defines an action that prints the file being `open` ed as well as the `pid` and `comm` of the process that execute the syscall. See the [Probes](#probes) section for details on the available probe types. ## Arguments This refers to traced function and tracepoint arguments. There are two ways to access these arguments and the way you choose depends on the [probe type](#probes). - For `uprobe`, `kprobe`, and `usdt` use the `argN` format. - For `rawtracepoint`, `tracepoint`, `fentry`, `fexit`, and `uprobe` (with DWARF) use the `args` format. ### argN These keywords allow access to the nth argument passed to the function being traced. For the first argument use `arg0`, for the second `arg1`, and so forth. The type of each arg is an `int64` and will often require casting to non scalar types, e.g., `$x = (struct qstr *)arg1`. These are extracted from the CPU registers. The amount of args passed in registers depends on the CPU architecture. ### args This keyword represents the struct of all arguments of the traced function. You can print the entire structure via `print(args)` or access particular fields using the dot syntax, e.g., `$x = str(args.filename);`. To see the args for a particular function, you can use [verbose listing mode](../man/adoc/bpftrace.adoc#listing-probes). Example: ``` # bpftrace -lv 'fentry:tcp_reset' fentry:tcp_reset struct sock * sk struct sk_buff * skb ``` ## Arrays bpftrace supports accessing one-dimensional arrays like those found in `C`. Constructing arrays from scratch, like `int a[] = {1,2,3}` in `C`, is not supported. They can only be read into a variable from a pointer. The `[]` operator is used to access elements. ``` struct MyStruct { int y[4]; } kprobe:dummy { $s = (struct MyStruct *) arg0; print($s.y[0]); } ``` ## Command Line Parameters Custom options can be passed to a bpftrace program itself via positional or named parameters. It is recommended to use **named parameters** because they are less ambiguous in terms of their types and meaning (they have actual names). ### Named Parameters Named parameters can be accessed in a bpftrace program via the `getopt` function call, e.g., `getopt("my_named_param", 5)`, `getopt("my_bool_param")`. The first argument is the parameter name and the second is the default value when that argument is not passed on the command line. If the second argument is not provided it indicates that the parameter is a `boolean` type. Named parameters must come AFTER a double dash (`--`) when being passed on the command line, e.g., ``` # bpftrace -e 'begin { print((getopt("aa", 1), getopt("bb"))); }' -- --aa=20 --bb ``` Here `getopt("aa", 1)` would evaluate to `20` and `getopt("bb")` would evaluate to `true`. Named parameters require the `=` to set their value unless they are boolean parameters (like 'bb' above). The supported types are string, number, and boolean. ### Positional Parameters Positional parameters can be accessed in a bpftrace program via, what looks like, a numbered scratch variable, e.g. `$1`, `$2`, ..., `$N`. So `$1` would be the first positional parameter and so on. Positional parameters can be placed before or after a double dash, e.g., ``` # bpftrace -e 'begin { print(($1, $2)); }' p1 -- 20 ``` Here `$1` would evaluate to a string `p1` and `$2` would evaluate to a number `20`. If a parameter is used that was not provided, it will default to zero for a numeric context, and "" for a string context. Positional parameters may also be used in probe arguments and will be treated as a string parameter, e.g., `tracepoint:block:block_rq_issue /args.bytes > $1/`. If a positional parameter is used in `str()`, it is interpreted as a pointer to the actual given string literal, which allows to do pointer arithmetic on it. Only addition of a single constant, less or equal to the length of the supplied string, is allowed. Example: ``` # bpftrace -e 'begin { printf("I got %d, %s (%d args)\n", $1, str($2), $#); }' 42 "hello" I got 42, hello (2 args) # bpftrace -e 'begin { printf("%s\n", str($1 + 1)) }' "hello" ello ``` `$#` is a special builtin that returns the number of positional arguments supplied. ## Comments Both single line and multi line comments are supported. ``` // A single line comment interval:s:1 { // can also be used to comment inline /* a multi line comment */ print(/* inline comment block */ 1); } ``` ## Conditionals Conditional expressions are supported in the form of if/else statements and the ternary operator. The ternary operator consists of three operands: a condition followed by a `?`, the expression to execute when the condition is true followed by a `:` and the expression to execute if the condition is false. ``` condition ? ifTrue : ifFalse ``` Both the `ifTrue` and `ifFalse` expressions must be of the same type, mixing types is not allowed. The ternary operator can be used as part of an assignment. ``` $a == 1 ? print("true") : print("false"); $b = $a > 0 ? $a : -1; ``` If/else statements are supported. ``` if (condition) { ifblock } else if (condition) { if2block } else { elseblock } ``` ## Config Block To improve script portability, you can set bpftrace [Config Variables](#config-variables) via the config block, which can only be placed at the top of the script before any action blocks, macros, or map declarations. ``` config = { stack_mode=perf; max_map_keys=2 } begin { ... } uprobe:./testprogs/uprobe_test:uprobeFunction1 { ... } ``` The names of the config variables can be in the format of environment variables or their lowercase equivalent without the `BPFTRACE_` prefix. For example, `BPFTRACE_STACK_MODE`, `STACK_MODE`, and `stack_mode` are equivalent. ***Note***: Environment variables for the same config take precedence over those set inside a script config block. [List of All Config Variables](#config-variables) ## Config Variables Some behavior can only be controlled through config variables, which are listed here. These can be set via the [Config Block](#config-block) directly in a script (before any probes) or via their environment variable equivalent, which is upper case and includes the `BPFTRACE_` prefix e.g. `stack_mode`’s environment variable would be `BPFTRACE_STACK_MODE`. ### cache_user_symbols Default: PER_PROGRAM if ASLR disabled or `-c` option given, PER_PID otherwise. * PER_PROGRAM - each program has its own cache. If there are more processes with enabled ASLR for a single program, this might produce incorrect results. * PER_PID - each process has its own cache. This is accurate for processes with ASLR enabled, and enables bpftrace to preload caches for processes running at probe attachment time. If there are many processes running, it will consume a lot of a memory. * NONE - caching disabled. This saves the most memory, but at the cost of speed. ### cpp_demangle Default: true C++ symbol demangling in userspace stack traces is enabled by default. This feature can be turned off by setting the value of this variable to `false`. ### lazy_symbolication Default: false For user space symbols, symbolicate lazily/on-demand (`true`) or symbolicate everything ahead of time (`false`). ### license Default: "GPL" The license bpftrace will use to load BPF programs into the linux kernel. Here is the list of accepted license strings: - GPL - GPL v2 - GPL and additional rights - Dual BSD/GPL - Dual MIT/GPL - Dual MPL/GPL [Read More about BPF licenses](#bpf-license) ### log_size Default: 1000000 Log size in bytes. ### max_bpf_progs Default: 1024 This is the maximum number of BPF programs (functions) that bpftrace can generate. The main purpose of this limit is to prevent bpftrace from hanging since generating a lot of probes takes a lot of resources (and it should not happen often). ### max_cat_bytes Default: 10240 Maximum bytes read by cat builtin. ### max_map_keys Default: 4096 This is the maximum number of keys that can be stored in a map. Increasing the value will consume more memory and increase startup times. There are some cases where you will want to, for example: sampling stack traces, recording timestamps for each page, etc. ### max_probes Default: 1024 This is the maximum number of probes that bpftrace can attach to. Increasing the value will consume more memory, increase startup times, and can incur high performance overhead or even freeze/crash the system. ### max_strlen Default: 1024 The maximum length (in bytes) for values created by `str()`, `buf()` and `path()`. This limit is necessary because BPF requires the size of all dynamically-read strings (and similar) to be declared up front. This is the size for all strings (and similar) in bpftrace unless specified at the call site. There is no artificial limit on what you can tune this to. But you may be wasting resources (memory and cpu) if you make this too high. ### missing_probes Default: `error` Controls handling of probes which cannot be attached because they do not exist (in the kernel or in the traced binary) or there was an issue during attachment. The possible options are: - `error` - always fail on missing probes - `warn` - print a warning but continue execution - `ignore` - silently ignore missing probes ### on_stack_limit Default: 32 The maximum size (in bytes) of individual objects that will be stored on the BPF stack. If they are larger than this limit they will be stored in pre-allocated memory. This exists because the BPF stack is limited to 512 bytes and large objects make it more likely that we’ll run out of space. bpftrace can store objects that are larger than the `on_stack_limit` in pre-allocated memory to prevent this stack error. However, storing in pre-allocated memory may be less memory efficient. Lower this default number if you are still seeing a stack memory error or increase it if you’re worried about memory consumption. ### perf_rb_pages Default: Based on available system memory Number of pages to allocate for each created ring or perf buffer (there is only one of each max). The minimum is: 1 * the number of cpus on your machine. If you’re getting a lot of dropped events bpftrace may not be processing events in the ring buffer (or perf buffer if you're using `skboutput`) fast enough. It may be useful to bump the value higher so more events can be queued up. The tradeoff is that bpftrace will use more memory. The default value is based on available system memory; max is 4096 pages (16mb) and min is 64 pages (256kb), which presumes 4k page size. If your system has a larger page size the amount of allocated memory will be the same but we'll just use fewer pages. ### show_debug_info This is only available if the [Blazesym](https://github.com/libbpf/blazesym) library is available at build time. If it is available this defaults to `true`, meaning that when printing ustack and kstack symbols bpftrace will also show (if debug info is available) symbol file and line ('bpftrace' stack mode) and a label if the function was inlined ('bpftrace' and 'perf' stack modes). There might be a performance difference when symbolicating, which is the only reason to disable this. ### stack_mode Default: bpftrace Output format for ustack and kstack builtins. Available modes/formats: * bpftrace: symbol + offset (e.g. `do_mmap+1`) * perf: linux perf style with leading IP (e.g. `ffffffffb4019501 do_mmap+1`) * raw: no symbolication (print instruction pointer) * build_id: no symbolication (print build_id and file offset) (ustack only) This can be overwritten at the call site. When [debug info](#show_debug_info) is available the file and line is added at the end for `bpftrace` or `perf` stack mode e.g. `spin+37@/home/jordalgo/local/bpftrace/tests/testprogs/uprobe_loop.c:14`. ### str_trunc_trailer Default: `..` Trailer to add to strings that were truncated. Set to empty string to disable truncation trailers. ### print_maps_on_exit Default: true Controls whether maps are printed on exit. Set to `false` in order to change the default behavior and not automatically print maps at program exit. ### unstable features These are the list of unstable features: - `unstable_tseries` - feature flag for time series map type - `unstable_dw_ustack` - feature flag for DWARF-based user-space stack unwinding All of these accept the following options: Default: warn - `error` - fail if this feature is used - `warn` - enable feature but print a warning - `enable` - enable feature ## Data Types The following fundamental types are provided by the language. | | | | --- | --- | | **Type** | **Description** | | bool | `true` or `false` | | uint8 | Unsigned 8 bit integer | | int8 | Signed 8 bit integer | | uint16 | Unsigned 16 bit integer | | int16 | Signed 16 bit integer | | uint32 | Unsigned 32 bit integer | | int32 | Signed 32 bit integer | | uint64 | Unsigned 64 bit integer | | int64 | Signed 64 bit integer | | string | See below | ``` begin { $x = 1<<16; printf("%d %d\n", (uint16)$x, $x); } /* * Output: * 0 65536 */ ``` Integers are by default represented as the smallest possible signed type, e.g. `0`, `1`, and `-1` are all `int8`. If an integer literal exceeds the largest `int64` then it's a `uint64`. Positive integer literals are flexible though. For this code: ``` $a = 1; $a = (uint64)2; ``` `$a` ends up being a `uint64` as bpftrace can determine this statically. Scratch variables and map keys/values will be automatically upcast when necessary, e.g. ``` $a = 1; // starts as int8 $b = -1000; // starts as int16 $a = $b; // $a now becomes an int16 $c = (uint64)1; $d = (int64)-1; // $c is a int64 below // an implicit cast is added to the assignment -> (int64)$d // and a warning about the sign mismatch is surfaced $c = $d; ``` Note: If there is ever an integer sign mismatch that can't be upcast to a type that can hold both, the resulting type is an `int64`. This may lead to undefined behavior, or, most likely, a large number being printed as a negative one. However, implicit casts of integer literals still fail when the literal is outside the destination type's range. For example, `let $a: uint16 = -1;` requires an explicit cast: `let $a: uint16 = (uint16)-1;`. Though this: ``` $b = -1; let $a: uint16 = $b; ``` only yields a warning. Additionally, when vmlinux BTF is available, bpftrace supports casting to some of the kernel's fixed integer types: ``` $a = (uint64_t)1; // $a is a uint64 ``` ### String bpftrace also supports a `string` data type, which it uses for string literals, e.g. `"hello"`. Similar to C this is represented as a well formed char array (NULL terminated). Additionally, all BTF char arrays (`char[]` or `int8[]`) are automatically converted to a bpftrace string but can be casted back to an int array if needed, e.g. `$a = (int8[])"mystring"`; It also may be necessary to utilize the [`str()`](stdlib.md#str) function if bpftrace can't determine the correct address space (user or kernel). ## Filters/Predicates Filters (also known as predicates) can be added after probe names. The probe still fires, but it will skip the action unless the filter is true. ``` kprobe:vfs_read /arg2 < 16/ { printf("small read: %d byte buffer\n", arg2); } kprobe:vfs_read /comm == "bash"/ { printf("read by %s\n", comm); } ``` ## Floating-point Floating-point numbers are not supported by BPF and therefore not by bpftrace. ## Imports Root-level imports allow you to import other files into your script using the `import` statement. ### Syntax ``` import ""; ``` Import statements must appear after [C definitions](#structs) but before any [action blocks](#action-blocks), [macros](#macros), or [map declarations](#map-declarations). ### Supported file types | Extension | Description | |-----------|-------------| | `.bt` | bpftrace script — probes, macros, and map declarations are merged into the importing script | | `.h` | C header — type definitions are made available to the importing script | | `.bpf.c` | BPF C source — compiled and linked into the BPF program. These are checked by the BPF verifier. | If a directory is specified instead of a file, all supported files in that directory (non-recursive) are imported. ### Path resolution The import path is resolved relative to the directory containing the script that has the `import` statement. For example, if `/home/user/script.bt` contains `import "helpers.bt";`, bpftrace looks for `/home/user/helpers.bt`. As a security measure, bpftrace refuses to import from world-writable directories. ### Examples Importing a bpftrace script: ``` // helpers.bt macro greet { print("hello"); } ``` ``` import "helpers.bt"; begin { greet!(); } // prints "hello" ``` Importing a C file: ``` // my_c_lib.bpf.c int __add_one(int val) { return 1 + val; } ``` ``` import "my_c_lib.bpf.c"; begin { print(__add_one(1)); // prints 2 } ``` Importing a directory of files: ``` import "my_lib"; ``` This imports all supported files in the `my_lib/` directory. ### Behavior notes - Each import path is only imported once. Duplicate imports of the same path are silently ignored. - Imported `.bt` scripts can themselves contain `import` statements. - An imported `.bt` script cannot contain a `config` block. Only one config block is allowed in the root script. ## Identifiers Identifiers must match the following regular expression: `[_a-zA-Z][_a-zA-Z0-9]*` ## Keywords `break`, `config`, `continue`, `else`, `for`, `if`, `import`, `let`, `macro`, `offsetof`, `return`, `sizeof`, `unroll`, `while` (deprecated). * `return` - The return keyword is used to exit the current probe. This differs from `exit()` in that it doesn’t exit bpftrace. ## Literals Integer and string literals are supported. Integer literals can be defined in the following formats: * decimal (base 10) * octal (base 8) * hexadecimal (base 16) * scientific (base 10) Octal literals have to be prefixed with a `0` e.g. `0123`. Hexadecimal literals start with either `0x` or `0X` e.g. `0x10`. Scientific literals are written in the `e` format which is a shorthand for `m*10^n` e.g. `$i = 2e3;`. Note that scientific literals are integer only due to the lack of floating point support e.g. `1e-3` is not valid. To improve the readability of big literals an underscore `_` can be used as field separator e.g. 1_000_123_000. Integer suffixes as found in the C language are parsed by bpftrace to ensure compatibility with C headers/definitions but they’re not used as size specifiers. `123UL`, `123U` and `123LL` all result in the same integer type with a value of `123`. These duration suffixes are also supported: `ns`, `us`, `ms`, `s`, `m`, `h`, and `d`. All get turned into integer values in nanoseconds, e.g. ``` $a = 1m; print($a); // prints 60000000000 ``` Character literals are not supported at this time, and the corresponding ASCII code must be used instead: ``` begin { printf("Echo A: %c\n", 65); } ``` String literals can be defined by enclosing the character string in double quotes e.g. `$str = "Hello world";`. Strings support the following escape sequences: | | | | --- | --- | | \n | Newline | | \t | Tab | | \0nn | Octal value nn | | \xnn | Hexadecimal value nn | ## Loops ### For `for` loops can be used to iterate over elements in a map, or over a range of integers, provided as two unary expressions separated by `..`. ``` for ($kv : @map) { block; } ``` ``` for ($i : start..end) { block; } ``` The variable declared in the `for` loop will be initialised on each iteration. If the iteration is over a map, the value will be a tuple containing a key and a value from the map, i.e. `$kv = (key, value)`: ``` @map[10] = 20; for ($kv : @map) { print($kv.0); // key print($kv.1); // value } ``` If a map has multiple keys, the loop variable will be initialised with nested tuple of the form: `((key1, key2, ...), value)`: ``` @map[10,11] = 20; for ($kv : @map) { print($kv.0.0); // key 1 print($kv.0.1); // key 2 print($kv.1); // value } ``` If an integer range is provided, the value will be an integer value for each element in the range, inclusive of the start value and exclusive of the end value: ``` for ($cpu : 0..ncpus) { print($cpu); // current value in range } ``` Note that you cannot adjust the range itself after the loop has started. The `for` start and end values are evaluated once, not on each loop iteration. For example, the following will print `0` through `9`: ``` $a = 10; for ($i : 0..$a) { print($i); $a--; } ``` Both `for` loops support the following control flow statements: | | | | --- | --- | | continue | skip processing of the rest of the block and proceed to the next iteration | | break | terminate the loop | | return | return from the current probe | ### While While loops are deprecated and may be removed in the future; please use `For` loops instead as these are more easily verified to be bounded. ### Unroll Loop unrolling is also supported with the `unroll` statement. ``` unroll(n) { block; } ``` The compiler will evaluate the block `n` times and generate the BPF code for the block `n` times. As this happens at compile time `n` must be a constant greater than 0 (`n > 0`). The following two probes compile into the same code: ``` interval:s:1 { unroll(3) { print("Unrolled") } } interval:s:1 { print("Unrolled") print("Unrolled") print("Unrolled") } ``` ## Macros bpftrace macros (as opposed to C macros) provide a way for you to structure your script. They can be useful when you want to factor out code into smaller, more understandable parts. Or if you want to share code between probes. At a high level, macros can be thought of as semantic aware text replacement. They accept (optional) variable, map, and expression arguments. The body of the macro may only access maps and external variables passed in through the arguments, which is why these are often referred to as "hygienic macros", but the macro body can create new variables which only exist inside the body. A macro's parameter signature specifies how an argument will be used. For example `macro test($a, b, @c)` indicates that `$a` needs to be a scratch variable (which might be mutated), that `b` needs to be an expression that will be inserted where ever `b` is used in the macro body, and that `@c` needs to be a map (which might be mutated). A valid use of this macro could be `test($x, 1 + 2, @y)`. Variables and maps can also be used for ident parameters that expect expressions and would be the same as writing `{ @y }` (Block Expression). Type expression substitution is also supported inside of macros but types must be passed into macro calls wrapped in the `typeof` builtin (see below). Note: User-defined macros with the same name and signature as a standard library macro will override the standard library version. However, standard library macros nested inside of other standard library macros will never use the user-defined version of the same signature. Here are some valid usages of macros: ``` macro one() { 1 } macro add_one(x) { x + 1 } macro add_one_to_each($a, @b) { $a += 1; @b += 1; } macro side_effects(x) { x; x; x; } macro add_two(x) { add_one(x) + 1 } macro p_cast(a, b) { (a*)b } begin { print(one()); // prints 1 print(one); // prints 1 (bare identifier works if the macro accepts 0 args) $a = 10; print(add_one($a)); // prints 11 print(add_one(1 + 1)); // prints 3 @b = 5; add_one_to_each($a, @b); print($a + @b) // prints 17 side_effects({ printf("hi") }) // prints hihihi print(add_two(1)); // prints 3 print( p_cast(typeof(uint8), -1) ); // prints 0xff } ``` Some examples of invalid macro usage: ``` macro unhygienic_access() { @x++ // BAD: @x not passed in } macro wrong_parameter_type($x) { $x++ } begin { @x = 1; unhygienic_access(); wrong_parameter_type(@x); // BAD: macro expects a scratch variable wrong_parameter_type(1 + 1); // BAD: macro expects a scratch variable } ``` Note: If you want the passed in expression to only be executed once, simply bind it to a variable, e.g., ``` macro add_one(x) { let $x = x; $x + 1 } ``` ## Operators and Expressions ### Arithmetic Operators The following operators are available for integer arithmetic: | | | | --- | --- | | + | integer addition | | - | integer subtraction | | * | integer multiplication | | / | integer division | | % | integer modulo | Operations between a signed and an unsigned integer are allowed providing bpftrace can statically prove a safe conversion is possible. If safe conversion is not guaranteed, the operation is undefined behavior. If the two operands are different size, the smaller integer is implicitly promoted to the size of the larger one. Sign is preserved in the promotion. For example, `(uint32)5 + (uint8)3` is converted to `(uint32)5 + (uint32)3` which results in `(uint32)8`. Subtraction (as well as decrement below) always yields a signed integer type as this is equivalent to addition with a signed (negative) integer, e.g. these two assignments yield the same type (`int64`): `$a = (uint64)1 - (uint64)2; $b = (uint64)1 + (-2)`. To maintain an unsigned type, cast the result, e.g. `$a = (uint64)((uint64)1 - (uint64)2);`. Pointers may be used with arithmetic operators but only for addition and subtraction. For subtraction, the pointer must appear on the left side of the operator. Pointers may also be used with logical operators; they are considered true when non-null. ### Logical Operators | | | | --- | --- | | && | Logical AND | | \|\| | Logical OR | | ! | Logical NOT | ### Bitwise Operators | | | | --- | --- | | & | AND | | \| | OR | | ^ | XOR | | << | Left shift the left-hand operand by the number of bits specified by the right-hand expression value | | >> | Right shift the left-hand operand by the number of bits specified by the right-hand expression value | ### Relational Operators The following relational operators are defined for integers and pointers. | | | | --- | --- | | < | left-hand expression is less than right-hand | | <= | left-hand expression is less than or equal to right-hand | | > | left-hand expression is bigger than right-hand | | >= | left-hand expression is bigger or equal to than right-hand | | == | left-hand expression equal to right-hand | | != | left-hand expression not equal to right-hand | The following relation operators are available for comparing strings, integer arrays, and tuples. | | | | --- | --- | | == | left-hand string equal to right-hand | | != | left-hand string not equal to right-hand | ### Assignment Operators The following assignment operators can be used on both `map` and `scratch` variables: | | | | --- | --- | | = | Assignment, assign the right-hand expression to the left-hand variable | | <<= | Update the variable with its value left shifted by the number of bits specified by the right-hand expression value | | >>= | Update the variable with its value right shifted by the number of bits specified by the right-hand expression value | | += | Increment the variable by the right-hand expression value | | -= | Decrement the variable by the right-hand expression value | | *= | Multiple the variable by the right-hand expression value | | /= | Divide the variable by the right-hand expression value | | %= | Modulo the variable by the right-hand expression value | | &= | Bitwise AND the variable by the right-hand expression value | | \|= | Bitwise OR the variable by the right-hand expression value | | ^= | Bitwise XOR the variable by the right-hand expression value | All these operators are syntactic sugar for combining assignment with the specified operator. `@ -= 5` is equal to `@ = @ - 5`. ### Increment and Decrement Operators The increment (`++`) and decrement (`--`) operators can be used on integer and pointer variables to increment their value by one. They can only be used on variables and can either be applied as prefix or suffix. The difference is that the expression `x++` returns the original value of `x`, before it got incremented while `++x` returns the value of `x` post increment. ``` $x = 10; $y = $x--; // y = 10; x = 9 $a = 10; $b = --$a; // a = 9; b = 9 ``` Note that maps will be implicitly declared and initialized to 0 if not already declared or defined. Scratch variables must be initialized before using these operators. Note `++`/`--` on a shared global variable can lose updates. See [`count()`](stdlib.md#count) for more details. ### Block Expressions A block can be used as expression, as long as the last statement of the block is an expression with no trailing semi-colon. ``` let $a = { let $b = 1; $b }; ``` This can be used anywhere an expression can be used. **Note:** There will be a warning for discarded expressions, e.g., ``` { 1 } // Warning $a = { 1 } // No Warning has_key(@a, 1); // Warning $b = has_key(@a, 1); // No Warning ``` The warning can also be silenced by utilizing the Discard Expression: ``` _ = has_key(@a, 1); // No Warning ``` ## Probes bpftrace supports various probe types which allow the user to attach BPF programs to different types of events. Each probe starts with a provider (e.g. `kprobe`) followed by a colon (`:`) separated list of options. An optional name may precede the provider with an equals sign (e.g. `name=`), which is reserved for internal use and future features. The amount of options and their meaning depend on the provider and are detailed below. The valid values for options can depend on the system or binary being traced, e.g. for uprobes it depends on the binary. Also see [Listing Probes](../man/adoc/bpftrace.adoc#listing-probes). It is possible to associate multiple probes with a single action as long as the action is valid for all specified probes. Multiple probes can be specified as a comma (`,`) separated list: ``` kprobe:tcp_reset,kprobe:tcp_v4_rcv { printf("Entered: %s\n", probe); } ``` Wildcards are supported too: ``` kprobe:tcp_* { printf("Entered: %s\n", probe); } ``` Both can be combined: ``` kprobe:tcp_reset,kprobe:*socket* { printf("Entered: %s\n", probe); } ``` By default, bpftrace requires all probes to attach successfully or else an error is returned. However this can be changed using the `missing_probes` config variable. Most providers also support a short name which can be used instead of the full name, e.g. `kprobe:f` and `k:f` are identical. | | | | | --- | --- | --- | | **Probe Name** | **Short Name** | **Description** | | [`begin/end`](#beginend) | - | Built-in events | | [`bench`](#bench) | - | Micro benchmarks | | [`self`](#self) | - | Built-in events | | [`hardware`](#hardware) | `h` | Processor-level events | | [`interval`](#interval) | `i` | Timed output | | [`iter`](#iterator) | `it` | Iterators tracing | | [`fentry/fexit`](#fentry-and-fexit) | `f`/`fr` | Kernel functions tracing with BTF support | | [`kprobe/kretprobe`](#kprobe-and-kretprobe) | `k`/`kr` | Kernel function start/return | | [`profile`](#profile) | `p` | Timed sampling | | [`rawtracepoint`](#rawtracepoint) | `rt` | Kernel static tracepoints with raw arguments | | [`software`](#software) | `s` | Kernel software events | | [`tracepoint`](#tracepoint) | `t` | Kernel static tracepoints | | [`uprobe/uretprobe`](#uprobe-uretprobe) | `u`/`ur` | User-level function start/return | | [`usdt`](#usdt) | `U` | User-level static tracepoints | | [`watchpoint`](#watchpoint) | `w` | Memory watchpoints | ### begin/end These are special built-in events provided by the bpftrace runtime. `begin` is triggered before all other probes are attached. `end` is triggered after all other probes are detached. Each of these probes can be used any number of times, and they will be executed in the same order they are declared. For imports containing `begin` and `end` probes, an effort is made to preserve the partial order implied by the import graph (e.g. if `A` depends on `B`, then `B` will have both its `begin` and `end` probes executed first), but this is not strictly guaranteed. Note that specifying an `end` probe doesn’t override the printing of 'non-empty' maps at exit. To prevent printing all used maps need be cleared in the `end` probe: ``` end { clear(@map1); clear(@map2); } ``` ### test `test` is a special built-in probe type for creating tests. bpftrace executes each `test` probe and checks the return value, error count and possible exit calls to determine a pass. If multiple `test` probes exist in a script, bpftrace executes them sequentially in the order they are specified. To run `test` probes, you must run bpftrace in test mode: `bpftrace --test ...`; otherwise `test` probes will be ignored. ``` test:okay { print("I'm okay! This output will be suppressed."); } test:failure { print("This is a failure! This output will be shown"); return 1; } ``` ### bench `bench` is a special built-in probe type for creating micro benchmarks. bpftrace executes each `bench` probe repeatedly to measure the average execution time of the contained code. If multiple `bench` probes exist in a script, bpftrace executes them sequentially in the order they are specified. To run `bench` probes, you must run bpftrace in bench mode: `bpftrace --bench ...`; otherwise, `bench` probes will be ignored. ``` bench:lhist { @a = lhist(rand % 10, 1, 10, 1); } bench:count { @b = count(); } bench:my_loop { $a = 0; for ($i : 0..10) { $a++; } } ``` ``` Attached 3 probes +-----------+-------------+ | BENCHMARK | NANOSECONDS | +-----------+-------------+ | count | 40 | | lhist | 88 | | my_loop | 124 | +-----------+-------------+ ``` ### self **variants** * `self:signal:SIGUSR1` These are special built-in events provided by the bpftrace runtime. The trigger function is called by the bpftrace runtime when the bpftrace process receives specific events, such as a `SIGUSR1` signal. ``` self:signal:SIGUSR1 { print("abc"); } ``` ### hardware **variants** * `hardware:event_name:` * `hardware:event_name:count` **short name** * `h` These are the pre-defined hardware events provided by the Linux kernel, as commonly traced by the perf utility. They are implemented using performance monitoring counters (PMCs): hardware resources on the processor. There are about ten of these, and they are documented in the perf_event_open(2) man page. The event names are: * `cpu-cycles` or `cycles` * `instructions` * `cache-references` * `cache-misses` * `branch-instructions` or `branches` * `branch-misses` * `bus-cycles` * `frontend-stalls` * `backend-stalls` * `ref-cycles` The `count` option specifies how many events must happen before the probe fires (sampling interval). If `count` is left unspecified a default value is used. This will fire once for every 1,000,000 cache misses. ``` hardware:cache-misses:1e6 { @[pid] = count(); } ``` ### interval **variants** * `interval:count` * `interval:us:count` * `interval:ms:count` * `interval:s:count` * `interval:hz:rate` **short name** * `i` The interval probe fires at a fixed interval as specified by its time spec. Interval fires on one CPU at a time, unlike [profile](#profile) probes. If a unit of time is not specified in the second position, the number is interpreted as nanoseconds; e.g., `interval:1s`, `interval:1000000000`, and `interval:s:1` are all equivalent. This prints the rate of syscalls per second. ``` tracepoint:raw_syscalls:sys_enter { @syscalls = count(); } interval:1s { print(@syscalls); clear(@syscalls); } ``` ### iterator **variants** * `iter:task` * `iter:task:pin` * `iter:task_file` * `iter:task_file:pin` * `iter:task_vma` * `iter:task_vma:pin` **short name** * `it` ***Warning*** this feature is experimental and may be subject to interface changes. These are eBPF iterator probes that allow iteration over kernel objects. Iterator probe can’t be mixed with any other probe, not even another iterator. Each iterator probe provides a set of fields that could be accessed with the ctx pointer. Users can display the set of available fields for each iterator via -lv options as described below. ``` iter:task { printf("%s:%d\n", ctx.task.comm, ctx.task.pid); } /* * Sample output: * systemd:1 * kthreadd:2 * rcu_gp:3 * rcu_par_gp:4 * kworker/0:0H:6 * mm_percpu_wq:8 */ ``` ``` iter:task_file { printf("%s:%d %d:%s\n", ctx.task.comm, ctx.task.pid, ctx.fd, path(ctx.file.f_path)); } /* * Sample output: * systemd:1 1:/dev/null * systemd:1 3:/dev/kmsg * ... * su:1622 2:/dev/pts/1 * ... * bpftrace:1892 2:/dev/pts/1 * bpftrace:1892 6:anon_inode:bpf-prog */ ``` ``` iter:task_vma { printf("%s %d %lx-%lx\n", comm, pid, ctx.vma.vm_start, ctx.vma.vm_end); } /* * Sample output: * bpftrace 119480 55b92c380000-55b92c386000 * ... * bpftrace 119480 7ffd55dde000-7ffd55de2000 */ ``` It’s possible to pin an iterator by specifying the optional probe ':pin' part, that defines the pin file. It can be specified as an absolute or relative path to /sys/fs/bpf. **relative pin** ``` iter:task:list { printf("%s:%d\n", ctx.task.comm, ctx.task.pid); } /* * Sample output: * Program pinned to /sys/fs/bpf/list */ ``` **absolute pin** ``` iter:task_file:/sys/fs/bpf/files { printf("%s:%d %s\n", ctx.task.comm, ctx.task.pid, path(ctx.file.f_path)); } /* * Sample output: * Program pinned to /sys/fs/bpf/files */ ``` ### fentry and fexit **variants** * `fentry[:module]:fn` * `fexit[:module]:fn` * `fentry:bpf[:prog_id]:prog_name` * `fexit:bpf[:prog_id]:prog_name` **short names** * `f` (`fentry`) * `fr` (`fexit`) **requires (`--info`)** * Kernel features:BTF * Probe types:fentry ``fentry``/``fexit`` probes attach to kernel functions similar to [kprobe and kretprobe](#kprobe-and-kretprobe). They make use of eBPF trampolines which allow kernel code to call into BPF programs with near zero overhead. Originally, these were called `kfunc` and `kretfunc` but were later renamed to `fentry` and `fexit` to match how these are referenced in the kernel and to prevent confusion with [BPF Kernel Functions](https://docs.kernel.org/bpf/kfuncs.html). The original names are still supported for backwards compatibility. ``fentry``/``fexit`` probes make use of BTF type information to derive the type of function arguments at compile time. This removes the need for manual type casting and makes the code more resilient against small signature changes in the kernel. The function arguments are available in the `args` struct which can be inspected by doing verbose listing (see [Listing Probes](../man/adoc/bpftrace.adoc#listing-probes)). These arguments are also available in the return probe (`fexit`), unlike `kretprobe`. The bpf variants (e.g. `fentry:bpf[:prog_id]:prog_name`) allow attaching to running BPF programs and sub-programs. For example, if bpftrace was already running with a script like `uprobe:./testprogs/uprobe_test:uprobeFunction1 { print("hello"); }` then you could attach to this program with `fexit:bpf:uprobe___testprogs_uprobe_test_uprobeFunction1_1 { print("bye"); }` and this probe would execute after (because it's `fexit`) the `print("hello")` probe executes. You can specify just the program name, and in this case bpftrace will attach to all running programs and sub-programs with that name. You can differentiate between them using the `probe` builtin. You can also specify the program id (e.g. `fentry:bpf:123:*`) to attach to a specific running BPF program or sub-programs called in that running BPF program. To see a list of running, valid BPF programs and sub-programs use `bpftrace -l 'fentry:bpf:*'`. Note: only BPF programs with a BTF Id can be attached to. Also, the `args` builtin is not yet available for this variant. ``` # bpftrace -lv 'fentry:tcp_reset' fentry:tcp_reset struct sock * sk struct sk_buff * skb ``` ``` fentry:x86_pmu_stop { printf("pmu %s stop\n", str(args.event.pmu.name)); } ``` The fget function takes one argument as file descriptor and you can access it via args.fd and the return value is accessible via retval: ``` fexit:fget { printf("fd %d name %s\n", args.fd, str(retval.f_path.dentry.d_name.name)); } /* * Sample output: * fd 3 name ld.so.cache * fd 3 name libselinux.so.1 */ ``` ### kprobe and kretprobe **variants** * `kprobe[:module]:fn` * `kprobe[:module]:fn+offset` * `kprobe:addr` * `kretprobe[:module]:fn` * `kretprobe:addr` **short names** * `k` * `kr` ``kprobe``s allow for dynamic instrumentation of kernel functions. Each time the specified kernel function is executed the attached BPF programs are ran. ``` kprobe:tcp_reset { @tcp_resets = count() } ``` Function arguments are available through the `argN` for register args. Arguments passed on stack are available using the stack pointer, e.g. `$stack_arg0 = **(int64**)reg("sp") + 16`. Whether arguments passed on stack or in a register depends on the architecture and the number or arguments used, e.g. on x86_64 the first 6 non-floating point arguments are passed in registers and all following arguments are passed on the stack. Note that floating point arguments are typically passed in special registers which don’t count as `argN` arguments which can cause confusion. Consider a function with the following signature: ``` void func(int a, double d, int x) ``` Due to `d` being a floating point, `x` is accessed through `arg1` where one might expect `arg2`. bpftrace does not detect the function signature so it is not aware of the argument count or their type. It is up to the user to perform [Type conversion](#type-conversion) when needed, e.g. ``` #include #include kprobe:vfs_open { printf("open path: %s\n", str(((struct path *)arg0).dentry.d_name.name)); } ``` Here arg0 was cast as a (struct path *), since that is the first argument to vfs_open. The struct support is the same as bcc and based on available kernel headers. This means that many, but not all, structs will be available, and you may need to manually define structs. If the kernel has BTF (BPF Type Format) data, all kernel structs are always available without defining them. For example: ``` kprobe:vfs_open { printf("open path: %s\n", str(((struct path *)arg0).dentry.d_name.name)); } ``` You can optionally specify a kernel module, either to include BTF data from that module, or to specify that the traced function should come from that module. ``` kprobe:kvm:x86_emulate_insn { $ctxt = (struct x86_emulate_ctxt *) arg0; printf("eip = 0x%lx\n", $ctxt.eip); } ``` See [BTF Support](#btf-support) for more details. `kprobe` s are not limited to function entry, they can be attached to any instruction in a function by specifying an offset from the start of the function or by providing the bare address of the function, which is useful if there are multiple functions with the same name. The bare address variant `kprobe:addr` requires the `--unsafe` flag. `kretprobe` s trigger on the return from a kernel function. Return probes do not have access to the function (input) arguments, only to the return value (through `retval`). A common pattern to work around this is by storing the arguments in a map on function entry and retrieving in the return probe: ``` kprobe:d_lookup { $name = (struct qstr *)arg1; @fname[tid] = $name.name; } kretprobe:d_lookup /@fname[tid]/ { printf("%-8d %-6d %-16s M %s\n", elapsed / 1e6, pid, comm, str(@fname[tid])); } ``` ### profile **variants** * `profile:count` * `profile:us:count` * `profile:ms:count` * `profile:s:count` * `profile:hz:rate` **short name** * `p` Profile probes fire on each CPU on the specified interval. These operate using perf_events (a Linux kernel facility, which is also used by the perf command). If a unit of time is not specified in the second position, the number is interpreted as nanoseconds; e.g., `interval:1s`, `interval:1000000000`, and `interval:s:1` are all equivalent. ``` profile:hz:99 { @[tid] = count(); } ``` ### rawtracepoint **variants** * `rawtracepoint[:module]:event` **short name** * `rt` Raw tracepoints are attached to the same tracepoints as normal tracepoint programs. The reason why you might want to use raw tracepoints over normal tracepoints is due to the performance improvement - [Read More](https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_RAW_TRACEPOINT/). `rawtracepoint` arguments can be accessed via the `argN` builtins AND via the `args` builtin. ``` rawtracepoint:vmlinux:kfree_skb { printf("%llx %llx\n", arg0, args.skb); } ``` `arg0` and `args.skb` will print the same address. `rawtracepoint` probes make use of BTF type information to derive the type of function arguments at compile time. This removes the need for manual type casting and makes the code more resilient against small signature changes in the kernel. The arguments accessible by a `rawtracepoint` are different from the arguments you can access from the `tracepoint` of the same name. The function arguments are available in the `args` struct which can be inspected by doing verbose listing (see [Listing Probes](../man/adoc/bpftrace.adoc#listing-probes)). ### software **variants** * `software:event:` * `software:event:count` **short name** * `s` These are the pre-defined software events provided by the Linux kernel, as commonly traced via the perf utility. They are similar to tracepoints, but there is only about a dozen of these, and they are documented in the perf_event_open(2) man page. If the count is not provided, a default is used. The event names are: * `cpu-clock` or `cpu` * `task-clock` * `page-faults` or `faults` * `context-switches` or `cs` * `cpu-migrations` * `minor-faults` * `major-faults` * `alignment-faults` * `emulation-faults` * `dummy` * `bpf-output` ``` software:faults:100 { @[comm] = count(); } ``` This roughly counts who is causing page faults, by sampling the process name for every one in one hundred faults. ### tracepoint **variants** * `tracepoint:subsys:event` **short name** * `t` Tracepoints are hooks into events in the kernel. Tracepoints are defined in the kernel source and compiled into the kernel binary which makes them a form of static tracing. Unlike `kprobe` s, new tracepoints cannot be added without modifying the kernel. The advantage of tracepoints is that they generally provide a more stable interface than `kprobe` s do, they do not depend on the existence of a kernel function. ``` tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args.filename)); } ``` Tracepoint arguments are available in the `args` struct which can be inspected with verbose listing, see the [Listing Probes](../man/adoc/bpftrace.adoc#listing-probes) section for more details. ``` # bpftrace -lv "tracepoint:*" tracepoint:xhci-hcd:xhci_setup_device_slot u32 info u32 info2 u32 tt_info u32 state ... ``` Alternatively members for each tracepoint can be listed from their /format file in /sys. Apart from the filename member, we can also print flags, mode, and more. After the "common" members listed first, the members are specific to the tracepoint. **Additional information** * https://www.kernel.org/doc/html/latest/trace/tracepoints.html ### uprobe, uretprobe **variants** * `uprobe:binary:func` * `uprobe:binary:func+offset` * `uprobe:binary:offset` * `uprobe:binary@file:line[:col]` * `uretprobe:binary:func` **short names** * `u` * `ur` `uprobe` s or user-space probes are the user-space equivalent of `kprobe` s. The same limitations that apply [kprobe and kretprobe](#kprobe-and-kretprobe) also apply to `uprobe` s and `uretprobe` s, namely: arguments are available via the `argN` builtins and can only be accessed with a uprobe. retval is the return value for the instrumented function and can only be accessed with a uretprobe. **Note**: When tracing some languages, like C++, `arg0` and even `arg1` may refer to runtime internals such as the current object instance (`this`) and/or the eventual return value for large returned objects where copy elision is used. This will push the actual function arguments to possibly start at `arg1` or `arg2` - the only way to know is to experiment. ``` uprobe:/bin/bash:readline { printf("arg0: %d\n", arg0); } ``` What does arg0 of readline() in /bin/bash contain? I don’t know, so I’ll need to look at the bash source code to find out what its arguments are. When tracing libraries, it is sufficient to specify the library name instead of a full path. The path will be then automatically resolved using `/etc/ld.so.cache`: ``` uprobe:libc:malloc { printf("Allocated %d bytes\n", arg0); } ``` If multiple versions of the same shared library exist (e.g. `libssl.so.3` and `libssl.so.59`), bpftrace may resolve the wrong one. To fix this, you can specify a versioned SONAME to ensure the correct library is traced: ``` uprobe:libssl.so.3:SSL_write { ... } ``` If the traced binary has DWARF included, function arguments are available in the `args` struct which can be inspected with verbose listing, see the [Listing Probes](../man/adoc/bpftrace.adoc#listing-probes) section for more details. ``` # bpftrace -lv 'uprobe:/bin/bash:rl_set_prompt' uprobe:/bin/bash:rl_set_prompt const char* prompt ``` Using DWARF source code location info, bpftrace can also attach uprobes directly to source file statements, similar to setting a breakpoint at a `file:line[:col]` location in a debugger. This avoids manually locating instruction offsets in the ELF when probes are needed inside a function body. ``` uprobe:/bin/bash@readline.c:362 { ... } ``` `file` path may be absolute or relative, and `line:col` must refer to a valid statement in that file. Only statements originating from the specified file are considered; statements from included files are ignored. When tracing C++ programs, the `cpp` qualifier enables automatic symbol demangling, allowing you to specify function names in their human-readable form instead of the compiler-mangled form. For example, given this C++ code: ```cpp namespace MyApp { class Server { public: void handle_request(int fd) { ... } }; } ``` The compiler mangles the function name to `_ZN5MyApp6Server14handle_requestEi`. Instead of using that directly, use the `cpp` qualifier: ``` # using cpp qualifier with demangled name uprobe:/path/to/myapp:cpp:"MyApp::Server::handle_request" { print(ustack); } # wildcards also work with cpp qualifier uprobe:/path/to/myapp:cpp:"MyApp::Server::*" { print(ustack); } ``` Without the `cpp` qualifier you must use the mangled name directly. You can find it using `nm`: ``` $ nm /path/to/myapp | grep handle_request _ZN5MyApp6Server14handle_requestEi # use the mangled name directly in the probe uprobe:/path/to/myapp:"_ZN5MyApp6Server14handle_requestEi" { print(ustack); } ``` It is important to note that for `uretprobe` s to work the kernel runs a special helper on user-space function entry which overrides the return address on the stack. This can cause issues with languages that have their own runtime like Golang: **example.go** ``` func myprint(s string) { fmt.Printf("Input: %s\n", s) } func main() { ss := []string{"a", "b", "c"} for _, s := range ss { go myprint(s) } time.Sleep(1*time.Second) } ``` **bpftrace** ``` # bpftrace -e 'uretprobe:./test:main.myprint { @=count(); }' -c ./test runtime: unexpected return pc for main.myprint called from 0x7fffffffe000 stack: frame={sp:0xc00008cf60, fp:0xc00008cfd0} stack=[0xc00008c000,0xc00008d000) fatal error: unknown caller pc ``` Uprobe targets are expected to be valid ELF binaries. Unsafe mode (`--unsafe`) allows probing arbitrary files containing executable code. For shared libraries mapped directly from ZIP archives (common on Android), the archive and library name can be separated by `!/`: ``` uprobe:"/system/app/Foo/Foo.apk!/lib/arm64-v8a/libfoo.so":func { ... } ``` ### usdt **variants** * `usdt:binary_path:probe_name` * `usdt:binary_path:[probe_namespace]:probe_name` * `usdt:library_path:probe_name` * `usdt:library_path:[probe_namespace]:probe_name` **short name** * `U` Where probe_namespace is optional if probe_name is unique within the binary. You can target the entire host (or an entire process’s address space by using the `-p` arg) by using a single wildcard in place of the binary_path/library_path: ``` usdt:*:loop { printf("hi\n"); } ``` Please note that if you use wildcards for the probe_name or probe_namespace and end up targeting multiple USDTs for the same probe you might get errors if you also utilize the USDT argument builtin (e.g. arg0) as they could be of different types. Arguments are available via the `argN` builtins: ``` usdt:/root/tick:loop { printf("%s: %d\n", str(arg0), arg1); } ``` bpftrace also supports USDT semaphores. If both your environment and bpftrace support uprobe refcounts, then USDT semaphores are automatically activated for all processes upon probe attachment (and --usdt-file-activation becomes a noop). You can check if your system supports uprobe refcounts by running: ``` # bpftrace --info 2>&1 | grep "uprobe refcount" bcc bpf_attach_uprobe refcount: yes uprobe refcount (depends on Build:bcc bpf_attach_uprobe refcount): yes ``` If your system does not support uprobe refcounts, you may activate semaphores by passing in -p $PID or --usdt-file-activation. --usdt-file-activation looks through /proc to find processes that have your probe’s binary mapped with executable permissions into their address space and then tries to attach your probe. Note that file activation occurs only once (during attach time). In other words, if later during your tracing session a new process with your executable is spawned, your current tracing session will not activate the new process. Also note that --usdt-file-activation matches based on file path. This means that if bpftrace runs from the root host, things may not work as expected if there are processes execved from private mount namespaces or bind mounted directories. One workaround is to run bpftrace inside the appropriate namespaces (i.e. the container). ### watchpoint **variants** * `watchpoint:absolute_address:length:mode` **short names** * `w` This feature is experimental and may be subject to interface changes. Memory watchpoints are also architecture dependent. These are memory watchpoints provided by the kernel. Whenever a memory address is written to (`w`), read from (`r`), or executed (`x`), the kernel can generate an event. Once the watchpoint is attached, an absolute address is monitored. ``` # bpftrace -e 'watchpoint:0x10000000:8:rw { printf("hit!\n"); }' -c ./testprogs/watchpoint ``` Print the call stack every time the `jiffies` variable is updated: ``` watchpoint:0x$(awk '$3 == "jiffies" {print $1}' /proc/kallsyms):8:w { @[kstack] = count(); } ``` ## Types ### Type Syntax bpftrace uses a postfix type syntax for pointer and array modifiers. Modifiers are read left-to-right: the base type comes first, followed by any combination of `*` (pointer) and `[N]` (array) suffixes in any order. ``` int32* // pointer to int32 int32[4] // array of 4 int32 int32*[4] // array of 4 pointers to int32 int32[4]* // pointer to an array of 4 int32 int32*[4]* // pointer to an array of 4 pointers to int32 ``` This differs from C, where pointer and array declarators are written around the variable name and read inside-out. The table below shows equivalent types in both syntaxes: | C syntax | bpftrace syntax | Description | | --- | --- | --- | | `int *p` | `int32*` | pointer to int | | `int a[4]` | `int32[4]` | array of 4 ints | | `int *a[4]` | `int32*[4]` | array of 4 pointers to int | | `int (*p)[4]` | `int32[4]*` | pointer to array of 4 ints | | `struct foo *p` | `struct foo*` | pointer to struct foo | | `struct foo *a[4]` | `struct foo*[4]` | array of 4 pointers to struct foo | | `struct foo (*p)[4]` | `struct foo[4]*` | pointer to array of 4 struct foo | The same syntax applies to type annotations in variable declarations, casts, and type introspection functions (e.g. `sizeof`, `offsetof`, etc.) For the parameterized types `string`, `buffer`, and `inet`, a `[N]` suffix sets the type's size parameter rather than creating an array: ``` $s = (string[64])arg0; // string with capacity 64 bytes $b = (buffer[256])arg0; // buffer of 256 bytes ``` ### Type Context Builtins The following functions accept a type OR an expression, which is evaluated in order to get a type: - `sizeof` - `offsetof` - `typeof` - `typeinfo` (unstable) Examples: ``` print(sizeof(uint32)); // prints 4 as uint32 is parsed as a type print(sizeof({ $a = (int8)1; $a })); // prints 1 as the expression evaluates to $a whose type is int8 print(sizeof(uint32*[10])); // prints 80 as the type is an array of 10 pointers to uint32 ``` Note: any expression passed to these functions is removed before actual runtime e.g. in `print(sizeof({ $a = (int8)1; print("hi"); $a }));` the "hi" is never printed and maps and variables are not mutated. If passing a type to a macro call, you must wrap that type in a `typeof` e.g. `my_macro($a, typeof(struct task))`. ### Pointers Pointers in bpftrace are similar to those found in `C`. You can also get the pointer to a bpftrace scratch variable or map using the address-of operator (`&`), e.g. `$a = 1; $b = &$a;`. ### Structs `C` like structs are supported by bpftrace. Fields are accessed with the `.` operator. If the `.` is used on a pointer, it is automatically dereferenced. The legacy `->` operator may be used, but is purely an alias for the `.` operator. Custom structs can be defined at the top of the program. Constructing structs from scratch, like `struct X var = {.f1 = 1}` in `C`, is not supported. They can only be read into a variable from a pointer. ``` struct MyStruct { int a; } kprobe:dummy { $ptr = (struct MyStruct *) arg0; $st = *$ptr; print($st.a); print($ptr.a); } ``` ### Tuples bpftrace has support for immutable N-tuples. A tuple is a sequence type (like an array) where, unlike an array, every element can have a different type. Tuples are a comma separated list of expressions, enclosed in parenthesis, `(1,"hello")`. Individual fields can be accessed with the `.` operator or via array-style access. The array index expression must evaluate to an integer literal at compile time (no variables but this is ok `(1, "hello")[1 - 1]`). Tuples are zero indexed like arrays. Examples: ``` interval:s:1 { $a = (1,"hello"); $b = (3,4, $a); print($a); // (1, "hello") print($b); // (3, 4, (1, "hello")) print($b.0); // 3 print($a[1]); // "hello" } ``` Single-element and empty tuples can be specified using Python-like syntax. A single element tuple requires a trailing comma, `(1,)`, while the empty tuple is simply `()`. ### Records bpftrace has support for immutable N-records. A record is a struct-like type where every element has a name and a type. Records are a comma separated list of named expressions, enclosed in parenthesis, `(color="green", size=2)`. Individual fields can be accessed with the `.` operator and the field name. If records are assigned in a different order to the same variable, map key, or map value then the final ordering is ambiguous. Note that the evaluation order is maintained, e.g. `$a = (size={ print("first"); 20 }, color={ print("second"); "pink" });` will print "first" then "second" regardless of the ordering of the final type. Examples: ``` interval:s:1 { $a = (color="green", size=2); print($a); // { .color = "green", .size = 2 } print($a.size); // 2 $a = (size=10, color="blue"); print($a.color); // blue } ``` ### Type Conversion Integer and pointer types can be converted using explicit type conversion with an expression like: ``` $y = (uint32)$z; $py = (int16 *)$pz; ``` Integer casts to a higher rank are sign extended. Conversion to a lower rank is done by zeroing leading bits. It is also possible to cast between integers and integer arrays using the same syntax: ``` $a = (uint8[8])12345; $x = (uint64)$a; ``` Both the cast and the destination type must have the same size. When casting to an array, it is possible to omit the size which will be determined automatically from the size of the cast value. Integers are internally represented as 64 bit signed. If you need another representation, you may cast to the supported [Data Types](#data-types). #### Cast Parsing Most C-style casting is supported, however due to bpftrace's builtins, which are raw identifiers (e.g. `pid`), and macros which can be called without parenthesis if the macro doesn't have any arguments, a raw identifier wrapped in parenthesis is considered a type when followed by something that looks like an expression start. ``` $w = (myident); // parsed as an expression and not a type $x = (myident)*$a; // parsed as a cast to myident type with a dereference of $a $y = (pid)*tid; // parsed a multiplication of the pid builtin and the tid builtin $z = (myident)*arg0; // parsed as a cast to myident with a dereference of builtin arg0 ``` Bare identifiers in type contexts (casts, `sizeof`, `typeof`, etc.) are always treated as type names and are never expanded as macros. To force macro expansion in a type context, use the call syntax or wrap with `typeof`: ``` macro uint64_t() { 1 } $x = sizeof(uint64_t); // uint64_t is treated as a type name and $x evaluates to 8 $x = sizeof(uint64_t()); // call syntax forces macro expansion and $x evaluates to 1 $y = (typeof(uint64_t()))$z; // typeof wrapper for casts and this becomes $y = (typeof({ 1 }))$z; ``` Additionally, in a type context the array syntax is always treated as a type unless surrounded by parenthesis. ``` $x = sizeof(ident[1]); // parsed as an array of type ident with 1 element $x = sizeof((ident)[1]); // parsed as an expression accessing the first element of ident (useful in macro contexts) $x = sizeof((ident[1])); // parsed as an expression accessing the first element of ident (useful in macro contexts) ``` #### Array Casts It is possible to cast between integer arrays and integers. Both the source and the destination type must have the same size. The main purpose of this is to allow casts from/to byte arrays. ``` begin { $a = (int8[8])12345; printf("%x %x\n", $a[0], $a[1]); printf("%d\n", (uint64)$a); } /* * Output: * 39 30 * 12345 */ ``` When casting to an array, it is possible to omit the size which will be determined automatically from the size of the cast value. This feature is especially useful when working with IP addresses since various libraries, builtins, and parts of the kernel use different approaches to represent addresses (usually byte arrays vs. integers). Array casting allows seamless comparison of such representations: ``` fentry:tcp_connect { if (args.sk.__sk_common.skc_daddr == (uint32)pton("127.0.0.1")) ... } ``` ##### Endianness and Memory Layout When casting an integer to an array, bpftrace initializes the array from the source integer's underlying representation. No byte swapping is performed, so the result depends on the source integer type, the target array element type, and the system's native byte order (endianness) For example, when casting `(uint16)1` to `bool[2]`, each `bool` element is initialized from one byte of the `uint16` representation: ``` // On little-endian systems: begin { @a = (bool[2])(uint16)1; } // Output: @a: [true, false] // Explanation: uint16 value 1 = 0x0001 is represented as: // [0x01, 0x00] // array[0] is initialized from 0x01 (true) // array[1] is initialized from 0x00 (false) // On big-endian systems: begin { @a = (bool[2])(uint16)1; } // Output: @a: [false, true] // Explanation: uint16 value 1 = 0x0001 is represented as: // [0x00, 0x01] // array[0] is initialized from 0x00 (false) // array[1] is initialized from 0x01 (true) ``` The source integer type also affects the representation used for the array initialization. If the value is explicitly cast to a wider integer type first, then the array is initialized from that wider representation. For example, `(uint64)12345` is `0x0000000000003039`, so casting it to `int8[8]` uses the full 8-byte representation: ``` // On little-endian systems: begin { printf("first byte: %x\n", ((int8[8])(uint64)12345)[0]); } // Output: first byte: 39 // Explanation: (uint64)12345 = 0x0000000000003039 is represented as: // [0x39, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] // array[0] is initialized from 0x39. // On big-endian systems: begin { printf("first byte: %x\n", ((int8[8])(uint64)12345)[0]); } // Output: first byte: 0 // Explanation: (uint64)12345 = 0x0000000000003039 is represented as: // [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x39] // array[0] is initialized from 0x00. ``` ## Variables and Maps bpftrace knows two types of variables, 'scratch' and 'map'. 'scratch' variables are kept on the BPF stack and their names always start with a `$`, e.g. `$myvar`. 'scratch' variables cannot be accessed outside of their lexical block e.g. ``` $a = 1; if ($a == 1) { $b = "hello" $a = 2; } ``` 'scratch' variables can also declared before or during initialization with `let` e.g. ``` let $a = 1; let $b; if ($a == 1) { $b = "hello" $a = 2; } ``` If no assignment is specified variables will initialize to 0. 'map' variables use BPF 'maps'. These exist for the lifetime of `bpftrace` itself and can be accessed from all action blocks and user-space. Map names always start with a `@`, e.g. `@mymap`. All valid identifiers can be used as `name`. The data type of a variable is automatically determined during first assignment and cannot be changed afterwards. ### Map Declarations ***Warning*** this feature is experimental and may be subject to changes. Stabilization is tracked in [#4077](https://github.com/bpftrace/bpftrace/issues/4077). Maps can also be declared in the global scope, before probes and after the config e.g. ``` let @a = hash(100); let @b = percpulruhash(20); begin { ... } ``` The utility of this is that you can specify different underlying BPF map types. Currently these are available in bpftrace: - hash (BPF_MAP_TYPE_HASH) - lruhash (BPF_MAP_TYPE_LRU_HASH) - percpuhash (BPF_MAP_TYPE_PERCPU_HASH) - percpulruhash (BPF_MAP_TYPE_LRU_PERCPU_HASH) Additionally, map declarations must supply a single argument: ***max entries*** e.g. `let @a = lruhash(100);` All maps that are not declared in the global scope utilize the default set in the config variable "max_map_keys". However, it’s best practice to declare maps up front as using the default can lead to lost map update events (if the map is full) or over allocation of memory if the map is intended to only store a few entries. ***Warning*** The "lru" variants of hash and percpuhash evict the approximately least recently used elements. In other words, users should not rely on the accuracy on the part of the eviction algorithm. Adding a single new element may cause one or multiple elements to be deleted if the map is at capacity. [Read more about LRU internals](https://docs.ebpf.io/linux/map-type/BPF_MAP_TYPE_LRU_HASH/). ### Maps without Explicit Keys Values can be assigned directly to maps without a key (sometimes refered to as scalar maps). Note: you can’t iterate over these maps as they don’t have an accessible key. ``` @name = expression ``` ### Map Keys Setting single value map keys. ``` @name[key] = expression ``` Map keys that are composed of multiple values are represented as tuples e.g. ``` @name[(key1,key2)] = expression ``` However, this, more concise, syntax is supported and the same as the explicit tuple above: ``` @name[key1,key2] = expression ``` Just like with any variable the type is determined on first use and cannot be modified afterwards. This applies to both the key(s) and the value type. The following snippets create a map with key signature `(int64, string)` and a value type of `int64`: ``` @[pid, comm]++ @[(pid, comm)]++ ``` ### Per-Thread Variables These can be implemented as a map keyed on the thread ID. For example, `@start[tid]`: ``` kprobe:do_nanosleep { @start[tid] = nsecs; } kretprobe:do_nanosleep /has_key(@start, tid)/ { printf("slept for %d ms\n", (nsecs - @start[tid]) / 1000000); delete(@start, tid); } /* * Sample output: * slept for 1000 ms * slept for 1009 ms * slept for 2002 ms * ... */ ``` This style of map may also be useful for capturing output parameters, or other context, between two different probes. For example: ``` tracepoint:syscalls:sys_enter_wait4 { @out[tid] = args.ru; } tracepoint:syscalls:sys_exit_wait4 { $ru = @out[tid]; delete(@out, tid); if ($ru != 0) { printf("got usage ...", ...); } } ``` --- ## Advanced Topics ### Address Spaces Kernel and user pointers live in different address spaces which, depending on the CPU architecture, might overlap. Trying to read a pointer that is in the wrong address space results in a runtime error. This error is hidden by default but can be enabled with the `-k` flag: ``` stdin:1:9-12: WARNING: Failed to probe_read_user: Bad address (-14) begin { @=*uptr(kaddr("do_poweroff")) } ~~~ ``` bpftrace tries to automatically set the correct address space for a pointer based on the probe type, but might fail in cases where it is unclear. The address space can be changed with the [kptrs](stdlib.md#kptr) and [uptr](stdlib.md#uptr) functions. ### BPF License By default bpftrace uses "GPL", which is actually "GPL version 2", as the license it uses to load BPF programs into the kernel. Some other examples of compatible licenses are: "GPL v2" and "Dual MPL/GPL". You can specify a different license using the "license" config variable. [Read more about BPF programs and licensing](https://docs.kernel.org/bpf/bpf_licensing.html#using-bpf-programs-in-the-linux-kernel). ### BTF Support If the kernel version has BTF support, kernel types are automatically available and there is no need to include additional headers to use them. It is not recommended to mix definitions from multiple sources (ie. BTF and header files). If your program mixes definitions, bpftrace will do its best but can easily get confused due to redefinition conflicts. Prefer to exclusively use BTF as it can never get out of sync on a running system. BTF is also less susceptible to parsing failures (C is constantly evolving). Almost all current linux deployments will support BTF. To allow users to detect this situation in scripts, the preprocessor macro `BPFTRACE_HAVE_BTF` is defined if BTF is detected. See `tools/` for examples of its usage. Requirements for using BTF for vmlinux: * Linux 4.18+ with CONFIG_DEBUG_INFO_BTF=y * Building requires dwarves with pahole v1.13+ * bpftrace v0.9.3+ with BTF support (built with libbpf v0.0.4+) Additional requirements for using BTF for kernel modules: * Linux 5.11+ with CONFIG_DEBUG_INFO_BTF_MODULES=y * Building requires dwarves with pahole v1.19+ See kernel documentation for more information on BTF. ### Clang Environment Variables bpftrace parses header files using libclang, the C interface to Clang. Thus environment variables affecting the clang toolchain can be used. For example, if header files are included from a non-default directory, the `CPATH` or `C_INCLUDE_PATH` environment variables can be set to allow clang to locate the files. See clang documentation for more information on these environment variables and their usage. ### Complex Tools bpftrace can be used to create some powerful one-liners and some simple tools. For complex tools, which may involve command line options, positional parameters, argument processing, and customized output, consider switching to bcc. bcc provides Python (and other) front-ends, enabling usage of all the other Python libraries (including argparse), as well as a direct control of the kernel BPF program. The down side is that bcc is much more verbose and laborious to program. Together, bpftrace and bcc are complimentary. An expected development path would be exploration with bpftrace one-liners, then and ad hoc scripting with bpftrace, then finally, when needed, advanced tooling with bcc. As an example of bpftrace vs bcc differences, the bpftrace xfsdist.bt tool also exists in bcc as xfsdist.py. Both measure the same functions and produce the same summary of information. However, the bcc version supports various arguments: ``` # ./xfsdist.py -h usage: xfsdist.py [-h] [-T] [-m] [-p PID] [interval] [count] Summarize XFS operation latency positional arguments: interval output interval, in seconds count number of outputs optional arguments: -h, --help show this help message and exit -T, --notimestamp don't include timestamp on interval output -m, --milliseconds output in milliseconds -p PID, --pid PID trace this PID only examples: ./xfsdist # show operation latency as a histogram ./xfsdist -p 181 # trace PID 181 only ./xfsdist 1 10 # print 1 second summaries, 10 times ./xfsdist -m 5 # 5s summaries, milliseconds ``` The bcc version is 131 lines of code. The bpftrace version is 22. ### Errors 1. Looks like the BPF stack limit of 512 bytes is exceeded BPF programs that operate on many data items may hit this limit. There are a number of things you can try to stay within the limit: 1. Find ways to reduce the size of the data used in the program. Eg, avoid strings if they are unnecessary: use pid instead of comm. Use fewer map keys. 2. Split your program over multiple probes. 3. Check the status of the BPF stack limit in Linux (it may be increased in the future, maybe as a tuneable). 4. (advanced): Run -d and examine the LLVM IR, and look for ways to optimize src/ast/codegen_llvm.cpp. 2. Kernel headers not found bpftrace requires kernel headers for certain features, which are searched for by default in: `/lib/modules/$(uname -r)`. The default search directory can be overridden using the environment variable BPFTRACE_KERNEL_SOURCE and also BPFTRACE_KERNEL_BUILD if it is out-of-tree Linux kernel build. ### Map Printing By default when a bpftrace program exits it will print all maps to stdout. If you don’t want this, you can either override the `print_maps_on_exit` configuration option or you can specify an `end` probe and `clear` the maps you don’t want printed. For example, these two scripts are equivalent and will print nothing on exit: ``` config = { print_maps_on_exit=0 } begin { @a = 1; @b[1] = 1; } ``` ``` begin { @a = 1; @b[1] = 1; } end { clear(@a); clear(@b); } ``` ### PERCPU types For bpftrace PERCPU map types (e.g., those created by using [`count()`](stdlib.md#count) or [`sum()`](stdlib.md#sum)) you may coerce (and thus force a more expensive synchronous read) the type to an integer using a cast or by doing a comparison. This is useful for when you need an integer during comparisons, `printf()`, or other. For example: ``` begin { @c = count(); @s = sum(3); @s = sum(9); if (@s == 12) { // Coerces @s printf("%d %d\n", (int64)@c, (int64)@s); // Coerces @c and @s and prints "1 12" } } ``` ### Supported architectures x86_64, arm64, s390x, arm32, loongarch64, mips64, ppc64, riscv64 ### Systemd support If bpftrace has been built with `-DENABLE_SYSTEMD=1`, one can run bpftrace in the background using systemd:: ``` # systemd-run --unit=bpftrace --service-type=notify bpftrace -e 'kprobe:do_nanosleep { printf("%d sleeping\n", pid); }' ``` In the above example, systemd-run will not finish until bpftrace has attached its probes, so you can be sure that all following commands will be traced. To stop tracing, run `systemctl stop bpftrace`. To debug early boot issues, bpftrace can be invoked via a systemd service ordered before the service that needs to be traced. A basic unit file to run bpftrace before another service looks as follows:: ``` [Unit] Before=service-i-want-to-trace.service [Service] Type=notify ExecStart=bpftrace -e 'kprobe:do_nanosleep { printf("%d sleeping\n", pid); }' ``` Similarly to the systemd-run example, the service to be traced will not start until bpftrace started by the systemd unit has attached its probes. ### Unstable Features Some features added to bpftrace are not yet stable. They are enabled by default but come with a warning if used. If you explicitly add the config variable to your script the warning will not be shown e.g. ``` config = { unstable_map_decl=enable; } ``` To opt-out of these unstable features (and ensure they are not used) add the config variable and set it to `error` e.g. ``` config = { unstable_map_decl=error; } ``` Note: all unstable features are subject to change and/or removal. bpftrace-0.27.1/docs/language_parsing.md000066400000000000000000000210541526721631600201620ustar00rootroot00000000000000# Language Lexing and Parsing This describes the technical design and implementation of bpftrace's recursive descent parser (`src/parser`). ## Overview The `Parser` class is a single-pass recursive descent parser that transforms bpftrace source text into an AST. There is no separate lexer/tokenizer phase. Key design properties: - **No separate lexer**: tokenization is done inline via helper methods (`consume_identifier`, `consume_string`, `match`, `expect`, etc.). - **Single-pass**: the parser walks the input left-to-right once, building AST nodes as it goes. - **Backtracking via SavePoint**: ambiguous constructs (casts vs. grouping, records vs. expressions, trailing expressions) use `SavePoint` to speculatively try one parse and rewind if it fails. - **Precedence climbing** for binary expressions. - **All AST nodes are allocated through `ASTContext`** (`ctx_.make_node(...)`), which owns their memory. ## Entry Points ``` Parser::parse() -> ast::Program* // Full program parse Parser::parse_expr() -> optional // Single expression (used by CMacroExpander) ``` ## Grammar Structure The parser is organized into four layers of grammar rules, roughly ordered from outermost to innermost. ### 1. Program-level grammar (`parse_program`) Parses the full top-level structure of a bpftrace script. It enforces a strict ordering of sections: ``` Header = "#!" ... "\n" (shebang line) Preamble = Config | RootImport CDefinitions = CPreprocessor | CDefinition MainItems = Probe | Macro | Subprog | MapDeclStmt ``` **Constructs at this level:** | Method | Parses | |-------------------------|-------------------------------------------| | `parse_c_preprocessor` | `#include`, `#define`, etc. (line-based) | | `parse_c_definition` | `struct/union/enum Name { ... }` | | `parse_config` | `config = { key = value; ... }` | | `parse_root_import` | `import "path";` | | `parse_macro` | `macro name(args) { ... }` | | `parse_subprog` | `fn name($a: type, ...) : ret_type { ... }` | | `parse_map_decl_stmt` | `let @name = type(N);` | | `parse_probe` | `attach_points /predicate/ { ... }` | ### 2. Block and statement grammar **`parse_block`** parses a `{ ... }` block. It supports an optional trailing expression (no semi-colon). Inside a block, the parser dispatches on keywords and sigil characters: | Input starts with | Dispatches to | |-------------------|-----------------------------------| | `import` | `parse_statement_import` | | `while`, `unroll` | `parse_while_or_unroll` | | `for` | `parse_for` | | `break`, `continue`, `return` | Control flow | | `_ =` | Discard expression (`DiscardExpr`) | | `let` | `parse_statement` (variable declaration) | | `$` or `@` | `parse_sigiled_stmt_or_trailing_expr` | | anything else | Parse as expression, then check for `;` or `}` | **`parse_statement`** handles: - `let $x`, `let $x = expr`, `let $x : type = expr` — variable declarations - `$x = expr`, `$x += expr`, `$x++` — variable assignments/mutations - `@m = expr`, `@m[k] = expr` — map assignments - Fall-through to expression statements **`make_assignment_or_expr`** is the core disambiguation function for statements that begin with `$var` or `@map`. It tries, in order: 1. Simple assignment (`=`) 2. Compound assignment (`+=`, `-=`, `<<=`, etc. via `try_compound_op`) 3. Post-increment/decrement (`++`/`--`) 4. Otherwise, parse remaining postfix/binary operators and treat as an expression statement **`parse_sigiled_stmt_or_trailing_expr`** handles the ambiguity when a `$` or `@` expression appears at the end of a block. It speculatively parses as a statement; if the result is an `ExprStatement` and the next token is `}`, it backtracks and re-parses as a trailing expression. ### 3. Expression grammar Expression parsing follows standard recursive descent with precedence climbing for binary operators. ``` Expression = Ternary Ternary = Binary ("?" Ternary ":" Ternary)? | Binary ("?" ":" Ternary)? // short form: expr ?: default Binary = Unary (BinOp Unary)* // precedence climbing Unary = "++" Unary | "--" Unary | "&" Unary | "*" Unary | "-" Unary | "!" Unary | "~" Unary | Postfix Postfix = Primary ("." field | "->" field | "[" expr "]" | "++" | "--")* Primary = "(" ParenExpr ")" | "if" ... | "sizeof" ... | "offsetof" ... | "typeinfo" ... | "comptime" Unary | "{" Block "}" | Call | Builtin | Identifier | "@" MapWithKeys | "$" Variable | Integer | String | "true" | "false" ``` #### Precedence climbing (`parse_binary`) Binary operator precedence is handled by the `get_binop` function, which returns an `{operator, precedence}` pair. `parse_binary(min_prec)` consumes operators at or above `min_prec`, recursing with `prec + 1` for the right operand (left-to-right associativity). Precedence levels (low to high): | Prec | Operators | |------|--------------------| | 1 | `\|\|` | | 2 | `&&` | | 3 | `\|` (bitwise) | | 4 | `^` | | 5 | `&` (bitwise) | | 6 | `==`, `!=` | | 7 | `<`, `>`, `<=`, `>=` | | 8 | `<<`, `>>` | | 9 | `+`, `-` | | 10 | `*`, `/`, `%` | Compound assignment operators (`+=`, etc.) are explicitly excluded from `get_binop`. #### Parenthesized expressions (`parse_paren_expr`) A `(` can introduce four different constructs. `parse_paren_expr` disambiguates them in order: 1. **Empty tuple**: `()` 2. **Record literal**: `(name=expr, ...)` 3. **Cast expression**: `(type)expr` — lookahead sees a type name followed by `)`, then an expression-starting character 4. **Tuple or grouping**: `(expr, ...)` or `(expr)` — comma means tuple, no comma means grouping Records and casts use `try_parse_record` / `try_parse_cast_expr`. ### 4. Type parsing `try_parse_type_reference` handles type syntax: `int32`, `string[64]`, `struct foo *`, `void`, `bare_ident`, etc. It supports arrays (`type[N]`), pointers (`type *`), and composite type keywords (`struct`, `union`, `enum`). `parse_type_annotation` parses type annotations in `let` declarations and function signatures. It accepts either a type name directly or `typeof(...)`. ## Comment and whitespace handling `consume_layout()` handles `//` line comments, `/* */` block comments, and records both comments and vertical whitespace (blank lines) in the `ASTContext` via `ctx_.add_comment(loc)` and `ctx_.add_vspace(loc, count)`. This information is used by the formatter (`bpftrace --fmt`) to preserve comment placement and blank-line structure. Vertical space is suppressed after `{`, `}`, and `;` to avoid double-spacing. ## Backtracking with SavePoint `SavePoint` captures `(pos_, line_, col_)` and can `restore()` them. This is used in several places to lookahead and restore the current state if there is no match. ## Error Handling and Recovery Errors are reported via `ctx_.state_->diagnostics_->addError(...)`. Parsing stops early when `has_errors()` returns true (checked in loops). Several methods include error recovery, e.g. `skip_to_block_end()`. ## Debug Tracing This requires both the `-d parse` command line option and a Debug build of bpftrace. When active, the `PARSE_TRACE` macro logs which grammar rules are entered and what token is being examined, producing output like: ``` [parse] 1:1 parse_program [parse] 1:1 parse_probe [parse] 1:1 parse_attach_point [parse] 1:9 parse_block [parse] 1:11 parse_expression [parse] 1:11 parse_primary, next='$' ``` Note: The debug flag is always disabled when parsing standard library `.bt` files in `resolve_imports.cpp`. ## Adding a New Syntactic Construct 1. **Define AST node(s)** in `src/ast/ast.h`. 2. **Add a `parse_*` method** to `Parser` (declare in the header, define in the `.cpp`). 3. **Wire it into the appropriate dispatch point**: - Program-level: add a keyword check in `parse_program`'s main loop. - Statement-level: add to `parse_block`'s keyword dispatch or `parse_statement`. - Expression-level: add to `parse_primary` or as a new precedence level in `parse_binary`. 4. **Handle ambiguity**: if your construct's syntax overlaps with existing constructs, use `SavePoint` for backtracking or add a `looks_like_*` lookahead helper. 5. **Add tests**: parser tests live in `tests/parser.cpp`. bpftrace-0.27.1/docs/migration_guide.md000066400000000000000000000126411526721631600200240ustar00rootroot00000000000000# Breaking changes (migration guide) This document lists changes introduced in bpftrace which break backwards compatibility in some way. Each entry should contain: - a link to the PR introducing the change - a brief description of the change - an example of an error message - a simple guide to fix existing scripts ## Versions 0.24.x (or earlier) to 0.25.x (or later) ### `args` in tracepoints now requires BTF After https://github.com/bpftrace/bpftrace/pull/4864, using the `args` builtin in tracepoint requires BTF for parsing the tracepoint argument types. For systems which do not provide BTF, it is possible to pass a custom BTF file via the `BPFTRACE_BTF` environment variable. ## Versions 0.23.x (or earlier) to 0.24.x (or later) ### Probe Attachment Failure Exits the Program Previously, if a probe with multiple attach points or a wildcard failed to attach, a warning would be printed and the program would continue to run. Now, if there are any attachment failures, the program will exit with an error. If it's expected that some probes will fail to attach, you can use the config variable 'missing_probes' to either `warn` or `ignore` these failures e.g. ``` config = { missing_probes = "warn" } ``` ## Versions 0.22.x (or earlier) to 0.24.x (or later) After https://github.com/bpftrace/bpftrace/pull/3428 `pid` and `tid` are no longer from the initial namespace. https://github.com/bpftrace/bpftrace/pull/3428 introduced `pid(init)` and `tid(init)` which have the old behavior. Unfortunately, there are no equivalent workarounds in 0.23.x. ## Versions 0.21.x (or earlier) to 0.22.x (or later) ### Added block scoping for scratch variables https://github.com/bpftrace/bpftrace/pull/3367 Previously, scratch variables were "probe" scoped meaning the following was valid syntax: ``` BEGIN { if (0) { $x = "hello"; } print(($x)); } // prints an empty line ``` However, the value of `$x` at the print statement was considered undefined behavior. Issue: https://github.com/bpftrace/bpftrace/issues/3017 Now variables are "block" scoped and the the above will throw an error at the print statement: "ERROR: Undefined or undeclared variable: $x". If you see this error you can do multiple things to resolve it. **Option 1: Initialize variable before use** ``` BEGIN { $x = ""; if (0) { $x = "hello"; } print(($x)); } ``` **Option 2: Declare variable before use** ``` BEGIN { let $x; // let $x = ""; is also valid if (0) { $x = "hello"; } print(($x)); } ``` Declaring is useful for variables that hold internal bpftrace types e.g. the type returned by the `macaddr` function. This is also not valid even though `$x` is set in both branches (`$x` still needs to exist in the outer scope): ``` BEGIN { if (0) { $x = "hello"; } else { $x = "bye"; } print(($x)); } ``` Additionally, scratch variable shadowing is not allowed e.g. this is not valid: ``` BEGIN { let $x; if (0) { let $x = "hello"; // shadows $x in the parent scope } } ``` ### multi-key `delete` removed https://github.com/bpftrace/bpftrace/pull/3506 This map `delete` syntax is no longer valid: ``` delete(@b[1], @b[2], @b[3]); ``` And will yield this error: ``` # bpftrace -e 'BEGIN { @b[1] = 1; delete(@b[1], @b[2], @b[3]); }' stdin:1:20-47: ERROR: delete() takes up to 2 arguments (3 provided) BEGIN { @b[1] = 1; delete(@b[1], @b[2], @b[3]); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` You might also see this error: ``` # bpftrace -e 'BEGIN { @b[1] = 1; delete(@b[1], @b[2]); }' stdin:1:20-32: ERROR: delete() expects a map with no keys for the first argument BEGIN { @b[1] = 1; delete(@b[1], @b[2]); } ~~~~~~~~~~~~ ``` `delete` now expects only two arguments: a map and a key. For example, the above delete statement should be rewritten as this: ``` delete(@b, 1); delete(@b, 2); delete(@b, 3); ``` And for maps with multiple values as keys, which are represented as a tuple, the delete call looks like this: ``` @c[1, "hello"] = 1; delete(@c, (1, "hello")); ``` ### `pid` and `tid` builtins return `uint32` https://github.com/bpftrace/bpftrace/pull/3441 Previously, `pid` and `tid` builtins returned `uint64` so it is now possible to get an error when storing the builtin in a variable and overriding it with `uint64` later: ``` # bpftrace -e 'BEGIN { $x = pid; $x = cgroup; }' # cgroup is uint64 stdin:1:19-30: ERROR: Integer size mismatch. Assignment type 'uint64' is larger than the variable type 'uint32'. BEGIN { $x = pid; $x = cgroup; } ~~~~~~~~~~~ ``` To mitigate such an error, just typecast `pid` or `tid` to `uint64`: ``` # bpftrace -e 'BEGIN { $x = (uint64)pid; $x = cgroup; }' Attached 1 probe ``` ### default `SIGUSR1` handler removed https://github.com/bpftrace/bpftrace/pull/3522 Previously, if the bpftrace process received a `SIGUSR1` signal, it would print all maps to stdout: ``` # bpftrace -e 'BEGIN { @b[1] = 2; }' & kill -s USR1 $(pidof bpftrace) ... @b[1]: 2 ``` This behavior is no longer supported and has been replaced with the ability to define custom handling probes: ``` # bpftrace -e 'self:signal:SIGUSR1 { print("hello"); }' & kill -s USR1 $(pidof bpftrace) ... hello ``` To retain the previous functionality of printing maps, you need to manually include the print statements in your signal handler probe: ``` # bpftrace -e 'BEGIN { @b[1] = 2; } self:signal:SIGUSR1 { print(@b); }' & kill -s USR1 $(pidof bpftrace) ``` bpftrace-0.27.1/docs/nix.md000066400000000000000000000102161526721631600154500ustar00rootroot00000000000000# Building and testing with Nix Nix flakes are, in theory, guaranteed to be 100% reproducible on (nearly) any system. It does this by fully managing every dependency. This also means that you as a developer do not need to install _any_ build / runtime packages to build bpftrace with Nix. Rather than explain how Nix works (which is difficult to impossible in this kind of document), the rest of this guide will be a series of examples. Learning Nix flakes and the Nix language will be an exercise left to the reader. ## Examples These examples all assume you've already installed the `nix` CLI tool. If not, see: https://nixos.org/download.html. Also note again that we require _no dependencies_ to be installed other than `nix` itself. ### Enable flake support Nix flakes are technically an experimental feature but it's widely used and understood that the interface is unlikely to change. To enable flakes, run: ``` $ mkdir -p ~/.config/nix $ echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf ``` ### Build bpftrace When invoking `nix build`, flakes reconstruct the source tree from Git metadata but skip submodules, so append `.?submodules=1` (as below) to ensure libbpf is present. ``` $ nix build .?submodules=1# $ sudo ./result/bin/bpftrace -e 'BEGIN { print("hello world!") }' Attached 1 probe hello world! ^C ``` ### Build bpftrace with a different LLVM version ``` $ nix build .?submodules=1#bpftrace-llvm13 $ sudo ./result/bin/bpftrace --info 2>&1 | grep LLVM LLVM: 13.0.1 ``` ### Build bpftrace as a statically linked binary ``` $ nix build .?submodules=1#appimage $ ldd ./result not a dynamic executable $ sudo ./result -e 'BEGIN { print("static!"); exit() }' Attached 1 probe static! ``` ### Don't use Nix to build, but rather only manage dependencies ``` $ nix develop [dxu@kashmir bpftrace]$ cmake -B build-nix -GNinja [...] [dxu@kashmir bpftrace]$ ninja -C build-nix [...] [dxu@kashmir bpftrace]$ exit $ sudo ./build-nix/src/bpftrace --version bpftrace v0.17.0-75-g68ea-dirty ``` `nix develop` opens a developer shell. We've configured the bpftrace flake to be nearly the exact same as the default build environment except with a few more tools available. ### Build bpftrace with a different LLVM in developer shell ``` $ nix develop .#bpftrace-llvm18 dxu@kashmir bpftrace]$ cmake -B build-nix -GNinja [...] -- Found LLVM 18.1.7: /nix/store/50fcd75v40wca7vdk9bypgcvv6xhkfhx-llvm-18.1.7-dev/lib/cmake/llvm [...] ``` ### Run test suite inside developer shell ``` $ nix develop [dxu@kashmir bpftrace]$ cd build-nix; sudo ctest -V [...] ``` ### Setup an environment for fuzzing ``` $ nix develop .#bpftrace-fuzz dxu@kashmir bpftrace]$ CC=afl-clang-fast CXX=afl-clang-fast++ cmake -B build-fuzz -DCMAKE_BUILD_TYPE=Debug -DBUILD_ASAN=1 [...] ``` ## Internal examples This section has a few examples on how to interact with the Nix configuration. ### Update flake inputs Flakes have external inputs in the `inputs = { ... }` section of `flake.nix`. To update a single input: ``` $ nix flake lock --update-input blazesym warning: updating lock file '/home/dxu/dev/bpftrace/flake.lock': • Updated input 'blazesym': 'github:libbpf/blazesym/6beb39ebc8e3a604c7b483951c85c831c1bbe0d1' (2025-02-14) → 'github:libbpf/blazesym/285b17f15a12885544b21f1ae352928910656767' (2025-03-04) ``` To update a single input to a specific revision: ``` $ nix flake lock --override-input blazesym github:libbpf/blazesym/6beb39ebc8e3a604c7b483951c85c831c1bbe0d1 warning: updating lock file '/home/dxu/dev/bpftrace/flake.lock': • Updated input 'blazesym': 'github:libbpf/blazesym/285b17f15a12885544b21f1ae352928910656767' (2025-03-04) → 'github:libbpf/blazesym/6beb39ebc8e3a604c7b483951c85c831c1bbe0d1' (2025-02-14) ``` To update all inputs: ``` $ nix flake update warning: updating lock file '/home/dxu/dev/bpftrace/flake.lock': • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/d9b69c3ec2a2e2e971c534065bdd53374bd68b97' (2025-02-24) → 'github:NixOS/nixpkgs/02032da4af073d0f6110540c8677f16d4be0117f' (2025-03-03) ``` ### Format `*.nix` files ``` $ nix fmt 0 / 1 have been reformatted ``` ### Check `*.nix` files for errors ``` $ nix flake check ``` bpftrace-0.27.1/docs/reference_guide.md000066400000000000000000000002151526721631600177630ustar00rootroot00000000000000# bpftrace Reference Guide - [The bpftrace Language](language.md) - [Standard Library](stdlib.md) - [CLI Manual](../man/adoc/bpftrace.adoc) bpftrace-0.27.1/docs/release_process.md000066400000000000000000000161031526721631600200310ustar00rootroot00000000000000# Release Process This document describes the bpftrace release process. ## Semantic versioning We choose to follow semantic versioning. Note that this doesn't matter much for major version < 1 but will matter a lot for >= 1.0.0 releases. See https://semver.org/. ## Release cadence bpftrace is released twice a year. Since our biggest dependency, which also tends to break things, is LLVM, we align with the [LLVM release schedule](https://llvm.org/docs/HowToReleaseLLVM.html). In particular, a minor bpftrace release should happen **two weeks after a major LLVM release**. If patch releases are necessary, there should be at least one week between two successive releases to improve predictability for consumers of bpftrace releases and reduce work for bpftrace packagers. In addition, four weeks before the bpftrace release, we create a stabilized release branch, which will only receive bug fixes affecting the release itself. The branch will also serve as a target for future (post-release) bug fixes that should get into that minor release (by creating a new "patch" release). Overview of the release cadence is as follows: | Task | Approximate date | Details | | ---------------------- | ------------------------------------------------ | -------------------------------------------------------------------- | | release branch created | **2 weeks before the LLVM release** | [Creating a release branch](#creating-a-release-branch) | | LLVM release | usually second Tuesday of Mar/Sep | [LLVM release schedule](https://llvm.org/docs/HowToReleaseLLVM.html) | | bpftrace release | **2 weeks after the LLVM release** | [Tagging a release](#tagging-a-release) | | patch releases | weekly cadence after the release as necessary | [Tagging a release](#tagging-a-release) | ## Preparing for a release Once the release dates are clarified (approximately 6 weeks before the release), do the following steps to track the release in a public manner: 1. Update the release dates at the top of this document. 1. Create a new tracker issue in GitHub from the "Release tracker" template. ## Creating a release branch A release branch should be created four weeks before the planned bpftrace release. From that moment, only relevant bug fixes should be backported to the branch. The purpose of this release branch is to give sufficient time to test features in the upcoming bpftrace release without blocking the development on the master branch. When creating a branch for a release **v0.Y.0**, the following steps should be performed: 1. Mark the release in [CHANGELOG.md](../CHANGELOG.md) by replacing the `## Unreleased` header with `## [0.Y.0] TBD` and creating a new "Unreleased" section with all the subsection headers below it. 1. Update `bpftrace_VERSION_MINOR` in [CMakeLists.txt](../CMakeLists.txt) to `Y`. 1. Tag the latest commit in the master branch with `v0.Y-rc0`. 1. Create a new branch according to the [Branching model](#branching-model). 1. Update Nixpkgs to the latest version to get the latest (pre-release) LLVM by running ``` nix flake update nixpkgs ``` and committing the `flake.lock` changes to the repo. At this time, the `-rc2` or `-rc3` version of LLVM should be available. 1. Bump the supported LLVM version in [CMakeLists.txt](../CMakeLists.txt) and [flake.nix](../flake.nix), resolve any potential issues, and add a CI job to [.github/workflows/ci.yml](../.github/workflows/ci.yml) for the new version. 1. Bump the min LLVM major version (see: `MIN_LLVM_MAJOR`) and drop support for this in [.github/workflows/ci.yml](../.github/workflows/ci.yml). Also check if there are compile time `#if`s for LLVM majors that can be dropped ([example](https://github.com/bpftrace/bpftrace/pull/5067)). 1. Once the final LLVM is released and present in Nixpkgs (usually 2-5 days after the LLVM release), repeat step 4 to get the released LLVM in the CI environment. ### Branching model There should be one release branch per "major release" (we are currently pre-1.0, "major" refers to semver minor version). The name should follow the format `release/..x`. Example branch names: * release/0.21.x * release/1.0.x * release/1.1.x ### Backporting commits to release branches Any change relevant for both the master and the release branch (such as Nixpkgs or LLVM update) should be done in the master branch first and backported to the release branch afterwards. In the rare case when the master-first approach is not possible (e.g. a feature present exclusively on master blocks the LLVM update), the changes can be done in the release branch first and forward-ported to master afterwards. For backporting changes from one branch to another, use ``` git cherry-pick -s -x ``` and do not squash the commits when merging the PR. This will retain a clear connection between the original and the backported commit. ## Tagging a release You must do the following steps to formally release a version. In the release branch: 1. Mark the release in [CHANGELOG.md](../CHANGELOG.md) by replacing `TBD` with the current date in the corresponding header. 1. Tag a release. We do this in the github UI by clicking "releases" (on same line as "commits"), then "Draft a new release". The tag version and release title should be the same and in `vX.Y.Z` format. The tag description should be the same as what was added in the CHANGELOG.md with the addition of a "Release Highlights" section at the top ([example](https://github.com/bpftrace/bpftrace/releases/tag/v0.24.0)). 1. Check that automation picks up the new release and uploads release assets to the release. 1. If automation fails, please fix the automation for next time and also manually build+upload artifacts by running `scripts/create-assets.sh` from bpftrace root dir and attach the generated archives to the release. Once the release is out: 1. Forward-port the CHANGELOG.md changes from the release branch to master. This includes the release date and the entries which were backported from master after the release branch was cut. 1. Create a "Release Notes" page on the bpftrace website ([example](https://bpftrace.org/release-024-notes)) and update the text and link on the homepage to point to this new page. Also link to this page from the "Release Highlights" section in the tag description. ## Creating a Patch Release 1. Checkout the active release branch. 1. Mark the release in [CHANGELOG.md](../CHANGELOG.md) by replacing the `## Unreleased` header with `## [X.Y.Z] TODAY'S DATE` or adding this header if one doesn't exist. 1. Update `bpftrace_VERSION_PATCH` in [CMakeLists.txt](../CMakeLists.txt) to `Z`. 1. After those changes have landed then [tag the release](#tagging-a-release) following the steps in that section except the patches don't need a "Release Highlights" section of the tag description or a new "Release Notes" page on the website. bpftrace-0.27.1/docs/stdlib.md000066400000000000000000001611021526721631600161340ustar00rootroot00000000000000# bpftrace Standard Library This includes builtins, functions, macros, and [map value functions](#map-value-functions). The boundaries for the first three are blurred, by design, to allow for more flexible usage and are grouped below as "Helpers". For example `pid` and `pid()` are equivalent; both yielding the process id. Basically all functions or macros that don't have arguments or have default arguments can be invoked with or without the call syntax. **async** helpers are asynchronous, which can lead to unexpected behaviour. See the [Invocation Mode](#invocation-mode) section for more information. **compile time** helpers are evaluated at compile time, a static value will be compiled into the program. **unsafe** helpers can have dangerous side effects and should be used with care, the `--unsafe` flag is required for use. ## Helpers ### assert - `void assert(bool condition, string message)` Simple assertion macro that will exit the entire script with an error code if the condition is not met. ### assert_str Checks that this value is string-like. ### bswap - `uint8 bswap(uint8 n)` - `uint16 bswap(uint16 n)` - `uint32 bswap(uint32 n)` - `uint64 bswap(uint64 n)` `bswap` reverses the order of the bytes in integer `n`. In case of 8 bit integers, `n` is returned without being modified. The return type is an unsigned integer of the same width as `n`. ### buf - `buffer buf(void * data, [int64 length])` `buf` reads `length` amount of bytes from address `data`. The maximum value of `length` is limited to the `BPFTRACE_MAX_STRLEN` variable. For arrays the `length` is optional, it is automatically inferred from the signature. `buf` is address space aware and will call the correct helper based on the address space associated with `data`. The `buffer` object returned by `buf` can safely be printed as a hex encoded string with the `%r` format specifier. Bytes with values >=32 and \<=126 are printed using their ASCII character, other bytes are printed in hex form (e.g. `\x00`). The `%rx` format specifier can be used to print everything in hex form, including ASCII characters. The similar `%rh` format specifier prints everything in hex form without `\x` and with spaces between bytes (e.g. `0a fe`). ``` interval:s:1 { printf("%r\n", buf(kaddr("avenrun"), 8)); } ``` ``` \x00\x03\x00\x00\x00\x00\x00\x00 \xc2\x02\x00\x00\x00\x00\x00\x00 ``` ### cat - `void cat(string namefmt, [...args])` **async** Dump the contents of the named file to stdout. `cat` supports the same format string and arguments that `printf` does. If the file cannot be opened or read an error is printed to stderr. ``` tracepoint:syscalls:sys_enter_execve { cat("/proc/%d/maps", pid); } ``` ``` 55f683ebd000-55f683ec1000 r--p 00000000 08:01 1843399 /usr/bin/ls 55f683ec1000-55f683ed6000 r-xp 00004000 08:01 1843399 /usr/bin/ls 55f683ed6000-55f683edf000 r--p 00019000 08:01 1843399 /usr/bin/ls 55f683edf000-55f683ee2000 rw-p 00021000 08:01 1843399 /usr/bin/ls 55f683ee2000-55f683ee3000 rw-p 00000000 00:00 0 ``` ### cgroup - `uint64 cgroup()` - `uint64 cgroup` ID of the cgroup the current process belongs to Only works with cgroupv2 This utilizes the BPF helper `get_current_cgroup_id` ### cgroup_path - `cgroup_path_t cgroup_path(int cgroupid, string filter)` Convert cgroup id to cgroup path. This is done asynchronously in userspace when the cgroup_path value is printed, therefore it can resolve to a different value if the cgroup id gets reassigned. This also means that the returned value can only be used for printing. A string literal may be passed as an optional second argument to filter cgroup hierarchies in which the cgroup id is looked up by a wildcard expression (cgroup2 is always represented by "unified", regardless of where it is mounted). The currently mounted hierarchy at /sys/fs/cgroup is used to do the lookup. If the cgroup with the given id isn’t present here (e.g. when running in a Docker container), the cgroup path won’t be found (unlike when looking up the cgroup path of a process via /proc/.../cgroup). ``` BEGIN { $cgroup_path = cgroup_path(3436); print($cgroup_path); print($cgroup_path); /* This may print a different path */ printf("%s %s", $cgroup_path, $cgroup_path); /* This may print two different paths */ } ``` ### cgroupid - `uint64 cgroupid(const string path)` **compile time** `cgroupid` retrieves the cgroupv2 ID of the cgroup available at `path`. ``` BEGIN { print(cgroupid("/sys/fs/cgroup/system.slice")); } ``` ### clear - `void clear(map m)` **async** Clear all keys/values from map `m`. ``` interval:ms:100 { @[rand % 10] = count(); } interval:s:10 { print(@); clear(@); } ``` ### comm - `string comm()` - `string comm` - `string comm(uint32 pid)` Name of the current thread or the process with the specified PID This utilizes the BPF helper `get_current_comm` ### config - `Record config()` - `Record config` Returns a `Record` containing the current `bpftrace` configuration settings. [List of config variables](./language.md#config-variables) ``` printf("max_strlen: %d, stack_mode: %s\n", config.max_strlen, config.stack_mode); } ``` ### container_of - `Container* container_of(Member* ptr, Type type, Identifier member)` Returns a pointer to an object of the passed `type` given a pointer to the `member` of that object. ### cpid - `uint32 cpid()` - `uint32 cpid` Child process ID, if bpftrace is invoked with `-c`. If there is no child process, a runtime warning will be issued and the return value will be zero. This warning can be avoided by using `has_cpid` to check if `cpid` has a value, prior to referencing `cpid`. ### cpu - `uint32 cpu()` - `uint32 cpu` ID of the processor executing the BPF program BPF program, in this case, is the probe body This utilizes the BPF helper `raw_smp_processor_id` ### curtask - `uint64 curtask()` - `uint64 curtask` Pointer to `struct task_struct` of the current task This utilizes the BPF helper `get_current_task` ### default_str_length Returns the default unbounded length. ### delete - `bool delete(map m, mapkey k)` - deprecated `bool delete(mapkey k)` Delete a single key from a map. For scalar maps (e.g. no explicit keys), the key is omitted and is equivalent to calling `clear`. For map keys that are composed of multiple values (e.g. `@mymap[3, "hello"] = 1` - remember these values are represented as a tuple) the syntax would be: `delete(@mymap, (3, "hello"));` If deletion fails (e.g. the key doesn’t exist) the function returns false (0). Additionally, if the return value for `delete` is discarded, and deletion fails, you will get a warning. ``` @a[1] = 1; delete(@a, 1); // no warning (the key exists) if (delete(@a, 2)) { // no warning (return value is used) ... } $did_delete = delete(@a, 2); // no warning (return value is used) delete(@a, 2); // warning (return value is discarded and the key doesn’t exist) ``` The, now deprecated, API (supported in version <= 0.21.x) of passing map arguments with the key is still supported: e.g. `delete(@mymap[3, "hello"]);`. ``` kprobe:dummy { @scalar = 1; delete(@scalar); // ok @single["hello"] = 1; delete(@single, "hello"); // ok @associative[1,2] = 1; delete(@associative, (1,2)); // ok delete(@associative); // error delete(@associative, 1); // error // deprecated but ok delete(@single["hello"]); delete(@associative[1, 2]); } ``` ### dw_ustack - `ustack_t dw_ustack([StackMode mode, ][int limit])` DWARF-based user-space stack unwinding. Unlike [ustack](#ustack), which relies on frame pointers, `dw_ustack` uses DWARF `.eh_frame` debug information to unwind the stack. This makes it possible to collect complete user-space stack traces from programs compiled without frame pointers. The signature and output format are the same as `ustack`. Bpftrace needs to read the DWARF information for the target processes at startup. For this, one or more pids have to be specified. This can either be done via `-p`, `-c` (implicitly) or `--dwarf-pid`. If `dw_ustack` cannot find unwind information for a process, a runtime warning is emitted. `dw_ustack` is currently only available on x86_64. **Unstable feature** `dw_ustack` is an unstable feature. By default a warning is printed when it is used. Set the config flag to suppress the warning or to make it an error: ``` config = { unstable_dw_ustack=enable } ``` For usage examples see [ustack](#ustack). ### elapsed - `uint64 elapsed()` - `uint64 elapsed` ktime_get_ns - ktime_get_boot_ns ### errorf - `void errorf(const string fmt, args...)` **async** `errorf()` formats and prints data (similar to [`printf`](#printf)) as an error message with the source location. ``` BEGIN { errorf("Something bad with args: %d, %s", 10, "arg2"); } ``` Prints: ``` EXPECT stdin:1:9-62: ERROR: Something bad with args: 10, arg2 ``` ### exit - `void exit([int code])` **async** Terminate bpftrace, as if a `SIGTERM` was received. The `END` probe will still trigger (if specified) and maps will be printed. An optional exit code can be provided. ``` BEGIN { exit(); } ``` Or ``` BEGIN { exit(1); } ``` ### fail - `void fail(const string fmt, args...)` `fail()` formats and prints data (similar to [`printf`](#printf)) as an error message with the source location but, as opposed to [`errorf`](#errorf), is treated like a static assert and halts compilation if it is visited. All args have to be literals since they are evaluated at compile time. ``` BEGIN { if ($1 < 2) { fail("Expected the first positional param to be greater than 1. Got %d", $1); } } ``` ### find - `boolean find(map m, mapkey k, mapvalue result)` Return `true` if the key exists in this map and sets the passed scratch variable (result) to the value of that map key. Otherwise return `false` and don't mutate result. Use this instead of `has_key` and a map access to avoid an additional map lookup. Error if called with a map that has no keys (aka scalar map). ``` kprobe:dummy { @map[2] = (1, "hello"); let $val; if (find(@map, 2, $val)) { print($val); // prints (1, "hello") } } ``` ### func - `ksym_t func()` - `ksym_t func` - `usym_t func()` - `usym_t func` Name of the current function being traced (kprobes,uprobes,fentry) ### getopt - `bool getopt(string arg_name)` - `bool getopt(string arg_name, bool default_value, [string description])` - `int getopt(string arg_name, int default_value, [string description])` - `string getopt(string arg_name, string default_value, [string description])` Get the named command line argument/option e.g. ``` # bpftrace -e 'BEGIN { print(getopt("hello", 1, "Description of hello")); }' -- --hello=5 ``` `getopt` defines the type of the argument by the default value’s type. If no default type is provided, the option is treated like a boolean arg e.g. `getopt("hello")` would evaluate to `false` if `--hello` is not specified on the command line or `true` if `--hello` is passed or set to one of the following values: `true`, `1`. Additionally, boolean args accept the following false values: `0`, `false` e.g. `--hello=false`. If the arg is not set on the command line, the default value is used. `getopt` calls may optionally specify a string with the argument description (except for a boolean arg without a default value). You can use `--help` to see all named arguments/options. ``` # bpftrace -e 'BEGIN { print((getopt("aa", 10, "Description of aa"), getopt("bb", "hello"), getopt("cc"), getopt("dd", false))); }' -- --cc --bb=bye ``` ### gid - `uint64 gid()` - `uint64 gid` Group ID of the current thread, as seen from the init namespace This utilizes the BPF helper `get_current_uid_gid` ### has_cpid - `bool has_cpid()` - `bool has_cpid` Returns true iff cpid is available. ### has_key - `boolean has_key(map m, mapkey k)` Return `true` if the key exists in this map. Otherwise return `false`. Error if called with a map that has no keys (aka scalar map). ``` kprobe:dummy { @associative[1,2] = 1; if (!has_key(@associative, (1,3))) { // ok print(("bye")); } @scalar = 1; if (has_key(@scalar)) { // error print(("hello")); } } ``` ### is_array - `bool is_array(any expression)` Determine whether the given expression is an array. ### is_err - `bool is_err(void * ptr)` Returns true if the pointer is an ERR_PTR, i.e. it encodes a kernel error code. In the Linux kernel, some functions return error codes encoded as pointers using the `ERR_PTR` macro. These are pointer values in the range `(unsigned long)(-4095)` to `(unsigned long)(-1)`. This is equivalent to the kernel's `IS_ERR()` macro. ``` fexit:do_filp_open { if (is_err(retval)) { printf("error: %ld\n", (int64)retval); } } ``` ### is_integer - `bool is_integer(any expression)` Determine whether the given expression is an integer. ### is_literal - `bool is_literal(Expression expr)` Returns true if the passed expression is a literal, e.g. 1, true, "hello" ### is_ptr - `bool is_ptr(any expression)` Determine whether the given expression is a pointer. ### is_str - `bool is_str(any expression)` Determine whether the given expression is a string. ### is_unsigned_integer - `bool is_unsigned_integer(any expression)` Determine whether the given expression is an unsigned integer. ### jiffies - `uint64 jiffies()` - `uint64 jiffies` Jiffies of the kernel On 32-bit systems, using this builtin might be slower This utilizes the BPF helper `get_jiffies_64` ### join - `void join(char *arr[], [char * sep = ' '])` **async** `join` joins a char * `arr` with `sep` as separator into one string. This string will be printed to stdout directly, it cannot be used as string value. The concatenation of the array members is done in BPF and the printing happens in userspace. ``` tracepoint:syscalls:sys_enter_execve { join(args.argv); } ``` ### kaddr - `uint64 kaddr(const string name)` **compile time** Get the address of the kernel symbol `name`. ``` interval:s:1 { $avenrun = kaddr("avenrun"); $load1 = *$avenrun; } ``` You can find all kernel symbols at `/proc/kallsyms`. ### kfunc_allowed - `boolean kfunc_allowed(const string kfunc)` Determine if a kfunc is supported for particular probe types. Argument kfunc must be string literal. ### kfunc_exist - `boolean kfunc_exist(const string kfunc)` Determine if a kfunc exists using BTF. Argument kfunc must be string literal. ### kptr - `T * kptr(T * ptr)` Marks `ptr` as a kernel address space pointer. See the address-spaces section for more information on address-spaces. The pointer type is left unchanged. ### kstack - `kstack_t kstack([StackMode mode, ][int limit])` There are several [formatting/StackMode options](./language.md#stack_mode). ``` kprobe:ip_output { @[kstack()] = count(); } /* * Sample output: * @[ * ip_output+1 * tcp_transmit_skb+1308 * tcp_write_xmit+482 * tcp_release_cb+225 * release_sock+64 * tcp_sendmsg+49 * sock_sendmsg+48 * sock_write_iter+135 * __vfs_write+247 * vfs_write+179 * sys_write+82 * entry_SYSCALL_64_fastpath+30 * ]: 1708 */ ``` Sampling only three frames from the stack (limit = 3): ``` kprobe:ip_output { @[kstack(3)] = count(); } /* * Sample output: * @[ * ip_output+1 * tcp_transmit_skb+1308 * tcp_write_xmit+482 * ]: 1708 */ ``` Note: If a limit is used and `show_debug_info` is enabled then the number of symbolized frames might exceed that limit in the output as `limit` refers to instruction pointers, which can translate to multiple inlined symbols. Example using `perf` StackMode: ``` kprobe:ip_output { @[kstack(perf, 3)] = count(); } /* * Sample output: * @[ * ffffffffb4019501 do_mmap+1 * ffffffffb401700a sys_mmap_pgoff+266 * ffffffffb3e334eb sys_mmap+27 * ]: 1708 */ ``` ### ksym - `ksym_t ksym(uint64 addr)` **async** Retrieve the name of the function that contains address `addr`. The address to name mapping happens in user-space. The `ksym_t` type can be printed with the `%s` format specifier. ``` kprobe:do_nanosleep { printf("%s\n", ksym(reg("ip"))); } /* * Sample output: * do_nanosleep */ ``` ### leader_comm - `string leader_comm()` - `string leader_comm` - `string leader_comm(struct task_struct * task)` Get the thread name of the thread group leader for the passed task or the current task if called without arguments. This is an alias for `task.group_leader.comm`, which is different than `task.real_parent.comm`, which you can get from calling `pcomm()`. See `pcomm()` for more details. ### leader_tid - `string leader_tid()` - `string leader_tid` - `string leader_tid(struct task_struct * task)` Get the thread id of the thread group leader for the passed task or the current task if called without arguments. This is an alias for `task.group_leader.pid`, which is different than `task.real_parent.pid`, which you can get from calling `ppid()`. See `ppid()` for more details. ### len - `int64 len(map m)` - `int64 len(ustack stack)` - `int64 len(kstack stack)` For maps, return the number of elements in the map. For kstack/ustack, return the depth (measured in # of frames) of the call stack. ### macaddr - `macaddr_t macaddr(char [6] mac)` Create a buffer that holds a macaddress as read from `mac` This buffer can be printed in the canonical string format using the `%s` format specifier. ``` kprobe:arp_create { $stack_arg0 = *(uint8*)(reg("sp") + 8); $stack_arg1 = *(uint8*)(reg("sp") + 16); printf("SRC %s, DST %s\n", macaddr($stack_arg0), macaddr($stack_arg1)); } /* * Sample output: * SRC 18:C0:4D:08:2E:BB, DST 74:83:C2:7F:8C:FF */ ``` ### memcmp - `int memcmp(left, right, uint64 count)` Compares the first 'count' bytes of two expressions. 0 is returned if they are the same. negative value if the first differing byte in left is less than the corresponding byte in right. ### ncpus - `uint64 ncpus()` - `uint64 ncpus` Number of CPUs ### nsecs - `timestamp nsecs([TimestampMode mode])` - `timestamp nsecs` - `nsecs(monotonic) - nanosecond timestamp since boot, exclusive of time the system spent suspended (CLOCK_MONOTONIC)` - `nsecs(boot) - nanoseconds since boot, inclusive of time the system spent suspended (CLOCK_BOOTTIME)` - `nsecs(tai) - TAI timestamp in nanoseconds (CLOCK_TAI)` - `nsecs(sw_tai) - approximation of TAI timestamp in nanoseconds, is obtained through the "triple vdso sandwich" method. For older kernels without direct TAI timestamp access in BPF.` Returns a timestamp in nanoseconds, as given by the requested kernel clock. Defaults to `boot` if no clock is explicitly requested. ``` interval:s:1 { $sw_tai1 = nsecs(sw_tai); $tai = nsecs(tai); $sw_tai2 = nsecs(sw_tai); printf("sw_tai precision: %lldns\n", ($sw_tai1 + $sw_tai2)/2 - $tai); } /* * Sample output: * sw_tai precision: -98ns * sw_tai precision: -99ns * ... */ ``` ### ntop - `inet ntop([int64 af, ] int addr)` - `inet ntop([int64 af, ] char addr[4])` - `inet ntop([int64 af, ] char addr[16])` `ntop` returns the string representation of an IPv4 or IPv6 address. `ntop` will infer the address type (IPv4 or IPv6) based on the `addr` type and size. If an integer or `char[4]` is given, ntop assumes IPv4, if a `char[16]` is given, ntop assumes IPv6. You can also pass the address type (e.g. AF_INET) explicitly as the first parameter. ### numaid - `uint32 numaid()` - `uint32 numaid` ID of the NUMA node executing the BPF program BPF program, in this case, is the probe body This utilizes the BPF helper `numa_node_id` ### offsetof - `uint64 offsetof(STRUCT, FIELD[.SUBFIELD])` - `uint64 offsetof(EXPRESSION, FIELD[.SUBFIELD])` **compile time** Returns offset of the field offset bytes in struct. Similar to kernel `offsetof` operator. Support any number of sub field levels, for example: ``` struct Foo { struct { struct { struct { int d; } c; } b; } a; } BEGIN { @x = offsetof(struct Foo, a.b.c.d); exit(); } ``` ### override - `void override(uint64 rc)` **unsafe** **Kernel** 4.16 This utilizes the BPF helper `bpf_override` **Supported probes** * kprobe When using `override` the probed function will not be executed and instead `rc` will be returned. ``` kprobe:__x64_sys_getuid /comm == "id"/ { override(2<<21); } ``` ``` uid=4194304 gid=0(root) euid=0(root) groups=0(root) ``` This feature only works on kernels compiled with `CONFIG_BPF_KPROBE_OVERRIDE` and only works on functions tagged `ALLOW_ERROR_INJECTION`. bpftrace does not test whether error injection is allowed for the probed function, instead if will fail to load the program into the kernel: ``` ioctl(PERF_EVENT_IOC_SET_BPF): Invalid argument Error attaching probe: 'kprobe:vfs_read' ``` ### path - `char * path(struct path * path [, int32 size])` **Kernel** 5.10 This utilizes the BPF helper `bpf_d_path` Return full path referenced by struct path pointer in argument. If `size` is set, the path will be clamped by `size` otherwise `BPFTRACE_MAX_STRLEN` is used. If `size` is smaller than the resolved path, the resulting string will be truncated at the front rather than at the end. This function can only be used by functions that are allowed to, these functions are contained in the `btf_allowlist_d_path` set in the kernel. ### pcomm - `string pcomm()` - `string pcomm` - `string pcomm(struct task_struct * task)` Get the name of the parent process for the passed task or the current task if called without arguments. This is an alias for `task.real_parent.comm`, which is different than `task.group_leader.comm`, which you can get from calling `leader_comm()`. ### percpu_kaddr - `uint64 *percpu_kaddr(const string name)` - `uint64 *percpu_kaddr(const string name, int cpu)` **sync** Get the address of the percpu kernel symbol `name` for CPU `cpu`. When `cpu` is omitted, the current CPU is used. ``` interval:s:1 { $proc_cnt = percpu_kaddr("process_counts"); printf("% processes are running on CPU %d\n", *$proc_cnt, cpu); } ``` The second variant may return NULL if `cpu` is higher than the number of available CPUs. Therefore, it is necessary to perform a NULL-check on the result when accessing fields of the pointed structure, otherwise the BPF program will be rejected. ``` interval:s:1 { $runqueues = (struct rq *)percpu_kaddr("runqueues", 0); if ($runqueues != 0) { // The check is mandatory here print($runqueues.nr_running); } } ``` ### pid - `uint32 pid([curr_ns|init])` - `uint32 pid` Returns the process ID of the current thread. Defaults to `curr_ns`. * `pid(curr_ns)` - The process ID as seen from the PID namespace of bpftrace. * `pid(init)` - The process ID as seen from the initial PID namespace. ### ppid - `uint32 ppid()` - `uint32 ppid` - `uint32 ppid(struct task_struct * task)` Get the pid of the parent process for the passed task or the current task if called without arguments. This is an alias for `task.real_parent.pid`, which is different than `task.group_leader.pid`, which you can get from calling `leader_tid()`. ### print - `void print(T val)` - `void print(T val)` - `void print(@map)` - `void print(@map, uint64 top)` - `void print(@map, uint64 top, uint64 div)` **async** `print` prints a the value, which can be a map or a scalar value, with the default formatting for the type. ``` interval:s:1 { print(123); print("abc"); exit(); } /* * Sample output: * 123 * abc */ ``` ``` interval:ms:10 { @=hist(rand); } interval:s:1 { print(@); exit(); } ``` Prints: ``` @: [16M, 32M) 3 |@@@ | [32M, 64M) 2 |@@ | [64M, 128M) 1 |@ | [128M, 256M) 4 |@@@@ | [256M, 512M) 3 |@@@ | [512M, 1G) 14 |@@@@@@@@@@@@@@ | [1G, 2G) 22 |@@@@@@@@@@@@@@@@@@@@@@ | [2G, 4G) 51 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| ``` Declared maps and histograms are automatically printed out on program termination. Note that maps are printed by reference while scalar values are copied. This means that updating and printing maps in a fast loop will likely result in bogus map values as the map will be updated before userspace gets the time to dump and print it. The printing of maps supports the optional `top` and `div` arguments. `top` limits the printing to the top N entries with the highest integer values ``` BEGIN { $i = 11; for $elem : 1..$i { @[$elem] = $elem-1; } print(@, 2); clear(@); exit() } /* * Sample output: * @[9]: 8 * @[10]: 9 */ ``` The `div` argument scales the values prior to printing them. Scaling values before storing them can result in rounding errors. Consider the following program: ``` kprobe:f { @[func] += arg0/10; } ``` With the following sequence as numbers for arg0: `134, 377, 111, 99`. The total is `721` which rounds to `72` when scaled by 10 but the program would print `70` due to the rounding of individual values. Changing the print call to `print(@, 5, 2)` will take the top 5 values and scale them by 2: ``` @[6]: 3 @[7]: 3 @[8]: 4 @[9]: 4 @[10]: 5 ``` ### printf - `void printf(const string fmt, args...)` **async** `printf()` formats and prints data. It behaves similar to `printf()` found in `C` and many other languages. The format string has to be a constant, it cannot be modified at runtime. The formatting of the string happens in user space. Values are copied and passed by value. bpftrace supports all the typical format specifiers like `%llx` and `%hhu`. The non-standard ones can be found in the table below: | Specifier | Type | Format | Description | | --- | --- | --- | --- | | r | buffer | normal hex | Hex-formatted string to print arbitrary binary content returned by the [buf](#buf) function. | | rh | buffer | formatted hex | Prints in hex-formatted string without `\x` and with spaces between bytes (e.g. `0a fe`) | | rx | buffer | escaped hex | Prints in hex-formatted string with `\x` without spaces between bytes (e.g. `\x0a\xfe`) | | gr | integer | human readable | Formats GFP (Get Free Pages) flags into human-readable strings, similar to Linux kernel's `%pGg` format. | `printf()` can also symbolize enums as strings. User defined enums as well as enums defined in the kernel are supported. For example: ``` enum custom { CUSTOM_ENUM = 3, }; BEGIN { $r = SKB_DROP_REASON_SOCKET_FILTER; printf("%d, %s, %s\n", $r, $r, CUSTOM_ENUM); exit(); } ``` yields: ``` 6, SKB_DROP_REASON_SOCKET_FILTER, CUSTOM_ENUM ``` The `%gr` specifier can be used to format GFP (Get Free Pages) flags into human-readable strings: ``` tracepoint:kmem:kmalloc { printf("GFP flags: %gr\n", args->gfp_flags); } ``` This would output something like: ``` GFP flags: GFP_KERNEL GFP flags: GFP_ATOMIC|__GFP_HIGHMEM GFP flags: __GFP_IO|__GFP_FS|__GFP_DIRECT_RECLAIM ``` Colors are supported too, using standard terminal escape sequences: ``` print("\033[31mRed\t\033[33mYellow\033[0m\n") ``` ### probe - `string probe()` - `string probe` Name of the fully expanded probe For example: `kprobe:do_nanosleep` ### probetype - `string probetype()` - `string probetype` Name of the probe type. Note: `begin` and `end` probes are of type `special`. For example: `kprobe`, `special`, `tracepoint` ### pton - `char addr[4] pton(const string *addr_v4)` - `char addr[16] pton(const string *addr_v6)` **compile time** `pton` converts a text representation of an IPv4 or IPv6 address to byte array. `pton` infers the address family based on `.` or `:` in the given argument. `pton` comes in handy when we need to select packets with certain IP addresses. When casting the result of `pton()` to an integer (e.g. `(uint32)pton("127.0.0.1")`), the resulting value depends on the system's endianness. The byte array returned by `pton()` is stored in network byte order (big-endian), and when cast to an integer, it is interpreted according to the system's native byte order: **Little-endian systems**: The bytes are reversed when interpreted as an integer. For example, `(uint32)pton("127.0.0.1")` yields `0x100007f` (bytes: `[0x7f, 0x00, 0x00, 0x01]` interpreted as little-endian). **Big-endian systems**: The bytes maintain their network byte order. For example, `(uint32)pton("127.0.0.1")` yields `0x7f000001` (bytes: `[0x7f, 0x00, 0x00, 0x01]` interpreted as big-endian). This behavior is consistent with how the underlying `inet_pton()` function works. ### rand - `uint32 rand()` - `uint32 rand` Get a pseudo random number This utilizes the BPF helper `get_prandom_u32` ### reg - `uint64 reg(const string name)` **Supported probes** * kprobe * uprobe Get the contents of the register identified by `name`. Valid names depend on the CPU architecture. ### retval - `uint64 retval()` - `uint64 retval` Value returned by the function being traced (kretprobe, uretprobe, fexit) For kretprobe and uretprobe, its type is uint64, but for fexit it depends. You can look up the type using `bpftrace -lv` ### signal - `void signal(const string sig)` - `void signal(uint32 signum)` **unsafe** This utilizes the BPF helper `bpf_send_signal`. Probe types: k(ret)probe, u(ret)probe, USDT, profile Send a signal to the process being traced (any thread). Use `signal_thread` to send to the thread being traced. The signal can either be identified by name, e.g. `SIGSTOP` or by ID, e.g. `19` as found in `kill -l`. ``` kprobe:__x64_sys_execve /comm == "bash"/ { signal(5); } ``` ``` $ ls Trace/breakpoint trap (core dumped) ``` ### signal_name - `string signal_name(int sig)` Convert signal code to string. ``` #include begin { print(signal_name(SIGINT)); } ``` ### signal_thread - `void signal_thread(const string sig)` - `void signal_thread(uint32 signum)` **unsafe** This utilizes the BPF helper `bpf_send_signal_thread`. Probe types: k(ret)probe, u(ret)probe, USDT, profile Send a signal to the thread being traced. Use `signal` to send to the process being traced (any thread). The signal can either be identified by name, e.g. `SIGSTOP` or by ID, e.g. `19` as found in `kill -l`. ### sizeof - `uint64 sizeof(TYPE)` - `uint64 sizeof(EXPRESSION)` **compile time** Returns size of the argument in bytes. Similar to C/C++ `sizeof` operator. Note that the expression does not get evaluated. ### skboutput - `uint32 skboutput(const string path, struct sk_buff *skb, uint64 length, const uint64 offset)` **Kernel** 5.5 This utilizes the BPF helper `bpf_skb_output` Write sk_buff `skb` 's data section to a PCAP file in the `path`, starting from `offset` to `offset` + `length`. The PCAP file is encapsulated in RAW IP, so no ethernet header is included. The `data` section in the struct `skb` may contain ethernet header in some kernel contexts, you may set `offset` to 14 bytes to exclude ethernet header. Each packet’s timestamp is determined by adding `nsecs` and boot time, the accuracy varies on different kernels, see `nsecs`. This function returns 0 on success, or a negative error in case of failure. Environment variable `BPFTRACE_PERF_RB_PAGES` should be increased in order to capture large packets, or else these packets will be dropped. Usage ``` # cat dump.bt fentry:napi_gro_receive { $ret = skboutput("receive.pcap", args.skb, args.skb.len, 0); } fentry:dev_queue_xmit { // setting offset to 14, to exclude ethernet header $ret = skboutput("output.pcap", args.skb, args.skb.len, 14); printf("skboutput returns %d\n", $ret); } # export BPFTRACE_PERF_RB_PAGES=1024 # bpftrace dump.bt ... # tcpdump -n -r ./receive.pcap | head -3 reading from file ./receive.pcap, link-type RAW (Raw IP) dropped privs to tcpdump 10:23:44.674087 IP 22.128.74.231.63175 > 192.168.0.23.22: Flags [.], ack 3513221061, win 14009, options [nop,nop,TS val 721277750 ecr 3115333619], length 0 10:23:45.823194 IP 100.101.2.146.53 > 192.168.0.23.46619: 17273 0/1/0 (130) 10:23:45.823229 IP 100.101.2.146.53 > 192.168.0.23.46158: 45799 1/0/0 A 100.100.45.106 (60) ``` ### socket_cookie - `uint64 socket_cookie(struct sock *sk)` This utilizes the BPF helper `bpf_get_socket_cookie` Retrieve the cookie (generated by the kernel) of the socket. If no cookie has been set yet, generate a new cookie. Once generated, the socket cookie remains stable for the life of the socket. This function returns a `uint64` unique number on success, or 0 if **sk** is NULL. ``` fentry:tcp_rcv_established { $cookie = socket_cookie(args.sk); @psize[$cookie] = hist(args.skb.len); } ``` Prints: ``` @psize[65551]: [32, 64) 4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| @psize[504]: [32, 64) 4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64, 128) 1 |@@@@@@@@@@@@@ | [128, 256) 0 | | [256, 512) 1 |@@@@@@@@@@@@@ | [512, 1K) 0 | | [1K, 2K) 0 | | [2K, 4K) 1 |@@@@@@@@@@@@@ | ``` ### static_assert - `void static_assert(bool condition, string msg)` Assert something is true or fail the build. ### str - `string str(char * data [, uint32 length)` This utilizes the BPF helpers `probe_read_str, probe_read_{kernel,user}_str` `str` reads a NULL terminated (`\0`) string from `data`. The maximum string length is limited by the `BPFTRACE_MAX_STRLEN` env variable, unless `length` is specified and shorter than the maximum. In case the string is longer than the specified length only `length - 1` bytes are copied and a NULL byte is appended at the end. bpftrace will automatically use the `kernel` or `user` variant of `probe_read_{kernel,user}_str` based on the address space of `data`, see [Address-spaces](./language.md#address-spaces) for more information. ### str_concat - `string str_concat(string s1, string s2)` Concatenate two strings into a new string. Returns the new string. ### strcap - `int64 strcap(string exp)` - `int64 strcap(int8 exp[])` - `int64 strcap(int8 *exp)` Returns the "capacity" of a string-like object. In most cases this is the same as the length, but for bpftrace-native strings and arrays, this is the underlying object capacity. This is used to bound searches and lookups without needing to scan the string itself. ### strcontains - `bool strcontains(string haystack, string needle)` Compares whether the string haystack contains the string needle. If needle is contained then true is returned, else false is returned. ### strerror - `string strerror(int error)` Convert errno code to string. ``` #include begin { print(strerror(EPERM)); } ``` ### strftime - `timestamp strftime(const string fmt, uint64 timestamp_ns)` **async** Format the nanoseconds since boot timestamp `timestamp_ns` according to the format specified by `fmt`. The time conversion and formatting happens in user space, therefore the `timestamp` value returned can only be used for printing using the `%s` format specifier. **Note:** `timestamp_ns` must be non-negative. Negative timestamp literals are rejected. bpftrace uses the `strftime(3)` function for formatting time and supports the same format specifiers. ``` interval:s:1 { printf("%s\n", strftime("%H:%M:%S", nsecs)); } ``` bpftrace also supports the following format string extensions: | Specifier | Description | | --- | --- | | `%f` | Microsecond as a decimal number, zero-padded on the left | ### strlen - `uint64 strlen(string exp)` - `uint64 strlen(int8 exp[])` - `uint64 strlen(int8 *exp)` Returns the length of a string-like object. ### strncmp - `int64 strncmp(char * s1, char * s2, int64 n)` `strncmp` compares up to `n` characters string `s1` and string `s2`. If they’re equal `0` is returned, else a non-zero value is returned. bpftrace doesn’t read past the length of the shortest string. The use of the `==` and `!=` operators is recommended over calling `strncmp` directly. ### strstr - `int64 strstr(string haystack, string needle)` Returns the index of the first occurrence of the string needle in the string haystack. If needle is not in haystack then -1 is returned. ### syscall_name - `string syscall_name(int nr_syscall)` Convert syscall number to string. ``` #include begin { print(syscall_name(__NR_read)); // outputs "read" } ``` ### system - `void system(string namefmt [, ...args])` **unsafe** **async** `system` lets bpftrace run the specified command (`fork` and `exec`) until it completes and print its stdout. The `command` is run with the same privileges as bpftrace and it blocks execution of the processing threads which can lead to missed events and delays processing of async events. ``` interval:s:1 { time("%H:%M:%S: "); printf("%d\n", @++); } interval:s:10 { system("/bin/sleep 10"); } interval:s:30 { exit(); } ``` Note how the async `time` and `printf` first print every second until the `interval:s:10` probe hits, then they print every 10 seconds due to bpftrace blocking on `sleep`. ``` Attached 3 probes 08:50:37: 0 08:50:38: 1 08:50:39: 2 08:50:40: 3 08:50:41: 4 08:50:42: 5 08:50:43: 6 08:50:44: 7 08:50:45: 8 08:50:46: 9 08:50:56: 10 08:50:56: 11 08:50:56: 12 08:50:56: 13 08:50:56: 14 08:50:56: 15 08:50:56: 16 08:50:56: 17 08:50:56: 18 08:50:56: 19 ``` `system` supports the same format string and arguments that `printf` does. ``` tracepoint:syscalls:sys_enter_execve { system("/bin/grep %s /proc/%d/status", "vmswap", pid); } ``` ### tid - `uint32 tid([curr_ns|init])` - `uint32 tid` Returns the thread ID of the current thread. Defaults to `curr_ns`. * `tid(curr_ns)` - The thread ID as seen from the PID namespace of bpftrace. * `tid(init)` - The thread ID as seen from the initial PID namespace. ### time - `void time(const string fmt)` **async** Format the current wall time according to the format specifier `fmt` and print it to stdout. Unlike `strftime()` `time()` doesn’t send a timestamp from the probe, instead it is the time at which user-space processes the event. bpftrace uses the `strftime(3)` function for formatting time and supports the same format specifiers. ### typeof - `TYPE typeof(TYPE)` - `TYPE typeof(EXPRESSION)` This is a special builtin that can only be used in the following contexts: - variable declarations e.g. `let $a: typeof($b);` - cast expressions e.g. `$a = (typeof($b))2;` - macro expansion calls to pass a type parameter e.g. `my_macro(typeof(uint64 *));` - type accepting builtins: `sizeof`, `offsetof`, `typeinfo` This builtin evaluates to the static type of either the parsed TYPE or the raw EXPRESSION parameter. ### uaddr - `T * uaddr(const string sym)` **Supported probes** * uprobes * uretprobes * USDT If kernel supports task_vma open-coded iterator kfuncs (linux >= 6.7), uaddr() will correct the symbol addresses of PIE and dynamic libraries instead of directly using the symbol addresses in the ELF file, see https://github.com/torvalds/linux/commit/4ac454682158. The `uaddr` function returns the address of the specified symbol. This lookup happens during program compilation and cannot be used dynamically. The default return type is `uint64*`. If the ELF object size matches a known integer size (1, 2, 4 or 8 bytes) the return type is modified to match the width (`uint8*`, `uint16*`, `uint32*` or `uint64*` resp.). As ELF does not contain type info the type is always assumed to be unsigned. ``` uprobe:/bin/bash:readline { printf("PS1: %s\n", str(*uaddr("ps1_prompt"))); } ``` ### uid - `uint64 uid()` - `uint64 uid` User ID of the current thread, as seen from the init namespace This utilizes the BPF helper `get_current_uid_gid` ### unwatch - `void unwatch(void * addr)` **async** Removes a watchpoint ### uptr - `T * uptr(T * ptr)` Marks `ptr` as a user address space pointer. See the address-spaces section for more information on address-spaces. The pointer type is left unchanged. ### usermode - `uint8 usermode()` - `uint8 usermode` Returns 1 if the current process is in user mode, 0 otherwise Currently only available on x86_64. ### username - `string username()` - `string username` Get the current username Often this is just "root" ### ustack - `ustack_t ustack([StackMode mode, ][int limit])` There are several [formatting/StackMode options](./language.md#stack_mode). ``` kprobe:do_sys_open /comm == "bash"/ { @[ustack()] = count(); } /* * Sample output: * @[ * __open_nocancel+65 * command_word_completion_function+3604 * rl_completion_matches+370 * bash_default_completion+540 * attempt_shell_completion+2092 * gen_completion_matches+82 * rl_complete_internal+288 * rl_complete+145 * _rl_dispatch_subseq+647 * _rl_dispatch+44 * readline_internal_char+479 * readline_internal_charloop+22 * readline_internal+23 * readline+91 * yy_readline_get+152 * yy_readline_get+429 * yy_getc+13 * shell_getc+469 * read_token+251 * yylex+192 * yyparse+777 * parse_command+126 * read_command+207 * reader_loop+391 * main+2409 * __libc_start_main+231 * 0x61ce258d4c544155 * ]: 9 */ ``` Sampling only three frames from the stack (limit = 3): ``` kprobe:ip_output { @[ustack(3)] = count(); } /* * Sample output: * @[ * __open_nocancel+65 * command_word_completion_function+3604 * rl_completion_matches+370 * ]: 20 */ ``` Note: If a limit is used and `show_debug_info` is enabled then the number of symbolized frames might exceed that limit in the output as `limit` refers to instruction pointers, which can translate to multiple inlined symbols. Example using `perf` StackMode: ``` kprobe:ip_output { @[ustack(perf, 3)] = count(); } /* * Sample output: * @[ * 5649feec4090 readline+0 (/home/mmarchini/bash/bash/bash) * 5649fee2bfa6 yy_readline_get+451 (/home/mmarchini/bash/bash/bash) * 5649fee2bdc6 yy_getc+13 (/home/mmarchini/bash/bash/bash) * ]: 20 */ ``` Note that for these examples to work, bash had to be recompiled with frame pointers. ### usym - `usym_t usym(uint64 * addr)` **async** **Supported probes** * uprobes * uretprobes Equal to [ksym](#ksym) but resolves user space symbols. If ASLR is enabled, user space symbolication only works when the process is running at either the time of the symbol resolution or the time of the probe attachment. The latter requires `BPFTRACE_CACHE_USER_SYMBOLS` to be set to `PER_PID`, and might not work with older versions of BCC. A similar limitation also applies to dynamically loaded symbols. ``` uprobe:/bin/bash:readline { printf("%s\n", usym(reg("ip"))); } /* * Sample output: * readline */ ``` ### warnf - `void warnf(const string fmt, args...)` **async** `warnf()` formats and prints data (similar to [`printf`](#printf)) as an warning message with the source location. This respects the "--no-warnings" flag and will be silent if that is used. ``` BEGIN { warnf("Something kinda bad with args: %d, %s", 10, "arg2"); } ``` Prints: ``` EXPECT stdin:1:9-62: WARNING: Something kinda bad with args: 10, arg2 ``` ### write_user - `bool write_user(T * dst, T * src, uint32 len)` **unsafe** Writes `len` bytes from BPF program memory at `src` to user-space address `dst` using the BPF helper `bpf_probe_write_user`. Returns true on success, or false on failure. **Warning**: This can crash or corrupt the target process if used incorrectly. Only use on user-space memory addresses belonging to the current task. The kernel will print a warning to dmesg when this helper is used. ``` tracepoint:syscalls:sys_enter_openat /comm == "myapp"/ { $new_path = "/tmp/redirected\0"; if (write_user(args.filename, $new_path, 16)) { printf("redirected open for pid %d\n", pid); } } ``` ### zero - `void zero(map m)` **async** Set all values (for all keys) in the map to zero. ## Map Value Functions Map value functions can only be assigned to maps (when scalar) or map keys. The data types associated with these functions are only for internal use but many can be cast to integers (e.g. `count_t` and `sum_t`). ### avg * `avg_t avg(int64 n)` Calculate the running average of `n` between consecutive calls. ``` interval:s:1 { @x++; @y = avg(@x); print(@x); print(@y); } ``` Internally this keeps two values in the map: value count and running total. The average is computed in user-space when printing by dividing the total by the count. However, you can get the average in kernel space in expressions like `if (@y == 5)` but this is expensive as bpftrace needs to iterate over all the cpus to collect and sum BOTH count and total. ### count * `count_t count()` Count how often this function is called. Using `@=count()` is conceptually similar to `@++`. The difference is that the `count()` function uses a map type optimized for performance and correctness using cheap, thread-safe writes ([PERCPU](./language.md#percpu-types)). However, sync reads can be expensive as bpftrace needs to iterate over all the cpus to collect and sum these values. Note: This differs from "raw" writes (e.g. `@++`) where multiple writers to a shared location might lose updates, as bpftrace does not generate any atomic instructions for `++`. Example one: ``` BEGIN { @ = count(); @ = count(); printf("%d\n", (int64)@); // prints 2 exit(); } ``` Example two: ``` interval:ms:100 { @ = count(); } interval:s:10 { // async read print(@); // sync read if (@ > 10) { print(("hello")); } clear(@); } ``` ### hist * `hist_t hist(int64 n[, int k])` Create a log2 histogram of `n` using $2^k$ buckets per power of 2, 0 <= k <= 5, defaults to 0. ``` kretprobe:vfs_read { @bytes = hist(retval); } ``` Prints: ``` @: [1M, 2M) 3 | | [2M, 4M) 2 | | [4M, 8M) 2 | | [8M, 16M) 6 | | [16M, 32M) 16 | | [32M, 64M) 27 | | [64M, 128M) 48 |@ | [128M, 256M) 98 |@@@ | [256M, 512M) 191 |@@@@@@ | [512M, 1G) 394 |@@@@@@@@@@@@@ | [1G, 2G) 820 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ``` ### lhist * `lhist_t lhist(int64 n, int64 min, int64 max, int64 step)` Create a linear histogram of `n`. `lhist` creates `M` (`(max - min) / step`) buckets in the range `[min,max)` where each bucket is `step` in size. Values in the range `(-inf, min)` and `(max, inf)` get their get their own bucket too, bringing the total amount of buckets created to `M+2`. ``` interval:ms:1 { @ = lhist(rand %10, 0, 10, 1); } interval:s:5 { exit(); } ``` Prints: ``` @: [0, 1) 306 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [1, 2) 284 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [2, 3) 294 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [3, 4) 318 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [4, 5) 311 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [5, 6) 362 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [6, 7) 336 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [7, 8) 326 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [8, 9) 328 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [9, 10) 318 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ``` ### max * `max_t max(int64 n)` Update the map with `n` if `n` is bigger than the current value held. Similar to `count` this uses a [PERCPU](./language.md#percpu-types) map (thread-safe, fast writes, slow reads). Note: this is different than the typical userspace `max()` in that bpftrace’s `max()` only takes a single argument. The logical "other" argument to compare to is the value in the map the "result" is being assigned to. For example, compare the two logically equivalent samples (C++ vs bpftrace): In C++: ``` int x = std::max(3, 33); // x contains 33 ``` In bpftrace: ``` @x = max(3); @x = max(33); // @x contains 33 ``` Also note that bpftrace takes care to handle the unset case. In other words, there is no default value. The first value you pass to `max()` will always be returned. ### min * `min_t min(int64 n)` Update the map with `n` if `n` is smaller than the current value held. Similar to `count` this uses a [PERCPU](./language.md#percpu-types) map (thread-safe, fast writes, slow reads). See `max()` above for how this differs from the typical userspace `min()`. ### stats * `stats_t stats(int64 n)` `stats` combines the `count`, `avg` and `sum` calls into one. ``` kprobe:vfs_read { @bytes[comm] = stats(arg2); } ``` ``` @bytes[bash]: count 7, average 1, total 7 @bytes[sleep]: count 5, average 832, total 4160 @bytes[ls]: count 7, average 886, total 6208 @ ``` ### sum * `sum_t sum(int64 n)` Calculate the sum of all `n` passed. Using `@=sum(5)` is conceptually similar to `@+=5`. The difference is that the `sum()` function uses a map type optimized for performance and correctness using cheap, thread-safe writes ([PERCPU](./language.md#percpu-types)). However, sync reads can be expensive as bpftrace needs to iterate over all the cpus to collect and sum these values. Note: This differs from "raw" writes (e.g. `@+=5`) where multiple writers to a shared location might lose updates, as bpftrace does not generate any implicit atomic operations. Example one: ``` BEGIN { @ = sum(5); @ = sum(6); printf("%d\n", (int64)@); // prints 11 clear(@); exit(); } ``` Example two: ``` interval:ms:100 { @ = sum(5); } interval:s:10 { // async read print(@); // sync read if (@ > 10) { print(("hello")); } clear(@); } ``` ### tseries * `tseries_t tseries(int64 n, int64 interval_ns, int64 num_intervals)` * `tseries_t tseries(int64 n, int64 interval_ns, int64 num_intervals, const string agg)` Create a time series that tracks an integer value. `tseries` records up to `num_intervals` intervals representing `interval_ns` nanoseconds. #### Durations `interval_ns` is an unsigned integer that specifies the interval duration. You may use numbers with duration suffixes to improve readability: ``` @a = tseries(1, 100ns, 5); // 100 nanoseconds @b = tseries(1, 100us, 5); // 100 microseconds @c = tseries(1, 100ms, 5); // 100 milliseconds @d = tseries(1, 1s, 5); // 1 second ``` #### Aggregation Functions By default, each interval in `tseries` contains the last value recorded in that interval. The optional `agg` parameter specifies how values in the same interval are aggregated. | Aggregation Function | Example | Description | | --- | --- | --- | | `avg` | `@ = tseries(@v, 1s, 5, "avg")` | Calculate the running average of all the values in each interval. | | `max` | `@ = tseries(@v, 1s, 5, "max")` | Calculate the maximum of all values in each interval. | | `min` | `@ = tseries(@v, 1s, 5, "min")` | Calculate the minimum of all values in each interval. | | `sum` | `@ = tseries(@v, 1s, 5, "sum")` | Calculate the sum of all values in each interval. | #### Examples Example one: ``` // Record the minimum of ten random values generated during each 100ms interval. i:ms:10 { @ = tseries(rand % 10, 100ms, 20, "min"); } ``` ``` Attached 2 probes @: 0 2 hh:mm:ss.ms |___________________________________________________| 10:41:46.700 * | 0 10:41:46.800 * | 0 10:41:46.900 | * | 1 10:41:47.000 | * 2 10:41:47.100 | * | 1 10:41:47.200 * | 0 10:41:47.300 | * | 1 10:41:47.400 * | 0 10:41:47.500 | * | 1 10:41:47.600 * | 0 10:41:47.700 | * 2 10:41:47.800 * | 0 10:41:47.900 * | 0 10:41:48.000 | * | 1 10:41:48.100 | * | 1 10:41:48.200 | * | 1 10:41:48.300 * | 0 10:41:48.400 | * 2 10:41:48.500 | * | 1 10:41:48.600 | * | 1 v___________________________________________________v 0 2 ``` Example two: ``` // Create a zigzag pattern BEGIN { @dir = 1; @c = -5; } i:ms:100 { @ = tseries(@c, 100ms, 20); @c += @dir; if (@c > 5) { @dir = -1; @c = 4 } else if (@c < -5) { @dir = 1; @c = -4; } } ``` ``` Attached 2 probes @: -5 5 hh:mm:ss.ms |___________________________________________________| 10:39:49.300 * . | -5 10:39:49.400 | * . | -4 10:39:49.500 | * . | -3 10:39:49.600 | * . | -2 10:39:49.700 | * . | -1 10:39:49.800 | * | 0 10:39:49.900 | . * | 1 10:39:50.000 | . * | 2 10:39:50.100 | . * | 3 10:39:50.200 | . * | 4 10:39:50.300 | . * 5 10:39:50.400 | . * | 4 10:39:50.500 | . * | 3 10:39:50.600 | . * | 2 10:39:50.700 | . * | 1 10:39:50.800 | * | 0 10:39:50.900 | * . | -1 10:39:51.000 | * . | -2 10:39:51.100 | * . | -3 10:39:51.200 | * . | -4 v___________________________________________________v -5 5 ``` ## Invocation Mode There are three invocation modes for bpftrace built-in functions. | | | | | --- | --- | --- | | Mode | Description | Example functions | | Synchronous | The value/effect of the built-in function is determined/handled right away by the bpf program in the kernel space. | `reg(), str(), ntop()` | | Asynchronous | The value/effect of the built-in function is determined/handled later by the bpftrace process in the user space. | `printf(), clear(), exit()` | | Compile-time | The value of the built-in function is determined before bpf programs are running. | `kaddr(), cgroupid(), offsetof()` | While BPF in the kernel can do a lot there are still things that can only be done from user space, like the outputting (printing) of data. The way bpftrace handles this is by sending events from the BPF program which user-space will pick up some time in the future (usually in milliseconds). Operations that happen in the kernel are 'synchronous' ('sync') and those that are handled in user space are 'asynchronous' ('async') The asynchronous behaviour can lead to some unexpected behavior as updates can happen before user space had time to process the event. The following situations may occur: * event loss: when using printf(), the amount of data printed may be less than the actual number of events generated by the kernel during BPF program’s execution. * delayed exit: when using the exit() to terminate the program, bpftrace needs to handle the exit signal asynchronously causing the BPF program may continue to run for some additional time. One example is updating a map value in a tight loop: ``` BEGIN { @=0; unroll(10) { print(@); @++; } exit() } ``` Maps are printed by reference not by value and as the value gets updated right after the print user-space will likely only see the final value once it processes the event: ``` @: 10 @: 10 @: 10 @: 10 @: 10 @: 10 @: 10 @: 10 @: 10 @: 10 ``` Therefore, when you need precise event statistics, it is recommended to use synchronous functions (e.g. count() and hist()) to ensure more reliable and accurate results. bpftrace-0.27.1/docs/tutorial_one_liners.md000066400000000000000000000424621526721631600207420ustar00rootroot00000000000000# The bpftrace One-Liner Tutorial This teaches you bpftrace for Linux in 12 easy lessons, where each lesson is a one-liner you can try running. This series of one-liners introduces concepts which are summarized as bullet points. Read more about [the language](language.md), [the standard library](stdlib.md), and [CLI options](../man/adoc/bpftrace.adoc). Contributed by Brendan Gregg, Netflix (2018), based on his FreeBSD [DTrace Tutorial](https://wiki.freebsd.org/DTrace/Tutorial). Note: bpftrace 0.19 changed the way probe arguments are accessed (using `args.xxx` instead of `args->xxx`). If you are using an older version of bpftrace, you will need to use `args->xxx` in the below examples. # Lesson 1. Listing Probes ``` bpftrace -l 'tracepoint:syscalls:sys_enter_*' ``` "bpftrace -l" lists all probes, and a search term can be added. - A probe is an instrumentation point for capturing event data. - The supplied search term supports wildcards/globs (`*` and `?`) - "bpftrace -l" can also be piped to grep(1) for full regular expression searching. # Lesson 2. Hello World ``` bpftrace -e 'BEGIN { printf("hello world\n"); }' ``` Expected Output: ``` Attached 1 probe hello world ^C ``` This prints a welcome message. Run it, then hit Ctrl-C to end. - The word `BEGIN` is a special probe that fires at the start of the program (like awk's BEGIN). You can use it to set variables and print headers. - An action can be associated with probes, in { }. This example calls printf() when the probe fires. # Lesson 3. File Opens ``` bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args.filename)); }' ``` Expected Output: ``` Attached 1 probe snmp-pass /proc/cpuinfo snmp-pass /proc/stat snmpd /proc/net/dev snmpd /proc/net/if_inet6 ^C ``` This traces file opens as they happen, and we're printing the process name and pathname. - It begins with the probe `tracepoint:syscalls:sys_enter_openat`: this is the tracepoint probe type (kernel static tracing), and is instrumenting when the `openat()` syscall begins (is entered). Tracepoints are preferred over kprobes (kernel dynamic tracing, introduced in lesson 6), since tracepoints have stable API. Note: In modern Linux systems (glibc >= 2.26) the `open` wrapper always calls the `openat` syscall. - `comm` is a builtin variable that has the current process's name. Other similar builtins include pid and tid. - `args` is a struct containing all the tracepoint arguments. This struct is automatically generated by bpftrace based tracepoint information. The members of this struct can be found with: `bpftrace -vl tracepoint:syscalls:sys_enter_openat`. - `args.filename` accesses the `args` struct and gets the value of the `filename` member. - `str()` turns a pointer into the string it points to. # Lesson 4. Syscall Counts By Process ``` bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }' ``` Expected Output: ``` Attached 1 probe ^C @[bpftrace]: 6 @[systemd]: 24 @[snmp-pass]: 96 @[sshd]: 125 ``` This summarizes syscalls by process name, printing a report on Ctrl-C. - @: This denotes a special variable type called a map, which can store and summarize data in different ways. You can add an optional variable name after the @, eg "@num", either to improve readability, or to differentiate between more than one map. - []: The optional brackets allow a key to be set for the map, much like an associative array. - count(): This is a map function – the way it is populated. count() counts the number of times it is called. Since this is saved by comm, the result is a frequency count of system calls by process name. Maps are automatically printed when bpftrace ends (eg, via Ctrl-C). # Lesson 5. Distribution of read() Bytes ``` bpftrace -e 'tracepoint:syscalls:sys_exit_read /pid == 18644/ { @bytes = hist(args.ret); }' ``` Expected Output: ``` Attached 1 probe ^C @bytes: [0, 1] 12 |@@@@@@@@@@@@@@@@@@@@ | [2, 4) 18 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 30 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64, 128) 19 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [128, 256) 1 |@ ``` This summarizes the return value of the sys_read() kernel function for PID 18644, printing it as a histogram. - /.../: This is a filter (aka predicate), which acts as a filter for the action. The action is only executed if the filtered expression is true, in this case, only for the process ID 18644. Boolean operators are supported ("&&", "||"). - ret: This is the return value of the function. For sys_read(), this is either -1 (error) or the number of bytes successfully read. - @: This is a map similar to the previous lesson, but without any keys ([]) this time, and the name "bytes" which decorates the output. - hist(): This is a map function which summarizes the argument as a power-of-2 histogram. The output shows rows that begin with interval notation, where, for example `[128, 256)` means that the value is: 128 <= value < 256. The next number is the count of occurrences, and then an ASCII histogram is printed to visualize that count. The histogram can be used to study multi-modal distributions. - Other map functions include lhist() (linear hist), count(), sum(), avg(), min(), and max(). # Lesson 6. Kernel Dynamic Tracing of read() Bytes ``` bpftrace -e 'kretprobe:vfs_read { @bytes = lhist(retval, 0, 2000, 200); }' ``` Expected Output: ``` Attached 1 probe ^C @bytes: (...,0] 0 | | [0, 200) 66 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [200, 400) 2 |@ | [400, 600) 3 |@@ | [600, 800) 0 | | [800, 1000) 5 |@@@ | [1000, 1200) 0 | | [1200, 1400) 0 | | [1400, 1600) 0 | | [1600, 1800) 0 | | [1800, 2000) 0 | | [2000,...) 39 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ``` Summarize read() bytes as a linear histogram, and traced using kernel dynamic tracing. - It begins with the probe `kretprobe:vfs_read`: this is the kretprobe probe type (kernel dynamic tracing of function returns) instrumenting the `vfs_read()` kernel function. There is also the kprobe probe type (shown in the next lesson), to instrument when functions begin execution (are entered). These are powerful probe types, letting you trace tens of thousands of different kernel functions. However, these are "unstable" probe types: since they can trace any kernel function, there is no guarantee that your kprobe/kretprobe will work between kernel versions, as the function names, arguments, return values, and roles may change. Also, since it is tracing the raw kernel, you'll need to browse the kernel source to understand what these probes, arguments, and return values, mean. - lhist(): this is a linear histogram, where the arguments are: value, min, max, step. The first argument (`retval`) of vfs_read() is the return value: the number of bytes read. # Lesson 7. Timing read()s ``` bpftrace -e 'kprobe:vfs_read { @start[tid] = nsecs; } kretprobe:vfs_read /@start[tid]/ { @ns[comm] = hist(nsecs - @start[tid]); delete(@start, tid); }' ``` Expected Output: ``` Attached 2 probes [...] @ns[snmp-pass]: [0, 1] 0 | | [2, 4) 0 | | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 0 | | [64, 128) 0 | | [128, 256) 0 | | [256, 512) 27 |@@@@@@@@@ | [512, 1k) 125 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [1k, 2k) 22 |@@@@@@@ | [2k, 4k) 1 | | [4k, 8k) 10 |@@@ | [8k, 16k) 1 | | [16k, 32k) 3 |@ | [32k, 64k) 144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64k, 128k) 7 |@@ | [128k, 256k) 28 |@@@@@@@@@@ | [256k, 512k) 2 | | [512k, 1M) 3 |@ | [1M, 2M) 1 | | ``` Summarize the time spent in read(), in nanoseconds, as a histogram, by process name. - @start[tid]: This uses the thread ID as a key. There may be many reads in-flight, and we want to store a start timestamp to each. How? We could construct a unique identifier for each read, and use that as the key. But because kernel threads can only be executing one syscall at a time, we can use the thread ID as the unique identifier, as each thread cannot be executing more than one. - nsecs: Nanoseconds since boot. This is a high resolution timestamp counter than can be used to time events. - /@start[tid]/: This filter checks that the start time was seen and recorded. Without this filter, this program may be launched during a read and only catch the end, resulting in a time calculation of now - zero, instead of now - start. - delete(@start, tid): this frees the variable. # Lesson 8. Count Process-Level Events ``` bpftrace -e 'tracepoint:sched:sched* { @[probe] = count(); } interval:s:5 { exit(); }' ``` Expected Output: ``` Attached 25 probes @[tracepoint:sched:sched_wakeup_new]: 1 @[tracepoint:sched:sched_process_fork]: 1 @[tracepoint:sched:sched_process_exec]: 1 @[tracepoint:sched:sched_process_exit]: 1 @[tracepoint:sched:sched_process_free]: 2 @[tracepoint:sched:sched_process_wait]: 7 @[tracepoint:sched:sched_wake_idle_without_ipi]: 53 @[tracepoint:sched:sched_stat_runtime]: 212 @[tracepoint:sched:sched_wakeup]: 253 @[tracepoint:sched:sched_waking]: 253 @[tracepoint:sched:sched_switch]: 510 ``` Count process-level events for five seconds, printing a summary. - sched: The `sched` probe category has high-level scheduler and process events, such as fork, exec, and context switch. - probe: The full name of the probe. - interval:s:5: This is a probe that fires once every 5 seconds, on one CPU only. It is used for creating script-level intervals or timeouts. - exit(): This exits bpftrace. # Lesson 9. Profile On-CPU Kernel Stacks ``` bpftrace -e 'profile:hz:99 { @[kstack] = count(); }' ``` Expected Output: ``` Attached 1 probe ^C [...] @[ filemap_map_pages+181 __handle_mm_fault+2905 handle_mm_fault+250 __do_page_fault+599 async_page_fault+69 ]: 12 [...] @[ cpuidle_enter_state+164 do_idle+390 cpu_startup_entry+111 start_secondary+423 secondary_startup_64+165 ]: 22122 ``` Profile kernel stacks at 99 Hertz, printing a frequency count. - profile:hz:99: This fires on all CPUs at 99 Hertz. Why 99 and not 100 or 1000? We want frequent enough to catch both the big and small picture of execution, but not too frequent as to perturb performance. 100 Hertz is enough. But we don't want 100 exactly, as sampling may occur in lockstep with other timed activities, hence 99. - kstack: Returns the kernel stack trace. This is used as a key for the map, so that it can be frequency counted. The output of this is ideal to be visualized as a flame graph. There is also `ustack` for the user-level stack trace. # Lesson 10. Scheduler Tracing ``` bpftrace -e 'tracepoint:sched:sched_switch { @[kstack] = count(); }' ``` Expected Output: ``` ^C [...] @[ __schedule+697 __schedule+697 schedule+50 schedule_timeout+365 xfsaild+274 kthread+248 ret_from_fork+53 ]: 73 @[ __schedule+697 __schedule+697 schedule_idle+40 do_idle+356 cpu_startup_entry+111 start_secondary+423 secondary_startup_64+165 ]: 305 ``` This counts stack traces that led to context switching (off-CPU) events. The above output has been truncated to show the last two only. - sched: The sched category has tracepoints for different kernel CPU scheduler events: sched_switch, sched_wakeup, sched_migrate_task, etc. - sched_switch: This probe fires when a thread leaves CPU. This will be a blocking event: eg, waiting on I/O, a timer, paging/swapping, or a lock. - kstack: A kernel stack trace. - sched_switch fires in thread context, so that the stack refers to the thread who is leaving. As you use other probe types, pay attention to context, as comm, pid, kstack, etc, may not refer to the target of the probe. # Lesson 11. Block I/O Tracing ``` bpftrace -e 'tracepoint:block:block_rq_issue { @ = hist(args.bytes); }' ``` Expected Output: ``` Attached 1 probe ^C @: [0, 1] 1 |@@ | [2, 4) 0 | | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 0 | | [64, 128) 0 | | [128, 256) 0 | | [256, 512) 0 | | [512, 1K) 0 | | [1K, 2K) 0 | | [2K, 4K) 0 | | [4K, 8K) 24 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [8K, 16K) 2 |@@@@ | [16K, 32K) 6 |@@@@@@@@@@@@@ | [32K, 64K) 5 |@@@@@@@@@@ | [64K, 128K) 0 | | [128K, 256K) 1 |@@ | ``` Block I/O requests by size in bytes, as a histogram. - tracepoint:block: The block category of tracepoints traces various block I/O (storage) events. - block_rq_issue: This fires when an I/O is issued to the device. - args.bytes: This is a member from the tracepoint block_rq_issue arguments which shows the size in bytes. The context of this probe is important: this fires when the I/O is issued to the device. This often happens in process context, where builtins like comm will show you the process name, but it can also happen from kernel context (eg, readahead) when the pid and comm will not show the application you expect. # Lesson 12. Kernel Struct Tracing ``` # cat path.bt #ifndef BPFTRACE_HAVE_BTF #include #include #endif kprobe:vfs_open { printf("open path: %s\n", str(((struct path *)arg0)->dentry->d_name.name)); } # bpftrace path.bt Attached 1 probe open path: dev open path: if_inet6 open path: retrans_time_ms [...] ``` This uses kernel dynamic tracing of the vfs_open() function, which has a (struct path *) as the first argument. - kprobe: As mentioned earlier, this is the kernel dynamic tracing probe type, which traces the entry of kernel functions (use kretprobe to trace their returns). - `arg0` is a builtin variable containing the first probe argument, the meaning of which is defined by the probe type. For `kprobe`, it is the first argument to the function. Other arguments can be accessed as arg1, ..., argN. - `((struct path *)arg0)->dentry->d_name.name`: this casts `arg0` as `struct path *`, then dereferences dentry, etc. - #include: these are necessary to include struct definitions for path and dentry on systems where the kernel was built without BTF (BPF Type Format) data. The kernel struct support is the same as bcc, making use of kernel headers. This means that many structs are available, but not everything, and sometimes it might be necessary to manually include a struct. For an example of this, see the [dcsnoop tool](../tools/dcsnoop.bt), which includes a portion of struct nameidata manually as it wasn't in the available headers. If the kernel has BTF data, all kernel structs are always available. At this point you understand much of bpftrace, and can begin to use and write powerful one-liners. See the [Manual](../man/adoc/bpftrace.adoc) for more capabilities. bpftrace-0.27.1/docs/tutorial_one_liners_chinese.md000066400000000000000000000377411526721631600224440ustar00rootroot00000000000000# bpftrace一行教程 该教程通过12个简å�•å°�节帮助你了解bpftrace的使用。æ¯�一å°�节都是一行的命令,你å�¯ä»¥å°�试è¿�行并立刻看到è¿�行效果。该教程系列用æ�¥ä»‹ç»�bpftrace的概念。关于bpftrace的完整å�‚考,è§�[bpftrace手册](../man/adoc/bpftrace.adoc)。 该教程贡献者是Brendan Gregg, Netflix (2018), 基于他的FreeBSD DTrace教程系列[DTrace Tutorial](https://wiki.freebsd.org/DTrace/Tutorial)。 # 1. 列出所有探针 ``` bpftrace -l 'tracepoint:syscalls:sys_enter_*' ``` "bpftrace -l" 列出所有探针,并且å�¯ä»¥æ·»åŠ æ�œç´¢é¡¹ã€‚ - 探针是用于æ�•获事件数æ�®çš„æ£€æµ‹ç‚¹ã€‚ - æ�œç´¢è¯�支æŒ�通é…�符,如`*`å’Œ`?`。 - "bpftrace -l" 也å�¯ä»¥é€šè¿‡ç®¡é�“传递给grep,进行完整的正则表达å¼�æ�œç´¢ã€‚ # 2. Hello World ``` # bpftrace -e 'BEGIN { printf("hello world\n"); }' Attached 1 probe hello world ^C ``` 打å�°æ¬¢è¿Žæ¶ˆæ�¯ã€‚è¿�行å�Ž, 按Ctrl-C结æ�Ÿã€‚ - `BEGIN`是一个特殊的探针,在程åº�开始时触å�‘探针执行(类似awkçš„BEGIN)。你å�¯ä»¥ä½¿ç”¨å®ƒè®¾ç½®å�˜é‡�和打å�°æ¶ˆæ�¯å¤´ã€‚ - 探针å�¯ä»¥å…³è�”动作,把动作放到{}中。这个例å­�中,探针被触å�‘时会调用printf()。 # 3. 文件打开 ``` # bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args.filename)); }' Attached 1 probe snmp-pass /proc/cpuinfo snmp-pass /proc/stat snmpd /proc/net/dev snmpd /proc/net/if_inet6 ^C ``` 这里我们在文件打开的时候打å�°è¿›ç¨‹å��和文件å��。 - 该命令以`tracepoint:syscalls:sys_enter_openat`开始: 这是tracepoint探针类型(内核é�™æ€�跟踪),当进入`openat()`系统调用时执行该探针。相比kprobes探针(内核动æ€�跟踪,在第6节介ç»�),我们更加喜欢用tracepoints探针,因为tracepoints有稳定的应用程åº�编程接å�£ã€‚注æ„�:现代linux系统(glibc >= 2.26),`open`总是调用`openat`系统调用。 - `comm`是内建å�˜é‡�,代表当å‰�进程的å��字。其它类似的å�˜é‡�还有pidå’Œtid,分别表示进程标识和线程标识。 - `args`是一个包å�«æ‰€æœ‰tracepointå�‚数的结构。这个结构是由bpftraceæ ¹æ�®tracepointä¿¡æ�¯è‡ªåŠ¨ç”Ÿæˆ�的。这个结构的æˆ�员å�¯ä»¥é€šè¿‡å‘½ä»¤`bpftrace -vl tracepoint:syscalls:sys_enter_openat`找到。 - `args.filename`用æ�¥èŽ·å�–argsçš„æˆ�员å�˜é‡�`filename`的值。 - `str()`用æ�¥æŠŠå­—符串指针转æ�¢æˆ�字符串。 # 4. 进程级系统调用计数 ``` bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }' Attached 1 probe ^C @[bpftrace]: 6 @[systemd]: 24 @[snmp-pass]: 96 @[sshd]: 125 ``` 按Ctrl-Cå�Žæ‰“å�°è¿›ç¨‹çš„系统调用计数。 - @: 表示一ç§�特殊的å�˜é‡�类型,称为map,å�¯ä»¥ä»¥ä¸�å�Œçš„æ–¹å¼�æ�¥å­˜å‚¨å’Œæ��è¿°æ•°æ�®ã€‚ä½ å�¯ä»¥åœ¨@å�Žæ·»åŠ å�¯é€‰çš„å�˜é‡�å��(如@num),用æ�¥å¢žåŠ å�¯è¯»æ€§æˆ–者区分ä¸�å�Œçš„map。 - []: å�¯é€‰çš„中括å�·å…�许设置map的关键字,比较åƒ�å…³è�”数组。 - count(): 这是一个map函数 - 记录被调用次数。因为调用次数根æ�®commä¿�存在map里,输出结果是进程执行系统调用的次数统计。 Maps会在bpftrace结æ�Ÿ(如按Ctrl-C)时自动打å�°å‡ºæ�¥ã€‚ # 5. read()返回值分布统计 ``` # bpftrace -e 'tracepoint:syscalls:sys_exit_read /pid == 18644/ { @bytes = hist(args.ret); }' Attached 1 probe ^C @bytes: [0, 1] 12 |@@@@@@@@@@@@@@@@@@@@ | [2, 4) 18 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 30 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64, 128) 19 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [128, 256) 1 |@ ``` 这里统计进程å�·ä¸º18644的进程执行内核函数sys_read()的返回值,并打å�°å‡ºç›´æ–¹å›¾ã€‚ - /.../: 这里设置一个过滤æ�¡ä»¶(æ�¡ä»¶åˆ¤æ–­),满足该过滤æ�¡ä»¶æ—¶æ‰�执行{}里é�¢çš„动作。在这个例å­�中æ„�æ€�是å�ªè¿½è¸ªè¿›ç¨‹å�·ä¸º18644的进程。过滤æ�¡ä»¶è¡¨è¾¾å¼�也支æŒ�布尔è¿�算,如("&&", "||")。 - ret: 表示函数的返回值。对于sys_read(),它å�¯èƒ½æ˜¯-1(错误)或者æˆ�功读å�–的字节数。 - @: 类似于上节的map,但是这里没有key,å�³[]。该mapçš„å��ç§°"bytes"会出现在输出中。 - hist(): 一个map函数,用æ�¥æ��述直方图的å�‚数。输出行以2次方的间隔开始,如`[128, 256)`表示值大于等于128且å°�于256。å�Žé�¢è·Ÿç�€ä½�于该区间的å�‚数个数统计,最å�Žæ˜¯asciiç �表示的直方图。该图å�¯ä»¥ç”¨æ�¥ç ”究它的模å¼�分布。 - 其它的map函数还有lhist(线性直方图),count(),sum(),avg(),min()å’Œmax()。 # 6. 内核动æ€�跟踪read()返回的字节数 ``` # bpftrace -e 'kretprobe:vfs_read { @bytes = lhist(retval, 0, 2000, 200); }' Attached 1 probe ^C @bytes: (...,0] 0 | | [0, 200) 66 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [200, 400) 2 |@ | [400, 600) 3 |@@ | [600, 800) 0 | | [800, 1000) 5 |@@@ | [1000, 1200) 0 | | [1200, 1400) 0 | | [1400, 1600) 0 | | [1600, 1800) 0 | | [1800, 2000) 0 | | [2000,...) 39 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ``` 使用内核动æ€�跟踪技术显示read()返回字节数的直方图。 - `kretprobe:vfs_read`: 这是kretprobe类型(动æ€�跟踪内核函数返回值)的探针,跟踪`vfs_read`内核函数。此外还有kprobe类型的探针(在下一节介ç»�)用于跟踪内核函数的调用。它们是功能强大的探针类型,让我们å�¯ä»¥è·Ÿè¸ªæˆ�å�ƒä¸Šä¸‡çš„内核函数。然而它们是"ä¸�稳定"的探针类型:由于它们å�¯ä»¥è·Ÿè¸ªä»»æ„�内核函数,对于ä¸�å�Œçš„内核版本,kprobeå’Œkretprobeä¸�一定能够正常工作。因为内核函数å��,å�‚数,返回值和作用等å�¯èƒ½ä¼šå�˜åŒ–。此外,由于它们用æ�¥è·Ÿè¸ªåº•层内核的,你需è¦�æµ�览内核æº�代ç �,ç�†è§£è¿™äº›æŽ¢é’ˆçš„å�‚数和返回值的æ„�义。 - lhist(): 线性直方图函数:å�‚数分别是value,最å°�值,最大值,步进值。第一个å�‚æ•°(`retval`)表示系统调用sys_read()返回值:å�³æˆ�功读å�–的字节数。 # 7. read()调用的时间 ``` # bpftrace -e 'kprobe:vfs_read { @start[tid] = nsecs; } kretprobe:vfs_read /@start[tid]/ { @ns[comm] = hist(nsecs - @start[tid]); delete(@start, tid); }' Attached 2 probes [...] @ns[snmp-pass]: [0, 1] 0 | | [2, 4) 0 | | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 0 | | [64, 128) 0 | | [128, 256) 0 | | [256, 512) 27 |@@@@@@@@@ | [512, 1k) 125 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [1k, 2k) 22 |@@@@@@@ | [2k, 4k) 1 | | [4k, 8k) 10 |@@@ | [8k, 16k) 1 | | [16k, 32k) 3 |@ | [32k, 64k) 144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64k, 128k) 7 |@@ | [128k, 256k) 28 |@@@@@@@@@@ | [256k, 512k) 2 | | [512k, 1M) 3 |@ | [1M, 2M) 1 | | ``` æ ¹æ�®è¿›ç¨‹å��,以直方图的形å¼�显示read()调用花费的时间,时间å�•ä½�为纳秒。 - @start[tid]: 使用线程ID作为key。æŸ�一时刻,å�¯èƒ½æœ‰è®¸è®¸å¤šå¤šçš„read调用正在进行,我们希望为æ¯�个调用记录一个起始时间戳。这è¦�如何å�šåˆ°å‘¢ï¼Ÿæˆ‘们å�¯ä»¥ä¸ºæ¯�个read调用建立一个唯一的标识符,并用它作为key进行统计。由于内核线程一次å�ªèƒ½æ‰§è¡Œä¸€ä¸ªç³»ç»Ÿè°ƒç”¨ï¼Œæˆ‘们å�¯ä»¥ä½¿ç”¨çº¿ç¨‹ID作为上述标识符。 - nsecs: 自系统å�¯åŠ¨åˆ°çŽ°åœ¨çš„çº³ç§’æ•°ã€‚è¿™æ˜¯ä¸€ä¸ªé«˜ç²¾åº¦æ—¶é—´æˆ³ï¼Œå�¯ä»¥ç”¨æ�¥å¯¹äº‹ä»¶è®¡æ—¶ã€‚ - /@start[tid]/: 该过滤æ�¡ä»¶æ£€æŸ¥èµ·å§‹æ—¶é—´æˆ³æ˜¯å�¦è¢«è®°å½•。程åº�å�¯èƒ½åœ¨æŸ�次read调用中途被å�¯åŠ¨ï¼Œå¦‚æžœæ²¡æœ‰è¿™ä¸ªè¿‡æ»¤æ�¡ä»¶ï¼Œè¿™ä¸ªè°ƒç”¨çš„æ—¶é—´ä¼šè¢«ç»Ÿè®¡ä¸ºnow-zero,而ä¸�是now-start。 - delete(@start, tid): 释放å�˜é‡�。 # 8. 统计进程级别的事件 ``` # bpftrace -e 'tracepoint:sched:sched* { @[probe] = count(); } interval:s:5 { exit(); }' Attached 25 probes @[tracepoint:sched:sched_wakeup_new]: 1 @[tracepoint:sched:sched_process_fork]: 1 @[tracepoint:sched:sched_process_exec]: 1 @[tracepoint:sched:sched_process_exit]: 1 @[tracepoint:sched:sched_process_free]: 2 @[tracepoint:sched:sched_process_wait]: 7 @[tracepoint:sched:sched_wake_idle_without_ipi]: 53 @[tracepoint:sched:sched_stat_runtime]: 212 @[tracepoint:sched:sched_wakeup]: 253 @[tracepoint:sched:sched_waking]: 253 @[tracepoint:sched:sched_switch]: 510 ``` 这里统计5秒内进程级的事件并打å�°ã€‚ - sched: `sched`探针å�¯ä»¥æŽ¢æµ‹è°ƒåº¦å™¨çš„高级事件和进程事件如fork, exec和上下文切æ�¢ã€‚ - probe: 探针的完整å��称。 - interval:s:5: 这是一个æ¯�5秒在æ¯�个CPU上触å�‘一次的探针,它用æ�¥åˆ›å»ºè„šæœ¬çº§åˆ«çš„é—´éš”æˆ–è¶…æ—¶æ—¶é—´ã€‚ - exit(): 退出bpftrace。 # 9. 分æž�内核实时函数栈 ``` # bpftrace -e 'profile:hz:99 { @[kstack] = count(); }' Attached 1 probe ^C [...] @[ filemap_map_pages+181 __handle_mm_fault+2905 handle_mm_fault+250 __do_page_fault+599 async_page_fault+69 ]: 12 [...] @[ cpuidle_enter_state+164 do_idle+390 cpu_startup_entry+111 start_secondary+423 secondary_startup_64+165 ]: 22122 ``` 以99赫兹的频率分æž�内核调用栈并打å�°æ¬¡æ•°ç»Ÿè®¡ã€‚ - profile:hz:99: 这里所有cpu都以99赫兹的频率采样分æž�内核栈。为什么是99而ä¸�是100或者1000?我们想è¦�抓å�–足够详细的内核执行时内核栈信æ�¯ï¼Œä½†æ˜¯é¢‘率太大影å“�性能。100赫兹足够了,但是我们ä¸�想用正好100赫兹,这样采样频率å�¯èƒ½ä¸Žå…¶ä»–定时事件步调一致,所以99赫兹是一个ç�†æƒ³çš„选择。 - kstack: 返回内核调用栈。这里作为map的关键字,å�¯ä»¥è·Ÿè¸ªæ¬¡æ•°ã€‚这些输出信æ�¯å�¯ä»¥ä½¿ç”¨ç�«ç„°å›¾å�¯è§†åŒ–。此外`ustack`用æ�¥åˆ†æž�用户级堆栈。 # 10. 调度器跟踪 ``` # bpftrace -e 'tracepoint:sched:sched_switch { @[kstack] = count(); }' ^C [...] @[ __schedule+697 __schedule+697 schedule+50 schedule_timeout+365 xfsaild+274 kthread+248 ret_from_fork+53 ]: 73 @[ __schedule+697 __schedule+697 schedule_idle+40 do_idle+356 cpu_startup_entry+111 start_secondary+423 secondary_startup_64+165 ]: 305 ``` 这里统计进程上下文切æ�¢æ¬¡æ•°ã€‚以上输出被截断,å�ªè¾“出了最å�Žä¸¤ä¸ªç»“果。 - sched: 跟踪调度类别的调度器事件:sched_switch, sched_wakeup, sched_migrate_task等。 - sched_switch: 当线程释放cpu资æº�,当å‰�ä¸�è¿�行时触å�‘。这里å�¯èƒ½çš„阻塞事件:如等待I/O,定时器,分页/交æ�¢ï¼Œé”�等。 - kstack: 内核堆栈跟踪,打å�°è°ƒç”¨æ ˆã€‚ - sched_switch在线程切æ�¢çš„æ—¶å€™è§¦å�‘,打å�°çš„调用栈是被切æ�¢å‡ºcpu的那个线程。åƒ�你使用其他探针一样,注æ„�这里的上下文,例如comm, pid, kstack等等,并ä¸�一定å��映了探针的目标的状æ€�。 # 11. å�—级I/O跟踪 ``` # bpftrace -e 'tracepoint:block:block_rq_issue { @ = hist(args.bytes); }' Attached 1 probe ^C @: [0, 1] 1 |@@ | [2, 4) 0 | | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 0 | | [64, 128) 0 | | [128, 256) 0 | | [256, 512) 0 | | [512, 1K) 0 | | [1K, 2K) 0 | | [2K, 4K) 0 | | [4K, 8K) 24 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [8K, 16K) 2 |@@@@ | [16K, 32K) 6 |@@@@@@@@@@@@@ | [32K, 64K) 5 |@@@@@@@@@@ | [64K, 128K) 0 | | [128K, 256K) 1 |@@ | ``` 以上是å�—I/O请求字节数的直方图。 - tracepoint:block: å�—类别的跟踪点跟踪å�—级I/O事件。 - block_rq_issue: 当I/Oæ��交到å�—设备时触å�‘。 - args.bytes: 跟踪点block_rq_issueçš„å�‚æ•°æˆ�员bytes,表示æ��交I/O请求的字节数。 该探针的上下文是é�žå¸¸é‡�è¦�çš„: 它在I/O请求被æ��交给å�—设备时触å�‘。这通常å�‘生在进程上下文,此时通过内核的commå�¯ä»¥å¾—到进程å��;也å�¯èƒ½å�‘生在内核上下文,(如readahead),此时ä¸�能显示预期的进程å�·å’Œè¿›ç¨‹å��ä¿¡æ�¯ã€‚ # 12. 内核结构跟踪 ``` # cat path.bt #ifndef BPFTRACE_HAVE_BTF #include #include #endif kprobe:vfs_open { printf("open path: %s\n", str(((struct path *)arg0)->dentry->d_name.name)); } # bpftrace path.bt Attached 1 probe open path: dev open path: if_inet6 open path: retrans_time_ms [...] ``` 这里使用内核动æ€�跟踪技术跟踪vfs_read()函数,该函数的(struct path *)作为第一个å�‚数。 - kprobe: 如å‰�é�¢æ‰€è¿°ï¼Œè¿™æ˜¯å†…核动æ€�跟踪kprobe探针类型,跟踪内核函数的调用(kretprobe探针类型跟踪内核函数返回值)。 - `arg0` 是一个内建å�˜é‡�,表示探针的第一个å�‚数,其å�«ä¹‰ç”±æŽ¢é’ˆç±»åž‹å†³å®šã€‚对于`kprobe`类型探针,它表示函数的第一个å�‚数。其它å�‚数使用arg1,...,argN访问。 - `((struct path *)arg0)->dentry->d_name.name`: 这里`arg0`作为`struct path *`并引用dentry。 - #include: 在没有BTF (BPF Type Format) 的情况下,包å�«å¿…è¦�çš„pathå’Œdentry类型声明的头文件。 bpftrace对内核结构跟踪的支æŒ�å’Œbcc是一样的,å…�许使用内核头文件。这æ„�味ç�€å¤§å¤šæ•°ç»“构是å�¯ç”¨çš„,但是并ä¸�是所有的,有时需è¦�手动增加æŸ�些结构的声明。例如这个例å­�,è§�[dcsnoop tool](../tools/dcsnoop.bt),包å�«struct nameidata的声明。倘若内核有æ��ä¾›BTFæ•°æ�®ï¼Œåˆ™æ‰€æœ‰ç»“构都å�¯ç”¨ã€‚ 现在,你已ç»�ç�†è§£äº†bpftrace的大部分功能,你å�¯ä»¥å¼€å§‹ä½¿ç”¨å’Œç¼–写强大的一行命令。查阅[使用说明书](../man/adoc/bpftrace.adoc)更多的功能。 bpftrace-0.27.1/docs/tutorial_one_liners_japanese.md000066400000000000000000000526761526721631600226200ustar00rootroot00000000000000# bpftrace ワンライナーãƒ�ュートリアル 12個ã�®ç°¡å�˜ã�ªãƒ¬ãƒƒã‚¹ãƒ³ã�§ Linux ã�® bpftrace ã‚’å­¦ã�³ã�¾ã�—ょã�†ï¼Žå�„レッスンã�¯ãƒ¯ãƒ³ãƒ©ã‚¤ãƒŠãƒ¼ã�§ã�™ï¼Žã�™ã��ã�«è©¦ã�™ã�“ã�¨ã�Œã�§ã��,一連ã�®ãƒ¯ãƒ³ãƒ©ã‚¤ãƒŠãƒ¼ã�§ bpftrace ã�®è¦�点ã�Œåˆ†ã�‹ã‚Šã�¾ã�™ï¼Žbpftrace ã�®è©³ç´°ã�¯[インストラクションマニュアル](../man/adoc/bpftrace.adoc)ã‚’å�‚ç…§ã�—ã�¦ä¸‹ã�•ã�„. - 執筆:Brendan Gregg, Netflix (2018).FreeBSD [DTrace Tutorial](https://wiki.freebsd.org/DTrace/Tutorial)(Brendan Gregg 著)ã�«åŸºã�¥ã��. - 原文:[The bpftrace One-Liner Tutorial](https://github.com/bpftrace/bpftrace/blob/master/docs/tutorial_one_liners.md) # レッスン 1. プローブã�®è¡¨ç¤º ``` bpftrace -l 'tracepoint:syscalls:sys_enter_*' ``` "bpftrace -l" ã�¯å…¨ã�¦ã�®ãƒ—ローブを表示ã�—ã�¾ã�™ï¼Žå¾Œã‚�ã�«æ¤œç´¢èªžã‚’付ã�‘ã‚‹ã�“ã�¨ã�Œã�§ã��ã�¾ã�™ï¼Ž - プローブã�¯ã‚¤ãƒ™ãƒ³ãƒˆãƒ‡ãƒ¼ã‚¿ã‚’æ�•æ�‰ã�™ã‚‹ã�Ÿã‚�ã�®è¨ˆè£…点ã�§ã�™ï¼Ž - 検索語ã�«ã�¯ãƒ¯ã‚¤ãƒ«ãƒ‰ã‚«ãƒ¼ãƒ‰ï¼�グロブ(`*`å�Šã�³`?`)ã�Œä½¿ç”¨ã�§ã��ã�¾ã�™ï¼Ž - 完全ã�ªæ­£è¦�表ç�¾ã‚’利用ã�—ã�Ÿã�„å ´å�ˆã�¯ "bpftrace -l" ã�®å‡ºåŠ›ã‚’ grep(1) ã�«ãƒ‘イプã�§ã��ã�¾ã�™ï¼Ž # レッスン 2. Hello World ``` # bpftrace -e 'BEGIN { printf("hello world\n"); }' Attached 1 probe hello world ^C ``` "hello world" を表示ã�—ã�¾ã�™ï¼ŽCtrl-Cã�§å®Ÿè¡Œã‚’終了ã�—ã�¾ã�™ï¼Ž - `BEGIN`ã�¯ç‰¹åˆ¥ã�ªãƒ—ローブã�§ï¼Œãƒ—ログラムã�®é–‹å§‹æ™‚ã�«ã‚¤ãƒ™ãƒ³ãƒˆã�Œç™ºç”Ÿã�—ã�¾ã�™ï¼ˆawk ã�® BEGIN ã�¨å�Œæ§˜ã�§ã�™ï¼‰ï¼Žå¤‰æ•°ã�®åˆ�期化やヘッダã�®å‡ºåŠ›ã�«åˆ©ç”¨ã�§ã��ã�¾ã�™ï¼Ž - { } ã�®ä¸­ã�§ãƒ—ローブã�«é–¢é€£ä»˜ã�‘るアクションを定義ã�—ã�¾ã�™ï¼Žã�“ã�®ä¾‹ã�§ã�¯ã‚¤ãƒ™ãƒ³ãƒˆã�Œç™ºç”Ÿã�—ã�Ÿã�¨ã��ã�« printf() を実行ã�—ã�¾ã�™ï¼Ž # レッスン 3. ファイルã�®ã‚ªãƒ¼ãƒ—ン ``` # bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args.filename)); }' Attached 1 probe snmp-pass /proc/cpuinfo snmp-pass /proc/stat snmpd /proc/net/dev snmpd /proc/net/if_inet6 ^C ``` ファイルã�®ã‚ªãƒ¼ãƒ—ンã�®ç™ºç”Ÿã‚’トレースã�—,ã��ã�®ã�¨ã��ã�®ãƒ—ロセスå��ã�¨ãƒ•ァイルã�®ãƒ‘スå��を表示ã�—ã�¾ã�™ï¼Ž - `tracepoint:syscalls:sys_enter_openat` ã�¯ tracepoint プローブ(カーãƒ�ルã�®é�™çš„トレーシング)ã�§ã�™ï¼Žã�“れã�«ã‚ˆã‚Š `openat()` システムコール呼ã�³å‡ºã�—時ã�«ã‚¤ãƒ™ãƒ³ãƒˆã�Œç™ºç”Ÿã�—ã�¾ã�™ï¼ŽTracepoint ã�® API ã�¯å®‰å®šæ€§ã�Œä¿�証ã�•れã�¦ã�„ã‚‹ã�Ÿã‚�,kprobe(カーãƒ�ルã�®å‹•的トレーシング,レッスン6ã�§ç´¹ä»‹ï¼‰ã‚ˆã‚Šã‚‚利用ã�ŒæŽ¨å¥¨ã�•れã�¾ã�™ï¼Žã�ªã�Šï¼Œæœ€è¿‘ã�® Linux(カーãƒ�ル2.26以上)ã�§ã�¯ `open` 関数ã�¯å¸¸ã�« `openat` システムコールを呼ã�³ã�¾ã�™ï¼Ž - `comm` ã�¯ãƒ“ルトイン変数ã�®ä¸€ã�¤ã�§ï¼Œç�¾åœ¨ã�®ãƒ—ロセスå��ã‚’ä¿�æŒ�ã�—ã�¾ã�™ï¼Žå�Œæ§˜ã�®ãƒ“ルトイン変数ã�« pid ã‚„ tid ã�Œã�‚りã�¾ã�™ï¼Ž - `args` ã�¯å¯¾è±¡ã�® tracepoint ã�®å…¨ã�¦ã�®å¼•æ•°ã‚’å�«ã‚€æ§‹é€ ä½“ã�¸ã�®ãƒ�インタã�§ã�™ï¼Žã�“ã�®æ§‹é€ ä½“ã�¯ tracepoint ã�®æƒ…å ±ã�«åŸºã�¥ã�„ã�¦ bpftrace ã�Œè‡ªå‹•ã�§ç”Ÿæˆ�ã�—ã�¾ã�™ï¼Žæ§‹é€ ä½“ã�®ãƒ¡ãƒ³ãƒ�ã�®æƒ…å ±ã�¯ `bpftrace -vl tracepoint:syscalls:sys_enter_openat` ã�§èª¿ã�¹ã‚‹ã�“ã�¨ã�Œã�§ã��ã�¾ã�™ï¼Ž - `args.filename` ã�¯ `args` 構造体をå�‚ç…§ã�—ã�¦ãƒ¡ãƒ³ãƒ�変数 `filename` ã�®å€¤ã‚’å�–å¾—ã�—ã�¾ã�™ï¼Ž - `str()` ã�¯ãƒ�インタを文字列ã�«å¤‰æ�›ã�—ã�¾ã�™ï¼Žï¼ˆè¨³æ³¨ï¼šbpftrace ã�¯ãƒ�インタã�¨æ–‡å­—列を別々ã�®ã‚‚ã�®ã�¨ã�—ã�¦æ‰±ã�„ã�¾ã�™ï¼Žprintf("%s") ã�®å¼•æ•°ã�«ã�¯æ–‡å­—列を与ã�ˆã‚‹å¿…è¦�ã�Œã�‚りã�¾ã�™ï¼Ž ) # レッスン 4. プロセスã�”ã�¨ã�®ã‚·ã‚¹ãƒ†ãƒ ã‚³ãƒ¼ãƒ«å‘¼ã�³å‡ºã�—回数 ``` bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }' Attached 1 probe ^C @[bpftrace]: 6 @[systemd]: 24 @[snmp-pass]: 96 @[sshd]: 125 ``` プロセスã�”ã�¨ã�«ã‚·ã‚¹ãƒ†ãƒ ã‚³ãƒ¼ãƒ«å‘¼ã�³å‡ºã�—ã�®å›žæ•°ã‚’計数ã�—ã�¾ã�™ï¼Žé›†è¨ˆçµ�æžœã�¯ Ctrl-C ã�§ãƒ—ログラムを終了ã�—ã�Ÿéš›ã�«è¡¨ç¤ºã�•れã�¾ã�™ï¼Ž - @: ã�“れã�¯ãƒžãƒƒãƒ—ã�¨å‘¼ã�°ã‚Œã‚‹ç‰¹æ®Šã�ªå¤‰æ•°ã�§ã�™ï¼Žãƒžãƒƒãƒ—ã�¯ã�•ã�¾ã�–ã�¾ã�ªæ–¹æ³•ã�§ãƒ‡ãƒ¼ã‚¿ã�®æ ¼ç´�や集計ã�Œã�§ã��ã�¾ã�™ï¼Ž@ ã�®å¾Œã‚�ã�«å¤‰æ•°å��(例ã�ˆã�° "@num")を付ã�‘ã‚‹ã�“ã�¨ã‚‚ã�§ã��ã�¾ã�™ï¼Žã�“れã�«ã‚ˆã‚Šå�¯èª­æ€§ã‚„識別性をå�‘上ã�§ã��ã�¾ã�™ï¼Ž - []: マップã�®å¾Œã‚�ã�«å¤§æ‹¬å¼§ã‚’ã�¤ã�‘ã‚‹ã�¨ï¼Œé€£æƒ³é…�列ã�®ã‚ˆã�†ã�«ã‚­ãƒ¼ã�ŒæŒ‡å®šã�§ã��ã�¾ã�™ï¼Žã�“れã�¯çœ�ç•¥å�¯èƒ½ã�§ã�™ï¼Ž - count(): ã�“れã�¯ãƒžãƒƒãƒ—ã�«å¯¾ã�™ã‚‹é–¢æ•°ã�®ä¸€ã�¤ã�§ï¼Œå‘¼ã�³å‡ºã�•れã�Ÿå›žæ•°ã‚’計数ã�—ã�¾ã�™ï¼Žä»Šå›žã�®å ´å�ˆãƒžãƒƒãƒ—ã�«ã�¯ comm をキーã�¨ã�—ã�¦ count() ã�®å€¤ã�Œä¿�å­˜ã�•れã�¾ã�™ï¼Žçµ�æžœã�¨ã�—ã�¦ãƒ—ロセスã�”ã�¨ã�®ã‚·ã‚¹ãƒ†ãƒ ã‚³ãƒ¼ãƒ«å‘¼ã�³å‡ºã�—ã�®å›žæ•°ã�Œè¨ˆæ•°ã�•れã�¾ã�™ï¼Ž マップã�«æ ¼ç´�ã�•れã�Ÿå€¤ã�¯ bpftrace ã�Œçµ‚了ã�—ã�Ÿã�¨ã��(Ctrl-Cを押ã�—ã�Ÿã�¨ã��ã�ªã�©ï¼‰ã�«è‡ªå‹•ã�§è¡¨ç¤ºã�•れã�¾ã�™ï¼Ž # レッスン 5. read() ã�®ãƒ�イト数ã�®åˆ†å¸ƒ ``` # bpftrace -e 'tracepoint:syscalls:sys_exit_read /pid == 18644/ { @bytes = hist(args.ret); }' Attached 1 probe ^C @bytes: [0, 1] 12 |@@@@@@@@@@@@@@@@@@@@ | [2, 4) 18 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 30 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64, 128) 19 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [128, 256) 1 |@ ``` PID 18644 ã�®ãƒ—ロセスã�«ã‚ˆã‚‹ã‚«ãƒ¼ãƒ�ル関数 sys_read() ã�®æˆ»ã‚Šå€¤ã‚’ヒストグラムã�«ã�¾ã�¨ã‚�ã�¾ã�™ï¼Ž - /.../: ã�“れã�¯ãƒ•ィルタ(述語ã�¨ã‚‚ã�„ã�†ï¼‰ã�§ã�™ï¼Žã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã�¯ã�“ã�®ãƒ•ィルタå¼�ã�ŒçœŸã�®ã�¨ã��ã�®ã�¿å®Ÿè¡Œã�•れã�¾ã�™ï¼Žä»Šå›žã�®å ´å�ˆã�¯PIDã�Œ18644ã�®ã�¨ã��ã�«ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã�Œå®Ÿè¡Œã�•れã�¾ã�™ï¼Žãƒ•ィルタ内ã�§ã�¯ãƒ–ール値ã�®ã‚ªãƒšãƒ¬ãƒ¼ã‚¿ãƒ¼ï¼ˆ"&&", "||")ã�Œåˆ©ç”¨ã�§ã��ã�¾ã�™ï¼Ž - ret: 関数ã�®æˆ»ã‚Šå€¤ã‚’æ„�味ã�—ã�¾ã�™ï¼Ž sys_read() ã�®å ´å�ˆï¼Œæˆ»ã‚Šå€¤ã�¯ -1 (エラー)ã�‹ï¼Œread ã�«æˆ�功ã�—ã�Ÿãƒ�イト数ã�§ã�™ï¼Ž - @: å‰�ã�®ãƒ¬ãƒƒã‚¹ãƒ³ã�¨å�Œæ§˜ã�«ãƒžãƒƒãƒ—ã�§ã�™ï¼Žä»Šå›žã�¯ã‚­ãƒ¼ï¼ˆå¤§æ‹¬å¼§ï¼‰ã�Œç„¡ã��,"bytes" ã�¨ã�„ã�†å��å‰�ã�Œã�¤ã�„ã�¦ã�„ã�¾ã�™ï¼Žã�“ã�®å��å‰�ã�¯æœ€å¾Œã�®çµ�æžœã�®å‡ºåŠ›ã�®ã�¨ã��ã�«è¡¨ç¤ºã�•れã�¾ã�™ï¼Ž - hist(): 底2ã�®å¯¾æ•°ã‚¹ã‚±ãƒ¼ãƒ«ã�®ãƒ’ストグラムã�¨ã�—ã�¦å€¤ã‚’集計ã�™ã‚‹ãƒžãƒƒãƒ—関数ã�§ã�™ï¼Žå‡ºåŠ›ã�®è¡Œã�®å…ˆé ­ã�¯å€¤ã�®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ�ルを示ã�—ã�¾ã�™ï¼Žä¾‹ã�ˆã�°ï¼Œ`[128, 256)` ã�¯å€¤ã�Œ128以上256未満ã�§ã�‚ã‚‹ã�“ã�¨ã‚’æ„�味ã�—ã�¾ã�™ï¼Žã��ã�®æ¨ªã�¯ç™ºç”Ÿå›žæ•°å�Šã�³ï¼ŒASCII文字ã�«ã‚ˆã‚‹ç™ºç”Ÿå›žæ•°ã�®ãƒ’ストグラムã�§ã�™ï¼Žãƒ’ストグラムã�¯ã�®åˆ†å¸ƒã�®å¤šå³°æ€§ã�®èª¿æŸ»ã�«æ´»ç”¨ã�§ã��ã�¾ã�™ï¼Ž - ä»–ã�®ãƒžãƒƒãƒ—関数ã�¨ã�—ã�¦ lhist()(線形スケールã�®ãƒ’ストグラム),sum(),avg(),min() ã��ã�—ã�¦ max() ã�Œã�‚りã�¾ã�™ï¼Ž # レッスン 6. カーãƒ�ル動的トレーシングã�«ã‚ˆã‚‹ read() ã�®ãƒ�イト数ã�®é›†è¨ˆ ``` # bpftrace -e 'kretprobe:vfs_read { @bytes = lhist(retval, 0, 2000, 200); }' Attached 1 probe ^C @bytes: (...,0] 0 | | [0, 200) 66 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [200, 400) 2 |@ | [400, 600) 3 |@@ | [600, 800) 0 | | [800, 1000) 5 |@@@ | [1000, 1200) 0 | | [1200, 1400) 0 | | [1400, 1600) 0 | | [1600, 1800) 0 | | [1800, 2000) 0 | | [2000,...) 39 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ``` read() ã�®ãƒ�イト数を線形スケールã�®ãƒ’ストグラムã�¨ã�—ã�¦é›†è¨ˆã�—ã�¾ã�™ï¼Žãƒˆãƒ¬ãƒ¼ã‚¹ã�«ã�¯ã‚«ãƒ¼ãƒ�ルã�®å‹•的トレーシングを利用ã�—ã�¾ã�™ï¼Ž - `kretprobe:vfs_read` ã�¯ kretprobe プローブ(関数ã�®æˆ»ã‚Šã�«å¯¾ã�™ã‚‹ã‚«ãƒ¼ãƒ�ル動的トレーシング)を `vfs_read()` カーãƒ�ル関数ã�«è¨­å®šã�—ã�¾ã�™ï¼Žé–¢æ•°ã�®å®Ÿè¡Œé–‹å§‹æ™‚ã�«ã‚¤ãƒ™ãƒ³ãƒˆã‚’発生ã�•ã�›ã‚‹ kprobe プローブ(次ã�®ãƒ¬ãƒƒã‚¹ãƒ³ã�§ç´¹ä»‹ï¼‰ã‚‚ã�‚りã�¾ã�™ï¼Žã�“れらã�¯å¼·åŠ›ã�ªãƒ—ローブタイプã�§ï¼Œæ•°ä¸‡ã�®ç•°ã�ªã‚‹ã‚«ãƒ¼ãƒ�ル関数をトレースã�™ã‚‹ã�“ã�¨ã�Œã�§ã��ã�¾ã�™ï¼Žã�—ã�‹ã�—ã�“れらã�¯ã€Œä¸�安定ã€�ã�ªãƒ—ローブã�§ã�™ï¼Žã�ªã�œã�ªã‚‰ï¼Œã‚«ãƒ¼ãƒ�ル関数ã�®å��称,引数,戻り値,ã��ã�—ã�¦å½¹å‰²ã�¯ã‚«ãƒ¼ãƒ�ルãƒ�ージョンã�”ã�¨ã�«å¤‰ã‚�ã‚‹å�¯èƒ½æ€§ã�Œã�‚ã‚‹ã�Ÿã‚�ã�§ã�™ï¼Žkprobe/kretprobe ã�Œç•°ã�ªã‚‹ã‚«ãƒ¼ãƒ�ルã�§å‹•作ã�™ã‚‹ä¿�証ã�¯ã�‚りã�¾ã�›ã‚“.ã�¾ã�Ÿï¼Œç”Ÿã�®ã‚«ãƒ¼ãƒ�ル関数をトレースã�™ã‚‹ã�“ã�¨ã�«ã�ªã‚‹ã�Ÿã‚�,プローブや引数,戻り値ã�®æ„�味をç�†è§£ã�™ã‚‹ã�Ÿã‚�ã�«ã�¯ã‚«ãƒ¼ãƒ�ルã�®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã‚’å�‚ç…§ã�™ã‚‹å¿…è¦�ã�Œã�‚ã‚‹ã�§ã�—ょã�†ï¼Ž - lhist(): 線形スケールã�®ãƒ’ストグラムを作æˆ�ã�—ã�¾ã�™ï¼Žå¼•æ•°ã�¯ 値,最å°�値,最大値,ステップ ã�§ã�™ï¼Žæœ€åˆ�ã�®å¼•数(`retval`)ã�¯ vfs_read() ã�®æˆ»ã‚Šå€¤ã�§ï¼Œã�“れã�¯èª­ã�¿å‡ºã�—ã�Ÿãƒ�イト数ã�§ã�™ï¼Ž # レッスン 7. read() ã�®å®Ÿè¡Œæ™‚é–“ã�®æ¸¬å®š ``` # bpftrace -e 'kprobe:vfs_read { @start[tid] = nsecs; } kretprobe:vfs_read /@start[tid]/ { @ns[comm] = hist(nsecs - @start[tid]); delete(@start, tid); }' Attached 2 probes [...] @ns[snmp-pass]: [0, 1] 0 | | [2, 4) 0 | | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 0 | | [64, 128) 0 | | [128, 256) 0 | | [256, 512) 27 |@@@@@@@@@ | [512, 1k) 125 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [1k, 2k) 22 |@@@@@@@ | [2k, 4k) 1 | | [4k, 8k) 10 |@@@ | [8k, 16k) 1 | | [16k, 32k) 3 |@ | [32k, 64k) 144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [64k, 128k) 7 |@@ | [128k, 256k) 28 |@@@@@@@@@@ | [256k, 512k) 2 | | [512k, 1M) 3 |@ | [1M, 2M) 1 | | ``` read() ã�®å®Ÿè¡Œæ™‚間をナノ秒å�˜ä½�ã�§è¨ˆæ¸¬ã�—,プロセスã�”ã�¨ã�«ãƒ’ストグラムã�§é›†è¨ˆã�—ã�¾ã�™ï¼Ž - @start[tid]: ã�“れã�¯ãƒžãƒƒãƒ—ã�®ã‚­ãƒ¼ã�«ã‚¹ãƒ¬ãƒƒãƒ‰IDを利用ã�—ã�¦ã�„ã�¾ã�™ï¼Žread ã�¯å�Œæ™‚ã�«è¤‡æ•°å®Ÿè¡Œã�•れるå�¯èƒ½æ€§ã�Œã�‚りã�¾ã�™ï¼Žã��れã�žã‚Œã�®é–‹å§‹æ™‚刻をã�©ã�†ä¿�å­˜ã�™ã‚Œã�°è‰¯ã�„ã�§ã�—ょã�†ã�‹ï¼Ÿã��れã�žã‚Œã�® read ã�«å¯¾ã�—ã�¦ä¸€æ„�ã�®è­˜åˆ¥å­�ã�Œç”Ÿæˆ�ã�§ã��れã�°ï¼Œã��れをキーã�¨ã�—ã�¦åˆ©ç”¨ã�§ã��ã�¾ã�™ï¼Žã�‚るカーãƒ�ルスレッドã�¯ä¸€åº¦ã�«ä¸€ã�¤ã�®ã‚·ã‚¹ãƒ†ãƒ ã‚³ãƒ¼ãƒ«ã�—ã�‹å®Ÿè¡Œã�§ã��ã�ªã�„ã�Ÿã‚�,スレッドIDを一æ„�ã�®è­˜åˆ¥å­�ã�¨ã�—ã�¦åˆ©ç”¨ã�§ã��ã�¾ã�™ï¼Ž - nsecs: マシン起動ã�‹ã‚‰ã�®ãƒŠãƒŽç§’ã‚’æ„�味ã�—ã�¾ã�™ï¼Žã�“れã�¯é«˜ç²¾åº¦ã�®ã‚¿ã‚¤ãƒ ã‚¹ã‚¿ãƒ³ãƒ—カウンターã�®å€¤ã�§ï¼Œã‚¤ãƒ™ãƒ³ãƒˆæ™‚刻ã�®æ¸¬å®šã�«åˆ©ç”¨ã�§ã��ã�¾ã�™ï¼Ž - /@start[tid]/: ã�“ã�®ãƒ•ィルタã�¯é–‹å§‹æ™‚é–“ã�Œè¨˜éŒ²ã�•れã�¦ã�„ã‚‹ã�‹ã‚’ãƒ�ェックã�—ã�¾ã�™ï¼Žã�“ã�®ãƒ•ィルタã�Œç„¡ã�„å ´å�ˆï¼Œã�“ã�®ãƒ—ログラムã�¯ã�‚ã‚‹ read ã�®é–‹å§‹å¾Œã�«å®Ÿè¡Œã�•れ,ã��ã�® read ã�®çµ‚了ã�®ã‚¤ãƒ™ãƒ³ãƒˆã�®ã�¿ã‚’æ�•æ�‰ã�™ã‚‹å�¯èƒ½æ€§ã�Œã�‚りã�¾ã�™ï¼Žã�“ã�®å ´å�ˆï¼Œçµ�æžœã�¨ã�—ã�¦ ç�¾åœ¨æ™‚刻 - 開始時間ã�§ã�¯ã�ªã��,ç�¾åœ¨æ™‚刻 - 0 を計算ã�™ã‚‹ã�“ã�¨ã�«ã�ªã‚Šã�¾ã�™ï¼Žï¼ˆè¨³æ³¨ï¼šå­˜åœ¨ã�—ã�ªã�„キーã�«å¯¾ã�™ã‚‹ãƒžãƒƒãƒ—アクセスã�¯0ã‚’è¿”ã�—ã�¾ã�™ï¼‰ - delete(@start, tid): 変数を解放ã�—ã�¾ã�™ï¼Žï¼ˆè¨³æ³¨ï¼šdelete ã‚’ã�—ã�Ÿãƒžãƒƒãƒ—ã�®å€¤ã�¯ï¼Œãƒ—ログラム終了時ã�«è¡¨ç¤ºã�•れã�¾ã�›ã‚“.) # レッスン 8. プロセスレベルã�®ã‚¤ãƒ™ãƒ³ãƒˆã�®è¨ˆæ•° ``` # bpftrace -e 'tracepoint:sched:sched* { @[probe] = count(); } interval:s:5 { exit(); }' Attached 25 probes @[tracepoint:sched:sched_wakeup_new]: 1 @[tracepoint:sched:sched_process_fork]: 1 @[tracepoint:sched:sched_process_exec]: 1 @[tracepoint:sched:sched_process_exit]: 1 @[tracepoint:sched:sched_process_free]: 2 @[tracepoint:sched:sched_process_wait]: 7 @[tracepoint:sched:sched_wake_idle_without_ipi]: 53 @[tracepoint:sched:sched_stat_runtime]: 212 @[tracepoint:sched:sched_wakeup]: 253 @[tracepoint:sched:sched_waking]: 253 @[tracepoint:sched:sched_switch]: 510 ``` 5秒間プロセスレベルã�®ã‚¤ãƒ™ãƒ³ãƒˆã‚’計数ã�—,サマリを出力ã�—ã�¾ã�™ï¼Ž - sched: tracepoint ã�® `sched` プローブカテゴリã�«ã�¯ï¼Œfork ã‚„ exec,コンテキストスイッãƒ�ã�ªã�©ã�®é«˜ä½�ã�®ã‚¹ã‚±ã‚¸ãƒ¥ãƒ¼ãƒ©ã�¨ãƒ—ロセスã�«é–¢ã�™ã‚‹ã‚¤ãƒ™ãƒ³ãƒˆã�Œã�‚りã�¾ã�™ï¼Ž - probe: プローブã�®æ­£å¼�å��ã‚’ä¿�æŒ�ã�™ã‚‹ãƒ“ルトイン変数ã�§ã�™ï¼Žï¼ˆè¨³æ³¨ï¼š`tracepoint:sched:sched*` ã�¯ãƒžãƒƒãƒ�ã�—ã�Ÿå…¨ã�¦ã�®ãƒ—ローブã�«ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’ç´�付ã�‘ã�¾ã�™ï¼Žprobe を利用ã�—ã�¦ï¼Œå®Ÿéš›ã�®ãƒ—ローブã�®å��称をプログラム内ã�‹ã‚‰å�‚ç…§ã�§ã��ã�¾ã�™ï¼Žï¼‰ - interval:s:5: ã�‚る一ã�¤ã�®CPU上ã�§5ç§’é–“ã�«ä¸€åº¦å®Ÿè¡Œã�•れるプローブã�§ã�™ï¼Žã‚¹ã‚¯ãƒªãƒ—トã�«ã‚ˆã‚‹ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ�ルã�‚ã‚‹ã�„ã�¯ã‚¿ã‚¤ãƒ ã‚¢ã‚¦ãƒˆã‚¤ãƒ™ãƒ³ãƒˆã�®ä½œæˆ�ã�«åˆ©ç”¨ã�§ã��ã�¾ã�™ï¼Ž - exit(): bpftrace を終了ã�—ã�¾ã�™ï¼Ž # レッスン 9. CPU上ã�®ã‚«ãƒ¼ãƒ�ルスタックã�®ãƒ—ロファイリング ``` # bpftrace -e 'profile:hz:99 { @[kstack] = count(); }' Attached 1 probe ^C [...] @[ filemap_map_pages+181 __handle_mm_fault+2905 handle_mm_fault+250 __do_page_fault+599 async_page_fault+69 ]: 12 [...] @[ cpuidle_enter_state+164 do_idle+390 cpu_startup_entry+111 start_secondary+423 secondary_startup_64+165 ]: 22122 ``` 99ヘルツã�§ã‚«ãƒ¼ãƒ�ルスタックã�®ãƒ—ロファイリングをã�Šã�“ã�ªã�„,ã��ã�®å‡ºç�¾é »åº¦ã‚’出力ã�—ã�¾ã�™ï¼Ž - profile:hz:99: å…¨ã�¦ã�®CPU上ã�§99ヘルツã�§ã‚¤ãƒ™ãƒ³ãƒˆã�Œç™ºç”Ÿã�—ã�¾ã�™ï¼Žä½•æ•…100ã‚„1000ã�§ã�¯ã�ªã��99ã�§ã�—ょã�†ã�‹ï¼Ÿãƒ—ロファイル頻度ã�¯å®Ÿè¡Œã‚’俯瞰的ã�«ã‚‚局所的ã�«ã‚‚æ�‰ã�ˆã‚‹ã�“ã�¨ã�Œã�§ã��ã‚‹ã�»ã�©å��分ã�‹ã�¤ï¼Œãƒ‘フォーマンスを乱ã�•ã�ªã�„程度ã�§ã�‚ã‚‹å¿…è¦�ã�Œã�‚りã�¾ã�™ï¼Ž100ヘルツã�¯å��分ã�ªé »åº¦ã�§ã�™ã�Œï¼Œ100ã�®å ´å�ˆä»–ã�®ã‚¿ã‚¤ãƒžã�«ã‚ˆã‚‹ãƒ­ãƒƒã‚¯é–“éš”ã�¨å�Œã�˜é »åº¦ã�§ã‚µãƒ³ãƒ—リングã�•れるå�¯èƒ½æ€§ã�Œã�‚りã�¾ã�™ï¼Žã��ã�“ã�§99を利用ã�—ã�¾ã�™ï¼Ž - kstack: カーãƒ�ルã�®ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã‚’è¿”ã�—ã�¾ã�™ï¼Žã�“れã�¯ãƒžãƒƒãƒ—ã�®ã‚­ãƒ¼ã�¨ã�—ã�¦åˆ©ç”¨å�¯èƒ½ã�§ï¼Œcount() ã�¨å�ˆã‚�ã�›ã�¦é »åº¦ã�®è¨ˆæ•°ã�Œã�§ã��ã�¾ã�™ï¼Žã�“ã�®å‡ºåŠ›ã�¯ flame graph ã�¨ã�—ã�¦å�¯è¦–化ã�™ã‚‹ã�®ã�«æœ€é�©ã�§ã�™ï¼Žã�¾ã�Ÿï¼Œãƒ¦ãƒ¼ã‚¶ãƒ¬ãƒ™ãƒ«ã�®ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ç”¨ã�« `ustack` ã�Œã�‚りã�¾ã�™ï¼Ž # Lesson 10. スケジューラã�®ãƒˆãƒ¬ãƒ¼ã‚·ãƒ³ã‚° ``` # bpftrace -e 'tracepoint:sched:sched_switch { @[kstack] = count(); }' ^C [...] @[ __schedule+697 __schedule+697 schedule+50 schedule_timeout+365 xfsaild+274 kthread+248 ret_from_fork+53 ]: 73 @[ __schedule+697 __schedule+697 schedule_idle+40 do_idle+356 cpu_startup_entry+111 start_secondary+423 secondary_startup_64+165 ]: 305 ``` コンテキストスイッãƒ�(off-CPU)イベントã�«ç¹‹ã�Œã‚‹ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã‚’計数ã�—ã�¾ã�™ï¼Žä¸Šè¨˜ã�¯å‡ºåŠ›ã�®æœ€å¾Œã�®äºŒã�¤ã�®ã�¿ã‚’表示ã�—ã�¦ã�„ã�¾ã�™ï¼Ž - sched: tracepoint ã�® sched カテゴリã�«ã�¯ã‚«ãƒ¼ãƒ�ルã�®ã‚¹ã‚±ã‚¸ãƒ¥ãƒ¼ãƒ©ã‚¤ãƒ™ãƒ³ãƒˆã�«é–¢ã�™ã‚‹ tracepoint ã�Œè¤‡æ•°ã�‚りã�¾ã�™ï¼Žsched_switch, sched_wakeup, sched_migrate_task ã�ªã�©ï¼Ž - sched_switch: ã�“ã�®ãƒ—ローブã�¯ã‚¹ãƒ¬ãƒƒãƒ‰ã�Œ CPU ã�‹ã‚‰é›¢ã‚Œã‚‹æ™‚ã�«ç™ºç”Ÿã�—ã�¾ã�™ï¼Žã�“れã�¯ I/O å¾…ã�¡ã‚„タイマ,ページング/スワッピング,ロックã�ªã�©ã�®ãƒ–ロッキングイベントã�®ã�¨ã��ã�«èµ·ã�“りã�¾ã�™ï¼Ž - kstack: カーãƒ�ルã�®ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã�§ã�™ï¼Ž - sched_switch ã�¯ã‚¹ãƒ¬ãƒƒãƒ‰ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆå†…ã�§ç™ºç”Ÿã�—ã�¾ã�™ï¼Žã��ã�®ã�Ÿã‚�スタックã�¯CPUã�‹ã‚‰é›¢ã‚Œã‚‹ã‚¹ãƒ¬ãƒƒãƒ‰ã�®ã‚‚ã�®ã�§ã�™ï¼Žä»–ã�®ãƒ—ローブタイプを利用ã�™ã‚‹ã�¨ã��ã�¯ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã�«æ³¨æ„�を払ã�†å¿…è¦�ã�Œã�‚りã�¾ã�™ï¼Žcomm ã‚„ pid, kstack ã�ªã�©ã�¯ãƒ—ローブã�®å¯¾è±¡ã‚’å�‚ç…§ã�—ã�¦ã�„ã�ªã�„å ´å�ˆã�Œã�‚りã�¾ã�™ï¼Ž # Lesson 11. ブロック I/O ã�®ãƒˆãƒ¬ãƒ¼ã‚·ãƒ³ã‚° ``` # bpftrace -e 'tracepoint:block:block_rq_issue { @ = hist(args.bytes); }' Attached 1 probe ^C @: [0, 1] 1 |@@ | [2, 4) 0 | | [4, 8) 0 | | [8, 16) 0 | | [16, 32) 0 | | [32, 64) 0 | | [64, 128) 0 | | [128, 256) 0 | | [256, 512) 0 | | [512, 1K) 0 | | [1K, 2K) 0 | | [2K, 4K) 0 | | [4K, 8K) 24 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [8K, 16K) 2 |@@@@ | [16K, 32K) 6 |@@@@@@@@@@@@@ | [32K, 64K) 5 |@@@@@@@@@@ | [64K, 128K) 0 | | [128K, 256K) 1 |@@ | ``` ブロックI/Oè¦�求をãƒ�イトå�˜ä½�ã�§ãƒ’ストグラムã�¨ã�—ã�¦è¡¨ç¤ºã�—ã�¾ã�™ï¼Ž - tracepoint:block: tracepoint ã�® block カテゴリã�¯æ§˜ã€…ã�ªãƒ–ロックI/O(ストレージ)イベントをトレースã�—ã�¾ã�™ï¼Ž - block_rq_issue: デãƒ�イスã�« I/O ã�Œç™ºè¡Œã�•れã�Ÿæ™‚ã�«ã‚¤ãƒ™ãƒ³ãƒˆã�Œç™ºç”Ÿã�—ã�¾ã�™ï¼Ž - args.bytes: Tracepoint ã�® block_rq_issue ã�®å¼•æ•°ã�®ãƒ¡ãƒ³ãƒ�変数ã�§ï¼Œãƒ–ロックI/Oã�®ã‚µã‚¤ã‚ºã‚’ãƒ�イトå�˜ä½�ã�§è¡¨ã�—ã�¾ã�™ï¼Ž ã�“ã�®ãƒ—ローブã�®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã�¯é‡�è¦�ã�§ã�™ï¼Žã�“ã�®ã‚¤ãƒ™ãƒ³ãƒˆã�¯ãƒ‡ãƒ�イスã�«å¯¾ã�—ã�¦ I/O ã�Œç™ºè¡Œã�•れã�Ÿã�¨ã��ã�«ç™ºç”Ÿã�—ã�¾ã�™ï¼Žã�“れã�¯ã‚ˆã��プロセスコンテキストã�§ç™ºç”Ÿã�—,ã��ã�®å ´å�ˆãƒ“ルトイン変数,例ã�ˆã�° comm ã�¯ã��ã�®ã�¨ã��ã�®ãƒ—ロセスå��ã‚’æ„�味ã�—ã�¾ã�™ã�Œï¼Œã�“ã�®ã‚¤ãƒ™ãƒ³ãƒˆã�¯ã‚«ãƒ¼ãƒ�ルコンテキスト(例ã�ˆã�° readahead)ã�§ã‚‚発生ã�—ã�¾ã�™ï¼Žã�“ã�®å ´å�ˆ pid ã‚„ comm ã�¯äºˆæœŸã�—ã�ªã�„ã‚‚ã�®ã�«ã�ªã‚‹ã�§ã�—ょã�†ï¼Ž # Lesson 12. カーãƒ�ル構造体ã�®ãƒˆãƒ¬ãƒ¼ã‚·ãƒ³ã‚° ``` # cat path.bt #ifndef BPFTRACE_HAVE_BTF #include #include #endif kprobe:vfs_open { printf("open path: %s\n", str(((struct path *)arg0)->dentry->d_name.name)); } # bpftrace path.bt Attached 1 probe open path: dev open path: if_inet6 open path: retrans_time_ms [...] ``` カーãƒ�ルã�®å‹•的トレーシングã�§ vfs_open() をトレーシングã�—ã�¾ã�™ï¼Žã�“ã�®é–¢æ•°ã�¯ (struct path *) を第一引数ã�«å�–りã�¾ã�™ï¼Ž - kprobe: 以å‰�説明ã�—ã�Ÿã‚ˆã�†ã�«ï¼Œã�“れã�¯ã‚«ãƒ¼ãƒ�ルã�®å‹•的トレーシングをã�Šã�“ã�ªã�†ãƒ—ローブタイプã�§ï¼Œã‚«ãƒ¼ãƒ�ル関数ã�®é–‹å§‹ã‚’トレースã�—ã�¾ã�™ï¼ˆé–¢æ•°ã�‹ã‚‰ã�®æˆ»ã‚Šã�®ãƒˆãƒ¬ãƒ¼ã‚¹ã�«ã�¯ kretprobe を利用ã�—ã�¾ã�™ï¼‰ï¼Ž - `arg0` ã�¯ãƒ“ルトイン変数ã�§ï¼Œãƒ—ローブã�®æœ€åˆ�ã�®å¼•æ•°ã‚’æ„�味ã�—ã�¾ã�™ï¼Žã�“れã�¯ãƒ—ローブタイプã�”ã�¨ã�«æ„�味ã�Œç•°ã�ªã‚Šï¼Œ`kprobe` ã�®å ´å�ˆã�¯é–¢æ•°ã�®æœ€åˆ�ã�®å¼•æ•°ã‚’æ„�味ã�—ã�¾ã�™ï¼Žä»–ã�®å¼•æ•°ã�«ã�¯ arg1, ..., argN ã�§ã‚¢ã‚¯ã‚»ã‚¹ã�§ã��ã�¾ã�™ï¼Ž - `((struct path *)arg0)->dentry->d_name.name`: `arg0` ã‚’ `struct path *` ã�«ã‚­ãƒ£ã‚¹ãƒˆã�—ã�¦ã�‹ã‚‰ dentry や後続ã�®ãƒ¡ãƒ³ãƒ�変数をå�‚ç…§ã�—ã�¾ã�™ï¼Ž - #include: BTF (BPF Type Format) ã‚’æŒ�ã�Ÿã�ªã�„システムã�§ path ã�Šã‚ˆã�³ dentry 構造定義ã�«å¿…è¦�ã�ªãƒ•ァイルをインクルードã�—ã�¾ã�™ã€‚ カーãƒ�ル構造体ã�®ã‚µãƒ�ートã�¯ bcc ã�¨å�Œæ§˜ã�«ã‚«ãƒ¼ãƒ�ルヘッダを利用ã�—ã�¾ã�™ï¼Žã�—ã�Ÿã�Œã�£ã�¦å¤šã��ã�®æ§‹é€ ä½“ã�Œåˆ©ç”¨å�¯èƒ½ã�§ã�™ã�Œï¼Œå…¨ã�¦ã�§ã�¯ã�‚りã�¾ã�›ã‚“.場å�ˆã�«ã‚ˆã�£ã�¦ã�¯æ‰‹å‹•ã�§æ§‹é€ ä½“を定義ã�™ã‚‹å¿…è¦�ã�Œã�‚りã�¾ã�™ï¼Žä¾‹ã�ˆã�° [dcsnoop tool](../tools/dcsnoop.bt) ã�§ã�¯ nameidata 構造体ã�®ä¸€éƒ¨ã‚’手動ã�§å®šç¾©ã�—ã�¦ã�„ã�¾ã�™ï¼Žã�“れã�¯ã�“ã�®æ§‹é€ ä½“ã�Œãƒ˜ãƒƒãƒ€å†…ã�§å®šç¾©ã�•れã�¦ã�„ã�ªã�„ã�Ÿã‚�ã�§ã�™ï¼ŽLinuxカーãƒ�ルã�®BTFデータã�Œã�‚ã‚‹å ´å�ˆï¼Œå…¨ã�¦ã�®æ§‹é€ ä½“ã�Œåˆ©ç”¨å�¯èƒ½ã�§ã�™ï¼Ž ã�“ã�“ã�¾ã�§ã�§ bpftrace ã�®å¤šã��ã‚’ç�†è§£ã�—,強力ã�ªãƒ¯ãƒ³ãƒ©ã‚¤ãƒŠãƒ¼ã‚’作æˆ�・利用ã�™ã‚‹ã�“ã�¨ã�Œã�§ã��ã�¾ã�™ï¼Žbpftrace ã�®ã��ã�®ä»–ã�®æ©Ÿèƒ½ã�«ã�¤ã�„ã�¦ã�¯ [インストラクションマニュアル](../man/adoc/bpftrace.adoc) ã‚’å�‚ç…§ã�—ã�¦ä¸‹ã�•ã�„. bpftrace-0.27.1/docs/type_resolution.md000066400000000000000000000264141526721631600201250ustar00rootroot00000000000000# Type Resolution This explains how bpftrace handles type inference and resolution resulting in static types at runtime. The pass that does this is called the `TypeResolver` (type_resolver.cpp) and inside this pass is the `TypeRuleCollector` visitor, which walks the AST and emits rules into a `TypeResolver`. The solver then propagates types through the rule graph using a worklist-based algorithm until a fixpoint is reached (basically a `TypeVariable` is fully resolved). However, there a lot of additional non-standard complexities that are included as part of the bpftrace language. It consists of 4 different visitors: #### `TypeRuleCollector` Walks the AST and collects type rules into a `TypeResolver`. For leaf nodes with known types (e.g. integer literals), it seeds the solver directly. For compound nodes, it registers rules that compute output types from input types. Does not mutate the AST but may run multiple times due to AST transformations in the `AstTransformer`. #### `AstTransformer` Utilizes the resolve types from the `TypeRuleCollector`/`TypeResolver` to transform introspection functions (e.g. `sizeof`, `typeinfo`) and create/expand calls to memcmp (for tuples and records). #### `TypeApplicator` Utilizes the resolved Types from the *final* `TypeRuleCollector`/`TypeResolver` run to add the `SizedType` to the AST nodes themselves. Note: this may go away in the future if future passes just consume the map of resolved types instead of relying on state in the AST nodes. #### `CastCreator` Injects casts based on the resolved types of the AST, e.g. so the left and right of a binop are the same type and size. ## The Basics The `TypeRuleCollector` visitor walks the AST and builds up a set of rules in a `TypeResolver`. Each rule has an output `TypeVariable`, a set of input `TypeVariable`s, and a `resolve` function (lambda) that computes the output type from the input types. A `TypeVariable` is a variant of `Node *`, `ScopedVariable`, or `std::string` (the last one being used for map keys/values, as these are often resolved separately by different statements/expressions, e.g. `@a = 1; $b = @b["str"]`). For nodes with already-known types (e.g. integer literals, builtins), the collector calls `resolver.set_type()` to seed the resolver. For compound nodes (e.g. binops, field accesses), it calls `resolver.add_type_rule()` with a lambda describing how the output type derives from input types. For simple type forwarding (e.g. variable references), it calls `resolver.add_pass_through()`. After all rules are collected, `resolver.resolve()` runs a worklist-based propagation algorithm: 1. Seed the worklist from nodes with known types by enqueuing all rules that depend on them. 2. Pop a rule from the worklist and check if all its inputs are resolved (non-NoneTy). 3. Invoke the rule's solve lambda with the resolved input types. 4. If the result differs from the rule's previous result, update the output type and enqueue all rules that depend on this output. 5. Repeat until the worklist is empty (fixpoint reached). ### Example Iteration ``` $a = 1; $b = $a; ``` **Collect (visiting the AST)** 1. the `ScopedVariable` `$a` depends on the `Node *` on the right side of the assignment (integer literal `1`) via a rule 1. variable `Node *` `$a` on the left side of the assignment depends on `ScopedVariable` `$a` via a pass-through rule 1. the integer literal `1` gets seeded with a known type (`uint8`) in the resolver 1. the `ScopedVariable` `$b` depends on the `Node *` on the right side of the assignment (Variable `$a`) via a rule 1. `$a` (on the right side of `$b`) depends on the `ScopedVariable` `$a` via a pass-through rule Notice the distinction between the variable `Node *` `$a` and the `ScopedVariable` `$a`. The latter is not an AST object but something specific to the `TypeRuleCollector`. `ScopedVariable` is responsible for tracking the type of a variable and then updating the associated variable `Node *`s. This is needed because there are multiple variable AST objects associated with a single scratch variable (`ScopedVariable`), e.g., `$a = 1; print($a); $a = (uint32)2`. **Resolve (rule propagation)** 1. start the worklist-based rule propagation 1. pop from the worklist a rule whose input (`1`) has type `uint8` 1. the rule's `resolve` function checks if `ScopedVariable` `$a` already has a compatible type 1. it sees `$a` has a `None` type (by looking it up in the `types_` map). The lambda (`resolve`) returns `uint8`. 1. the resolver sets `uint8` as the type for `ScopedVariable` `$a` in `types_` and enqueues all rules that depend on `$a` 1. it processes the pass-through rules for the two variable `Node *`s for `$a`, setting both to `uint8` 1. finally since `ScopedVariable` `$b` depends on Variable `Node *` `$a`, its type also gets set to `uint8` in the `types_` map The reason we store all the types in a separate map as opposed to on the AST nodes themselves is because the `TypeRuleCollector` visitor may need to run multiple times to resolve things like comptime branches (more on this later). We need a clean state every time we run or else weird things happen that are hard to debug. When the `TypeRuleCollector` visitor is done running (possibly multiple times). This `types_` map is then passed to the `TypeApplicator` visitor which uses it to set the types on the AST nodes. ## Preventing Infinite Loops There is a really easy example that demonstrates how we might end up with an infinite loop when propagating types through the rule worklist. Consider this example: ``` $a = 1; $a = $a + 1; ``` The second statement demonstrates that `$a` depends on the result of the binop on the right side. The binop depends on both `$a` and `1`. So when `$a` is resolved from the first statement and `1` is resolved, we enter the infinite loop of resolving `$a` then resolving the binop then resolving `$a` again and so forth. The solver does something very simple in that if it sees that the type returned by the rule's solve function is the same as the type already previously returned by that rule then it simply stops propagating. In this case the binop resolves to a `uint64` so when `$a` becomes a `uint64` and re-triggers the binop rule, it already has this result and stops. ## Breadth First Search The resolver utilizes a BFS (worklist/queue) to propagate types instead of a DFS to prevent an issue with stale updates. For example: ``` let $a; $a = $a + 1; $a = 1; ``` There are 4 `$a` variable `Node *`s that need types. They should all resolve to the same type with their input being the `ScopedVariable` `$a` in the rule graph. In a depth first search when we resolve the first integer literal `1` and set the type of the `ScopedVariable` `$a` to `uint8`, we have 4 rules to process. When we process the third one (the left operand in the binop) the binop resolves to a `uint64` setting this as the type of the `ScopedVariable` `$a`. We then process all 4 rules again setting the 4 `$a` variable nodes to type `uint64`. All is OK **BUT** we have one last rule left over from the first update to `ScopedVariable` `$a` which sets the last `$a` node (`$a = 1`) to a `uint8` - here is the stale update. ## Comptime branches A large source of complication in the `TypeRuleCollector` visitor is the existance of `comptime` branches, e.g. `if comptime (...) { } else { }`. There are some `comptime` expressions that get resolved before we ever reach the `TypeRuleCollector` visitor (e.g. `if comptime (1 == 1)`) but some `comptime` expressions rely on knowing the types of things, e.g. `if comptime (typeinfo($a).full_ty == "uint64"))`. For these we need to wait to fully resolve the type of `$a` before we can evaluate this `comptime` expression. Additionally `comptime` branches may further expose parts of the rule graph that we couldn't visit before. For example: ``` $a = 1; if comptime (typeinfo($a).full_ty == "uint64") { @map = 1; } else { @map = "str"; } $a = (uint64)2; ``` In this case the value type of map `@map` changes depending on which branch we take. So in order to resolve the type of `$a` we need a full resolution of the `TypeRuleCollector` visitor (minus the `comptime` branches). We then call upon the `AstTransformer` to transform `typeinfo($a)` into a literal record (e.g. `(btf_id=0, base_ty="int", full_ty="uint64")`). We can then evaluate/fold the comptime expression and, if it's part of a conditional in an `if` statement (like above), decide what branch to keep. We then need to re-run the `TypeRuleCollector` visitor because there are new branches to visit. We basically have to keep doing this until we either have no more `comptime` expressions (as they can be nested) OR we reach a point where we simply can't resolve them (and return an error). ## Locked `TypeVariable`s Let's look at a slight variation to the `comptime` example above: ``` $a = 1; if comptime (typeinfo($a).full_ty == "uint32") { $a = (uint64)3; } $a = (uint32)2; ``` Hopefully you spot the issue right away. We resolve the type of `$a` to be a `uint32`, the `comptime` expression evaluates to `true` and we take a branch that then sets the type of `ScopedVariable` `$a` to `uint64`. How can `$a` be both a `uint32` and a `uint64`? **It can't**. This is where `locked_nodes` comes in. It's a simple map that gets passed to subsequent `TypeRuleCollector` runs from former ones, indicating which `TypeVariable`s have "locked" types - meaning they can't be changed. In this case because `$a` was evaluated inside of a introspection function (`typeinfo`) it is locked and trying to change it's type results in an error. However, `TypeVariable`s that are not used inside of introspection functions (`typeinfo`, `typeof`, `sizeof`, `offsetof`) CAN be changed inside of `comptime` branches. ## Variable Declarations One neat thing we can do with the `TypeRuleCollector`'s design is around the handling of variables with explicit type declarations. Example: ``` $b = 1; let $a: typeof($b) = "str"; ``` This is clearly an error as the type of `$a` is a `uint8` and we're trying to assign a string literal to it. However, the error itself doesn't manifest in the `TypeRuleCollector` visitor. This is because we completely ignore the right side of the assignment to determine the type of `$a` because it has a type declaration. Then in a later pass, we simply issue an error if the right side type is not compatible with the left side. This reduces some complication and added state required to track what variables have explicit type declarations. Except types with no size - in these cases we need the RHS to know how big the type is, e.g. `let $a: string = "hello"`. ## Casting Inserted casts are reserved for `CastCreator` based on the types resolved in the `TypeRuleCollector` visitor. Example: ``` $a = 1; $b = 1; $a = $b; $a = (uint32)2; ``` In this example both `$a` and `$b` start off as `uint8` but the last assignment transforms `$a` into a `uint32` (propagating to all the `$a` variable `Node *`s). So the statement `$a = $b` is valid because `uint8` fits into `uint32` but the type of `$b` shouldn't change, we just need to add a cast so both sides are of the same type. So `$a = $b` becomes `$a = (uint32)$b`. This is done in the `CastCreator` for the purposes of not overcomplicating the `TypeRuleCollector` visitor and separating the concern of cast injection, which doesn't change the types of the `TypeVariable`s but just inserts an expression that doesn't require type evaluation (namely the cast to a specific type). bpftrace-0.27.1/flake.lock000066400000000000000000000110471526721631600153370ustar00rootroot00000000000000{ "nodes": { "blazesym": { "flake": false, "locked": { "lastModified": 1774111433, "narHash": "sha256-c3ETNTuQMUCgP1U5DfyqXHyMoq9dg7fif7UvSn5xMvs=", "owner": "libbpf", "repo": "blazesym", "rev": "8d28acade9ac5e5991ac2b67912eb3d88fa5b8f1", "type": "github" }, "original": { "owner": "libbpf", "repo": "blazesym", "type": "github" } }, "fenix": { "inputs": { "nixpkgs": [ "naersk", "nixpkgs" ], "rust-analyzer-src": "rust-analyzer-src" }, "locked": { "lastModified": 1752475459, "narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=", "owner": "nix-community", "repo": "fenix", "rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f", "type": "github" }, "original": { "owner": "nix-community", "repo": "fenix", "type": "github" } }, "flake-compat": { "flake": false, "locked": { "lastModified": 1733328505, "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "owner": "edolstra", "repo": "flake-compat", "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "type": "github" }, "original": { "owner": "edolstra", "repo": "flake-compat", "type": "github" } }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { "lastModified": 1731533236, "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { "owner": "numtide", "repo": "flake-utils", "type": "github" } }, "naersk": { "inputs": { "fenix": "fenix", "nixpkgs": [ "nixpkgs" ] }, "locked": { "lastModified": 1782220280, "narHash": "sha256-thLTFbp9D5Qknmh8q/v4FRpLGphUSijT3E86cbLYTXo=", "owner": "nix-community", "repo": "naersk", "rev": "9aa07bb0256d300219b30622d2454e85f7f3667e", "type": "github" }, "original": { "owner": "nix-community", "repo": "naersk", "type": "github" } }, "nix-appimage": { "inputs": { "flake-compat": "flake-compat", "flake-utils": [ "flake-utils" ], "nixpkgs": [ "nixpkgs" ] }, "locked": { "lastModified": 1757920913, "narHash": "sha256-jd0QwCVz4O1sHHkeaZILD/7D6oyalceEJ4EFnWCgm0k=", "owner": "ralismark", "repo": "nix-appimage", "rev": "7946addbc0d97e358a6d7aefe5e82310f0fe6b18", "type": "github" }, "original": { "owner": "ralismark", "repo": "nix-appimage", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1787964612, "narHash": "sha256-0N9nghg3nwzX6b6qc77EzjR9cu/Z+UR66FlfsCqiURs=", "owner": "NixOS", "repo": "nixpkgs", "rev": "e8be7818e19ada32105a8af937a6a473b38167ca", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { "blazesym": "blazesym", "flake-utils": "flake-utils", "naersk": "naersk", "nix-appimage": "nix-appimage", "nixpkgs": "nixpkgs" } }, "rust-analyzer-src": { "flake": false, "locked": { "lastModified": 1752428706, "narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=", "owner": "rust-lang", "repo": "rust-analyzer", "rev": "591e3b7624be97e4443ea7b5542c191311aa141d", "type": "github" }, "original": { "owner": "rust-lang", "ref": "nightly", "repo": "rust-analyzer", "type": "github" } }, "systems": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } } }, "root": "root", "version": 7 } bpftrace-0.27.1/flake.nix000066400000000000000000000311301526721631600152000ustar00rootroot00000000000000{ description = "High-level tracing language for Linux"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; nix-appimage = { url = "github:ralismark/nix-appimage"; # Avoid multiple copies of the same dependency inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; naersk = { url = "github:nix-community/naersk"; # See above inputs.nixpkgs.follows = "nixpkgs"; }; blazesym = { url = "github:libbpf/blazesym"; flake = false; }; }; outputs = { self, nixpkgs, flake-utils, nix-appimage, naersk, blazesym, ... }: # This flake only supports 64-bit linux systems. # Note bpftrace support aarch32 but for simplicity we'll omit it for now. flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: let pkgs = import nixpkgs { inherit system; }; # The default LLVM version is the latest supported release defaultLlvmVersion = 23; # Override to specify the bcc build we want. # We need specific patches in BCC which resolve build failures with # LLVM 23 and are not a part of any official release, yet. bccVersion = "dad0db93fd0f443b2a4f43bc2f23c621c9202516"; bcc = (pkgs.bcc.override { llvmPackages = pkgs."llvmPackages_${toString defaultLlvmVersion}"; }).overridePythonAttrs (oldAttrs: { version = bccVersion; src = pkgs.fetchFromGitHub { owner = "iovisor"; repo = "bcc"; rev = "${bccVersion}"; # See above sha256 = "sha256-js1NZumvODHrLXyaRaBMYJZtmTU63a3tl1+VJj0/y+E="; }; # Use shared libclang-cpp.so instead of individual static libs. # New LLVM 22 static libs (e.g. clangAnalysisLifetimeSafety) are # linked into libclang-cpp.so and not meant to be used directly. cmakeFlags = oldAttrs.cmakeFlags ++ [ (pkgs.lib.cmakeBool "ENABLE_LLVM_SHARED" true) ]; }); # gtest-parallel for running tests gtest_parallel = pkgs.stdenv.mkDerivation { name = "gtest-parallel"; src = pkgs.fetchFromGitHub { owner = "google"; repo = "gtest-parallel"; rev = "96f4f904922f9bf66689e749c40f314845baaac8"; sha256 = "VUuk5tBTh+aU2dxVWUF1FePWlKUJaWSiGSXk/J5zgHw="; }; propagatedBuildInputs = [ pkgs.python3 ]; phases = [ "installPhase" ]; installPhase = '' install -m0644 -D $src/gtest_parallel.py $out/bin/gtest_parallel.py install -m755 -D $src/gtest-parallel $out/bin/gtest-parallel ''; }; # Download statically linked vmtest binary arch = pkgs.lib.strings.removeSuffix "-linux" system; vmtestVersion = "0.18.0"; # Architecture-specific SHA values. # You can get the sha by using the trick above and running `nix develop --system aarch64-linux`. # It'll error out on the actual build, but the SHA check is done before that. vmtestSha = { "x86_64" = "sha256:1wv49fq7n820jj7zyvbvrrzg2vwvyy8kb3gfw1lg55rzfqzhl9v3"; "aarch64" = "sha256:1nsq32bn6pd1gmij1qlry8ydn4gp0jdcqs030ba6yh2c30rhi02d"; }; vmtest = pkgs.stdenv.mkDerivation { name = "vmtest"; version = vmtestVersion; src = builtins.fetchurl { url = "https://github.com/danobi/vmtest/releases/download/v${vmtestVersion}/vmtest-${arch}"; sha256 = vmtestSha.${arch}; }; # Remove all other phases b/c we already have a prebuilt binary phases = [ "installPhase" ]; installPhase = '' install -m755 -D $src $out/bin/vmtest ''; }; # Build blazesym blazesym_c = naersk.lib.${system}.buildPackage { root = blazesym; cargoBuildOptions = x: x ++ [ "-p" "blazesym-c" "--features" "blazesym/xz" ]; copyLibs = true; postInstall = '' # Export C headers mkdir -p $out/include cp capi/include/*.h $out/include/ ''; }; # Define lambda that returns a derivation for a kernel given kernel version and SHA as input mkKernel = kernelVersion: sha256: with pkgs; stdenv.mkDerivation rec { name = "kernel"; version = kernelVersion; src = builtins.fetchurl { url = "https://github.com/bpftrace/kernels/releases/download/assets/linux-v${kernelVersion}.tar.zst"; sha256 = sha256; }; # Remove all other phases b/c we already have a prebuilt binary phases = [ "installPhase" ]; installPhase = '' mkdir -p $out tar xvf $src --strip-components=1 -C $out ''; nativeBuildInputs = [ gnutar zstd ]; }; # Define lambda that returns a derivation for bpftrace given llvm version as input mkBpftrace = llvmVersion: pkgs.stdenv.mkDerivation { name = "bpftrace"; src = self; nativeBuildInputs = [ pkgs.bpftools pkgs."llvmPackages_${toString llvmVersion}".clang pkgs.cmake pkgs.gcc pkgs.ninja pkgs.pkg-config ]; buildInputs = [ bcc blazesym_c pkgs.asciidoctor pkgs.cereal pkgs.elfutils pkgs.gtest pkgs.libbfd pkgs.libelf pkgs.libffi pkgs.libopcodes pkgs.libpcap pkgs.systemdLibs pkgs."llvmPackages_${toString llvmVersion}".libclang pkgs."llvmPackages_${toString llvmVersion}".llvm pkgs.pahole pkgs.xxd pkgs.zip pkgs.zlib ]; # Release flags cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" "-DENABLE_SYSTEMD=1" ]; # Technically not needed cuz package name matches mainProgram, but # explicit is fine too. meta.mainProgram = "bpftrace"; }; # Define lambda that returns a devShell derivation with extra test-required packages # given the bpftrace LLVM version as input mkBpftraceDevShell = llvmVersion: let pkg = self.packages.${system}."bpftrace-llvm${toString llvmVersion}"; in with pkgs; pkgs.mkShell { buildInputs = [ bc binutils bpftools coreutils pkgs."llvmPackages_${toString llvmVersion}".clang-tools # Needed for the nix-aware "wrapped" clang-tidy gawk git gnugrep go # For runtime tests gtest_parallel iproute2 kmod # For git-clang-format pkgs."llvmPackages_${toString llvmVersion}".libclang.python nftables procps python3 python3Packages.looseversion qemu_kvm rustc # For runtime tests shellcheck strace unixtools.ping util-linux vmtest ] ++ pkg.nativeBuildInputs ++ pkg.buildInputs; # Some hardening features (like _FORTIFY_SOURCE) requires building with # optimizations on. That's fine for actual flake build, but for most of the # dev builds we do in nix shell, it just causes warning spew. hardeningDisable = [ "all" ]; }; # Ensure that the LLVM & clang version for AFL are aligned, and can # be controlled alongside the version used for the shell environment. mkAFL = llvmVersion: pkgs.aflplusplus.override { clang = pkgs."clang_${toString llvmVersion}"; llvm = pkgs."llvmPackages_${toString llvmVersion}".llvm; llvmPackages = pkgs."llvmPackages_${toString llvmVersion}"; }; # Lambda that can be used for a fuzzing environment. Not part of the default # devshell because aflplusplus is only available for x86_64/amd64. mkBpftraceFuzzShell = llvmVersion: shell: let afl = mkAFL llvmVersion; in with pkgs; pkgs.mkShell { nativeBuildInputs = shell.nativeBuildInputs; buildInputs = [ afl ] ++ shell.buildInputs; # See above. hardeningDisable = [ "all" ]; }; in { # Set formatter for `nix fmt` command formatter = pkgs.nixpkgs-fmt; # Define package set packages = rec { default = self.packages.${system}."bpftrace-llvm${toString defaultLlvmVersion}"; # Support matrix of llvm versions bpftrace-llvm23 = mkBpftrace 23; bpftrace-llvm22 = mkBpftrace 22; bpftrace-llvm21 = mkBpftrace 21; bpftrace-llvm20 = mkBpftrace 20; bpftrace-llvm19 = mkBpftrace 19; # Self-contained static binary with all dependencies appimage = nix-appimage.lib.${system}.mkAppImage { program = pkgs.lib.getExe default; name = "${default.name}.AppImage"; # Exclude the following groups to reduce appimage size: # # *.a: Static archives are not necessary at runtime # *.h: Header files are not necessary at runtime (some ARM headers for clang are large) # *.py, *.pyc, *.whl: bpftrace does not use python at runtime # libLLVM-11.so: Appimage uses the latest llvm we support, so not llvm11 # # The basic process to identify large and useless files is to: # # ``` # $ nix build .?submodules=1#appimage # $ ./result --appimage-mount # $ cd /tmp/.mount_resultXXXX # in new terminal # $ fd -S +1m -l # ``` # Patterns are wrapped in single quotes because mkAppImage.nix # uses concatStringsSep to build the mksquashfs command, which # causes unquoted multi-word patterns like "... *.a" to be # word-split by bash into separate args, breaking the exclude. squashfsArgs = [ "-wildcards" "-e" "'... *.a'" "'... *.h'" "'... *.py'" "'... *.pyc'" "'... *.whl'" "'... libLLVM-11.so'" ]; }; # Kernels to run runtime tests against kernel-6_14 = mkKernel "6.14.4" "sha256:0gvbw38vmbccvz64b3ljqiwkkgil0hgnlakpdjang038pxsxddmr"; }; # Define apps that can be run with `nix run` apps.default = { type = "app"; program = "${self.packages.${system}.default}/bin/bpftrace"; }; devShells = rec { default = self.devShells.${system}."bpftrace-llvm${toString defaultLlvmVersion}"; bpftrace-llvm23 = mkBpftraceDevShell 23; bpftrace-llvm22 = mkBpftraceDevShell 22; bpftrace-llvm21 = mkBpftraceDevShell 21; bpftrace-llvm20 = mkBpftraceDevShell 20; bpftrace-llvm19 = mkBpftraceDevShell 19; # Note that we depend on LLVM 22 explicitly for the fuzz shell, and # this is managed separately. The version of LLVM used to build the # tool must be the same as the version linked as a dependency, or # strange things happen. Hopefully this is a simple update, where # both numbers are bumped at the same time. bpftrace-fuzz = mkBpftraceFuzzShell 22 self.devShells.${system}."bpftrace-llvm22"; }; }); } bpftrace-0.27.1/images/000077500000000000000000000000001526721631600146455ustar00rootroot00000000000000bpftrace-0.27.1/images/bpftrace.graffle000066400000000000000000005120101526721631600177620ustar00rootroot00000000000000 ApplicationVersion com.omnigroup.OmniGrafflePro 138.29.0.155790 CreationDate 2016-03-04 01:58:06 +0000 Creator Brendan Gregg GraphDocumentVersion 6 GuidesLocked NO GuidesVisible YES ImageCounter 1 LinksVisible NO MagnetsVisible NO MasterSheets ModificationDate 2018-09-06 19:01:57 +0000 Modifier Brendan Gregg NotesVisible NO OriginVisible NO PageBreaks YES PrintInfo NSBottomMargin float 41 NSHorizonalPagination int 0 NSLeftMargin float 18 NSPaperSize coded BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAx7X05TU2l6ZT1mZn2WgWQCgRgDhg== NSPrintReverseOrientation int 0 NSRightMargin float 18 NSTopMargin float 18 ReadOnly NO Sheets ActiveLayerIndex 0 AutoAdjust BackgroundGraphic Bounds {{0, 0}, {720, 504}} Class SolidGraphic FontInfo Font CourierNewPS-BoldMT Size 16 ID 2 Style shadow Draws NO stroke Draws NO CanvasOrigin {0, 0} CanvasSize {720, 504} ColumnAlign 1 ColumnSpacing 36 DisplayScale 1 0/72 in = 1.0000 in GraphicsList Class LineGraphic ID 218 Points {100.56071, 286.80136} {100.56071, 336.21786} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 217 Points {100.56071, 243.74657} {100.56071, 218.11617} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 212 Points {116.51337, 211.42293} {17.765594, 211.42293} Style stroke HeadArrow 0 TailArrow 0 Bounds {{594.2088, 450.04092}, {79, 16}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue Size 13 ID 210 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 Timed Events} VerticalPad 0 Wrap NO Bounds {{592.52771, 397.79242}, {98, 40}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 18 ID 209 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs36 \cf0 profile:\ interval:} VerticalPad 0 Wrap NO Bounds {{11.168304, 452.83752}, {86, 16}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue Size 13 ID 208 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 Special Events} VerticalPad 0 Wrap NO Bounds {{11.542926, 401.00977}, {55, 40}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 18 ID 207 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs36 \cf0 BEGIN\ END} VerticalPad 0 Wrap NO Bounds {{674.00085, 225.2804}, {26, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 206 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\b\fs28 \cf0 bus} VerticalPad 0 Wrap NO Class LineGraphic ID 205 Points {707.11572, 245.2608} {667.31061, 245.2608} Style stroke HeadArrow 0 TailArrow 0 Width 1.5 Bounds {{594.2088, 59.240166}, {98, 21}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 18 ID 203 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs36 \cf0 hardware:} VerticalPad 0 Wrap NO Bounds {{127.97746, 401.00977}, {98, 21}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 18 ID 202 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs36 \cf0 software:} VerticalPad 0 Wrap NO Bounds {{137.27701, 60.738724}, {119, 21}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 18 ID 200 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs36 \cf0 tracepoint:} VerticalPad 0 Wrap NO Class LineGraphic ID 199 Points {257.00269, 358.54868} {268.39191, 330.24179} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{240.63177, 358.47018}, {34, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 198 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs28 \cf0 scsi} VerticalPad 0 Wrap NO Class LineGraphic ID 197 Points {132.44882, 339.89978} {132.68912, 273.06277} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{130.54706, 340.3559}, {34, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 196 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs28 \cf0 jbd2} VerticalPad 0 Wrap NO Bounds {{485.17822, 484.28946}, {218, 15}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0.697622 Font HelveticaNeue Size 12 ID 138 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;\red178\green178\blue178;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\fs24 \cf2 https://github.com/bpftrace/bpftrace 2018} VerticalPad 0 Wrap NO Class LineGraphic ID 195 Points {452.44153, 402.19925} {452.26917, 296.48868} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{431.7403, 403.79242}, {101, 48}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color b 0.6 g 0.6 r 0.6 Font CourierNewPS-BoldMT Size 14 ID 194 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs28 \cf0 page-faults\ minor-faults\ major-faults} VerticalPad 0 Wrap NO Class LineGraphic ID 193 Points {390.05359, 401.50204} {389.88123, 250.79147} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{284.14206, 404.28827}, {110, 32}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color b 0.6 g 0.6 r 0.6 Font CourierNewPS-BoldMT Size 14 ID 192 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs28 \cf0 cpu-clock\ cs migrations} VerticalPad 0 Wrap NO Class LineGraphic ID 191 Points {720.67969, 390.10159} {0, 390.10159} Style stroke HeadArrow 0 TailArrow 0 Class LineGraphic Head ID 44 ID 188 Points {645.28192, 366.33118} {645.28192, 344.8429} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Tail ID 186 Class LineGraphic Head ID 43 ID 187 Points {642.23309, 194.14841} {642.18158, 224.80887} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{615.78192, 366.33118}, {59, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPSMT Size 14 ID 186 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\b\fs28 \cf0 cache-*} VerticalPad 0 Wrap NO Bounds {{592.52771, 110.81422}, {101, 80}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color b 0.6 g 0.6 r 0.6 Font CourierNewPS-BoldMT Size 14 ID 185 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\b\fs28 \cf0 cpu-cycles\ instructions\ branch-*\ frontend-*\ backend-*} VerticalPad 0 Wrap NO Class LineGraphic ID 184 Points {580.85297, 51.678741} {580.85297, 504} Style stroke HeadArrow 0 TailArrow 0 Class LineGraphic ID 183 Points {117.76019, 51.820648} {117.76019, 504} Style stroke HeadArrow 0 TailArrow 0 Class LineGraphic ID 181 Points {459.71552, 89.123932} {412.92816, 215.27336} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 180 Points {348.47974, 339.62717} {366.03448, 296.155} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{11.542926, 61.738724}, {97, 16}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue Size 13 ID 174 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 Dynamic Tracing} VerticalPad 0 Wrap NO Bounds {{277.97556, 61.738724}, {80, 16}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue Size 13 ID 50 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 Static Tracing} VerticalPad 0 Wrap NO Bounds {{609.698, 321.87671}, {71.167847, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 44 Shape Rectangle Style fill Color b 0.851391 g 0.851391 r 0.851391 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 DRAM} Bounds {{616.98218, 225.30887}, {50.32843, 40.90387}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 43 Shape Rectangle Style fill Color b 0.851391 g 0.851391 r 0.851391 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 CPU\ 1} Class LineGraphic ID 113 Points {621.03168, 243.74657} {470.22656, 243.74657} Style stroke HeadArrow 0 TailArrow 0 Width 1.5 Bounds {{649.10779, 275.54425}, {48, 31}} Class ShapedGraphic FitText YES Flow Resize ID 70 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Memory\ Bus} VerticalPad 0 Wrap NO Bounds {{495.49713, 202.92044}, {73, 31}} Class ShapedGraphic FitText YES Flow Resize ID 68 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 CPU\ Interconnect} VerticalPad 0 Wrap NO Class LineGraphic ID 137 Points {720.67969, 51.205944} {0, 51.205944} Style stroke HeadArrow 0 TailArrow 0 Width 0.5 Class LineGraphic ID 168 Points {194.18262, 359.07861} {214.97746, 305.54657} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 171 Points {154.87547, 126.52167} {154.11154, 259.46808} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{5.5429268, 142.82158}, {109, 60}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color b 0 g 0 r 0 Font CourierNewPS-BoldMT Size 18 ID 165 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs36 \cf0 uprobe:\ uretprobe:\ usdt:} VerticalPad 0 Wrap NO Bounds {{5.5429268, 245.28812}, {109, 40}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color b 0 g 0 r 0 Font CourierNewPS-BoldMT Size 18 ID 163 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs36 \cf0 kprobe:\ kretprobe:} VerticalPad 0 Wrap NO Class LineGraphic ID 161 Points {490.20508, 189.45589} {457.79449, 243.1916} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{483.17822, 107.67329}, {76, 80}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color b 0.6 g 0.6 r 0.6 Font CourierNewPS-BoldMT Size 14 ID 160 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs28 \cf0 sched\ task\ signal\ timer\ workqueue} VerticalPad 0 Wrap NO Class LineGraphic ID 159 Points {491.18097, 339.74957} {454.96002, 324.67889} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 158 Points {478.23856, 282.89941} {449.48291, 283.48987} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{484.61728, 257.14508}, {76, 48}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPSMT Size 14 ID 157 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs28 \cf0 kmem\ vmscan\ writeback} VerticalPad 0 Wrap NO Bounds {{495.49713, 335.2966}, {26, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPSMT Size 14 ID 155 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\b\fs28 \cf0 irq} VerticalPad 0 Wrap NO Bounds {{175.27701, 358.91217}, {43, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 154 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs28 \cf0 block} VerticalPad 0 Wrap NO Bounds {{145.91074, 104.60594}, {34, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 153 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs28 \cf0 ext4} VerticalPad 0 Wrap NO Bounds {{432.88959, 69.687424}, {68, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 152 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\b\fs28 \cf0 syscalls} VerticalPad 0 Wrap NO Bounds {{387.52762, 104.94469}, {34, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPS-BoldMT Size 14 ID 201 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\b\fs28 \cf0 sock} VerticalPad 0 Wrap NO Class LineGraphic ID 142 Points {403.37744, 124.20242} {360.62976, 234.90355} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{338.05746, 340.3559}, {26, 32}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font CourierNewPSMT Size 14 ID 141 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 CourierNewPS-BoldMT;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\b\fs28 \cf0 net\ skb} VerticalPad 0 Wrap NO Bounds {{247.66663, 21.18483}, {186, 26}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Thin Size 21 ID 136 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Thin;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs42 \cf0 bpftrace Probe Types} VerticalPad 0 Wrap NO Bounds {{127.24895, 311.14508}, {342.55994, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 90 Shape Rectangle Style fill Color b 0.989631 g 0.927333 r 0.755614 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Device Drivers} Bounds {{198.2724, 176.34805}, {271.53644, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 94 Shape Rectangle Style fill Color b 0.816575 g 0.817319 r 0.990984 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 System Libraries} Bounds {{240.47348, 115.41571}, {105, 16}} Class ShapedGraphic FitText YES Flow Resize ID 46 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Operating System} VerticalPad 0 Wrap NO Bounds {{378.9624, 266.21274}, {90.846375, 44.932343}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 89 Shape Rectangle Style fill Color b 0.802726 g 0.939072 r 0.998695 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Virtual Memory} Bounds {{378.9624, 221.2804}, {90.846375, 44.932343}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 85 Shape Rectangle Style fill Color b 0.802726 g 0.939072 r 0.998695 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Scheduler\ } Bounds {{277.97556, 288.67892}, {100.98691, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 88 Shape Rectangle Style fill Color b 0.797729 g 0.916695 r 0.851254 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Ethernet} Bounds {{277.97556, 266.21274}, {100.98691, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 87 Shape Rectangle Style fill Color b 0.797729 g 0.916695 r 0.851254 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 IP} Bounds {{277.97556, 243.74657}, {100.98691, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 86 Shape Rectangle Style fill Color b 0.797729 g 0.916695 r 0.851254 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 TCP/UDP} Bounds {{277.97556, 221.2804}, {100.98691, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 84 Shape Rectangle Style fill Color b 0.797729 g 0.916695 r 0.851254 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Sockets} Bounds {{127.24895, 288.67889}, {150.72662, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 81 Shape Rectangle Style fill Color b 0.989599 g 0.860461 r 0.79432 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Block Device Interface} Bounds {{127.24889, 266.21274}, {150.72662, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 82 Shape Rectangle Style fill Color b 0.989599 g 0.860461 r 0.79432 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Volume Manager} Bounds {{127.24895, 243.74657}, {150.72662, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 80 Shape Rectangle Style fill Color b 0.989599 g 0.860461 r 0.79432 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 File Systems} Bounds {{127.24889, 221.2804}, {150.72662, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 79 Shape Rectangle Style fill Color b 0.989599 g 0.860461 r 0.79432 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 VFS} Bounds {{127.24895, 198.81422}, {342.55994, 22.466171}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 83 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 System Call Interface} Bounds {{127.24895, 137.62154}, {342.55994, 61.192688}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 78 Shape Rectangle Style fill Color b 0.816575 g 0.817319 r 0.990984 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;\f1\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Applications\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f1\b \cf0 \ } Class LineGraphic ID 114 Points {642.23309, 266.71274} {642.52075, 336.21786} Style stroke HeadArrow 0 TailArrow 0 Width 1.5 GridInfo HPages 1 KeepToScale Layers Lock NO Name Layer 1 Print YES View YES LayoutInfo Animate NO circoMinDist 18 circoSeparation 0.0 layoutEngine dot neatoSeparation 0.0 twopiSeparation 0.0 Orientation 1 PrintOnePage RowAlign 1 RowSpacing 36 SheetTitle probe types 2018 UniqueID 35 VPages 1 ActiveLayerIndex 0 AutoAdjust BackgroundGraphic Bounds {{0, 0}, {720, 504}} Class SolidGraphic FontInfo Font HelveticaNeue-Medium Size 14 ID 2 Style shadow Draws NO stroke Draws NO CanvasOrigin {0, 0} CanvasSize {720, 504} ColumnAlign 1 ColumnSpacing 36 DisplayScale 1 0/72 in = 1.0000 in GraphicsList Class LineGraphic ID 273 Points {367.90503, 278.2301} {367.90503, 327.57556} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 272 Points {341.46149, 158.34779} {128.52332, 124.22475} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 271 Points {327.12799, 220.11488} {129.4769, 242.09456} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{469.24796, 151.50769}, {65, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 270 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs18 \cf0 process structs} VerticalPad 0 Wrap NO Class LineGraphic Head ID 179 ID 266 Points {402.69992, 177.07678} {402.69992, 192.24722} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Tail ID 264 Bounds {{77.252029, 115.34409}, {49, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 265 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 structs_} VerticalPad 0 Wrap NO Bounds {{341.64667, 142.57678}, {122.10646, 34}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 264 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Clang Parser\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 clang_parser.*} Bounds {{596.92767, 149.64587}, {45, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 13 ID 263 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 Events:} VerticalPad 0 Wrap NO Class LineGraphic ID 262 Points {327.71173, 261.40762} {130.06064, 283.3873} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{204.50983, 255.98492}, {57.269684, 12}} Class ShapedGraphic FitText Vertical Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 259 Rotation 353 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 name_ids_} VerticalPad 0 Class LineGraphic ID 256 Points {328.19995, 198.0903} {128.40494, 153.61374} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{52.51329, 134.49333}, {73, 36}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 255 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 printf_args_\ stackid_map_\ ...} VerticalPad 0 Wrap NO Bounds {{208.23531, 102.76789}, {73, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 253 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs18 \cf0 bpftrace program} VerticalPad 0 Wrap NO Bounds {{367.90503, 455.75885}, {85, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Italic Size 14 ID 252 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 AsyncAction::*} VerticalPad 0 Wrap NO Bounds {{266.16663, 455.78265}, {49, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Italic Size 14 ID 251 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 printf()} VerticalPad 0 Wrap NO Bounds {{483.05966, 288.89569}, {60, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 250 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs18 \cf0 BPF func calls} VerticalPad 0 Wrap NO Bounds {{483.05969, 249.63867}, {58, 23}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 249 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs18 \cf0 AST Nodes to\ LLVM IR calls} VerticalPad 0 Wrap NO Class LineGraphic ID 248 Points {671.17255, 367.70795} {671.17255, 245.32845} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 247 Points {665.60895, 432.4906} {665.60895, 442.52478} Style stroke HeadArrow 0 HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 246 Points {633.69141, 393.59317} {633.69141, 407.73416} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{609.55481, 328.13684}, {50.13974, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 12 ID 245 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs24 \cf0 Verifier} Bounds {{618.401, 285.35843}, {26, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 13 ID 244 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 BPF} VerticalPad 0 Wrap NO Bounds {{596.92767, 227.44653}, {79, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 11 ID 243 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs22 \cf0 perf_events} Bounds {{596.92767, 173.44653}, {79, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 11 ID 242 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs22 \cf0 tracepoints} Bounds {{597.04163, 209.44653}, {79, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 11 ID 241 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs22 \cf0 uprobes} Bounds {{597.04163, 191.44653}, {79, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 11 ID 240 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs22 \cf0 kprobes} Bounds {{265.43835, 434.62363}, {166, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 11 ID 239 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs22 \cf0 Per-event Output, Async Actions} VerticalPad 0 Wrap NO Bounds {{52.413818, 412.15796}, {67, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 238 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 print_map()} VerticalPad 0 Wrap NO Bounds {{601.33826, 406.15381}, {63, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 12 ID 237 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs24 \cf0 Maps} Bounds {{54.570164, 438.77698}, {67, 24}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 236 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 perf_event_\ printer()} VerticalPad 0 Wrap NO Bounds {{302.99918, 402.28421}, {92, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 11 ID 235 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs22 \cf0 Async Summaries} VerticalPad 0 Wrap NO Bounds {{599.61194, 442.52478}, {71.560608, 18}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 12 ID 234 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs24 \cf0 perf buffer} Class LineGraphic ID 231 Points {599.61194, 452.52454} {124.47879, 452.52454} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 230 Points {601.33826, 419.89258} {118.98193, 419.89258} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 229 Points {57.801025, 197.90755} {41.32082, 198.16011} {40.85701, 393.81531} {149.95813, 393.81531} Style stroke HeadArrow 0 TailArrow 0 Width 1.7000000476837158 Bounds {{258.29111, 353.49463}, {235, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 221 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 bpf_attach_*(), bcc_usdt_enable_probe()} VerticalPad 0 Wrap NO Bounds {{257.2486, 322.3833}, {91, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 220 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 bpf_load_prog()} VerticalPad 0 Wrap NO Bounds {{185.80527, 301.36035}, {53, 28}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 214 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 bcc\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 libbpf/libbcc} VerticalPad 0 Wrap NO Bounds {{175.31076, 294.23932}, {74, 87.786255}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 213 Line ID 219 Position 0.15744693577289581 RotationType 0 Shape Rectangle Style fill Color b 0.988235 g 0.968627 r 0.843137 shadow Draws NO Bounds {{350.28506, 327.60806}, {104.45963, 21.979675}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 13 ID 183 Line ID 219 Offset -0.4654541015625 Position 0.56086909770965576 RotationType 0 Shape Rectangle Style fill Color b 0.918349 g 0.918349 r 0.918349 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 BPF bytecode} Class LineGraphic ID 219 Points {138.07822, 338.13245} {609.55487, 338.13245} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic Head ID 212 ID 218 Points {92.362823, 273.69583} {92.611145, 293.6806} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Tail ID 202 Class LineGraphic ID 217 Points {138.15176, 368.62692} {671.17255, 368.62692} Style stroke HeadArrow 0 HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{48.773739, 294.18057}, {88.77803, 87.786255}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 212 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;\f1\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Attached\ Probes \fs28 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f1\fs16 \cf0 attached_probes_} Bounds {{183.37308, 191.73579}, {79, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 211 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 create_maps()} VerticalPad 0 Wrap NO Bounds {{165.10924, 215.05168}, {126.24751, 12}} Class ShapedGraphic FitText Vertical Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 210 Rotation 353 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 bpftrace_.add_probe()} VerticalPad 0 Bounds {{57.851265, 234.58633}, {68.530945, 38.609528}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 202 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;\f1\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Probes\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f1\fs18 \cf0 probes_} Bounds {{469.24796, 74.576599}, {74, 23}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 200 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs18 \cf0 parse bpftrace\ program into AST} VerticalPad 0 Wrap NO Bounds {{483.05969, 191.73579}, {63, 34}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 199 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs18 \cf0 syntax checks,\ map creation,\ add probes} VerticalPad 0 Wrap NO Bounds {{305.83975, 378.62137}, {97, 12}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 198 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs20 \cf0 bpf_create_map()} VerticalPad 0 Wrap NO Class LineGraphic ID 196 Points {149.95813, 393.77628} {633.72522, 393.77628} Style stroke HeadArrow 0 HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 195 Points {327.44894, 207.44949} {127.90216, 207.71301} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Bounds {{57.851265, 180.0654}, {68.530945, 48}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 194 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;\f1\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Maps\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 maps.*\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f1 \cf0 maps_} Bounds {{52.157158, 79.419266}, {72, 28}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 193 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 bpftrace\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 main.*, bpftrace.*} VerticalPad 0 Wrap NO Bounds {{613.19141, 79.419266}, {39, 17}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Medium Size 14 ID 160 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 0 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs26 \cf0 Kernel} VerticalPad 0 Wrap NO Bounds {{211.40228, 76.429428}, {68.530945, 21.979675}} Class ShapedGraphic FontInfo Font HelveticaNeue-Medium Size 14 ID 189 Line ID 190 Position 0.49987009167671204 RotationType 0 Shape Rectangle Style fill Color b 0.918349 g 0.918349 r 0.918349 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 program} Class LineGraphic Head ID 83 ID 190 Points {150.42352, 87.419266} {340.96149, 87.419266} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic ID 188 Points {430.47937, 312.56189} {430.47937, 327.76917} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Class LineGraphic Head ID 181 ID 187 Points {402.69992, 227.24722} {402.69992, 243.26457} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Tail ID 179 Bounds {{377.73087, 110.03512}, {50.13974, 18}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 180 Shape Rectangle Style fill Color b 0.918349 g 0.918349 r 0.918349 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs24 \cf0 AST} Class LineGraphic Head ID 264 ID 92 Points {402.55963, 104.91927} {402.655, 142.07678} Style stroke HeadArrow FilledArrow HeadScale 0.75 LineType 1 TailArrow 0 Width 1.7000000476837158 Tail ID 83 Bounds {{27.851707, 70.806091}, {122.10646, 405.32471}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 186 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Bounds {{589.73248, 275.51532}, {95, 156.49527}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 185 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Bounds {{580.16034, 70.806076}, {113.48351, 405.32474}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 184 Shape Rectangle Style fill Color b 0.880332 g 0.985746 r 0.904703 shadow Draws NO Bounds {{382.19992, 277.76465}, {95, 34}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 182 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 IR Builder\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 ast/irbuilderbpf.*} Bounds {{328.19989, 243.76459}, {149, 34}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 181 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Code Generation\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 ast/codegen_llvm.*} Bounds {{328.19995, 192.74722}, {149, 34}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 179 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Semantic Analyzer\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 ast/semantic_analyser.*} Bounds {{341.46149, 70.419266}, {122.10646, 34}} Class ShapedGraphic FontInfo Font Helvetica-Bold Size 13 ID 83 Shape Rectangle Style fill Color b 0.840392 g 0.984419 r 0.994962 shadow Draws NO Text Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Medium;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs26 \cf0 Parser\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \fs18 \cf0 driver.*, lexer.l, parser.yy} Bounds {{490.45667, 484.28946}, {218, 15}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0.697622 Font HelveticaNeue Size 12 ID 138 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Align 2 Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;} {\colortbl;\red255\green255\blue255;\red178\green178\blue178;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qr \f0\fs24 \cf2 https://github.com/bpftrace/bpftrace 2018} VerticalPad 0 Wrap NO Class LineGraphic ID 137 Points {720.67969, 51.205944} {0, 51.205944} Style stroke HeadArrow 0 TailArrow 0 Width 0.5 Bounds {{266.16663, 21.18483}, {149, 26}} Class ShapedGraphic FitText YES Flow Resize FontInfo Font HelveticaNeue-Thin Size 21 ID 136 Shape Rectangle Style fill Draws NO shadow Draws NO stroke Draws NO Text Pad 0 Text {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460 \cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Thin;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc \f0\fs42 \cf0 bpftrace Internals} VerticalPad 0 Wrap NO GridInfo HPages 1 KeepToScale Layers Lock NO Name Layer 1 Print YES View YES LayoutInfo Animate NO circoMinDist 18 circoSeparation 0.0 layoutEngine dot neatoSeparation 0.0 twopiSeparation 0.0 Orientation 1 PrintOnePage RowAlign 1 RowSpacing 36 SheetTitle internals 2018 UniqueID 54 VPages 1 SmartAlignmentGuidesActive YES SmartDistanceGuidesActive YES UseEntirePage WindowInfo CurrentSheet 1 ExpandedCanvases FitInWindow ListView OutlineWidth 142 RightSidebar ShowRuler Sidebar SidebarWidth 126 VisibleRegion {{-80, 0}, {880.95294, 504.00003}} Zoom 2.1488094329833984 ZoomValues probe types 2018 0.0 1 internals 2018 0.0 1 saveQuickLookFiles YES bpftrace-0.27.1/images/bpftrace_Full_Logo-Black.svg000066400000000000000000000177171526721631600221450ustar00rootroot00000000000000 bpftrace-0.27.1/images/bpftrace_Full_Logo-White.svg000066400000000000000000000177171526721631600222110ustar00rootroot00000000000000 bpftrace-0.27.1/images/bpftrace_probes_2018.png000066400000000000000000007522231526721631600212000ustar00rootroot00000000000000‰PNG  IHDRÜYóºysRGB®Îé pHYsgŸÒRÕiTXtXML:com.adobe.xmp 5 1 2 ‹O²@IDATxìݼÕÙÇñ´$¸CA‹´P ¸K�â…Å)œ ¥Xq§Bñ/„"I‘†âV(,XBÐyŸÿy9sggg}çÞÝ{çóIvv|¾³;wö™sžÓ+²â( € € € € € P¯À„^½zõ™¤Þ¥Y@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:¸wX0„ € € € € €@ÝÜë¦cA@@@@@:&ëd@zºÀ7ß|ãžzê)7÷ÜsûÝÁãã�?vwÞy§{ã�7ÜO?ýäæŸ~·Ç{t‡Cë–Çðå—_ºçŸ¾æc›zê©]ß¾}ÝÌ3ÏìzõêUóò]µ@wüÎ¥-_ýu7vìØô覽_d‘EÜL3ÍÔ´õ±"@@èYid,‹ €ÝG`ôèÑná…vÇwœ¼)¦˜Â­³Î:nß}÷u믿~Ëß»Ûw.ëÄéוW^™5©)ㆠæ6ß|󦬋• € € ЀÀ«üÓ‡î ²( €´®Àí·ßî=ôP7pà@wÐA¹•W^Ù)ûÝwßìôÅ_ì&�tR÷ûßÿ¾`ûÌ_§û÷ïïæ�w^·óÎ;ûÏe¹ýb € €@c½"+�­‚¥@@ »(@½ð »ãŽ;Î <ØÖ�wÞéöÝw_÷î»ïú€ëÒK/í–Yfß!©‚Ì#GŽt/¾ø¢Ÿvíµ×ºM6Ù¤$GÖúxàÈ~õÕWÝꫯî–Xb hW�Z�Þûï¿ßo{©¥–r·ß~»›{î¹3ׯ`g²hyÒñ‹_$G;÷ÌEzõê妚jª0Ê¿®³Î:îïÿ»>ôÐCÝYg�å÷c®¹æòã´ýË_þâþñ�¸Ÿ~úÉ�S�{̘1~Xÿ)hzá…ºSO=ÕÂ_|q·Øb‹ù`¸öW.ôï±Çs_~ù¥?þË/¿Ü-°Àñ:Ê hû‡~¸?& e¤€ï¸qãœñ ,¾ôÒK~Üa‡æÏãä“O^n•N·†G}´;í´Óü|z  Àä’K.é¶<þøãþU<ð@wæ™gx–]yõyÒØÍ7ßÜ 6¬Š%*Ï2à 3¸o¾ùÆ?øÐg¢Þó¶tî¹çúuè¼k_e#÷¯¾úÊŸÏ{ï½×? Xyå•ÝÍ7ßì?ÏaÙôkÖw¢™ß¹ôöºúü¦÷'ý~—]vñß8Þh£�Ò“Ý"‹,âƒÉzpUêZP´PjÄž{î鮸⠧k�e�ƒf]—R›öoó8z€ ‡jÅ¡yz� Ï¤>û ¼ëÁ ®3z §BºžÕó€/ëx‡ €  L°ß–}ô£Š‚ €x zëA|dwÿÞ‚®‘忎¬&sdAõÈŒ™Rÿú׿" òDvsüñ%çK¯ÿšk®ñÛÛ`ƒ "«��¹n ZGh�,pYMåHÛª¦Xmøh³Í6«8«=`ˆ,`Zv¾?þñ�~?í¡ƒ?6 Hû÷Vk4:ýôÓ£‡z(²Úª‘Õ”-XÏ1Çãç³‘æ ¦%ßX-ÔÈjÆGö ² |d ’“‹†-8mµÕV~Ýö` ²àcѰµß~ûE–ª ¢‘‚�V;Ý/c5Ÿ3çO®ÿÁŒ¬¶u¤Û÷ߟ9r¤þ ê+�n5Ï““2‡ó ¸[-RŒ–^&R`µTÑñéaŲË.Mœ8±ÔlãÏ9ç¿îAƒŒO¾QÀÐjùúùþð‡?Te§å>ø`¿Œˆdýuþäféo²f)wÁøsh5�+>$(Z¸ÄˆfÜ­¥†?î�vÚ)Þb2à^íù”»‚öº}>è ƒJ5ã�ØÀ¨Q£"K»ä�¬rrR<œüNäñ� j•óö§Ôk¥€»¥Ьuˆ—ûþ•Z¿¥Åòçð¤“NŠgIžƒ<¯Kyœ=|Óƒ:k9YZ£ø˜Ê Xj«ÈRLE‹.ºhÓ¾·å¶Ç4@@  pïA'›CE@ *�xRpÖÒDGqDUË…™ SmqÒ³j]‡õ«æ·‚Æ{ï½w\Ë4¬£Ü«¥_‰æ™gžÈrW 4çp·ô >Xg©\Êí¦Ÿfi|-RËõ]qÞä :6Ká’U0l9éý>Xšš‚ñ•Þ¨Ö«j�+`lyò‹fµñK†‹øyÄe—]æ×yÊ)§”š¥¦ñÍ ¸[J¢¨OŸ>~ÿî»ï¾x?BÀ½–ó©šç²³TñzªÐgV$,Q¤Æé¾y}çÂöZåü†ý)õZ)à®åô IçBç¯Ö¢Öz–l�ÎAÞ×¥<Î�¥òúÖRô9–¡–§ € €4M€€{Ó(Y €ÝD žTƒÔ:ÈŒT#³Ö¢Úç äX' E‹†õ«f¥åL/JÁR´@Æ˽ìׯ”åJw¥¡È:®ô~(°ªZ§[l±EzRÅ÷[o½µ·ÉJ ¡T.J‡¡48–‹¾âºÒ3<ýôÓÞNÁãdÑyÖz-‡~rtUÃÚ�O}^Ò)uªZAj¦fÜ­ÓÈH=ôYÜÿý ¶îÕžOùXg«¾@©´JH½ÑgUûaùîSS¢(|'òúÎiƒ­t~‹R#ª ¸[¿Þs­µÖJ-]þ­~(Ø®VÉÎAž×¥¼ÎAh¹¢c«¥¨Å�>“'žxb-‹1/ € €@ypŸÄn´( € €@�À×_í,�ã;Ü+˜PÅËî;‘´<ÈÎj¹g.aùÎÝŽ;îèfœqÆÌéåFj9Ëåî¬Fµï”´Ü¼Ížfeg9Û+®ö™gžñ™®´ÒJçMÏ N^ÕÁ§¥ËHOr–Ãw®z 'øa‹f¨0BÞª#Å{î¹§`γÏ>Ûwø©Pk-ê„T�ÂZëwÆgÔºxÓçÿä“OÜÅ_ìt¬O>ù¤ï„·Ô9«ö|jyuFiéx|»µî´¥³ñåÚƒ|žß¹ît~eg�q·Æk8Kÿâ;PÍòÌ7dÈßÁ±=4Ëšìò¼.åuìÁ¢?–R×Ú̵‘ê[EÛC¸R³0@@ N�Éê\ŽÅ@@ › XîöºŽÐ:Nu‡v˜S�ñá‡v–"%s=–=s|¥‘–{Øí»ï¾>øiºõÖ[¯Ò"M›n�°º™fš©âú¬ƒWg�;ºM6Ù¤â¼é.UôÃ:UuV ¾Ô,Çk¿,ÍM<ŸÕØvç�wž³46ÎòÍÇãkÐC³u[Ëbeç}î¹çœÕL/;O˜¨c3fŒ³T9Î:Iõ£­Fº8¢Ï™bd•jΧU`qÖѤÜ[‹…¬ÕTg­œ¥q»í¶›»á†Ü^{핹Lß¹V=¿™5Œ”•>o—^z©³ô(U-©ïÏ,³ÌRö{™Çu)ÏsðË_þÒ»¥†q«­¶ZUšIÊžþùºÜU½fD@z¨÷zâ9l@Ê ((UM`¹Ô:,•‡Ÿ” ì&çÕº8®·l´ÑF>à>zôèN ¸¯³Î:Uí²j�ê_­EÁâx s1ëÑ׎Þe—]êªeVš¿÷Þ{¾ÖüòË/f©ëUçÓÒTÔµlÖBúìX§¬Y“2Ç)Àn)bÜ*«¬âƒãz(S©E5çÓòÀûÚÿ믿~Cî–ÆÄï·¥/ÉÜÿ¼¾s­z~3j©‡<–ß]}õÕ¾µK©‡*a•�<òˆ(sÈ!‡¸P+ŸFIÇ»òÊ+;õ%¡JûDA@È_€€{þÆl@�¶˜nºéÞg¥øPíÓ¬¢`|£¥ÿþ%;emtÝ¥–W¸–¢Ž ¯ºê*§ÜÑï¾û®_T5Rçž{n_#U_Õ,W v©¥–r pJ£¢\øÉòÎ;ïø·:îf–ðPD¹°ÓÛ¬u;JÕñÕW_ÕºX—Í_Íù ÁÒf¤ßÐ:n¹åß¡®òº'K^ß¹î|~õ@F)U†êó‘«•EVQë}.Ku––ÉëºÔç@ /¼ðB§Üö÷Þ{¯Sÿ#GŽŒÞ黽È"‹ø<ïêC@×  € €@>…wúùlƒµ"€ €@› „àp#»­Ü×¥jí~óÍ7�¬Ú/;~üø¦Ô¤nxGJ¬@�cî¸ãŽ®wïÞnË-·ô�AçœsÎK”­”$*ü±kFð7lM©9T^z饦Ôâëí.¯zp¤¢”5}ûömè°”úF\ÒÁv­4¯ï\w?¿ÊÕ¯€û%—\â;·Í:AJ'Ó§O·í¶ÛfMŽÇåu]êÌs  ºþ|ðÁîûï¿wO>ù¤{ì±ÇÜ£�>ê_/¾øb_ ~­µÖò�%/ºè¢ññ3€ € Ðr¸7Ç‘µ € ЭBmêzJ)>ýôÓ’q¥Ri¤üøã�>@r¹7²®<–ýÛßþæƒíJé @ªj¹+·r½ÁvícÈñR·4k¿ÃC‘P ·Yëí.ë ¹Û_ýõ†IédÂúÒ+Ëë;×ÝÏïŠ+®è–]vYtÏÊ[®tM>ø Ûj«­|ª´{ò}^×¥®:“O>¹ûõ¯íþøÇ?ú>"”ÊJõTçÌê3¢ÑÏ]Ò�a@@�ÿ àÎ'@Фj¤„\àÊGžU liý?üðC„ÎÚFW�ûé§Ÿ|煪ͮ\ʵ¦ Ñqe•ðp¡Ù÷È©S²¶Ý“Ç…œù¥r¯WkóÝwßùàf©€{^ß¹žp~•FE)c®»îº¢Ó1dȧ>*¥“Ñ‚y]—Zå(­Ì6Ûlã^~ùe_»]Ç»Ùf›™1@@ 1î�ù±4 €ÝRà‹/¾p�ÔèU •_ýêW™> ˜+Vo µ±CºÞõä±ÜóÏ?ï”:Dé+”>¤Öjœ¦}±6¾ó×0®;¼†ÎRÕ)e#å•W^ñ6!€Ÿ^W^ß¹žp~õ]›i¦™|Z™´«úO�ù*«¬’žTô>¯ëR^çà…^p§œrŠ«õš 7ûï¿¿Ûu×]ݳÏ>ëÓTa0@@ nîuÓ±  €Ý[àüóϯûէʆn˜¹¤‡ž9­š‘ ¢©,¾øâÕÌÞ©ó¨£B•ßüæ75oWixžzê©Ìå” ~ÕUWu·Þz«Sp¶Þ¢”Ê:ˆìׯŸ›a†Ü�wÞé[ Ô³^¥:ꨣ| îI&é^·—Êý­”%êì´‘Ðçž{®§-÷¹Èã;×Îï/~ñ _ƒ]ÁãQ£FÅáGyÄ£wß}÷x\¹�¼®Ky�åœ?æ˜c|š˜rÇUjZ¸>?ñÄ¥fa< € €@ÝëQ,‚ €ÙêhðË/¿ÌžXf¬j]þûßÿöÁðP+;kvurXOQê åHWnâ•VZ©žU-£40Í*ê,VeŽ9æ¨y•—]v™›8qbÉåŽ>úhlWmòzŠÒ¢¼úê«nàÀ�ñâ �+dzj¸Ëµž¢‡Jé¡tݱœtÒIþ¼üéOªëðd{íµ×:uT¹úê«—\Gß¹žr~ÕºBÇš¼®ÈSÔî¼óÎ%ÍÓ’˧§•{_×9Xj©¥ÜSLá~øár»VrZèøÍ7ß,9@@j à^»K € ÐíÔÁàøñã ‚WÕôÙgŸíg=þøãK.2`À_£:§KΘ1áÌ3Ïô5±O8ᄌ©µ�RíXulÚ¬²Øb‹ùUéÁC-E>^tÑEe;V]wÝuÝrË-çþò—¿øóSËúõPá€pÊã¼å–[,ªñJÉ¡ôê�¶–¢Úí§Ÿ~º›rÊ)»m>è 6ØÀ·.Бz>³ Ø+7ÿi§�V’6Ïï\O8¿óÌ3�Ûxã�Ý�7ÞèÆ�çô¹¼é¦›ÜFmäfŸ}ö’îÉ y^—ò8 ¶/½ôÒîÑGuõô1pÿý÷ûÃïÛ·o’�a@@�¸7Èâ €tG�EYÄíµ×^>MÈ•W^Yõ!wÜqNµJ•6#ÔM®dÓM7õµÓõúÑG%'•VÀóâ‹/öË*øÜŒ¢`œR´Œ;¶«sK,±„_ÏwÜQõú>ûì3·öÚk;üÖYg¿\©ÎSUËý“O>ñµÉki�pòÉ'ûN\•‚b™e–)Ø·i¦™Æzè¡>h·ï¾ûÖ”Zf�=öp/½ô’SÊ”Z;ˆ-؉£Úíß~û­Óçî­·Þªjo•‡ÿØc�uJ�ôÛßþÖ-¿üò%—Ëó;×Sί>»J³"ïaÆùVÕt–NJž×¥¼Î�lês¹Å[ÔôNËÜ~ûí¾Ÿ‰5ÖX#ðŠ € Ð û!@A@¼€¥QO¦‘Σï¾û.²À¹oÁÆŠBVãÜÏÛ¿ÿÈjgΟ\¿å ެVt4ÿüóGÖAkæüa¤ÕºŽ,í‰_¿æ·o˜TòÕjF›m¶YÉéa‚ðýz­†qUô¶m5ዦ¥GXMòÈ‚²~�C‡MO.z/+«Y-ÓÈR;Dx _öÉ'Ÿ,š7Œ¸ð #K•-¼ð‘Õl £3_-(|ðÁ‘¥µˆ,gs$ˬb5‚#{Hâ·½æškF–O>k¶xœ=$ˆì¡ŒŸß‚îñøFFŒá×¹ùæ›7ºª’Ë×r>“+±‡O‘µˆˆ¬ÓÙÈj'' [à7Úzë­ý±èó`IŠæÑˆäw"�ï\Øh«œß°?¥^-ý‹7»ë®»JÍRr¼¾{¿üå/ý÷BŸaKë}ÿý÷%ç’ç ÏëR^çÀ¢ÅŸ3]C*•?ü0²”\‘µv‰,=U¥Ù™Ž € P½Àx¯¯~~æD@�î.� <éXTÝ~ûíã`Ž¥hˆ¬Q`Kåã�?ެ³Íh½õÖóóX'¦eÀéõ[§†ÑÌ3ÏY:“èÈ#�Œžyæ™ÈR«øu+0l�TFVc>Zyå•ýú­jdúé•þ«6à®c Ǩ`�ÕôŽô€Áj¨Ç›¨5@kµö£9çœÓï³¥´ˆ,uƒ?–à¦`¶{ ®Ï8㌑Ü,´ßžåC÷Ë-ºè¢ÑàÁƒ#«ÕïGrà�ðËZfø¾âŠ+¢çž{.²šñ‘ÕØ�dk©g| _�µwܱ*;KM:餑¥èðÖYh4è¸h>ãŒ3ü¶Äßu×]#Ë;ŸÜµ††[9à®Óƒ=TÒâ½÷ÞÛ;롆Šìß~ûíÈ:?õQän�É–|È¡eÒ߉fç´�déêó›Ü—¬áFîZŸµ´ðß=84hPÖ&ŠÆ¥ÏAž×%m¼Ùç@×Ê=÷ÜÓ?TÓçR׫‡zÈ_s´=]wtÍÑuh¿ýö‹f�uVÿÀnÈ�!šLA@hž÷æY²&@º‡@:ðŽêž{îñAaÈš|òÉ£©¦š*lÍ5×\щ'žX1ðšµþ·Þz+²T‘ÇZ·þM=õÔ> Þ÷ë×/²Üíq ?ìW¹×jîZ‡¥WˆÎ:ë,_£_Ë)�l)@âÕ×pׂz¡‡–J">.Ãô/ׂ .YÞöH5_CQðL­4MÆÛm·]˜Tôª–z‘\§†ÃyÒvô°bÔ¨QEË–ñÏþ3²´3ñ~j=Éó­÷ªµýì³Ï–[M]ÓZ=ஃRmu†ûôéé3«áÜÊÏRvT4ÈúNh¡f}ç²v +ÏoÖþ$Ç5p×¹Þ½{ûóP©õGØnÖ9È뺶™Ç9°~#¢M6Ù$þ 골ϨZÄϥ®³ Îë�@@ é>àÞK«µ0  € PQ@{ª3P«Iíóž[PØéŸÕÆvl¬¸üèÑ£�¥AqÊõnµ· æWîåÇÜYMo÷Þ{ïùN8g›m6§NH•sÜ‚Èó·ËåYñÅÝ;ï¼ãÿY@ßÍ;ï¼ÎRã8«Ùî,¸ßð¡(ý¿þõ/g-|.z«ÁêÝt^¬}Ýëã�7œ朵jðù¡µß:ß ,°@Cë­{‡ZlA}f~øaß鮌,èî;½]vÙe½S3v·Ñï\¹}èŽçWçÁ:{ÐäìáM¹Ã�§uåu)�s`µÙݘ1cü?{pàì„ï8ÖZÝøþ/t ¢ € €ä"0Á~·ö!àž‹-+E@�,�r�­¬ù‡Ô"pöÙg;k‘â;NµÚòU-Êu©*&fB@¨,àî�W©ª¼!æ@@@r°>Ü 3Ìà¬àÜ·Å@@È àž¥Â8@@h+�Ç{̧¼²Îl}•¶Úyv@@ Ûpï6§’A@@ ç ¨_å'ßÿý{.GŽ € ÐåÜ»ü° € € P¯ÀG}ävØa7|øpwÀ¸9昣ÞU± € € LÖðX € € Љ×\s�{å•WÜûï¿ïîºë.7nÜ8·Â +¸SO=µ÷‚M!€ € P,@À½Ø„1 € € ÐÂ'Ÿ|²{ûí·ÝÔSOíæ›o>wÊ)§¸�vÚÉM>ùä-¼×ì € €@OèYé Ê1"€ €@× è¶cüøñ>ϲr-S@�z¾ûî;©gÙô2\—Ò"¼G@¨S`B¯^½úp¯S�Å@@@@@øYÀÜé4•Ï € € € € €M àÞDV� € € € € €w> € € € € €4A€€{Y € € € € €Üù € € € € € ÐîM@d € € € € €pç3€ € € € € €@¸7‘U € € € € € 0Ù×_ížþy$@@@@@@ �Ÿ~úI•ÛWšlĈî˜cŽqQÕ±A�VÐ÷¹W¯^­¸kì € € €¹ XÀË}óÍ7®wïÞü.ÎM™#€@–€]¦°ñõ²À‘ö,!Æ!Ц'NtK,±„[qÅݵ×^Û¦GÁn#€ € € P»À)§œâ+–^vÙenÏ=÷¬},�Ô/0Á*Àö™¬þåYZQàÍ7ßtcÆŒq_|ñE+îû„ € € €@nï¿ÿ¾_÷ÿþ÷¿Ü¶ÁŠ@�rtšZN‡i € € € € €T)@À½J(fC@@@@@ œ÷r:LC@@@@@ JîUB1 € € € € €å¸—Óa € € € € €U p¯ŠÙ@@@@@('@À½œÓ@@@@@¨R€€{•P̆ € € € € €@9îåt˜† € € € € €@•Ü«„b6@@@@@Ê p/§Ã4@@@@@ª à^%³!€ € € € € PN€€{9¦!€ € € € € P¥÷*¡˜ @@@@@�rÜËé0 @@@@@�*¸W Ål € € € € €” à^N‡i € € € € €T)@À½J(fC@@@@@ œ÷r:LC@@@@@ JîUB1 € € € € €å¸—Óa € € € € €U p¯ŠÙ@@@@@('0Y¹‰LC@@@@�l�n¸Á >ܽõÖ[3qÄnýõ×/Ç›b�1cÆ8>úè£nâĉñ sÌ1‡ûÛßþ¿g�v àÞNg‹}E@@@h �|Ðm·Ýv™û²óÎ;gŽgd¡À®»îêƒí…c�›o¾ùÒ£x�@Û�R¦mN;Š € € € Ð*|ðA«ìJÛîÇûï¿ß¶ûÎŽ#PJ Ój¸ßu×]n„ EûÑ«W/×·o_·À ¸Yg�µh:#²Æ�ïî¾ûn?QM”¦�vÚì›0öïÿ»ûþûïëZÓ¢‹.ê_|ñº–Ís¡'žx½ýöÛn®¹ær+­´Rž›bÝ ÐÛo¿½KÞ,o²É&î�Ciƒ=góø÷¿ÿíî¼óN÷æ›oº÷Þ{ÏÍ<óÌnÞyçuË.»¬Ûf›mÜd“uÚ-TՇȽAÕT™3ro�ÉÂH@(#°ÕV[¹‘#Gú”2Š1Pj8ï¼óÜ9çœãk¹ûí·µ¯€%hA�Nûµ¸Ï>ûø¬å ¦›n:·È"‹¸£Ž:Ê)ØA)-ðÑGùüšãÅ_t‹-¶X陜²Ë.»¸¯¾úª®µ}ôÑîä“O®kÙ<ºð Ý�!CÜ–[nIÀ=Oè:Ö­›”{î¹Çm¾ùæN9Û(t†€‚«Éœ‹ -´Pgl¶îmð=©›®â‚Ï>û¬;à€Ü¿þõ¯’ó{ì±î´ÓN‹ÿ§gÔßeýXèׯ_Ó+”[7÷é3QÛ{î jóbn@pnŠ)¦p—^z©§¸úê«Ýn»íK�o¼±Ó?Ý?«² �vè´€{€šfšiÜÜsÏÞú×O>ùÄ�;Ö}ñÅNA��ºõÖ[Ï�{î¹®ÕƒÒMߨ–ú×_]ttúaÿñÇûñ /¼°›tÒI‹æ¡ÕB #Êès¦ïüwß}çN8á]P+ tð=é°hö�:lZwÝuýß6Õ`ßh£�ÜŠ+®èfši&§¦®O>ù¤o]¦‡3j¡ŠYa©Ò€Ѝ¶ÎþûïßÔÝÌsݵì(÷µh1/ €ô~»6~–1lÜ�5´†@§Ü×Zk-§%éòé§Ÿº—^zÉÙ‡ æî»ï>·êª«ºW_}ÕÍ0à éÙ{ü{™œrÊ)Þ!ï ¶‚dDì'©7égœ1k¶–§ší ìêA¥uFŒáƒíÚ#=Ìyæ™gÜ2Ë,Ó:;Èž Ð|Oò; j¬k�ìêkÉ%—,ÚØsÏ=çÖYg?Ÿ‚î£G�v³Ì2KÑ|]1‚{ƒÆÔ¹7hÌ�¥@@ ¼ÀĉýïÝf¦Ž¢È}öÙg>Ý¡*ƒtFùòË/]Ÿ>}2+]V»}ÅCj—{»:ë\iß;ë³Qíùï óuzÀ½ª~Ü*À®]t‘oέÔ‡v˜»âŠ+J-ÖcÇO?ýô>õN�hðÀUC�´E "æ°¸r%'‹j‘pOŠ0œ—À­·ÞêtÊl³Í[î•ïI>§D�v¥“QQ:´¬`»¦ 0À]wÝu¾&ü¸q㜀(PÛ …{ƒÆÎ÷�ù±4 € <òÈ#îüóÏw�?þ¸O•¢à§úZzé¥ÝÊ+¯ìc_Õö ¤eµ>¥>TÅHUPûðÃÝ?üà7¬ jÿþýÝšk®écisÎ9gñ¥Æ¨§RºŽ5ª¨ï>UFQ‹OÝ'ë8{ì1_ádÊ)§t¿úÕ¯|EÐUVY%µÖâ·Zÿßþö7¿U`Q† íURê?kžyæ)^ðç1ŠþãÿðÛOæy×òjq*Ϭòù矻{ï½×çÙOö+©ÌªDó›ßü¦h±vvÖçA­lu¾”ŠòÝwßõÇ÷‹_üÂÿŽÑýîN;íT”y¤¡Ìõ¥¾®TAz‹-¶(ù»©Ì*zÆ$û uJ±Î)#�6Ûl³ª¶gµÆüüö´+²‹IUËÔ:“uYY‘ýXŽì‡vU‹Û4²md_ØÈ.J‘]4" ÒTµl˜éÿû_4|øðȾaTÁ«åK�xà�È.¤%ç)X Âû‚EvaòÇZíqVX¥Ÿ|üñÇûs¤ójO'«YÄÏcŠÈjÄG¯¼òJÑ2�úæq¬õ|Nt`ú\أ詧žŠì`ѱæ5ÂZŠøób5.óÚDnëµ? ñgJŸ«[n¹%·m±bÚU€ïI>gÎZßÅ×Ý”+?ýôS¤k¬®Söã hVû±à§Yj¼¢ié–£Òÿ­¸ýöÛ£‡z(²T4éY Þײî‚Soòø{©MÔ{o ¿]º·’mºÔj”\^‹u¯§û®×^{-²”eÉÉu·Û½AÝÊ‚ €´¡Àþð/¦û’Î,–Ã=¾ŸÔ}¢Õà.x¯qék¯½vd5Ô+î¦Uº‰æ›o¾¢åÓë ï- �zê©×»ÄK”\§–W¬gç�wŽ› ëN¿ZEÙ’Ûѽ˜¦[ â’Ëk}öÐ!Úu×] Ìt¼¡XåÜ’ËO2É$‘|²Ê6ÛlSr9m×Zµ,֮κÇ=óÌ3#Kã]öxuÌÖï@¤ïˆb�µ ¶G3ÏZ³ôh¥•Vòš°n]8ì©bd9î“«ö“0�¤‹.jÚ'«¥Y°=-cOÿü�ûô2µ¾¯æGµŽOÛ´4AÞG�‰Þ½{ûqVƒ0Þd=¾aázŽU0´_V+1¬Æ¿6ú9ÑJî¸ãŽè׿þu¤?pá…ÏÈ�?þ-¸à‚~¼‚;yîõ«ÚSö†Ž(Pd}RDö½þ�(³¤nv,w™9ꛤãÎkŸ­öA.ëÖ÷Þj9ÔwÀ]¸”®úŒ4R¸7¢WzÙ‡~8¾f[‡¨¥güyÊÈ‘##kÿ=ÕÍz¸æg½Z­¦‚u*À®¿YóZ �x½Z¨ÚuëBX_«ÞXÍ&¿�Ö‚À{Xí¬ÈZ Äû�¼—ªÅ¨×Þ¨²Æ²Ë.M>ùäñºe£%–’/óZÚ�ï Ò>¼G@ ; „ØQWÜÃ}Y¥WÅT1³\QEŽJëÉšn-3K®V¿-§šjª’ëUìHñ¬¬õ¦Ç)—.Ö?R´È"‹Tµ|z}zîªÀh©Ë®Çj\§7ïß÷íÛ·ìrgœqFÁríè¬ßÅÖ¿RÙãÌòÕ¹©5pùå—mGŸ‘άdZpÂZó�¸·LJ;ùÅž²9;ùîå—_vV#ÉOûýïïÓͨùÂm·Ýæ;,+Xèç77ÜpƒZmµÕœ}A fQ³uÈúŸÿüÇ)÷¹š�¨ŽÖi5 |çhJc‘Ì©¥êÔDÅj*ûu©j¥¹Ð«–UN$5­Ñ:,¨^°½ðÆž4ù&=ZF°i«áí�mÓM7õ½Z«)†:�µ‹­S:MW³™›o¾Ùçä²~Uù­þûßÿúfaíꛎ¨38­_Íi¬½US£Î*;ì°ƒ»é¦›Š6׈o^ÇZÏçDvá…ú&axuö°Ä-¾øâ>—š=@Š?#šFéxýõ×}Ó05yR?ÉrÁø¦JÉqaXi¨ôùµNÍÙÒ%ï¦qv]ozs¾ô1X@Ïÿ墺¨èúdï|Óú^Y@É·t ©¦_‚F›™éš¬f‡ú\'?Ï:°ò}p\|ñž ›:Ž´ ³ïm^©8tíT'’öT<}¸eßkwß}·»êª«üõûƒ>ð¹èt}S“L]G÷Øc�¢k~©•Z�Y ºî‡&˜éyÏ9眪ûÑçA©Et�¶›åxUÛn»­³ ªoj©iÊ÷ýÍ7ßø|…º>¨£=TöOâ…2òúždl*¥¿i=©© šÄêo´:mþóŸÿ쬢€ÛqÇc�ô@VóÓô<¥Þ_ýõNß]}nT´-}wuÝÒ}�î-Ôy«>ŸºjFÉëïe#û¦{1õí£ÏZº4bô—¿üÅßs…ï¶®—ʳ¯û"{ÀïSéúz×]wù¿Ñém—zϽA)Æ#€ €@%Ýg*þ¤4/úM {¾Pt¯úé§û> øô«~÷¦‹~ª#{Å�ô›Xñ¥šI¦NÙ{ï½�ÕòÎÌ·®”.ê›O)H’¿aÂv;J—©§žÚ§€Qj«!ON¦yÑHý~Ó½´âZɢ߮º¿]`�œbTšn.’³ [íxwÒI'ù}Õ1¦‹U\un¸¡¿·ÖvCQªž#�<Ò|ðÁ™ÛÐý|ú~¿Ýœõ{|»í¶+ø<…ã×oeÅå«ßú�“,²?ôÐC�Ñ“£ËÏ>ûìEÓuŸ­sDI tÖÀZk¸k¿ìǦr¢'5¡¬°Â ~œ}™Â¨‚WÕz´¼U~žk¯½6žj.[Þ"_ë[é`BQ3Šd�ÁtͶcŽ9ƯOM3,àS�BÆ'‘¹üt»ð<Õ 5ÜCÓÕ8×ü¡¨Ö·�Žøßb‹-©f(ªåj[i>»‡Iek¸Û¿N» G×\sMÜ|ZOœ¶|¡†µœêiBv¢–¯cÐçàì³ÏެSÜ8�O½¾Ú�z�5¸–ªá^Ïç$´¬ÐqZð/RêœPôÔPé”’ç›î‘o©RéIuÒ,k8ýD:˜çÙ4.¯ffaßõÙÙsÏ=ãV>YÇ�®1jI‘¬Ö^›ÑÌL× m'¹ý0¬:j)Þ—zU S{0v«â«Ò{„4¥Ö©ñr°|t‘jì—+vS…Ö7åÖ§”Õ{œyÜLŒìánæ´°mÕôµN%7eÁÈŠ5:ºJ½–úž”Ú¨¶Ù› ªfÒÐ~Dx`¤3•R²és¥{ýëÿsk¶³Î:+§é*ªIZ@ÙÍqd�ð‚Ó ´2¡%˜ýðòÓª]w¹îõþ½,ع*ÞTº75ÜíC®ÓúÞªöÕÓO?í·P�QØ5¥r çPM�•Ž&{P…{Íc?ÜÂ$ÿÚ�ï ”7 €ts�Vªá®Ø‚Uä)ˆ#‰ÿÆo,ø½§ßÅ•Šî•”æE¿¥,vf*>Åúõëßéžç…^¨´êH¿}Ò)qÂ=•^•}A1- xûu©õµî«”UA÷réÎÚÏäòú­¶Ï>ûDVù´`_ô^ãÃoÚä2¡†{X@¿g“¿­£K¦7Öoè°¼Ö§{c¥.¶ ñ4Ísì±Ç†Õ½¶“sòÞ6»>ÿº'–W(ŠE*¨sæ ¯Ji]m±‘U‹Ï—U„$p1^k§”Ñþî¾ûîþƒ ¦:©*JË¢…ò;e¥9XLÖ—*”pײ¥>L!³ù曇Åü«‚HZŽ*Þ(Gwø &›p‡€»¦m½õÖaö‚×ðAù¬².‚ú¡Ö­}(¥~T«‰{˜_?j³J20¤æðõ–J?ªµÞ`ª}²Ú¯™¹ÉêõmäX+ý¨ÖþÖú9Yc�5¼½Ž'|^“¶ú´üòËÇ燀{äóø‡Ïk½¯VK4É쇬ɳi\ÍÌÂA(½BµÍö²ÌÔ÷CViV33=ÌÚn=ãô .}c–ÞwåƒÓÍ]-ë·ïeØz ¡’•ÖYKÀ}ðàÁ×Wn{Êïn^ÓVó ¡uk»Yß“ôv’ï{rSAk�‘™ŽMŽÖ)StÀø|à!€žt Ãá‘æ§‹r‰k]Ju¢YEiï4Oú¡°æ-·îv¸7wŸ¾ÛÉ{›`ш‘riÝz�•¬äÖ­óf-mü< ø'Kw¾7H'à €tw�V ¸+ˆ^ê÷™Î�Õ°ö÷$ºwÑ¿d¥½FΑ*}„uêuèСU­Nýé$— à à?d•Bª-º'MÿÞ2dHÙÅ5=l/¼¦îZ�î�Ãt½†œî«ÓÃ’Aõd0^ËÕr<¥v¼«�Uq'!:°Ã@IDATý B¿ã*¥WLÊY•†j)Ú¶bžÉ ~-Ëwóy}À}CnÙb5¼ü¾©ˆÒs¨¨)ŒšÍX�ÆÙA?.ù_§füj>‘.Ë-·œOC‘¯÷¿ýíoýh¥H«ÝæìåÓ$LJa¥‡ Å>¤a°àÕ:‰(xÞX@Úª)¹Ò ¤‹å›Š�#Ù\'=_xÉ%—øA«]ç­Âøä«R/X-sg"gO““rÖùSzûƒS´�z}ó<ÖZ?'ê�Ù.ØþØt®Ãç5y°jbcý$Gõøa}î÷Ûo?§ô0µë¼ÚM‚O••Þ75?´0>U”Ò[éZaXÃb¯éë—&Z€©l33{XäÔ³¼¶“.¡™Y¯t_{íµ—O‰Æ•zÕ5Ø@9{ˆé›O¦÷Yé²Ô4°T±VJΞØ¤­Ñ¼ö@Õ¯wàÀ�΂�E‹¿eiÁ4Íj;Mӈ駟ÞwÜqÎldN¯g¤= ö†Yßý°>5Ÿ´‡nþ<ª9i²XGI¾¹cr\Îë{ÖŸõÚ“› ê{úÎ;ï8»éwº—PÉPÔüWMn•îE鑲šÙ†yK½ÚOa�B»ô5",î+JÝS„ùª}Íóïeµû�5Ÿîét}H—z�Ô[)óTìÁˆ³eéUûk§šÍêÈ~°5­-Z 1‚{ƒƒ € PQÀ²'øô+¥fTjÌd )D“㲆•Ä*@:«­ìׯô„JM¬)V©É§ÍK.—õ›69½Ü°~+Z�o·úê«—›­`šR÷Y 6§{jík¹¢éº7¬T”::Y´-«LêS7'§Y�ýø·¤Ò†¢ß½Vù5¼-ùÚêÎJÏh�ëxÿ§°ÊÆ>M�~Ç—úgÙÜRK-/gHœRüÖRt¿®íé7.¥„@g=U¨'¥ŒÒrØnûäÿÉýTs�·àVr´¯):B5jTÁ´PÃ]½—*á)�³JÍ�WÍG=ý³|WMZž|òÉxžd wÕ¸Í*–—ÞK©9Z&¤ÜPz˜PJÕb³ƒ~}0³æöZK wÕ8«¥TãÛȱVªÅVëçÄ'Þ]ŸËr=Œ'[,Pýã¡–ëÛŸdþ]tÑE‘O3ÿUûô¿ÙMãÂ^çÑÌ,ÔÄǯ°ƒ *h­¶¯k@ø‡ùõš•ª%�ff:gÿüç?ãs•ܵ0Òç;�ÞFÍCK�0¿Z÷¨µJº¨ét+Õü×w-]ÔŒ0\KÃzõºñƧg-z¯ÏGøŒ…¿9ašVk±‡E&j¥¥TZéÚ¶i?Õr/Wòüž¤·«mÑTðÿUT#ZŸ]5±µ�qÚ:}NôùUÇžéR®zz^½W�]Sôw~£�6Š?CYŸárën‡{ƒd wulZm©ÆÈr²ÇvÖWEµ«Žç ×ÔtË‚zï![éÞ >H@èáw•b�Yt¿~KèÕúŸ*»ùÝvÛ­`~Ýs–+Ö¯W¤Œ ÉmT3¬LÕ”t wÝ¥ÓU³¥dLî—†«Y,Ò|Éå²j¸§[\+E£Š=(X6¬GǤ´‚á½^­�­²ûÓ.Ί$�«‘áK/½´¬ kð5Ü[¶ÓTû øfzM×`Tç©ê�O�A¼ñÆnþùç×l¾s7ÕUíOu~–UÔQj=E�l]vÙeîÁôö%k›«¶d¥R®Ö£–­4½ÒúÃty¨è g+uˆQ®Ôã›ç±Öú9±€�?<ՒΪÅŽ]5ju®Uã˜Ò! µÊ°€cÇHÒyHÿ f¨â�¾ Yµuµ¨žÊªëꉧõÚÕº.WóZ˪†rº–²Æ'‹jb«þÿøÇxôsÏ=—ÙšEµt] E&Ö×�S�‚¬¢ÚW\q…ïÅôų¤¯G4övÆ3Ø€jwªƒÑtQmPÕÐ?Õª>úè£ãY¬ žß–:ãQÑþ©ÃŸtÑ~YÎRo¤'ùqê„S…>þøã~ºv�Ý;K©U0¿:=´u=µö‚Zfèó¬»ì²‹ïtH­Ä¬‰ªV�u2UîÚŸöÕ{}¿Õ1¨:œR‡Qv çgÓötíP�Í*yþ½ld+ÝÔjŽSŸÕZÿŽWsµ®“{ƒjT™@ª° M¾öº~?uVQ‹Neœ¨µ<óÌ3ñ"Z¾Üï±xFÐo>ͯŒ¥ŠæÑï?ývRÑoDÕÐNÖ`O.k=| ãä8µ(UÚÕ¹ÔñT;ÞdT;+óU)Pû7§Ê7:›šS¿öÚk~5逛š>¨Y¾šOX'[>5€f´š�~~5íof¹ãŽ;|³rôåW€D 5ÙÑ—]�©ô>6sûÕ®K?ÖCoÔé OµëÈk¾dP+½�z|[íXC]Mµ´oéÔᘭ¥Áö€Ñů dßtÓMÎ:†lhO,µÎ”ýyý¡W* Yä׿tZ“RÍù,·_pÓ©'õRÁö°Ã *)0­t0*j†Ã<åš™…y²^ÕÌL)_BÓ2›†+5½ÓC€¬`{؆ÒýX§ÕÎ:ÃŽÓúX g�ûÄÁt=ÐÔƒ�Pä©ë{úaB˜^Õ;»>(ŠRi\xá…ám§¿yä‘™Áö°#ºÙ w�³\x%îa™Î|ÕC)ýë EÁoÝÜëAšþ¶—*úÞqÄþ~àÐCõ†¬U�Sº§jŠ®V‹=N}¢ë„RÚéžB÷júç?ÿÙ?ä¯f}•æiµ¿—aåh�l…·¯õ©Ò…Š®…¥þl(ç7Üä Ìê@è!úMg--3Ó“†ßžÖ”KV íJšd:ŦtßWMѼª¦¸I©¢{<ý†R¥&¥TUzÝófëðht©€{»9×Zá§"1ÂZ‡&Þ1Ø �– ¸+h‚ÇÖÙfѱª–{2஽jUꋬ Q³Êûï¿ïs+Ø®üÎ ¥k8¥ó-7kÛµ®GÕöùå—}ЦÜòºËWùc 8–ÛN˜–•GUÓêõmµcU DÅš[¹±cÇ–¬Q­ %¥ë”·WÁµzžÖ‡½×÷LùÅõ<«¨Æj-%ýDÙRgUµ¸‚s§Ÿ~º{øá‡�jw+ �,ºN&‹¥1ñÁîä¸j‡U;¿\À]�ʬëuzý œo±Åq \7GÚOÕ|WQ>Îô^yñ•þš¢Üìz] „ve)•£;ìS:(ö;Lçµóþô§?9}•?2ùÀ§Ô(H®€»Šuž^uÀ]Ázå×gÚ÷ú\•éÏA©mÖ3¾Õþ^†c(¯×(Ô˜×õCµžÒ­¦Â¶õ·:Ü»©åYµ?ÃòÕ¾roP­ó!€ €@9KyÇÇ4ŸîqöÝw_ßjY•c½¤âbjy©¾°”?¾«Š~*#…ŠîËÔÏN¹JYa?5_¹`{˜O­oCÀ]ãÔçb(²PAÆ ó£üWE»PÔj8]I-Lk7çe—]6®x¬cXuÕUëþ­¯Ö ”æ ´dÀ]AXëíש>@ ̤‹šprÈ!¾¼5ê @5¢4o©æøéuTó^µNCà_) ÒÁv­CÖV)ê„U�@¥¾)UÔ ›jïi¿�:ꨢt¥–Ëc|#¾­t¬É?z‚ªN÷²Š‚¼”®¨·i\Øó<š™)˜ŠR›X¾ºð¶âëá‡îô/«$›óeM¯e\ú¡@zYÕέ¶è&'Yó\AöpO?¬(•",k[JÅ¡ [h!RLdÍË8’úœé3®f©jª«Ž®Ë=¸%VÃûr¯JÕ£¢Î•u/“Uš}_ÑJ/³Ž7=®^£Ð½Ö§û =\Í*êÄ]÷� ú«R^wî ²ô‡ €µ¨·b<¡Ì=÷ÜîÑGÍL#<í´Ó:ý«åÞ4¬·™¯éÔ«gœq†O‡ZijåYMQ`¹TY}õÕ}Œ+ÜÓó)–Õrº�ÓAr¥¤<ÿüóªX˜öâ}ý“Ô¿h>Kª°òÚ*订§rái]r‹ Hm¿ýö~”ÒÊ„t2¿ûÝï’³5<j$«iKß¾}3×§”¡”jƦçýªw* ^)qV¹úê«ã‡ÖYkÖ,�6®ßV:V¥ÇÍ’t�Ó“åtQ.WÕf¤´·€ð•kΧæÓL3MÍ™ Þ©Y`Öu¯æ•Ú�ÙÌ,]›¾Üþ*g}²$[Ú¤�µ^W“M›å˜ÜW†»§@¸†¿ýöÛ>¥S¥£´Î?ý,úŒ•jÙ‘õÙ ÷J=TÓ'µDQÉZÞO¨0-Ì^[éïeاr¯õ©%LrŸy晙ͮU»=¤�Ò�µfôÝPêX¸7(%Ãx@¨V ý»I÷¬¥Rö*=åàk¿W»þ<æSjTUlEqÝ•jÍ«Ê. ÊW/Qši=XÈ*ª¥®Š`áÞ>=O©ñíè¼âŠ+TÔS%¾ 6ØÀ�7.}ØEïu.^|ñEß:@ñÃZ‹¶¡V ¥Îi­ëëŽówz wå”J>�ªÒµè¦õìs²ëÇ�~À*‡q¨ñ˜…¯´2ªu®æ#z’£ü”ö¥™%¤1Píy¥)Pç‡!€£œÃJ_ }E㺲ì°ÃþB¦Z­ª9§€À&›lï³Ò+œzê©~õå´Þ™»rwã4õø¶Ú±ÊUo}¾u‘ÓçEOÕ¢@5&Õé¤ZK(Û*¹Õºôä·éÆójf¦ë—}*ê8SOØKÝHù™ªü¯3›™é:®�¥Zx„]VSA¥ KÝ4…ÒB„÷÷ß¿¯�Þ—{Õ>GÍ—^W¹e™Ö³”JF­WÔJIN•ÇP9øÓ5tÔ‘¬~0询¿µÉF§]úªs`= Sú=¸×ýƒî+tC¯´5ª$�ì|XŸu¥“ )•²î)Ê­[ÛÎ*­ö÷2k“ãê5Rš0¥ØRºßQsâk®¹&~ð¨ûM�S]_UtŸ™wáÞ oaÖ� €@× ¨åþ¹çžë+>&÷F”úxÿý÷/ÿõ¯u·Þz«OK˜œ_ýªÅÞàÁƒ�j²«¤k1ßxã�þ¾R±ݧ*È®À©Rª<ÅÓÒE÷G#GŽtë®»®O™bZúí¤Ê«ÚÅ-BG¤aùË/¿Ü©ûdѲK.¹¤8p ¯,›œ†õì”SNq‡vXåciº/Óý¯jàëXéoôÛPÛÉ úª"®úIRëhõ×¥Ê*ª ¥Ôª²MU¤M/T&]JÜÛÑY¿1TYÇ:šUÅ�þýûû´•ЧÊY5úUÁO¿o^x៬ÊrÉŠ¢ú¤{èjŠ~[¨¿7}Ö´~ývÊÊLRͺºõMÕzÔ5A©¦è©U(öå ƒM{Umä»ï¾Û×XÖJUcM��)?°šƒë ¢jºÙ`¿Må] M¡ýˆ.øO5EÕ”DêLCM=ô4SOÕA„Æëé¡Ü»º4êÛjǺÇ{ø§¨Ê«'ÒêðCéATã]9Äô9½?[§«ù[nûé?õ}+Uìjí­U[@i¨ÒO·K-×Èø<›™¥s9«6„j‹«y]¥¢§ÑJ] §òé`:»™™ž¬ë{ Ú]{ä¦Ö6jå¡÷!¿ºŽKפPS8§:YN×’W­ß‹/¾¸d“5ÕXUm†Ð9�Ö¥Ú®ûí·_Xm·yíÌïIOk*¨Z1ª­š>ª¹£¢¿ëú\©câW_}Õ§yQë0uF¥Fúœ¥‹jô¨³ß™fšÉÆ“ÓußrÎ9ç8ý Pú£Ç{ÌçáÔwGµáõ}Q‡ÌZVåÉ'ŸŒk¬è}¹ukz©Òj/Kí§Æ7j¤kŠîÝ”£S÷™º¯Ô9TkHÝ»©FŽ®±�U¸7è,i¶ƒ@{ ¨e¶R¤ªåMúŸZSUS”BT÷zú�^‡jÐR@ �júþÑožPYÕŠ~ë&‹îM›•—=¤oÖúCl"¹­j‡u›L‹š^N÷`ºWÖým3ŠjÃ'‹:NM——Óxý¦T ÖdÑ}`²uirš†ÛÑYû}ôÑGûþѲrÓkz¥¢ß@»ì²K¥Ùüt¥JN}¦”µ‚’h÷G á©–jpç]ìbÙcÿOµàÒE5ËTãºYµGÓë¯÷½jiªÅ€ "»(Ö»šÜ—k†o««jþÛàØî£�>Ò_NÿOÇ›Giçîªý|ôª'ÒúŽ�1"²€IôÐCE–†!4hPA+Í«ý¡Ö€=\ŠN:é¤È~ÈDö‡Ø×nL®×ò¬ûñšþ­nµW-ß]dM°Jž}¾’ëQmnköÙšHû®Úͪ=o�߸eCr~ «Õ‡ý1‹¬éWQ-pëS¡`ýš_µ]µN»Y‰¬©_4zôh�ÑwÚ‚J¾ÅMzªéž,ªY«}MΧZò뵦v±¯uìYgÊ~½–¯` ì'WeÕpOn£šáR­_ìæ­èk}öPÁ×âR«k6ék†©¦ªj˦·—U»]µàUßpÄç>|¬Sì‚u¨Vs˜¦WÕ4±@hdk8è�jªh�jA�ܵ~R-hµnI–>øÀ×D ­£Â2öp.Rk¦tK…ä²Íúž$×™5lA€øsl7¦‘5{Íš­[�S }?tN¬ÿÿ·´ÑÖaL×+]¯Õ Å:÷-:çú{mbEú»‘Giµ¿—YÇØ #Õn²‡¹Zfí{¹q]qoPn˜†]#`�uÜ3„{½ÚÃߪvêž{î)¹ÝSPè©�YÃ]ÆV#²ŠOE¿¹ôL-õ6YŽ=öØÈRè}ÕB~£�6Š[F&—Ñï#µâ -è“׌0ܯ_?ÿ[Ù°EëVeXÐï¡Pt Ño NÍÖ™~UÖ«˜âo‡õTzÕoWµM¯+ù^Nú-:Çş}Ó>j_“E÷Ê–R%ž×ÒÍÝO+†�܆~‡W*íì¬:F�£äqg +3ƒ²wXº¡š~odµF·‡¾•X{Út_ý—ŽÚðÛ²h×õ”Ï~¨:uj¬¶<vº{\tÑE>G»òdYÐ-ó Î:ë,g)$|'myåqWy念´³@Mæ~´êHÕP'Ê%WkQmQՈדlu„—•¯­šuªs D9 ¾fήÚHÇÏœVëHåk¶›‡x1=µ·ô>_<²Æ{Há;�–C²ØßçDr\­ÃvãꟜ‡å^yå_³>¼W-†jÿ¤Xj_Ë·\Ë$ÕJ•‡ZŠÔZÔ!ô�wÞYT»X­¨TÓ¾‘¢¼Šªé¬ã E5%,ˆÞ½Ú�±¯A¢VG*ªñZ®S }ÆJõaÒ¬ïIÑN&Fèû£ïQ²¨…ZGQ@ z�V¹7¨~�™:K@ýt¨åô;ï¼ã7©{Ý[©¨µ•äýp¥ÿÔw—ZK©v¡r9+�´ŠZØZ€ªÒâLG [ XºN§¿Á–RÆYÊßnuŒºf¨åž2¨f±¨}öýFYa… ~£´Ò�ëw¢~gë:§ª)=ûì³ûÖ‡–þ¯àwe+ìw»:ËN}ZE=ÿ›U¿[{Rÿpúgeü?}n” ¿ž¢¿_Êà ¾”÷]9ä“¿�ëYg7[f‚yô)nÝFG©ÎlW m›m¶i£=gW»£€‚§êlOA2ÝÜ¦Ó èBš°+=¥X@|u£t ú#QmÑ ýH Aæf4�+pW33ÝÈè§Ñ’lΧuõíÛ×§–P°XÁæZ‹nXôÙ ÉåÕÌL)*ôšÕcrÞ¬ájš™©=@Ѓ%uÂ’U´oJó¢fÏ!øœ5ŸÆéÆËjø:Ë«ìÓd•š/9^M4ÕâÉ'Ÿ\l×|�|6ÂvÔtRM(Õ ¦ŠÕF¯x³¢ýÒ|¡(MI¹R.x߬ïI¹í—k*Ž»ÜòLC�ÿàÞ€O”PÓÿйŸæQð=ÜK-“5^�&†¾uÿîYó2Ú_@©�[!=p­’ È*í®þ©[«—vu–«:SMþmh¶µþ~©ƒ_Jy�¶ ¸+˜¤|¦ F(ªŠj g˜Ê:Sh®À^{íå”GQ?®0VZÕ4WdÝü*§¬òÇ*Èh);š»ñn´6åMV-†•ƒ·TQÐO}=èa›ræ+ Š~h¨o…ÐÛz_îU7 ðnµÕVeŸ®«¹¥hqª1®ZY½Àk;zr¬Þ»UÎåd™gžy|ñY õÔÙR†ø'ÆêM^×»JÅ:UôŸ7õÜžtH.§€¯j¨ËÊR­8kÖX±6ºŒ•^½Ù«&ºZM”+zȤcÒ?õ#¡'ÞÊ׮Ͻj\¨õ‚Z„ÜÔåÖ¦éó ï�z>OÖü ÓëZ&XçÓþï�¾¥Š¾—Ú'õÞ^.¨�µ¼j©+Oª˜%ƒÎ²ÕþYg¦þ�‚ñ¡hšÎÏ®ÖχuFûš6š¦¼àÉÞáË}6â…m ß“äúÒÃ[o½µ³T=yuS•<îô2¼G�bî ŠMÓžºßyÛZê�¬ú'ÒýŠ¥è벃ÑÃoõ›õÙgŸùÊWjõ\ê¨ÜNŽ?Þ©u¨î×U�C‡ÕÇTµÅšÖû–™¡U©4 &龤]K«�ëvud¿@z¶@Û¥”QPÃò,ÇgM�P*(§À�®¸ýöÛ}ºŠ�?þ8sW¬—nw饗:ËÛœ9½#Û9¥Lúø°UMo5çRºË)î;9QÇ›ê ´«ÌtF33¿~ܪ‰°þ)½Šj²ëG¡^õYZd‘EÒtß7£™™ja)ÍH(êèT›æY,o»SÓiÙ+P­üúq«šõ•jÌç¹_]¹î¼¾'4ìʳʶ»“@+Üt'OŽ¥s”æOéÔÂO)Í’EAn=TÖCvUvH¦ÉSz¥OÓƒeµUôà^tUi!Ýç¨"€*„õ+èmyŠ‹Ò…jºõ©á[±¥[b©ò•jLªõ åñu–8l¢èU-ÎTiB•3ô!™O÷–JÅ¢JÖw�³¾„|�äJtOª‡ìªd£ý!†y°W:‹Ã;¬¦{ËÛ§€©%¥LØ®^UI!¤¢©5¥L½ç:¹}†h�îœR¦UŒÙ()àSÊ´]À]75ºÑÒ�‘nðT“’`{ɓ̄.P­ÕtW`P7äjn£Ú½ LZÇ‹¹ïQw ¸çŽÅ芀{C;Ì €@ tõ½A6›msÝÏn¾ùæEå¬ÃRj”[n¹%žd�…;¥ÈË*ª�Z»©5•ß颠{2¨®ÖcJÛ8räÈô¬™ïõ›qñÅ/š¦Zñ;o­X41c„u|îÓ&')_­¤U* |k«mÖ•÷FÎu%¦#ÐÜ»B�m"€ÀÏí™Ã])BlN%­( ´úq¢@@€{>í& êÛo¿}A°}¾ùæó- 'Nœèžþù‚NÞ“ÁqëÊ+¯ìÖZk-Ÿ—<»‚ìZg¶k¼Þ«£nÕp5Í•¾ï ƒ ‹ùWõ“ ¶÷éÓÇç§UúÕRWÍn=Ø Eû“¸«&ºjØ«RL( ìk>¥TJÃO?ý4Lò¯Y}ö,µÔRqÀ]©•Zg¡…òµÙß{ï=¿Ÿª�ÿÄOø”sJÚÊ¥ÑsÝÊÇÆ¾!€ ÐUm—ý« Ø. € € Д&櫯¾ò‡ªÔ1 F'û"QZ–;ï¼Ó©ÿå1Wà:Y”Pý¥¨ï˜[o½ÕOÒ¼JÅ’,J8lØ0Ÿ"O�_-§Ô�É¢ |(\p�S;»CQ«R¥ÕºTÒû£q§žzjlW T¥ÁQÇì¡(à?zôhŸÊFÁòRE)vT]A¥öK§8L¦@•[«—FÏu«û‡ €@Wpï u¶‰´±€:/½é¦›ÜÓO?]pW_}µÿQ­Zbª-¦fØjÎIA@�öP_1¡¨–÷Gás™+E¢ò›÷îÝÛmºé¦îÆot#FŒp|p˜½àUÁé¿ÿýïNúË/¿ÜçkWÇòÉròÉ'»lWº–t°]ó&÷G�rõE£ĵ?Z_ß¾}}çêªm®T.éÚíZG2uÍ•W^éïS4>Ý¿èØ®½öZ¿^ÕR/ÕOÎòË/ï”ææ¥—^ò�·ªF½:�Wÿ:Éê§ÕKÒ¶‘sÝêÇÉþ!€ ЙÜ;S›m!€m. ÎJU«,tl–<51×?•|ÐÿSsrýx¥ € €@û(ˆ­€zÈU~ÕUW9ýSQ`z«Ñ®´1ªµ^.ݧßJã¢NWTW‡©—]vY ¡t0Éõ<8ž–Øk¯½| \icVG«¡¨“Ò¸5×\ÓuÔQ™•êþå‹/¾ð‹,½ôÒEÁö°.½ªï%Õ†¿÷Þ{}ç­Éi�·j_Û! žÞÿôûf�ëôzy� €@O˜¤'<ÇŽ P›€òWÛQµæK7³®mkÌ� €]%pÍ5׸ýöÛ¯¨ÓO¥^Q�î¡C‡úÔ*»ì²‹ûüóÏKî¦j¹‡ô/ýë_}�ð0³j·‡ÜëêxUµÖ³Šj­ßqÇNýy¥‹Rß<òÈ#îÄOô5Ûï¾ûîô,>ç|©€{¥¢€¾*¬´ÒJ³*Ø>pà@÷»ßý®[ÛÃÁ5ë\‡õñŠ €@O †{Oÿpü €@ sÎ9§»þúë}ŽTåüTñtQÍ7ý V³pu°FA@�ö˜nºé|§ŸÇ{¬Ïᮿûê,õÕW_uo¼ñFœfÈ�!NÓÔi¬'�VŠªsT¥jQÇ¥ª®¯Ö¡W=¤W`¾\YýõÝzë­ç;#}öÙg�þ)¥‹j¼øá‡~Ñ>øÀm¼ñÆîæ›oöùãÃút,¡„Üôá}-¯êõž{þù�öKµÄ¿üòK§\òo¾ù¦ï6ž© šu®ÛàPÙE@:E€€{§0³@ û¨šþQ@@ { ¨ãÒ#�<Ò§Œ9ä�CüCt=HEµÒï»ï>·Í6Ûø|ê ¸kijÊqÇçØ+à~Ýu×ùuŸvÚi>¯ù•vf±ÅËZÔ?Üßu×]} [}Ȭ°Â þ_rf¥v9ì°Ã|3ÖYgÜ—[n9ÿ0@5ÔÕ«‚ãêØµ\QM~åiŸrÊ)ýl:fõcŠ}ôÑE´/ýû÷³µük³ÏuË0;ˆ €@'�R¦�Ù € € Ð.ê˜ôÉ'Ÿô�qÕ`O·hSй 6ØÀ-»ì²ñ!…ZæñˆÄÀ ,àvÞyg?FAï=÷ÜÓÞ5BµÛ�?þøÄÜ…ƒÏ<óŒ¯ÿè£�:Þ•�=]æž{nŸæ%ŒOï‹:y]j©¥üdMSîyÕ†/UT‹]­õÔ«jÒ«¨&ý×_í‡gœqFŸ/>Y£_zuÛn•š}®=ÿ!€ ÐèáÞÃ?> € € �xíµ×ü[ÕðVŽvÕFWu¥ŠSÀ\©S”�m¥“Kç;O®OÃJM£´2ª)®œë¡(ÝL¹Öþhþûï¿ßwjºîºë:ñg™e÷é§Ÿ:åGŒVéVYe•x8 \rÉ%nµÕVó5òµïóÎ;¯h `gŸ}v7nÜ8§N\Xúé§Ãbnøðá>X¿à‚ º©§žÚÝ?ûì3ßQëꫯîfžyfŸÚF(ÒTó_�°n²É&¾Ö}X©:�UG²}ôQåk݇7j)0ÙdÿÿS]A}=Ø8ýôÓ}Žú0Ï‹/¾è äŒèœ¨¨A(<ð€÷ ïeµí¶Û:µ6H–àÛÌs�\?à €ôD�^ö$>ê‰Î1#Ð]^~ùeß$W7ÕÉ›øîz¼ € €@sðU ¹Ú¢.J=S©ì½÷ÞîÒK/�gS0ù•W^q f—*�?þxÅ`~rYåU×2ºN—Ûn»Í×@OרOÏÞk] 䫦»ÊUW]UP“>ÌWÍë˜1cœÖ÷Å_¸f˜ÁÕú3üàƒvgŸ}v¼)yŸsÎ9ñûjô`D ¦Ÿ~úxö¼Îu¼è�}÷Ý×]tÑE¾õL¥þ!º`÷Ø$to� ö÷¶)eº÷Iæè@@@�šŸk®¹ÜZk­›³V°Î:ëøU« ¶kùcŽ9ÆM1ÅñªvÚi§²ÁvͨšõJ_£´1ÚŸPó;^ÉÏJórÊ)§øÚîYÁvͦ<ô�=ö˜Uð¹TQvÕB5jTÁñï¾ûî¾£Wu"ŸU à?üð‚I ®ë8lWQ¥ûï¿æ�‚~£”;2PíôdQZ�×ôjŠLöÛo¿‚`»–Ëë\W³Õ €@w †{w=³W� †{�=õ8 € ÐtÕÄ~ê©§|§¥cÇŽuSM5•O-£”. ‚×R”be饗öµ»8=z´_W-ëP ™'žxÂç`Wç§ýúõóëPZí[µEiq”>F�œªU¨ösÌ1‡S0]ùÛ˲'L˜àƒñJÇ¢T, ÐkûJÓÎ¥™çº�Ø÷ö †{ûŸCŽ�6ð5ÜÉáÞÆg�]G@@òPMðå–[Îÿkt;JíR©¨T儯µÌ4ÓL¾Æ{­Ë¥çWš˜�*&=­Ò{uºÆkø•æm§éÍ<×ítÜì+ €Í¨®ýY³·Êú@@@zŒ€:6Uu•É'ŸÜ§—é1Ï�"€ €@� àÞ£N7‹ € €ä+ðÃ?¸Aƒ¹W\ѧgQŠåaEédöÙgß¹iÇ+ € Ð]H)Ó]Î$Ç� € €´€ÀC=äN?ýô’{òÍ7߸üãîÛo¿u<ð@Éù˜€ €´£5ÜÛñ¬±Ï € € €@‹ ,¿üòn™e–qÊ ^ªÌ0à nóÍ7/5™ñ € €@Û PýmO;Ž € €´žÀôÓOïžzê)÷å—_º &dîଳÎê&™„ú_™8ŒD@�¶ àÞÖ§��G@@ZS`Úi§uúGA@z’U zÒÙæX@@@@@r àž-+F@@@@èIÜ{ÒÙæX@@@@@r àž-+F@@@@èIÜ{ÒÙæX@@@�(ðã�?öÀ£æ�@@ +¸w…:ÛD@@è� /¼ÐõéÓÇ-¼ðÂîÝwßí”m²@è¹Ü{î¹çÈ@@@�n-ðù矻C=Ô}ûí·nôèÑîꫯîÖÇËÁ!€ €@× pïúsÀ € € €ä pà 7¸‰'ÆkžwÞyãa@@�<¸ç¡Ê:@@@º\`È�!ñ>ôîÝÛm¶Ùfñ{@@�<¸ç¡Ê:@@@ºT`̘1îñÇ�÷aË-·tSO=uüž@@ îy¨²N@@@�.Hçkße—]ºtØ8 €ô î=ãÞ~ýú¹ÕW_=~Ï € �—÷¼dY/ € € €@—<ôÐCî�wÞ‰·½óÎ;»I&áço  €ä&ÀGn´¬@@@ +®¹æš‚Íî´ÓNïyƒ €ä%@À=/YÖ‹ € € ÐéãÇ�wÆ ‹·ûë_ÿÚ-´ÐBñ{@@�<¸ç©Ëº@@@:Uà–[nq_ýu¼M:K�)@@�N àÞ Èl@@@ s’éd¦œrJ·õÖ[wΆ٠ € `Üù € € €t �wß}×�1">–M7ÝÔÍ0à ñ{@@�¼¸ç-Ìú@@@:E@µÛúé§x[¤“‰)@@�N àÞIÐl@@@ _�¡C‡Æ˜uÖYݺ뮿g@è î�¡Ì6@@@rxì±ÇÜèÑ£ãmì´ÓNn²É&‹ß3€ €t†÷ÎPf € € €¹ $;KÕ†p§ € €�-@À½³ÅÙ € € €@S¾ýö[wóÍ7Çë\zé¥Ý€â÷ € €�%@À½³¤Ù € € €@.·Ýv›7n\¼n:K�)@@�N àÞÉàl@@@ ¹C† ‰W¨¼íÛn»müž@@ 3¸w¦6ÛB@@hªÀرcÝðáÃãun°Án¶Ùf‹ß3€ €t¦÷ÎÔf[ € € €M:t¨ûá‡âu’N&¦`@º@€€{ ³I@@�ÿcï<à¤(²?^§w¢žžñÎ,ž9+Š¢‚EEQNÅœÀœsΊYQ f ˜#&<ÏœÅO1ü=ûÿ¾uV]MïÌîÎîl˜Ùßû|v;UWW»g¦ûիߨ �k¯½6V4Ë,³¸Þ½{Çe͈€ˆ€ˆ€ˆ@k�ýµ‰ëx" " " " " " !ðüóÏ»_|1ÖÕ¿שS§¸¬hmr¸·6qOD@D@D@D@D@D "®¾úê‚z$'S€C " " " m@@÷6€®CŠ€ˆ€ˆ€ˆ€ˆ€ˆ€4�ºí#GŽŒ•,¶Øbnå•WŽËš�¶ ‡{[P×1E@D@D@D@D@D@šEàî»ïvŸ}öY¬càÀ�q^3" " " "ÐVäpo+ò:®ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@“ ¤r2SM5•Ûn»íš\—v�J�ýR$U�ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@«øúë¯Ý]wÝ�µÞzë¹ùæ›/.kFD@D@D@ÚŠ€îmE^Çh�믿ÞýüóÏq_%K�(4#" " "ÐÆäpoã  Ã‹€ˆ€ˆ€ˆ€ˆ€ˆ€”G •“™a†Üæ›o^^*-" " " -D@÷«jE@D@D@D@D@D@*Oàµ×^sÏ<óL¬x«­¶rþóŸã²fD@D@D@D - ÈáÞ–ôul�²\yå•å%'S€C " " " mL@÷6¾:¼ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ãüöÛoîºë®‹…;wîìÖ\s͸¬hkr¸·õÐñE@D@D@D@D@D@Eà¾ûîs~øa,;pà@÷‡?ü!.kFD@D@D@Úš€îm}t|�F¸æšk Ê 0 `Y " " " "ÐÖäpoë+ ã‹€ˆ€ˆ€ˆ€ˆ€ˆ€4Hàûï¿wcÆŒ‰åºuëæ^xḬhäpoWAm¨—ÀM7Ýä¦L™Ë(YjD¡�vD@÷vt1Ô�⮾úê¸aÚi§uýúõ‹Ëš�öB@÷ör%Ô�¢Þ}÷]÷È#�Äm}úôq3Í4S\ÖŒˆ€ˆ€ˆ€´l/ Q;D@D@&�e™>|¸ûå—_bá=öØÃM=õÔqY3" " " "Pkˆnç9(˜äd ME@D@D@Ú9ÜÛÛQ{D@jŠÀøñãÝ7ß|ã¶Øb‹Š8ů¹æ·Ûn»0�=z¸^x¡àÀóÏ?¿îDJ/ %óÖ[oÅÛo¿½‚ " ͈€ˆ€ˆ€´7ÒpooWDí¨�?þx<—t>®,sæØc�uŸ~úi™{©¸ˆ€ˆ€ˆ@[�ô[ó®@š,•šp¸ËD@D@D@D ½�ý½^µKD ê üüóÏñÒù¸²Œ™W_}Õ�{î¹q�©¦Ò×w„¡hç�˜»ùæ›Ýšk®ÙÎ[Úþš÷ÓO?¹Q£FņuíÚÕ-½ôÒqY3" " " "ÐÞÈcÓÞ®ˆÚ#"P_ýµcøñ3Ï<ãxQ«vÛgŸ}ÜÿýßÿùÓèÕ«—›{ý”Ô~è0f™e·å–[º.]ºt˜s®Ô‰Ž=Ú}ûí·±:%K�(4#" " "ÐN Hý�^5KD |¿þú«;ï¼óÜ™gžé>üðÃXÁÿøG·øâ‹ûĥÆ sÓM7]Üfî½÷^wüñÇ»W^yÅeYæþð‡?øè©#�<Ò­·Þz¾Øž{îéî¾ûnŸ•3Î8£OØ5|øð¨#Šs—]vq=ô�ûꫯBõîœsÎq”ËÛb‹-æhÓf›m–ß—o»í6Ÿh�ÓL3�;묳ܺë®·kFD@D@:�’…ß×9æ˜Ã-²È"n†f(ëÔé¼F œä¥üŽ/´ÐBîoû[YuP˜g…÷Þ{Ͻþúë¾ óÌ3�ëܹsÙõh‡† ¤r2úÓŸÜ6ÛlÓðN*Ñâ>úè#ÿ|šÊ0ÀÍ;ï¼-~즀< ?ü°›2eН‚çêý÷ß¿©Õi?(I@÷’h´AD š<ÿüóއ|æyÃÿòË/û¿k¯½Ö]sÍ5®[·nÅÎ8ã ÷è£�¬ã�ü /ôw^¨/¸à‚‚íDÑ_qÅnç�wvk¬±†ßöàƒºë®»®  8â‹EÚ?ùä“î”SN)épgŸôE€y 2èþóŸÿ8®tŠ¿óÎ;§<í´Óú„ä“'OöŽó‘#GlOp žzê©þÇ}j< 2¤QŽ\œõŒ:£cýûï¿O«q .¸ Ûj«­Ï$sÍ5—»òÊ+ ¶—Zxê©§Ü¡‡ê^|ñE÷Ûo¿ùb�:uòÏ]t‘ûë_ÿZjך_ÿñÇ»ûï¿?žgïÞ½Ýì³Ï—5Ó6è¸Zi¥•×'5ž‡Û«Ã�Q¯+¯¼rÚ\ßY–>glÔ‚ˆ€ˆ€4ƒ€$ešO»Š€´¼8oºé¦Îv"Þzôèá_ĉ` ÆËz¿~ýÎòÔþñ�8¢Óò¶ï¾ûúU‹.º¨¯+ÝN´M6ÙÄ¡%líµ×öë8&QòÁ˜Gw=ýcÿ%—\Òíµ×^¡X�éé§Ÿî£ùØ@û;ì°:e´BD@D@j‘À/¿üâGt 4¨Ž³�ó¥SšQ`8Òn¸áß±^Œ£Ø–]vY?.ïl§<îýû÷w}úô©ó|�Ödze–YÆÝu×]uœí”#úþä“Ov磌®r“&MJw/9�Sý�p_~ù¥?>Ï(Ÿ|ò‰»å–[Üí·ß^r¿Ž°� :]‚IN&�hÛix®mÛV”wtå?*�—J‹€ˆ€4�€îÍã§½E@Ú�m·Ý6JÈL?ýôîÎ;ïô/¬ãÆ�scÇŽõó$+ûË_þâ[ËKl>š¥oß¾îÍ7ßô‘ié)}þïÿÛ×ùØc�ÅMh±Þwß}þE˜(´`Ÿ—ãï¾ûÎ]zé¥aµ;øàƒý #/�á�ÈûþóŸþ%?Lf>øàwÒI'Å5§�vZÙCçãΚ�*#Àè3F›ûóŸÿìG¨ñ»¿úê«;äERËGÀ³íÙgŸõ£È>ûì3_§ 7‰DïÞ½»›i¦™b·Þz«_¢Ìã›3fŒvøñÇýjäéVYeÿ¾üòËûõ´<óo¼ñF~UÑåYg�µÎzž'Øxã�ëlëH+™l¶Ùfsm´QXÔ´ ×8qâD7bÄß Õ†Miô¡W\qEÿÜMí—‰€ˆ€ˆ@K�ý%éªn�'ðî»ï:œé:Œ¼“T4}�&’|ýõ×÷Žp†ŸcDž!“Ûˆ�cXw0¢ØˆŠÛ|óÍc4z¯O<ñ„QåZbzÐAE�É5×\³¤c¾%Ž­:E@D@D ­ �ü<ØùçŸïg²é6:Áq°o±Å¡ˆ[`�â<3tp£÷ýóÏ?ûõŒ*c?"Ïo¼ñF‡ Qåüî‡Qit¦“w%5¢âwÛm·¸ŠÑm8Ó‘…»þú뽄 QéÅrµÄ�ŠÌÐ>ˆœÆh¶§Ÿ~ÚýðÃ^išŽjŒ\ 0!ØvÛmçŸõ²¦mK€< \“…^¸mRÆÑù೜¾'”±»ŠŠ€ˆ€ˆ@£ ¨k·Ñ¨TPD =àe,µ††“ä,ØsÏ=ç�ŠI�îN8Áë¤<Ø¡Q‰S?Ú”DÀµ´~(Ú°80: xùOÛÚ£©ˆ€ˆ€Ô*�ÔÙÌï ‰éÇi6ß|óy©µË.»Ìýýï÷ÚÌD®§vÇwø©¬C-ð9çœ3-âcùÝçXAâ�ìè´ ¢xC„ü +¬à¥^òÑõŒ¢Ûu×]!*{‰%–(8V~á€pŸþy\MÔ>22ù6Æl9™ÔzÆKËv´y:…š›Pftô�‰$>tb¥ÒŒ�åúá‡ú‘£Œá3Ë´£3Š‘§Œö\l±Åü罜ýCYò;p>$Fæ™?ބ횊€ˆ€ˆ@K�ý¥Èª^�V!@2Ô`h½"ÓX{饗J&Hc¨9’0�?þxAuDÁµ´³�uÔQñ¸¼tð‚_Êx¡G3–6ËD@D@D V�_ç5�ßD”#Ï 'àrË-ç5Þùm.&ËrÏ=÷„â>J}Žì=öØÃwnãä#rþµ×^sÁaN2Ó`ü>ç�íaÓ#�<Ò‘ 'aØ?ݞΧÎövØÁ?w0ZOæü5gÔa0:Yê{ å:Ò”çÃJ$FBé /ô92I<¸‘ñY|ñÅýˆž7×Yg�’˜ JÙo¿ý¼ÜL(Dà²Kt pë3œãtDM˜0Áçheyö&I+Ÿ?¤œê3:æøN`ôIú£HH*R}ô´MD ¥ ðËH6ü a^8&#éÉ7'«v±e" 5DÀ†ÞÂ�Y$W �UéS¹üòËýùrÎåþ 2¤hÅÅ–ÙÃ|Ñúì%;»âŠ+Šî—_iQw±Ž¡C‡æ7×»lIÙâ¾�9/“Ì©·>m�j$`Nó¬¡ßD‹ÄÍ,K�Óã·1ü†šüK�íù¦ Ë›¤\ÜlŽÞ¸þý÷ß�ë›2³÷Þ{ǺBÛ˜véÒ%³hܦTY“ûŒ=º€Ó©§žZ“çÙÔ“2'M¶ÖZk0Jï§ü¼É(=Ô[o½•­¶Új�®Ç$œêÔcɆµ¿�É,·R�ýYaNÿ̤3“z©·.‰šYG\f�pEëásn7 ÖøÌ0à EëÑÊê'`�¨þ>Øšpz@IDAT°Nšê?�AM°|o%¿£¬ƒ³¦ÎµŸÌö;ã¤á™ˆ@ÕH£�Ð’$2�d¤�ù;÷Üsëœ7û3¤û©§žòÛˆ†!q)‰–0¢ìvÞygc? ~]cþ•S–úH Æð×Ra˜;eioõÇ:™ˆ€ˆ€Ô� 7ÜÐaŽ^úÅ_ìõ—Ék’F«üñÇ®wïÞnÔ¨Q§<óÌ3Çe¤%2s¦Ç"i2ÕtžDê•2¢vC´üóÏ?ïÌñé^}õÕJU_Õõ¹Œg´Âeÿ#P‰„Â<+3:’¼DÁ��á³DžžEóÖØDÀìKÂ_¤Ã3ëwß}ç† –¯Ò/ŸrÊ)î´ÓNóÏï¡0´�èú`3‡]öÑGmû{ï½—™C.þ®ºêªåL›=nëÖ­[fÒsÛÓË�£kMF#ûꫯâæC9$ÖcŽÁ¸¾¾“µ(º9�p7‰�Ì’´fµN—Xƴسüsóæ›o·[^‡ŒzS£ÎÍ6Û,–¡=ŠpO ÕÖ¼"ÜkëzÖÚÙX.¹Œïnë<Í,gLü^R„{Í\iáN¯LD †t4‡;—Ž,^ŽÃKE§N�2þ‘q9ñÄ3Ó’ôËóÌ3O,CYÓh÷Wž—b‹~ÉØ/ÔÁÔ"æ³»ï¾Û—áÅ{º�yèó/(~ûÇ‹@(oÑ=¾ G}tÆß Aƒ2‹š�Û)ǺúŒsÓ¯Ì,".£¾P7†RCtë«OÛD@D@D ½xöÙgãï\�=2Ó–.ÚÔ{ï½7–³èÜ‚28ØÒçž òŽ|¸3Mvg‘è>ùȘ1c<)äb0‹€qib®°#IÏH"e?|>yš½°„MqJbµãŽ;Αì,o$L³—Ÿ´‰„T´©T»ZÆÞúŒDl$³ÊÃìZÛ³gÏü&-‹€ˆ€ˆ@Uxýõ×c»Ç�ï�—0gœ3}fgÎqgŽm‡ ¿áÁ,Š=Ìú)RsÖñî<ð@¿Ìoð<à�©A¦â믿væØ/H�ŽT û¤Ö«W/g�îŽç´o¹å–>!*0æ(wÓM7�³h{ÿýÌ3Ï8stúÝoºé&ŸI Ë9ãŸ)H ™7d/Ì©“‚ÚÈ5/¥�ä ‰a-ÙËÇå÷«ÕåTNÆ¢ÿ�E%×ê©6ù¼š›P˜ûõÛo¿õÇç9Ú¢ÊK¶…ÏŸ sè;‹Ä,YŽ ]»v-º}î¹çŽëó²L|f‚ñyìܹsX¬3EÚ1ØÄ‰ì³à›8�ôc©„Å<û7”ø5V¤hc¼×ò›Áo•å*qH>‘0¼\Cn‰Dà¼oÚ(gMåVÑ®ÊWŠK%Nª½´…$ÚÈi}ðÁ>iû|óÍפӳfîí·ßöÏ1"Ü/¸à‚´óÔM4[>z>ì�4Ì^{í•qÝ2ÓœÏˆÞ û†é’K.Ù¡#áâ¦í" " ÕGàñǯó{~÷ŠMZh¡ Ù‰bfyN¼”E±ýÒuö‚šiVÌ��+'¹$õZ˜X£æÒc1"Ü)Ĩ»üö°Ì(¼Žb/¿ür‡]wݵ£œzÙçÙœ„ÂiÒ¾b#1ÊiLáþðÃÝ•Ï`¸Ÿ-H&–!j=µÊ4fÊ~AÚ‘Hþ°Ï•W^ë/6cZòñû@îÅÕÆºj�pgTõyç�çGQ#Áîk¦Œ°â=–QÜH=Y²¿Xü^®»îº™åNÈf™eÿ7xðàìÚk¯-�^¥ê´ °¢ïŽHæG‘X±Xõ¦ÆÈn‰‡ã0å}¶¥­)\h“u´gŒíe¤¸©e/¼ðBA“I® —PÎ:ß3ë\ϵ–·¦¶%_OXnN„;>d×Ù“Þ+œ'ÑòHæ6dŒü± Ï¥u0O½ÜsŒ²ïHÏ" 1kÄvIÊ4’Šˆ@ÕèÈ÷p±,b'³¤§^ê'õèÑ£3‹žñÃÈqœ·…¡WÉP_Kô”ñ¢�>k±ð¶h›Ž)" " í�/€¼,Î?ÿüyP,2¯àe2¼¢yŽV;N´úl„ ÙÚk¯ma¦Ô±ï¾ûfß|óM}Ud™›Ùˆ²ù—´æi'ZÒ•_P—%„ôç’–Oîhn¯³Î:ô8F,Â=C6§£˜�F(¸Î�>úhG9õ&�'ϵ8T,¡p¶Ûn»e–4ÃQ”ÞgÌç%ŠÐ7eúõëפc‡�šãp§:ºB[Ê�~þùç¾Ç{l¬ge}FÇ\8Žîõ‘ªîmÕèpë­·ÊêØ%Ð C-ÜÓašwÖ‡õé”ýÓß=ýQ§µRp#,¸à‚uÊXBâ‚2•^h*Ú‘æ HÏ�€·`0(Å몫® Åü´9m)¨(YhŠÃ�ïþƒ:¨ä³Q8WÎËFDäÕHí%¼ÖZk­:×4쟟Nš4)Ý]ó¥ HRÆn™ˆ@ `ø±ý¸ú¿örz QçO&" " "Ð0¤,�J,ˆ„Œ½”:ëÀvæ\w —¶/ ƒ¤KCfÎvgNw/ý‚üîVo#Õœ%fu9ØP¾¼EÒ:{Qwààld�ÿ³_?ÜŸ!ÿÈÉYt`�º�µ Ò6u6Ú ¤i�»éÈÆ�xK8p}¹6²BÜoôÃþ‘-2Mrÿ—–âÞ4gŒc;f‰ù¼R(ƒô Ÿ1˜[ˆÿLñü\Ÿ™_ÁK*Ù¨ÍúŠ•½Í¢eýç‘i³� itA’:‚Yô¾³< a±Î´”¼c�‚Z!­HÀ:™½”X*•„„Œ�¸væ4õÒgü¦öÆoøÅ�vÚÉY‚c/³Ægãó i‹Pvßÿ½¯i4Ì‚Òü÷@øž@ZÊFÎ8äJ-—Bؽ`Êï˜åjðß?|µ´5‡ mCrÖœä^†ŽeXòýg#×Yôfù,¼\–�ˆåØÀï�å�ùo!ûßܶĊ*0c Ü�uäÔ„ü×òË/ï,I¶³\r~÷�ü9î¥aÆ”g�ß™×[ç‰CfÌ‚¢L^*åe£ ü=wÐLýJ;äµED  (½¯šÚ," " " ›‰êíÍ5þµ,«K  …©uÅWŒ¬‘Vœ‚ƒˆY]DÔÚ‹‡3}ʪKZHb:sd8þéˆH!#.\wÓaô‰�êž±Öˆ€ˆ@ÛH“¥ò›”F ¶M‹ÚçQ+‘P˜33ÇÈ�)S¦øÑ$Œö0ç‹ÿ�`T&‰ùý#Š6MJ:nÜ8Eir?Τ˜üh�@Šß“'ð#¸†üöl»í¶eÌîó\Â(s ¹Ûn»Í™ì�¯†$æøq&%åGŽ�kÎ$gN3gºË>Êž‚Œr¡}$%6íjg9•œIkø:ˆ’¿á†œéOû$¬$$É2Ñü©ñ<´€ý.Â�(PsJ¥›5/­F€¨ñ`$Ù&Ú<5>O$û& ÛòwùÑ)¥’‡ý,ŸA�ïQ"˜ù ZþwÜqÇù¢^x¡Ûe—]Ân›2š„gÐÆß$#O­\HLnÒY~ÄÏÂ&C瓘§ÇaTÐe—]æWÁšdåy«D[òu6eùŠ+®ðן}I&?räÈ:£ôH.or8ŽwFýpÞÖ‰íLÊ®à�ŒÌ vÎ9çøßxq�ñËè;¸ðû€‚#.de(í�×�j$ ÷j¼jj³´´Mn!F&Ø#B�y¢W쥵åÑŽkF‹�hÁO?ý´h+wØaÏ‹ÄIÕbDAU”Oòœ^{"cH]*Édkž+‘‰\ƒ|«ÖlƒŽ%"жÈ¿“þVuïÞ½mÔŽ�^É„Â$,'i)ɉCth¯^½êüðà L´ž$E–Õ�jr¸[r¼_wÞyç&_„Ôá¾Ùf›5XOšPÔF²Äò©s¹9÷~øÁ®øl5æ/ÿ-¢yhU©œŒ9@]ß¾}[õøÕt0…V2¡0IW‘~øè£�¼| Ò 6úÉY'¨—t±NZgΘ:¿%H^äe/ò©i¶Æ2;—…1‡ŸOúG²C’¹"m€´Ó†’$Ûè/aCbdI"‰c#¾¼œš9½ôB�ÒhL»TFZšI;ƒ!R ³è÷z“!ÛÈN/Óıf™eg£W*qØ‚:ø.oŽUš‹�vðïC$–½æšk|ÑEYÄK­�Cz†ï»¼Uº-ùú»l^æ…ï·rÍ:5½¬h^:kà 7t={öôßÕÈvñgAœþ»9/ IÒÞ½{{é/Þ�d�$P¯O^E@ªŽ€"ܫÁ"PqD Øc€ÿcˆd>Nþ€$a"z�}^xáÌôRóEjv¹¡÷j;ñ!C†øëˆœŒ½P”l>ÛÂð}áµ¥)½-éëØ"ÐöÞ|óÍø›Åï�ép·}£Ô�ª&PMîD‚‡$˜Hƒ ±Õ�1"„Ѭ©¥î|—š#5ûî»ïÒ"~ 'ÓJ�ß»æH-(“F¸×'åB"NŽS*ijA¥MX¨—ôÐŒçMÄ»åĈì‰Ç—RÌZ¢-á8åD¸³£àΟÐø÷<ÞõóŽÉ”w~o×Xc�Ì:\ÓMqþ½÷Þ˶Új«x¼UW]5nÓL½|„ûTv‘d" " " 5B€è…aÆù³1g²�p&®>#zÛ$U|s|¸áÇ×WÜo#‰Ùĉ}"V’Ž•c?ÿü³�¢0Ý@"JÊÙÿ•W^q÷Þ{¯³Çœ:»¡÷ÄOøA&Lpö X§L±Åê*V®¾uœË3Ï<ã£ÆIÐÖXƒm&)Q7Í1"š0{Aª�˜Ök/në­·ö«ài/wéæfÍs¾úê«þ™Ž¯O˜ÅýR)kîý3yòd7~üxGtW1ã~~à�,K•)¶ŸÖ‰€4�@ÝN D9ËD@D £ |ùå—÷§KDqÿþý}Dq©óg„ QØ$´$¹”�;Ö'Z=ùä“�9ãý³1‰3‰êæ¹#q1ëR#š›'ØË/¿ì¾ùæ›t³aÃèq¶¤µ—#Ž8Â%Ž‘ltРAñÙ›¤Ï$ -f-Ñ–bÇiÌ:¢ðƒ�vÚiñ]�÷½üï&¼_�,•çßÔH$M^žw­#¢è;ÓüóÏï…ýBÄ{XÖ´õúäµQD ê(½ê.™,%póÍ7Ç(“ itÝDÊ-Ö9æ˜#c9Ú®ö8‘¡wHÒœ=zèŸB”ô­·Þv):5Ç®×mM“ó؃~fÃ3“¶©³Ïõ×_ï�»ì²ËúmhÁ.·ÜrñüR­G“R)ˆÖ¡½á�è’Ì3gjÜʤS{ E³RîDƒ°ºÃD m²É&1ùT¨ mL"gJz�DuêÔ)¶Ç†Îg$}#êÄ^ˆüz’Ú5ÖH4Èñíe©¨NcZÏ矞¡ÁËß×_í7…ˆ0¢•ˆæ)eè=r´.mÈ,†N|580�}öÙ}Ž9ËcY4|Ó2é<÷DÞʽÌ©îëGw»üòËãHŽp¬E]4¶ÿµ×^ËV_}õ¨ãIîm{±)™T7ßF-‹€”G€ßšô;ÃdCê�S^í*-"ÐQ „ç™jHšÊ5²€ Ÿ!<ŸðlÈó7yyÌaž :4³@‰l…V(xv"�j°|„{¨«ÔÝrsÞ‡Ý ¦Œ�Ãsø!‡’™sÚ?ïçëãY�gºG}´ ŽJ,T‚K¾i‚Ôp.Œ0°`‘|Ñ‚åJ´eÒ¤I §y×âÙ˜?F¥†v�s+¬gJ>ŠcŽ9¦ ,ðlöaJBTîyrmX§‚OË{õ…r&ÉUðûÞ³ÂvÊ2Ú�{î„NÈöߟœ—gáPfÀ€uÚ¢E (ijQ,Z)UN@÷*¿€j¾4“ÀÁìŠxPŸ2eJYµá T ' î$B Iux(ãA š°Ü¥^lL+1¾H˜þªß—ø�¤È"G²ûï¿?ÒOà ån‰8‹ip¸SŽc‡m8lÖ_ýØ�Àzû8l±J:ÜO=õTŸŽc�Œ ™–´�$-64˜$¦á–)Ià,º)®£sÃô4ý9•ãpç!;p0ÿ’CD=ˆ"ÿ,R*îoÑ0EJüw•E úr8øƒ‘œ5{¶ÙfËØ¶öÚkûd¨a=ÃRCgN9÷¦Ü?©ÃÝ"€|Û¸oKçR¸g`oÑ=þå‡.^2iwš¸o½õÖ‹íç«©ˆ@ó <øàƒñ{ƒï œ:2h.�js¸s¾<ï…gÃðÜTß”çÄ4ypêpÇ1oQè߯i]|<üðÃ%1ÛÈ£øœ”îWß¼Eˆ—¬¯9šË%ldRRG4çD€Mc¬¹mÙo¿ýJ^“Rly^ �1¡�ûiÈRûå×ÿýï/�%)_¦¾eî7Ëïš iýäp¯Ÿ�¶Š@u�ý:¯›Z-•"týp–k8¼Ãƒ–I¶Ä݃Ã=l#ê!Ír�î_ê<å�?5"‡Ãƒ-ãiG€ MÌp S7Žxô䃇;çýh â¶á‘¾˜ÉÄq‚›Y²·°»ŸâÌÁ™Oý! ‡/º—üuîü_íú3Î8#® a*h(ÂýJ¢TÒ!Kx•™DOdyÒI'´)D‡Ó&®WúmÃv}DS`Í´‡» �‘ñìKûè(¡3ņŽ]ç‰TCd÷Þ{ï¸>8ÜÙ—S¤y7nœ¯›‡þR(Ƚ”:~�2HÏ7=Fp¸æÛ$e¨7™öG®„í}úô «üt�uÖñë‘/A:&o<¯´ÒJ¾ û—ãp§.¨¹þÅ^Öˆ¾Ç‘Îù~üñÇùCûe^°8.ÞÅ"YhÛqº‡Î:XÇ¿CŌȶ‡Ž�P¦¡¤©M½‚Ã�cY_ÌBç‘í óÍ,Ãy»ÿòåµ,"Ðx|gÏ8ãŒñ3ÆçQ&" • P­÷pî<4B¤9£ôx6ãY‹‘ˆÅžÙ¯˜Ã=Ô×Ô)Ï÷HŸqÓM7ùà�40¥©õ6u¿¦p)v,žÍÃó£J›b•jKSŽ�îÃý€¼#ןç{ž«y7!`%<§§åKÍÓ�Ã=ƽvÖYge£F�òNåÔQªî¸Þ;Üÿ›-Àî4™ˆ€ˆ€ˆ@õ0]n&éQöÉXCÜ'ÔWØ ‰•,z9]ç-‚ÝY´‹#‘ÉyHjNc÷Áøä™$QQ13Ç®;ì°Ã\ß¾}}òsÈ:‹Ì.(J‚O{8.XÇ‚éº#F8sÚ83‹Èð«-šºØæf­ëÚµ«[wÝu‹ÖÁùXt»³ò¸�d¢öå—-Ú¤hbSÁy»í¶‹û•3C-{`v$C…�=tû·ö@îÌÁå·±Ýä‡ÜàÁƒ�iC:Ó�Œ‡€µ yup»ñÆÝž{î·1Ã:ŒäRùäçIöe~ŸÈ–ëwñÅÇm¾€ý#ñ–u®8î•ÆZ¥îX3ëq$ïµQÎ"€ê�%çh‘ñÎF.ÔÙ®" M'`ù# >W}ÙôÊ´§ˆ€Ôž?økkã™Í‚Lü_[·…ãW‚ ‰f-ï”? Øq‡~x“N­miÒ�s;YP’[pÁý_nSY‹¼;ZÀNYû¨pýäp¯Ÿ�¶Š€ˆ€ˆ@U0}=gº~ΤUÊnwºny[sÍ5�E5çWÇe‹œŽóUáîíì×áTgÞäb™t&8øM^Å;fqd§f‘JébœÇQÊ_j‰á8¾E,;‹Æq–�5Ý\ÑùbNÚp:(0œµÁ–M'<¬®3­o[�Â%V˜N¹³aÄ~+ÎbÆêlh±³d­ÞO„EÂø‹��ï�ý]t‘3ùž‡;lï¸ã_§EÅ#[bRg‘ûÎôñ�é­;ê3¹gCT�Eò»¹çž»d‡H¬¤ÈLàÕÜûÇ’N©ÝÅNž]t;+éüI¯aÉ‚ÚP蘢³Ë†Ü»ÝvÛÍüñ5q^íñ$,r36 §�}2hI6Z׈pŒ�vÚÉÙÌ–<œêîÀäpïÀ_§." "P{LRÆG—¿ýöÛeŸœIÊÄ}òNl6Ôç”d;æsÎ9§3]vgZˆ¬òQÖLM&Åm»í¶Ì6h&cR§Œ%g­³.]aº‘näȑι7ß|3>HuM'�%.M‹WlÞt˪+0Æošå%÷Å�MÄŠ Û-Y¦œ ŒÀùÍß‘G鯋éá{g» öQîDã#ò‡»éT:¦êèÈÁp¶%OGƒiP†âqÛà.¹ägr5>Ê�HwŒûi‹-¶ð‘û¦Gé×5æQúXsïXÖg m¯o_m«-6”:Žâ0ÍRït·D̵u’íàlùFûÐËåáÒQVí ‰j‚ˆ€T‚N=õT÷È#�ÄöÞvÛmÎò¹¿üå/nýõ×w8™y&îhFÐ�Éá¸×_=¾0â2ÌUzöÙg‡UšŠ@ÅÈá^1”ªHD@D@ÚžwÌ™ºwß}×-°À~¹1ÿp¼ õ„e¦�qþâÅÂ482²™FÀûB%þå¥aØ×“-mÚ’®W¯^^6…8ü‘rYd‘E¼“—a°¼„ >¼èþ­½20¤Ý¦gXòåÇ’Á6ŠwÚ~œÓ'NôŽú†ähˆ~§s‚á°–ð´ÀñE�HÄ „4Qî8é±n¸ÁOÓèv¿ÂþqÝpÒuÔQ^¶Æôõ÷÷"R:DÛóÒCäpÞYêÈO+qÿäëÔ²ÔGÀ’øÆÍÈ Õ×1 j¦lŒ„ ߇ì,9™²jðLãÝ�.Lq|óÍ7Ž?Œç=žÁ-OFZ¤CÌ#wÉù—2FÞòÇ»#ye"PIr¸W’¦ê�6&€óç(ÎÜÓO?Ý�þù�jzÝD&cH€s2½÷Þ{õÖ…D‰%ÜñeBDz�ò@¦áæ›ov8ÏË5¤JEå :Ô;Ûqö™Š$A©²å·%ÊÓ€¡eþé§Ÿú‚bÇiÊdt,É«¯nµÕVkP˱S§N®wïÞY‡çŸÞ;¿‚ƒ›JˆrOîÜ#÷Üs�¿† (Öl¿ŽNòÁ)Ï‹ ÷áe—]æõšÑùoè^ •Wâþ ui* à^}öÙgc±þýû;$–d•'píµ×ÆJõ²á†Æe͈€ˆ€4žÀæ›oîr`taÞx®#ÈaÙe—Íoê˼ðÛŽde1ã�¡K—.–O1&ZW9õ�¯­ÜqT“ˆ€´kèG‡ˆÜvÝP5N ÀCcÐÁ½âŠ+Š>|«‡h�]!ée1Cÿ;DËÛŽ36Xp¸I�ÉøÒK/…Íu¦“'Ovg�u–ÿC²¤±Æ ¶ÕV[ù$žÅœí8¶Û‹¥#B¦bmC§\K£Æ'L˜Ð¨ÝC ’1©³��IŠŠ Ãpq¼Ó^"ó7Ùd——…áx^x¡�lϧù\àvß}w¿‰\AZ'_6¿ÜÒ÷OþxZîØB§c 0hР0«i UŨ—`tà‘§A&" "P>î*¾ËîÝ»ÇC„„²q…ÍÛ¯¥ïŸôøšïØu’vtÑi¾Ç:6™ÊŸ}š,•Ú%'SyƪQD ãà}–Q†é�Ý(I™¤óhÜËD ¥ÈáÞRdU¯ˆ@Uø÷¿ÿí£2i,z×cÆŒ©Šv«‘"PœÏè9ò€‰Ãy†ïðÁq7œKD-ã$%úƒtö;óÌ3c™b3Ǽ;üðÃÝ”)Sâæ¯¾úÊ!’5‘˜iê©§ŽÛ‰˜'òü®»îòåÐ ÆOt¿oºé&¿j×]w ›5]j©¥|9ô€‰îImüøñ^¦ DÌ‹ÎÒ9DÿpÈâsü¦õ6w-s Íõ�6ÚÈ_:,hçØ±c}' |›ò’týõ×;¤b`Œƒ›‘ éµâ¸Œæa4޾éàØi§�ØTÇ�•ÁFŒáà9÷Üs»ž={Ö)·îºëúuèµ8гL ‘H-}Œk–FȇkÀ îIÚËý¬%ïŸp ME€ßÿ4as¸÷E¦²~ùå—ø}OÍ$õ[n¹å*{ÕVUiÅo×É'ŸÿBÂìª:5VD@D@RöR)¨!–¥œÎÌœ5tV-w*æ€ô¼`Æß9çœÓrSÍ"ÐÊ,²Û„û›é¼óΛYÔffÉ î}‹lÏÌù]´…6TÕ—íÑ£‡ßŸzløfò5™ElgæL�uí»ï¾™9ïëÔsöÙgguïËQÞF”d&�’™c>îkNû‚}íÜo3‡p�ú “€ˆû›Ö»?7K”šÍ:ë¬~½u"dtP,Óµk×Ì$MÂî™9‡ã¶ÀÉœïq»i¢ûí[n¹e\Ç Ç ¼E’¬Ol¤�/³ôÒK§«ý¼%fÌÌ1�mß‘çañŒ¶s “r©³}+¬ó!ÖÅþÓN;mf£2‹bÏ,jdÃ6Ø>ôÐCõU—­¸âб�‡rHɲÇ{l,ǹÁš{†û$\gÓÚÏxà�‚:Þzë­¸�6ñgNý‚2M¹¬ƒ ¶Çœøõ…sªú2¦eVÕ™Z‡€/cQ¹u¶iEíØ`ƒ âýÂýj�GµsríèL¬s5ræ³n�¼í¨uÕÙ“VËàj�©Uy–¤»àžà¾°QUUy.jtû!°Ç{øûÊFW¶ŸF©%" …€×GU„»ý¢ËD@:.ûÆ/8ù¼†qÁF-ˆ@•@&„d˜}ûöuætõ­GFäñÇ÷r3¬èܹ³O®zÛm·¹™gž¹Þ3DÞƒ(vs>ûrÔMÑëD-ßxã�^V†å¼í³Ï> x¢í‰À~ã�7ÜÓO?íˆìžk®¹œuvù(êbûæëJ—‰BEÊfŽ9æpDNrn‡(nt�Ÿ{î9‘?Ûl³ùÝHˆ˜æk@~g³Í6sloÍÏÿ.»ìYÎ?ÿü¹ëñï£G�ö‘ùD…cœ[9¶ýöÛû‘ ö²é¯;Qû$T½ÿþû}9‘ühU2²�kˆìP}–Fú–Š„gd‰È@b.´ÞaMT<Ç€mŸ>}܃>èÖYg�‚Ã1²‚Q‹.ºhI�Ñ–º ¢…K€Ñ1|>‚!­ÅhYå ¤r2Œ„"1­¬é�U³Î"ŸÇ$ȧ5½¶¶Ù“û@&" " µFàt/ÔÚIé|D #Àù†ë§C£;2“úÎý½÷Þs ,°@,‚ü2¨5H‡ ×Ažœ»è<âèlÌP~¥$ÌÜyç�£¶8Úã“&MòÎvê(Gw‡7`†‘£9nQ÷ÍvvãlG>'5ŸiêM�÷AB‡\ ©œI{¹Î8ÁéðN9s�0Ω\§{8/äYЄÇ)ƒS‘zpð/¾øâ΢ÍC±z§Hº 6Ì;æ-¾Þ²a#Ç¢s‡û„óàšTJ'³%îŸÐnM;&�Q�câŽ;îp6ê¡cÂhÁ³æ¹”\¡Óư–5�r_t²bGy¤;æ˜cš^Y퉴^çž{n”¦#oHÈ!ÒFÍÒa«œïs$s'R‡2hESì=ôÏJߊÄu(�öG ßç˜:èÚ_kÕ"h:ôÀƒÎvÓkùßž8OMVå+ʘ39ß1XÆ. 5GBRþŠIdÛKD^q„›ÜJìð0 œ‚f£I�‘\´©ÎvöÇ©N',M1¾#MþÆïJ‡Kc�èà–Šn‰û§±ç¥rµI |Þ8;:ˆŠå)¨Í3oݳ‰œíYÉR›ÏŸÑDÁÒù°®¦äñ`ä#èB.˜jh·Ú(" " õ�ý>:Ú&"PóH™Zˆ.M×i^D@*I™F àp¿ûî»äÔ^}õU/óúÝwß=ÝÔêó8ÈLcÝ;ý·ÞzëV?¾(-Mîñ`t,ÑA'«<�´cƒ=H÷ÈÚ«“øšWadÒì³Ï^v½Æ¨*ê¡Ã˜‘etËD@D@D #(|ÃëHg®s# wÝ" ­Màÿø‡»óÎ;½¾9šöh¤�ΰzd,A¨ûöÛoQï‡zhk7Ïw ¿Žüе×^ë�à�Æ<­Þ PZ�Àå—_^P»%J.XÖBe¼øâ‹î…^ˆ•m³Í6>ŸG\¡™F /y@�øÂ©Œ\(Ç‹qjI³½,ùJò6jÔ(Ÿ?Å’…»bR”Œ C’�øúŒ|,èóüñ^Æ,-KF� 5¶ÐB ¹‘#G¦›ë�ê©§üï ÷O’! #ìÈýÑ%âê=!mè0äpï0—Z'*"PŒ@Þá®÷b”´ND ’6ÜpC‡“c×]wõ‰Eqnç ùŸK.¹¤ÁD¶ùý*±L´/–`´wÿý÷‹šŠ@Í c‹„ÑÁH ¼ÄK„EM+H M–Jµ’“i:\’O3ú(o8âùËÛ“O>éÈÅ‘w¸ÓÒ¯_¿|ñ‚e‘‡ß¬-¶Ø¢`[X ‡ #¶~øá°ª`J›ÂçŒNåÃ;Ì-½ôÒeJ-àTà�êl¾å–[|’ñAƒÕÙ¦"ЖÈÁ“väò££I&Åè~)F¥vÖÉá^;×Rg""Ð!Z&ì* ÷@BSø�ƒ:È'/#©¬2p|l¼ñÆ>Ò}âĉ~? ‹.º¨×¡_{íµ+s &ÔÒ½{wwÀø@]»vuHɨ3² µK»'€ÄÉ�?þÛ)ç]DQÑtÛ¯¿þúX'#«®ºj\ÖLyø}@Žg„ > zá6ÿË2î{íµW�ƒ�8�ü.$UÇø ¢ì /ìЃÇQOòkêGj‰ß­©§žºN=gœqF�³�$ê]ºtñ ºß}÷]?r‹ÄåÁHäÝX‡{>¿ u�›„w~Ce"ÐÞ�èþ�C‰Íâ^¯f‡;a:¸èx[`�âyuô™Jq©µû¥£ßùó—Ã=ODË" Š@xI '-§R ¡©ü�@{I6ú¿ÕÆ:Ñ}úôñí錖Yf™¨!ßžÚ¥¶ˆ@¥ ¤šâhL—Šà­ôq;Z}cÇŽuŸ~úi<í�ÆyÍ”O‡óí·ßîw$’yìàƒv'Ÿ|²ŸoÌ?’Ÿãü~å•W¼£ÝöÔˆLÇùŽ®;£AþùϺe—]6-âçÓD§çŸ¾Ûm·Ý óì¿÷Þ{»Ñ£Gûò�qÚ!QÃȪ³Î:+ožyæqcÆŒq+­´R\§�–%@ò‚t’"=%û/qÑ�Ðr¸7†’ʈ€Ô,E¸×ì¥Õ‰‰€ˆ€ˆ@IÏ=÷œ—t ¶Ýv[%v 0*Â]’2ò6ÐI‹€ˆ€t $y¼ñÆã/¾øâ>ò6®ÐLÅŒ9Òë�‡ •,5�hû)ð={öt|šcD­#qƒ¤Í¤I“ ªBþÑGõ8ÍùëÕ«WA™†¨óË/¿ti$}Cûh»Ô:ÁÞ{ï=ß‘ÅHòüüñ�å¹ð¾øâ ?r嫯¾rsÌ1‡#‡jíÅ>ûì3ÿ½ÁòJ´–¶¯¿þºçßÎ�;·Öá+~:<é@e$�ä ÈË„5ö ßÿ½û׿þå~øá?"iöÙgo쮾m!’eÓM7�£S¡£æ›ª,r*," 5F Í£÷»À:ȸù曽/¬&BWÖ2R9’iJ'¿e8—[+ήEp¶ãÄ#)êa‡æN:é$·çž{úü"8èc$T|ñÅ}¢Õ‹/¾Øë¸#U“JÀ|üñÇ®wïÞnÔ¨Q V‰ƒ'DÒ>ÿüónµÕVs¯¾újƒû©€´îm>OÜïŒâHÿ�+kÈn¸áßéöcDÈu×]ç%™pTn°Án©¥–r|‡xà�Žü õ‘èDÙãÀFj•UVqm´‘[a…üòæ›oî�׿ÿ¢Õ�+�Ïí™ùä“6oS-6àµ×^‹œyƲd©µxšmzN¦�[„y£Ûrâ‰'ÆýLâ'³HÄ¢ûšÓ)–3i :e̱—™³-3‡UfZïu¶³Â"t³­¶Ú*ÖcÉ‹–³Äª±Œ9Ò2sÊdæø‰ëÌ)”Y‚Ö¢ûj¥ä ì±ÇþÞ9ꨣò›*¾|ÁÄû4¼S†é&›lÒàñ–^zé’û‡zÒi—.]2“4)Z/ëÍÉÙèúlI�zÌÙÚèýC»î½÷Þ‚z^~ùå¢uôèÑ#ëÓ§OÑmÔeÑÐÙ�?þ˜Yè:eºvíZp ëP¨SÆ:% ʤ gžyffÎà:û„sÈO_zé¥t÷¬\¨°¹÷Kh”%$Ï,нÁó±–ÌF8„ÝüÔ:>Ü/å1õÔSgæ¼/¨#]à÷�ç©tŸRó}ûöMw­Õùìü�"Ü¡ è°ì¾àÜá^€C " " "PSn�”F0"ýÅöÑ´q®ºêª‚‚’“)ÀQ‘…é§Ÿ>Ö3qâÄ8ŸÎnNG·Í6Û8ëñ›ˆ¶Ï>ûøèΰ̔D©ûï¿¿»é¦›ÒÕuæ©ýöÇ{ÌY‡Š—¿ÈB³?Í‘`\ù"u–͹ãˆf5»�À¤’æ¬kT„|� µBZ�À¦›nêïW"{‘'-W¢tß}÷­ó¤¹ÔcÎxׯ_¿‚Èm>wgŸ}vÑ3:ãŒ3ÜÃ?·ß­[7]Läs9 û‘7ëüòÑÒ|S ç–N‰†æü‰¦N�¤ÉÛm·��žNyŒ?Þ) fDB‡vñý€#Ö^{mשS§P´Î”hÿ…^¸Q¼9&ßiæÌ÷õp\"ÿ‰ò^~ùå‹ÖANŠÔ*Á…úš{¿PdzÏ>ëG Ƀ…{Å:7]÷îÝÝL3Íä×óïÖ[ou¬O¥tù~eäD±Ü$reDîáº0j‚óçÚä ={¢×ýõ׸‰Ñ[n¹¥M�ÏÛRìž‹;ÖÚL­v'è¼D £P„{yWþ¹çž+è‰5­Ñò*Pi�ª!pøá‡üîßsÏ=UÓöjj¨½ØgDNÛ»³ÿcžu²Ê0gzdl9zôÑGgü™“;3¹…¸�kÁ:ÌdcâzÓsÎLW=;æ˜c²Ýwß=3ÇYfN˜¸=\CsàdD§š´@<‰ë¯¿¾ û™\CfÄì„NÈÌÁ•™Ó&£m¡žÄý™!Jߤ.²i§�6–19�X&ÿ¬nÁ1~$¯ÉPdæè�å4#)�ÖŒpO�Ë<Ÿ‘p¿7&Â�}LB%îþ&o’™L›¢�þù± QìÅÌ¥± åÍ ZPìÃ?ÌÌ™Ë䣸 Ûçá\ˆ¼ �·ÜrKZ¤`¾\B…åÞ/\Sî�ÀÒ:7 ¾—©—2–¨:ƒs(G„Þ¬£4n§œIêd¦Á‹}÷Ýw™IïÄ2<ð@Üfžz꩸ÝrdðN�‘Pæô�£ ¸ÿ:€ù÷ò2.Ø�‰€ˆ@-H{z9/E¸×ÒÕÕ¹ˆ€ˆ€ˆÀÿØ ž�Æ kУ%bVVy÷ß¿OÞj&º]ÏX�F妋-¶˜�,4Ç·�^$Š3�M�„N;ÚŘ9#�É(: ÔqhùÞu×]þ/-ŸŸ7‡”#:•!& ã7£{œšðwÞygºª`�dsú¬C7âR–�Üçsl¯ŒÖ;Q»2¨%|ƈRG—;5¾G‰2æý•dŸÅ,M.|Î9ç¸)S¦¸e—]Öq޾9šÝÖÉåõËÑé&‚¾µ�Ï-ß?D¶#aéi§�+:åX!{s¤ÇÈíp "õwÝuW?ª†Q;šèíÑL¾Å'H¥mhôó{›æË`=£¬ÓÓ'›Þk¯½XåÎ;ï<Lj¦tÄ�ßðû? HpÇw\ºÊ'`%R=\î;"ßSKï9F :Ô—áž#)=#±Ðã'YýC=äöÛo¿t÷šž—¤LM_^�œˆ@CxhO­ÔPZFó" " " ÕGÀôN $/vÙeÿRZ}gÒþ[œ&K¥µ$Õ“µ �K/½Ô;áJI/X$¦ÃáBRS$”0œK¦¹ìeŠµÊ¢Þý5#™`0:L�^H¥�pØ!=€d8õ‹Iùpþ …�ƒ(5d!ò’éö m�žm!áb±Ä†é¾š�j$€c<ïlç<ø\™— �’??’€œŸ–ÛÁ'å3Æçéäh,úÙþ[»#'6ß©³=•^æ»/òZ�OX—N�<òH/µÂwf{u¸ÛȼØd:,óÎö¸Ñfè\EvCÊ%ÈŠù¹¡#5·ÚÍ<óÌqU±ûŽû‡z0’¯ò›OB[îYäeXæÞ=ýôÓ£LX(_ËÓ⿈µ|Æ:7H(Â=�¡Y¨a¼¦¶Ã;¤‹š¯"¦Ó(kœ¶6̼Bµ«š<¢‰d5)ïT·$¥~4Î"" qv3"]‰8$¢Ñd%üˆ"O‰45é‡ösC†åî»ïŽÅ¾üòK÷ôÓO»�?þØ™��¨ÅÙB”#šÉÅ ‡;¥ŒvšŒA©ÍZ/"� ìöÛo÷ŽvKˆšlq^ûÑGuüÑQÇŸÉI”iéKøêèlMãû-ǯÏpNÓÙžíí·ßŽÍ+å$&äžxóÍ7ý*œî-Ñ‘@';òÜShº#¸‘còÇHž»ø½J�ø¡l-Nåp¯Å«ªsh4�|„{k÷ò7º¡*(" " "Ðd$\dv°u×]7F}…ušV†À¨Q£Ü?xùR_a]™#¨–bˆr¬/Ò±Ø>¬[tÑEý_©í嬟m¶Ù|Ä{9û¨¬ˆ@e l¸á†>‚œÎ¯^xÁÿ!EÄ{HZL§S¦™î“[V¶í«¶4�h±¤Ÿí«µ ·&uVOž<¹ÁH,eÖUbJ½HÖqÄîñÇ÷�¿tt�´û­·ÞŠNøk®¹ÆoC*,ŒÖ¨ÄñÛk’”i¯WFíhùwIÊ´ vDD@D@Z•ÑWiÔ•%�lÕãw¤ƒ¥r2–ÈÎõëׯ#�¾ÎUD@Ú„ïµDwëÖÍ�2Ye•U3]t‘ׄÇÉΘ­¶Ú*¶ïŒ3Έó ÍäÕ*_éí–|³IU¦Qàõå˜H+/&�’nOç[›K¥ON Krš6§`ž\O>ù¤_gI­ý¨§‚X¸ï¾ûÜJ+­äósüíoóÒeH÷ •OG�<0 Câ‡}:‚ÉáÞ®²ÎQD $�ü¤"ÜK¢Ò¨Z©Û e]µ'ÔNŽ3‡¤hÁÐuM£ñÂzME@D@*Kmt~>öØcnàÀ�9K‘ÐrO;œCÄ{ØžŸ')ëó ŒY÷ÓO?ù(ùm¶Ù¦NBd¶7׈œïç/¿ü²ûæ›o ªDÒŠŽÚQÊÒÄÊD`ãÎû¾Œ†C¿}–Yf)ඇi[ráúá<Ç�Úzë­‹&ž&6 OýõW_–rœW¥ ‰˜gŸ}ÖËšÁžhD3Ÿ\hºkè¾ åª}ú»Ñ 3Vû©ý"ÐÁ ¼òÊ+n©¥–ò ‰B6î¦"á‡ëòË/wŸ[o¸ý*5µšv½ßû|à®ü=9 ÝÆ~”³¡µ2�Ú ðáG¹Ë-Â=ØJöÒ·qÏžaQÓ xÈ^þ'XD]°mí‘… ‹µ7µä� Ús£òÔÞ¥ÕU7�!C†¸ /¼Ði{ôÑG·ØÉ ›AþœÑ!gp 㥓7ÀÛn»­#Ùe°=÷ÜÓá}÷Ýwý*”ä_ í}úôñë&L˜àå:p°b8¡×Zk-wÒI'¹ÕV[ͯ9r¤¯Û/Ø?޽Áxù4’“c§<�¢Á):`Àï¤ûä§´•z1œõ}ûöõ~†/¾øÂ·—Heò5C¾„$š×]w�;÷ÜszãD`ûí·¾É�gœqÆ!„x@IDATPÜŸ ��=öØxqãï3hŽ#M‚-»ì²^w?‘ÛDP§Þxâ‰.$}ÆåÙ¿Ÿ³"”¥N¸‘#‚ütÃÿ™gžq8Ý1~Òîb#à›Ê¥÷ mcdBšû‚Ž ¤„È—ñõ×_{8Ò.Á�ãÜ‚~>÷ëî»ïîùM™2Å›cŽ9£�…#6ÜHºJÅçŸËйBâÝ`‹-¶˜{ýõ×âoºñäïà3ñ‘=ƒÑ1œì\#’·Öxn—)vž¢LD †Ø�žñÌ~T›}V–ØÂ×E}úݺtèÐ= {@÷€îÝuïsb5û¹[ˆ€TŽ€9 ýû«9­+Wi‘šöÞ{ï²ß“Í�›™“Ú×fŽÇ’û›s9ÑïEËm·Ýv±Œ9X‹–)õ�½ÐB e渎û›1 øÌÒ�ª×œ¬™9X}5æLmÔ>¡mæÀ.vx¿ÎF¨eæ¼,«>s Ôg1™9ØËªÃ:3 êHšÊ¥¹÷KÚ†ƒ>¸Q\¬$3=ÿt×Ì: J²=z´/kÒ/%ËX>€XŸuê”,®o:µÎ‚¸o ÏøD6JšjW^&"Pœ@è‰^Èz³70-¸Z´ÉÖ;~[¢!¶ñÚk»ÎÖÓ-¨~¿ZtÕÕ£G»_~×8�Õ¢À¶îÕ«úO¬žÁÇwëøñ±eËY¤Ýê+¬—kqæ‹JýÚ" C4k-ž£ÎID 4"�Ÿxâ á¢ÆK—v.D¸‡(o¢|‰¾&8¼{³?ÑÁDÛe—]Ü›o¾é&MšäW%Ld8Ò1Áˆ*Fºƒ¨oê%’=ȉ„2Lg�uVwÀxé”ÐŽt{:Ï1Ð=ßo¿ýÑÙy#ŠžHr8� ;Dƒï»ï¾îôÓOwï¼óN~—‚åbçQPÀAÄy0 ¯­¾À øcŸvÚi>’žúˆ‚ßi§� ª!ŸÈ¸qãÜ%—\âÎ:ë,u]Pà÷"»I&ˉõ×_¿X¿®©\š{¿¤ :å”SÜÆoìGB ÕnÎët³¿Î°c„G>Y*ë¹O¸ŸÂ~0bt#'°¥—^ÚËÕŒ;6Þ›HÒÀgá…ŽÇÚm·Ý* Dº3�ˆöbÖ£GwÌ1Ç”ÉPlŸj_'I™j¿‚j¿äTRR†axüØô³/òÏ>+w¤ÚXœðÔSnÝíwˆ'sçðánãîkÇe͈€ˆ€ˆ€T/�«G�q; Oà\ÓoÝsûqY3•#0øðÃÝe7Ý+|ñŽÛÝ2ö^˶t¯Þî•7Þp>ø ëÞ½{-ŸªÎMªŠ@kIÊ´g(HÈXd³O Šì R/8ò‘AF¥Ã)‹N7t’¯vîÜÙ!ËbQò^~¤œºšZö—_~ñ²(Èâ B§ŽoœìåõàlFþ†?:Jæšk.ÿ‡Ó˜N‘ÆZ{àB[‘Äyî¹çÜ&—‹Îßÿþwß´Þ{>Í-äj�úôÓOý}Æ=‡ƒI¢d^RFîèŠëTE@ê=ºaK™¿×a7ME@D@D@Ú!�ËGýÏŒ.nÿÞŠno‰ËôÓÏ?»›î¾'VÝÅô‡kÝÙOV3" "Ð Ì6Ûl>â½Mé½ÒJ+ù¿JÔ×”:B4}ÐfoJìC=]ºtñM­#ì׸Ð:@økkƒG×®]ý_[·¥=ªöеAD@ÚŠ@~è_×VíÑqE@D@D@*Càí÷?p�>;1VÖ·çn6-«<�[Ç[â¼ï¿�ïø{¢¿¸B3" " " "Ð�ÈáÞ�.¶NUD .�œÔYÙCÒêÖ¨5" " " í�Àðo,hÆ -·,XÖBå\=fL¬lê©§vý7é—5#" " " �€îíŠë|E@ ü–ýV°<ÕôµXD " " "P…Á6âöÛbËç�sN·Îª«ÆeÍTŽÀ'–,uüc�Å {uïîþjIùd" " " "ÐQ ȳÔQ¯¼Î[DÀ�†»n¨=wM˜à&úY<±]¶êç$qTtæÚ[oóIçB¥’“ $4è¨äpï¨W^ç-"à äîz×�!" " ÕOàò›GœÄ›o^°¬…ʸæÖ[ce³Ì4“ëÕ}í¸¬èˆþØOZç," �Ào¿eaÖOɬ-¨^Ÿõ•»û¡‡â lЭ›[`Þyã²f*G`âË/»¾ñF¬p[ÓnŸfšiâ²fª‡ÀÓáíµ×|ƒç4 ¦�VOã+ÜÒ/¾øÂ�?Þ½÷Þ{ujÞqÇÝ\sÍUg½Vˆ€ˆ€ˆ@J@÷”†æE@:�:îÒpïp÷€NXD@D ¶\yË-î×_�'5¨Ÿ’¥FžI“¥Rµäd* ¸«1b„=z´?âŠ+®Ø¡î={ötÏ=÷\Qúë®»®îEÉh¥ˆ€ˆ@J@’2) Í‹€t8ù¤©Špïp·€NXD@D Æ\3æ'3ÿå/ns�É*OàÿþïÿÜ wÞ+^|¡]×e–‰Ëš�j%ðÇ?*.±Z¯�Ú-" í…€~IÚË•P;D@Ú„@>Â]Š2mrtP¨�Ç&Nt¯¼ùf¬ íöi;uŠËš©d{¾øúëXáÀ-¶ˆóš©>DnÏdüØ ,à§õß½÷Þëî¿ÿþ()sÙe—¹ýë_‡Î[D@D  äpo4í""P;~ûí·‚“QÒÔZ�ª"�O–ºã}ªªýÕÔØTN†‚Ûm²i55_mÍ2dHnMÇ]œyæ™]ß¾}#œïr¸Gšh9ÜIED@j—@V˜3ÕIR¦v¯µÎLD@D ¶ ü0eŠe‘©Á�7é²ä’aQÓ øÒ"Ûïšð¿Ä´ë¯¾º›gÎ9*xUU’|¾ýöÛî+K<Çs¸EYÄÍ0à åTQ‘²¿üò‹{å•WÜ;ï¼ã:wîì[l1÷ç?ÿ¹Iu3 •¤¥oXRÞyæ™Ç-ºè¢®©—üѽi£]>ûì3|Ú3ÿüó+©o“®†v(—€îåSy�š"�—”™JISkêúêdD@D@:�‘wÞé¾ÿá‡xƒ¶T²Ô£Â3#M» ÷`IH´Þô?ÿù�»úê«ÝñÇïÜé‘§�vZGâÏÉ“'»…ZÈ�92Ýç/¹äwÑE¹÷ß?® 3&LpË.»lX¬wÊþ»ï¾»7n\AÂâ馛ίÿé§ŸbnYÒ:Â?üp߯n¸Á�yæ™Þ9ÎA–_~y7hÐ 7tèP÷ÑGÅãN3Í4n¯½öòçËù3ÊŸ{î¹nüøñnÒ¤Im¡üŒ3Îèˆä?蠃ܬ³ÎZ¬ ­�Š�ý"U‰ˆ@µPÒÔj½rj·ˆ€ˆ€Håd:™snë^ÐRŤr23Xóæë¯_±ºUQÈ$ïÑ£‡{øá‡‹ÆÁ}Ûm·ùmÏ<óŒ;ì°ÃÜÒK/]§ìGá>ÿüó:ëYñ믿]Ÿ_yýõ×»ÝvÛÍýûßÿÎorD™ãLÏÛ£�>ê×Ó)p '¸—_~9yðÁyãœÏ8ã ÷À¸'Ÿ|²h¤:ÎôpÞùýY¦�'Ÿ|²¯v�”ß¡&­«2SltŸ>G!˜¬k×®n}}/WäJò]øØc�¹§Ÿ~ÚÑщ1b¦ÿþ©¿R•ÐαcǺå–[ÎÍ7ß|•ªVõ4ƒ€îÍ€§][—_wZäÒ?ÿùÏ‚0ÀGA¬Ô‚4’@x( ŧšêaVS�*!ðºIX<õ⋱µý6ÚÈÍü—¿ÄeÍTŽÀ¿Þ|ËML¤[ëé-’YÖzp<§Îvd[ºtéâ%SÞ}÷]‡“=�€ÄK1‡û°aÃÜyç�#Üó¹�:#ÞËvÞyg÷óÏ?û¢D´¯±ÆÞ…æ9Žñ|�äKZj©¥|ä;;í»ï¾>j�v§F9"á—Xb _Ï|à7?ÿüóîì³Ïv|pZÜÏîSO=µûûßÿîemˆfÿðÃ=3f8Î8ï<°NZ!ÕFà€p_|qA³÷Þ{o9Ü ˆ4}¶Œ®I�$ÓíÍá~ÖYgùïEdÅ>ùä“´¹šo#r¸·x¶<<$öêիεðP'�¦È¿Hý©$µŸˆ€ˆ€´�á7ÞXpðAý$'S¤‚ W�]PÛŽ}”˜¶H+,<òÈ#ñ(矾�0ÇÁ in£¿V ,°@ØT0ÝÿýÁ6ÜpCwo’!¬/6Åq½Ã;DgûJ+­äˆv_xá…cq"ÙqJáìvÙe—¹�vÚ),úÀ)"qÓ6"ƒCÛSI› .¸Àí¹çž~¿»îº«¨Ãýè£�öïŒt@ÐdhRÃÉìñÇO7i^ª–@úÙ¯Ú“hÇ ¯¾¡öÓO?õ¹/Èå!k[r¸·-½‘Hv“wŒ6rW�z (ij½x´QD@D@Ú=†Q_wû±� Ì;¯[Ëœ²Êàyüº;n�ú[×ã²fZ‡À\sÍtÎ9ç8$%pNŽ”IFqlá½òÊ+�n�4q†ä¨Ï=÷œß{¶Ùfó‘åi»ØÐ­[7w£u†­µÖZQŠ¡¡Ã�‰ãhî¹ç.(ºãŽ;zg9÷à믿^°-]Àñ�ü Ñ÷$’%p‹d«sÎ9§›}öÙcÑbºõq£fD Šœ~úén³Í6s×\s�1bDµ¼:š:xð`Ÿ[‚Ñ3§œrJ»m4^ÁÒù°NÓÖ' ‡{ë3×›@`•UVq‡rˆ»õÖ[Ãe"P)y w%M­YÕ#M'0Ö^´¿ûþ{_Át–m¶ÙÞícë~äÙg}3g�if·þ«Ç&ß÷Øãî«o¿ñËkš¦æ\û[ÜÖžgªµÝ황ÚÖ2n¿ÿ÷é_ÄÊwÝj+§kGEgÆ›ŽíäO?‹uîØgs±Ž4Zoæÿø‡»öÚk½lÌo¼QíMbP4|‘<8ôÐC[,9è /¼O‰Ï¼³=l\}õÕýˆä}Ö—šÒa�w¶Sv†fpDšâp/åL ‰d�9æ˜(“Sê8Z/µB€$ÂätøÂ~åp¯üUå{gµÕVsŒœi/÷7ß|Ó�l¢M½{÷ö.陈0Á_3Ri¯í·ß¾Ž,NZ^ó-C@÷–áªZ[€À‰'žèøchâšk®ÙGP•‘@^Ã]/èñ.Ð9·'}ò©ë=ø£š^¹çn·¸ /oÏöÜ?_qÛ컟o⊖˜.u¸bZ»AïøŽK.q½Ú�Ãç䇿ë;Î6óÌŽ(Õ¼µÇvçÛ¨e€Àå£nŽ ø°Ù¦qY3•%�&K¥æí7Û¼²Pm�"@Ôúí·ßîí“&M*؇Ġ¼/ñw饗ú?¤9+mi”ùâ‹/^oõlo¬Ã½ÞŠêÙˆ³}ÓM7uwß}w=¥´I:#¿úê«^bi™e–qÓO?}³!àÐ}饗 šÉ�ÐP�t’á$F¹#éèüóÏ_Gö©1 ãýý½÷Þó²)ŒæYtÑEý(–ÆìÊ„:ø£3�zhS¹ÆyÑ鉌Ëb‹-æÏ©Ü:šRžL÷߿ߕßW§ZŒ*úá‡bÕüNì¾ûîesŠh¦I¦jÒ^ÚID@j„@^ªHISkäÂê4ª–À56’)ÿ¹¼â–[ªö|Úkï½õ6·Ò}ýß‘çœÛ^›©v‰@ƒ>1G¸G‹å6^{m7_"·7h¦Ùytëøûb=k®ÔÕ-8ÿ|qY3­K½õ-Q0Ñ‹$õÃáBPÒ)Á>þøcý8jÔ¨°ªbÓ\0Ö…#­>kh{}û6v PSg;:ðC† q'Ÿ|²�ôG’FA[�¥©rÕN€¤ÉHÌ 3õ7 ôÀ»êª«:FÀ�@'m){衇Ü:ë¬ã�Š"ápøC¢ ‡ù{ìáfši&·âŠ+úÑ+8«É%‘7rI :Ô­°Â î/–ÄÙ+ò5ð‡¾8O¨|õÕWù]ýò 7Üà%±ÂñµsÝu×yÙ,ä²6Ø`Ÿ€™(o>ÿ8ÿ²·ÞzË'ÒêèÙ³§?rHð�A{ønMóL«“Ñ䔀-#Šh {˜~øá.ÔW¬Žæ¬£sù­`¼;¥çŸ:Û Dà|�Ö’µ.o]Þ-v4têè]㋯5ì»ï¾óCjšš@‚LöÔñ׿þµEšKýüñEZ)£½|q¶ãJµ[õÔO@îõóÑVhmWq \3æVw¢%u«ÖÅ-7ìéV²ˆ"¬ó<…š´­Í·œãUk»Ë9G•­~WŒº¥@zç-•,µ¥®êM9ü“=_S²Ô@¢u§8VèõÉoºé&‡ô&©¡O~ÐA9¶cgØH«-+üÙÀÉŒd©¥äk�ž!Ú¾% ç"ŸÁ�”9ì°Ã¼MXÇ.M‰bMëмT:á.ºè¢:Måûƒüh¾#3BÖ©áÝtÓùžE¾ðwÙe—FJÔW_±mðà‡$Çá˜ôT2ĉÞW¾ðg™e–b»]÷‰ µ?÷ÜsçM�|ð�/Ç—&Œ7Ùdÿ#ÅP¨æ½�wÜq‡æµÅ[øžßæÔ§}Ë#�ÿ N5•þ”GP¥E r~ú÷–½ c+-»Œ›zª©Ý“öü™=Øßeþ›YDL5ÚPK¶T�V­í®FÖjsÓ ¤'³Ùs^¯îk7½2íY/�«­ó3Ø´ö°¥EÊZŸÀóÏ?ïõÛ92ŽwdcòNdÞO î¼×TÚpæ ƒTïv8vˆ>MµÜy�ÝÊr*àkICÒáûßs¿ ‹ó? ãyŸ\`È“ÊD #Hßqù~èÒ¥‹ÿNœ8ÑËŸÀ€<øtøI ¿ ‘àø­�Ž †¯*5"Öéì 9öò#YðÇ;ŸG"Ê‘]á3úá‡z';>›§Ÿ~Úû™ˆROmß}÷uǼ{×|]©ñ¾Nä>NdìÁOÃwãÙgŸ]�Ó"ì7ḟ=~(Ú�ÿ‰öç}n”ã{¥”Ã=ÔÃy-µÔR^ÖÙ¬ ™ÃyãŸÂÏÕR†ŒþF|qt6äî|'yä‘-uxÕÛr¸7RCEø2êjIÐÒ/µ°P†¤ãaç/_LÅŒ88Üy` Ã:QÕyãƒÁø/¦ü6¾lø»óÎ;½3ùÖ[o�/V°LûòÚ¡_ˆ$ˆØo¿ýürzŽ YáK…¡yDPœzê©a·‚)e—ÿ¢¤½‹t<ðGo" wèQ-'2�Žøóã‘7ŽÉXtN >;í´Ó‘÷içåù²áK‡/‚† †ô²2ä�Èt˜b}ûÞwß}õmŽÛˆä'ƒó®»îê Â�N,`30ãጀÆÑ^x¡À|â‰'Ê–›aøeøB ÇãcذaE¯W(£iåä?»Òp¯[Õ$åø·½$�{¯ß'ëÖöàÏ÷ô~�ÆoÈ=ö{ô±éFÎU$áè]Np›X‡5¶ý曹³,²msÓ—|ôÙÿ9‡Ø6ÿÜs»Ó†ìúm´‹†žyHlúÖý÷¹‡ž~Æím/#ß' ‡ˆèÜhíµÜ¥¶~VK4ÚXKëöIS×é^°+χžy¦CƒN‚Ôæ1}ƃ,Òèý·q�¦™&Ýäço¸ó.w†� mO t¶‰}vÜÁík�ÁVµ‘kO¿X8v„Eáð‡�k�=·àçj7ߟg]y¥;õÒËü(¿Óïÿà3d»íÜCöˆŽ‰°ýêÑcÜNö;‡í¿óNî8‹`ÚiØ!î6û=Ç鬋9uÎ?êH·šEeåíª[F»Óì%ñ_ô�7Ê»ÏÞn=½`äÑÔÜ2q©Iâ$¥QÙùt$5ïh�²¶!�:Ÿhï#[•2TgÚoLj8gô©Ï�‰H G¥¼÷c´3¥p€oÇ×_£êC™ú¦tðî“¿‰8ÃqÖ‡;ÁP©, ¿?t(°/Ž(œÿçœsŽ�ê§®Е֛Ÿ'r—@6Ø I ':p†åßÒ}ó\‘Žã-Ï8ÝGó"ÐølâûH�Ï Ÿ-äwƒ| #?R‡{Z>?߿Ă ý3»x– ò$ˆ”ï(:¾�@ÁÏE‡¹&pCî©!C³ÿÔÜö<ŸÁ�8îy_H;$C™#FÄ4” ð�Á!5>aõÈ#�xŸÛê“a!Zÿ±Çóší¡X •îÅäo(‹¯«TÀk¨+�¢¿_Êá~ÕUWÅÎU:XàÃwt¨ÐKô~1ßWz Í· �©Z¦ÚŽU+½vô\嵯ŠQÀ™‹¼¡nzÉøp0ܦ!c8 ½V<�0T(ÿaâÃFO}1£Í|ᦽ{i9zåòÎv¾\éñ$áFj|i§†óœaGyg;è´—DùFöçK˜mym°´îúæ‘��3×eÞyç­S”!S8ÉóF;ù)æl‡1‰CˆÉ÷ÌR)ùÝ|ýÅ–Ó¤Fa;‘)Å:GÂvM+K æ??•=šj(EàF´-²[gÕUÜœö]8‡=ˆ3�ñÐHBÕ†Œïu¶ß¡Ž³�ýˆßzŸ}Ý�‰>c±ú.²Nê�-iRêl§ÚÅcÆ�w]Í9?)'!W¬žÆ¬ûÐF¾u³ßž3.¿¢Ž³�ý?úôS·¯u^o·ÿu~OϱÈÂmmxl1g;û¾gÑ3ûŸx’;È"ï*mÈü¬kœ<ù”:ÎvŽõ•9jŽ3GȪý¶rïZz)ûaÊ�®÷à8´¡Sg;å‰ôßpçAF©}îyþús¶Sî ‹ìÜx×ÁŽŽYí “nŒE÷££ei‹V•UžÎÇ·ÿ·SŽÚéø\¯D´]å�®óprodÇÈÆ¤Qèùr¼Gâø!Ú=Ÿ7‹mÈm¦¯üþé2ï&èÄó›7"K‰ DZ–7öÛvÛm]ß¾}ó›ü2‘é¼åsd!ó€<!Š”u<¯?0éPÞyç�}Ä}Þê ˜+ùÊ{#:Ö8Û1Ú�,kžW¨#?ÅÁÆõ(Æ%_VË"К½‘w¶§Ç§Ã -†„nþ�8-扖'`08ÛÃúRSžÝ‘æsŽ£‰”POàsÏwC9†|r±Ï7í þ“búìtàÃ�w¶‡mL eÄß 9ÜI�š·´}ÅÔòå›»œŸ(K›Qu~6¤‘óþ¼æSû7ž€î�gU²$X$KèÑO“µÛ�‡¢Íq&ãXÞ}÷Ý‹óëÐ#'â:ý¥…y  wŒHxz×Zƒ–<Î_œÃ©1dˆÞºbƃZHÑÐCVÊx à‹‰ñLq¨ÓÓȃ ÑãÁèY¤Ã 5ôüFY2<¢h/ºV0€E~è=œéTZO©yþGĽ‰DzpNuû�pb\î³A7Ê´?|äa÷Ú¸{}Ôxxù8ëʫܷ¿K¤�>t¨»ý’‹Ý@ˬ»9QXÇ_ïuº‡ÕõNqä?dš›¬N³zŸ³g¡—ï¾Ë�wän–ß“¸?gMƒ?¢d]Ãmø.õnŽX?m²B{í°½›î÷$Sÿ¶ÿÏÞ™À[5µ|½xÍ^Ñ+•©�Ê”1Ñ@”æ¹4Ï)SèM©2”(ED“æyNM¢DÑ@ˆR"”¡ø¿xÿë»´vëì»Ïpï=çÞsÏ}žÏgß=­½öÚ¿sÏ>{ÿžçù=÷ÖpÊ Ô/Öéßó:2žÏyî #´ŒNq³‹É.Q¢m2Ï™LÒõo¬“Ž+h×0˜ÐË™W—\£^óîõÅ®£Ž³VuëF•{J®+H­Ñpo'ª‰Þ‘,e}ôèѦ !ï[¼ò~‡–¹?HÊ¢�Œ'ïš8T¢MDƒ£•Œ|J�A†£ÃÌX�‘An‚÷EÞÅÐuwƒ»¬ ýðÜ �Çû¡;$[ÝwIÞ™ˆÒ´m yÇC.Á5êœñŽÇ;ïÒDÆóÎIý1HE¤_lÌyo?~¼Û…‰”GNÆmnB™QHw1A ™@*’DheY¢©Ø~ŠŒÕønÐ9”X¢×cí7#í¸wX#@5’!}ƒö:÷ŽD÷RÈøX§HŽ ”4%[§#–Gg™.^¼ØÉ’‘ä:uMÒo0Ço–­Aâ=_@ª{P_–Aã'ú�B­ÜðyðÃÐNGÇËì< ÚÔÛ'‘ðDSø�¢©è•1Q(ÈÕ[Ç‹L„¼¿Â¶¿»ÎçËC)ççA�>#y\íq2�~o>Ÿ‰˜ d-[w|æiµ#›‚6°5–»öë¯þO¨h5¿©£èÊEy‰¨[¥²š¡”-ጞx­A‰ŒÉ„¹Gi>¤SÏki)´ 'ÛViÂûZM X+®£íÊi¢¡L“¦†ä#úšh÷úU�ŽÕ¶�uN‘XŠÁb§è(£µÓ§©óôï†üÍMúž± Û‚MÑ¿‹½nïl–k‚Ùm'iýY$o¬õîÚE½·åc3Fîsom|OU×Å$-vÛ>ûÜ65zë5}ŽzogÀŸÁdýœ�áXþÊ+ªô•Wx-Ѻ¯xý «&†è];®g/]ˆ$Ž +cC'à~ªÆã‰Gš>?ܶÝë›èu ‘~ŽêÞ¡½·�Ϲˆ~^©ÔªµúS_ó!]se“B@šF,õpådpÐIE¥ÞUgÏùåd�îKØ!â=Œ@,ÞA]ã7ˆ 1káH{»?³s¢v >ó e¶_9^ÈI@¢G3—¯‰ÆKEëË¿Ÿì�ÖÈ"A~^‰€Q4Ì‘˜ j�‹Çܽ¶¬ˆ:�6f›Y­],ûqšIŠÁSYî+–~¤Mbf)1¸&¼W¢©ƒÈv{b¤b¸Á¹UâÑÍòkÎÙö‘æ<¬@fCˆÇbÜÄÜHäXˆ<"ÛÝþH+²E3ìv"b1":‚Èv{,$6éL�ûÖ¸¹£'†AÈóÒo�h „�-iª«#| ô­ñ£AôDz�Î)d{z‘Ë|{ÓÒ‰M �CV�,AÀ-– )|º#Y–Gk*Þª�‘ÖFëȽh6@§ªZ²Ý¶Å™6P§±ÚˆqHÜ Ú©d õ �K¶Û6%õÃkûF íª=s†·œ‘…¦LöëÞ¾�G¶{õƒš`'z'Â…œïÉÜ”½úÁOÿ²±cBÈv{üÏ¿}Ù:ðóOvs¦ç£´T�µ–úwÐ%Ûíö‹/,ªº6?š*ìcÛ0'¾K³ÛÜMfùæÒ×{Û(ŠjÍ:$XÇ3rÊÔ�4h$Eö½½Níg½™„l·È¥ÖücÁêJ)5ÕÑ]6%µ®4û¯æ°v\Í8°Âh¸7âTbA€ŒètÁEÎ�H2 ±ô)mA :Ô<ˆ$ÑK&üF€'βxY†®òò5’UÃý€@ÇqZYmõ¬°ë¯?úLDN�ÁuFí—m‚@,á JIÖ†4 ”F3îúNÊ8„2Ärz �-"°cÕ÷£onÜ®G}{*ÖÇbÈ©¸ƤèE³KtäZ,Q8Üt~ì�ŒÒ3é7ÚÄuù vW#,ÚØeö#à:Z�MÍþÏDF�» «ÉF�s宜ŒEâ¶š5좚±x‰B»9œÒÙZáÈ tá‘O±ö©NDz̮Äͧ;ƒ�ê3hÛ6í¤µT”}yµ¾ì,ý‚2[˪0�ªê„ö-º®S1�õ†íÑzï«ôïæ :=¿f§NŠÈòD˜«�î~6þs¹X¹Ç¸í.½èÂ4ÎöÈw–׌hukDµ—,Qܮ٘eÊ-ûáã'ÖŸ¹ä5–…”A)"×\G˜»]–3�rVn=‹Öõêf¾Sé!å@šéQd,ÈNf"Â’¬ltŸ­\”Yf÷Ë\âƒd;�ûô³¡ß�ljÔ¨‘§,€fy< 2ÿ—#Ïê<"måÂðþMÖK¸Úñ }Q?ÐZß¾}MÑT?`÷Û{õ�Ã2ƒÀq™9XŽÍxx‰Õ(òéV~‡`ö§ùEê‹â®Î^¤¶vߎ;좙§GÓŽtt³lui~ ¢cŒÕüš]hÿ±�y¼ÌÕ‹WŸÒOâð3ò�8¬¥gA $U(ÀiíåiÓÕø9síª™S¬ÔšÍXíи±Ý2¿@GéD²¢ºÈœµa÷ Π߇{üN�‹d›ûaûŽeîö]pA,‡„´ù^׎Aêaæ’¥ê#^nbHé ƒ+®�‹‡¿;ä]¬QÀ•Ͻw×N=ùo‚»�åp÷b¶/Ôîu»tUèÃcßi¢gêÂEfb'EÇÆ�Twý¢tf€”mÄr.LLY°Ð»€ õw§L:ž½e!&^™}T „LL² Ä?Ó´ŒèÕHé&µª"!$û�Œ!°zõjEùÆ�C:xM§`)µöàXøý$Ò|Ñ¢E^¦?õžÖ²„ÖPD@Š5€ßt†“«�@ád÷™Rš¾Ÿyæ{¸™sN ™BºC`SOµ‚8á£(²L ×Z¤Ðk-]ÇÉŽ‡‚ÌŒÕmP ö^½zõÌfjëA¢smr5œë‰'žP7)î�Æy-sÈ} …‚JÉ´a?×�"ã!#‡@LÆŒMŸ>]!3L@(ä;xZ#ƒ ítë°èß¿¿©IaÛPÓiånݺJÛv2O]„pÏ�Ÿ­?;Ò% ãZz"ÕÝãÒ³ìÞ„9.œ÷0\ŸVæ…ýá^¸Ýcc­’Í1®~ë¿!qø±ˆ—qcË98JBfÐn†Eι © �sðB]¦`£Ç„#Ü£{ÜqÇzMþ«£ëÓkÇébuÖ Û3J¸sºôÖN;¹nףͿڳGÝØ¬¹bníb­�Y¼HaUBëÍ£ÉÞgÈPñn÷'bé7Þ¿/–ßôXƈVû†9³Õ’7ÞÐÅoW¨•:ª»“-€#âÉ‘/©¹:[í--ig ¸ÆÒ·´I~æèÞýú3¶Ö1ŒóÍî—yÆ 8óò#õ è…¢Ê8´Ä?H�"w ™ç�[dNÍ›7wwɲ Ä �!C†¨•+Wö†Üï”)S÷!ñDQcWvYâpít~{épÿþý¦Ps—.] ±oO‚söY]+ÉFˆSãŽ)’‘ñJd<ä=„?ÏÉnà(ÇBªCºCl[Â�â¦�ßÖxöÄÁ±–pçù Š·Ú‡V6Ø4§VÜä‰]ƒ³"h“z†î8& `ÆmÛ؇ƒ‡@Pm@ÛNæ©‹€î9ð³%‚msŠ~F2nX®vm]½ñHÇffÞS×ðÞwß}Ë\žEkþ¾ìvwîw*¸ûüËþ¶6â�â=èÌ[»ñÆ�œŒ]OÏ<=÷ééWÚ&‰pO ®Ò«  ß|÷�zU?[+xv>uì1G m»�ùúÁ{ï·ßšMoëZZEVÅoŸщõo·ë_~}” v#°í~æôAÁÒ s�‡ø=^y͈áœ&:ÜÅ_íÝ«þíÔqû\ýÎ;žN9Ò3GíÔ§¯G¶£{ÿ’~à/èÓßL”ÜßùàC3ÄÏôË 2>Aæ~A¤ [ÆÓªéßj&쀎h§Ióèˆÿ¿ ¤‰?X×xy,Æg�xŽMúJn±TþÇ[Ô©�¸“åòž'Ì›8ÓúHDa.‡E.?2°·mÛf"Cmð$Á^þ`¬€Ãe“ dÈ\jÉmvjQî4]iþüù!$0§á»Ù¶m[5pàÀ4ÒÁ¨!p,$6î‘ c=ïo×®];£”ЫW/µÇ ±íˆz¯Zµª4h�ݤlÄ<V!ΑÄÁpðàA¯MT!o�k‡C²×εÑw›6ml3?Q?ƒ"•+iê!0~î\ï%àM¹zUH÷Љj)P¶œúAG�`,ܳ§ÛÄ,ïÒÄ5ÅPƒŠžÔQ>n´æ…ç˸Ì^ºLµmÐ Mßl˜µl©·)‹Ì‘è–p_°b…º: Þ ÿÕÚµ7§Aeߺµ†|_ëH¡�~üqu¶þÝõ›ÅÊ¿=³ëDÒ[Â}²–ö¨ähcº}³ÏÇÄÃkÍ»G^(ËigyÅ#éÂ×­£_™zè—·Á£F›Ó­{?ý…Ìã1Né#1ìÖY„nm‚Zº¦Q�|ùs2éUq�¶Fdû­G\v›Ì?n¤¬Ÿ¬ ‚@b€ f ²½ú¹nè‹/¾0Ò)H©0ýK?7ÙYºÞ‘+�Ô&Öm­Zµ2ò-ÔåC2gÜúÙd5édp\“uM¢hV½zuÅ‹¡Œpÿý÷›zDžñÎDõþ˜ÈÔÉç{®€w›={vÔSÀ1‰ �cì‚Ìãƒi9®A6ÙZ]ȌԓhZwADz�”¼yeË–5Ñîoè´j¢·¹)uìØQ±muÐiOÐСCYL¸á=ôGßãí{á…¼=ÿ vïÞmŠf¼ýöÛÞ.¼‹èvE3n�-Z´ˆ¨ÃŽÌKÓ¦MC¼«åË—W'Ÿ|²éžÊÕxK­ñ£D!V×aa÷ùçœÿ£�>2U¶¹qgÄ8×î�¶ÎH_rLúðc.ESÓ‡Ÿ´2ƒÀØYG^›ê¨‘"²yØm¬ïËÖ(´jõí6;ï1è)õ»~¨÷[¿g‡©_2›‰n/sõUþ&f]ù i4ß_˜|4-·¥. žk^»–w8ýâ,ðÛÀ—^ö6ÕБì8‹qX½v^H‚ï›uZÿ¦­[½cý Ç{ôð§EhýDZÞ^k_Z›¤#§Ö9ä¿Ýþ±Î²£x«µº8WiKxkÑÔ§8‡5*n×­[×®F�£g8C¿@Bq¼¢õë×�zœ4ˆ~²&–ï]|Î,½¹�µÚIl£»A¢y­ÚQ� ~ñˆ%…2®\¥êÝR%Íq«ô½¹BóªgçNê*ý{³]GõPˆrØZ휎”æ^³Sgõ�N'E®å]Lé�w7¨¾Úqm£ÆÏÓ/0.anûMϼ¡~*_êZµF÷MáØò·5S�v»G¹ýÓ/¿ª¦LV+�8¢�×DW7ý¢„¡IŽŒËNí¬æVÿŽ;Õ#÷Ü­.ÓÑB�ñÈô<úüÓÖþÙ°ù#U£Buºþýà œu4*˜ˆááã'¨ó äWÅ  ”ê±ý0/§o›iòm²þMF‡¾rë6êá»ïV•u¤û?ÿyœÑ�ï;ôY} ¿˜ÃØ^¿ê-n^¾ùúÒÆ1ƒ³”ÿ!®½i�ꪬƌßQ>'´ë­UÑ� b©�ÿënÄu>äRM?·‰% 2»Öº~=wU–A@A@" „{p2²ë­« ± Y‹ñr@dy¬Ñå�ÛL�ÑDX„ Ÿ$ jÇ6Š„RD�® C’† ÔáŒÔ#&¿!áI¾KëÜy‰ôG/¬Œ~Év‰n¢ðý:êþ¾Y'-ˆÊÒÖvîÜ©¨.í�F¶û™³o„ fr·-SÄÃ�h§ Qî=ô�™ì1htá$ðkáÛýAsR°b%ÜÁÞM•Bߌ¢B¸!›˜mýõ¿�Ž#E؆4”A@Èn±TäF®¼äâ¨ý•¹úju¾vLÚB¡cfÎLC¸+\Xkœ¯Ökw½®wöÙD´m„wl6Ò¿¿3/Véß &¿!_2á©§âí9ê±ÇTÝ.]ÕVí æºZ÷xÀ:³þ̃½ŒóÀîì¥#…:ëß âÒÛo.VCµ¤Úb� ·uÉbÓ¬¼&Í!ñ!Ì>¬îÑ…ž°aºÏ m|³Óù3¤÷ƒêë}ûŒnúa­ñ‰ŒK�]£¥ì^~ìテö§wÛE… ©áõUwôØ:O?o1Ÿsf�"AýʶìA`ùÚuê‹]»½“·kØ@¤ÿ<4â»@àÐÔE‹¼N/½è¢�û�·CA@A@8šO¸[6fÔÌj¥£µΨöLTz©R¥Â51ÑÝÝ»w7Å3‘íL¤vF�‡q«ÓÔZîo½õ–)2´?hd'ºZ³fÍ ‘ا_ê#‘íA}m#B}ĈaT¢&žv1tÁZ·nó¡AÎ Hw2IJ¿óJ"ܳw9KîFY—iº’5¢¥c1¾ŸÍjÕ¨„@Þ£\;í”SÔkš\n¡ÓDýìD†÷ÑÙV“Ÿy&"YÞJg)Í>Ì�ûnßœmøµÓ¦ª¯ ÿìmyÜ٪«Îv:U�Ýo]Ëtö»Ö±IcC<ŸPhµd‰âjÅ„ñê}]ððßZw9ÈÎɶÁÁ_8V_bLÆy9ÇÓ½z*"�ý†Þ|_�!°nú4EÁÔxZ� 8ë¹çd~�átÜó5éé§…� (‡n£nƒkRÀÓE#¾Ë V®T?:EêÚHæe|–ÞA@A åø‡&›BÃ;Sþ’³æ¿ýö[#¹‚äH�Q()t։ʶ†„ ò%Æ 3E-ؾUk°"Áb }tôÐ1$jЧ }R|‚¾©¤ìד·Ç»óÅ:‚ïMášyÛIñF&…(q®%È�á¡ÐN‚Ž@ó·ƒ Ÿ7ožò뤣eOõg*NGrT e3xð`u¶.ÌÍøüzôè¡Æ�5›€¬†råÊM~œd'ÄjTþF6Çu\ ¥ó´& 2j[¶lQ—êÂ{ŒƒëȌᜠBw#�q0mè�Ìt•´ÇÒ²I=Ÿì�ï»õo+ ƒ‰ ‚@ÎA`‘––©¥#¾1HØwgÏ2ËFDº#³r…þm,®µ½Ã9ÕJÕo 6êßSl�þ=©qssÿGý3]P )–Òú·õ_Ú±š(㑌s}¸m»9O±Â…´ÌK�°cf¿i-íw~½ÛNE¿Ü- Š¬ ð‡ÿ¦�—¥q"Ø>�è9UË«á”ȈíÓrk`õǪ+u1.ý¬0du¾ÔŽê=û¾Õ÷î<ê|�W‰8hÍŠñË9bCà€–î+P¦¬W›)¦ÕZ P,1Ôî|»–ìZi:'f׫¥8m¨/«QSmÑ5+Vj¼*hÙ.1A@Hx‡å]¶_¿~ªÿþÉ1(… äéwÎSŽË-W›Õ×‰Ì E0‰Ì¦ )Ä;QÓ…uÔÑïâÖ u3jôãö•Þ~�­ ']“޾µ§À$2zíhª© Ï¡{QŽ“¡råÊ*ZUûÇtÚ=S8{ðÁMD=ºôŸþ¹úóÏ?�óÁVâF^'Vãó§#$ù‘Fg~Û¶mfBb†13A”3QˆÄEëyЙÿT?¤SõÇ R4èÈ‹eþ̉pd\Ö�HÎ$ñBò¸Z@ý’Xûç~€9« ‚€ �q:0ÁÚ)úÙ¬AœŠðÚ>e~ŠKÿñÇÞ‘îñ �A@A@bF@÷˜¡’†‚€ �ŠH„{*~ªrM‚€ ©‚À{¬Þ×ryÖ(„ é.–^™3Çë˜ ™Ú•*yë²�ÚÌÑŸ=™½XþüùU›6m̲üA@�ô# „{ú1“#A …ð—±I™úpåRA@r<£gÌ ¹†v †¬ËJüجÉÖ¶nó:lZ³†BrJ,¹xíµ×Ô�T}]Ü6£2—\áĉ�Ì%Ëd$ áb‚€ ‚@ÆÂ=c¸eÉQ�>}ºzO;s mñY³f™"jèÁópEQ1A@H?ýï¯�ƒŽÑÊb‚€ �³¸éºRêÃ… Ì OÒµ12bSuaèú�5Vèœs2Ò…#qFÝö©‹y½–(Z$l½¯‘,d7º�NZéÚBbÉ�u«n¹å3È%K–¨ªU«&÷€et‚€ ‚@.A@÷$ý )*zûí·›ÂŸþ!þ¦ &lÅŠfª¤Ó=K”(áo*ë‚€ ‰p��ìr§žrŠº¬X±L�´èùçgêx9Xâ�ÀLM þxð ×q§&M¼eYˆ/þù§š4ÿoÇ%=sO,sõÕñ=‰ôwÖ®]ëõÉrf÷Š+ªÓu±q¬P¡Bf.A@A cáž1Ü~@)ÞÈÃo4£ÝñÇ­™ì�¤hj(²IA@H\9™ãŽ;N5«U+ F•šCXºæMµoÿ~ïâ¤XªER/üþûïÞøÜeoc:$c:`ISA@A B¸G(»v,XPM™2Åèè}ðÁÊ_Ø‘q¡5}ùå—«º:ݳH‘"Ù5T9¯ �£ð·DÃ=Gœ2xA@�Aà˯¿V«Ö¯÷®¦nåÊ*_Þ¼Þº,Ä¿œL˺uâ{é-W °mÛ6µ{÷nUªT)/ZþСCŠ÷Ù?þøC!‡zÆgDÅ‚ ³;v¨]»v©âÅ‹«óÎ;/ê1±6øöÛoÕæÍ›UáÂ…å:VФ� ‚@ºÂ=Ý�eÝ 4PLb‚€ �8þ§þÒ¹h¸‡À!+‚€ ‚@¶ 0jÆŒ�ó¶k(ÏÄ!€ÄqåÀO?©ùË—{=V(]Z] µ,<<’miÑ:¨Õ«W«~øÁÞ³Ï>«^zé%oÝ.@X÷ìÙSÕ©“Ö‰2räHõ /¨¯¾úÊ6÷æ«V­R%K–ôÖÝ…±cǪáÃ9ö´@IDAT‡«�;wšÍW^y¥Ê«b3gþ]äø-õF¿{öìQ�<òˆ‚tÇN>ùdõðëîÝ»›uÿŸ-[¶¨ûï¿_qn+¡J›ÿû߆ÄïׯŸ*­ÿ?ÃQú‹/6Edm›† \æÌ™£ú÷ï¯>üðC»Ëèß3N ^ó ‘…$Cà¿ÿý¯Ú¸q£¢^Ã7ß|£òäÉc¾\p�ºôÒKÙ_b©…À¦M›Ôo¼áÝ7Q³¸ï¾û²ì"¿øâ µuëV#Q–™BÜY6à$>‘|;“øÃ‘¡ ‚@â�÷Äc,gA@Òƒ¿ÍãçÌõ)xv>U¥lYo]â‹À´E¯* ÔZ9‹DrÎW®\©&Mš”fpn�/wçÛo¿­H¸÷íÛW}÷Ýwnso™ˆôpiNÍ1kŒÉµ_ýUµjÕÊÝd–!ÞÿóŸÿ�xˆpkÔTzà�Ô�!CL$¼ÝnçûµÜD:…a;uꤞ{î¹4DãǬFŒañæ8êׯ¯ Üý¶lÙ2uÓM7©O?ýT�˜Á¢ëþ>e]ˆ8°ø^@¶Ù"sçÎU7ÞxcÐî”ÛÆ½jÖ¬YªZµj)[gâÝwßU×]w]Ègwê©§fáÎ}êOÚÏý´K—.!c‘•ô!pLúšKkA@R )ššZŸ§\� ‚@ÎG`éš5j×Þ½Þ…´kÐPI”•GÜ\9™“O:I5¨zKÜÏ!ÆâZºžÁi§�f$FmÏÈ"RÛË�øÞ\rÉ%ê®»î²ÍBæD¾ÒRí1!;#¬…~î¹ç†´ � *Fŗճ믿ÞkOT¹k8žzꩲ½˜.†Þ¸qcU¢D ¯)ÏíDå<ØÛf¸ÎæÍ›«3Ï<Ó\�ÝþÚk¯…�í'éÿqŠËR3 #jøçŸ¶Íe.$ .4ÿÿáÈvùã�?ª¾l°¤|‚Á}ø¶ÛnKв¿[î£ÙiÈA¶co¾ùfv%%Î�½ŸfJ@(!9�¿þòIÊdó�\NÆRÆ.‚€ Ä·X*ýµ®_/ÝJ|ª£ßÖéëÖ ÛOÕr bÉ‹²,óçÏ7¤ÈË/¿ì ´G� ísw"Z‘Èïp2ÈØc ¢c1|"Î]ƒD'ÒÝIθ nˆN·d’+ë‚tBŸ>}¼®ˆF‡ß¾}»š6mš‘6@w2Ýöìw ‡ÃĉÕ÷ßoÎåîc™ý8¾Öõ! QíHÛP7í¬³Îò7—uA [¸óÎ;• »úê«UïÞ½Õ€T×®]UíÚµÕUW]ed–Úµk—­ãÌÊ“¯]»ÖœŽ(p¤vRÑ®¹æsÏæ~šrA‡ö`u—½�²�.DR&]pIcA@H5샌½.)šj‘�¹ ‚€ �õ|¯#ö8òo¸A=ÿü¬H.9£ÝÎ%‹œL.ùàã|™åÊ•3R/të’×;%z;ýôÓMTùï¿ÿ®˜¬�3Æþ¬ßrË-†G³Ø5ú7nœ‰DÇÙ€|ÚðAÒ:îqv xÈxס€6Qõb‚@²!€ÃÉJ6ñ¿O½dEr»Ùû†uÚ,•TÃ…l¦{ï½7$ë'×Éý™îá8;ýr»{u¶!²E‹-2cÁÉÏ"Ö‰¸¦dêS÷dú4d,‚€ �åüõ¿¿BÎ)„{²"‚€ d)ãõ‹�¹ÖÞÑyÎÒ�ä‚“t0qÞ|ïJÏÍŸ_Q0ULH/ሯX"4‰Vµ¶aÃÎÜ{…$c±‹/¾X¡Õî—À‰åXi#dîÖÐÓŽ7ÙNÆÈæÍ›UáÂ…c*Ì÷î³Ï>3Å•‘²*Z´¨Ê—/Ÿbºæ¿üò‹ÉZ¡ÎÃe—]f À¦«ƒ85FŽç£�>2µ.¿üò ×pàwç3çèbãHaÅrßs/ƒâÒŒSŽÏªz|dNàÀà>L ^[#ˆkrÇ�oޱmd‘”‰Œ�ì�GÀýIñK•ËA@’�q³�6ü—Žè«[¥rÒ�9§p¥.¦ù•~Ñ·Öª^]OòÃn“¹ �H�¼Ù¶m›wŠ~øÁÈÉ@8MÈÅXƒà"Ò=š!½!d{4”dv#€ÔQ½zõT~íø¤Nƒ5dš¨KàNÅ‹‘a²m™ßqdžDwÛShCîéŠ+®PgŸ}¶ª\¹²!ÎÉú§¿oß>…nzÁ‚Ž+Ú–)SÆ_¾|y5uêTÓ¯ÿD.2V�µvd²4kÖLýë_ÿ2EAo¾ùf“ s饗ªuëÖù»ðÖó :Ó�~ ¦­(PÀëÛžƒÈë–-[†dÐØö̹ß@*ÓŽc(6K�Rœ�îýúõSádT¸VÚÚsU¬XÑdØÐŽ ²s¸k¤ª¢Ý›( Ý­[7C²ƒS•*UÌgƒs¥I“&Ê•Ýr¯!žËœË/7†#ÄX¸\ ×zë­·ÚÝ2�‰p�$i"©‹€vJ{fu%½ ² ‚€ Y†ÀúM¨ÍŽ.s‹:uÔI'ž˜eçÏm'òËÉ´ª[7·A ×›Í Ù´k×®t�鈽¬ŠM÷åA Ìž=ÛHwø�$&Û5Ö{ì1#9’7o^oõFŒá­Û…�ºVr!þú ì'û‚–û]Zºt©jÕª•">ȨËÀD�Èô3Î8ÃkƱ~2¾}ûöÞ~w�ÈnÈ{ä¡ šýöä“OªwÞyÇ¿Y8p Í6pA: Òܵ÷ß_µhÑÂD’»ÛYc¢Ý™&L˜ ˆâFbÅ5ðf¿5!L~û¿ÿû?õôÓO«+V¨·µSÛ/�Eûõë×›±ìرø‰6Ÿ>}º)†ë’ÝiÆi×ûÀ(Ή´ Ÿ‡k8jÖ¬©4h`Šu»ÿ#n;YF@"܃q‘­‚€ �KpuÊDN&—|èr™‚€ I‰Àè™3BÆÕ¾QÃ�uY‰¿êèºÙË^ó:¼^ËÓQzb9�¬ g�!­ýç?ÿ1äX,Úìb‚@* @!T¢¦O:é¤4™F…¹ê.vÉv0@÷›âÂDa»�d¯½öZÙÎ9ˆV·RPd“üüóÏŒH;ÕÑoK¶Óò/�7V*T0õlcô½Ùî¾SWªTÉÞAd3ĉ•FÊÆÇ=“hnˆv;®‡hu¢¸úé'#guß}÷©±cÇšsñ‡}dx 9¤;Zöd&@˜[{þùç½û…FÁÚµÎ�;«ï¾ûÎlBІbÐHÛXCƇ6öžh·ûçï½÷^`6ƒ¿�]Ç9I¶@8ãÿÅ-"M{8cø.\¨$81zá· áÙ“dP´�/:©R®‘.EÉm'Ë‚@nÑÔ5�m‚€ ‚€ �p ÛÒòÖ:5ilež\9™ãÿùOÕ¸ºè²&æ„wéF‡C!�…!ÓqçñDuŽ5Êìïß¿¿!ž,ùÃÆƒš}ü!JÕRD—^{íµjРA&Š’È%gÖ®]«êjI"È&¢L­}õÕW†ØBb�(JkHÁ) ™¹4cÆß.DîBr~tš‘h€ôùàƒÌõ°ŽA¾!•af�¤ =j·¸*2 .a iFDt¢ -&ä P!ã!š­Aò»ßc¶/X°ÀHe'ºò®q?@b…ï'ßWløðáêž{îñ¾�n{–ûôé£}ôÑ�ÍDO7Ô…Ñí>ùä“4„{ÈXᙌq�¬ŽßÁõ@¦ÏŸ?_U«VÍè¯s�ÃA@Ó #Ëà�7Þ0úöîþÖ­[›h}"þ¹׈°'#ÃY!Oô¾kôË=«lÙ²FzÆÝç.s]8Bb5Èýp„;H~ˆØ¦Ms 8Y¸ß¾úê«fL|VbéC@÷ôá•îÖ|ø¥7$±Œ!€×³F�!©J¶'nFb‚@F°?,/^ÛŒ¢(Ç ‚€ ™CÀ•“�¾- µ9sg�£-J]¥5d­ÕÑDçŸnWežƒ Z�èÍÉ“'›÷$Ȥ �f. òÜJPœ”h÷Hæ×H¶ääd=ѱֈ†…4G ºC‡v³Ñ#†ìFãù™gžñ¶óü½zõjCÐCêŒ9RíÝ»×hBÓˆh|¦HÆõ¸Ïñ\:Ô~cl6Z×î#"7_¾|B¸[@džÒ@êò=Œ¥xðâÅG3Íz÷î�†lw�êÚµ«‰lG¾†ï¬Ÿ@¶íÝy»�9ÑðÖÂ,µû32÷ÝwCƒ�dî=…(òp„;?ŠÉú §&>„»ÿzèÏZ»víÂbÅñ�ãþh{l¼çŸ}ö™ùüè·D‰Æá‰´ÍÀ�½¬œB¸§yÑOH?f1�瞇 *EãEw¿¼1w" ¤¹º`‹ /þúëhÕT!¯¾¥A@A@ˆŽÀg: öÍ ½†õ«Þ¢Ît^½²&Ìý[¾Ãv&ÅR-9sþòË/›hÄN8!ð ÙˆB%Bœ(t �gÞQcÕ@‡Bv© ¹WZ-fdÐOv�gëR¥JyÇÙ}¹\©ëXò ]g¢E‰*…�dDÊ£õ¾fÍš]g4–‰âŒföÜDqŠ ¹äib!ÛÁ‚ káHr»Ÿï÷u×]gW=ÒÖÛ� n¡S›-CÆL¸ÉuÎ!_O#ãÈ÷ÅHvÍ5×D ä^‹$O¬ÓæÍ›Ãž§NT"ÿq¬Zyî©82 æž/–~$Â=ý˜Å|^{›òFª…Ü´¿˜;’†æ�”RpÐìâ…€ë“÷x¡*ý‚€ ±#ðò´é!�ÛKÚrñ^$¥�~óåÍ«ª–/ïSHYˆšÄè'ó®©Nä9Ï´Dš¢¿ ¹dȶ0eÄ(dÈÎÜçk·ÍoºVC8cÌð-[¶Td‰£=Oä%5D“B2§àc�mË$&GÀ�8ߣ³¡¢²QÖNOÂL)ds2jè¹ÇÓ\|Î�dÜ+ÃÝG9Ž ¢éãeýúõ ì ­~±Œ# „{Ʊ‹z¤ë¤1i6B¸G…-lƒÇ\1½ùæ›i*O‡=HvQpÈ$Â= X²[A@ˆ3h‡N8R0‘®ÏÓŒ7;ÅÙâ|º\ßÝ:ô©&3­5×QrV§Ûn“yÎD�e¿ÖrN¼žÇ‹)b¦œ8~³ �“ ~æÌ™æ��B†Š – #+åí·ß6»ÐGÇÁ—Uæ¾ÃG:§Ë¿¡�þÖ[o©B… E:ÄÛï`ùÄlkÞ¼¹jР�Áfÿþýæ8Š!ÃÙ`Ó¦MS�522T•æÜpfÈŸþùªzõê¦ *üòÏœ÷�wÞQ_ýµ9ž?ÔǰE ‰FÇÉ` ù.êP Å‚Æ9ÆgÕ·o_e±g,*TPO<ñ„Á9¯–p{þùç�líÙ>uêTU±bE…ô ×� 5õ)\C~†¨|ŠRS`úÄOtwËr#�aÂ� »K—.MS=o_F×è_²d‰Ú²eK/QŸ>}Ô…^è6÷–ÑŒzõÕWÕúõë½Z»“/O�5Ì*ņn¾ôTF¦` Å{ì1U®\dMBHwŠ�ZÂ^‘¬kð]ÔuäX‹s‹- ±‰Á[�=ÚvNmŽñãÇ«Æ�{ ààð7K1LüÈpÂ1‘žÈt>#þƒÒŠ8'ÅVÁƒ­uÔøÇb×ñ¿aûöÏùŸÁ)`Dù0`€êÝ»·¿©¬'7Â]÷�,Ý ‚€ Œ›=ÛKGgwûF Zɦx!àÊÉ@$4Ó�Eb‚€ Ù�Á�H�@ÍÐJ‡Gó[·nÝÔàÁƒ ‰ëßç®Û÷6mÚ¸›C–ᾈ'‚>Ç}g¦!Ř …pö«,°�àS¸<{­ðs7Þx£9R/ðTæBècG¢D¶³ŸÀRx.8@‚Rý†¢lÙ²ªY³f†r³×á£\£ÙúÙ#œÁCÝ|óÍŠz$s°‹.ºHÝvÛm&ÖŽ•틺…šá wìØáq˜áp†‡$Ð’c‰¸÷Ž�N�:þÑò¨ÈéáÎ$–sø‡þü/½Ã…¼´^ÿ±|ÁñˆY[¹r¥ùǶëþ9^<ëíq÷áy"uB6È ‰ñ()͈8w£îñ’ÚÉ›£ÒûºuëÒÜPlD(Ó&3Æ{âĉæK¯Hg²¦L™(³“HœÁ�,*»úÑð!â�#7Ô ËlÑÔŽ;šTœ r5QÿA×Á¶Q£F)ÆãZ], §‰õ¨ºûbYæÿúÒK/5ß<Ó™±#FOp#ýc;mhxrfΑÝǶíÙS½2{ŽF^ý#ÿÝú¿ ¿d÷¸äü‚€ ‚@ª#pÉ­·ªmŸ}n.ó �Ö½ç­7Õ ú…Y,þìÓ’ç–¿Ñd€Ò{MM(Ì]ÿ³¦~�—Õ¨©¶è`(Þyy¿�ä@›wYcHa±Œ#@t5 p§žzªQ(€Ø†à΃ÂDÖ†èpø@äXàáŠ-Sp‚Záî˜ Ð‰Î'RŸ ²;ˆ'JÄur` éNPmžE'pPeBºÿ;žðGËsÍ~}³DÿoØqºsÒ´ªT©âyQq0� –uüõ×Ñ$7í,ëF gA@rþb©mtzµXâ¯3”­åÑdîb‚€ ‚€ ‰A Cîv(ï¤\ÄbT".¤µªýúN±KŠGP$0Ç’öAñ€ N zR�>ú¨™Üþ!_‘8qÍ­<ìnGcÊj$¹îjj#B„<ÅYƒ Ò ãp ¬À =F_ Ls²+Hå eï7¶QŒ" Œ¢8ÂiâÓ&^8Ó•¥]9 4º üI“ñ8Qm™Ï½/[•œñíÍ óq6ýŸP4gQó63íôÛo¿Ýs¾dÕÿ†ÿ:ø|—-[fèµñ?Ç÷J,ë‰pÿÇ?²îÄr&A@A —"ð«~›ád«^«Ÿõ®¸¸D.E#ñ—ý¾~oÙìèߦƒ‘$› ñ¸ËA@A ÷"�)Â=»a#Š{úôéFš$–±@ººäZåÊ•�MP¡·¿º:ÅY¤Z°Ï?ÿÜ,—.]Úm–¥ËDÚ‘ívÈ© ピŒÕ¹§pÑåA¤·=.hž^œ‘óÁ b É"Ï£�©´¸(k�(Eh»Ï�SÙ9ˆl·m ±ÇŒ£ þ­DdƒÐÇÊîÿ «fÇ+ó¬CÀ½'H„{Öá.gA@ȽLÑA�îÖÚ)Lf×e_l­Ûkëz"'c±�¹ ‚€ ‰@ ÇîT Fª†ÈùX RÕ5¤Z ¤3bhƒgáŽ^;–£7Õ�-a ±D¾ÇjÁbßÕöGïÍöX 9¢ãm‘Õõë×G=ŒÏðV]t+šOÅêçž{Î4E«Ÿ±‚gªüoDÃ@ö§Eà¯ÿýåm”w YA@†Àè3½¾OÔ£MjT÷Öe!¾�9ŠƒÃZ1�%{Ý%íªÌA@A@€À1 è3Kº¤ÀhzÈv…–w¼ŒbŸÙeHÜÄjåÊ• i ÁœËÎ;vì9EzŠQ 9tá…zÇöÙgÞr¸Æ«A®»fÿ'ìÜÝ—ÑåìüßÈè˜sóq!îÿȱ·ÄÜüʵ ‚€ ä ¶ég»õ:pÅZ£[«)4ÅŃÀ««W«ït}#km¤Xª…Bæ‚€ ‚€ $ �\Å.�qÆqò›o¾‰[_éíÈ�éxtÍ]£°h¢íØc� 9…Kh†ì³‚Ì‹5ŠîF³SO=5Zo¿¿†Àï¿ÿnö¥Êÿ†w¡²3nÑÔXþßbîX ‚€ ‚@Fi™F×Ú7lä®ÊrœxeίGžsZèÌS1A@A@�Ä"»KbÇ‘%½_sÍ5FKÜžìÆo̰¤Lz¢ªíùâ5'‚msŠ~F²O?ýT¡õîDmn„:çzíµ×Ô}÷ÝÓi¹¶�;wzmý}y;œ¿SÁÙ•fÑßÖF¼§ÊÿFš – QpBB¸G…K‚€ Fy“‰óæ{Ç>ï\U¾ÔµÞº,Ä�tí¦…+Wy�VºáunþüÞº,É€ÀþýûÕ²eËÔW_}å §víÚ~O÷:‘A@A ˆ;á~øðሗóË/¿DÜŸÈ�~’üàÁƒjøðáé–¦Éè­.yF�w�»ë®»…@Ûµk§‚HB4æ7n¬~üñGï0ÈeІ&Ú.¿ürSÈ–‡'lÉ’%jìØ±ªmÛ¶OM´yË–-CÚP°5šQhuÕªUªB… ›2žqãÆymˆÄ/Yòo Ëìþßð% YŽ€û½”¢©Y¿œPA !0ù õí÷ß{WÜ¡QãÀçX¯�,d �©‹)jYkU¯®]”¹ �4P_lÓ¦M!ã9ÿüó…pADVA@r™&ÜóæÍrÍ�«}úô ÙÆÊÚµkUÿþýM´sš�Y´áúë¯WEŠQŸþ¹9#¤4Å6§OŸ®¢IŠ@ÊmÙ²Å< @\ÇRô”SN ¹27r;d‡^!ÊöÍ7ß4cá<Ý»w�X”¡:¨Ñ£G«V­Z™¤U¶mÛ¦V®\iî?ÿüÓ; D"ÅH³ÂN<ñD}?`Àït]ºtQ¿ýö›êܹ³ "5wïÞmŽyûí·½cÐè¿óÎ;½õp |6-Z´P ,0PƒÚ!D›={öx»Ë—/¯N>ùd³žÕÿÞ Ž,àÙ¾}»Bï>{Y�ÿSÿó:‹AÁÈk+ éG€{Ò ý?ðÓOé?XŽA@Èñ<9r¤w Œœyú¿ÔŒÅ‹½m²_†ŒçuHqZLðö ‰ËÂO?ÿ—~rs'~9ÒÜŒ…\» ‚@ê �iÂ)Žã�?^YÝmˆõ{ï½WÕÑú€D,Cj“"¶|ùò@Ô~øaÕ¬Y3ÙìFj#-2uêTCBCÔþàû¡£—_~Y-]º4¤OŽ'b™´J•*…ìcruÒ¤I ¢Â{ýõ×Õ\ š4i¢ð®,XPåÉ“G I»yófµ~ýz…núOI4Gë!Ö­9Jl\{â‰'äð :�óÌ3Ï4çØµk—!ò¹V—�ç¼�Ð`ÉÖ­[§˜¢ÙÀ�:~KΜ£[·njâĉÞ5ñ¿ÐµkW#qñ}É%—¨³Î:Ë�Ì7n49¿þúkÈð�¡9ï¼ó¼m8s ÕùóÛ×_­®½öZÕ¼ysU±bESx⟢«D}þùç•›]qÚi§g…í'«ÿ7ìy™3æZÏ”$þÿȺ¨_¿¾ÛD–ˆ€+)sŒMM ÒJ�™9KuîÛ7¡ç�ÎA@rüþvé×?g 6Fù›~oõŸ)p%Éy ¼·‰e äGá † ¦Ö¬Y“±Nä(A@A ÉÈ4á~‚Ž–€È…¸Æxx&’:ÖhjHs&ÈW¢Í­!•é÷‹/¾PL~CZ}sˆì|ùòùw+"™zè!3Ù�?ëÈ´ÎýzçvМƒh„;ò-h�CjcD1÷ìÙ3¨»4Ûˆrv¥.Ü8\’ÐÝç_¦Hè�!CÂʹ$ g2æÏŸ¯Ê”)Bt£¡î×Q÷�™õêÕ«+ÖpFÔ¨Q#,&´¯ &˜Énþì³ÏšlwVþoØóò?>yòd»j"ðûjBRw’„/HÑÔ„Cì�àë}ûÌr}o¾H;:ÅA@r_é,Ã�:@ÂÚ%úùßgœaWeg¾ÐïB»tð�µ’Å‹«<ÿú—]•yœX§{þ«¹¬”fœºÍUÝ�iÞ°aCóîéý?W�"+‚€ �ãÈ4á†DôÑGdïÞ½!Ç]žQ#Úž‡ž Â�>{÷î­ „™ÐÅ„ÒkH·´nÝ:êa¤ÇÍš5ËD´:t(j{Û @�†ü'B;ÈÚ·o¯*W®¬ž~úiyÔ†c‘céÕ«—‰¦jöD⌖û[o½e$oÈtˆÅp4�!��+­²Ouá±ôkÛ�½ðøã�‡u@dÕÿ†O�ÓÙ2pf‰%×yåþÏ%þ̹÷ uõýëùþýr/rå‚€ äBŠU¹Å»jˆö÷çÍ5õˆ¼�²7xf¾à¦ ^œsŽzþ<ÑË÷‰ßÂE•«¨ÏœbŸñë9ë{"Û–ì`Š—’ \´hѰïÓéÝ·ß~k2Ç .œ&è)½}¥§=ç…£ ­X±bæºÒs|<Û|ÇXxOç=9Ü»~<Ï®¯dK¸1ÊvA@r:ÇÄãˆN' ¬téÒa»+Q¢„zôÑGÓÅDÎ-òÛn»-äX"�!•ÓóCd%e8’%á R y4³!Î])›pÇ@~"Sƒ4 ðhmÇbHÜ �Btv$£ÿjÕªíõO>ùÄDx‡k�¶98ï¼óŽÑ”Gº…¨ý{î¹ÇH§ðY�ÖøÔSOE$Ûé?‘8Ó?×�Î�‹/¾˜M�†tQÝèØ<8ÍçÎÿÖƒ>¨�ÏÿOÿþýŽŠH†” ÷èɇ³¬üß` ¶ý÷¿ÿ2²„l�$¡+®#'–{AB#� ‚€ )ˆÀ*-ϸãË/½+k]¿ž�íñ_X®å&mV½·Ò2˜òŒœ³ºGˆp2¬Ï>ûlóއD)Ä-ïs~ã}™U·-ïeȶø�À¦ûï¿ßH[ò¾VµjU“¥Ì±H±"}Éî¸ãC¢3;uêÔÉ‚ ëW\aÆÁ»=$>ýÛšj‘úeÒ®¼ƒó¾dûæ��ˆøï¾û.ðp‚ïúõëgÞ ¹ŽGzô_:ÃsF=6Û’ž�52ïÕÈ⺘ùejÇ�¯��µÇ2w%PýBÆ–lsÚÐex|vŒóðáÃþÃÔN�Ý�,cI38Ù ‚€ q‰pçLD“Sð’ì7ÞxÃü8MŒi~h­ñCÍ�—q%f¢µÏÈ~Æm‹ßØß³gO“ÝÍ~�ÖS¦LQÈÒ†3Æ …‹µst-$UýõWë—EƆ,jŒ€&k¢Ñ‰^ǹ€!¨5Ýp$@†¯ZµÊd¾ÛsúçT\ã‹ä, ÊÞ’íúd»“a@D/8°Ìg†sÃá’n]tQÒŒÅ��¬g-©…œª×é¿ÃuVFj—¨}ÔU´Y;d.‰%!Ü�±œA’7:%»“&š ‚€ �!ÆÌœåw²Žrm¤k‰%�W �O8A5Ò²b©…r,ÖÖ¬Yc‘{±¹üᇚÕÕ«WÛÍ!²• ,0RÙië±]ýõ^[ Ä�ótu߇îE‰‡4XAwÒû‰'žð"·‘¥Î쑌¨^—l/S¦Œ!ÍK•*xåÈè`Œ›Hz꣹–7o^5zôh#uãn�÷2Ñô6¹du¨çF6kŒIdc,q�Ô-µÜâiÉ4–x^Wnê‹úv8j�'J%ã;BÆNn’ÓEé.¤²ÜûAV}®n½w9«ÎŸÏ#„{ê£F�R·ÜrKš›?ÆhŒÛ"0Ï?ÿ|_… MHnB#Ü“{¬2:A@A '!ð‘&�6ê([kMªWW§éôi±Ä ðÅ®]jÍ»¼ÎëV©¬N×2"b©……7­Q;�hi$_\ƒ€ß³g�©mÅöüùó+¢¦­A„[ëÝ»·Ùo×ýó®]»*¢ë1äO¶oßîo’f�úYH¸mŸs ¢¢1OÄ=×Έ|·†< r±AÑýÈ#�íŠÛ6d#\#ªžhü ‰,÷]ä½÷ÞsÍôr2�%Ó“K;À!ƒüJuýû™J†|Ž·pßÕTºV÷ZÈ&ºýöÛ³„p8p ‘°!{†ˆv7Ð�1íÝ»×�ÿ5kÖ4Ê]úB,¾u³Æ·_é-“�Ç‘t5¿ý¦Ór™0¼÷LTP§@¨˜ ¤·hªh¸§;i-‚€ DBàå#§¶�ÈÉX$3ï#][׫—˜I¯ÙŠ€K¸á>yòdOÆ ™—Èr rÒÆ-üé�l·}Ø9 èïØ±Ãl‚t‡P�dœûÜsÏ�Ô$æ}ÈÜ Yã—�q;°R2ls n» á…¦|¢"<Ý‚­èç#«‘™ /K¦±Ä뚤ŸPpNmÛ¶M‘M�ÜFé1HÖ¯¿þZýðÃ&¨³P¡BŠì”ôŽ#¾‡di KŽ-Ùa8!ùßÇY&6‹$½c±×„Œ×S¬X±tå8>©Ï@À,Çgt,éû/ºž ÎTøDod �rÊ)^7H[qM®Ã�âÍ#?$Â=~XƵ' €Æ*oA;n°b‚€ �~Ü¢©V£2ý½È‚€ ‚€ à"Ñ4yÁBoÓEú%¾Œ.^(–8&Ì�çuž_ëcWÖ2b©‡YÎÅ‹7Y6hÐ ï"­&8õC=ämwIz6¢qn B(š}õÕW^“ÓO?Ý[NÔ„ïÑòè«C*†3Wjù $§{NŠD‘íœ'3$£ÕWvÇ›™ådKf®CŽ E€ÂÃ�£8� rù~ã8£0òe—]f¤ŠB�]£®Aݺu�b…Jù~!{Ä÷‰)Šó=ŠÅ>ûì3E„4÷[C‚ã!î‹-ªzõêe¢§Û¶mKw¦ …¡ (å>@ád&nDÄ»Ù/n‡…T¦�4íÁG!˜@º÷ë×/ì÷~êÔ©¦­=WÅŠÕ¤I“L_\ª—^z©!¬©Aaƒ_Ýó»Ë‡2E˜ùl µÉP¸âŠ+Œ#¢I“&žä—{L¼—qzÜvÛm!ÝRÿÂ÷@—l·[E‚η¹îqƒ2¾,XГ¡à _n¢ü7X¾°Ü Š)ßHo‚@.AÀý¡‰ÕÉ•K ‘ËA@2ŒÀ­Ïú½Ž2³Ö±qc»(ó €”ÌçN:xË:uŒ–uN%]&®Ž»%Ã!§ÐG·f·³î×Iv£ßŸyæ�Î�­¡X+F�ï ‰6Æ„ì�u 9 ‰®Ðß•W^éEoBÖ!¡”)9ؼyó˜‡ÔG´ƒ¯v‹8GÈ € ŒerõòýçI¦±øÇ&ëY‹À‹/¾h oݺ5äÄ8šÐ¯£ïÿH1¹«m¸iÓ&…ìÒ¼yóL!a»Ý�¯]»Ö�ä³gÏv7§Y†à†Ì^´h‘"¢ÚodÒ<ù䓦(1²Èd«Äbhœ£â€ã�hu&2EfÍšèLÀ)¡Í÷Þ+¶çá{G´;RRðjA÷jUnÏ…„šùDþ»F ÁÓO?­¨)Ár�qÿa,Ï>ûlçßajMp¿ŠFÚõ�Þm&L0˜SX;è¾MÄ;|"c"3Á½w¥÷\Ò>!܃qIŠ­ 40d:7ÒPü7S¼qñL;KŠ —AYˆ€#îY¼œJA ¥p‹¥¢›Ü¢N픾Þì¾8·X*ciU¯nvIΟ@\ÂÝž"’È�ÎzÉ’%m33oß¾½—! é²oß¾�6¬@¤U i…ÑíåD÷ "\‰F'BCò‚HQ¢sýFB7Ò² §E^mqFÈ8¢ý„œ¿/ð²ï¼‡8p ¤É«¯¾ªJ—.–0ãVêLkÕªeˆC®)h‚HĹÀäqÒdK²’­¸ÿ'd1­ŽÆ;k�­Ýºu³«Þœ@M¢¾­‘íÂÿ3÷¾ëV Šs´k×.Ðqűæ;e³E�i¢¢ª!”ƒÙ�f‰Åˆ4÷R9AZöL®]»¶áÊì1DwÓ–îµ"‡…³bÝ5p""ßo\ßgŽ!ÜÿСCíª7ÿöÛoÍ÷ÝÊoqáÞ _‡ÓÓJº¸ŸŸwp‚?βü68ù¸¾¬’ºñ�!Õ×EÃ=Õ?a¹>A@ˆˆ€«á®ÅA@A “ìÒ…¸^×rÖjÞ|³BâD,1Öµ�f8E0¯Ñ/Ø—:2sVé5;ðKÄ0–6mÚýfˆ³#FxÃ#ÓO~AÌ=þøã y òŒˆÒjÕª²BjÆ ŠHWk-å×È´†°!’Õ�’'Õ•¤€x"êâù ×F�mÆKp™ß «,XàE^ÚXgËÍO?ü°‰6å8Š» o‰w¢iï¾ûn—Q×! ‘ìA†k¹�Üd‘þ½¹†|mÀ†(|Ètõ‘ø –(dd; DÑp†DGcçÎ�Šb¯níË/¿¬:tèàuŸLcñ% I�ôàÁƒMÝ?ë âÿ•hí¢|Ô¨Qªž®åá\%kâ™ïÿçÈž¸ÆwŒ"Éü_æ(BX'˜­ ÑÎ÷£O"Ö feL8¸8ÇØ±cÍ~þà€¬\¹²*ä�îÈááï^ûóÏ?¯î¼óNsÎÈ=zx}°Ð¹sg/ª)¢úÝ{58Ú�]É(žìÞÃ#µe÷C2 ÂNG7û‰ö|†`�ÔÏÂ… ='c¸>d{ÆÂ=c¸ÉQ‚€ �"¸îR45E>T¹ A ؼ}»š¹d©‘tørÏ×*ož3TÑóÏS—]TL5­YC�x Ù0ªÜwÊ9Ë^Sÿýãoi„+µ_1ý«½þÖZõÃÁ¿#Ë_{­*pä%t¯&YÖhâ ;óô<ªrÙœ«‹îcÅ(ÖvctªÁ%ÅRcE.cíæ¾öºúÙÑfm¥£ÅR¢P‰TµÅO!Ÿ‰*Å ¸\²Æ/'c‘¹ÿþû ‰ Ã÷r ‚,Ȉî„D·Ñ¯¶ „wPÔêï¿ÿž¦�ë믿nÈ=?áN‘¾ èz{Ž�7ÚE3g¬Öôq„CÁ¤¤vÿþý=ÎîcN„9ÄÛÒ¥KÍõºûÜet§q`p. ™2…3Ú »óÜsÏÂ�vD׿ôÒKêŽ;î0²àiÍŸß’i,þ±Ézö!@„uÇŽC@Ýþ÷ù³,Ž —p瀼yóšˆkHumÜGøN¡ßŽc ’Ù:‚�¦rIgާ(3( î ¶æ‚Ù¨ÿ@ì3>²Tˆ¶Ç¢[æžäj´óݦoÆd8­ “1䮸ޡ·îß)Èôùóç‡"ˆp¾WÜ+‚ ‡$ßidž]kݺµqâ‘!�‹k80æ)\N´8„¼ÿzé—ëÁ1‡ôL8ãºpDÆj�ûöóöƒÃ’ŸûÆ} G¤u’±Ã˜Èn‹?B¸ÇSéQröLJ!Ûè€4|ª d3Ÿè(¡{<¦–êŠpÖ[GêôÔÈ�-[$Å}fÓ–­êÏ¿þ4ý\¿l¤Ráõ6<à�O÷ê™.½—Öåܨå°#GªG÷÷>Þ¢šv»×l'r8'îá®Ñ\\œþð»úÊœ¹^ogkB¬šN¥K®œ Q}·i'ŸXê#@Tµ%Ü!Q¬A¾ Š&1ŽpgßÀ� GAA&÷¹˜ýH;  ‰Gd¶ß�b Ê–ˆÙHf#ÜÝqÚöDÙ#ýâjÎÛ}Ì)äw³Î’!Ú"£?H@!F¶­J”?Q¤D£ãà: ×�ž€œ"jC8ãš‘Ñ!šÕJfضDÁU‹£‚ˆâpc�œ£ø"EÒ†˜äú¬¤‡=��'ÓXì˜dž½ð¿ì'ÛÝá#ó„ì 4Û!ˆÝ,jPTyÊ”)i¾ón?á–?øào÷?ÙîíÔ œ‡Ñô~ÚmDzK¶óOÆG¤gT{�³ýð�‹dîý�(òp„;F?ÙN¿HÕ@àƒ§ÿ¾@Ö�â w­9Îw>+ŒÏÚÞŸ‘ºÂ1ˆ´ ÷þ{ïýûÙ§…î‰ù4„pO ®Ò« äÜ^÷A$‡ _†)ÙˆÀ×ßìSUÚ´UÈg¸ÆË·{o!Bú�Þûíß«Gô4Ýc³b¹œÖ×&$=è/’%ÓX"�Söe ×ê,¼HÆw‡HNESÜ’Ë|ב\ Wô3R¿vŸ›ñá`¶ûÝ9ò4d”¤×�„¢hj�ÂJ�k\)±×ÏZˆ86¬…“¿±û¯¹æó�wßì>æ8þùgwSÄåH÷>w¦8,‘ý±:ò8¹/1n$vă€î‰ÁUz�‚€MÍ!” SHBšÝŸG¶Ÿ¦£E÷ì©êV©¬eGNW6dH°i:Uó£#i§��xA]uñ%ª~ÕÐt×$¼´\9¤†ÕªªR—_n®ý‚sBÓˆS�¬¸ÆÑ3B ¶©_?UàKÊ똨ÓäÝg™ÖõDN&)?¨0(Š/2‰Eâ§SfŒ(öë®»ÎLí'™Æ’Ñk�ãâƒ$z4s#°mv R%õõo²%ÛɈ¢>…5q²!#Ã9IæÉöÇÒC G3Q8¤ÈÁÉ…üÔ’%K¼"Äþã3s¿‚lާ¹˜üòË/»FÖ&ÙÎ�|.|ñ2²‚Œì±Ä" „{bñ•ÞA Ép‹¦sLäè’$¿ž d!?ë‡é·6MÿÔ UGkDZ+}åŠ ™ë4TŸê—lœ.À$„»�"éþ<�ŽÂ^I7ø”èküQ¿(ÏÓYÖÊ—º6]²>ö8™ÇŽÀ+³�êBç=ã E„»˜ ‚@ê"ðæ›ošèo´Øƒ %[Üi²30$d(ˆŒQÈwõêÕª�–HònQQÿ~ô¿)DŠQpó’K.ñ7I³ŽओNJ³ÝÝðÌ3Ï)œâAÆÙ…hý3]ì Lë—êôÚ—:Ê�ëCמÏ'=c†ú]§u[«p]éñYÚñæ´ù�r¿Uë³ZC»=’–®m'sA ·!€ÔD—.]L�ÇËu&“-øDÑ¢e-*5·a&×›¼ µr›– ŠBG³»Q£F¦Wà%jÜÚ=÷Ü“†œ&ºy‘éÓ§Ûf�s·Pqß¾}MÑÍpÛ?èçÆ»îºK�¡ÂÔWˆdè›WªTÉZEJ ãø*Uª¨™º»ßˆÌG—‹ZµjGýMÜóL¤§pãõŸ#Öuœd²`h¢?øàƒ^&�ÛDzeËDÂÅ$Å—%Â=Å?`¹YÝt])5ò‘GÕ9ùÿŽ”3ùóÍwß©{\Mu±»Y=úüójØøñªmƒê±ûîU'i]e±ø!àK¥×ÖõêůséIH!Æ�§^|ñÅÀ+Ú¸q£bB›Â¥b‚@2!@:EPùu R—š5kÖTè¤ó¼¸}ûvµhÑ"�è…´~Z„·Fö íÇ�¡6RGÑ衯×AVnÆCÚ<òÈ# RC†† Ó¦M3í)¸I‘PœWœ“Hv¢Ó‘°¡¤9‘O!Tê¦�=Z�1BmÙ²Åìsÿ ?¿`Áã c;,�7VHÎPC< ý‘^™]�‚z˜Žúbå µyÑB/Š›Æ}‡5d{“ÕÕ»³g™ñÏÒ¢í1Æýôè1f9Yþà �l¯Z¾¼Z2f´óâÑ£BôûŸ3ÖÈï„s�AO²½àÙùTS-B¦Àyù Y—l¯w‹N¡Ö/m»×¼¡¶/[ªíÖÍ8yèwÈØq ";ÈæêÿÈv~ÓÐP¿£EsSÌ7¨­»í?ydû¥:jŽÿ¥/W¯RoN�¢šé4mŒˆü›[¶Rûi¡13õg@¶�8Põ»ë¨i…~)GöH,>,\¹Jýpà€×™D·{PÈ‚ �"{y/$ÊtïÞ½!Ñ·è]g¦cšÊA N…� ’k•uv"D°%�Ý}üö£Á¾MKù5í’'K—.5Ä®»Ý.S¨“m·H0ýíݺukÛÌ̉ÄFeðàÁ&ª=d§³Bzݺu ißÓ F讳Ñ‘g–¿9ÁqÒ3"ÜÛ¶mrcƒìGû=’qýuêÔ1‘ömŽd ’%€<�[ô”>Š)¢pPXóÛ�m1�¾=ÿA–/_>Õ§OŸù·“u!×ëÿ¼‚Ž—m9 ‰pÏYŸ—Œ6�p¤x†ß¸�Æb;wîT¯j€´ Ärˆ´Éaüõ¿£²Çèq1A@bE`¸&’þMMÔÅœ¬ÙH`¢�±³uNe�öÚ¹iUN§«»†¶;‘ñdÚ ßò¾N«½Ê)^¾€¿Xê# „{êƹú ÷D\Å iVü@@x�NDÊ“ÿk_Ò.ypÜåóMÞ�IF&$%h‘�j�Ñ#aÊd5÷µ×ÓD#§BT/ìÔ¡C<ëúÁ¿Ú�å�T8eáÂÂ}©N]ýIÿa¥J^®J-j–!@­!ï2rÊTÕ±Ic/M÷²bÅÔ¾·×Ù&éš#2OGHcôcIS·z´ÙÑæÆÁéÞW§òú�Hx—lg?äÔ»µ^(Ö4 u¶”ÉeÛ™ÆIòg€.®gÉv;$Ï�ÿù�š¶èUõÚYñá¶íŠ‚–¥´©ßˆlûäÞÿ�Ý_öêkLÔ<ë…4N–ð¶û™ÿü˯Þê�Ÿò–ý ß}wÌd;ÇòYÚŒ/"éƒÎý˜¾î—§M7힟8IõÒ²5§êóó ä÷Ÿ^uh|”T'+B,¾�aðªS‡Y7b‚€ ¹Kjg䊋ég<¦x2Ò.LÙm8МgÊNƒ7"‚Ÿ©jÕªÙ99w6" „{6‚/§N<¤ô {F”;z^é14¹lÑôÂ(rA:¢Xj!` ®J4ÜS볕«² �ë®(©˜F?þ—)t‰î:‘¼k6lPüñ‡7Œ:R§i·{Õ¼_ð¶QLÒFÃSàÒÖ:w!o­ÙèvÖ‰j/Y¢¸!uYG6†ˆêJenP7\y•ŽFÖ/=:¢=#÷´�t޵ó ÐQÔíjÈüŒÓÿå­°u›·ì.\|ÄAàncÒÝéAdí)'�úvëløûÉŽu"ü‰Þ²üg�e4ö—Ñø$:?ˆpÇYT<ôâ ‹*&×öhgÿ'Ú©‚Öý¢U«Ôëk׺»—�׎ Ûok¸/ÜÆÍÛ?ñvýCý#ì玳d—ލÃDä:N™†U«yÅYm'tÖÇ7ßíW×i‡ÅVóžq†Ý%ó8 0yÁÂ�{‹ÈÉÄTéBA@�8" „{Á”®’7‹4¢Ý:r/Vû\§d»Fª–î."©±ì’9–äJ�+“«�¬F‚‚•©§ŽþEc{¡ÖqìùÔ`Sä’ñ@º¿©‰x+/SK˼@F~ÿã�†„~sÃF£»�\Ëü#©´DÒ»‘àÜ«j ÷º]ºª÷tÊ*ö�Žx…°gÂè³£Ž2îÞ¾}X¹ÓÐ÷çc‡pÇ`�¾f!«?êôÝ ;Y§7G³ âùØc“·ÄÐZê%’uôHw„‘à 爠_þ� ™¹d©Âùñ‹ÖÀO¯1¢Íb5ÏúÖÞu—]Œ8ÿñàߟûU—¤Õ)}ÿã-Š ãÿ"$qˆÄË<®œÌi:Ë NåJ™ïTzA@A@ˆB¸Ç Jé(Ù25Ù?¡ì_h„{¨¦[öŒHÎ*ÉŽÙOÏMœè ³v¥JêB­}é7t´›×®­ÊèÛ¢•*{»¿ñ†G¸CŒ6×)‘ôÀ&/X`wˆnK¶ÖÐ:Ýþa"�7Ì™­–è¾æ/_at´Ñî¶qûäÈ—4ßš:U�qúévWÄùŸ­k‘/o^#ÿñ½³`€6g´cRuÿqÇë]Ú�ìo£^p%�Üí½±Yó�¤�óÅ‹V%´î'ü©] ™îö®·�»ÌïàŸþémºR뿦';bô̙ޱ,\}é¥ ©# æbôÿÆ»ïª7Ú¾«F<Ü_Gßßf¶ËŸŒ!€S Í}kr\Ùý2( ZCËwmÚ´I=ôÐCªW¯^Š ‚€ $!Ü °tŒò.± @Gz^ê‚{ Ýúý÷ß«3µn¬졸ÈZ09"î¤Ñ‹ ‚€  HòÁ£ÇhÉŒïLSˆÕ:u {Xa�auéE)=¾_“á®!+c ÷™K—ªáõUÓtÁnk‘ä"ªÝx£Ö�¿Ñ4= #ÍW¿óŽÖ‹_à&ÝöÙçz¬£½—¶Ïpób… y»ˆFž0ø)o]”ú\ÀŠd_~½ÇÛMñÚ ;æÁü�úôõÈvŠ¡¾¤ jùu¹cyfŠ¥�;.Úã0Ú²c‡ÙUHëÝÆbT�^¼x±é‹ÊÒ®=÷Üsj�Ž< 2*ÞWÔÅð¸ŽN8!¨IØm`C¿TÒ®_¿¾*©¥IJ÷ÿYœ4Y‡»œIÈé\å¦H*×AñÂ;FtôÚâ§´w‹‚²~ÅÅ%Œæ:Q«D¦•Ž Fd{õ›n2ËöÏb}¾wõï2VîškTÅn0Ëyt¡¨:úwˆ©Ç Ajð¨Ñfûº÷7™y,Š.ì5{çÃÍou� 9»N×6Á.»¨˜úöÎ<Ф ÃÅîn‚»;î\ƒîîîî‚{pw;Ü wwwøÿþ:7�ÙÍn²‘M6»UÏ3™î™Öw6+ÕÕUyGø/G0Ô\ºÀ®Ú¼áBþû5Iåä{׃vÏøŒïDGþã‰{n#FP|a”`,¯Þ¼1¾,yXÑk ÷câû”9…;‚ÿÂÝŠó-b'†æ�× üÕ^/™Å÷0�«U¥dE‹Ñç/_¤ßñS=éoá×�%à° jš`Q§ x`aæ1%/^¬n§ïñpSÆÂ˜`L€ X—+Ü­Ë×f[‡Ò;—ð§©W6jƒÍ,~DêîOž<¡œâËü÷ïßµ"ç–ÂO­_ w.>|8=ûϺI_?àW}�°~¡ ”çZÖäVòýû÷§ &l…Fa(±± €cæÌ™Ô AyÍdCÿ]üôéåÍ›—^Yjuöï߯%Mž1ޱcÇR·nÝLÞ7u}b1 �ÁƒÓ°aèoß¾¦Šó5+Ðûp×”V膛dLÀÎË›O)Ü�ŠÏu¡^k©@Y¯¹Â⯩à‹Â@ÏÅâZ¥ ­Û¹K6=lÆLª"Ü$EÆ z™)ŒÚ,/ån’ðºX"‚£ê}�%ŽØu;F ¥˜O?žqÎ[H`׿ÿª�5¨Ò°ª‹…5¹˜#ÀזּmÛüÞ?~¼É÷GäÃsfL€ 0&`M¾Z³7nÛfÀbÝ”²ÝÔ½Ä�;sÊvSåõ×F�(?�û„e¡æ X0¨$|ÞblþɱÕ_¯Ì7WþÞ½{f•íæê_ÇBA@–ùš²]«7}útêÕ«—´þ×®ñÙzôÿ¦Öë™[fL ,hS¿mس‡öþgÑ‚t?Kõãb÷•&ÕJ—>¹}”áÚõz•*R7ñ™ùM,n?ýo÷L¹‹(–/¯ü|”VÑba¹ZÛvR1KW|^ ðõ­‰q Ê„Âçú{ÒoÒDÙÇï¿ýNÕÊ”–íNìÛ‡Š5p•÷áæäú�»äRª$Å‹[úâ†K MÙ æ’ Ȳ¶ö †Ïœåï°VO™,-ü-ø_øP/Z¿�ŒÛBîL¸*X­ ¬¿5ÁŽìâ³Tàc?y’$tG!às ÏtHÇ”)M|»(†NŸaÐ,Å+-JˆTq)UŠŠ £Ì ±òÖ¨IC:u¤œÂû½G�iבi¼›ÏÂJצMé…ð ½é¿�ZÿXxzüüaA*EÒ$tS|·šµ|¹R¶'KœØd¼­>Ÿý& –Š’ØeÀÂÌÀîâ b§’&•ELü~baL€ 0&À¬O€îÖgl“= pNaÍ´[l[‡5¸_RTü˜ƒ›™­ÂŸì;áÖR¹%~°õéÓÇ 8šY³f¥ÄâW„èÎ�;ҥ͇ ÊÁÊü‹Øz)R$ƒëÈÀZëÆÊvX¦Vy°¶¿!¶ºt¡ ]ºtÔ®];Z.~Â|@ 9„•a§N�R�ˆ wÆ7nÜýH7®Ïù€Ð+Üû-\À*si&À–”©+…²º`�ºtí?å5‚^ŽðCÁ[¢@~Z6a¼If±„0\Á¬nÍ4AÀLS®K`E ?ïšµññYŽÃ”  býʆ –R ¨1#8+ô…;¤Hž<4X({O�&¿ÇÌ�K8Œ â-sçØ¬µ$\˜àðOÌ75U‹žÂýQª¶ikª�y“êÕLÞóëbo±k ¥Ø¹9"RJ6j,Óú?N‰)?ï“ÄÎ@àõÚîóšÑ— hzöÐ!äÒº y £5Ûw0ÙÄ0ᯕ óçû2È@|‚>ã'˜¬-JZÂ1L²±ä"vA¬ßåóþwîÜr‘Æ’º\Æñ`‡òÀ�ÕÄñ»kÒ$Ÿ…XuƒL€ 0&À˜€Uøì)¶Jóܨ­€rzýúõÒ¢{Þ¼y~JrM }[(Z·nígyíæ¡C‡ ¬èaQ+ò³ÂGéæÍ›iÍš5têÔ)zúô)͘1C*ᵺ¦jJÙŽûc„_Z-ðòÆ%9|¸Ã ÎÈãz@¬–a ×7X4hšW‚1bþ¦ôuòäIé¦GU° Q¾|y*%¬Ê´1Â<‚±„šr¬¹'&`oà_ýâæM4gØPiÍkn~ðÑ>äHÚ"\Ëø¨ÎXIëêRÅ\“Ôº^=ò±ErfÊd²Lá§w\¯ž´T¸0vs3¸C¡„¯làEûÒë/ÜXºDZXk×´s„ðá©}CW:²r%1±p¬•³Çs‚¸qh×w“~³a¥Þ¯M±¨2Á— KXüS»–\H‰+\°K–tiiïâEtvÃzŠ#^wÖ,äœ^¿N>[cw2è¯c¼æú´n%»w÷ð Þ ez[a a*ê_â;'!-_f’›5æb�m®Úº�¾~û¦¦ÖHøÆgaæ 0ªÞP FPðßΘ`L€ „ ¶pÎ6Û ïñÄÖrK?Ø“‹cÑÅJKäóçÏÅP?–‰‘P¬C1Ž §¥ÅV{X°ÃúÞ”@Ùm¬_¸p!¹ºzo}×׉*¶XCIž_“kذ¡þ–ŸiX«'K–Ì×XÁ óNA_;wî¤û÷ïKKÿ""0ž±¯Þàì�ÛòMÀÐÂ�× }â+L€ øEïÙÍkÕÍÕéŽW+·Ä{:ØÉ'¢ ŠLKäׯÿ©b¨ßÀÌg¡V¨jéR„nHî ëúGOŸ‰ «1ÈI#O'¬ãÍ ¬Ù KcÏ…[¸¡1¥Ä…‹š bAá½Ø…vAø$¤“‹jðU(XM ”€þ)¡xõK°Xðëša@w¿Êëï½={FŸ PúäZ“å++êk<˜v4Àïþç/_…ßûtÒU�ñÂ…Öàí}{µ¤Ÿg(­áý•«âõô@No}Õ{vK øOŸ¿ˆÞ .–pGÇææ¨ ‹)“ûõ£I"– ^ÇG¤ˆ(u²ääì”T+FÇÏ�§KÂÒ_¼V±ëbT·®ÒÑÝG ;° ƒñ# /KÐèÝÉDÖÊ5Ê” Zƒ\Ûn .¨à¶R“”âó G�Z–ÏL€ 0&À˜@`…{@vÔ.€T/ëÖ­#X®gË–�2 Ÿ 2d�.`pvrr¢âÅ‹Ó#ñã®hòˆíì¦ä Ø:ýMgÝW7¦”íúº¸¿eËZ¹r¥þ²M¥“Šàj8XBž€>hª9EIÈ�Š{dL ¬€‹™”â³ G`e¹Øý¥Iy±k©õ8\»àŒ˜²¦6nÊu(ßY À½ Žà(½ódÍ"SmÚ¼ìß›ºl×ðyè×ëÙmÍjƒ¾šÖ¨.ó‘…E¶ éåaP€3A"pãî]¹È¢5‚Xæ½´2|vLˆ]…@©zÁÞðâ}…… 0&À˜9¬p9Ö×SöìÙ¥¯õ%K–¨¹Ãêý¨0‡C/‰ÄV(Ü[µjE…Tsw4zÁvIK¤[·n6­p·d\Æ:ôî¬p·cn• 0Ó yüü¹ z ?êz…{‡F MWâ«L ” |ßåVnÙªF‘MÄÏÉ! )X¬GAyõb*˜²þ>§—ü´_ºtI¨Zµ*•+WNå9Á˜pðŒÏ ˆïÇÂB‹ûO-òÒïìÙ³©E‹þºI�e;ó… "³�\õ w¸¨Éœ9³E$3 ·Æ>l-ªÈ…ìžÀ¯ÿýRsä © '˜/ß¼¡dEŠRŒ9©^—.2@)º-S¸0!8' °Eð%þþãG5´f5k¨4'‚Ÿ oØ N?>ÏŸOå9Á4ø=5dÈ-+ãaMœ8Qå9Á˜pK—.•Šö4iÒЬY³aÊÿŒ1Bõ5jT7nœÊs‚ 0&àÈô;Ø™Ï=ô °Â=ôŸ�€ Ø,�K—.ɱ=xü„V=Þf³ã ®�Ý;%p°X—Àѳg  `L€ „=ûÄH,!G`Ôì9!×÷(عRÒ¡Cúüù³ênðàÁr×­ºÀ &À˜`L Ô °Â=Ô€ Ø.�”)SÊÁ%L� Èe» ÂÈÖ­ß.üÒþ’-8;;QŽìA „¡Ø}ÕÏŸ¿Ð¥Ë×éÇ÷ïv?Wž `LÀÀíÚã'ÏUðNø‡Ž/¶=LÍfçðI|V¾zõF�/z´¨5jd•ç„mxòô9ýøñÓßøSÁ5ê­[·ÒÆ�UsØ}kìË]Ýä`LÀÁ °K„òôYáÊ€»g¶Ln€ … 榕˧ÚòP=¶HQÓ …ûWY¿\Ù¢4uò @·Å™`L€ Ø�yn+¨E«>jJS& ¤–-ê©<'‚Ÿ@¥*ÍiËÖ½²áßÿ�®\ÞMñãÇ þޏÅ`!�)Kºìu=D|ìnaÝ®—éÓ§‡Hßú>9͘°eìRÆ–ŸŽc�í7Çš.Ï– 0&`Hàׯÿ© " `L€ 0&ð7÷UŠEáG¼NíŠ*ωà'ðìÙ Ú¾ã€j¸Lé¿YÙ®hpbÔ¨QtóæMÂÕÕ•þþûo•ç`L€ 0&`;Xán;Ï‚G˜@(Я€ó–³PxÜ%`L€ Ø$/¯tüø95¶š5ÊSôèÑTžÁO`é² b×ÝOÕp£†ÕUšŽMà–\3&À˜€c˜7¥€fMjä9ü.öP�ƈ�*W*¡òœpl;v$¸”Ñdذa” A-Ëg&À˜`LÀưvÉÆ‡ 0��%À+à!Ë›{cL€ 0Û'ð]·^²t½hʔɨpáÜ*ωà'pþ¼]¸pE5\»VE >¼ÊsÂq lذ�6oÞ¬dÍš•Ú´i£òœ`L€ 0Óx»i.|5d°Â=d8s/L€ Ø(¶p·ÑÃÃbL€ 0�P#°iózþü¥ê¿Y“ZÄ?Z«$ôÖíè ‘+»“± è0ÖèçÏŸ©S§NjÔø?D TÔeaL€ 0ßôu¾ïò&rXár¬¹'&ÀlœMµñÄÃcL€ 0�!à6ß'X*Ü­5t­"ý:j'?~ü eË7ªé§N�‚òåË®òœp\ǧ;wî(�7¦‚ ª<'˜`L€ 0Û$À wÛ|.<*&ÀB�ûpèÜ%`L€ Ø�G�žÒŽ�՘ʕ-J‰ÅWyN?�í;гg/TÃ�x�C±päÄ�7hܸq AŒ1 §ªœ`L€ 0“xwžI,|1„°Â=„@s7L€ ؽ;ŒŽ?�mïñˆ˜`L d ¸/XMúÏÇfMk…ì°·…‹ÖªY㻈kƒª*Ï Ç%о}{úúõ«0bÄŠ7®Ês‚ 0&À|`—2¾™ð•Ð!À ÷Ðáν2&`Œ?ŒÙÂÝ � 0&ÀB�>Ý®QýÇ�›*”/¦òœ<�•«6S¿ãéúõÛ�¼~ý–à3_“bEóSÒ¤‰´,Ÿ”€‡‡mß¾]Í>GŽÔ²eK•ç`L€ 0&`ÛXánÛχGǘ€ è-øÐ [¸[67͘`6OàÀÁãtëÖ=5ÎF «ÑŸþ©òœ<�'OžÓˆ‘Ó)m†T puš=g½yóŽV¬ÜDß¾}S 7jÈÁR M|úô‰ºté¢f�ï§3fÌ 6 QH8Á˜0K@oTÇ¿ïÍbâ!@à�胻`L€ Ø$ý‡1ÈÈ6ù˜xP:_¾|¥å+6Ò™³—èöíûôáãGrNáD)��¨b…”5kz]iN†$� ¼ÈcÝvº|ù=yúœbÅŒN|˜F5ª—£X±bûp?~F‡Ÿ”íÆŠ�J–(¤úؽç0½zõVæ ÊM ÆS÷üJ\»v‹Î�÷’EþüóªêRƯâaúÞ§OŸéÔ©‹ôâå+Š!ݾqˆzvo:²‘^Ýܽ-/1¼žkÕ¬`##³�aÄÊ;A:wJ‰’æ£*Uÿ¡G�žÚž…ŸV®\I»wïVerçÎMÍš5SyNœÀñãÇ¥%¹¦lOž<¹´fÇ.,f4iÒ„  óæ 4ˆjÖ¬I?~üð³£”)SRÆŒ gggµcëýû÷Ô­[7ª\¹²ŸíðM&À˜°o†K®ö=Wž`LÀ€M5ÀÁ%°}Ç5²ìÙ3ÒÚ5³Tà´xñâPÝ:•å‘K¸iÛ~€,{Vøx‡r7GŽLª.'‚—@ç®Ãèû÷ï²Ñ8qbÑV¡´Í•+‹A'E‹ä#­Úô¥9s—Ë{[¶î%¸3©T±¤AY΄�k×n«ÎÊ”.LåÊUyGM`éÌO5ýÚµ*:ôN "Q¸kݺï/‰Å×.ñÙN |øð�`Á¬ ¤r T�FàΞžžT¸paùY «õeË–Q•*U|56~üxêܹ3-\¸�¶nÝJ­[·¦¹sçú*§]ððð0iiCžýû÷˶Ο?OÛ¶m£åË—Sݺuµª|fL „ æ³7„‡ÈÝÙ1V¸ÛñÃå©1&à7_îâÇ °5ZPLŒ+·PèâG¸)iÞ¬¶ô½­¹„8zìL°*Ü?|øH°º|,,èá‹8Iâ„Ü‘"E45œ@]»{÷¡ëINII— æ| škJÃk×oSÜ8±E€¹l2¦¾,”WXˆ¸yë%O–XX§¥ Ôøáfßþ£ªé-Ý|)ÛÕM‘˜2i P²ï>íËË›6ï1«p¿%ÆvûÎ}zö쥰º‹LI“$’œÍ=w}?¡•þúõ+ý{ä4}üø‰R§�bÓ¤0û: è?þBX@z!|­çÏ—=Àî5Pÿø‰stÿþc±Û ?%Nœ€Þ½û †=zT•6•€û›‹¯Ê@¸H'JŸ2dH qÜ»÷�`UÿÇ¿‹ÇÉ„Ïàd¾Ü ˜êׂú?a®]ãëzëvÜk*vͰ/�ÀüèG äÙ3½c*ïh¸5[#0xð`zøð¡VË–-ÅçJ.•çDÀ ôêÕK*ÛãĉCÛ·o§œ9sšl$f̘4þ|‚eúÚµkÉÍÍ�  ‚h'5YÞÜEü�+VŒ6oÞ,­ßß½{Gîîî¬p7Œ¯3+0þ�o¥n¸Y&à/V¸û‹ˆ 0&`¯|[¸ÛëLy^a™ÀÏŸ¿Ôð¡¨EPGSŠè?ÿü“V,›*ð½‘åÓ§K%ÏeÊ5¤]»Ët½ºUhÉ"Ÿ`lªa‘@PÖn=FÈK… 妃ûVÊ4\ÔÀµ”ÌP^êÊJ¸³>´EŒAÞÊW°*�8q^_Œ–,]/\„ò¹]ÛFê>¾�5ƒ&O]`.-Šü�W*› $ÕËÂEÔ¤Ywy©KçæÔ¢yªçÚÉÀB<ÚµmHãÇö•¾1·yn+Åje+vŒу7ª¡oÞßô !“TŒ1wn¿ƒ˜Ám ¦.\ì!ë=|èÛ=ÄŠ•›h¼xZ SÕ�H$‹Û7�W›ê/‡xÚ˜ûÐÁ]äsذq}ýêø;1¦MLº Á.�ò›øoª´EåµX±bH<úW¯Þ¢æ-{ѱcg \ð¤N�B°hLmZ»ê‹ËtŠT…¥‚™¯Ÿ®Ò¶í¨uÛ~ôøñ3y?}º”äuå¦Lkô¯ÍÝ;—(@ú‹@Ä+Wm1xÍ þÿ*V(NcFõòRhMœ±û¡O¿±4ß}5½~ýÖà^ÏÝ»¶ –-ê‚öK`þ'ŒÛH &K—mPUt¹@ÓŠ)Uˆ&P…;׬šnñâL€Äl†ÀåË—iòäÉjÛ¡x7§lךƢ6= pÇ{ðêÕ«©K—.Úí�“$IBEŠ¡M›6Ñ•+WT— 3&À˜€ý`…»ý{ÑWa~0½/ÝÏ*|“ 0&`Œ-ÜmÙeƒ}çY†@·.ÿ(²¡<Ï•·2eÈ\Š:tD›6ï.2Þ›mÚ¥JiÒÜf@I +yc�b]³J‡Ò¼f�ò²Èü«”²=§ð¿Ï zúè$�<¶�ö祥A`×¥ËÖËü8¡Þ¸~®�Õ8ü˜ãŽŠJ¨zÝ{ŽTÊvXs®Šõ»·Óá« Öø,2+Y�^¼x¥êé«VÃù£T¾"ðåÅsÛ©Fuïñ£¬”¡l‡OjŒûÞíÉcõL‚U5_ÊaYn©Àÿ7®šdËšAKê å+vhRÕ¥Œ°j�A—÷¬Èµ 'ͧ·oßiECõ Ÿô§~}ÛÑù3[éÄÑõÔ¾]#µÓ; †Ÿ*ǘSÄОøð©qÏ™5B^_¶d²ºvóæ]jа³T¶ã=¹WÏÖtúÄ&ºuý ¹»�U®\fÍ^JýŒWõŒ=z�’Ï ¾¯ëÔ®$-â;ul&ûÓïhп6³fI/›0h‚R¶ÇŽS,rô¦SÇ7Ê Å°‚×b#@1?{î2ã®…U}¥l‡5û¢ãéÎÍC´o÷r¹è‚�µë¶Óè1³ êÇÿ„AƒdÜæ¯R¥ðZsmà¢òœ>–þèÇ‚èæ nÂ�…·Â.øFÀ-Ù"�¥K—J¿ßÚØòåË'yjy>ŽÀ¹sçdEA�%ŠÅ�tèÐ�úõëGµjÕ²¸Ž©‚ׯ_——L•… 0&À“[¸;æsçY3& èW¿ÄÒà � „$�)’ÒîK¨rÕ ¬Pa}‹cÚôER!›;wªR©µnUŸôV‘P Cy=sÖ9lMù¬Ÿ”ÖšT©\J(è£Éì¾ýÇ´ËÒ%Êßç‘ù¸qc‹íÙ™éÎÝJ��…€fMkÜÑ@®\¹%Ïø“$IE;®Á Ú}Áj$)�põe¸f!E\ZD‰IÅBÁDaI×5¦dîì‘2p¬v Ò5[µ¬ð�žŽ–/�¢òI’$$(Kµ ³×oÜQ÷üK»$qr šRlÛöýªK´µtñ$Å7úöi'üÚ_¢uëw á+½|¹bªNh%ðþ9yâ÷@%Jdé"ãºpÑ{+=^/ÚB‹¶x€ûÅ‹ gg'$•Àõ�Œvþ¼1Ôеšº—c1õèÖR-ž¨‚"—4µjV ·¹£ î‰ôâßkþö5Á‚G«–õµ,nˆÜŸ²æð^Ô9pð„º‡ÄA‘G`\ú=rh�Rœ:9%nòÊÏì¾€,®„z÷j#ÓÁù?!´àüËïÙû¯*Y©b Š?®Ês"øXò‹L+–MQ‹:Á×;·d‹`Iݽ{w54¼?Θ1ƒ¿�*"�KÀ»fYž*UªÀ5„ZÇŽ£¼Þg̘1-qU&À‚JÀ’ÏÞ öÁõ™€9lánŽ _gLÀî °…»Ý?b»™ ”Ï·® ©“üc ,®áëºwß1”|©«P¡‚íÔ†Fhüa¬)ölhˆ<& Àj½m›†òxþü¥ð�}LZ¦"0¤^a …lµ­éÀÞ”/Ÿ÷wXÃeË%á÷ E�µÛ¨y3oEâ aÝ ËZHüøq¨t©ÂªÏÕË‚yBŽ?G©Ó¾Ô3Üpä�B0.7#=¯ªjøßû÷ßS*¯O@q~ÿþ#é6 Y(bõ’>}J}V¥¡t׸$Mê£|× è±Æ‹oZSg½¿n(|áâEÛ`ª¼×Ò§OE8ôòèÑSº&|•{yÝ‹'ûh÷žÃúÛ6‘ÆëIo­® *a‚xZÒÀõŽºèGÂó’ÏkÂIìr0÷šˆ#ºjåü/•Ö'Z4¯«ÜÛè¯û—F°]ýÿÊ#X0þOðLÎ�¿L³ç,7ÛÌ•«7Õ=-h¬ºð_ÿ3pkd,Áõ?aÜ®¹<>Ý®V·á7¼l™"*ω�%ÐYVÆ{<‹c¸xñ"M›6MM6^¼x4dÈ•çDà è1âNÆÒ‹-êoQ|¯�kš²-¸ð€b¾Þ5ïøAY¸pnêÛ»-•*飨×ú4wÆÿ”ÉšÔ&-”4–H#_ò•�1‚¯k¿ÿ¸M~Œ”ãwî<¤¬Y½]ðøêDw®;4÷#x¯kM^¾|M yбâéyMY”‰Fš0a¡,N›ÆYú¶¯X¾¸\ðÀ3³wÑ£�'|¥Ã÷¿×1¦DïÉÔ}¿® 2™�¬ŠÄˆ�²dIG)�“Q~±kêÕk¶V÷µÆÿíÛw-KQ£FViÿ¡ñ?¡–Šñé]Où7^¾pæ¾cäÉ“•–,šfÞ>s®aL`Ñ¢EtèÐ!u¹P¡Bäêêªòœ�”)}v¾ÔˆïÂ… ÷0ØíT²dI“Ù³g�Tªߌ-šØYå¿€q=Î3&¼ð�Š… Ø›T¸7lØ�p°0&p—/_x%­aüaV~ú¸rÚW¯Ý"‘„@É[¿^?-P+W*©îx}¿zõV*ÕQß;peqZ¿a§T”ò½Lé¿…Eµ·(�³d1­8†«‰®Â5´‹:;v�Lݤâíwè4X.`œþ þ×R¥JF—/{[4¯^1�R _ÖaA 4+U²�ò5Ž��;5õó¹`^{÷UÓ+T0—J·hÕG)Û uάd¬Dv”÷¦4iR(.`¼x¡÷…º€D`w,!‚¦lþ/Z´`U¯VÖ@zøðI“#�uxÊ”N2`+ Àz e¦‹i¿þç½è”?_é»?$ÿ'^½z#Þ v©¡! rêÔ>üÕ NS wÅÞ¸nn ÜÛÀ¸¡%ðöí[êÑ£‡êïÓ§OWñJÔ Nš@¤H‘¤¥9\Ëœ>}:@í´jÕŠŽ=*­ÓÍ)ÜcÇŽ-\ð™^ìõ¯3Ô}ñâ…ôÿî_YÜõê•*†º,L€ 0&v„ s²°Ã“Gʘ@"`ì·ÙÔ�á04ªÈ—7›š,ªý³r~ûö½*¥-,ØõÒ¤q •]¶b#­2°n¯¦î!¿ÕC†N‘ÇÐaSÕÖwüŸdÎœŽºuý‡ÎŸÙªE°®?uÊÛß !3XpkrìøY-éë Ëz·ù+åW9¶ £Gö¤?þð¶Y€ùI“çû9¬; Ÿû> wø¾‡à=èÈÑ3ª®ÛÜQ¾”í¸ùêõUÆžú×ĉ“ç%SóÅB�öš@l�à¸�Ñ.VjÖ(o lǽW&\iuÒ¥õ±¬Ü´y�vÙà¼s×!*V².•(UŸjÖn+,)½_Kúù[ûbé² Âÿ›W³&µUšÖ!`ü;'¶nr'ìæ`qðëýôéS5áöíÛ‹Åî,*ωà! ¹sÙ±c‡paçeQ£xO1KŒŠdoÜðq¿—6mZƒ{œaLÀ4½Q�ñg¯é|• X‡+ܭÕ[eL Ðc¸ü�šƒ �)õ²õ];Ó•+>Aõ8žnsGûò“Ý»gjÙº�,~äÈi*YÚÇr^kÃÉ)‘òóEþ¶íûÉËs·v;L�K•,L׮ݖcÞºmáˆ+†z¾PBØYúQÇk}ÌØÙò0ž$*¶lt3¹+À¸l@ò.UJI«céÂ; ®]»F�:u;©²Éï'èŠo(äáWÿãÇ�"ØuTZ¼x±2tž‘ø´‚E€åË—Ó† ÈÃÃʔ)C“'OAÒ½]Íh%·nÝJ­[·Aê½wqÍ™3Çfvùicä3°UÆ¿ñmuœ<.û'ÀîöÿŒy†L€ ˜!`üaì(� ÍààË6L CûÆtéÂN©¤1÷:…U{Ëõ¤_uX¬›“ RSž�@ÑVâÄ hÙ’Iäììdд¦tÂEi<}bµo׈¢D‰lPrõX=“úô6­ˆ÷U!„/€ùÜÙ#epO0E�McÁµÖ­ù.*[¦ˆñmú§yš:y� jk|3K–t´w÷2:{j‹�k!ãra)?x`'ù:Ö³Ò¿&0—þýÚÓ�½+ vhsŒ!¼|½9äAI’$Ô.Û‹Gð«]¡¼oëF¼Þ»àš×êÓËük¯ëSÇ7 ·C®&_×p�³sû"yßxàÖþŸÀ"Ár¿AŒ%wnŸ÷í:ŸƒŸ€ðEˆ Яo»àoœ[´i¯_¿¦^½z©1ba�RY¬K UªTÂ%Û9±›Äû³Šî¼yóÊ]ùò壌3Š÷è(Ô¶m[©l�/-[¶ŒR¤HaÕ�Ay®Y«ïܹS!¤±âIËúܹsSôèÑ©B… b¡ýž\TîÙ³'•(QªcâÆ™@X$ЧOruu¥† R£F�Ô�ÿM<==©I“&Ô´iSu4kÖÌbWSZ;|f�!N(œ M<Ó ×aLÀfÀ' ¾@Æ�Wlg¤q͘1C~ ­Y£­\îã:H�ÚPå›7ïRêt>>gN&–64D ðEàÍ›wtãÆº-\¯Ào{‚qÉ)i"ñƒ-¥øÕWySòäw‘>Üq ßÙ3G˜*fpíãÇOµÆº{ï!!xi’Ä …EVJBà?ÿJ¾çÏ_Jå#”ø¦_Gà6ä‚ðY×+©…{ce½©z¶t \<=¯Ñé3Åæh”9SZ±¨�\¹�ñk¬`tá‚ݹû�â êtéœ ÜüÀ¢V±[ WÎÌä䔨¯æÂÄ=¼&¾ÿ!b*kCã�¿ÿAº?yôø%n‹ðš‹5Šq1«äïŠgáuå†dŽ€¦x–Pºk‚�çÎ_ÿ äŽý=­ ^×ø¬Áë:Z´(”F(㓊ÿWãE­¼þl�ÿ‰%K×QÃÆ>÷Ç÷— jú~9mØ5á윔­T­ƒ7ÔZÍ”¥ ]öº.-©ÍÚ„¥ò¬Y³Ô»uëFcÇŽUyNX—Üø 6LZ”Ãu ‚¼ëïÝ-Z´ XÄLjCK¥ÝÜܨyóæ2%~Ö¬A[¨Ä`Y?dÈzøð¡êGŸÈŸ?¿´~‡ž%à°�‚ß²¤Aƒ¼®aó„zøðá�ç¤I“¨cÇŽ�ªË•˜€>‰ïú‘Yán).ÂÂV¸[þ´ ´L“ÞÇŠJG(Y˜€=0~ÝŸ<¶�r . `öO ¸ˆ °ÿÀ19Qî|xï¨Ýìž°ÿ§Ç3´Eþ)ÜOŸ>-v•å!¸È‚$NœX?¿"-«mq>ö>¦ÏŸ?‹EÜ téÒ%±¨_¸K+-ÚMÉ XXEðÔ[·nÉïË©S§1qRQ̘1CbvÛ+ÜíöѪ‰]¿~]íQ-Hàÿ ÿwqâı 4a�" îª*WbL€ ØíÇ�6l÷faöH–ð‘"E —/߈ �ýÔóçÏÁÊvEƒLÀ¾ `‰¦lÇL«T.ÅÊvû~ä<»P&€ï™”ªÿ¾9aÂV¶‡âs‰1¢t+×2¶ Øí„E… ¶…!ñ˜@˜!€Å© Б#G4æJ•*±²=@ĸp` °÷À’ãzL€ „yƵ,Ùâæ'ÍpHƒ‡N¦±³‚;îÝçó¥tü˜¾Ƀ'Í‘Àü« ¦Ý¬)K5Â&ÌæÍ›G'NœP­Âw­Zü§€p‚ 0&D�7p �©àN¸XáÎ/&À–€ÞâÌ£tX@­Ú-S¦ U«VMå9Á˜`ÁKqØà*Æ?aëvÿñýà&À ÷à&Êí9(mk×®Mß¾}s¸¹‡õ ÿúÅ>ÜÃú3äñ3&À˜€ßæ/ðq'#F4ªêRÆï |— 0�@xþü¹�ë˜ðáÃÓÔ©SÕWbL€ 0Ë ø§LÇûqݺu-o�K2�` À ÷`€ÈM86�ÇÓÉ“'iãÆ�Ž " ÎÞ·…;¿%†ÁÇÈCfL€ 03Ž;K—/_Wwë×s¡«<'˜>=zô ×¯_«»wïN©S§VyN0&À˜€u (už<æãUU®\™bÅŠe�ιU&`†k—Ì€áËLÀR ,�Eµ³¥õ¸\è0š.»” ý§Â#`L€ 0�à"0Á*ƒ¦š6®i�ç `ÁCÀÓÓ“.\¨Kž<9õéÓGå9Á˜`Ö%à—•{“&M¬Û9·ÎLøÃÄ5¾Ä˜€…>}úD«W{oÕÞ±c=yò„$H`amÛ/öåË9È;PælemÀáçÏÞóÓªuï9’†�˜¦eù̘€ƒøôé3áý v¬D¼ðæ OÝþ§‰Eå«Woª‰Â²½a“®*܉Ÿ?Ñ«Wo(z´(ôWø¿‚»yn� Ø$�›7ïÊq!0ª~çääÉ“)bĈ69f`LÀ Ô©S‡:wîL_¿~5˜^„ ©téÒ×8ÃB‚+ÜC‚2÷a·<<<èýû÷r~H¶téRêÚÕz?fCäÕ«We—ïÞ} K—®…t÷!Þ߃�  `ŽIàÉ“çŽ9qžµCøòåkˆ|–?{öÂ!xò$™€žÀÍ›>‹[*T ¸/ëC¢ƒÊi.\˜ ´baL€ Ø*�˜1cÊ÷^Í R§««+ýþûïZ–ÏL İÂ=ÄPsGöHÀØ� òö¤pÏ�!ƒ|lÉ�ÓP™Jö· ý铇´~åõÒ,U¾9§N¯òœ`LÀ1Ì�:Š~ýúIUkU¢$I;Ƥy–vO`ÍŠõôøá9OüÐlÚª¡Uý·oÛ¼‹n‹útiœ©† [’Ùý Œ'( L›½ŒÞ¼}§hDˆ�¦L™¢òa9qþüyª]»¶œÂæÍ› Á%pÁ+Ô¤I“R¼xñ‚«Yndžð3¶¡‡á@CiÔ¨‘ò@ M›ÝÉh$øÒXáÒĹ?»!p÷î]Ú·oŸÁ|ðÅâôéÓ”3gNƒëa5óçŸÊ¡§Ï˜…ÚwV§avÜçÏ3P¸Wp©G%ËU5[žo0&`ŸæÏK¿¾ý¤Zõ«QþBæ.ÙçìyVöHàÖ�;4uü,5µŠ.e©ï�n*o�Ä­›w¤Â=s†Ô4´_ktÁm2›#0uÖƒ1õêÕ‹œ�� ®qÆ7�J•*Ñ�;wäâDûöí}à+až?ã0ÿÃäÊ–-+]üb‡$oÞ¼„€ª,L 4pÐÔРÎ}Ú�E‹øjÔ&elõ®]ç³íà ©¶÷LxDL€ 0&t+—x4R»A5ƒ}j²mÿ.¢ÞÎ�;ÉËË‹¾ÿî_qƒû�­–�aeé36˜g˜@dÊ”‰räÈAU«V¥èÑ£¡%®Ê‚F€îAãǵ”€9ëv »•ÑHØöÙø +$lûyñè˜`LÀ›À˯¨®KSZ¿f3}ùòÕËÊ%kUŸk5깨<'˜:�ÇOžÓ ‘Ó j×®�AÞÞ3… ’ ysæÌ¡×¯_SåÊ•)FŒ”'O*R¤Å�WúN¾~ýºB�ØWxOÂÿí�Ž;ªkÇŽ“×´?pý8|øpJ˜0¡ ®Zºti™NŸ>=uíÚÕ¤‚:mÚ´²½uëÖI…8Ê%Nœ˜° ²d‰�¿}líСƒôõŒÀ­åÊ•“cǸ‘>zô¨6 _gÄì£F�JY²d¡R¥JÉvÐ\ ™RœC)�y'J”H¶פiÒ¤‘õÊ”)C2d�í�7ΗËÒ ÔÕ–ZÝ€° è3Öúà3n°r×,݃»mn� XJ€ƒ¦ZJŠË1�ÿ|úôÉWäkc8°’€F‚ ŒoqÞ†üúŸ¡…;»”±¡‡ÃCaL€ 0³~þüIG—G´èéJ� T»AuŠ?ÁÂ]“¿‹¤D‰jY>3& ºôEï?|2hÉQ¿ó¿}û– 0†e{¼xñ({öìtöìYúøñ#�8q‚òåËG·oߦhÑ¢ðò/óòåKªY³&A� qrr¢äÉ“KKpXªã¸qã†üMö×_™l~œW­ZåëÞ½{÷¨Zµjtúôiy/bĈ”5kVÙ,Üñ;nÏž=ò\¼xqƒúX`À"Á—/_äuøíÇ‚ÀùóçéÑ£G4fÌ9æ5kÖÈ1Tþ/³téR‚_iøš†%. €.]ºDPlwïÞ]¶Ý¯_?SU)0uƒÂ2(¬LN€/Ú$¼ñÿðáƒOL ›h•"E úã�?hÿþý¨e»Eá 𬝰Ýgdjd¬p7E…¯1?xxxÐû÷ïý(á½Å_ˆ`UÁb»ØÂÝvŸ �Œ 0&ÀÌøõÓgÁøÝÛw´Øm¹<â%ˆKPÆkÂÁR5|fÁC`ßÁã´Âc›jì¯?ÿ¤ot¢*ÛAbÀ€ÒeÃÖ­[¥e8¦¥�»»»´ ‡«Í3fP¯^½¨hÑ¢JQ Kô»wïÒøñã©mÛ¶’„^qŽßPP¶'K–Œ/^L… V´–/_NmÚ´¡�7R«V­hþüùêž–@™Õ«WS’$I¨K—.”1cFéb÷[´h!•‹èoîܹT·n]úS|˜þùç‚e>”òp¡%JÙ,Z·nM°‡e;ú€e:×&NœH½{÷–‹Í›7—®bäMÝ(ô5jDõêÕ£éÓ§«…(ìÑ/.&L˜ Ç)R$]M¢ÀÖ Ë€² È36˜gB•^sݺu Õ1pçþÀšQ£Fù_�KØ V¸ÛÌ£à�„–º‹A9V¸ÛöS5öá.{Ù²í'Æ£cL€ 0øùËG©®'òL¸ºÐäÏ¿þ¤HQ"IëI¸2`aL hà*¤m—¡�$»Jî=xlpÍ‘2°ôÞ²e é-Á¡ nß¾=M›6�®]»&-ÝÁïCáÇ—x´÷$(ºµk7¸s�ËX§®_¿ž²e˦ݒg(Èaí …8ÜÄ@ëz½@ÙŽ1ÁÒàjÁXR¥Je|IæoÞ¼)ÏðíÑ”ÏøM‡à­~Iš4iämôõãÇéG_>(ÌZ7(,ËJ?WN3&À™+ÜùéóÜD¾ú´/–VD  M›6¶T²Ø ¡|ÐK8aU˜`LÀÖ è£Z:Ö1£ÓÂÕs(^ü¸–VárL€ »ö¡Õë½ý~HºÔ)¨K»FÌÆJ`%�Ëggg{�Ouc1¥PÇ¢ã§OÞ‹&šŸqãzæòÆ»bÍ•Ãu[2à ,Ë °ò‹ ßcL€ 8V¸;ÒÓæ¹‰€»»{ êí +Ü…Îê•~ýÏpK¾-}A¶úäÑÁ÷oßhÏŽõªfºŒÙ(¹³·�ºh"ñï��ôþÝy'qÒ”9[nºsë]¹tÎDió—‡�@ÅJWöUà«صuÃrºìy–Þ»-~L}>‹�…§3)Y‘ÒeÈê«_`ŽJàË—¯´Ñc y^ð¢ûwÐ'a±é”<©Bxr[>ƒR E! `–ø&¾û´ëf(uÚø~Ò݉å­pÉ€H—.;vŒàK}èPCö–¶ƒ ªÆ‚ïù)S¦$X}ß»wÏø¶AþÅ‹R9� ¨"™6mZy¯Äôòk!@³†G~ M ,Ë ° ÍùrßL€ 0["ºŸ¶D‚ÇÂü kD¹Œlß¾�ž×±ck•pÎz�ÙAËŠm´SÆô§{wnÈÙ”«R‡ÆN[êçÌ>¼Gm›T¦ß¿Ërƒ„ÿS(ÜîÙBc†tó³®ñÍX±ãúR¸/œ3�ÜfŒ¡W/Ÿ?uì ÌO;€J”u¡N½FPŠ”Þ?– r† 8�¹3ЬÉnôòÅ+ƒY?rJæÇ�˜Be*” ý;Û”bÖóÂej׬«cælCTá~é¢iJÓfHM¶â"îg|¸Ã'ðÔ¹ã(gîlÏ�3L€ øO`Üwºvã®*X»Z9*Á‹~Ї52d� ÷sçü6ÌX»v­T~#¸h‰%, ܽ@á®@5Ué‹0䀯ô§OŸRŸ>}høðáJáŽò{öì1«pÇî£ýû÷Ëf5%½Ì„ÒŸ ° ,«Pš*w˘°9¬p·¹G²Eð ˆ/\¦Áh–,Y¢nµjÕŠù^/p-cj»£¾ §Cž€±w¿‚'…üèl³Ç2kÒÜi#åà 4‡Õ;ñæäÀîÍJÙ+ŸRå‚ϽҬÉÃhÚ¸�æºV×÷l_OçÏ£›�S‚„óÙ©á㦎›EãGNõw;¶ì¡3§ÎÓÆ]+)abßÛôýmÀÎ Ô(ïJŸ?yü;xz»Ü ` S4þüòkLCÆô£Òå‹ûU„ï1&`‚À½û�høØÙêN”È‘hüˆ*ω 06~A‹M›6¥ùóçÓ–-[èäÉ“”;wn_]¼x‘j×®-}¤¯X±Â×}s°ëxýúõ„ßo›7o¦Š+ú*ŠÝÉP¶CÊ—//Ï©S§–ÁP÷íÛG¤ºuë’Vøï�››yyyÉ\Ë–¡P7(,ËJÏiSÏØ¸ ç™°Žâ}ËÓÓSý/æÊ•‹ü þl�‘8f«¬pwÌçγ ÇéÕ«—ÉZøÒ¦W¸»ººR�L–å‹6FÀ؇»ØjÊâ7�2k(…ûÇïéø¿{©P±²f+íÚºVÝËW¨$E�KåµñÕë6ײfÏ‘£DS÷Я^ÙW3-Úõ&¸¹y'Ü×?¼‡ŽŠcãšEk£ÏžPû¦.Ré®ù³T�q‚ Ø9�#�(ÛK•+Fm;·  ™ÓÑ»·ïé_qÿßGÉcÅFùÿòüé jÞ mܽ’øÿÅ6_šÕ½£k×¥5hRÛ¿b|Ÿ 0:õIŸ>QwõnK‰ÅWyNž@̘1éÎ�;tôèQjРÁu üªÃ•IÁ‚©råÊ´qãF*[¶,A‰ ÷2¸å-,ßÛ¶m+•í"в–Jýúõi„ töìYªS§-[¶Œ*Uª¤ü®?~œFŒ!›Ë—/åÏïãÂlüøñEÕãÇ�©P¡B².,È!X�4iõîÝ[æK•*¥”õòB(ý Ë °ÂtýzÆ¡„ƒ»eG k×®4kÖ,ƒywèÐ�îD¬—a…»õØrËL€ Ø8c‹ šêÿƒBÛ)y*åVf×¶ufîŸ?¢Ãû·«FËU1­ô !"õ1]•³$qxÿU,}¦ì4y®i;bljGå]êÊ#c–œ4¬o;YÖKøx¿zù¼P2æPu9Á�Àþ=‡Õ43fIO³MQÿ/qâÆ¦*Õ+È#s¶LÔ¿»·¿ÜKÂÇ»—çUÊ”Õ[™ à„M°Ä½F]êÖ·£MŒ—ÁÂ�m;ÒºÍ{Ô°3¦KEÛ¸ª<'‚F kÖ¬Ré ëtÍBÊw(¹!Ó¦M£G�Ñ©S§¨jÕª-Z4éæåæÍ›Êú|�ÃÈ“'Í›7ÏÒ!Y½\`Y…&åß3¶úĹ&ÀØp&”_¿…rÿÜ=`L Ô+,ðÅ’Åp+£Éþ]¥U�–ן¡lÿòå³¼·3ÅKWÑßRúôñCª~¦¬¹•òP]ü/ËùðºÀYçO5.Ây&`÷NþpÍš=³Ùÿ—:®ÕÅÿKxÅãÌI¿ýç>{úœì=L{w ÇŸ¨z–&>xD;·î•õo\»%­-­Ør_„µêégi×¶½¾|Ù¶M­ÞÍë·iÿžC´~õ&:´ïˆX˜¼¯Ý öóÏŸ†A¿�;(R¼�š4Øø2ç™°€ÀׯߨCo+g­øô ýC=¦6{8Ã/:”ݱcÇ6ù™”4iRú÷ß©G�”$I±{ñ9rD)Û]\\ÖèPnT²eË&æMš4!(Ö_¿~M¤ëׯ˱à:\λE?ÿüó�\(^¼¸t)sûöm9.(ÛQ.H>LNNN–ÕÊ…ePXù÷Œ­6an˜ 0E`ܸq´sçN¹“H]äDˆ` ÷CÍ1&`kþGÿ3’ÞŠÅàg èÝʼ|ñŒÎ�:B9ò2(ƒŒÞ�L¡¢e)j´è¾Êö¯_?UÕý»7Q¿ŸÓL®àÿùçŸ4núrzûÆ;H¤sêôª'˜€£Ð+gwïØGCö3ûÿ2mÞ8zóú­D“*MJ_ˆ°3hÞÌ…4{Ê|zñü¥Áý1£SÃæõ¨C·VfSßEå1C'Ѫ¥ëÄÿ¥w?Z# „«†–íšR½Æµ„kó±!´òÚÙSXã×si*Ü㼓—ª×©Bc¦ 5˜#”á=; ³Â?=ÜLi’"e2jÒÒ•6««]’JóƵZ©¼–ø;§·û,ÌóÜ�#ÚeZ½lÍžæN7®ÞT×´D¨´kïöT°ˆ·Õ¦v=¨ç_ÿ3¯pÇ®„îÌ>ƒ öÍõ™€½3É�nܺ§¦Y¿VE*RÈ·qUÀNeÊ”Q>�§¥²å³¹X‰%’¾ÔýjAªG�-�—/_JÄÑ£G§”)SRÔ¨QMV½zõªÉëÆa1Kwȃ¤²crvv&|wôKàF�Sa¸‹xø{G�UXÊ›øK6ÞYkªì7ÉX‚RWk+0,µº�eeÉ3Öúà3`Ö!AžÁÅÕ‹/ Ü [§7nÕ˜+Ü�‰pž 0‡!ð?ñEY/áˆ-Üõ<Ì¥áV&iò”tÿŽ·ri·Jj¬pÿöõ+!`ª&å*›v'£ÝèVížçOÉjÏŸ>¦Ö +P§^#Lº‹�w&àȲfÏDÎzJÏž<§Æµ[QÏþ�Mº‹)UÎ|pM(ØÛ5ëJÇþ=i'õSÆÎ”ë3L¢¤N‰ ÊÁ ¾UãN"ˆñEƒëZæÉ£§4¸ÏH:~ô͘?Á¤Õ£VV;{]ºJ ª5SÊöúBY?lÜå�å¶lØAÝÛ÷£O?iÕÔùöÍ»4 Ç0ºæu��ê`%õÄÑÓiò˜ª=ãv €÷ìE“Å.Ÿ"Æ·�7þüÒJš, ¹¯˜I‘£DÖ.9ìùË—¯´|õ:sþ2ݾû@¸{øDÎ)’RJqT,[”²ŠÖ�-ÛÐG¤ R²h~aAÃݺͧÏ^Ð�ÃÞÿÃ1¢G£Ò% º-}ÅÇâ½åÐïÏåXbQªd±°Ïèö�4rü5µhQ#Ó¸áÝUž¡C–ðEŠß{¨~° ÇP�¡Nš4iäк¡Y>(,Ë*4çË}3&`žÀóçÏéÊ•+„E9¸ÖB<�ÐäÀÍv ÁMÞkà²+¬ +ÜÃúäñ3&h¾,MØ¥ŒÅ,ËV¬¥‚§îݱžz gP÷èáÝ„ ª�ÂG{ÑR• îë3?~|§­ë—ë/ùJÇO˜„ræ-¬®7nÙ•Ö­r§¯_¾ÈkGî"ΩÒQ¾Â%)¿8rç+BQ¢úZU•9ÁŒ@‹vMh•°Âþ*�¸;Á‘*�³°¼ÎO……R0o�ÜbJ?É í7F)Û#FŠH�{µ¥‚磿„5àÑÃ'D`ÖiÒjÝS(8{wHK< }Øöí6D)ÛaÍ¥ž9éþ݇ÒÅËb·åôíÛwÚ¾iÍœ|¨ê GéÒ¥eþÕ«WÔªU+éVëË¿ÑqcÈ�!Ô®];UGŸÀ.¡Aƒɘú¨(“:uj¨13&Ož&½²Â]ÿ´9͘€C0öáÎ.e,üz·2îÝJ¥ó”.CVÕ€Þ�L‘’Åj¹ykK(Í{´o êšJ@a¯W¸'qJAó–ï¢vMª(w1¨wëÆy,s÷v1Køâe*Sm×Ö¬|7–¯9X=/[çFÍêµUÊiL~Óq,œ»Tº_�%|©òÅ©A“:¾”ïð¿a�÷®•¿þúS´7Ÿ²çÊ¢ø¥óÎKÕËÖ¾vß‹€ÉGi›Pœ—«TJ–9.,_áë)r$Z»})%JœPæ'IDù æ{ŒÂIw5¸¸Ñc«Ÿ ÷ëWnHeûëWodíº¶¤n}:È´þÏðc¥ÂׯNFp7£ ,ðóäÏI¥ V‘‹‹„¿U‡¦;N,*Q¦¨,öÛï¿kÅ©€˜ŸSò¤*æäy¥Œ‡k,lh’0qY øñùógºtñ eAkƒCŒ?¿"DŒ@ó—Ï$ŒÃÑeؘ™ÔØT áþËiŽäpF@ÌcâžØ¿Š’ˆçÅâÞ½û pš^\ܼm?m‡&Y2¦¡ö­êkY>3&À˜ófÍšE3gÎô5|·Dü Ä×puu•e"Göþ �ï²ýúõ£�?Ôƒò^“-[¶ÐêÕ«µ¬:ë•ïê¢HlÞ¼Y°þñã‡þ²J#®Æ ÷ZaMXáÖž�— 0�`#`láÎAS-GkìVf�p+£)Üñ¡¹oçFÕXÙʵT:8Ùs GþÏÞY€7±5ax~Üݵw÷ân…Bq»¸sqçâîîîî^ÜÝݵHqç÷?ß »Ý¤išúÌó,Ù=¾oÚÐÌ™ýæ.mY·„Ö¯Z@ׯœ7\55lV‡¦M˜#‹V-Y«:Ü—Î_©4£–íþR�íj¡8i×¥%=yüTÕ¹ýüé³®4 6 ê Göë?ÑËÝûý­ëœüè©LÊŠ9ÒgLkälWæ…½^ãš´`ÖR)9³xî êØ½�RmñNuÅ M³lá*ªÛ¨¦*…ƒ9ÏÞôNð¬´uÄëoMÒTlO›7N÷=qÄ\ÁiŒ}O9Û«Š ¤>ÝZRŽlèÝû�´÷À ò›A‹—o¢ŸâgÞó…U­ÓN:ÝÃj6W‚Ó=óZ}G zýŽ”1½3 íÿ7ÅŒé­ ¢Ž=†©ƒa“‰RùçBEÂ'L€ 0‡€óÖÃÃC&H~þü9Á1‹„Ã�É•+,XÐì|÷îÝ£k×®™­Gò*¤OŸžâÅ‹g¶Ý¹sçèÙ3ÃSiñãǧüùó›m‹Š�?ÒÁƒ†\»¸¸P¬XAK:ë²dZ’=çÌ™S÷ÖlØ%8w£Fõ O½@·ý¾�·R å.â 6&À˜p<�={öP×®]ÅS‘†„÷Ê §N�RN)oÞ¼²M�>¿»íÛ·�†ª¶µt‡{áÂ…iРA>œãHžŒHkœçÖîpÎkåQ6nÜH9rèÿ]kiM�]­ö±cÇJ %èÑêÆ “\ˆ3wî\�^±¢áï~D¸ãhÒ¤ -\¸ÐÇ-`Ãb×®]² ¯á 7g�‰Áæ Ò1ÇŽ3ÚÁß¹[¶l¡ºuëJ罓““lÜþa‡{p{Çx½L€ 8Œ€�]WÖp÷[­¬Ì­—…ó=JžÒ™<„ó]±’e«RD‘Ý’…�ê6nk©‰MuqâÆ§òUjÉn\½@Ë„´Ìýû)þˆ˜<º?Í[¹G^ó?L 4€lJåjååW/_—Ò2«—~ñG÷Øá“¤t êïÞöv¸§H•Eº–BÈ×(öäñ3‚Î9ôÞïß{¨ûIöD»1€‘µw—�BNeº:¾rrKÈÎ(¶Ï!ÂaÍÞ¿3þâg©=¾ `Þ ;ˆ$Ά(+ldl^¿]è‹MD½·lÿÅŠí¸¨_¿É¥!ã³(I;q•7WVÕÙnʧycwêÚg´ªÕ}üÔ‹÷Gâgù¼x*$\Øp”Ú99¥qNáë»÷î?¦³®R’Ä (“x$¶H,j‹=Oj`S …Ø4B¤¾­×Ï_¼¢ —nЇ�ŸD¢Øòþ”/Õ¶ÌëŸm¾~ýFçÅ=y½~Kóç øâóÈ7†þ'Ï\¢ÇO<©d±”Tä„°ÅÀòíŸßñ" tãÖ½iÎÂ5Ô»k ©ù¯ŒKD¾ÃÏÆ˜`Ž%€¿/G�­FN[ýôéÓT§N‚vxµjúÁ–ú+u^^^´iÓ&‚3Ö¬Y”-›·$¢Ò&´½‚i‹-Œn;|øðROÑçÐw‡ >œ‡»Qc?^$NœX²1={ö¤%JP¦L™(C† 2y+¤mV­Z%Ÿ(èܹ³Ú>8�°Ã=8½[¼V&ÀJà?úÏh¼0ÿ ctÍ– ø”•Ù@�Zt&��Þ÷ Uk[ÄŽÚÓÇÒµËgeÏXqâQU÷Fº£`}CÆÎ¥_Bâf³���!þ‡ø#QõlL 48!ƒ^¾xUÞjœ8±ueUP™9kF=y¨x´ó—�h2HB?|Jj”GŒÁ•�ÍJM­i|ˆ’ùW$CU,j4ó9”6–^áp„fû”±3 0Іǚ«×v5ê¦M,OD7#Q«5K˜ÈwÉ!+³uß:°÷°ØlÜ/ŸÐFóCc~úÄ9BÚf/­Û±T$kµÍÉjm�¿ÿGµê»Q—^úI¨¬õ©õÚ÷|‹x?ÌI‚àKåÊãèÍÛ÷$FL N�>ƒ&Òü%ëÕvJ›dâg©ûßM©UÓÚâ‘kãߥ�òºnÓnêÒ{=ÎaÅ"Š<�Û5¦½Û‰Äâ>ÿ?Âï"®'M_b”ø5šx¢£˜Kš5i�Y'ó!oÔ´m?:|Üðÿ¤2grñ³:fh7Šcaã'U–ÒÆ _5y”qj5êLk6"ئŽíGíZÖSª¬¾Þ¼uŸš·ï/µó!é£Xº4)éï6�¨m‹ºJ‘úª]Ó�×iÇîÃÔ¦ó zöü•l³fñr¯VNmoéO2˜Ú‘ç¨r­6âÑwïš!ý:žˆ`cL€ 0ÇèÒ¥‹Œ\VF-T¨�Ô G4{òäÉéñãÇRffÊ”)jt÷îÝ)I’$”/_>¥›Ñ+¤OúôécT† DÏ_¸p�öîÝ+ë<==©G�´cLJ%±÷1i0(H—.�g»vÙx`òäÉôåËÉk;úiM¼×p¨c#†' pÀðÝÁID´ã©D¸#?¸;܃ë;ÇëfLÀÏ´�äc° ùåç ÀŒde„Ž{¶œùéõ«r1bÆIË8|5îݤ1CºËq#GŽB•Ýê[Œø+^¶Šêp‡ãý»7?¡÷®ºÃÈ2� DàÞ�û4¬ÿ¹"DšW«YÙâïK™ò%T‡»ü}É �&�3]8{YŽóHDê"᨞=zøD-N–< !™',eªä"JÞ +óL8ãÄ�­¶Óž`ƒ@ùl†ôŒ©32\¸p4eîX© ÿåÓš3}¡ì>°÷r)VP®UÏY“@Ô¥xA¡K?J©røkñREì½�ä9yô mIf·o28&!¯ Æ4@IDAT3{êêÞ¯“CæÎ$¤lŠ–(ä�±BÒ yse¡Óç®È[‚C¶b�V4b`Ýèu×J%ÍÞú“§Ï©Fƒ¿éÔŸŸyÓ†Ož½ ¿{Ž Câ}^-¾æ¾ˆ.XºAFPÿ_Vµö]l@�œ0—~§þ¸á=µUôVüÎÕkÖ�´ò8JƒO≎m»Q¾âµhÓÊi”Gܯ։ߟ Õ[Ñnj�Å=ÕiÒ�j¹•7­ �ë5vÊ�܃©Ýºó�ÚuBW®Ý¦Écú˜}z`çž#ò}Ñ:ëMDzt}A$.Ö3­³=¥øÜjÓ¼Ž^3.cL€ 0?@„9dB«]»¶Œ Ö>¹ï–-[R©R¥¤CöÓ§O„ p8�‘”Sϰ‰Þ¸qc½*Y¶bÅ êÝ»·<¿qãAŽã‡VË“'�Å[�!‚| àĉ2Iê�;wNzGÛ¢E‹¤D tâU¯¾@³ÇÒ¥K©Q£F4iÒ$r@Jû üÊáœAùÝáµ1&à¿´ß°ÄLæ¾0ûï"‚÷è�•QìÂÙã´b‘·¬C©òn^ü‡íh˦Ñ`ÿúõ A3Þ’}ú`ˆ`D›‰’°³Ý,® qræÉ®Þä]N9­^ë�|øðI-N(¤/àl‡¥I—Z-ß´n«znz²i­÷—!8éK�6•r*ž‚Ù¯žkOí;Ju\ÿ¢z"!jÛ&�)|xŸq!³¤W±vîÕŽ’ ™ tçût¤Žœ5s^1«”—Wv¸—wŠ×ɘ€Ã (Q”êÀâñ%6ßPdeÐ HíØ¼J ‚«ãåd0xšt™….ra!œ@º iŒ¢ÉÿnÕƒ´ÉLµ·ÿRh>O;C-ÊW ·z^»Auõ|ãš­töôõZ9�fúÒù+•KªÝÐ]=¯ænp¢`é‚Uôì©·¼†ÒhÆäyÊ)•,[Ìì—0¥¦û�r)ù×xGNáÞ3gÍ ëï ™�5ôéÕâäó§ÏÔ´^;êÙéy|z×Z ÖûOå�&užâ&Œš&�q"Y*>M-uZgµ(A¢ê9Ÿø�TNÉÈcó|ŠÇøËáuñ„Á”YËȵN;Š›² *]W:Êõœïˆߺó \ $\Žy,§u\)…ˆ|.æ’W$Æíe$£²b�÷&“é]AwýøÞT¡lQJ)ž iÚ¨íÚ0‡0.ì·ø™AT·bçE.€K×ËËŒbÃêôÁ5„HüäbœBrÒÒ¹£©U“Z²Îë S)]iÆÜ•„û„E�…öo[(×™9cZÊ$~Ú·ªO‡v.‘oµS�të;FFócºùÓ‡Ñð��)göLä”2)5®_M2R6J¦ÍYAo„“žÝOÉÔ®^�nžÛNËç�¥©ãúSþ?‰�õÚ›–]¼rÓ´H÷ú€Ø˜ÌQ¨ºx"e }ŸlL€ 0&à7tåÊu�V­Z©çæN Ûž5kV逅¶·¶¿¹>æÊ!Q¢ØÓ§O•ÓPùzäÈzýúµÙ{‡¦:68`�òI˜0¡Ù¶��Ô3½¿‰µíðó¡ñãÇS‚ ¤Fÿ€hݺurn$TÅÓHî C’Uô næý-"¸­œ×˘ð#ÓÿXRÆ> å*ÕôÑñü…Kú(wD"!ÆL[®>‘ðÚë%U+••:·ªE‹çL �[VÓÊÅ3hhßöTÁ%-={òPN)RdjØüoG,�Ç`Á†~_¦Ì«þ¾x‰D�e W¥6"‚|îôE´uãNZ"œäý»¡by*� Ó´u#õ>ó ç{Õ?NóB£¾[3)‘‚d«p´/ž»œÜ+6z›‡5$\*Tñ–”ªXµå+hpàc 5E[è®?4׮ܠ>]ÑñÃ'å|Dô°vnu:'%ËU¿¢z@¯ô꥗l‰§–úë¥öêÕy�4žiþèÁcZ³|5­ÛV®�2dJGX·Ö$Œ¯^Ž6™¶ ‰˜[ ‰— ºäW¹ž=užZ5êH[6ì O!Ý�ûZ»b£L<« PÄdl¥œ_KŽé{—öÈèî\Ù3ÒÿL†G„ôñS©×€ñä$4Ë·ýq®+Íà¸V¬[Ç&ÒÙ­\+¯}D�êUJ“[åR2�ª9§,tÚ£ˆ¨r­!Yjvñ¤†b÷52L“g.•NxÔ éßч¤ʇýÓ‰Âü ˜6g¹ê†¼�bMÄY6ÍJy®™¨ÞŸ(y¥Ì¿_<|J·í•ÓdÍ”–Õ«êcJg!9ÕR³‘§»ž!²}ÁŒaõφ…^seØ\¹ÿÀ[òÊ\;¥ü_‘ÿeìä”!w%‚?`L€ ØOàÒ%ï'Ó¦MK °:X´hѤÓuûöí„£téÒVû˜kmxÅâĉ£œ†ÊW8Ûõÿâ…ñv€q÷î]ªY³¦ÈéôS²)[¶¬F±bÅRËà¼×Ú«W¯¤NþСÞoÚzå1gΜ‘R?ˆ`7 „„LP… (wnïà{ŸpPæ Œ×p�1)Ïɘ L?ØYRƾw¥|•š4wÚH£Îe+¹[�N5êàË‹.¥¨Ç€q4Jhóbãïåžíëä¡7¤&ÎY'5æõ까 „d…‹ þC{Òà¾#Õß—›w‹'Rô�Hø}™µxå4I˜øÏ°žôÂóAgý›Ðˆ>`¬.¶¬92Óȉƒ}Ô�š4„Z4ì@wnÞ¥§BǽKÛÞ>Ú  ŸXk–luëô ÿÞ‹ GóáÃG‘£á=õë6X¬²lZ p^™Xt¢�~ÁçÄLE�ÃÔ’‰èã+gøÈåáR¼�x‚æ�l¾Ï!ÂK8L±™�JhÄÕWnV Áîíûä!›üSÅ­‚ÔÏ7)æK"#F4Ý�„ž¯¼ÞÐþC'iï�´cÏa‚–¹boß} êõ;ÒÁ‹©@¾ì²ø†Hì©XÁ|9”S£×¸qcѺe†Ÿ1£ “‹lYô5Ok’ój½^¾zKAGEBO=K&dT�„õ½p"?xôŒ²G¶v݈7gåK»Ð’•›ÍU;¼\ÁŸ"yb³÷;V uî‹f´Öá”�ü'/„ÚØÆ“‹bcÏç3(Ö;ÿþƒ´k³Þƒ[0&À˜€)DM+†hõ€4$IÕ:—áð-vðàA©ö¬q"õ={ö8T®\™Ò¤I#uòoÞ¼)uòüø!ñ$Mš”Æ�ç•v³dÚ´i„'ð6Uöïß/ußµ�ÆŒ#“áÂɮح[†¿w0ô÷GŒ!“âBÃQó›,Š“!Ánp3v¸·wŒ×˘€ õâwûÐ*²2�ÜU(_ÅðÈ»Zà' šv¤BEËÒìÉÃEbÂ>vÆ1%¢Ú]ÝQý¦(uZÛxþ°\’ *�&­P‘dsêøY"‰ðvýßáȪQÛ•þjÙ€Ò¦÷ÖlWWè,¯Ø´€æÍX,�ÖˆT×Ñ�š×£ŽÝZëê‹ÃA½uïj&õëWmr._´Ý 0ÿˆˆtÓ(s£F:ˆBï%6ß%Û%¢i7¯ßN®Õ+ÊëŽÝۈϊüÔ·ë`ºyÝû *# ½ïº�Ü©m§¤�f—Å?]„N<ôá±9ÇLûEæu(~‚x4mÂlº|Áðø­lôçç4NT·qMj&žàM]-™€;�/~nk 4t¼!/3‰Aº‰Kû ™D[æËúÛB~H±´šÄ»J™o^éÓ>ÚŸ!¥›Ç×o$aP†¤­¶Ø[±É„/§Úu§L‘Äl×T)“™­ó�Š«-t$|ÅaͰ¢gÓ;ëÛTvñ²mr2ÚÁòäÌLë–N’rBÚr>gL€ 0ß@âMÅ’'O®œ:äÿ^¿~Ýh,üŸúæ�Øp`$ÞT Ñí®®®Êeˆ�0a‚d w£�mABY=‹7.-[¶Œôž@äyΜ9 Zø_¾|¡åË—ë ¡–½|ù’&OžLmÛ¶¥ôé OøÁA¯8ÝÑÉlq˜³±cÇÊ sõAµœîAõ�áu1&àï|JÊ„ñ÷9Cê;v©m½¿F-:¿šsš 4ròbê3d²�ˆ¸COß'è¶ÇK�ˆ'MAÎi2R´èÞQs~��û3�àLIL'Î%£²Š$†�=¥WB·=¾pX'IšXäGp¦è"2Ø’ÁQؼmcy@ºr0¿~þ¢LY2yZ3HÕ Ý�‹Èð‡÷ÑuÑ=z4J•&¥\ƒž#zî^ûtfkçª×¸á0gyòç¢]G6Ò§�ŸéƵ›ôB$�L&4¹¡±-zTsÝD4{,É Ü^‹HéŸÿþ¤Ø"ºYkå+—&àùTHò¼xþ’b‹~I„î¶6q¬¶Ÿ;žÀA¡»}ö¼áç$^ÜØºÒ%˜5‡xzbÞ´¡òqéÅ+ ‘Þˆ€Ç†J¸pa ’IŠE·ð³¡´qÔ+þ&Ñj¡æë æ6 �Í™oàÏÒ!ËdÎ~ÿ÷Û\•¿”kï)aü¸”,©õω$B:FÏ’‹Ï){íÂ%ó_äõÆlÒÀ�fL@#FЫæ2&À˜ð//ƒÜº8: '| lÍðeïÞ½U]pkíCB}óæÍéÞ½{tùòeõv Í=ztÚ¼y³Ñßh€¿Ã›4i"Újͪ�ÅIŒ1¤žz¥J•èĉÚ*‚L¹råd� ƇA‚mÓ¥ó~ê¯uëÖtíÚ5逇£Ýœ®~™2ed„~Á‚Æ’�F“á v¸á7‡—Ƙ€ÿ0•”Ñsôøï xtGˆ3eÉžGŽ“Ça!•@̘1„¼RyøåÙ]¬¤‹]CàóÖÉ9¥<ìÀÎNp®Ãùn�!Âß’%²48؇ÀM‘P³kßÑrò¨B7½~íÊ¥Í\+–$ÅáŽä¥oÞ¾'H½¤zâHÎ {ôØ“à¼×38ø•¿# =I<-áƒ# �ø�P"Â×,ž@©�SØ<¤³Srµ/´ÊÙ¯g÷î{ëØêÕ+e¿?¨”#Y«o,�xÊC±2% Ñ’9£”K_¿Úº¡70$el±ÂY0itojݬŽ-͹ `L€ Ø@ÀID4_¸pA¶ôôô´¡‡c›$NœXFY#Qgh2HÆàÐ3¼HFzÿþ}!×™2fÌ(8Ô­"ß�?NOž<¡C‡‰|2Ÿr0ˆ|Gt¼5sss#0@ò�þÁZ0¤nR¤°ýï ksF=;܃:Ïɘ@� `áÎ�û‰·…Á˜`LÀ× ä5h°£ãç/_éÀáSTÊB¢Ú÷ï?ªs §¢«žA<é¡8Ü·ìØOH4jj»÷¥rn-dqÜ81éÅÝ#¦MìºNŸÖIušŸÉ}Í9Ü—­ÚBß¾—s4ª[UF”¥ÎyÅY¿nÓÊg’ƒAYЊµÛ•S¯Ø\€&<ìùËW>êQpW<™âKŸ6•ÚüÔÙKr“Bïï­kBzæø)ƒ3&KÆ´”_ó~ªØy‚({­–¼¹a’ˆ —µK&QÁüúÚýæúq9`L€ X&½pÅá'­­æáá!rô|�Í¡ýž!C]U]§ŽÏMÒØ±cËjDV§J•JWîP;˜¢]®-3=·¥�iŸ z�M~±dÉ’Q½zõü2„ŒªÏ“'áiÆ÷�öŽòý0&`3�ÿD=­q„»–Ÿ3&À˜>2gLCñ…ÃøÕë·rÑõ›õ ;è¦ö\H) =C-.R(·zŽÈø�"lÆÜ•Ô´auJ.ä�´6jÂ\õ²R¹b#éÕ†6œ4¬ëJë·xÈ–CGϤª•JR´hÆ’G3æ® ¶]†È6…„c¸™ÈAÃ:7‰Ä½°Y V‰ò”N8ðµ¶c÷!Ú)Çš3'ñ„Æ™?²<ûž¤jB*Ikû�Ñ­;µEVÏñ¾@ç¼ÐÎGßK׫kV:úô™ªÔjK÷Dd>l÷Fo¾J¿¼Þ¸uOlPr0˜Ç¥@.Z³d%[lL€ 0&àXˆVVìôéÓôíÛ7ñdX$¥H÷õ_‘c¥}ûö²-̘1C×á1bD2Äðÿ¢î@ µåŸ?¶ÐÒPeÚÆ–hn«ƒrƒK \ˆ½3¾1&À˜€¦îìp·Œ«™`L€ QaÆ¥ ÆR¹j-è—ØP!’úfÉçJnUJS¡ü9)i’ôúÍ;é¼h¹HÚ+¢àaQD^�Nm©wå^­-”‡;#Ç(R®! é×�\ æ¦?I'ü>¡ù‹(´Òµ}ÕAì<�ƒ»D‘|´_Dç#Ê>‰:4XÌ�;GfzôäíÙwœÆMY ŽÞµCõÜU8çóæÊB§Ï]¡÷>Qá2õD‚âNT´púüù+íô8LƒGÎ }¡Ã0……Óyí¦ÝòbÖüÕô¯ÈY-ó¨Q#‹'NSï�ãÕùl=A4û„‘½¨xÅÆ²KËè¶p¼ã^Ä�C‡Žž¡…Ë6¨Îöl™ÓQéŽÕjµ–0µC«ú4nxù¤€­÷Åí˜`LÀv..Þ„oß¾¥ 6Pݺu-€¤œpÌ+ær0JOÌ�Ä®Ö6´ZèQ¢D!Dx³1sØánŽ —3&â ˜&ûŸøRÈÆ˜`L€ O��?¢'uî5’ ËÇ;ÈŠÙô®Â‡ Gë—Mö!_2wê`ªV·]»y—ŠD¸�Zõ6í*¯Ç�èE9³û”œÑmlcá¬IÕ¹1¿{ÃNº=‡ýó7Uw-cT7ú0ªZ§�t^{‰Í…V4ªÿŸ¸êñw3=ižQ¹rѺYm?u!=~úœ~ˆÈ™óWÉC©Ï‘5¥Ɇ•Hz¥ÜÚk1—¼4¸o4bš|OFMœG8L-Uʤ´míLùx¹i�_®/\Ö×o�,t÷Á»¡�åacL€ 0ÿ#�9sfª^½:­_¿^N‚hu$ïŒ_ÿ©"Æ�9R]PêÔ©É\Oµ‘'Z‰šïBªmïÞ½2Á§ÞPXÓŽ;Ô*HÕpÀžŠƒOt°wI 1&:øˆp'|ecL€ 0&À‚+�ŽmÒÕÓ[¨Aí*ÖÌF:¢Ú[7­M�o r¥½£î”{N+}ž9´†Úµ¨KÑ£EQŠÕ×,B&eϦ¹ÔVÔ;Ú0÷ÙÃk©cëºsÃé�M‚>ÝZù˜:K¦´töÐZªåV^FîkD‹…fOLZ××�#ñëþm ©T±FåaD’c”íÝ2ßlY£:ý{¶¡ƒ;SV±FÓ¿¶àøÆýóXNÉ’&Òéí·¢‹:w§Ièèžeìl÷Zî͘°™@�=T™G�‘»»;áÕÔàøîß¿?�;wN­êÓ§�zîÈl$I’Dk„ä�©!I:ê´k*SÆxÓÛ´_3ŽpçŸ&ÀB-S w½$^¡ß8`L€ 0�`JºíK挢)cúÒ�{�èþÃ'ôü…—ÐçŽG)„{Æô©)FŒhï.²pÊOן¦ŒíGwÅ—®Þ¢Ñ£R:ᇦ»¹¨¶ûW<,Ž‹ÊÕ‹'XlÇ÷¤Ñ}hâ¨Þtïþc976 Ò¦NIΩ’[ì+V Zµh¨|˜`þN ~ýúy˜Ž;ÒË—/éË—/tèÐ!yèMîææFÿüó�^•ÃÊ *Dݺu£ñãÇË�lܼySz“`c`„ NÈÒ±1KXRÆ®cL Dðáp7óèyˆ†À7ǘ`L€ 0�J@‘“�4к¥“hÄ .ÄÎöúfóm1&,(P@j¡Ã™ž8qbÝ5Ã)¿dÉéØFrRÿ¶öíÛÓ®]»¨D‰f§Š=:õîÝ[Fà§J•Êl;®` Þ’QHð+`¡Žv¯µfîñpm>gL€ 0&À˜�05}Z'Ú°|Š”Õ «æU2&ÀB6�¸qãJg:îòÕ«WR²ÅÓÓ“Ò¤ICHd+–AÆÌ…æÍ›Gdd,X@ïß¿§ÈçÉ“''''')y>|xGNÉc…pìpáo0ß`æ ˜F¸sÄ“yV\Ø`L€ 0�àFšý§ö¯¶ªÙÜî‹×˘)âÇ�ïoíö0Š3&eÏž]öôç>L@!Àw…¿2&êü÷ŸI„;±†{¨û!àfL€ 0&ÀB,�zµ*Ƚ!ÁŸµˆÌYO˜€$àåå%_Ÿ?N.\`*(¬,4á*&Àì Àw; q& %’eH�ÄvüÈ>ªT4½ö¶CÄùûwÞI´pCµ+ç#$ccL tøùï¿9JdêÚ®EŒ!tÝ<ß-p�×^¯4Â�/ N½-ZŸEóJ™@("0kÖ,ÂÁƘhìphâ<_ˆ#�9sfé¤ýõëEŽ™ ýR Ñ:°woßÈ#¤Ü—¹ûxòè¾¹*.gL „øúå+á`cL€ 0&`+�OŸ Á)¶¶çvL€ 0&Àì!ðíÛ7zöì™=]¹� �1bP´hÑLJÉwÇ3åC$öغu«Ì´íîîNÐ )†ÍXúŒYɽ~Ë�r[ê}Ù¿“îݦ^wë7š"FЬ^ó `¡ƒÀˆ:Ñïß¿¨ië†ääœ2tÜ4ß%p0�ÕK×Ó•K×<*Ç‚6�xñbÓÓg/(jÔ¨.µÚï¯.4øúõ+ýøñƒ"FŒH‘"E M·îë{UXùº#wß¿—ólß¾�’&M s†ôIðÿõüùó©aÆþz«üW�¿âåÁC �òåËŽ�fмŠsšôT·qÛ�v{ôþík#‡{­­(JTÿßé q ù†˜@0'0zpWúýã•©P’ ºä æwÃËg�Càä±3ìpô}úDË–-#òòò2ª]¸p!¥L™Ò¨Œ/|O`çÎ�´uëVºzõªQç P³fÍŒÊø‚ h ?ìAׯœ—™¨áTÿ‘•úÚå3Úf´zél ÖP÷¿ÿ^Ѿ’[}NPbDŠ/˜`L€ 0&À˜`L€ 0&Àô°Ã]�ŠeS§N¥Þ½{ëöüüù³n9ÚNàþýûT©R%2�HÆ… ¶} n* |ýò™ÆïeõÞ‡ömç£M¦¬¹¨Z­¿|”s`L€ 0&À˜`L€ 0&À˜0%Àú ¦Dì¼öôô´³'w³…ÀË—/u�í¶ôå6L HÉŠ+v\»@¸ÕnbW?îĘ`L€ 0&À˜`L€  �cÇŽQ† ä1kÖ¬€™”gafp„»0¾-îÔ©=þœöîÝK¯_¿ömwno…@þüùå7n¤ëׯ[iÍÕLÀ˜@øðá©bµº´|ÁTã +W"F¤ŠUëZie¾úÁ½[tãêó tj"FŒD%ʺÊHá¼÷FžçÎW„â'L,Ï_½ð¤³§Ëó˜±âPÁ"¥åy@þsëúeÚ½}=yx�ž=}(74’§LMiÓg¦ ®u(b¤H¹ž‹ „:Gž ·oßÙußQ¢D¦’e‹éöýüé3yì:@G§çÏ^Ò·oß(…SrJ•:%åÊ›ƒ ºäÓí‡Â{wе+7ÌÖ£"vìX”>SZŠßw› «—­§ÅóVȱ7¯Gª”¥{ Ÿƒ(,\´ÅŽKÖ›ûçì©óäùì…¬N�0>å+˜[mjmíáÂ…Ÿo©%[ò}ìÜêA?þTÇ7= 6¬+uÚT,Yf ‡¯™`L€ 0&àK�y;v¬üÛ]ÿý÷__ŽÀÍ™€c °ÃÝAKmfëÚ£D�B™³f�üZuhJæœïÝÚ÷¡O­K ‘Ÿ&�3uèÖš*U-§®‡O˜`L€ 0&À¬øðრ|�4i=xðÀznÁˆKÊhž† 0�À%�%{rN›ÑW‹pcív#^/<ŸRóºe}8Û‘€VkˆÀ‡S~êØÚâ@;oèV„jWÊ'�çžOm<1ª4¬ÿjÑ ƒg»éšOŸ8Gu\ÿ¢�k¶˜VùêÚëÕkÚ´nU(Zƒ.�¿b±/êg;ýˆ¸,ûòù �Á¨Á¨q­Vôö�}O(ëGü�k·¨]Ó.Ô¯Û`úï¿ÿ”*~5!ðÌó¥I _2&À˜`¡•À´iÓ(Ož<”#Gêܹ3;ÛCëB¾oŽpÂoŽo–öãÇúúõ+ÅŒÓ7Ýìn‹]ĨQ£‰¶Ç¾ÿN#~üøöt·Úããˆ#†Õ¶¶6ÀzñE8 Ûº.ng;�ªî iˆ>6uH”$9p)eS[[!бFÝæV›F�æý3[¶R Ê’ÝEš$iJ«}ý»A�õ…ÄÄc9MÔhÑ©»pЕ,WM<GDâŸ!Hàìܲšnß08ÏfMF²ä 2ªû÷Òx|&ê@R%K¶L>îûÐþcôè�á÷4q’DTª\1mbÇ5~r§K›Þ´eõ]¡¢ù©j�Ê2š=yʤôøáSòعŸ¦Œ�I?~’íºwèOI’%1’eQ'#F >ƒ|>áóáÃ'™‰öî: ›{>{N=:ö§‡Ö›}"r2ŠÕnPC9õ·WÓµùò•îÞ¾O·oÞ•œî°Ã‚u¥âî´a×rJ˜8�Ùõ”«TŠ ÉoTÿóç/ñyú‚6®ÛJ¯^xɺ¥ VQáb…\N£¶|Aäùüuê9‚V/žÀ8˜`L€ 0&@^^^ò`L ¨`‡{¿3W¯^¥;v^µQLÑ¢E£bÅŠQùòå)zôèrU·nÝ¢íÛ·Ó¥K—Œ†–,Y’5jD»ví’Ò5W®\‘»y�LHž<9eÏž�råÊE:t xñâY½ÃgÏžÉyNž<éCçªfÍšT©’AÆâÂ… 4eÊB"Š›7oŠ/Ó)_¾|4lØ0rqq±8Ö¶mÛ6š?>�>}š�d÷9rd‚OÕªU©yóæäììlqK•à1sæL�û÷ïK '''¹ã™;wnj×®�ÐŽ5v2Xšü“'O&Ü7Æ|üØàÀˆ$´©Á¸J•*Ô°aCJ‘"…¥a¬Ö}þü™¶lÙB7nÜ êÕ«S¶lÙ¬öáö¨ìÖ€&Žìkô»gn¤j"ºÝœT€¹>–Ê#FŠLý‡O³ÔÄG]3!ËTìó§�tþôQu9#&.Îöªêu¶œù G½¿ÚS�Êùéá}ƒôæՋØá®Râ&à8�3Ñ3DJ+÷4é�ièØôš©e�‹Ñ:ÛáÐ>~€Ñ†ºs'jÙ¾‰pÞ§ªejK©DÅê3‚¶í_«Ž¥= !<5nQ_[dt¾bñêÝy ,C„7$]0¾©}ûú�6­Ý&‹£G� ÎhKkÿî½Ü صm¯\Ó³§ž4mâ<ª¯éÒÕë¼r›eÑ©g[ªRª–Ô¿G‡ifÈ=ª‹ &'KWn¦MÛö‘×ë·ÏdÃ(˜Ü/“ 0&À˜p D¶Ã_¥µÍ›7ËÀKmŸ3�À"À÷$�dªxä Èô �Ä´lÙ’�M òæÍ+£ÀMÛÞ¾}›ÐöÔ©S¦UÒ) ÇðÖ­[¥3òÚµkûh§-€“ÿòe}ØôéÓSÁ‚å#:K–,1rTâ>:$õÔ»wïN£Gëë¶¢MãÆ�uñATþµk×ä1räHjРM�:ÕW‘éØ(׳g½5f•û{ 4¼p Ù*tõgÏž­n (mL_áD€£}РA"’ï£iµ|ÿ0'ŽÁƒË�‚Q£F6M|k_¾|!l `w†9‡J}ûšÿâîÛ9¸½7�„‰“ʨuDb[³j5,꿉߱ëWÏÓ»7^”=wA‚F¼=vþÌ1£�?8×õ,zŒ˜ä*ž$˜2Æàä»xî„^3?•Ý¿{“ž>ºOïÞ¾¦8ñ’µ&Oiÿf�ébÁìæõKôPèÝÇŽ_nD˜&‘Å&äÍkEäð]%ìDiD²ÙÈ‘£˜.ÅèÚ¿ïÛh2¾°ñ=¸ïHõ^K”)J£& V¯MO�à³×€®RúuW/]—QÚ‰’$4mjõºn£š4nø‚´ ìü™‹º÷�[÷¨QõUªW¤H‘7!sÌX1iÖâÉR‚gÎô…rí+ÅæA»N-,F¹Ë†:ÿD�•š¶ndÄôû÷ò �æ¡¶há²�ôCü}¶|õVêØ¦a¨åÀ7Θ`L€  h‡Ö8@¯^½Òñ94amæP81¢¤Í9ÛçÏŸ—§ˆÐ†„‰ž!Â\ÏÙnÚ4uêÔ¡Zµj© MÛ ºúÎ�;¦Åê5œåY²d¡Å‹9ÛÕNÆŒC;wî4-–Ñï%J”Ðu¶›6Æ8õ±SyñâEÓj³×ºÎvÓˆä¯\¹²ÜÔÐ>] mf˜¿[·nºÎvm[œCÊgúôé2Òÿýû÷¦ÕV¯—/_®:Û•ÆØLQ<*eüê8p[³|‹S²©¬5ó÷zèŽgIVEVßœ³ «¥üc4Ì;4s£¢9Q¥¢hÅ¢é¾J¶ýýû—Q��Œ®µHP;tÜ7ìa¶iÍ"už1Cº’ÊÖª˜—j”ÍI]Zצ&µJRþL±Ôä¹øìA"ÝBYâÊv]ÛÔ¡ºU PùB© ÷§g¾¹o½þ\ÆÌ€LÌ•‹×ÔjsQójqRͽ2eÍ‘™2eÉ �+—¼ûkÛÙrîäì-•õô‰§n—U˼?kjÕwÓm…íº´P�ÿ?~üKóg-±{©4ðñB$„eó&pZ$¾&ä|`p¼³1&À˜`L€ 0� N€îø¥M›– ãlÎ2eÊDýû÷—ÕY³f¥V­ZQœ8qÌ5WË!ËR¨P!rss£œ9súÐ@]³f 2Dm¯=�ûÀ�)iÒ¤ÚbõNtÈ¿h ‘ÜåÊ•S¥o”:h¦k Îó~ýúEÅ¢èX¯«««ŒîÖöÁ96P‡'ì1ÈÆ/^\F²'K–ÌÇsæÌ‘NrÓŠß¿Sݺue´½icãÒ9"D0­¦ëׯK'½� +‰%òѺööjãûŒ |(-ôÄ#G‰ê£\[P­ö_ÚË`w¾këéÌ…Œéæ ¤^†õë@Cú´#$ë³Õ2dÊaôs9yt?Z0s,}×yb'qÒIå/~grˆèz'çtêtÛ6.Wϵ''…Óüû·²(Qâd”Wl~À¦�Dýº6£{·¯ËkÓàЇÞ·Ê8Ž`öB$dmì^œ®]>§ +_ŠM„Ås&4í±I€sHôhíµ×Kêß­¹Ü˜Ð–û÷}kçâóÐGàÒ…«êM§MŸš��ÔšE‹•¶ì]MÛ®“Géò%¬u1[ÿøÑµ.ŽŽLÈã‡ODnˆ“²Mº iÄçHБ\‹;¹Ö¨¨®ÿêeýÏ&µ�…-4‹Çvù; Ƙª…šM—ó⩊‹—o„˜{ãaL€ 0&À˜™Øá@ïë™3g(þü>\ÐG4÷Ë—/¥®;tÁƒ9"®Á­gp\oذAFÂ=z”Ö¯_OçÎ�“Î_8‡µ™’Çk‹Ôó=zГ'O¤ÍÂ… ÕrÓèYC-pÄãõ„ J-sD�+ýylh-qâÄ´víZz÷îa½›6m’Îu8Ö!¥£µG�Ñ_ý¥-²z½ú•+WÒ›7ohÿþýRVò:xjšëZÃ=CšGk  ½{½#dQ×¶m[©Y�èõ}ûöI†8Ç£JÐo×Úܹsem™µóŠ+R™2eÔM’¸qãÒ?ÿXÖÛµ6&×[&ÙŽ²•ÜÍ6B2Ð2k˜­··âçÏiûÆ�³'õG}3ç£w©gdžôõËg©Aß¼]/Z³ã í:v—†�Ÿ¯JʬZ2“&�6lðÙ2~‚DI¨z�fjÓïßѸa=É%{jÛ¸ -™7IM–ª629qÓldlß´Ò¤Öp¹C$]U¬rõò¡>oú(¥˜5¿ãÈmò8õ�¦ÌÛ@é2d•upléÝV>�“)[nšº`“<"DŒ¨ö8j–,=u™Zæ(fHûE8Òû žD»�ߣ�—Œ~Ö ³³mÃrªàZ›Vm;%×?qöZ™t‹Adë¢YãÕuÙsßjg>a6@PÅ2eͨœÈëŽ-{D$÷Ku.8üMmÍ ïhæZõƒ^òå4éœÕ%?zà½y ÚpòíÛwZ¾h�ÚÉW£Çð½D�:@;Á“„+×í0º+­Þ¨‚/˜`L€ 0&À˜@!`>Ü:ˆ,0$,céÒ¥4aÂr2õë×'D[#zÚœÁÉ�$IÕH4Šä«ÐX75”! '¹Ç�—Õˆr…óØœV;!\/âuHÆ Y™â"r\1Dß#r^/z~âĉ}vÅ K‡¬X±”"õã@·c#¬u z¬ÑþÖ Î|l6è­1HÔŠ¨yEöÚé­[·VìpÌ#ù«ÖðÞ ‘«©!i*ÜâÈ�!ƒ‘Þz‹-d„<ÊÚbxwïÞ-7;�ˆc†Þ–®ÜÆ +)=«àZǪ–¶^?keˆïÑ¡�ÅfÅËT¡Üù‹Xlc­rìÐîÇ3lˆ�u©êÞHí’4¹åÊW„ª•Î*#ÓW,šFÍÚt§˜±­?IƒAú ™Lß„ó{Ëú¥ê˜pìÚ·](Œ?!t)Mµ´s¹¨ípâZ£Mexêò-ׯœ§ŒYrªm =³W#U£Èÿ\Ñë?þá’>ôÞÉlÐèÙT±Z]u¾nýFÓîmkÕklŒ™æÝ�õ{½zNCû¶—m”d³¸°÷¾ÕÉø„ X!pçÖ=µEò>ÿÖP+í8ùõë·ÈqÓ¨'6•Þx½¥ý‡hé|ïM7D·» }v­á©³µË w<èVË; AÛ.0Ï$ˆ§Nÿôñ3ù¤÷„Ú‹ç/}°ø!tÚÁþÌÅtU±Ý´•ñf¾:A(=Ù¼}?½yk,Ù·lÕV=¤ÿ½J&ø¶™`L€ 0&°Ã=Þ¥#FÍ‚/cH �p{ ÑÔzÎve&ÔFaû¨ âO? }»6ÉU¦Í�ÅÈÙ®,ÉEkÖk)œ]“e<œî­;õWª-¾â÷hĤETï¯v´RDÈïÛµ‘>~0v„¼~õ‚¶nX&l Œ�¶Bè6ã'LL.ÅË«ÎyD¹kîGî¢O ¹+²äÈKÎi2Èõà½R éÕKg‘{½2úå¸×Cž+M|õêHfHH«u¶c!I’¥$8ÕŸ ¹X…ªµå«öŸ,Ù½e<ž?7´C½Þ·v~>½¼^z©73vLõÜ'_¿|¥ E­G¥cã¹÷À®%j£i�8NÏžzʲÒå‹SÜx¶m  âÏHxª>}ü$žXñÉqδ…„ÚeÈ”Ž6­c­Y¨ª×‹fõú-mÛu�ªU.ªXðÍ2&À˜`L€ á‚ÏRCÆJù )h ÛkÐi/Y²¤ÕîppW¯^]uXá Ç2"ßm5wwwZ±b…EíyÓ±àØG2VÅ�9:sæÌÊ¥ÅWÈ© :‘m°“'OZl�Jl*T¨PÁj;DÁ׫W�¦N�*Û"9#Ö žà¢5Èø`\{ A¾u¸Û3÷±ŸÀÿþ÷?mÝ�fOn4¼Ùs0*sÔdMº÷kq8¿&j½}óŠ:~â$)èœÐp׳1c©Å7¯]RÏm=Éš3áøý{.]½t–NÝKÇyйS‡Õ'T0Ö�=[¨[»º4uþFuhèã#"¶C8Ü»ô©J*A’E±ªâýQ Qíé3f£›× k,dc¦Ž@ù]JQñ~åÈSH:îá¸ó­9’™sÚŒºÓ'NwÅá®u¢+�µ9þûóÙ‡:ÿ¼oen~ ÝœœSˆ¼—%ϧömZù…`â$‰hòœÑ”·@nì^¶^- Šr2X¢õÆ�ž³]©·öZÿ¯ZÔX/Šɶ'ä¬�ê_ˆ ¡]úÿ�-\º‘î!áMæ{`L€ 0&À˜@%À÷~c‘XR0pzÛãÂr!cb«!ɧ6Bfß8ÜsåÊå+g;ÖuçΣååË—ÏèÚÒtéÓ¤ICЀ‡Ý½{×RsY‡5Újp®k úî(ë£ìÒ%ß;057�c;�*5øp¸»Õnbû¾l>|ªÛ¸­/{ù®ùÝ[WÕZ™µPçäý{o‡‘NµÅ"|†e‘è8 �h÷ƒ[iˆÞôâùSÙN÷s§Ž¨ò2%JW¡X±ãÒ»·¯¥u�Ñ�äÎþÝ›eŸp"’¾BUï(Ol�L[´…:6sS’¾yýJ:ìá´‡aLD½7iÕÕf‰ôs$³H‘¢`H‹1’!Ú_ÛHO‚õþyßÚùù<ôH›>�êpòÈð;k ��ûéÃ{CâßLY3"³M OÄÔiänZ,‚ÆhiEî…4”*uJÝ¿1Þ½}G»·ï•}$ŠOÅJËSùT|-Ö 2.Ž´—š'R¤LfvèÜùr8i-\¸°”Ê9%¥,À\ØŒ ,]¹…~Š'ôlûîCôÊë Å‚O>譗˘`L€ 0&ÀBv¸Âû=iÒ$zúô)-Y²DD2Eòõ L£±- ]s­Ù* £íãÛsSç‘VªÅ–± ó¢NÖ,Z´hÖš¨õpèk  °Ø±ck‹ýtþüùs?õçÎC UêôÂQœ�._8%'ÄÏmMTuÀ¬Â±³@Ò@±¸ñPB!ebÍ$Lb­ A[}ùBÓ!h\¢Œ+¥H•ÆG¿è1bRåêõeÄyùÂÞõ‡÷ïTîá…„Se·úRÒl‰dáp?´;}ùüIŽY¬T%é@×NY–ÕÛOÓ1Ö~áÄ?ul?A^18ðçN)en–l8""Mmû�ö/fʺüúê_÷í×uqÿ�A@›ôóô‰s"GÃ7!eùï<Ö¾y7Ùf,œ¨ëp�) ÝÏ.P›Ön’o†\îuª‘éßÔTbæËç/VçÒ¶‰ãGíñ#ÞOá¥p2ÿy[¡JjÞ¶±Õõqc‹þhø—®þýù“à�ïÜž¹êñá2&À˜`L€ 0�À%À÷àß«W/©M™ÅÖ®]KpÌB^IC}cˆ ‡¶9’~Z²Û·o´Þµ†¢þmˆP×Úž={¨K—.Ú"³ç¸·¨õ¦c©šÓMM•�SÓ¶JÄ{îܹ¥Î¼Ò¡hÑ¢vKÊø&â^™�_‡’r*÷"%+R<‘ð38›“³w”iÁ"ehädï\ ~¹/8ÉÌG^/ ›I?þKÍÚö4;$¤qÒ¤ÏLwn"îß¾ñÖ‰F'ÈÊ@C†„¢Hƺs³FNF“èU6ÒüãR¢<á€}xÿŽÎœ8(ôâ—«‰IïݹA ÅZÿî9TÓËü©13?£}5޾oûVÁ½B—âÕ[zûæmX³…ê6ª©–é�œ?sIu¶£>o�\zÍüT¶j©·œLÍznºc!"<¾HZúêO”ùå‹×¨tùºmQˆÍµkW¼7éô¢òÍvÖ©@BØc‡¼îÅKÑiÅEö8wá]¾vÛbw軳ÃÝ""®dL€ 0&À˜$ìpð 6¤ÁƒS³fÍdT»2å‘#GdbNHÌ899)Å6½vèÐ�ð¸vÓ¦MUýcmGèˆ×ªU‹Þ¾õ–‹€s9K–,Úfþrž5kV™`ÕËËàdÛ¹s'-X°€š4±,×�hs°Ò¶Z3$Z=pà/^ÜbS¬gáÂ…jDÌeË–M^›:Éß¿OS¦LÑ}Ô]€O‚=�Š®uhÔ .ôSDlV÷G9™€åäœ^�  È… ']u÷Ö5!#q\¶EÂÑl9­'ù…¶ýÞ�-öCûvPÓ6=t?{”(ÉOq�%{¥X¾fÈ”]j®_¿r^JË ù*¤h`�†Áæ‡ÖïßAW.ò,äÊçBù rX@‹¾d¹ªò7¬'-˜9Vv»øçÞ´c˜;÷Ofææ´µÜ?ïÛÖ5p»�M sÖŒâ³Ï•Ö¯Ú,otƤyÒi G¶žá‰µ‘ƒÆ«U©Ó¦•qÕkGœ\¹t]8ÆoÈ¡à̇ìŒ9KŸ)­êpßµÕƒ:vk­ �þG›tÔ¡Òe4P+l8yáù’út¨¶L’41¹×­¦^ó‰ß è%K5õÒÕ[t^l´äÌžÉ´Š¯™`L€ 0&À˜@ ð}†¹@]nð�ÎñÅ‹SŸ>}ŒnâÆ�T°`A2�¼6j¤sñSI‡+dcŽ7DŽê =lØ0‚ŽxÏžÞr p+VL:ÉS¦L)“šÖ¯_ßbô¨26æ²4ŸÒnÔ¨Q™Sƒ„ËÊ•+ ÑößDÒÂ7oÞ5™3gíڵ˨ ºêˆ wuu¥R¥JÕ)�:u’<yD¯·mÛVJÜÀ9ž)S&Š?>ݼy“Ξ=+%r>þ¬t—¯�¡Iž<¹Z†Hù-[¶Ð±cÇÔ2åšøyòä!p+Y²¤L¼ Ç?’®"!*Çâ=R,zôè4oÞ<åR:Þ—-[FpÂc3†÷ïGíÚµå{’$IŠ+!RïÙåË—éäÉ“Mý¼�x6l jÕl�tÚ׬YCø‚‰9Y_½zuum|â¿ +“TH `ƒ'¸6ÖzOMjœP{¶¢‡÷ïP©òUŦB:{ò�p-¢'�îË[M—!+,RÚ¦Û®#¾îIMOÝ'Û/š=^ʸT©Þ€ !I$}ü螈TßF—Î{Ë,”©P]D¨z;ÕÉ*U«Gc†v—úð¯_½PŠ©ªŽœL¾B%ä¦!6¤ÎŸ9F·¨A\kSμ…åÓ ¸¯Écú«c2¹§ø ÓçO†�“G÷§ª5œðX›2Sdç‰_ïÛÎi¹[(#�(IBê/6Ðúw*7}Þ$ÊÕ)�Hô‰ód)’JgöÞ]èέ{*�: Ý©T¹âêµ#NàÔ‡~;,j´(T©j9‹Ã6lV—vˆÈö㇠Ÿ9Û6í¢£‡NP¶Y(s¶ŒôúõñtÌ5ºyý¶””Q5i°ø[,†réãõËç¯rãA©øúå Ý»û�¾~1l *åx…äMíü¶–‰_Ï·î´o;áˆ+Žt¸£�1Ó®Ážs¿Þ·=srŸÐI þ_µ)uZgêØ²;½|þJ$0þ"•‡·ZUè!ãähÛ½}/½÷^[©ZyŠÕðš¹yð÷иiè¾[3‘Dù¡löîí{³kGûÖ›YÔzÇ ø{âÌÉs榕å"„§�#ûP½Æµ,¶ãJß°ENFõõ›÷}u×2J¿2&À˜`¡”‚!Ù˜@P!À’2z'<==mI+kb®“¥6ЂGTzÞ¼yÍuѦ‘¨[·ntïÞ=³ÎvtF¤¶½öãÇím®?´Ü�=JÙ³ÛþØ6¢M»víJëÖ­“‘§ÊØ/^¼°èlWÚY{E„úôéÓÍ2éÛ·¯Œ†G;{,Z´hÔ¸qc›»êmfà½ÇlCò%ÉSzË ̬þ;KëNýiáÚb#!‹�‰"ŠÏ†úM:в�G)Qâd>ê-@_}ƒÇ%8j–Œj7×6½Ðh:nÍX´•�pÕœieeÐÆµFsM©N£64qöZµš[· ’Ÿvï?†FMYêãi…öBk¹²pÂGˆQí Ç›Öü‹™v{ÎýrßöÌÇ}B/�…óÒŽƒë ÎôÄIé‚€fû’µshÂŒ‘V�áºX)ÔÊÉÔnPÃJkC5ôÓwÝDGô9 bšíS¨h~Úº õü§³Ù6–*°éˆD«ˆh$íÛ+v¶["f_Ý+¯7´c·ù@½Qh’ìêÕs`L€ 0&À˜háî â�;w¦—/_J%Y¨¹¡!'ƒÈé½{÷úÐW$eêÖ­k®»t&Aæ´Æ¡½v$úL—.eÈ�A:¹enÍé=~üxURÆZ{ÔÃQgzÍš5¥4Œ¥>�žÁ.#dR%~ýúuÝæÐ>­\¹²Ü$€¦½©åÏŸ_êßoڴɇN:´ì“%KF³fÍ"K�²;v,%L˜ÐtxõH߸»»S�=¤î¾µ§ " 'ž‹‹ •-[V:ò!•c«!±-6´?3xêc²�Zt&öÚªm§t»zóWÿÒ­S s ¹• {.J)•›×/Ñ«Ï(I2'rN“AH5DWšùúîõš“›H2ûôñqÜ5÷äçBâ¤)¥#‘Ù¶Øïÿ~«Íð¹RYÈÓX²ÒÜæ}ö䡼§˜b qÒò¾ÌõE4ýÈÉ‹åñæõ+)C;ŽÏ¤�ö0«Z³±�¨±¼É¶dý!sK“åØ,°ô~Ú{ß'åÊK`Úüñ4Í냶9œé°W/½„<Ôò|ö‚Ò¤sÎæ´Â¡my3ºyÛÆ„Ãûõë)Qˆ\Š”ò ¹óæ°y|.ýÕ²5hZG|><£Bçу'=zTñ„LJrrNA±ãøßÚõzå�þç·^[.ó&°lÕVú÷�´Ÿw©å³�{ŽÐ ñóšÐL²_˽¹– _øŽyKÈm" 'NjÙ²eð½)^9`L€ 0�B€îz#�œœhÅŠ6�–>}z©ÙmSc+�=î›rÓá�‡¾C�ôÚ¡©þðáC©{G96J—.-ÿ@´´èßã0gHH‹ˆzèÒ#²_Þ±ù�1cFy@^ÇVƒLÎÂ… e4|¸ÑõîÝ» ‡©�Ê—1cF2=2eÊDµkצeË–‘³³³/Fç¦L€ 0&À˜`L è°E¶"è߯� ,�(Q¢PĈ�&E�¾3vïÞ]–—/_žJ–,IôÒZ¢D‰¨jÕªFè¨�7.¹¹¹QŒ†äÄ�=…ã]1///ruu5r¶G‹�Ê”)CåÊ•£èÑ£+MéþýûT³fMÂÌÑkQ'â&À˜`�D€î�Þ–i5g:"%`z\½zU>ÊW§N[†ã6L€ 0&À˜`L X` ÷`ýöñ•ÌóåËGß¿WgC¾/\ß½{—:vì(ËáXß»w¯t’+ ‘ ß17nÜHîîîJ1! Îõõë×SóæÍÕòK—.©çS$dàðߺu«t¨#B~çÎ�ò|Ïž=ªÃþùóçÔ¥KÙßÑkQÅ'L€ 0&À‰;Ü ¤n”ÖÖ¢´ãW&À˜`�I€î�IŸçfAœÀ›7oä wn]O»"ñÕòò˜`öø÷ÇÙ±a�ô¿0ÿ³oîÅB9�ü+ ¬Û¼›"ÆËî0¿~ý6+s~Wb]w#$|ˆ”Ÿûþ Ä¥ø˜úýû÷táÂ_9Ü} bc$P ÈÅØj�¥a‰T[iq;&à�ÌxÛ¶mþ7�l|–³Oìpžï¯š �/^Èyþûï7)©™˜'aL€ �Ÿ?¬<%Y~ÿþ�~üq¾ûÇ�ýû/ÿžúWÓoÞ½{ç·Øzë�–ùõëA»ýÑ£G4bÄݨJ™2¥ÝwðáûûrG&ÀüNÉ”a¶Sîü>*�àhÊûäèqy<ÿ#ÀwÿcË#3�`O cÆŒòrçs¡vÝûûá`L€ èhQ¯ýÎöþC{R¦¬ôšp`VL3�N9MÅ ç¡�}Ú[im{õ¶]iìäj‡Å³GRò¤‰Ôk>a�I Q«Þôø‰'%H� 0—¡Î ‡ ’ž6hЀ֭['ËG�%“™ÎŸ?_ê««�x’+W.u´„ ÒÑ£GÉÉÉI-³tÂO¬X¢ÃuLÀÿ yq±bÅèÓ§Oþ?Y̰lÙ2š;w®œ©V­ZÔ¦M›˜Õ§ˆ)’L†í¿³ðèŽ&ÀwGåñ˜@$� a"ÊW°x¼3¾%&À˜Q˜0aè—g{A—|Œ„ 0;,]°JöJ?./â¸ß£;÷­&îl”.­“Q_0�À"=ZÔÀšZw^$&…cfõêÕÔ¹sgš}ú�éïÙ“'O¤ÃÝT«Ñì&L »wïRΜ9å˜Q£¢þ¿ÿN6l HÚ`L´Ã5¢Ûµ†¨ü-[¶8t-Úñùœ 0�ÐE€î¡ëýÊwk·¤ þ³Æ£iäåået� .$¿$N1Œ/˜À;w[·J]B-h6kÖL[ÄçL€ 0&À˜`L€ 0�K R¥JR*áØ±c"QñÝûìÚµ«Œtøð¡Z+V,Bß¿þúK~—‡Þ:œã°¤I“J½c­Ã åñâÅ£ºuëúj ׈RO�:µ,nܸ1•,Y’:uê$åk´mµç1bÄ %JPýúõe”=÷èçȵhçãs&ÀBíç—éæaè¡ÀwØípŸ:u*õîÝ[÷>þ¬[ Æ+\¸°�2.`L€ 0&À˜`L€ „TÉ“'§ýû÷[¼=HÇà0g{÷î5WEãÆ�“‡iHÄà0gX¶~øðAjºC×ýýû÷RFu8�dVëK”(ùÇZÌ­‘Ë™¹´Ÿ-ìp¹ïsp¸3»îHºÂf™žHŸ>½Œ88p L £ýå·Ü›kµ Q¨çl×¶ás&À˜`L€ üŸ½«“Ûh–ý'13333333SÌŒ1Å;¶cHÌÌÌÌŒ133sÌ;É{SsݬV»·Ç{wÝß·'iH3¥=­TÓSÍ/þG,â¼®(�&¤ /öܹsËOH3�“`�scÂ=ð¯GHî��5ܱL AZbĈ’ñs:vDGVËûž?nDbwZ‰3-È“'�\Q‘.]:Ë|NdF€`F€þüý_ð$��`F€`|„î>‚�+ù>&Ü“%KFË–-“úímÛ¶õ‡®ý&oݺe3È¢°ù�áÇӥK—èÀ�>o„k2Œ#À0Œ#À0Œ#À0Œ#À;˜pv—4ÈÈÇ„{�1wœ`F€`F€`F€`F€`‚L¸«Ë¤ìwgù÷ß}|QPA]‚šAº& ûí[œÿþûo‚ÌŽÚGýÒ‚êwÃ/1à¶F€`F€Hôç€LW¯^¥0aÂÈà,Æ £‚ ÚÔ3þl9ÆI“&Q«V­hÚ´i–ù ãÏŸ?o™—&MÊ—/uíÚ•,X`óð�óíß¿Ÿ *D={ö¤Q£FÙµDûàÁƒéÝ»wvùhD?>C† ‘dðÈ‘# ŽìãÇ�„àž¯^½²,²wï^Ët•8vìXúí·ß¨G�ôþý{Ê•+—¥—6H}`wìØ1UÕØbŸ�7J2uêÔ1ò­vügœ×¢I“&„I³}úôIê²C›}ĈÔ°aCÂÄ¢Ú»j¸Føž�þòË/Ô¯_?GU8�`F€`F€`F€`FÀ„î&@ø0ÐðWÂãŽÈv5âÓ§O«]›-¼~oܸa“¦€Ä™ Oigá ••AʤhÑ¢’èUiζ�k™<ù+V¬H-[¶”“<ú�XUò¯ï†jß¼]¼x±A¶«´+³uëV»4xŸ(P@JËè^ëÐóVößÿQ½zõ,ÉvÈ›äÍ›WÊ×À{D»n—/_–Þç3fÌГ�ý´iÓR‡$¹ ï~ïØwß}'e`ºté"«eÊ”‰Z·nM+V¬ ¿þúËiSèw¶lÙ(Nœ8Ò›¤½~cAÀxšÍ¿pÆy@ž÷ïßß|J9a‘!C)w¹x ë†É†Ê•+Ó©S§R;Þ5ÈÆ@Vc;{ö,=xðÀ¦ \?äCbF7ÿünèçÑ÷ãÆ�«ÊýX±bi²ß=ýGÎn€�˜*th?êgºwç†ìE¹*ué·‰‹œöèý»·Ô¾Yeú盬ՠ‘S}E¸_ºpŠz´«'Ï™!s&ÜÛ7­¤IcÛ\‡†Í;QïÁãlÒ¬6®^H¿ô¸oªüúÍ:0á®Àà-#àÆìÞ¾�~ùÙcbÄHì÷úÒûw¼ž5S¦NN{´¡ UÊxYž -Üõ™"h¡È½eF€`BúsƒÎ‹…ŒÑó(Ý  šzâÄ )¯b&Û¡¥ ôÙ³gRã鎬W¯^’,…DÊܹs#�ÕÐ+q "[½  ¡¿¯fe¤]»v©C¹m×®�$étt÷îÝtàÀ€0¨¯ÛÌ™3e=M߇×=Ɔ>˜ nxɃL¶ú€ ‡¶9¤Q”A�׎<¸áiOpxÂ:tˆV¯^-IjL +VL5#·�)Á¸¬Ì?p†þ<& t‹/­\¹’^¿~-û»nÝ:‰Æi!ݰZ iÓ¦z’—ûЫ_ºt©œ ÀjÈêໃU ØuØ!Í£›7ôs©ýòåËS©R¥ ‚ X”mö{ 'wO™ŠµŒîìßµ‰àõîÌöíÜh�í uJ•«á¬8çù[6,s)ö–õËüèŒÜ #ÀUð¬yåÒ5jß¼õï1ÄÆé ¨Ž‰ûí~yvŒ ç0Œ#À0!&ÜCú7À}Æï/î .¤qãÆÙÉÉ4hЀà] �lïX„ ÉÊm Hèüùó©¨�ˆQ=zt:t¨ü¨4lA¾BâD7ôÁ:͆ ©êŠ<×uMmH’@sÁY­ I’$!ôC·Ø±cK½n=Í«}´?~|»b4Š`´Ð²7ÒœD.$p` ЉGšø(ãW8£­ßÿ� Ï®,cÆŒ’ð�5ªJ2¶À :þ¸†«&i@˜£¿ðö÷Ê@æÃ#Þê{‚ ©˜Ì€×¼Zíô6mÚ“/õÝ0�×wûöíò»‰€¿ø¾åeñ÷nß  ¿  *µšRÌXqÌÃu‹ã2kÒŒ‰¿Ê¾|xÿŽŽÚM‹yJN™;¹cój#)oÁ’%šíÿµ‘É;~ŠÀËçOåµÉ_¸”Ãv?¼GgNzÜãâ F€”©P‚òÊc3–þù—ž¤–ÁÓÞŠlWý�œÊæÍ›¥”ŒÒ¹¿xñ¢ô.·"½U=«­wq†œ&A”a‚žç^�R?X�à±ÊàåMs¯lÖ¬Y–d»ª{öìÙâ_IôÀã²A¡…ÌH`70q„OP·5ËçÊ “MkQ“VÝÜr8ÐmOœ4¥!+³cˇ„û§Oéà^OùªrUê¸å˜‚k§6­]BÎwön®WžÇÅØ#�+ojÒ²�}†HéòS;ªT¢6A6iÜt&Ü%ü‡`F€`��…î!ëz»óhý…p× /pH‡”)SFOöõ~Íš5¥V:$\5�ªºAªÚæ>1Èâá½v‚õÊ@pW¯^Ý ¬1Ù àùîªùgûƪ¬J•*ÍvW r*ðŽ‡ž:ìèÑ£^VÃ5,W®œ—åà_¿~}š8q¢,ûUhr£¯À3¸|7¼Á àš­_é1ѲnÅ|·%Üde”—ûÞëÅ÷mŠ”¦2òýóçO2úïÅKW1‘Ç/ž=rgÅJ’(Mú,.û´lȯ^>Gwo]£hÑcQæly(ŒX½£V¿\}¿÷&ÅO˜”R¦É V!…׋Xî+X._-#À0Œ#ÀôçÝá6ˆtŸ»Œp�­öá °Ò' y!ŸáW–={v�Õ;íAËÛ¯ Á>Ë qãª,XÐ ÜQ³wwŸà|ã†G@JÕÇܹs«]/·Ð¥O™2%AvóæM/ë �®ÈuÝð�@Zpùnèc èýÃûwÐÓ'åi¯ Bä H=w4]Væ¥ ?Ïœ8LÙs´ëª.'S°hYŠ9ŠQ?ÞógŒ£ÙS~#´¡[”¨Ñ©^ÓöÔ¦soݧJçKN EaKÖ¡LÙìÿwºµ©#ƒŒ¢L¿¡ãåy°¿nÅ<ê×­9vådG­-©W‡6$ôb¥Gý¦¨×€ÑrµÏoC{Òª%3 Ò:ÊbÄŒM]ûüJUk7UI6ÛÛ7¯Ò€ž-éÜ©?m4Ö“$KE [t¢zMÚÙ”÷îAtqþñÒþÝ›e¿öíÞD¥ËÛëæß½}]�¿÷tÐ “$·«ù¼/„D 䎶 mx}¼(â¹HÉŠÔ½ßHÂ8tӯɱ+oèØ‘½4Bi}pï¶Q “1�ìJíº°œؼn)Í›>V�€'�:j'~Â$·Æ?Ú~Uùo^ýEzµ¤}"Þ€ Ü‹¼¤ÉSÓä¹h­¸îÓ' —Å,¶ï�?TU¹Å÷“K g�§¿^>7òÂ…�@¹ò¡�#¦Rœx Œtìèߥ–úÐ�í¢A½ÛÐ1&(˜p—Pð7B Yò$Foð½úø©XÍôWŽƒâ�Àxy>}ö]¿éñûŒU“Õ*•4úãhçÑãgtðˆç}¿bÙ¢ôæí{:pø„¬=Z*Y,¿£êA2ýñ“çÁz|Aò¢p§F€a0áÂ.¸×ß wŒý�?þ ‡Ò‚ Úè�eÑ¢yí�èjßž””uÜ´” QR›|ÿ>xúø5©Y” ƒ®[LÀûÖ�+´iÍb=[îcl?÷ø‘’¦HCY…çºnÛ6® þÝ[Ч�ž+XT>ðaý;Ò�«©� }½³úHµ¡¶«7�„;ŽÑG+Â]‘¿(SI”?íDËÞìÍë”�cFy³ÁË÷¶utîôQš¿r%N–Ò\DïÙ¾žúuonC|#Þç³&�¤¯_¿ÈÉ ½ò‚YÐÈAŽå•0Á2jpwzöäõè?J¯JX�оie¡Q}ß&wĪŒ)›ÅD‘*üæõ+êÕ±Ú»M%[\CLjÔ­”‡&ÌZK³ä4òô¬\i×´�&ÜψUÿþë±4S†TRѪ�vêÌ%?_@÷›ÏÇ0Œ#|Ð9$ïrQÁ‰; à/„{ïÞ½¥7$[”­\¹’@RC^ÆLT•ñïmŽ9¤–¸:OáÂ…},)ã¯ju>¿ÚƒÚæúéÌ®_¿NÐz× DýÛà¡®ÛŽ;¨[7Ç„“^c»s玑dnËÈÐvÌ“ Z–Ý®¹¬òx.ß »Pˆ½]ÛÖÚœmÓÚÅÔ]ˆ¾!^môヲk²2»Eßáõ­Û‘ƒ; Oè°aÃQÑR•ŒìQCºd;äWÚwDy –oCÓ±Ã{h˜�ôV`‰“A?µ¦‹í O£1ØÙºa¹”…�·3úýñÃ{šþ›Ïó¼_ʼn[ü/¹>Xýæó*—/NaB‡¢¿¿|•�^³q'ýÔõG§Xµ~‡‘_»zYy5|¹S°tCúðÑCòîæÙm”<¯æð%¤\�`F ˜ À„{0¹�Á`þB¸7jÔˆ† B-Z´�^í §ƒÊ ¥�˜Iš4©J°­™$óæ M˜0!ÀA¥KîîØ±£ ÷BQóæÍ-à¡1_»vmzõê•q:�Ëêß–)S&ÈöÅ‹òT[·n¥9sæP³fÍœžÞæøî膀­^­îÝ»—Š-ê´(ú3wî\£ ˆºÌ™3ËãÀþn� ¢;›×-‘^¾z÷!_q`Ï*¦Õz~`ïë²2��{Z¡¿®L—“�ÜHx!Á;uì á)‘YËvJmtUr¹ §†U H¢¤ì¡E^ª\uU$@¶ƒGM§òUëç‚÷ôöM+�ch‡ÿ6ÉÓÃ=® Ÿ_<B¿ôë ËÀc]·Ñ¿ô4<»‡Ž™EUj66²áÁŸ=w!ªZ2ýýù3-™7‰Z´íIQ¢E7Êxg“%^ˆ ïñ›WQõºr9hçú• tóÚ%Ùd�"e¼Ô_?°g³qúŽ=‡P�Fž“•1b§_ÆÌ¦ê¥=yàÈ@Ð/ZØÐ¸¯Q¯…ìgÉZ¬°X#ãVœ>qˆ //«lX½Ð�̉;.Í]±×h7aâd‚xÏO±D:&:¬ r;k–Í‘YÉS¦¥e�çŽ'´ãQ?|øˆrÂÞîógüN�úÅ®)�í�R;u9å+TÒ.Ÿ�€Bàé“g"nÄU›Ó}:í7®Ý¢ÙSçÓÅóWŒ¼æ­mŸ%Œ Þ ’è/Î�5€H‘"PÙ’…hÝæÝ² k68'ÜÏ_¼fHРB�êq/’$ŽOm[Ô•m`Ÿ�`F€`üý¹�=Üý[nÍ{ø�¨ºé¼ ƒçÏŸO}ûöµÉ¹rå åË—�ÌžÆ6…üé oÞ¼”55jîAhdÿø\‡€xd«U­ŒqÞc'ÎÑÃG¶²mF¦ØY­y·'Oš�rçôpðȘ>•Xq6@~¼ò�×Ûã}F€`F€p õ~ƒÒL¸»†—ò~ði³ïß¿—ä3dcŽ9â°™aÆt³úÉÓ äg‘"E$)œ$IijAƒÆ‹?ƒ´ÈÒ¥K ^ñŸ…Çä_ýesŽ3fжm¶2 øÇ‚ÇråÊ•%imSA€\]´h�h¡Cÿч:uêÈ~Ä�Ÿ¢F�Jð†F?ÏŸ?OG�%覿}ûVÖÁŸ5kÖPÕªU�c«�Þºýú믒PÅ„dupŽû÷ïÓ¥K—äXuBç ZxÐ:3`ï UwäÈ‘ ³ùÎ8G—.]ä÷C� ÞëíÚµ“7 ÇÓ§OO±bÅ¢«W¯ÒÉ“'¥D·¶ºÐ�¡I”(‘ÑexÊoذ�>l¤©ÄÈ™3'á{T¼xqxÄ?‚®" ê¤I“ßYe‘"E¢Y³¯X±Bè?%|ÿ°ê¢zõ€õ†ÖûãÝ}x[ƒD;{wn%¯¤f¸wÛ ˆòº¬Ì®-k¨½�ì€?²WJ«`?|„ˆT¸˜‡×1ŽoݸŒ�´òU“:ÈC°J˜^G&øóŸä‚ð·²x‚t"ôÝaq…—³ÙHSÙÿ‰‰,eðÚV/~b:uü�:´ÙFŽÕ8¾z霱ï“�ºA«ç½uý²Ðøß,eiô|µ¯gt9#•�mè0a(GžÂ6+Tþu¸X~]3xíC¶æý»·„‰L¨è†Uuz®ÐóxŸp74­M?ë-â…q·®q‚º¬ 8ÿµwQûVž“ÃúW­ÛnÖÚí>µOŸ>ÓQAîßð˜ŠÉK „|@Û­Û÷éöÝôìù_)bJ”0.eÊ�Z:ót_ø|Œ#À0Œ€Wøá.Nç� ¼þÊUG®F¼³U©RÅÕª\.!àcÂ}âĉԧO— Ð‰jUäç¾}K÷á �`žeËz>�B*ߎìöíÛ„�Ù -�o|¹cǶ÷üƒ'ó€äGÕ}÷î�$‚Ízç*ßj ]r¯wÈ·@ƒ¤6 ^ÌзwÅà‘îÈÛ7Wgê0Ù1nÜ8‡r.þ…sŒ1hýúõ”?~¢+\YÝP¾|yÂ…2÷*Tpˆ Ê/æÅÇ+C _}µÊäwCõßq¬JPüŸþ9Hîk–ÏUÝ·ÛBähÝÆmíòÜ!A—•¹&Êûwo<µw ò]YñÒUl¼ƒo‹`£Ê%I¡ví¶ E;ÊóÓ§�vÞÑ*߯·aÃz¬ÜpÖn¡Ko6sÀc•óÚEµ+5Õ¡«î•½yóÊ«"NóÑ—òUêI�rÜïð=j,ôÑ¡—Žëƒì äg\±cbeÍÒ9‚x>H¸®ÞCõ¶!ÁbeúC�9ÿõ«—´nÅ0‹†~9›ùƒrø€È†¶<ôÚ3ìxðÈ’%‹œTpxÂoþ‰3N�ñCŽ2)˜D¸|ÙÓëRïT*V¬H=zô�zöñP‡xëÖ­³ÓЇ–=<-¦M›æôÆ)›Ñ£G¼+H©€ún lÛ½{w›ÿ!¬: d;ú@x:#8ª3;æ!ð"HFw4Y¡ãž9[zùü©ì*ˆÙü…JÙt;yÊt„1Áîß½I %•ûæ?¾ya#úéaÃ…3qzüßÿyJºè]ñ�ÖËûÅ~Òä©�fò �J•¯aC@#®Ø ŸZd;‚¡9�bǵ�ˆøŸ"ßÈ5Áîܺj©áŽ<}ÅŽa¸�%NšÒ,‹€§‰“:^�áQËúïÿþç3¢Þº5NeFÀ÷xõÌîû38nA—•¾aË^j\¿ŠM]NFKµ)àÂA¯ŸGK²=A¼ØT¸@NŠ.HýBùrІe“eíZ�»Ðg46cŠ;¦ðÔ %�}ûÚô:Ù^½RIjP§åÍ•EÄùHË×l¥AÃ'Éþ�›8�ú÷l#äC]÷4ömÿ|ZÿãÇO´|õVÊ�.%åʑɧ͸M=¬$†c—Ùà>}útù>ƒ÷AÖjU¹^å°šXwª@>“tÛ¾};ác6H®Âƒ^ º*ßJ•*%ã‹™ëàÄ>Þç`xGÄ;2V…› ^ñxws$�Šó ÕVß› w�é*ßÜ>ŽÁO€¨ß½{·ì¯ùý Ò¸xÏVb³¡/p„C;ˆÉ¥ãa.ËÇŒ#àÿ褸_<3 =Lâ^Z´hQ/0wî\Yõüâü^ž� ¸->&Ü1›ílFZqš4i¤FµžæÕ>f¬ññOƒ<þð -qÌðãƒ_¸ø@Cx�;’[ðª�xØÙ¸q£üÁÆì:– aVÐì†Ö{öìÙ}ô㌶ññ©ÎÐP†;>Ðk‡¦:0ÀrE`ŒIxì;óÄÇøðЃ�#! x!à! �˜|H—.�ü@^ÇU ¨ï¼ °4sõêÕòû™"Ä*æLNF¼Ü»ôv|íô²½¯ËÊœ9yDûôx™E?J”­f'§XîðºÎ[°„e—õ@Ÿ é]±hÑcJ¹”…v¹•�ähKšÜs²c‡Ç‘•ÇôÍk— ŽÉ ß¼ØÿÙ_63¬GCƒ¾\庖}0ŸO'Ó«ÖjJe*ÚË«¼ym#Ä܆OŽ�Ñé‡�ªCFϤ˜±ì'û�;UÚLá¾jélËÉL@èç0N&v’‰k†ë;'&îW/žq^m•k6&ܯÙF€`¬°’•Ñ ÷»÷ÚH°Ô­YÞº!/R¯\¿M ëgMJ"„·+­¿“/œ‡’'ó»ÕH[v0Η$Q|Z4ë7›¸ýÁ~êÌ%Z½a§XMõúó•/SĨãn;ç.\¥és–ÓÂe"®ÐÛ÷´tÎè`A¸C~ïOx÷�\Š2¼[ ]½vêÔ‰ö /÷—/_Ú¬† sÊ�¸ÄªUeð~‡³ˆv½m¬GL08Ñ)Ùïú» ˆçýû÷«¦Ä÷7eË–MÊ·ÀK$»~.�XfžèpJÂ{£2p( Îl�nxŸ2<ÒáŽÿ™dÉ’x ¼sBŸýÄûâ±cǤs¿tCL2x­£ßºáñÈðŽ ‚]é4ã÷÷ß—}zyÞg�€EÀ¯ wL"â~8Wp‡^îX„ Q˜ª°£ç³¹>&ÜÝi¾í fâAÿ4<$˜(üó|îØ6&ÌÁdýªŸ Špôê&è�óÄw27ðjjöòÅ3ôÑñª }<V- N½†ºD�êõb_—•Á ´.YR®r».Ô¨Û\jr#cãšET£^ Êš#ŸM¹W/Ò²SŒ´õ[ûÎvâ'Lj =*…–(k˜ùÈ��t÷¶ý …³6ý"/eš œ®\<#Ï¿fÙ9n½mxÞ·oV™Ü»-“§/Úªgûx¿BÕúáþçÁ]F;®ÊÉ‚úˆ¸ÿŒ# ¸*'£:Y¿"aU›~µ-[©Íœd¬t…šÆC¼ù< ŸŸ=~HÇÿÜ'´(?јa?™‹Èã ™sÐàQÓ-ó¬ë4lCó§�“²)ÿˆ¥½ ÝñQ–&}©¿gûz•`Û\ùŠP‡îƒ¤:fO%?怞<£ü¡4çùôÞì'�0ªWü6áa$8Ù)Q¦*ÍL1Bê¿c‚dܯ}åG¯‚@°ïß¿¥¿…®è§O©l�”ôÛ¤ÅdµÂA¯çÕ~˽ÅäDY Ò/ ÌÍ/AbCç}ÁÌßéàž-´a¯‡ÌØ)Ëè§N�hïŽ ²{}âªC�Á„‰�élõVÕ9Žœ*' ��O·ÖµU–Í«O\�²©ÈŒ#À~ñòì›n[ÉÊT:ç�Ÿ<§ÃGOMûT¿ ¤K“Üh'0v^¾|M󯥕ë¶Ñ…K×éÝû��Ñ —Î oö%+7KÙ˜ã§<õ¶Uþ*<ö‚›�ð!R[ËðZW†f«R« áã̬Þï,›’&Oí´o¨œ=WZ³ã¬œ<¹zùA‚ÚóÉS¦%Ä>±¶]>Ž ò,§o~r”-Ó4>V–0q2š4w½ H OïOŸ?Ê ¢ ¤AºÃ@^—*_ƒ®ŠëGL¨€¯Û�ܲjÒ&mìÔe6ÇúA½¦í©zÝtM`õðÁ1A‡’ ¬ôª[^§3Âýʘ9§^]>ØÕjЊ𱲧�ÉÉS¦1öÕ&Bú ù�z'åÐ�°áÂKò>Qk¯W¾Kª}Þ2¾AàÇvMGváŽcm^Gu8�”¬ÌßBüÕë·RneպƩ}ãÝŽF¾ûîF[¾Ýùï?5 `ÛÒ{áne­: ¤»‚t‡U(S˜¦�-BS^7%Ÿ¡§Äþ{¡¿xÅ&éÍ~Rî>±¥ÂþüÅkOw�ïÐt‡7¶í±È“ù_=ò¿•5ÊËÃñç¿¿Èn€`ñ­Áû„‡N¹Ú&Èx{?~üXêªCF¦jÕª2è§j£k×®RÏ\û×òÀ gΜ‘7ðxñC?+V¬(½7uo|È!(AïSƒ'?&”ABý‚—:H*hÉC®@לWeyË0Aýª&};"xŸÃ$9VÎ F„nÐ;_¸p¡Lrä¯Ê9r„æÏŸ/µÖA0CzE7Äá@l¬ðA›#FŒ�·zücu�#Dz¿~ý¤t ÊÖ©S‡~þùg½š$¾‘²ýüùó6y¸o‚ˆ‡| &GÑž2œ“ˆqØ®];CdË–-ƹT9xç£,b]T«VM%Ëm«V­R3˜p~þü¹�<  =ûø@Pïà`L¸»éUÄ̾¨V„»¹Ë(gc.ÃÇŒ€_!Ù�-ë=–úx·Íu+ç»-áîݱèåAž"¨¥_¼ÄýÚSÜ/ûrä{P2èÁããÈR¤JGøøµ�ôΔ-·üXµ /ü‚ÅÊÚdm^·TèÍ�’i¹ò‘„¹Mq€ÿEÈ)KžÒqßñà‰É|ØF€Jè/ÎîÒo³¬ÌŒ¹+%éŽþ�*¯]ÝöžÐýŽ#ݹçAš?yöÜòô7oß³KÇ‹¶.‹3kÒ/'¶ýʺ¿^yH~Ø5àO 'O_”$;ÈvG®žú��ýÁÇ Þ‡ðnôI`:�3 K@ˆÀàý²Ä Þ’:xJ— þðßM ²áµoFåѨNoóž={Ê|¤�3†tÂ=gΜRŽïÀ ÃAŽGŽYU·Ü‚PƒWe˜0ad>&PtÏMHÊ€„RzïªôÞ¥lŒ#¼ПüŠpB¸¿)Âò2úy@cuä[°ºÆ™áþ„~UªTÉŽlWõ@Vc¥HqxÎ뫘Pˆ:Ù®êAjK™~oUiØBn¦OjbB޼0L&èd»Lüö¤9âs`õÖ´iÓìw¡o&ÛU:&~q_G óoÒ`uëÖu*}& ‘?ß‘~†¸nB� m„@œ`þ ò1¾ÌX’ô�BÜE¢>rp§˜ úž ›YxGŽ•"EŽBa†³¼hÉOX‘Â1´x>昡WmS˜FÀ�¬9òÑÕKgågɼIb’ËãDzóúõïÑ‚ž<º/“/ ]¦ì*›·Œ#À[üòåÙ7 é²2Ë×l¥ÙË—'+%Nß7M{Y÷ûï=_áÞ¾³—!IšØs¥Ýî}GíÚÛ¹ç0]»q×.ýÍ›w†^ûwb¢V'Tax‡#8i@Ø�»©P醔³H-š>w…¯Éö€è³oÎQ¥J‘íêœX­šBGËù•uêÔÉKâZ•õéÞùdzèÐ!ILaŶ٠ù«K(�wUÞ“ÊÛyðô„7¼#ƒ;H)hÛâHÉó€üBA�lÇ=R>ÁŃÒ6œÎ„Tôß.¿|fÀ=1îܹ#å_t|U°T�ÅjòOÏ×÷±â'[�ÌŽ>*ÎäbÌnÐÊôŽ&1Ak6èÊJ–,©ví¶¸—+VL¦ëuô‚ð€·²"Pƒ d–YV�T7lØ ó ‡\Œ=ÜÝøJâšÜø…Ю-Y‘ž{f7ú•‹g"‘¹jÛ))[aW�FÀKà‰ß°y'Z8{¼\éÔ³}}5¤;ÅO�„Þ½}M÷ïÝ"�…a2kø¸¹rY¢— sF€`?A R¹b&t(‚¬Œn¾•“ÑÛr´/n,zûîƒÌî?ôjR¿ª$«W.%Ó äÍ.žn—ûÓf/—Ò)ÍVr"á„'þqê3h¬eÓÑ¢E¡dIÐmAtÿ'HÉêõ;Ñ�þ)cúTb™÷;Ú¼}? 5ÅЪG#'N_Ò3EÄpÏ¥ç–�û 1©èË–ÕÓhݦÝRJfû®Cô�ð|ö�ý È‚ðáà ¢ã õC(±J8Ô·}q,Ò<�=Ò=�‘o_~ñŠÍô׫×2@¼±êåÔÇÕcxq+¯CŸŽdu·nݨO�¸4Ѝ†§b—.]ìšEÐ>9…g¦2HÓ ¬™0�‡8t‹áÕ©èA¯~ìØ±tíÚ5#kÇŽOKÄ#K™2¥œÀù@ÊC§X™ÒVÇØ"°æ�€¡Ž`€åÊ•#H:@êAAx�XWúô¨™�õÀ¤˜ÒÔ‡TOÑ¢E ö ºHÐ<€Õè/™ÆF `ð/„1�‚\Ÿ+¼Îñ¿{ñâmܸQîà Þ+CàRVáã•aå“Ù rᕹRFµ¡îßøÍ½֙)/zè»CJÇT÷|Gù)S¦H-yÔ‡Ü d;tßáµ�X ÁŘp.W’ÇÁ2æÙcáÈ=âÓ3Aè®ÇŽŸæLM¯þz!ôòË�>ª¢¥*Q×ÞÃ)Eêôz2ï3Œ#Àø3‘#G¤²% ѺÍK°q:x…תæÿr2¥Šå§«×ïÈnÚ¶Ÿð‰= )½M‹:4vâ\ºÿð }DàÔÙËäGV²fJKI„¾Þw•×§{+‚Ž; Ò+%*5WYÆu•Îû¸IóiËötù¤}L£‚/v"Fqu*ÉÏ‹—¯hùê­´xùF)}ó>h·G§fôëàn>¨i]e÷þc’p‡×¶"_¬KLjûöí $8HieH‹-š:4¶ 8V­Zec$6<ÂÍÁUAªCš¥sçÎ6å!¡0nÜ8Â9Ì$ d^ eSéÛˆõfƒ¬ ¼áx™=�ž¹¬:F[Ês“�ÔkÀhúcÆ*Ú°÷Mœ½–ÉvßA̵FÀÍpöbØ]×eeЗÂr¼ÏýÛ÷í@  6LhãTº£CذahϦ¹T¢H^#;˜@Ú® ³ :ïVÖ²i-š8º?ÅŽé¬]/“%cÙî郫(–ƒúzy¿ÞGŸÛµ¬Gw,¢ÛvЯƒºR&á}ïC0Ôàlfovåõn5fh/^ÜFþÒ,ÐX7ÿßÁ;ßÐ‚× Ç�®á ¯Dx¢C6¦D‰v^�ªd† &½Ý•ŽÊS[|=|ø° üjî‹*ƒ-$†*ñ¡ïÊ@Ú °!dZ­ ^ïfMdLJ¨±ÀKr6zW´rL÷þÇŠ�fÊÐWJ®x¹ª:¼e¿E@¿gØq¾Xõãß–&My L”šW™Ï­¼áq?4{·ÃC^Çß\Çðr‡)Y¬ ÂJ+�õ 6”yÁå{¸—+Éã`Ü ¯n´nÖ]î#à¶àáAUÍ�UݶÃÜ1F€`ü¿~yöMW•絫mT([„þï­ÇRrs�Ûvš“G�•Ì)?Ï_ü%%cbư%BS$OL;±þ@x¹_¿yWHм§Bùrˆ€nåfNJøXYûVõ©EãtîÂU|õ¡ œš6u2›ª7În“^æ?}¦œÙ2Èfœ�Ïê<¾IK"tê{wk)?.]—^ïKVn2‚Å:jûë×àM¸cÜðT^ƒŽp@:¼&wíÚå°¤U”¼Š^¨wïÞ„�Ùൠe��9vLÄoì T%J$‰*�MºÎ°*oÞ"à*´Ö>|(½ÏäÒ ìãÅ‹'Ét�ÝŽd7n,²=zTÊÝ€HA�ó+I„‘#GšO+�ñ¯U¯¬|ùò„#À¸:á×Ï h»I“&RZj®�•É–-›Œ�ûŸ«d1b1þùçŸFÜ GÈ­^½Z’ß™3g–“˜ŽÊùEº"ÜÑ~yÞcõ¤´`z™àâèÜCþ Ä=<Ý/_¾,W2U¯^݈CâbSn_Œ w·¿DÜÁ €ÀçÏŸéÆ�ò¦r,$šùÇLÿ¡ ‰xð˜F€`F€ðobYx¢ëçL˜ .áã]ƒ—|åǪ®”Ô)UÈ*+ÀÓ 1?\x»Ø…Ž=#ôÞ7Jé™çB‚Æl!�p7�9°ŽcĈ!=Þ}{~x®ëÞëÞiþð§‚üy§.—e� ‰€ÎC˜9 ¿wHK!˜©Šk�C®J¿`ÎìÙ³eŒÎV24çÏŸ§:uêH�t%·â}wÔVõà>¹gÏ9&¬ðA, ³Íš5KäHG ŸÚ­_¿>M›6Mz¹+�y%æ“6ݵKʸë•á~�KáaQ @©ßd:ï‡õ�3?ì7Å0Œ#À0Œ#ŒÉ’?o6š8ægzt}mY5�Õ­L‘"†7FýÅäÖÈàF€`�`�€îX)rüǺuë$f®ÊÉ 08£Ê•+Ëú ê!)£¸l\d6bKÄŽ[– ˆ ƒMX1„UIh­Ç¾@< Ä¸èØ±£ìJ©R¥|µºGÉÊ,\¸�dò_eÊ” ˆaè9ØÃ=@áæ“G&¨S§N-?~ÝpG3fÌ�Í"ˆlp5&܃ë•åq1~€€ZÒ´gÇfÊ�&ŠÓ¿~ýb“_©HztÃ&‘F€pC¾~ù"ôÃR‹úíݰwÜ%F h ðõëWé¨þâì/'àFF€`F Ø  ?7Ø9›Qí�,Z´HêÕlj‡êÔ©´ã¤÷L¸;‡³��ŽÀÛ·o%Ÿ?ô6>©ãí“pF€`üÕcc÷GÀ2Æý;Ì=dF€`�C€ ÷ƒÚ['Ú¼y³Ô‡üø1-X°@ÖíÑ£… Ö[í¥ÂL¸¥«Å}e¥¥U p)ê5p¬Ó³¯_µ�fMi”™½lňÛ8æF€`Ü�e²Ó?ÿ|¥Ñ‡Q–lݵ›Ü/FÀ­øeÀo´o×A·î#wŽ`F€`‚7L¸»çõ½yó& 8Ðè\Ù²e©[·nÆqpÜaÂ=8^U#àÇDFðŽÔé�¶#–-¹ž4yjŠ7¾Ó:œÉ0Œ€; ð¿ï0A�ˆ‘"¹>s‡F€`F x!À„»{^Ï¢E‹R÷îÝePל9sJ)™àÈœ w÷ü.r¯� ‡€i�·þCôÃ=fF€`w@€c°»ÃUà>0Œ#À0A�‡` w÷¹f™2e¢Ñ£G»O‡ 'ßÀ9øŒ#0ÿ˜é?t!`ø#À0Œ#Àt‚Ÿ‚ÈE ¦ÝdÂ=˜^X#ÐØý˜±KZ@_>#À0Œ#À0Œ#À0Œ#b`Â=Ä^z·8KʸÝ%á1A3á®ÿÐÍq¯F€`F 8#péÊ ºpéºÍóçÉF ĵI³:xõê íØsØ&+UŠ$”-‹ó˜76ø€Æ<þœfÍšeŒ°V­Z”"E ãØ�w®^½J»wï¦7oÞÝìÒ¥ … Ö8j;xW;zô(>|˜¾|ù"»=ztjÕªUP ÷—pŠ€ÎC˜9 §9“ðc˜p÷c@¹9F ¤"`þ1ÓèB*&}<ÿ—2fÌèm¤ýªU«¨lÙ²”4iÒ�óÁƒ„¾þóÏ?6çkݺu�&Üׯ_OU«VµSªT©˜p·A„‚úsƒ™£ãã1XR&è\+î)#¤Ðè‚Tǹ³Œ#À0Œ#à¶ø÷Ëó²U[èßÿõrüKWmö² `ß!н{wjÛ¶-Õ«WÏw y£ö÷ßOÁñ=ãbcBúÿ¯?3„G€=Ü}Ž×d ó�™þC§ã]F€`F€`Ü�'Ï^Ðî}G©Tñüûxïþ#:rôŒÃ|Î`¢hÑ¢Q³fÍ (%Jd컺ùØñãÇéëׯ*T(W«ú¸\¼xñèÊ•+RR¦oß¾/ûà`+V¤“'OÒ®]»¨W¯^ÁaH<FÀ�‡0s–1ñöíÛòþæ¨ ß}÷… ŽbÆŒI©S§–÷UGe9Ýý`ÂÝý® ÷ˆ¢ü_í7w›`F€`O¯Øè”p‡ˆí>ªQ¥´]ë×Ù ÂÂ;yÒ„^îèó¯c¦Ó“гÏ ¨1Bx*R0'Mûc°9=oÑZjÚ¶/ŠQ÷ŽM©UÓÚT¿E›s…òZ×§1Ã’/â=ú�¢™óVÊþËŠâOœX1hÄànÔ´¡õoÆÓ¦Ë`:pø$}Õ‚D~/ž)råÈHSDY2¥UÍÛdKÒ�{�äñ——giËöÔ¶ë`zôÄC~#³˜ÀÀä¬A튴pæ(¹oþ3vÂ\ê.ú +$îû·-0ác îÝ»G�:u¢#GŽH©I� �ô”ìܹ³M�[·nQ—.]èèÑ£FYxŸÃ«mÀöíÛGƒ ’„ºþ?vâÄ Š1¢Ì›7o}üøQ–�5* :”:tè �ÕŸÇ�Sûöí R0 ¦uCàÓÅ‹ëI–ûkÖ¬¡Q£FÑÕ«W%Ѥ �PÖ‰4¤Gˆ�Š-J3gÎÏ1öd˜$˜0a�;V䪭~ø�Ò¦MKÕ«W§Þ½{KÉ•çh ’|úôéÒ»T°@0Rœ2:VöðáC?~<íØ±ƒÎŸ?o÷Û ’¸õìÙ“¢G·~Ríþ÷ß4yòdy¾;wîÈÿ}•Ò°Ûž={hĈ’œSùζÐË_·nýõ—ç= >®qóæÍ�Uå=Ø¿k�ÒÃËêáÂG t³Q‘å©Y›žnE¾û6^‚âÃ:æ"FòsÂ(ðV€¥w(x4ùph6ÕöïÞL}»4¥×¯^éu·¥þÃ&Ǽ´èÑ¡/½Ä¡w $„N¸?zÖO=•MD�ULˆ&°iîè¡ãÔ£C?™V´DAA¸O³Éé^áÒñq·ñ7¬SYîè×¢e, ÷¥BNFYÃ:•èðÑÓêÐrûêÕA”÷¤­;Úå¿ÿðQž/wÑÚ´né$Ê™=£]$”48'ä{ô1ÙæªT©B €u!Ó£Géx+7iÒ„2dÈ`#Y�j”U«#áíž-[6¤«n åu²=sæÌ”.]:£¼¾u«\¹2•(QBzŒ£mÕ¾^Æ«}xÝãf¹%Õž¾�92ᜅ ²iöÅ‹2r+Êà©_ªT)Iˆë²+ZX«V-9 ¡ÊZmÕ»$òåËGõêÕ“šè 3x÷ÃcþúõëvÕ!Á£ ãJ™2%U¨PAN€WcÅD•-UˆÚuBSg/“Õ:tÿ…Nì_aƒz[W®ß¦:ÕËѬIC…ćDŽòë‹þNž¹T]¼b“˜ (¯W£åk}zÚ¾}»áe�3gN:~ü¸ôä©>kÖ,Yö÷ß·ñZ†W¶òÌ.P €”„‘¿ýI“& M›6�Š)B�4�‡=Úi¯¤jvîÜi$¡� §½c 4 |`˜D€V: zåf}c™añ§~ýúF=�ÉðòÇø9Ž•†�\©Q£½}ûVê#wëÖMz�Z4g$aüðfÑ­ìÌ™3Ô¸qcy ¹ƒ ŽØü¯ 4Hì�ÀÁµ3뵃dWò>�ã±²áÇÓÉ“'edlþøãy^Uïb�áÁù­V¨ræ-VT«V�T€ZäÃ#ß…—¹3þÜ`æ(ܹ߮ô 14`æ9¸ïbB†ûP¸páä¾ùî=_ÅDúÊ•+åýOåÃk¾oß¾ru &÷tÃ}bæ‰M½ ï[#À„»5.œÊ0¾D@ÿ¡37•#wAªßÌVóQ/3°WkZµd¦Lº|á4ý-~XÂo’�n¡B…vˆÛ›×bqÏi×Öµ¦'�îÓŒI#¨Ÿðz lkÑî§ÀîŸß„À]1¹¥¬@‘2T¨˜×^šªnÃÝ*ú÷ËsƒÚ•$áŽqƒ$Ö ÷¥+7p@~Æ+?u!Á»6ôçNÙ®×6  ͘»B–›4c1õéÞRhfGЋPl U'Û‘™DÈ;%¤úý‡Odٺ³Ül¹²g2’|“†B<Ëwî="ó Õ>zXO;b ÏqÃù¿`ézú ä`Μ¿B'O_¤ÜB·ÞlðlŸ3e˜xÁ·}VkÖ°ºA¸Cvò:Ñ„ü�2µZÇ�ëUQÉN·Ìj>�Ó Á<Dˆ"ÜAò‚pŸ={¶1jh°#Ð)ˆyè´+óqOnh—ÃC/Ë:uêÈ�jÏ�¶ðì‡V: ä$nÌr3ð(/Y²$­_¿ž - DzŸ>}d T«ñ¤J•J,4‹…÷:äd2fÌ(W@îd>Ú×-W®\Rמ©�†�g=í¸qãR̘1�¢Ðç·2]ò'ð¦× ÿ³Ðn‡D¾˜TÐW#èeÕ>¼W1Á‚@®0à5iÒ$©ï¯Êð–jè<„?3$6´Œ{ LM�úÅù±R©hÑ¢„U:À:ò±cÇ–‘ø}ÁobC@ò*wîÜ~qÊÓKÊ„˜KÍeü�o/”ê,ú�Jsu[¦bM£(¼hž=õÙR¦¯BÇzÙÛ6®  "0$ˆ{ïØgñðyîôQÚ²~�>q˜þzéÌ;mTÙ(Q£Ñ3VQ“VÝŒS®\<ƒž=qŽÝ£w m¡?¯tÅ�açñÃ{´{Û:Ú'´ëoݸbTÊY—s,_þþ›ŽÚM{vl�ýÆ÷Ö¯ ßC|ÿöl_ï£ï ê;²—Ö¯Z@O?”Ýzÿî­Ñ½H‘<É#QÛA`Uüàºl^»„ŽÙçí~ÕëªÁÀ»ÞDà³ Åíû“vnÝC7®Ý’‘®4�z'��¦[vÓK-¸¤+uQõ�m%Y¯¿ âÇ»dÙjÔºK§õÍý6z¶¤5ËæÈ¬ÈQ¢Ò´…[)SV™syß·êЇ–ÍŸ"&ÎOÝúްiý™1ñWZ8k¼ qŠÀ«¹ò¡�#¦Rœx Œ:Ãt¦Ås&Êãl9óÓ‚5Œ<}g̰ŸhÎÔÑ2©r�F4ü÷¹rzå6eKx.‰G¸g+µil;n”-WÐã…7JÔètè¼í„Îí›Wå÷æÜ©?mH½$ÉRQÃ�¨^“vêtƶt¾ä„‰Øé[Ÿéàž-4¤o;zþô±LKž2�˜¸,÷ÕŸ «>°YKwPžÅåþ‹çO…^ðÚºa™]Àcx†��»÷Iè�•¥ëjÕÿ�žVµt]:sÒC¦@a=r|`ƒE è&-¨,c‹ ­ÝÛ÷ÿûåÿ¶ÊÈ�9 ÕŸri+»yý6ýÔy€˜\:kó}O–" 5k݈·¨gW­`ÖRòvýÉÚ»óõÿ“Ͼ¤“g�•`õrï£?E ×A}~¥ûwm†ŠZ´mB�{µ³ôBƽfÒ¸4gÚ›‰€ðB>#OþœôëØA7~£=Ÿâg4àË�+—®QóºíÄDóßâÞÊ—­…¬ê¸¿Á›ÁHá�¯ö®šÐ‰Sèæíû ÈÎ@~Æ™á;£Ô*ꊽ²˜üñê\h×Êëûûï¾·<¥Þ¯ÉY–Q‰)’%V»b<žD½‘(vM LóF5ÄsÈHY|‰X1ðc§ èÒ+kP§¢�ü†J7o1á1GzŪ€0aB›³Cä±N¸ÃäŒ. PT$­2³�J·ÚB=¨¡*CÑ'O�>~Ȇ|DÛ˜PÖ¿# íÛÞî;Ž|eˆ‡Ð¥UMƒlWé®l_<{BÍk—ÒNÞ¿³«‚—Gx¼7©Y”îݾa—”¯«Ý`8Áe^ ¢°^Õf´mÓ.² \ ôÜ<<�™òG™(Q¢E¡s¯“í)R¤�é#FŒ�šÉðÀ÷JâGoïÝ;ûç2ãd>؉ßc¥ îWÐnïÝ»·�׿šä*Œ@ " ÿVyõ¨õÁÉÇ�/W¸èÁ¬}ÐŒM¬º�!ân˜­aÆôúõkù£<›Ëð±5O?ÖyœÊ0Œ€Ëx¾ŽyTÑèÌ�Ü¿w›Nµ÷’¾vùmäå©ce•ü…KQ÷o^Qæ6¬Žo^¿,ÈíÖ)ƒúu·%x߸v‘V/™- ó„GõoC{R¦ly„®­çfx¶Ã›[¼´4ï(ôocˆ@¤ÛiÕÒÙtáÌq)MÓ®I%Ú~äEˆI·Ü‚UzôðÖŸ¹d‡N™Î²¬_%&O™ÖhêÁ½[Æ>vÆ ëE‡ön“i)ÓdÞœ¿PZ�4ß— ÏøMkK‚¶™ [1>LÀ?iòÔtç›î÷ŽÍ«$.zÃ×.Ÿ–ǹbÄŠCy –гîíÓNbŠðfïÒg8åÌS˜ˆïÈn!¡²tþdé©�‰ŽY“Gþ?{ççDñÅñ'X�Þ{•*‚ˆA�Þ{Gšt)‚4,ˆŠ"½WiRE@zé½÷.½ úÿïoŽÝÛä’\r—Ë%Ùßû|övfvvv滹ìæÍ›÷¤•fÁ¯KDÆ¢Ÿë�ýÜc•«†6�>“r•jk »'²xÞtu¿±ÂŠêÑC¿–þß�–œyòËðI Õe»¶­k(èû7F’$K!ðϯË9-hp�� >§X•ña»On–âÅO(;·®Óîa5Y2{ÚhíóO³¨Ÿj³¬ÕÃ�'Îͯ1…}öœy´ë¥Tn„09y§p iÒº‹Jg{¾òãçú)×8(Äç¿eûòŽè8yÊ4râèÕLJA1?GãÐí³Ðø8'�ï+úŒr`ß!Y8oi¸C+Qª¨öY‰/}¾ì.wïÜS®Sæþ²@�W¸è;†ø×s„]Ù‹x|f?îÞNà3þŸ'ÿÈü9Úÿñ´yÊÕ ¬ßþqŒ|3¸ŸÑ�³§ÏIç6=”‚ç¶ý¸…²J�Ÿ žæ¦i‡ ìÿ£RrOŸ4[â¾Wzö ]²o4¢%PŸ÷äš/é‚…ßÖ&ãKJJÀ.m{J6­ï=´v²fˬ}n‘SæÊò £§ª1š­ÕôûAÖ­y.½ž=‹tÿ¬“Àb“S'Ì’…¿.QŠþúÕšËÆÝ+$Qâ„âgODÓׯÝ�F5[jßã7Œ&^2K`_üxÎ÷fNÉ©}>iÝ;5¿åG��–9ó—+¦©R$•’Å |�%ðyÎ’)½duîÔ!’9S:gÕ}Zn¶H?yê¼ËkŸ`µßøñ!q©p\2ôéÓ'ÌŠÜ7W°ž‡¢ Ï9¬dÀÄ€>¡â¬?à ÿW¬ÕÏÉ”)“r!…Ú¼yóTñwß}§ÎÂŽ}pWý<îIÀŸ ˜ÿ�ÝýÞð‡ñ ¦„½…9ú…É>L¨"Ð)V,!.ÅáÇ�Ý $íj|XÕƒ8˜Ìà ¸£ªX±¢ ÌŠï²—4à 󤟫¶xÌ–î¶<˜#ˆ û‡Ù âüÇ×ÌÉ#›+É£)Ã?_["ÛU5›c5e¹nY¦b-4âcÉSÊÔé¤h‰òÊ*xÎô1êPîE�Yá@áþçò…ŽW¬Zß`м3Ù¹u½òÕŽãpg3}á&A? àU pq¥Ðž:nˆ*[¶p–¡p�ÌXTc^øƒÏ|¯/†Ú²ÍýæÛ;N\å²—À$$Qâ¤RBsÁ1/ñ‡û{—I?|Ý])ÛQ÷«'HµÚM�T’:myë�bR½ôjâg攚Œîjeƒ^GßÃ%Mù*uåËÆk÷5Ž^¬ö§O1òP¢ë}Ó 7¬ ]öܱû—R¯q[ý�$NRR¾þq¢Ô,ò£“f ôûjK0¥Ó¬t±…'KÖüªî åWUáêE(¡K•+¡gîûiߣfW3yòå–8šÛ¸c�>úÙC~Àçƒ køA?-µêWC±’´ZPÈw ç—2ïVS®Q¦N˜©)ä?TA@õ:úý¬\½¼|?ì+íÐùs#eª²à�_´ïœw õ4wå«”–ÂyJ+kuü_=rÜps@³ÌŸ;#äû-‹¦l\ôçÃåL*M¡Ÿÿ�|j|¿hJ{X»O5ESÈwÖÜsEŒŸ>žˆìïiþ¿”Ñæ@IDAT›Öi#çÎØ*P_ÒÜåP<'ËìÞÚw<¤C·¯m‚“B™îŽdËšÁP¸oݱשÂ}ÆìÅòø¹[2Å�Û¨³Â}Ëö=rúÌɘ!M˜KÞ¼y[–¯ ™lÂAóya*»(@ðT(Ü!X1pçùê äÝ –:ùùÿ!ÎùCë|ë§Ô&?("P¸CYb–F� ”¨p+W!º@i‚ª�"fŸéýõ—R™ûŽ`§‹/VÊb󃻸@@ðÐ#GŽÈÕ«W¥J•*²víZÐ|®ž¾xñ¢R\!�À€ÎFZ·n]›*XAûÓO?É”)ST9”Ô%J”PéãÇ�Ëýû÷U>Ò{÷îmóŽŒgõð¹îJÀÊ~0€‹²…"¾ã ,êqïQwÕªUN' ðû »9sæüÉÃz2cÆ åÓyþüùT´9Ì2¿&¨ ÷téÒI–,Y²E ÓÊ•+« SÄYÀ÷Û˜1cÂ�Óà°1»B1”ízö­;öR~óÁ<]†,F"3sû‘IÇÓÕÖÓVPØË;EJEχ*+�B |Žáª’5{ne»~ôu¶VYLŒà>9X¶C1n¯lwT×\k¬¯~˜ Åø]mµ¶2VéB—3ßµû?ôûf°,p›,ã?ø°~˜ú…‹4ÊΟ½šÖ‚–®xîVçfe»^)]†´Ò°i•…B{êø™ú!›=,Û>À¥²'´h×ÄP¶ë  ß9r…¸d@™¹�“ÇN7¾7?éÕÑP¶ëçb‹wý{ý{pÿ�ù°OÒ�5_í-µ—Cl'4pqZ(Fì4Ôü¸ë¦«´•º¸ãNF¯Û¸AU=)_?ZS¼…ýlŒÒ>3´ê!-;|.§Í�re;:”^›Ì*]¢°êÛ¿š²°[Ÿï ƒ½Ãx¯ëÙo°<ÔC`‰ž?_.ý°Gû e‹ £Bvh¾ðG�Ÿ¥Ò/jʾ†uÃÆ7QM Ðœ6k‘Q‚>O›ò¬4 -œpä"Š(i¡x7 ¬í'Œà*A;Ó¦M+I“&•íÛ·§,XP•¡ršƒƒµüŒWªTI”U¯oV`ÿñÇF9ŽçÊ•KYá›Û°OçÏ2y‰rŒ×8p |òÉ'*p ,Ø¡Ÿ={¶*ƒ(ü ×½þÝKP(²hîRp>ÚA>Mš4jƒRÛ¤I“Ôw~‡”âëäÉи0ê©W¯ž@±�ã_ýµZA¿™É—_~i¥E�T=àìÍ›7J3¸méׯŸ œš1cFÕ��;wCß»w¯âŒ1šeôèÑꞢ uœ[£F ¥(‡U:ÆKU0Ã}@ðC¸�@ðCȵk×+p·|&0i`öÙ…øàžCO!�@! ¿“¡¿ö:Š@ƒ³~~øá‡‚É;”äÞLâû+hð]R¨P!õ ëú%K–¨ïLô™ãÛyëÚÁÜ΋Á<8Ž�HÀ‡´ff1?èÌåH7iÕE*;ðñ}ÿþ]Ù°úw�˸AÍ.mê¨ �°xw%æ@�y5KíTiÒ;¬_S’ÂÒ.J 8ï�|ïˆÙâ7Ëë¹4×!~/í�‹l®dÔЯ 7)¨W¢te±íêo»ù÷u£9XŽcÌ�ãGöå¸?»4ÿàŽÏp1E=ÀPü‚gþ‚Å”+ ¼¸€Ÿ´÷ “�Œ™³i®B9j_/;e²²~óypQý˜¾‡;“¡ã~Õ³Æ>2c1‰dŸG~ì’j.[tÁ„‡'r\s×¢KÊTéœÞ#ÞÕåè¡+z=¯ïëhŠòX¯†XñêeîìaYùnñ²6U?z¤YÍž�3§�Éу{�•6•žgý¾:S0”•¯RFŠsý=Šq¦J�"ÂÃ}={f‡ÿÉLV¨æÿ‰c‡C\J¨ë¦I©|¸;ºxüø¡ßLJuTE6©£}ÞÃN"ÚWΑëuû"•7÷ñ?Óÿ-‚�¢}oÂϼ#�åü¥‹—µå¸÷U WL øJÀ´cËOdÛæP…�ùÚ�náîê}ÂéØÜHGubØ ÞòfáòTS"Î_¼J*Öj#í[7øš? ¹{™0už*G?0ñ0üÇÏþ»ÓO(@1ù0觉ªúÕë«=\Ë$®ˆwÕΪ5[äâåk6U&OÿM>íÜҦ̪(EáäÔ©S ”ººë“Ö­[ËÈ‘# 4ŽÜÉ@y;s¦ãÉÌ[·nç"qãÆ 2dˆÀÚÊd³L˜0ÁÆW¹ùÒpo‚óuA¾å?þøcyí5Ç.{ôè¡,ÀánWpmgExêÔ©Õa…Õ?”ÛP!�,Ü0„'x¯ƒÂ{ÄÇÆ 8ÇŽjsÔV�:u¤{÷îÆ!¼SA‘Ý¢E UvèÐ!ÁæJ Ø‡eüàÁƒå£�>ø|‡À­ ,ÏkÕª¥”^“Ù��£6q®>ékõ¹sç:ªf”Á‚Þ,°ÎG_†*mÛ¶5â˜ë0MþFÀüÞl wŒ Vð˜õ$ 4î&WaXåLðý‡ Úz`m|ïÂ�Í Aƒdÿþý2kÖ,)[¶¬4oî»wg} ”r*ÜåN±Ÿ$`Ì:û®§H™Zr¾ñ–}±Êß4¬ÐV-¬—B‘0nø·òó×/ɧ4ÿíº¤Mòbªçí÷°8×åäñk@Ý?9ÊÓg´ý¡×uw?ïf™1q˜æf¥žRì›Ë£*}ãz¨õyÚt™Ôeð²afÔ¥u·.÷Nè-X¹ë¾÷W,ùÕP¸›Ýɸ,?w:TÙæ soŒÅ­Á‡S îw‰«Ï¾£ú沓Z¬]À[xrÇt�Ìu3E2VÀö-keÁ¬IšÒ£À5‘»/¬�~_Í ƒ)ý¶æú¤I‹Q:$¸Žq$PÖ9’cGBî"ð(¶ðäÎí»«dÑüm»#ÎÜÍ8ú¿ÅgþıÚn׬³;—g}tëäTêÙ¹Ÿ6 ºÆé™�4Õ~`vóûö‡½š‡[³Â½Q½Ê·?æ§þR½AGå>ák7vü9 ¹Å«YµŒÇíGô„ÚÿÌØa_(w9>’•šR›½àó3°y·�ã÷6ûúÎòÍU7îzwÝÉ Xª½Öþ7·inz xÓþ�%óp  +ÜaÝ® ”ï 0ÄŽîeÊ”‘Ò¥KËÆ�5·‰!+ôóí÷ $Pn ¹=€•ü–-[”Ûw¬ “%K¦,ë�)ÛqmôÖ•°°†½½ÀŠýÝwßUí ø¨Ùzù’%KJçÎ�Êfg_èðY ÅtíÚµ•2ŠsX䛃¨Â Þp¹`/° ‡;–jÕªÙX¤bÒ©W¯^réÒ¥0Ç1ÆråÊÙ¼M˜0¡â¬+Ûõ“ªW¯.›7o\]¸p¡Ów3øƒ‡Û LŒ$NœX�«wX±â|L~8XÕc‚À`Rϸç¢Â]'þž ÷ð± �€Â<Ì´Ù׈ ^Já3A!zUWíyò`5÷U?ï‰äR—ØáBÕë¹ÚçÕ,¶¤rÝŸKÕƒ±Ï'ʯ¿ÿ%/»\äª=OŽmß¼Ö¨žFs?Á˜ÿý/ÔÚ:{®¼6?JŒ\$ÊU®£•ýXüükû-�á5ÍŸw2±q'S£‘‹Ba"åéÓЗ}³œÐZŽSÞ‹ã–£¿Ôlý ¶Xmž$KžÊa•©Ò:,w§päà/dä�/�ª°¨=GÍß|fyó­B*�jçÖµ�ãz‚÷U'Á½;þý÷?£Z’¤‰ ¿éF¡ƒDr“µ¼ù0,̽-ø®1[»çÒ\j¼ -»÷'ùF 誵uÖ¯` šêlœQQ^»ZYé¨ùoòÏSeåݨ®ç ÷¬Y2È_~•Ÿÿ(“¦Ï—{÷Út®Z>ïù‘ÔÐb øZš}PCŠ~KÚvþBÖoÚ©¬Ýõ>ÀÝK�ü¹eÔ�~ò¦ÖÇÈJNmu@Á·óȶ�!JÓñ_“ªK†Ûì]-6ÁÍß‘Lš¾€ ÷ç`à›#1»ˆqt –•+W::äQÜÏ„w-�|^Jó={öÜ®œ>}Zù‡BÁ¡�Æïg79 Å9|cƒO{¬ À1lPüë¿Ð¬<áÓÜ‘À] ¬ÀázáúõëêúèG† \¾W7iÒD)ó·mÛ&ÇŽS oŒ¾æuE6ܸ#à k}øž‡õ9,ÿá.n&àÓ=UªTòÆo„éƺf�óÉY\tãÎ]`&`þ6ÿî÷ç>»Û·ŸþYàž bž@Åwš.øÎÃd›½`¢Î^àz¬oß¾ªM¬ÈiÕª•}õ½å>Vÿ¸š s" ÄùÓ‰pH€HÀÞ~˜Å�ϸ:”þ£-›t¥¬Î”%‡QÿüÙ“FÚQâü™Ð㙲„øíÍ ¹BÑåÊÅsz2Ì–¾çÏ…X<Âu‚�ÚËÛ…Þ“‘“+—,UÞÏ©ù󽧬ËGhJÌ.½¾±¯îÕüQ-Hç¶M«�6‹½_^¥añè'�…,cå_‹_¹ÇY±ôW5‰°Js+Sª| Ù³s³º&Ò¤Ëh\ÛU?f ¼…ï|Èe�yÂD!þ]íÏÛ±e�ü÷¿Å\Þ· +ßó‘‹ý5ü%Ÿ!S¨õPábeäÛaS#ܵ/DL1¸w×VCÙŽÿ¹�C§‚›­ÆœM‚ñ¾FøvYòÄL™C]ÕüIíž²Á¬1">Éë¨=”á3Ÿ>c:9®Y%CFN¢ò*ãÆŸ$Ø\ ~tâÿ’â˜ÝØœI„ñåñ�—iÎêü2ñÁæJbÅzE~ú¾· ý®—œ:}^ö<&±5HYµÿ�LOŽ6Õ,±¹’ +¦»:,¯gÍ ÿ»ëÚ}E­«OTËÌ9)ÇOž•ŒéÓH®YÆ,Ð/xú€c%¸~ÜÑÞlõ\·Fy—íëçÏY°\i1 Éìù¿+¦àK nø.ƒ¥>¶ˆ¬Øár[dß§mŠ-XÒcó†À}ŽîBÇí± �ªpÇDž£ é0hª¸�Ò'Vá6 «gtÁw&Û°Š.±à‚Jÿ¾|øð¡šHƒû°W´ßvpG¥ X•(QB­‚ /ĆÀŠ'] ã™6mš±Âu)î ÂÝ}V¬I$à‚€½ÂÝü sqšÓC{þ ]Öœ4yJ—Êv4bvŸ±W;~Å)ïܺ)×.7®«+ê3šçp¥%¹#«ëîí ’�ý;T¸7oÛM ÜWm�5÷8ú~¬êO=HJW¨!oä�Ø�Õˆ‹?×®\’/z´5jÀ¹z�fF>c¦l†Â}Ÿ6†t&×:F%-±dþ íA²¤¸jí&6~¬<€Â²bé<¥�Òï½»ÁRÕÉÚ0×îkW.vèfhÓºÒæƒ ê¬X¿çŠJ{c,z?üiŸA»Gºìß³]Ml˜Ýú1Lœèÿ#ð±^Œý?XÙ`/˜s&¼¯ÎȰܞ@¦¬¡t{wíwúy?®¹žÙ¥¹Ž€¼®ùFϧYÉúJ2k}Ôî»wîuªpÿmîbyò8dÕNÍúUm¾7£¢¯°j‡u{x Öí‘}Ÿ�‘/�c,™3¥S›/¯ëεð#–ìÞ°fwt½š"Suiݼ®žt¹Ÿ¬Y±;“Ûwî)ë÷Z€[ � � €€ù½Aÿ�dŸÁÉ“'�ò§n^Ý£»­êر£ ˜Œ‰AX¥CÁŽ•=ðÝ>jÔ(�y³ÀbS è4\Œa5ŒîÎ A§¯^½ªªÃe–9°²¹ ¦ˆ˜ù›ã¶XJ$`aö3óƒÎ,° ?â[™?+tYìy÷FAPÏBEK©KÁ‚ꇯº ‚™}<°—æ,Ä}L¶œoJÎç>_Ïþ†`ƒ<|p_ù�7Ÿ‹4ü—ëÊväß/S;—RO °ª+CѯÏ4×2O�øMtÙ�“ƒ›BI^³l^Ù·{›Q³U‡žò’æÛR(Ëu3l€§ž×÷³¦Ž’ž�šH¿O[˂ٓÂ(�p�L!;´‰‰y3'¨4ò嫸÷ãY� ý1Î�=m´\ÖµÚË„‘ßEÅKU2,5½1£a'b˜¬Mh�‚Í’%[.�»ÈYÍÇ=î�½àóÙ¾yUu�pŸÜÖ›råÒ£9s_õB|ækŸ7gbÕûêŒG —›'|îkA½)¯k.&à¦rZSÆÍ�V±öàþù°a{éÑùsµy»á�§FÝÐïùŸ£MÆ>sÊ´‰³¤sÛžª³gÌ·ùÞŒ ~+_-=:}¦Ž ‚Í;Æhÿ¾áhÜ,óW®^×\yÜ—Óg.(·5z¯ŠÌ+ùóåÒ³N÷PÒoÚ¶Ûéq˜ìà{Ãå ³ê/üÉ™ç-£•y3ÇKÊTi´•5µñääñC2müO‚ º\¿zIõ¾äá‚Æª÷Uçá¯û¾&Ã�q«{ó~Ÿ!°ì†$3ùL߸n«ö1]R¦†;­ ’ÕÍ@¥Î.ŠïǾzJýªÍT•ž]úÉéSg¥lÅR’$i"Ù¶y§ü:ó79ö‚:ž=çë×3¾”r•JIá¢ïÈ–�ÛµÏÿi©V¶�|Ò³ƒäΛK &|Y6¬Ý,ãFL6ºÔª}3#�„·ù�I‡Ÿ¨ï_› 9ɼôòKNް˜¢žÀGÊ艳m.ô‚–ûq@›2g™)¿,tvÈ(_¥z½pñФIíý8ÆE˜  f=„½ŽÂßÑ¢E Áæ-�R~Øá‚[®\¹l¡ÂbÝ‘À•ÌØ±c•<âB F”ïˆ ‘!C›UŽÎg™c/:.f) � xJà6'˜t6´ ,²±…'°Zÿü›‘’.c–ðªªã™³æPÊíŸuTJh(�±ÙË‹šÒ¸KÏo4Åî»6‡ y_Úwí§âx8Ï™>Fm6•´LZÍË—ƒÆÙ;Í¿žã iÖ¦›Lù�ª3qÔ÷ʵL®çÖõNO´; ùÝ;6Ù•Úf¡˜î­M<ÔiÔÚöÀó\¿ïFKÇ5”OùSÇK×6Ž­Ò?þô+¥vÔHÕZ�•ÂÝ|ÌSw2ú¹à¨÷çòÅsÒ»s3ý�ÍþS-Ø&NÌâ�±˜ÛóUºð{eäŒ6QY¿z™Úà. wH�ÂÅ¥Ã'ýÕç÷Ÿlö’Z›9u‰×_€J•«.ã3«&e°cÈÀÞj3_]1)òD‹V� Ÿòïf‘A#~‘ Uë©jV¼¯f>þ˜~üè±`sGÌÁ{ß)”_^Ö”¶ÿhA#=|$ý{ TM|ñmïH+ÜÑP¡w HWM�=ôû‘J‰½ùV!™µd›4mÖzuÚuù\&Ï]#pía/h¯I«.2{Év‰ûZ<ûÃ.óí:÷5,â¡Ìò–kŒ VÎ7í»3e;:˜>cV™»l§4jÞQù˜·ï4Üì û«´îØÛþ�‘‡zspOøº/QºŠqÜ“ú3gé©ßô#‡ýÁ}÷Ëj¥‚}»Þ‹}›¾ÈwèÚ_s§ÓÈ&.�ýÿK[íó2ù×µÿìöòJ¬XêþÍøm“¤H™Æþp¤óøl�šºTàÂÇ^0¡ƒøßlÕ¡—ýa#oÅûj >È)R%—ŸÆÒb>Øv´ÿÌFfØwo's–L‘lšv{yE †Ø¬u#™¿|†fY=¬µ ’KVÏUýˆ7¶}%gîì2zÊOÒ¡k؉Noñ;{úœ4­ÓFîyèÖÇQð­0ðóÍí9%@ 4¨SQöï"½?i-SÇ ”Ã;—H˦µÝÍšõÛäìùKnÕ�<ã7·ê± � �@ð0¿£Úë(‚ô¡?xAûÚš¥úSïØˆ]£F £§›6m’"EŠy_':d,ºvíZ¤.?räHiß¾½f±W[�´]lß0–OÀíÀùí«ø<�à p�qNó…�:mFÉòz.�²Ò]�Û�£‡öÊ�ëW$múÌJY 7Á"øú?ö”;¼Ob½[�/múLÑ6<ÕŸ3'åè‘}Ws_¥>¿š_šœuÎßÆâ¬Ÿöå7ÿ¾.Ï´ÏiÂDIlüí›ë©Ï¡v�àº%Uš *P¯£€¾æs¼•FL¬„xôø¡ P-éPºërR;vôàI®)þ«À|L¯÷5_æWUl…™ ')÷!zß¹·%ðøñ¹ù÷M‰'¶ÄOßö —r÷ï=�#‡ŽÊÕ+×%MÚTšk›LÚg/µùfðy>wæ¼>xL^�Kû¿Hf2ÂÙU"ÃoÀçƒdâèiÊ5™³ö•gy=“¬ÚêÊQo•µ×\Ý,ým¹Ô©^NæLâ­få·%«¤FÃ��ö6­˜!E Ù®x224š¶é©Y®‡oá®xãŠéòn¡·ô¬Ïö¹Þ©*‡´ÀÎkÖ¬‘%Jøìº¼ �€kø ‹ß²ýúõ“þýû»®Ì£AE`÷îÝòÖ[!σ„ ÊÍ›7ƒj|L@x¨é0â¼]e'I€üž”þ&°ìË®Ylc‹ˆ@©ùÖ;E#rj@œEv:Í=6ÕÍ}�».„Ì}ö·±˜ûæ*�(qRW‡Õ1õ9´sîI^ª·NØœ Ü8as%V¼¯®xò±Xšµy*Í{T ”ëoô½ÒÌÝ1áóœ>c:µ¹{Ž^/2üú|Ù]Z}ÔL”uÖÔ¹rQó…»;ãd�à"p_ NîûH$@þDÀ¬‹ ÂÝŸîŒõúB…»õî9GLQBÀü03?ä¢äbl”"HàÈ¡½òqËšòìéSí‡y̶ÂÓH€H z ̘4ÛèÀËšR½NƒF>mºÔÒý³ÎÒ¹G{9vä„QÎ �úµ+ 6{6jštê1Ð(ž=y°¤I�ÂÈ3A$@$@ `ÖE˜u¤C¾&@—2¾&Îë‘@�°y˜éæHA:V+0 \ºpVÚ5©$îßSˆ“ ÷À¼“ì5 X›À‘CÇd×ν„ UËIÂD Œ¼žx饗$×9ôlÀî_�¶ïì8 � � �€o Páî[Þ¼šsT¸;gÃ#$@$`~ÈE° žF^%pçÖMióA¹~õ²Ñn *Ü L� �“çØtöƒæumòÁž±™àöÁr|¾[(˜  pAÀü¼à;ƒ P<å¨p�rļ Xƒ€9ˆ™ù!g�Ñs”þLàñ£GÒ¾yU9}ò¨M7cÆà#Ð3$@~OàჇ²`Nh°Ô,Ù2K�Bùý¾ßì x›•(Þ&ÊöH€H 8˜u|VÇ= ÔQPÛ¨wŽý&?#À‡™ŸÝvGø÷ߥ{‡†²ç¯-aˆÐÂ= � ø9�Åó—û÷½lÔÔZÖíÆÀ™    ¨pw…EÑB€ ÷hÁ΋’@ð0+Ü͹à)GH|ÖQÖ¬µ5÷�>ÜÍ4˜&Ó'‡K}%Ö+R³~Õ@èv¤úÈwŠHá š“ù9š[É�� �@”0?/Ì:Š(½('^tPÆ" °!pïÞ]9uü°M™}>²uùßÿ$Üúz]îI ªÌš:ZæLã´ùÛ7ÿæçÔ)køßÚ—–&Ï_’ÇNZkðmÀ8~ä¤ìßsÐèoñ’Eµ¸×ÕfFcâþÝûêêwïÝ—ÃG½÷tþbhì \àôÙ‹’ØA�Øh:/íW®Ý°¹Ê±“g便b)ºåÉ“¢» ¼> � �€‰î&LF+*Ü£?/NþMàôéÓªƒ×®��ks»ÝÙž<–ª%ݯïvìH^$0yì`ÁF!�@·}ô$÷$à÷V,ûS°ù›üñç&ÉY J”u«IëžQÖ6¥«´ð«ÎÞ¹sǯúÃÎ� �€U PánÕ;ïã¦Kÿ»'ì ø �—_~ÙoúÂŽ� � � � �€? ›:¼+ì �€ PánÅ»îŸc¦…»ÞöŠü‚@êÔ©U?ÊÖ¨-&…ú�uÔ¹o:·““ǪC±ãÆ•uhéãˆË¢–ÀÁ¿¶KÛ*¥äñÃð—™wÿþ'©ÛºCÔvˆ­“ �€Ì›8Z¾íÚÞh©Ç�Ã¥v‹vF>˜–/‘®õ«C»l­ä+RÌÈ3a sÆ��AÝ?6»hß)I™.½‘�®DýB¹åä‘ÃW{÷¥� � D?*Ü£ÿ°!háÎO �€× ˜r^oœ ’€çN—Îu«¸¥lG1bÆtÒ‹I€HÀ¿ÌŸ2¡�^ÅŠ[*ÔýÀ¿:èÃÞ0šaûÑ¥ønéG7ƒ]! ?&`~^ð�Á�o”ºF…»n2‡H¾!tP]ë…|sI^…žøûÚUù¸V¹ý÷ ·™Páî6*V$ˆFvn“cû÷=(_§¡Äyí5#Ï X‘•(V¼ë3 � „O€ ÷ð±†oPáîμ =þð ú[ì·|xÿ¾fÙ^Y.ž òënGcÆ …»»¬X�H ú˜­ÛÑ‹šÍ[G_gxe   ðcf…»w“]³*Ü-p“9Dð³Â�9_ç5@àÙÓ§òiãÚrdÏ.��ÐÂÝcd<�HÀÇîݾ-+æ‡ÆPÉ‘7¿`³’ð�ÂJwÛùXù9pΆGH€H€B Ø?/ÌzŠÐZL‘@Ô Â=êó $` æ™ýCÎ8Èh!pãêIš2•¼òê«_Ÿ w�‘ñ X6{šÜ_úp·äg �"MZé7r¢,?zIz %9ß*àv/b2hªÛ¬X‘H z˜ÝÉÀo{¹Ú ¢§#¼* D3{J4w‡—' ðSöÏ *ÜýôFY [T¸[à&sˆ$à æ™ýCÎ×ç5¬M n¼xR³Yk™²z«ÌÜ´GR¤I.Z¸‡‹ˆH€¢‘Àž-åÔ‘CF*Ôý@^�ÇÈ3AV&ð? 5ô°2Ž�H€HÀ–€½.¬§°­É D-*Ü£–/['˰y�½@ wËÜx?hÜxñåêÅóFÏ$Ij¤Í M5Ó`šHÀߘ­ÛÑ7«º“±ÿáìo÷‰ý!  ðöï 6z ÿé&{bT¸[à&sˆ$àkö9__Ÿ×³6�E3&Ùøøý|øxY¸÷¤´ü´¯$O�Æ€C w$@~Fàέ›òçÂ_�^½Q �dÍ�ÇÈ[:aragi<ß--vÃ9\ ˆ ûçîÉÓ"M€ ÷H#d$@ `~�Ù?äHˆ|Eà¿ÿþ“Å3&—Kœ<…)SAR¥Ï mz÷—EûOËO¿.•’UkF(ЪÑ0$@$…–̘,ÿÈ‚÷ÞÒȶ¯]%WΟ3º\µQs1G�#†)]^mF%&H€HÀÏ,˜<ÎèÑk Héu�<$@$@$@$@Ž Páî˜ K}O€ wß3çI 8 ˜,�ìrÁ9`ŽÊ ü6u‚M·ª|ÐÌ&ÏLÔX³x�<{öÔéE%I&Ùò䓸ñã;­�n\¹,»·lP]ˆ—0‘,Q::»ãÖµ}Í<¹Ò�*í\¿FΞ8fô¨Rý&ëÕW�¼åŒ c¹[îpÀü8ÄÂB  [öºÚòaÎw¨p÷k^‰‚š€ùAfÿ� ê�sp~CàöÍ¿eÝÒ…FÞ*Z\ÒfÊb䙈z_|Ô\Ü»î…ÒdÌ,9òæ—Ÿ~&™sä ·¾¯*Ù»Kz7o .‡þ\ëÿ w_3DF¾úüxë:öÁRk4kå­¦ƒ¢óûFP ˆƒˆ~"„�'‘ �@а×Eðyô·ÜoHî~{kØ1,62Z!ÖÍ ’Þ.›9Už= µ®®Þ¤E�Œ,ø†qáôIY¹`Ž4+UHþ˜7+øè‡#"s?¼)ºtëÆuY³d�q$oᢒ){N#Ï X•À ò‚U‡Îq“ � x@€ w`±j” …{”âeã$`f…»ýCÎ:8Òè$°hú$ãòpYò~•šFž ß(Q¹ºxï}ua|?\¹p^N=¬m‡äÒÙ3ªüñÇòY‹FráÔ iÑý3ßwÒîŠ)Ò¦—Z¶U¥)Ó¥³;êÿY_0tFþ~MŸh3qXëÃ6þÞeö�¢…€ù½3Z:À‹’ � ø%{]Ÿ~y›,Ñ)*Ü-q›9Hˆzæ™ýC.ê¯Î+X�À��Ûää჆ uYÛç±A"úù4Ëܺ­;8ìüŽÕ±¥Ü»}[Ÿ0h€TÑÜ&K•Úa}_fÉ™[zá«Ëyý:¾`茼Ý‹ â9º`òx£ÅøZ�’Uky«&øNaÕ;Ïq“ � �€çìßÌz Ï[ã$qt)qv<“HÀ û‡œ“j,&¯°–Zµñ‡^k› yŸÀûUjÈŒõ»äµ TãOÿùG¦ ýÞå…?z${·m–uË ÜnD· ?˜èY1¶ê—'}ŠŽ±D„9£¯mX+KgM“k—.ú{dù¸êóÃû÷eÏ–�²ê·¹òçÂyêb¥…?Èöµ«äâ™SFWª|Ð\^~å#ÏDþp¶æ'�ï–Ö¼ï5 � xJÀþyÁ÷O ²¾·Páî-’l‡¬N@³ÌÓÅþ!§—sOQAàу²RSzê’íÍ|’]Û(þM eºôR³Y¨»Œß¦Œ“»·o…éô™ãG¥eù÷¤DšøÒ²\1éÖ°†”Í’BjåÏ.sÇ�´©óú5)”øe)� ¦Ú¶i LGËúBI^1ê]x®äÜøÇR£¬I‰w�*‡vï”Æ% HñÔñ¤yé"ÒçÆª_岦”Mêȱý{ž‡BOÆâ´‘H�yÕ<™Œñ#&7jäË*m«”’þm›Éþí[Ä£Èrׇ>îôí߸zEÝ«²YSH« Å¥W³úÒ³i]u+äH#ƒ{¢&ô¾DÇ~ÞÄ16—e°TÌ�€ *Plp0C$@$𜀽.‚Ï ~4¢‹îÑEž×%� #ÀY�ÝÐ,ŒaµªK5Z·ë(ü~_§ÕGFÿyòDùx7 ´¬�›hÊí½[7É¿ÿþk>$çN—ï»u”o»¶—gÏž©c‰’&“‚%ËõþüíW#mNløc‰üûüœ7 ’42™;MÏ;\Z”-*Göì’ÿþûϦ¾W/š/–)"ûwlµ9†Œ§c Ó€— Âc®_fóªåÒ£qm¹qå²^ätï îÞàã¬Ïˆмtaµá‰f±o/÷ïÜ‘™#‡J×úUåÉãÇö‡}’çõÚ‡.okñÒeΪg¹'   pƒîn@bŸ wŸ`æEH ø Ø(Ü_x!øÌú �EÓ&}�û…òµy&ü›@òÔiäÕ8q« p§ñfÁ"*}áôIéÛª± #F iÒéS)U½¶ÄK�PvmZ'Ã>ï¡\ËÌ›8ZâÄ‹'ûTçU¬ÿ�l^ù»JÃW|�GH̘1U^ÿ³vÉozR*Ôkd¤]%`Ù>èÓNF•ŠõKý¶%~ÂIJuÍ Y8u¢ÚµC)l»Ô­" ÷�’8¯½¦êGt,ÆÅ¼˜pÅÜ|ðÅ$GÒ”©$_‘÷´q&’äiÒÊí¿o˜«éÈp÷g}F@å+çÏ©¾æÈ›_:øA2fË¡ò='–/‘qß~©ŽíX·Z–Ï™!Õš´0Æå«ÄÂil&•,5”¼ýçÐ#LY‰?VºÛ+ �@DÜ»wOΟ?‘Sƒêœû&C, ìðáÃ?~ü £/ƒß_Ù²e>#N› ÷ˆ³ã™$@&ÿº”1á`ÒGN=,û47º”ªVÛð ®—qïß'K!P¸BÌþ«‡~Ö])ÛQþùˆ R©A$•¤JŸAò)&õ ½¡ÜsÇ�ÐòÝ•R¸xÅj;n\µêÊáÝ›Ö ¬…u�oXBCb¾ø¢”©QW?ärÿs¿žÆñzm:J·ï†ùšÍZË{ªJõ¼YÔwnÝ”mkVj/kª:‹q/'œ17_æ¬æÊlú¯&Eôcp)ãH"ÃÝ[|œõíëÒ¨CyëÝ÷T6a’¤üåsgeÃï‹UÙ¶5«|®pÇj s ¬(Q©ºÞeîíØLðÛcÖ:ø9°Î½æHI€Â'e{Ú´i厶j�bK H‘cÛRæÜ!P¿~}™9s¦;UYÇ*Ü@a �€çÌ?|8 ê9?ž1 MÖíh�îd"Æ1:ÏÒ­Àч;7oª®ÀȺ¥ U:sÎÜ6ÊvU¨ý�˜š¢{ÖèaÊBJ÷–Ÿö•X¯¾*˜xY'IòÒùëAš¢=Äoü½;·ÕáÈŒÅܾ7ÓŽ˜Û·ËöÏGNT<í�9ÊG”»7ù8ësòÔi�.Ïý³ä~»�¤Î�Ñ(ë§�3:e‹6¤[à£U5—_z):»Äk“€ÿàêIÿ»'ì �€ß€e»®lO”(‘ßô‹ LOµXN˜ÄÙ·o_`ÀOzM…»ŸÜvƒžƒ¦ü- ´ ¨ã²YÓŒn§Ö°o-nä™ ·n\7:šBsY9yø€©,�òán˜¯%H`äŽ}!¬XïCá¾fñ|ùô‡ŸË"!«573º¸ëNæì±#ú)’){.‰«¹°q$µ[´lf‰ìXÌmy+툹}ÛØ %º'îÞäã¬Ï¥ªÕ’óf©¡عMj¾õºäÈ÷¶ä/VBr½U@}o$H”Ø“¡zµ.ƒ¥z'³ Ó{§U†Ìq’ �@x lßµkWxÕxœ\زe‹4hÐÀe Ÿîá3b  7ÐÂÝ H¬âUë´ƒfÅaµ&ÒÇœW G}cøÞøûÚUãB˜4�œ:rÐ(Û´b™` OîÞ¾eT�"¾Ê¯^¼ 7¯_“Ý›7H~m2ÁU7j>»!p;70îÈÙÇŒji= dÙ±öRÂsûæáãÜS‰woòqÖg¸öÁêƒQ_÷U.ˆàÂåà_ÛÕ†1bUV>ÍEчÝzKÁ÷Ëx:ìHÕÇgÔüù.¤ý5[ßGªñ 9™«æ‚äFr$@$@$@$`!T¸[èfs¨$à; šê;ÖÖ½’9X*¬—+7hj]:ò½[7É¿š\]áŽ`�ºÀŸu2Myž$M‘ʨ]ù:�dÊÐïTÙŸ ç)…û®�ëDWÌ¿_¥¦ÛÜO?2ÚŽ7$ªQN"²c §y�;cnß�Ù ‹ý1gùˆp÷&W}nÔ¡«”«ÓPE…ÛŸý;¶Èm©,“»4_ÿØz!µ>lëlˆ^/_8u‚`@KÕI8ß›cÆ8¯Å#ÁF€/ÁvG9  nT¸÷ýåèHÀgháî3Ô¼�FV¡[þüÃ`ñnÙŠÿÍ”À"ðËÈÐÀ£É5w2™²çTHŸùuc °8þrìT#ïn¢bý …ûêEóT�ÓµK~3N¯P·¡‘/‘>k6£Ê• 猴}Á7õÀ¯IR¤” ¯goŒÅþ:‘É;cnߦî‚Ǿ<¼¼§Ü½É'¼>ÃÏþ?QžY'Pß#`rãÊe5´AŸv’Jõ›H¬Ø±Ãj¤�c²á·©ã�vð™)Z¾²‘g‚HÀ9ó{§óZ9ºw·ü}õŠò¿viˆÂ=±¦x}û½’FÝð²f7ªüµq­²Œ6ÕöiÑP³œÞª²]Q¸›”õ‹Þ~d÷®˜G¶mý|O¹{ã^ë×v´üè‘L6H‚…l³®ÚçìÅ•™,¹ÞlU5“ʹ3¨`ºXqqh÷NyëÝ÷5çÕ2¸7º~ù’ÑfµÆ-Tߌ&H€Ü&ðôŸäÒ¹3òJ¬WÕê%ì_ÑâP8zv¸Ý(+’ � � �@ PáAp<�HÀ–€YáÎe¿¶l˜ó.|ÖMŸd4š8Yr�…;Åÿ <¼_Î?"3†1‚X¢×ð·^¥Qsc™rä’lyòÊÑ}{äÜÉã²X»ßö“*h«kýªšEùiuÞðË�óõ‚xBáù¹_OC¹Y¶V}‰3¦^-ܽ®˜=qp¿àº“+íû °9~âue;èþá½5›‹y�q—¹M†[ÕîQÍ�_”“.LÊÀOºY$N"šŠ•3_­–1KÅs³zÓ–æn1ýœß)øQ�ð>/½ü²,�9M&ýø� 0”Cñn£ˆ®ŒWeÚj›cÏë¾òj,£¼lÍú7~|›v™!   W¨pwE‡ÇHà9�S§NÉøñ¡Ë¾Í`Ž ¦‡òÑ£GË’%!Aùôzõë×—pK´lÖ45Œ¾­K£]äíbïKªôåÂé“J!¯+ÛS¦K/i3eñtÈ׿töŒl]½Â8“†)4·J7˜Þ7ܨÍ*AJÀlè¡ñ£¾_Ékšb|Øç=ô"�å;¶ûwîež$ĸzÓVžœÂº$@$@$@$ T¸óC@nH•*•Œ9Rî¸ñ²>mZÈ�z½Ù—^zIºvíªgƒvoþáC…{ÐÞf¿ØÂ)lúQ­ñ‡6yfüƒŠØ\Iž‚EäÛɳZç/Z\Úôî/ã¾ýR¹”™:ô{Áf/©Òg�¡s–8´~Äꇂš5óæ•¿§Á¯zö¼oywo¿÷¾´îÕOõßwó'�Q›ýùi2f–φ�³)öÆXlt’‰,s'Íz\ì)÷¨æóÉ·Cî|Î?*·ÿ¾!#¾èãpLqâÅ“¯ÆÚ>ÃVôB!Üû˜Ÿ›5›·öB«l‚‚—€»ï–�?î&qãÅ—�]ÚÙü�E”LÍæmè–&¢ðx � � X˜@ ��C'· ÄŠK`¥©\¹²$I’$"§Ô9fÅ�¦ù ¨¾³³�Càέ›¢ûáF¯ó)&é2g œX¼§pÝwÍ5?ÚßM�+c–¬v¨l×1µü´¯Œ]¶VàŸÝ^^Ѿ—ëµé(VlR.iì�ëyñ4‹'ÁRÍç!ݪÇç2féɬ¹¼±—˜š_ð†í»ÈÔ5Û5eO<ûÃâ�±„iÔ�O™»Ñ¤[U<å•|â%H(£µÏZƒv�CÅꊲ5ëÉøß×Ë›…Þuk|‘©ôìéSÍ-ÖD£  ¦[,$à›÷N»3j4k%_O˜!ø^ŽŒ¼üÊ+R•“ú‘AÈsI€H€HÀ²"÷bYl¸ 4kÖLÆŒãñÐqžÄüÃÇ]+$+pá½Kà÷ÙÓÕÒp½U{¿Þz9÷ÑC`íùÛ^¿0 ³6ïU�JOÜ'ׯ\Rn\ÈÔQàRû”ÓüµcsGŠ–«$;nÿë²*&yfmÙ§úsüÀ^å<µfÕŽ‰ŸØqãº<7²cqÔ¸7™/ÚwÊÑ%lÊÜa„<á®_ "|Üé3ÚO¢ÊE ÛvŸ}¥â\9V øN¦ÅÀgéµ ônDù~ÝÒ…ò÷µ«ÆuªkAŸáZ‡â„'ñ�€a±+˜D‹÷5éѤŽ}T¿ÐRç)OôÎ[ €#ZA D%�…Sí‚¥6a°Ô¨äͶI€¼O`ÁdÛ€º –ê}Æl‘ì Pö¸ß×IûêeåúåKö‡æŸþó�üÜ¿—Œþ¦ŸÀµL�–í$÷ÛÖe! � �@(�S§NÉ¡C‡B ìR/jñ5²fÍ*3ftË¥^xí¡yü%J”HÒ¤I#)S¦ôÈèñòåËò×_½Ì“'�¤K—ÎÈ;J?~<Œçƒüùó«k;ªo.»sçŽlذÁ\$2d�Ü¹ÃÆ¬²©ÄLÀ Â=àn;�R§N-eÊ”‘?þø#ÜnäË—Oðem1[ÑÂÝ*wÝwã|ü𡬘7˸`ÖÜy$GÞüFž  ðwPà-š>ÉèfªôTa£€ ‡^bwÆj…‘ôåŸ1[¿|ƒRº_8}Òmzø¿]6kšÚ ¸¯Óò#)«Åá ;·²" �€Å¬^½Z¾þúëpG;vlÉ•+—”,YRÚ´iãTùîn{úÑnóæÍ¥uëÖ?~|½Øé~øðá2cÆ ãxåÊ•e®dÙ²e2dÈ›*¸f¿~ýlÊe,X ýû÷·9Ô´iS*ÜmˆG†.e‚ã>r>$à®Õº»õ|Øõ(½”Yá®M1G鵨¸õ¬\0ÇÆÿ*‚ RH€H �¬^4OîÜüÛèr�f­”E–QÀ„[lÞ7Ü:ƒ•‚’@VVb’kÜòõ’9§k+œo½-ñ& ƒíÈž]òU‡–R1GúYw�‹( � �@Ä<�W‚@IDATÔ ªvìØ!ß}÷�@á|ëÖ­ˆ5dwÚ1b„T©REîß¿owÔ6ûX ª½hÑ"›Â+VÈíÛ·mÊÜÉ,Y²Dþý÷ßp«Ú_/ÜX!` ÐÂ=`o;]ªW¯®fJ±È™¼ôÒKÒ°aCg‡ƒ²Üü˜îAy‹£uPæ`©/¿òŠ”¯Û(ZûË“ �€§æO2KÕ–SWý€n±+ÖtŸ@ì¸qeèœ%ò^Ū6'ÕÖ‚£ÚKÎ|oK¿‘eÙ‘ òñ—ßIê ™ì«ÈÕ«W¥W¯^’6mZiܸ±lݺ5L� � „€u1¶jÕÊ(œ5k–ú>5 Ÿua°T�÷$q6ï�oF½³÷=Yê´j/µ>l#1b„ÿóÊÿwËT�!³IºL!îgâÅ‹¦»wï––-[JêÔ©•›ø+¦� � ØH� �T­ºÚHWJÛÖr?§ûpÇpñ•0aXW¤X1û믿�V«VM¥õ=2pãÊZÝ8YKÔ¨QÃÈÂÿ»#Y¼x±Ql®o2t£º!s@$àX.êè¥Ü™"Þ;WõßV¼õÃÇGÈžEs°Tü¿UnØ,:ºÁkú�Y£‡É¤¿Q=y‘ w?¸#ì‚»Ìîd0YT¹Q3wOe= €ýÓAäA»Î_MŸ†¥äÔ©S¥`Á‚aÚ¸­M¸ 2D­Ž-W®œRâüûï¿aê±€H€¬J K–,ÆÐáê%¢‚‰Íáǧ#¶ž#Ù¸q£áj&Mš4’?~U ûT©R©4ÜÑÀEŒ;R¦L‰ó<ˆ6,Üq®½è w¸ŸqÖ/ûs˜lÖ3à ìûÅÞûX«à‹�8tÉ—/ŸäÉ“GÏZjoV¸GŲ_KÁä`�k—.Ê–U¡/9…µ@fÉR¥& X>÷ù±gcä/½D w~MàÄÁý²o{ˆPt´TµÚ’ QˆP¿î¸uŽï~t3¢±+¾øÀÅLDåem2 Æ8ØvíÚ¥ÿÍœ9S=zd4‰wå+V¨-]ºtÒ¦Mew” °2ó÷àÅ‹“’º_t3¸í8p ¹H¥ñ]»aÃå¶E?˜5kVéÖ­›žµÙ›ÝÅT©RÅXA�g òð-AðÔêÕ«Ûœë(óꫯJùòåeÞ¼yÊ-Îï¿ÿ.õêÕ3ª=zTôUNp?£ûŠ7*0”¨pÊÛÊAùЬÙÍ ÷`µn¿¯ÍО:rÈ%ÖGîÇÿyü$ÜúFe&HÀ X…b¹Ÿ.…J–áçJ‡a¡ýž-åûnmFüô~ÇØaÆo Lü­Mß •*Ëï1"ág.�?kSéò¹³dhCÄL›åÂé“ò¢/ºåMùc/ºïö~øA&Mš$£F�’'NØTƒgŸ>}ä‹/¾�Úµk+ÆEб©Ã � X…€nŽñBÙ_èªj/OŸ>5”áöÇÌù† ÊgŸ}&±cÇ6«4V­\¹Ò(7»‘A!òºÂ}óæÍrþüyÛ8ÁIŠy(Ü!pGcV¸ëÖí8Fw2 ` ¡ÂÝ÷™£Œ"øRŃàÎ�;‚ˆØøb&Ñ­‰6ÿ¹B6ÿù†ÛC;uä Ô+ä~}·fEK0[8[/»6­çw ?I ÛfÙoê4'SH G“:~Ag6w ~ƒ»ví*]ºtQVí#GŽ”%K–Ø @à/¿ü¢¶7ß|S)Þñ{¬|2·É4 � #�›7oÂ’Ü‘²Ý¨àF–éðH€€¬öëøî…dË–M²gÏnS%gΜ7úD)\†á»<<Á¤)|Æ_¿~]¶lÙ"×®]ÝrÑ¢Eêt|·ÃKŨp·Æ}æ(£ˆ"Yׯ__Í€ÂW’$I¢èJÑÓl©R¥<4ÂÌcÆ‚ ±Ž‚“„×�“€N/A˜ÈÒËôâÆ�«g¹·�gÏž ¾WÌîªôa¿¢-ûw N?Î= ø,o†…–.ø‘åÈÒJ?νcöÏüïã;€b-\wïÞ=cвc�L™2þõÊxønÇvöìYõ»aüøñaÞ¯÷îÝ+­[·–îÝ» VͶk×N)ƒµÉ2 &PNë—[ÎïRýõW˜ÃÐWÀeË÷ß/GŽüŽ4h�äÎ�[Š/nSÊx]£’–€ XÇãû¿_ dGàì}ûö‰î—ngð»–b T¸[ã>s”QH/ÄXr„}°É믿.îF ‡/2øMƒ ØÈÖ­[ƒ ÇãC�5RÖ^ú%wïÞÍ�: ìñRúî»ïÊ­[·ŽK4§L™âð IÀ_¼óÎ;²cÇÕü¸ºpá‚@IHñŒÀÚµkåý÷ß7Nš5k–T¨PÁÈ3a ð‡n^IºzõjAì¤@“ôéÓË7ß|#ýû÷XMŽ1BYBšÇƒƒŸ~úI† &0~ùè£�¤jÕªý›ÏcšH€•,Âuq¥pÇ&Œí%mÚ´ÊíKáÂ…Õ;Õ+WT¸x1+Ü8 ‡…ºÊÅ»6WréÒ%A�Uè;Âx@€Â·2P¸Ó�LxÔ‚÷xŒàGF¾!P¨P!)V¬˜T¬XÑ7 €«8ZVÝfý„”¬óçÏ7zS´hQ*Û ÁŸ¸q㆔-[ÖåË/‚ÓQHÀŸ `’PW¶£Ÿ˜$¢²Ý;wÌѪï´ÌVü™@°½[â9ãøÆ÷”2ö+`ðY_µj•Ô¬YS2dÈ _ýµ\½zÕŸoûF$@8|ø°ú.ÔO,Q¢„žôx³�ôS§NÙ´a–ŠïÜT©R9ÝÌŠ}óy6 Úe`Qw4�ýû÷ËÉ“'•+1äá^†±:@Â:B…»uî5G…`u7*Vóà`ûQdåûcŸ1c†`é¸.øJ±¸ßÀäåÑ£G]˜ w—xxÐŒ=Ú¦mÚ´±É3C$9æ÷ÎȵýgçÍ›WÆ�'/^”!C†V˜Ú ,0ûöí«,84h ¬-íë0O$@�F“ˆ½{÷6º 8IGFräÈaœ®[º£¿/au® ‚ªbÒÓÙÖ­[7½ª ²êlå­Qéy¬ðÿüóÏåòåËêV*ňA¬=¯`ÎónóÝåØ|F9¬.ÁôÃÇê÷2ºÇ?a£ ðÕ[§ŽF3:Ç„W ÀO3^PÍVÁÎ.@…»32,÷ð3� ˆºäÉ“G°ŽB$@®` üÃÿðŠ+® àØ,ˆ—·JX]‹ «pk Ä Ðœ?^¼>ͱÊG¸ÐŠì{¾yE!‚±êz |¯Þ½{W] 1@*Uª¤_Öá rÝ�¿SÐ_w~ÜuÙ´i“žTßéF† K ÂÝ·™ƒ$�¨' ?Èp%ýÁõWå‚�‚àìٳǂÛ/±624þûï?iܸ±Z:ïΠ0ÑJ¬]°JÇ,µmÛ¶ÑÕ• ¸.ß)‚â6FzVú`¬eÊ”‘ ÈéÓ§¥OŸ>Ê�=DâÃ÷ ,B?þøc¥¨·¯Ã< � D'…ź¾AÉ�3gN5iˆ F³Õ8Œ¬à‚/²ƒ-]ðãöíÛ*k– ·5ñãÇ׫9ÜÛ»€1Ÿïð„ç…iÒ¤Äñ1KÖ¬YUWsÓÁO€ ÷à¿Ç! ø„î>ÁôуÌè¥;�Dpï;vì(î¾Ä‚Dd-_‚›&GÝ`qªKœ8q”Ÿf=Ï}ä ˜ß7"ß[TVù  |·Ã+gPÜ^`±ùóÏ? Ü( È*‚>{ö̾ó$@$àsPxïܹӨ<(�=²éÞëLzРAËóÈŠ½"}ûöí*6”ÙÚÜl…îêzæzð5¿ìîˆÙ­ êcÅÅz¨p·Þ=çˆI J˜øXÉ )J`Z´Q¼|!‚.o¼ñ†(P@Ïr¤ú÷ï/#GŽôhtT¸{„‹•}H?êÌ«tàkÙliåîðR$T¬þn‰çžî»}ïÞ½ÒºukÁ„ž½¬^½ZY’"Èê—_~)fÿÅöu™' �è WYÙ³gWnC¿øâ Y¶l™4lØÐk]ɘ1£ÀÊ\LVb"R×W໳téÒúa—û *ˆye­»ÁS“Êü{… w—˜ƒö µ£<ímåÀHÀ÷ô®lõE¾§Wüõ×_åÎ�;Æ`hÝn ÚĈ#/ÚžŠùÖÓsYŸ¢’€}°Tº“‰JÚlÛÊÌï�V〸XIóý÷ßË”)SdÔ¨QaÜÉ k¿~ý”u<,-Û·o/ï½÷žÕPq¼$@Ñ@¿á¼ù;."ímܸ1ÌÈ;uê¦,¼‚×^{MŽ=¦ÚrÕ¬ì�;æ%`þáC…»OÑÍÅÌîd`IðÁÍØ8�°`u7tèаÜ(¡ÂÝ H¬âs˜04[>åÏŸ_°Q"G€ï‘ãdzƒ—:ðÝ7«V­’š5k: ² —mÅ‹¬„rÞcÂ:ð)ÿí·ßªmòäÉžœÊº$@$@$`9T¸[î–sÀ$õøã8êÛŽ?.ëׯ7†k¬D‰y&‚�@Š)”åÇŠ+¤V­Zòâ‹î/º£Â=ø>Á0¢iÓ¦ ‚ƒéBëv�„w÷æ ~ï¶ÌÖü™ß-]ßÝwû™3g¤oß¾‚g¬½8p@>úè#dÕk¾ž³üôéÓ¥W¯^j>|¸³j,'  ÐPáÎ� �€W˜óG‘W�Zª‘ &ØŒ·E‹6yf‚“¾+Ê”)#p'„€p pËß5îÁùyôQ­Y³Æü¶Ãß2…H j˜ß;£æ �Ù*üÃwû¹sçdÖ¬YR¬X±0¹wïžtèÐÁf‚0L%� � � DŠî‘ÂÇ“I€tfkäĉëÅÜ“@¸ž={¦|�êè –Zk€5Þ'Ÿ|"/½ôR¸§Â=\D¬ J–,i\µsçΘ  �($€gi½zõÔêÁ}ûö VÜÄ�׸"ÞÛÍ��.øŽkÞ¼¹ÚªV­ê¢&‘ � � ¸¿~›¬H€HÀX¦^ºtI¹…èß¿¿‹š}ä÷ß_¶l™Pá$7<‡Q¤H‘ • ‰®Düë~DWoø9ðœ<\]µk×Îó}pƵk×dÿþý’1cFÉ”)S¸W|úô©š8¸zõªdÍšUÒ¦M+x‡¤� � �€¿àSÉ_îûA$@$pùòe¥@Õ‡^®\9õ£IÏsoGŽ‘uëÖFà\(Û!ø]©R%Y´h‘œ>}ZÞyç£$@$@ÁO€îÑs�1Ñ�7o^ÈnhÌ›»†6°Œ‡Ý|nëÖ­Õ€,X o¾ù¦$Ož\J—.-™3g¼ ž:uÊá€wíÚ¥üÒÃ=Nž}º ˆ¾|ùò0§â8”ú/^‡U{·nÝdæÌ™C Èž={¤G�ƹµjÕø|ß°aƒ Ø:Òþù§$H�À¨ƒD¯^½Ô{&ƒ½Ú`a†H€HÀGèRÆG y  [æ`©8Bw2¶|¬”3KE@TεÒÝçXI€HÀsœxñœ™¿�‘$I¥Œ7+ñÓ§O/ƒ ²é*ÞÿùçUeûܹsm&åa9_²dI{¬š£�€U àeéÒ¥V>Çí%ÇŽóRKÖn† wkߎž¢”ÀÉ“'ÕK±~‘æÍ›« Fz^ß=zTV¯^-wîÜÑ‹¤sçΆßF£ÐK Xʬ_¿^>|¨Z„‚ÏÕrÓ¨`Ž7n”Ý»wKêÔ©%W®\òÁ0xcïÉíÛ·eÞ¼yÆÙEŠ‘9ry&¬CàСC‚ÿ-]ðc?Â)$`uð›ŒïÉòåËKÍ¥…H€‚…Þùà«=Mš4áiÛ¶mF�Ø(Û�Z¢páÂR¹reÁª9 X�À‹/†¨öîß¿/\Õaµ»uãåêóȱ¥Â=rüx6 �€ GŽQË9õ*°`Iž<¹žUû .HîܹÃ@BÀÄX±bÙÔõFfÇŽa”äqãÆuªpGp&,u5[Ré#FŒ�¶mÛÊ?ü ð=IqŸÀ/¿ü"�=2N u»�Âr ³u;ï,XªåÀpÀ–'ðÉ'ŸÈ´iÓ¤P¡B²eËËò +ËÞz›�ós`ƒ#à3ùòåsKÙŽ�ž={V�7f̘’)S&—cÏŸ??î. ñ`°xýõ×¥]»v²oß¾`"ÇåcP¶ôÑG>¾jp]Ž ÷ຟ ¼<ûòG”9`“+XP°üñÇ2|øp§Õþûï?9r¤`?jÔ(§õx ,�ñãÇ…¯½öšÔ«WÏÈ3a˜t™:uª1àlÙ²IñâÅ�<$`e›7oVÃÇDñÓ§Oãâù‡Á<nåχÕÇÎÏ�u> P.2àCÁV+V¬ètð8N!«ÀïR �€ÿ`ÐTÿ¹ì ,…}Kœ8q˜1¦L™R` ?nÜ8#8R˜J^,€åËÁƒ•‚\_zç¨y¼°ëÊv(é±4oïÞ½W(p1Ó©S'Ñ•÷£G�VËbµÃ²°à–›.P¶Ç‰GÏro!sæÌQÿSú�iÝ®“àžDž¼ç¡�:uêç" ´¹ÝdÉ’I™2elÞ ôÊøÎûý÷ß�8Pp±…8J 4Pç`*•í:-îI€\˜={¶¬]»V­°wU�ÇHÀháî ŠlƒH@(BðPX™¸ÝÅU;qℌ;Vùw†Ò]— HõêÕeðàÁ’0aB½8ÌþáÇһwoApN³Õ<|Æ×ªUKúôéæsÜÄÀb½páÂE‰#�å£.%|ø�·<ºÐº]'a½½Ùº£§;ë}üaÄ PVèz_`ñäÈê Ï!¬t‚²iëÖ­òòË/ë§{¸ÊÂD¬½Â  ˆ‡;2l„ŠUTf7 z#ß~û­lß¾]Ï{ó÷¦^ úéÓ§+¥»•VXѲYÿXkωßÞï›7oÊ_|áò¢ößKK—.•9r¨«ú‰hÃü¾¬—Ãe–î6K/ƒq ïx÷¶L€"®Þß¡0sô=�!Cu}(ç)$@$àˆVË@°Ç;…¢’-Ü£’.Û& 8p lÛ¶M pµÙ¿œ;CkÖ4+ÛQçã ‹Ã?þøÃáéèÜÙüôÓO6ÊvT†å:üFc9ª+KE¸�Ár³ìÙ³;¼ÆØµkWãX‘"EŒ4Î ˜ƒ¥Bae^%àü, 6˜ƒ¢PXÐ9R>êǹ'�¨"—aPÒØ btäÎ�[YdÂ’\(ÕáRÌ^nܸ!U«VµQ¶Ç�WY_–+WÎfâöôéÓª]� X›ÜRmÙ²EA€ñƒ¾¢ÝÚT8ú¨$@ ÷¨¤Ë¶IÀBDJwX±8ú„`FžˆÞ|ßæË—O)Dð�Ü·oŸ²¼|ù²Ô¬YSöìÙ#Y³f5š†oÇ*UªŠv¼Àc?z/^¸~yðà�Ã>�„“€’Ö„º5?~”Pq4íðÉ“'eݺuFE¬Tp÷‡œqAAn<àCQZ·ë$¸÷5�-ZHéÒ¥Õ3F¿væÌ™eþüù’'O½H¹/èСƒÊÊóÓO?5Ž!ѰaC¹pá‚*‹;¶šØ…¢]÷ûŽu°œÇ «»wïÊ•+WÔ¤-ü›¥Q£F‚ E¿Þ&ž[xRH€HÀW†.Ø"#}ô‘`ó¦à½…H€ïm›™�ùîÞÝÙ3gÎyé%ó /D�l¬d ²ŽN£¸ó.d°¨ÁGÛ¸qãœEÌÈ‘#�Òw§�v*¥:.J{|òz_‘³Ï>»s°Øb‹•\f³d$XªH¡Í(º$ÍI t'Ó®];ç£9I¨ÕµF`ÑE5¼+Be;uä]ƒ…9â[݆ý7eÊ÷ÑÆ63w°´Ü~ûí#e;û±þD±ÿÀDŠsfk%Ë"­$N@®Dâ<šuK÷A³^yµ[D@Ê'€ñVí¡Ð“ˆ@5 ȽštU¶ˆ@ɰZ6l˜ÁR0¦›âJ†©þø—dZVƒ(2ð›{ß}÷¹äXz_’a~”)øßxã�� œðX¾u‚·2 þÞ{﹤(PØn»íòemúã Š„VK-µ”»fM¦ 0+%ôQ½ë®»æŒÇЄˆÔä6$€UyÚ*îaxæóÁöÃ?ÄjÈ@p((çsI8ðȬ«W\1WrKù%i³‰è>h¢‹­¦Š€ˆ@™ˆág ú¢î¿ÿ~ç®–q¨Y¸WƒªÊ(›A–’Êv_hÇŽcþÓQX ~Éúþûïïüಞ”&ÅI!P~Ú½²«\\ôêÕ+Y¼¶S0xÂÔ=/\o-ê÷iÙBëvZ,w2Íqݹ•BõBÜÜÅäú â&M""�Ÿ€,Üó3jÖƒ 2¸ðÂÍLèõúë¯wq.0À‘ˆ€47�4kvâ¹áæR"Õ" ÷j‘U¹" eèÒ¥KÎüáq,f¿d½k×®,²Êºë®køx+ÄB »(gΜéÊ[`�̃>è¬ä³ž@bp'ãE;i%ÍGà»ï¾3|{áãxà 7ô›ZŠ@]Xzé¥K®7þÜ%" Å(¤ÿV|©ÊQopeI�8IÁÅ$ýuf¨âæK""Мˆ…»¿4A衇¦Ò>(›€,ÜËF¨D@ªA ­ãž'œÒ?ÿüó»C~Éн\ˆv¾�5\œtÒIÎZÞ+Û—[n9ƒOy\ÒH #€¥gh]´ÕV[\ÊHš�ÀwÜa¾ýöÛ¨á²n�Ph¥Ž ¬³Î:Qíq[öÎ;ï¸àÞ(‚òý]qÅQÞ\+ùÞW¹òÖû1Y6×ûTýE zL½×^{fž¦É¼óÎë‚Z§Ó>�æ 0xð`÷šŒ3ÆL˜0!í�ö‰@Ù¤p/¡ ¨ï‹=[Ùáq¯ìðKò˜.—dåöyPØ÷èÑÃ\xá…~—³Ä=z´Yi¥•¢}ZÉOßí(�¼(Xª'Ñ|ËÐ� .£øH–ˆ@½ ¦ˆ/|òÉ'¦{÷îæ‹/¾p>ßqa–ücòá‡v¹é¡[5‚†'…�Ç!C†˜>}ú˜K.¹$y¸a·s1kØF«anV¢0ˆ@�ë®»ÎLŸ>Ý|üñÇ-þx‡nfÒòkŸˆ@cHs'¶8ßñ0­ÖE r)S -¥h5çž{®Ye•U CÁêüòË/�pÎ1ÇfÓM7uI6Ø`3ß|ó¦è?öØcæÔSO5ýû÷7¤ eøðá1ðá1ÖñÓŽÂ$ô­Û»wosë­·‚±†‚ƒ€yøwG©"iIছnŠv.´ÐBf§�vжµÒ<P†JC”„ᬔæ!¡–Ö�Ã?<6gܸq†àÜýúõsƒ®Ôõ©§ž2gœqFäVŒw ï�óÎ;Ï ÄbaImÞAøpÇ}³x¨M@Tîs\L™2Å þðÃ#ø>ðÀ£íp×go½õ–Ûµçž{š]vÙÅ,¼ðÂæóÏ?weÌ»¤Áz‹÷A_%"Ð 4ðÒ W¹ð6Î9眦C‡…gPJ�¦ 0qâD3jÔ¨œm½í¶Û º}ËçĤƒ%�½hÊ""P9|0qÄæ‘Gq _2Ñ»í¶›¹øâ‹Ízë­ç:Ñï¿ÿ¾yæ™gœ2ç;ûì³Í +¬à6ÿûß›«¯¾Úì½÷Þne�P6ß|sƒ�]”¯¼òŠ+Ãçg‰5û2Ë,cºuëf°ÀÅz>T¶“† ©iŠŒ3fþhC¡®(¯YdäÈ‘‘ˆ6sm’ Í¢ÙÛZ·ÃBîdšýŽhûö£Ìæ� îÃPº3XË,'„gû³Ï>%ã½õôÓO»¼>ÁÚk¯mhúöíë| 5ßL* Ìõq‡K3ÞG¸Pc øÒK/�ê�\á=¹øâ‹'wk[D@D@D@š–3­óÉG}äŒõ¶Ùf›|Iu\Š" …{Q¸”XD ÒPl$á9°ç/M°æ;á„b‡pQ1vìXså•Wºý“'O6aÀÎXâ`cêԩ΂=iQï“0%5—`)iI É^îdZ2j†=ømÇ»,ˆQJD - 0X»ûî»›aÆjy!VÇa‡æ7�:~ÙÇ�ïöáS|Í5×4þóŸ£4¬ì»ï¾n€÷è£�6÷ÜsOìX¸ÁL¬Í6ÛÌ`µÞ«W¯ðPl�s :ÔsÌ1-�IÈà%ñDöØcwnR7¢È‡{#^ÕâÛ¤û xfÊ!" ÍL€™ñX¯"¸•‘½RJS )Ü‹¡¥´" '°úê«»ið�>úh45ž“àfРAExR˜ª�Åa6×$ëÙ³§S˜0µ?)‹,²ˆ9øàƒÍ\¹ÀW.îüMš4)™%ïv¾ ­y hÀ(°þõ¯E-Ãݪ«®mk¥yð[#²nožk_Ë-E�‡+˜|‚kþ fBÝ}÷Ýî}F.þx.±Än–ÇyªŠ™±µòÊ+›N�:ÜÙ4›È•H³]ñôöê>H碽" " ¿ÀõÞ|PŽûï¿ß|õÕW¦}ûö¥W"(„@óõÒ ¡¢4" %FŸ}öÙce3�þ®»îŠíó¸‹Áç3 püߢ\@É€û—|–|ø×}ã�7 nhPº¿ýöÛîŠåb—.]œeà9çœãO[y䑆?Iy°hÆÝŽY·{Í· ÝÉÌ3Ï<β·ù(¨ÅÍD+vfqTb&Êù®]»º¿fb¨¶Š@H ÐAª0�ÖE@D@š—@1ÁPÑWàŠöÐCm^`jyÅ Há^q¤*PD I ´r^g�u’‡³n£Œ/GaÁÇÖðüm½õÖYÏ£Õ!º“AÉJ�LIóÀź^pá1ï¼óúM-E@D@D h²p/™2ˆ€ˆ@Ó`va!±tB (è¥p‰h½\�éì±\*Ê/"P>}øá‡ ÁK½l²É&~UË&€o~\ xÁ7>JwIó­Ûi½ÜÉ4ß= ‹@9dÙ\=å�æ#0xð`β/„À˜1cœ+ÀBÒ*�B@î…PR�¼xàsýõ×›)S¦Diñ5íСƒó×%ÐJíÛiä�ذmUòÀº„é™^Ö]w]ßDD@J% ËæRÉÕw> ¼Ô÷õSíE@D 5 ãN&¬ùÎ?ÿüp—ÖE dR¸—ŒNE@Bø=jœ¬Û#M·º“Áo;þÛ%" " " " " "P ß|ó�9çœsZݯ_?ó믿ºýƒm·Ýv-Ò°ãóÏ?7‹.ºhê1í�bHá^ -¥ÈJà¯ý«á%º�i×®�™þù³æÑ�Æ$pà 7D ›}öÙÍÞ{ïmk¥y`Y2~üø¨Á{î¹§üøG4´""P(¹)”Tc§Ó}ÐØ×W­�JèÚµ«á/)gŸ}v¤p_o½õÌé§ŸžL¢m¨()Ü+ŠS…‰@s@¹ŠŸvIóx÷Ýw�ë O`Çw4 /¼°ßÔ²‰„Öí4[îdšèâ«©"PEr%RE¸uT´îƒ:ºXªªˆ€ˆ€4!�Yš°Íj²ˆ€ˆ@•ÜtÓM&ü–;™*�®ñb¿úê+s×]wEµÄŠd­µÖжµ"" " Å�…{1´”VD@D@D ­ HáÞÖW@ç�!ðË/¿"»{YrÉ%ÍŸþô'¿©e¸õÖ[Í?üµXÖí ­ˆ€ˆ€T€@8¸_�âT„ˆ€ˆ€ˆ€T”€îÅ©ÂD@D y <úè£æÃ?Œì·ß~f–Yôš‰€4ÑJèN†8}úôi¢Ö«©" •$ ËæJÒTY" " " " ­A@š�Ö ¬sˆ€ˆ@ƒ¥¢ Aá.i>¯¼òŠyóÍ7£†ïµ×^fî¹ç޶µ"" å�es9ôê7¯^ê÷Ú©æ" " "ÐŒ¤poÆ«®6‹€ˆ@… |ýõ×fèСQ©[n¹¥Yf™e¢m­4'f8zè¡ÍÙxµZD@D j4ðR5´*XD@D@D f«@*BD@D É ̘1ÃüüóÏ…ƒ:(Z×JsX{íµÍe—]fxà³çž{šÕV[­¹¨µMGÅߘ1cÌóÏ?oþóŸÿ¸ö/¸à‚æàƒ.˜ÅĉÍ“O>i¼ôrôÑG›¹æšËoj)" " " " "P'¤p¯“ ¥jŠ€ˆ@-èØ±£¹ä’K ¾»±nïÕ«W-WWu«2�£Ž:Êð'�f ÀàÒÎ;ïkê +¬P°Âýƒ>pSá %…lX wcäJ$vk5í†îƒ¦½ôj¸ˆ€ˆ€Ô%)Üëò²©Ò" "P{°ÆäO"" ÍD`ÖYg-«¹ä—2±p„r%R8«FN©û ‘¯®Ú&" " õO@>Üëÿª" " " " mD`‡v0/½ô’¹ð Kª3„&L˜`®¿þz³ð —T†2‰@£РT£_aµOD@D@‹€î�u=Õ�V&°Î:ë˜<°ä³.·Ür.ÿ ,PrÊ(ÍD@îÍtµÕV¨?r)S×L5�¦&ðÙgŸ™o¼1bлwoÓ©S§h[+"P�™3gš)S¦˜É“'›víÚ™%–XÂ,»ì²åYV^±Nš4Éàë}ÅW4K/½tYåÕ[fY6×ÛS}E@D@D@D@¤p×= " uH`âĉæÉ'Ÿ4_ýuT{ü§—`K±±cÇšçŸÞüôÓOQ™¬ ÈD¡Y/òù矛áÇ›÷Þ{/ªòŽ;îhVYe•h[+õM`Ú´iæ”SN‰±Új«IáÑÐJ©ÞyçÓ¿sç�wš_~ù%V AP»tébÆ�g.¿ür:– ÇÆqÇgî¿ÿ~óå—_F©–Yfsøá‡›ý÷ß?Ú—\¡>4·Þz«Aéî¥}ûö.H+�ª›Ñ"^–ÍþNh®¥^šëz«µ" " "Pï¤p¯÷+¨ú‹€4¬Q0þüóϱ¶rÈ!%+܇jPJ§É¶Ûn[W ÷­¶Úʼú꫱¦,µÔRR¸ÇˆhCD $À3°G�-ž«>ÍÛo¿møC®»îº‚îXÊ£OÊôéÓM¿~ýr*Ü×_}“¦\þꫯÌÍ7ßl}ôQó�üÃl½õÖÉâµ- O í·Ñð�VE@D@D@ꆀîus©TQø�À¬³Îj*mé5Ûl�ó:€�¤± `Õ»ß~ûE�\rÉ%£u­ˆ@±˜Õ³Ç{Ä”íøTÇ/û�?þh^{íµØŒ\Í*sÏ=·™sÎ9c3‡f™eƒ…ûQG•³¯PdæÒÚk¯íò0»‰ú0àúñÇ›ž={ºF,ð%" " " " " µA q4,µÁSµ�ªèر£™0a‚s)sê©§üY—+X±¿üòË‘Kܱà6¡å±Ç3O<ñ„¹âŠ+Ì3Ï~kÇ{¬9ýôÓÝ.f(m¹å–þ°–"ÐpdáÞp—T �†& …{C_^5ND ™ Ð8p ¹õÖ[c ÉöíÛ›�wÞÙîÃú»ÚòÉ'Ÿ˜ /¼ÐÕãóÏ?��îøƒSšöéÓ'¶?m£JÞd¹cÆŒ1¸áÁ…n"ü+£L»öÚkÍ /œÌR·Û• y饗šÓN;-²ÔMy÷ÝwÍùçŸíF ¸úê«GÛ¬T¢.÷Þ{¯á/M’ƒii´Or¸å–[œòúúë¯�ù[gÀŸíüÝ~ûíΕ î¶x®*_ýµó³^¬Â½K—.9OOŠÎ™QE Ƚ.¢š " "  L`–n›š&" ME`ýõ×77ÜpCLÙ€¯¾úÊù^uÕU�‚jByôÑGÍk¬á”ûIe;ç}öÙg�•h�=ÌôéÓ³V%/JÛ‡z¨…E5™¼’—óÝ|óÍΗqÖ‚(ÕŸ|òIóÅ_¸óS‡iÓ¦™»ï¾Û<ðÀAÊú^ÍW;;ì°ƒYj©¥b Ì7 tüV#íÚµ3ÜgXúâÖ‚à�IÁ%G(•ªËŽ;îh¶Øb WΛvîð¼Z�bÌ?ÿüæÊ+¯t3r¸ïû÷ïï’®²Ê*nPΗŀ榛nj~ùå¿+ër±ÅsÇHË쌓O>Ù£$ ­äÓNâ—£þ�*²lnÔ+«v‰€ˆ€ˆ€ˆ@ãhù¥Ü¸mUËD@D ¡ xEÎ\sÍe6ÜpC§]g�u¢à|¸äèÙ³§I*D+åÅ_tn>ýôSW$ Q| ãnU¨ºï¾ûÜ~oeÖ¡JÞ°¼p×IÁ?óV[me¶Ûn»ä¡ºÝN�$°.3† â\[ `ç @Gp™‘L=ôÐhw÷îÝݽ3zôhç¾2 X0«"—T¢.”O ÔÇ܉D�ùÜsÏå:­Ž‰@Á¸¯ºvíê q{ÅŒ ~ýú¹�¸7ÞxÃT%h*Ï „{š<¹WKüævÙe—(Ù\`öÞ{Q‚Ä ¿Ñ\çYß,âßuÍÒ^µó7xÑ� " " "PO¤p¯§«¥ºŠ€ˆ@ݺu3ÿþ÷¿�Ÿk|Z¿ôÒK.ªwñ1cÆ ³ï¾ûd�™çT±Ã(@qƒ53‚U( ÑñãÇ»@ƒôêw.þ£…®B©”’7,“uꇥ6–ó^ø9vìXçkyøðáÎÿ¸?VïË´ �¸ÃÀÏ3÷ƒ!>äqÇg®¸âŠM&½òÈ#.�/ãçŸ6»í¶› ÔJ}x^½ÿþû†g«^Î>ûlÃó_"" " " "�N€À÷ÇsŒéÔ©“9ä�CÒi¯T�€î„©¢D@D - œuÖY-”í¾>(v°ð>ýôÓÝ.,�+©pøá‡ý©\€Í\ŠìÃ;Ì) òŠk“‰'FJÚJ)y£Êüw%T¶ï³Ï>†ÀˆX…6²”òµ×^‹ð¬½öÚÑzÚÊòË/Ÿ3>@¹uI;§ö‰@¥àRÉ+Ý)s„ î/[ù|°… î{î¹Ç¹kÊ–žýÌ6 …@¿¸÷ºì²Ë 3“®¾úêðplý…^p3•b;ÿ»Ñ»wos '¤j˜}~VTÃ4H )‰€îƒ’°)“ˆ€ˆÀ `TÁŸDZ‹€\Ê´i�GD@ªL K—.9ÏõÕWs¦-ö AL½l°Á~5u‰Å'Öš^€�¥(yÓÜ¡ø²Ó–¸¹Á½M£K¹A Ãi—ß~ûmY¸Ê­KY'WfÈC€XXœ”7é6)ÌJ¬‡çŸÞ ^†û±RÇ¥K®Ag™?üðCtäÖ[oí“Np=„ :Ôùå�fYáó�X}’JÔÅ—¥¥Tƒ@�= J<¬ÑDÄM÷3®e˜Å�’;Mp›ä+iÇÙÇfþ² Šó4Á] õÁe3u˜�Û&¬ò›MÑžÆGûš‡€,Ü›çZ«¥" " "ÐdáÞWQmKkÇ\'f%%t9rÉ%—8Åv¶òGŽiF�ícJ€U/¡u—³•QOû+2ôQ}Æg8Ÿ÷Ù, ‰ €êXÀpÀ1T•¨K¬@mˆ@  Ôc6Ю»îêîé<Ðl¾ùæY•íU¬Š+šØÌbðŒà«XÓ3 e{µÉ«üZ'�í}TëõVýD@D@D@šƒ€,Ü›ã:«•" M@€€¤(¯Q…ò믿:ŸéøÑFPrãþ ’‚’ò|öÙg�åôµ×^k]tÑØizè!³ß~û‚"XX£¤õ’TòbÍÙ³gO“fÙ†’—`žøcÇ-Ã�7Þè‹i±Di…»‚ n·Ýv."ùqAàÕ^½zµÈSÏ;¼?êRƒ@Òv{\ŸÁƒ»ë #,k™€Û ,¸ $>¦á‰`©Ë5ñ ÁJÔWCXìcéKKÄßC¬c­O°^/‹,²ˆÙc�=\<¿OK�ú$�öü¯Ï–¨Ö" " " " ÍB@ ÷f¹Òj§ˆ@ÃÀª kb\¢ ìô‚)ý°ˆ$péûï¿ï”Ìÿþ÷¿}2ƒ‹‚0àß믿nN>ùdóâ‹/¦*3Ÿx≘2ÅfŸ>}Ì™gž•‰býoû›9þøãݾ{ï½×<ùä“f›m¶qn[¦OŸîÊÇÿ±’ù+Ù@IDATêGžP*¡äEñ~Í5ט7ß|3,Ú­¯±ÆæÁ4ÞÂÿÇt¸œYsÍ5Ý A¨ôoQ@�ì(7$ÍDÉuóÍ7ÜÿŒ5ʵœû(¼—ÒpœvÚi‘²�㕨 ×tذai§sûXøüóÏ£ã¬sb<ï¼óFûµ""PÿdÙ\ÿ×°”hà¥jÊ#" ÍEàÃ?4Çwn}Ë÷Úk/«Ço7Ê’oô|ÃâÞPR{¤p¯½k¢‰€ˆ@NøÛ¾úꫳ¦ÁÚ˜¿4!0ß 'œ;tÓM7,ϳIš2³ÿþN™ún'(à§Ÿ~j.ºè"çŸéXG§ �‚»ï¾»Eç§J^¾ø^Î&XI‡‚òßÈøGñÞ w‚@2àйsg3aÂgѶٯcáÏ̬ÖÓd®¹ær�Ö˜K/½4k9³Í6› üØ·o_³å–[ÆŠªD]°VGéϵcÆF>ñîR¶ç#¥ã" "PŸ4ðRŸ×Mµ�j FU×®]ÍÇ;nD—Xb‰Ø¾FØàÛìÄOt3ʧM›ÖMj¸6HáÞp—T ht«¯¾ºAqŽ�o¾ù&jî©§žj äÜ|D;ÿ»B°¿+®¸Âì´ÓNÉCÎ7ðsÏ=ç,Ð Qfz ÷PÙî ½à‚ œË\½à«=ùA¼à‚ š}öÙÇ °¤úü,ËUòbeå•W:Ëì°\¿¾í¶ÛšÍ6ÛÌ`mÿÓO?¹Ý(ú±~ÇÝM#H¹A CóÌ3�a0…Yo¼ñ†ãŠÕ;÷JÇŽÝŠ}”ÜiR‰º¬¿þúfìØ±iÅkŸˆ€ˆ€ˆ€ˆ€ˆ@“à{λ´l|k#š½ýöÛ±ìÍÐþzh£îõp•TGà�?Ùi‚»¬€'Mšä¬¶ñ�ŽßmÜzdë€` 0f̘´âJÚ×­[7óÔSO9ÅÿË/¿ìÜÚ ´]vÙe] R|Èç“r”¼(ܽk›´óàw7Í"t> É_9Âu#8n ·Øò*U—bÏ«ô" õK€ç†DtèÈE€·|3k#°ñãÇçJ^÷Ç~øá‡¨ áz´S+mN@ ÷6¿ª€ˆ€TŽÊxü·ó×Ö²ôÒKþÊ‘J(yË9¿òŠ€ˆ€Ô�ä̩ڪ�jÓZt´i�GD@ê‡qÅöÜsO纴‘îï¼óŽÁMçï~÷;çÆ39kî¼ÝsÏ=fôèÑfï½÷v³“ëçÊ5fM¥poÌëªV‰€ˆ€ˆ€ˆ€ˆ€ˆ@C�…{C\F5BD N|ÿý÷.ÔôéÓ�ûHfK ‹k”ÄÄ÷B0ÂÂÅi!3�“ˆÊ­‹/ïƒ>puj×®�s%ʲùå—_\þ÷ßßÅÉjÍ@¥7Üpƒyâ‰'\uxà§|Yn²É&N^løË_þb°ú—´�YÚîÔ:³ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€G@îÅñRjÈG€øLW]u•Yn¹åœr�Ó[o½µSN/´ÐBfç�w6'Ÿ|²!¶Òˆ#Z÷ᇚ“N:ɬ³Î:f¾ùæsù¶ÜrKÃß +¬`(ã”SN1_~ùe‹¼ÉåÖ%,ï¾ûîs®5Q�Çkƒ 6píÃÝæ›o¾&M]' 1ÀpyºÒJ+™­¶ÚÊ ×l»í¶«¨kÖÔ Ø�; Žê�ÃçÇô›1e;ÔÄ%“²=ÂÓf+îh3ô:±ˆ€ˆ€ˆ€ˆ€ˆ@.²lÎEGÇD@D@D |ï¾û®Ùk¯½Ì¨Q£R ûÏþcî¿ÿ~÷Gó(¯CéÛ·ot<Üï׿ýö[sþùç»XZüœsÎ9ý¡Ø²u ¼ä’KÂM·Žµ:þÞ7ÜpC��…¤0°ËÂ¥—^jpÙ’”Ï?ÿÜ<üðÃæ‘G1|°cR-%÷Fmdà‚uûÝwßm† ff̘«Òꫯnzõêez÷îíb¸Åj£MȽM°ë¤" " " " " Å�es±Ä#½^ã:ª" µGeò®»îS¶ãBf‡v0Ý»w7¿ÿýï[Túí·ßn±o­µÖŠöWlùå—7Ûo¿½ó'Žrž}ÈØ±cÍ•W^¥ W*U—°L¿N;°Hßxã�Í,³ü¦ ýæ›oœÕ¾O. ¼zÑEÅ”í+®¸¢c…¥»ú% 0_|±ßU•åÜsÏmúôéãæšk®ç@Ù~æ™gJÙÞ‚LÛí�…{Û±×™E@D@D@D@D@D@Š$ �—"�)¹ˆ€d!ð·¿ýÍY{s¸}ûöæòË/7ûì³O”šçíĉ;ûîë”åÑ�ÄJÿþý�‚�Àž(ÛCã$EÉ~ä‘Gº\Ï?ÿ|"÷o›•ªK²ð3Î8Ã)£½:¾å;wîl¾úê+3nÜ83mÚ4Ó¡C‡(ø§Ÿ~z´Ý³gOsÍ5×Äܺ|öÙgæ˜cŽ1ƒ réÎ:ë,Ó£GWn”Ñ®ôë×Ïàn§P9à€œå}Zz\É0Á»åÁM–öÈÙgŸíÜ÷` /© R¸×ÆuP-D@D@D@D@D@D@D@D@D Õ„.Wn¼ñFƒr9faÑ}Ûm·™UVYÅàŽeå•W“Dë]»v5¸Ÿyã�7œ ”É“';_â(³Q{yï½÷üjlYɺø‚)Åx(‹,²ˆ³à¿ýöÛ  O=õ”³÷inºé&×N¶ÿô§?™;Å>Üo¾ùfƒ«\½àS¥·WÀû²î½÷^CÓB…¨¸ºIÎ÷ôÓO»CX¼30€BÈ�!®¾‡rˆyíµ×Œf…¥Ñký}R¸·>s�QD@D@D@D@D úh,R$Ñ}ÐYMhuS§N5_ýµ;ïÚk¯ÝBÙVw*X ã³ü¨£Ž ¹uñ·Ür‹ÁÒ;›B½E¦`G%ë릆Û~}±Åó«NimØ•^x!Ú|ñÅÍÒK/m'WfΜíÂ/|5åñÇ�ŠgÆtõ�2eŠyýõ×ÍÇl¶E´Òê¤pouä:¡ˆ€ˆ€ˆ€ˆ€ˆ@)äJ¤j�—G÷Aã]SµHD õ ` í…{>9ñÄ IAÙ¾ãŽ;º`žÉc…nWª.…ž/[:üÈO˜0!:ìÝ·D;r¬àÛK÷ÐÇúèÑ£ ®` •0o2ÏÉ'Ÿlð;ÿÇ?þÑì¿ÿþî0n€ÞzôÑG;—2R¶'©µÝ¶îmÇ^gÈC@îyé°ˆ€”@`þùç�rá¥T9þøãcÊöN�:™m¶ÙÆ,¹ä’NAŒówß}×<óÌ3YOQ©ºd=A�ðó¾øâ‹›÷ß¿ÀÿK†bý»ï¾‹)ÜqýR)Yc�5ÌСC[‡ËfHj‹€îµu=T�dណ‰€ˆ@�ºtébf�uVçÿe8ÖÓóÍ7_ÎÜ<ñÓ>çœsºt¸T¹á†¢<¸”9í´Ó\¹ÑN»‚›™\®Y*Q—ð|嬯³Î:‘Âý„N0ç�w^ÁÅÁS"˜ED@D@D@D@D@D  Ȳ¹¯Šê$" "а¾^k­µ\S¦M›fvß}wç<[Û† fV_}ugþꫯºd¸QÁªYpÁÍ©§žS¶£ 'pè.»ìâÒdûW‰ºd+»Øý½{÷޲\tÑEæÚk¯umB™žüÃÍË/¿ì‚¥~ôÑGQ>­ˆ€,Üuˆ€ˆ€ˆ€ˆ€ˆ€ÔY6×Åeªx%5ðRq¤*PD@�ë®»ÎtëÖÍ̘1ù…YvÙeͶÛnk–YfÓ¡C3}útC@Në(–½ >Ü)ëWXa3Ï<ó8¥;þÎ×\sM³é¦›š…ZȼñƆ £D eܸq† ¬Ý»w7ÿûߣCåÖåÙgŸu¾Ì9¯—>}ú˜M6ÙÄüóŸÿ4¼K&OžlöØcW7Ÿæ”SN1ƒ6÷ÝwŸkËž{îiî¿ÿ~3dÈ—äˆ#Ž0W]u•Ùb‹-LÇŽ�…?´ƒ�,þ\èÀj–YdÛì€4ù?)Ü›üPóE@D@D@D@D@D žhफ़®–ê*"PËpå2hÐ g�ŽòŸ~úÉ)žsÕí(¥‘ÙgŸÝ\~ù忀pÛo¾ù¦á/—`Žÿ’K.1‡v˜¡<¤Üºœþù楗^Š�«ó;ï¼Óxà�Na~õÕW™†òÅ_˜'žxÂÜ~ûíæÐCu‡ à¬ýQâ#'Ntn#Ë?ü¿ëý”NîÖ°K^t5YD@D@D@D@D@D@D@D@vÞygóüóÏ–¹fáƒýœsÎ1cÆŒqne<¹ý÷ßßÜrË-f±Åó»bK¬ÞO<ñÄØ¾XÀì½÷Þ‘²Ý,§.Ôc•UVñE¹%®j¶Ûn;³Á¸mÜÅtíÚ5f…ΠVð[o½u”—ú�9ÒÜ|óÍf‘E‰ö§­¬¶Új_ïøÁ—÷4B͹OîÍyÝÕj¨y¹>ük¾òª`Åè>¨J$" ©Ö_}çkýÃ?tÖç9ýôÓO�_vܨ LÇ{6w)ûì³�éÕ«—SÆ¿õÖ[ÎÍ ú•VZɹ�á¤\pA깓;K­KÏž= ¹„²ÇŽ›+ItŒwϾûîëp3aÂ3iÒ$X÷1K,±„s#Ó®]»(�VDÀ�ÂÝ“ÐRD@D@D@D@D ¦ hªvM_žV«œîƒVC­‰€4�Å_“îƒZ¾:ª›ˆ€ˆ€ˆ€îºD@D@D@D@D@D@j–€,ÜköÒ¨b" " " )¤pO�¢]" " " " " " µI@îµy]T+�ßHá®;AD@D@D@D@D & Ȳ¹&/‹*%" " " "�ƒ€î9àè�ˆ€ˆ€ˆ€ˆ€ˆ@í�esí\‹Ö¬‰^Z“¶Î%" " "P.)ÜË%¨ü" " " " " " ­F@/­†Z'(�€î%@SH�Â=IDÛ" " " " " 5A@®Djâ2´y%t´ù%PD@D@D@Š …{°”TD@D@D@D@D íÈ•HÛ±¯¥3ë>¨¥«¡ºˆ€ˆ€ˆ€$ Háž$¢m�š! ÷š¹ªˆˆ€ˆ€ˆ@¤p/’’ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ÔY¸×ÆuP-D@D@D@Ò HážÎE{E@D@D@D@D@Ú˜€,›Ûøèô" " " " E�½hdÊ " " " " "ÐdÙÜÔÛþœxiûk ˆ€ˆ€ˆ€N`¶‘#Gš#Fu^ ‡¦”"PË>ûì3W½ï¿ÿÞôïß¿–«ªº‰€ˆ€ˆ€ˆ@N_~ùeìøƒ>h>úè£Ø>m4>�O>ù$ÖÈ»ï¾Û¼ýöÛ±}ÚO`ìØ±nõ©§žÒ7±‡¢¥ˆ@«øå—_f·'êÿ‹-¶XF�ÖVa®“ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€40�ÿ»ï¾û2Çoà&ªi"Ð\°»óÎ;Í\sÍeößÿæj¼Z+" " "ÐP¾þúk3hР¨Mݺu3«®ºj´­•æ ðÅ_˜ÁƒG�Ýb‹-LçÎ�£m­ˆ€ˆ@HO¯¿þºéÒ¥‹Yo½õÂCZ�ª°î3 pýÿYW2™ªžI…‹€´*�7ß|Ó}ˆ.¼ðÂæÓO?mÕsëd" " " "PI“&M2Ë/¿|Täu×]g9ä�h[+ÍA`üøñf�5Öˆ{ë­·š½÷Þ;ÚÖŠˆ€„úöík®¹æÓ¯_?¹” Áh]D 5̰±g~§ ©­�Zç(‰€‚¦–„M™D@D@D@Úˆ€îm^§(ž€&iÏL9D@D@D@Z�€î­ÇZg(‚€,›‹€¥¤" " " " 5A@ ÷š¸ ª„ˆ€ˆ€ˆ€ˆ€ˆ@>²lÎG¨1�kà¥1¯«Z%" " �J@ ÷F½²j—ˆ€ˆ€ˆ€ˆ€ˆ€4  ¼4àEU“D@D@D �HáÞ@SMh;R¸·{�YD@D@D@D@D ¹É§‰é>h¢‹­¦Š€ˆ€ˆ@�½.¢š " " " " Í@@®Dšá*ço£îƒüŒ”BD@D@D íHáÞvìuf�<dáž�‹€ˆ€ˆ€Ô)Ükêr¨2" " " " " " ¹ÈÂ=hkR¸·õÐùE@D@D@D@D@R Ȳ9‹vŠ€ˆ€ˆ€ˆ€Ô0)Ükøâ¨j" " " " " ÿ# Ëæÿ±h¦5 ¼4ÓÕV[E@D@D þ Há^ÿ×P-�¦! �—¦¹Ôj¨ˆ€ˆ€Ô%)Üëò²©Ò" " " " " " " " " " µF@ ÷Z»"ª�ˆ€ˆ€ˆ€ˆ€ˆ€# W"º  û@÷�ˆ€ˆ€ˆ@=�½ž®–ê*" " " " ML@®DšøâM×}ÀЪˆ€ˆ€ˆ@Í�½æ.‰*$" " " " " "à ÈÂÝ“ÐRD@D@D Há^WIupdá®AD@D@D – Há^ËWGu�&& Ëæ&¾øjºˆ€ˆ€ˆ€Ô))Üëô©Ú" " " " "ÐldÙÜlWü·öjà¥9¯»Z-" " õJ`¶z­¸ê-" " " " " "Ð|4ðÒ|×\-¨�=ö˜yùå—Í»ï¾kÞ{ï=Ó®];³ÐB ¹¿%—\ÒtéÒŬ»îºf–Y ³ Þc�=ÌÇ�éÞ½»9öØc£íBWÆ�g† bÆŒc~þùçÔlwÜq‡éСCê1í�4R¸§QÑ>�6'0çœsÆê0Çs͵!" " "PÛF�mŽ?þxóÜsÏå­èꫯn^xá“|ÿ§e¤ÜÉ“'G‡:wî­ºòË/¿˜�vÚÉL�:5g–ü1çq�$�†�’¹´-" " " " " U&°è¢‹šÍ7ßÜ�eÁ4Ûl³M•Ϩâk‘€\ÊÔâUQ�D@D ?�W^yÅlºé¦)Û)müøñfèСù ®P éÓ§O¯Pi*FþG@ ÷ÿ±Ðšˆ€ˆ€ˆ€ˆ€ˆ@�xôÑGͨQ£ÌÛo¿m–Zj©«�ªÓ:vìhæž{îèT�:uŠÖµ"" "P›Pf÷îÝÛüôÓOEUpíµ×.*}9‰÷»ß™+¯¼Òl´ÑFfÖYg-§(å�¹”‰áІˆ€ˆ€ˆ€ˆ€ˆ@-˜m¶ÙÌlPKUR]Z™ ‘{ï½× 8Ðüñ�Œf=´r5t:�"¼ôÒKfÒ¤IQüµ0Àl¼ñƦ}ûöæÓO?5ï¿ÿ¾ùàƒÜò“O>qî]–[n¹(O®•»ï¾Û„®^˜WŠì³Ï>†?ÄÇÙo¿ýÌ-·ÜRJqÊ#Ž€îºD@D@D@D@D@D@jšÀŸþô'ßDD@D >à‹=”“O>ÙôìÙ3ÚE TþJ•jXÂ{f~YjÝ”OäRF÷€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€T˜Àþóóõ×_W¸Ôôâ¾ùæCÐr÷/Ÿ}öY9EDy±X·-’ßp­Zë¾ó¶! ÷¶á®³Š€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€Ô�·ÞzË 6̼öÚkæ×_�jO�o\“{äÚk¯5¯¿þº™2eŠS‚cɽæškšuÖYÇqÄ÷*¹ä£�>rç3fŒ™9sf,)~Ñ·ß~{·ïÕW_u>ÈŸþy3qâD3çœsšõÖ[Ïœ{î¹æøC,_Ú ú‡zÈÜtÓM‹ô�?þعUi×®�YvÙe�‹—<Ðâæå‡~0�=ö˜yòÉ'ÍW_}e^~ùåØ)ÿú׿š…^8¶� ÊfS>÷q¸ž�ûرcÍÏ?ÿÜ¢v\zé¥f�H=Ö–;§M›f®¸â Ãõâ¾À•2×\s¹û¢{÷îfï½÷.+VÍ÷ßo|ðA3aÂ7“`�5ÖhË&7ý¹ÿÏú'Ê´…Ï?ÿÜLž<9ï©æ˜cCœyæ™'oZ|ùå—1ŸPìKNýÈ·=ûì³›ÕW_�¬y\mzøá‡Ý„ ?�Å_ÜM…Ùf›mÌZk­åÊჿAÊOÊú÷¿ÿmøQ a=ýº_úã°™o¾ù\úä?Ê¡<Ÿ–¼<Äs—âáÏè%iý~2WZi%õ�Ô�7ß|Ó¬ºêªîE†O4I~t è ¼ûî»æ½÷Þ3t.øíðGǨK—.fÝu×5³Ì¢IAùi*…ˆ€ˆ€ˆ€ˆ€ˆ€´�¾}ûšk®¹Æôë×Ïôïß¿¢ùî»ïœþ å¤`Á�"…p.AéL ÎÝvÛ-k2”¥ãÇ�O=þ·¿ýÍrÈ!æ˜cŽ1·Ýv[äw<™ø„N0^xarw´=räH³ï¾ûºA�hgÊ º¢½öÚË\uÕUYõQd;ãŒ3 JõRŸï H¤ ú3ôT väÙK,±D®$ÇûÍ7ߥEŸ¹Ì2ËDÛ…®0X‚¢ý¬³Î2ß~ûmÎlèàÜ¸à‚ Ö‰úg̘a–^ziƒîÕ ×â´ÓNó›Z¶�ö7ó;~˜U;E"cU{2ûÿÙH¦W¯^;B—Z?;r–±³ŒU€\f¶ówèÐ!õÉ�öÇ–±Ê·¼ç[e•U2ö¡•±ÊöLÇŽ3ãÆ�K•¹ýöÛ3‹,²HÞ²’u¶Êð̦›nš±Ó’beîºë®ûãlQžUf¬B=–– û ËXå}‹ôþ|sÏ=wæàƒn‘O;jŸÀo¼á®«}‰×~eÛ¸†vð,c¶dýøßK;(—±YòÖØ¾ˆ3W_}uÆZ$äM«" " " " " " •%pØa‡¹o<«p¯lÁ¶4kÕ^Ð÷cø-™mÝZªg¬‚¾E­R?c�À²žÇz:]S¶rÃýÖX´Eùì°ÊØ¢õiÖâ=c-´SËc§µÒÎZç°NÙÖo¸á†¬eOŸ>=Uç•,Ë*ܳ–QÌ�?ÿùϱ¶ð�_¬XÈ úÁdóm¯¼òÊkÀ[Ô鮿þúçA™vU°—BÀYUWÝ\sÈ�!†Q*[C{O.Lù׿þå,Ï‘Iæ:t¨aÊL8}§ðÒ‹K‰_%¦·Ø\4í#W XÍ‹s¦ãÜ{ï½-’ÿýïw™[ȳƒÑÒ§žzÊYØû¤LG¹ë®» ¾Á’ÂèֱǛÜmØbf@˜ˆÑ1ûƒ-¨½a>­‹@½xå•WŒ¼2Ï=÷\AUƺ€çN.ÁÚ¡sç΋ ¦ &Ÿ[¹òꘈ€ˆ€ˆ€ˆ€ˆ€ˆ@mÀ;Öå .¸`ÞŠ2s«÷=z|b) ú²sÎ9'ÜåÖñ”€e>žÒä‘Gqº¦ð^"¶Þzk3ï¼ó†» >Ù“‚Uüé§ŸÞBŸ6ÿüó»úî¸ãŽ©ÖÜXysì‹/¾Hé¶±¨ÇãC²�©‰ƒ�p¢î¹,þÛ·ooÎ<óLc•ÈAÎÚ]EW¹ûî»ôƒI¡½›m¶™sù“æYÏÇ|2[ÎmkHÜâ83)f�uÖûµ£uT]á^nP”ÈL—¹øâ‹cDÖ_ýV¹qPšo·ÝvÎU¬El0à�kU›ÜUð6.jºví¥_a…Rý`ùÁwØa‡X\²0` Jl ^q‹L}ï¿ÿ~çźõ|&u.X1FM“?þñ�îØ»”þË_þKv÷Ýw»rQ܇¸Š¦îù\KcŒ‹o{˜øü;í´Sìµ²�;£'žx"V;óÂcÔ‹Ÿ{®;ëÕâ¿=kíïÒ„ûr­£·Üj«­¢ÁŽßÿþ÷n€"W«.�ªMµS!œÃ~¾|¸yà�Ü�Ó'Þb‹-òúdç�ÅÃ$Ÿà? KúP6Ùd³ÿþû»€ø†Bi÷öÛo»vâ',é¯+-J4<PÐaë…ö„#`ø�âaíŸUXÛ‡£zÅ Xyù4h�O-y b o]Ÿ}{î¹§cÏ?ß!FÛðÍŃY>«#„Zi  ‚Mš4)j¾Ú `ˆbäœß/qßÁ!º:¿×|�bð �€l>èÂtZh>IJî �âkHú¤Öí¨YmµÕܲ–‰ PãêÔ©-ª‰Oèð{µEí� €®d±ÅkÑ�ó�™ÏIaA-QŒA_„"6›¿vtNiÖËäE/vë­·šMíÌm/XÞc5Ÿf9OšË.»ÌÜÔ Ïôo|'…²øN¦|‚Áâqaæ7õÍ ‘|ü…º,òñ\(Å:yC }´çSÒ‡ùZk]AkCÁƒúŤ²[·nî}_èsý ƒrúAt~ù„û} çFWJ™ÙâIæ+KÇ+C ê wªÉC…?¦2„ w^ÄÙ¦Œ „>ôÐC#å1?l¦Ûx…;å@”3‚ˆ2æ…2¹1s ‘�ó)܉}ç�wFÅPêÉ>¦û`qÏmâ‡Åˆ¢—4¥5?˜-·ÜÒýùt,Q°‡ w¦Ìò@âÌ�‡ešÂÅ#l]t‘;u"r5Hȃö0  �F%@ôõPN>ùdÅÛï£ãŸDD@D@j™@£(¼pÁF¿#ï"‘õdŸ»–¯…ê&ÅÀ¸ƒþ'nH³¹HÝe—]œÅi1å¶fZÜ?¼üòË©§Ü|óÍ‹V¸£¼çû¼gÏž­2“=µâÚ) €erš²Ý�¾ý‹õí¹…aà�û?Méíó%—XÊãZ˜�ºB… �(è½`l‰Î+ßyq�òâ‹/šK.¹Äg5XùÛØeѶVþG}Cè^ÝÆ}ÌpÈ%;ï¼³Ó{Z?ù.}¬£k,T¤Ë(”TõÓµŠÂ½”f0JÅÓZ¼Û:â•F‘¼„ë~K¦ð„‚º�Ž?>Ó5ä#±AcÃbÚlýÒK/u>¤dqÛf— áOÌo•)Q¼ôÓšÊ@ÙLÉÃY¹‚Åz(庾 ˪çu:Lç³Á™[X#T«]\S:�åø–£ êž´ ¨V�U®ˆ€Ô �J+¼Úª]ÌVå#3\&Òïóh]ê�ÀÌ™3Ýýî­[³Õ× |O£LËVV5öÓ_¬” Tb7‚!Ï6‰Ô#\�2à”OPp3¸äÖ|Ë ¤Åò½éÕ«—¹ãŽ;Üw[!é}û¸MöÂ,îUW]Õoæ\b ŠžËVR?—óÄux0ià‡ë!XJ‘qãÆ¥p/åÊS•{KV¡~¼ÄC% £q¥ÈM7Ýdl°ð÷?üáÎ å¥ù3ÇÂfäÈ‘Ñéøq„S;¢)+Œ’Å;Ö9méSŠ`~d�©JLaáÇrMi‚v‰@AxY_y啿ÑGu.Z>üðC÷æþbº#¹øJçc�é¦üþð%Wˆp¿>ôÐC†ß/÷,ˆ¹—ù}1M�ß÷s>7/œ‹)sXÍ0ÃË�¤5~óÒù”Mçƒ 6ÈZeÜI1e�‘g:0¡àš‰)ƒi‚O5:c0òSİv¢,ž?~ ‘¼XHØHô.ÐNZY´‰�žY<ö²ÔRK¹N¾ô’ËgŸ}ÖM=z´óµ7mÚ´hš Êkâ8PG‚ߤM—L–‰;0¬5è|ñ1 ÷ÁöÛoïvÁŠû†v2Ý�ö3Û†ÙA<›ó õ¼âŠ+s\e1mað”`µÝ»ww>ðh©Â½Íµ›0a‚ë ¯±Æ¥¥|" "P5•TxU­’¬~i�”¤a0Ù+Ûq÷‰å(}N¾u½;CúÔôukUÙÎÅ ÿ�{RïR«Þ|Ö›Ù."}B/¬KáîihYop R¨ðÝãîäá[²P…;F”¥ôÞyç�Xõ¼ÇƒØÎ,|.¿üòðHè¢5K–¦Ý]ÉXn¸�–Ô)«ti5±îX2Sôg§®ä<÷gœ¥%ŸUÖ¥¦¿ýöÛc饳ƒØ±)S¦¸cVá–±—Œ� œ±A!¢ô~Å*ÊbùìƒÐ*xi}òe¬ò«àô$´Á'bçµ®`ŠÊo}SÇò[%WÆF©Ží»ð [”¹âŠ+FilÇ®Åqí¨öEí®¥U WµÒ—_~yÆú˜Œî›ð·�mÝŽâT'Û c])å-Û(elp‘ŒµªÏY®uñ”·¬luf?¿«4±JÙÌ ,PVÙÖÍST´�‘µ,;c c­¢´áŠu£•5õ· arWŽý°Ë™'äaâ¼:VFÚ†õá—µLòÛ ;ëú*Ãu Ë×­r?­h·ÏºÈØø-žia~¿n£½g¬/ÄŒýxÍZ^¶\Wžƒ¾,–vP&[rí�6#`ãeìlÐÌßÿþw÷gc'EÏ.;øÙfõ*åļké£úg¯µp/¥å�š'`ckE÷ù\Póõ-´‚6`_Ô®bŸ?VYå=餓 =¥Ò‰@V|ð>±^ ²¦©Äë8ºw9ŸUH\,ß=þ�Çò¶ÛnËš×WÅÒòm–VØ?ÿùÏX9ôŠ‘ð�ïà|b]gÅÎgÔòe)ú¸�O;‡5Æ*ºŒ´ åèæúôé«Sx�‹]·†ÃiÕÓ¾Ú&঑Ԕ…;SSÔ Ûán¬”¨»…–±>˜Ö§¡`ኟt¦úäš“�'Àk±R >  &qÞyç™Ã?<ª>®q°ö/Ä28ʤœþùæ”SN ö¶:bÄgŸËÝ VÎLWóSÕr•lŸ±ÆvLœ¥6A™±nNž)å#Ôi®˜x^…Á�K9‡÷ÏÆs+[ Ê…VX÷'Kõ\B�X|üyÁr;àÕK[bmOàj,Þ÷Øc�´$njbÒb"Lˆõ=VíÌTÈ%Ä™Àª‹þP>ûì3¬'ŒqO®ã˜˜ÜsX‘ãnÆvD#—`¾\¬Oðµ*+LODK�Z À”tút^°6Möaý±Z_òžå—téXëõnäúñ.åÝŽÕ5.~¬¢Å0{¶Pa†!ù™Á‡Ð�`ö™/´—޾~ô­‘�+£˜zø“Ñgcf3âô—Í­¨O_­%3õ¼2³Ï§M.™á‡%<î ´Êõ©e‹ødý«µÍ,KkdçÑ23–ïá´þsµÎ¯r››Ï<|›�0— §bVH(Ö4ܬÊ:ê¡0 Ï …mã·å%Y–߯åon¥Ãx�Ö°®d—2iz1®­9(�´p·Š‹Œ�ýaÁi±¥þaÅšM’îÙÊ`¡#xVáÕƒ:Úw¶ÓWt9£hT$iá~Ì1Çd¬¢.c}TGí�ƒuc«·,Üc8êz£ÚîvêX e,–™-b]†d�µq 26Cìžó¿K¬‡³‰ à’šÇ*KÝ=¼ãŽ;fµ|·pëº&µh«ìuõËeYíë.m'=c§´æ´’¶ƒYë&µÞaYÉužw6tƺˉêÌÌš¤eµÏÇoØ*åÝï™ç‘ÿ#3ùlòÔ:Xw2û¡�ƒ�ø²YÚàÓë:'c§/gvÝu× Ï@;Í9V&³eì`f¬¬p+­Å_<–'쀌»Ÿ¸6aŸÓ„ÄÎïëK?5ÙG +a˜®`IýðÊÔj¹”á¾ñ¿ –Ö_v&mÚŠu~ó¡6×½e}ygPž†eÓágª|Rø ÀÅT˜–õvØ!™4¶M>=ùË_bymP*·Ÿcá’BE8J£þýûÇÊ¥ýayá:nÒ·)áGbáGéA�ƒïf÷U6ˆMt ¸åÊ&¸Õb*"®½¬ŸòÔ¡õ Ÿ±3ubeZ+ülEFû¹’÷Ix­l8âˆ#¢Ú‡Û>ª\M*õÓ\щfJ"¼¼p½žzê)WFx>Öéô*\Oë?1Xb@%í>,´<¥Èd¬U””MŒEÙÇpôƒ¼TJXm%“¯o)ËR¸ä:O± ¯°¬{î¹'³é¦›FÏ>ÿµñˆ2Gydê»>ÌÏ:ÏO”sÖš´E9ôCQâ.·ŽIwgäϦp·Öw™N�:Å”p('n¼ñF²IJ$€…¿Îá2Ÿ�ý9î—4á‡ee[ç@�“&ÜeË›k讀¾ Ö\é9ÆýúÌ3ϤU¥bûøå«GxƒŽ¤ „Ód[çúÑ· …¾• Rß"ÿСC£dÙ _B÷‡Q┕bŸ?6îO‹údk“߿ᆦœ9“ÁX%§O—k)÷ ©ng[*ÜýýÇýzíµ×fp—Ša¤�ßà3“ƒB|‘&—TJáÎ9’ßV¸廕wxšðm‡a�oK~o¸PÎ'ͪpG’táÊ{�÷[>á:ðÍ�‹!;++_òÇ9†Ù®g‹ ÚQ õ¥p§“Î(aš´¥ÂݺªÈX÷NÁƒ¢ÿÄüí»ï¾î£K |]£L,Dª¥pçÜý¬ÿ²ð!‰É[¨Há^ÈÕ©�4ÕV¸Óiï£=zdrY­£èô�Š8 +Ĥ«£lJi_>è’�k¬èòIµ^ü6�gŒM©JZu>VŽÑ™À�¨T•ñ¤1bD>y�3+(<ÏÛB$Ù)ôe À/¦^tä’þ×_}Þ*X×D±zÓáÉöaŸ­0Î�T¨ÔÏ–VûE@²Àº49 êŸ iKžã•R¶†’){Ës)…Kî3™b^”‡%ºu{f¦]¬L“J¼°>\3” iyÓö¥ÅuIS¸3X�–Ÿ}XÆJÊ#À·JÒÚÑóÆkr¬ž“ð|›¡ÐNJø½AÿÆ(jøNbFšïrŽlŠÜ¤?^¬“÷Úk/7‹c _¿piÝ+eè?ùw¶uEת�?ÔÓf×uèС EH²½…nŸÀºÔÉ$gt³þÁKnоEÑÄ, gÒæõ×_ßYuÓöЊŸÙ¡I†sÎ9Ç]ǰ_*Üù.ĺkó0M¶ë”¬`±ÏúµîЦð|¬‡LXç¾að„¾Rèß…\¸/è÷Ácf?„÷ ÷´¤ñ Ô‚Â=¼ïr­§ýƘ±Áo–çU·nÝ2ÉXY ²?ücМòÇ<çfV¸uAû]P?~ôMøŽc€€ßÛqÇ—:X—ͺ�ÁKÉyÞS·ä»Ãְάó\æÝÁ¬ºlÂï} ¾Ñ“ùCc5ÚÁ34Lƒ¢›A†4=³ø¼gL˜‡õä +ŠÃ4ÌÀ¶nW3ÌXH”ÞI]Ï*f_<Ø ô¢XçÛøŽ;îpeQfò{ߺÎM+>uý9?‹j±ÅËÙoK-@;+E íî(y™öþáŠ"ùƒñ'^¶a§À“H*Ümdè 7*LÝðùYêR†‡�χ5@š|òÉ'-¬Æ}žä’N4ù¤š w&a0-êÈ‘Â=ß•©ŸãÕV¸óq•¼¿Q¤ð‘Í˃—ôÃ?œ™:uj�ßJ®QV¦™‡V7”ç•ÌQ!YVx¡‡õ¡s•Oj]áŽu`Ø&,�4Ë#:1~ô:üó!\HÐf‚Z1�šYžÅÌHàã-|¨ÐY ëR¨5ašÂ�²ø.FPî„ç§ÃDg,ß¿ƒp¦e¤}¼S¥(žV°áo˜ç; ">lø�Ò· �³î•º•RV[ÉT<•Œ³Û] —\ç+VáEY<ëú`‰‹[1Ü‹uîÜ9v�Pz¥ÍÂm}ø°>æQv¡PKs½†ò )i wúXß…esß PèER]»v�1Æí]r#ïÖ°¯ÁzšÑ®„H›æŽ(4NÀh#)(üµæ~c†Jè–�¾MÒH…jRPàørP ó É}êe4ƒê¡b#œaãÓ¡tÂ`¤Ð¿B~†³ž{î9ª‚–(Êp•Èï")Ìô g–b–&á÷fÚ·5y0(óüÒ”�iå–òüñå Hóç+„¡ÏÇ’¾¬ÏËàL²¯I?W4á\¹feç*+h)Vç‚M\|ñņ`yˆýq¸àŸÓ³°–™þ»‡ ÖÒÓmÙ�c4QZû¢�ÖY±Ö8Æ~‚N…b-=¢MÛ‘tu°.:¢}¬”ÊZQÄöeÛ°óÖ[o¹`­ÙÒT{¿}ðû 2öámì-çNGp@kqRíS«ü"@Àa«œ5v +j•íà»À”V©ícÅŽªº˜�Ùxã�cÇ ûQæ‚nú}öCĬºêª~3ç’«Ö•Jd5W0äœÕÐA;r«�µ0öãÒØYl?öcØ솀±ïü1–VamìH¿!Ølš§’b:ÆŽÜ;Ê_T±ÖÇ},½µØ(9à Ás­¢/Vž6D@ªGÀ*†bAìâÕØYRÆ*„¢“Òß³V>ƺ ‹öù;ÀçV­E‘ ŸVèž]ÖšÓ'uÏ4«¼sÏAúfÖÊðÚ*ÚܳŽçÝ~ûígì‡U”ǯп³~ŒÝ¦�Eá$ûcÉ¥tv™“û³mÓŸ$Ðx(år Ë*wý–[n1v6–+Æ*±Í 'œ`¬•Yìýa?Ê�U¾;[ÓØJ<ÛZ�ÇÒXeÆ*&]9ô©­"ÜØŸQõèw’ßÎ5VíÏ·Â5äºZÅm”´oß¾î½_ìû$*@+y ØY††¾G2¨¨ýp7¼‡­‘… ÖI¿ƒmc'V¦UÞ»o$úwiç~ázY+òXPO‚Ï'ÅN¡�v@׺–жY¡oc \à>kà;æ7êGßáû‡¾ŽµÜö‡Ý’oI¾xà¨ÝZOºçÃ)§œâ³úÄ”åŸE~_®%Á9“¿ù\é‹=Æw+ßrKµn™_¾•yŽÁ×ú‰wÇ(¾l7ºØYQ DiöÆy¸þ¢5Äsï¾-x×X·ÆÆ8‹ÒkE*MÀιg‹5ôŒõ]Âóðlµn£ Ï;ÈŠÖÃàÊÑÎWèÑ×°†¬Ys8Úø¹w5ßH…ý~?ýë_]ëdt^èJ;Hàúiº¾rxøúÀ6vßï2å.W¬{T×OIûö>í´Óœ¾‘¥u×Zô©ì†ë;’‘wmR>úè#W·°ÍÉ4Ú®"�ÖÔõc¥i›ýá;8Ÿ0•†)~a¾0¸ ù“ejœ·\`:G8õ‹'F ±¬MZ„#ÿœ¿ÀIatŒ)-É)la]ý:S# ‘äyí�¦�lQ¬0ü9Y45)I«¦7†S™V*©_Xqí«åÃ2X3áCÝOW ï¹lëXód›å�²0VòÅHhmÅôÚ|Rëî<[B_Ÿü>™ªŸÍb+Dž§!ÃlÓü`ƒÅ)VcaúB×KµpÇ_|)Â4ÊBë–/�UÒ”Rå(‘–©þwÉÌAû‘“µ$ÜMø´É)Å¡å-îÆ°âLÜ@…Ö�÷ß,YØÇ*Õª39ëÆ×9Û’)ßI©—d¹lkaÎeºu6a&Z8ýüÿøG,)Vzž�Ÿ¡Kðß \,ú÷ﮤ„îôÏíÇkT.{…¸K–©í„¿³»îº+g&¾¡üõf:}(XŽÓWHºñðéÃ%³"’‚¥ OÃý�MˆàÓ%-Ü©¿?Æ}÷d®¿pÓúC©Äo>,�õr,܉ûÀ ål}Bßn–ø5O“J< ÓÊ-öù–QŽ…;å„LCpâ9ÌL·z(<¥Öœ@[Y¸[C³ˆ,®FÐU1›ø¨£ŽÊ<™YbVñ¥É¶BŒföD8¼§s­s¿œ™gt¡Bß /IOáyxŽ23$Œ‘‘­|ÊâÙž6ƒ1,3\§|Üáäê?`±O_1›[±°¼ä:: f ¤¹¤âZà÷+É|ù¶Ñ/Z£Bçk=¿Ÿú[£ƒ‚žÝ¼“ðÖa�@"оœ\KúÇIqx�´ �¶·p·7p^±® ŒíÈë‹*Jküµ°Rˆ&Ví·g½°É&›Ä,̱¶´è�e-Ö Ö�B”›õРʾ MÒêÔ>МŦíX:+SÊBìTGÈ¡,*Bk`¿¿­–X]Ð^,#ëú#VߎØNmˆ@@‹Á¸ß&³&°jcd<×±U|8 ";xÕb†Jr»Ø{�‘j/ü.ë]hÖK0C>øàgq˜�‹�&Û¢ÉäO¬D™¡€•bR•Ç:ŠÑÿo¿ý6y¸M¶­ÏàŠ�·–«Œ �& ZLa5m?x²¶šÙJX6Y&Æ~ôåL—´ºõ‰­‹-gQoc[¸]ÌxJZÞú´m¹¬—RÚÃ;Û×K|ø;k1Ö¸Ä03Õ[­cYl•v.=ýH¬ÚfÁÙ�r·žöÏ�¬á­Û1c•iI¢}Ì0õ‚ UÆúêþ˜–•'`Ýrä,”Yt^Âïúü欢È.jÉ7•·Ð³¾sM®>–ËÙĺ%ŒÑG,æýÏŒfÈx¡=Åô‰ªÙ¥m  žaíÛÐ Kfë0“‰ï’pF }gî)þøçÆ œäìöf`¤6¶>f óWŠl»í¶†¿j }3^Ö…®O˜îë%Y–ß_oKø¼Â�º‡ƒv|Ì1Åž—)ÂǤµærëücºŸõÁm‡+(HôBç‰éù\^ðþC‘NƒrLí>ï¼ó|òV_òQo­÷£ó2pÊ”öRÄZØ–’MyD@J$€âÊ ŠØ\³ۻuÉ•®TE`®2‹9V å[5¸ÓŸW^pÓ“¯mƒ�ùä‘R”Å´‡ô¸ á¯A¡Oß#4Ž)&¿ÒG…¹õ¥›5Sø[Å}Œ—ã�?>¦l§¯ˆ+Pú¾_Á}‡»š4ᛉ´¸B±³”]¾[Ò$—ë;D¥ õ …:1¥¿­…¾.ß§ÞÈ„zÙ`´n3 T@IDAT÷?Ô�>š1xÙlbgÙÉ0à y6¡ÐÂ…¬W£°ãŠÅ|ϼfc¨öŠß]ဪˆTž†‹ô‰óõ‹K=3ƒ‰6R©Ù•¯ÂjKœÒ8ü<Ú@-±#Ù,7c‰òl$-E“J}FºðmŽrÁb…;¾=ñ;�B+›X·ÙÕÌ~üØÑï·³f*¦ŠÔ<îfH`u„ïN¬â¼0£ÄNs~ß AƒœEµßÆ�fRáÎŒÊÁ²Áò�ßþvs �çd |6ÖŠ$Ÿ+ÅÔ År6�ñ¹çž)ܓ鸸J³ÜÁRßí^ìlç»�õ¤ð�Ë_>åV2_¥·“Jr”.|PÕÚ@f¥Û­òD  ñRŒ…¨Ï“¶,U˜VV)û*¡|«—RÚ¾'ðñ™OBÛaÂõJ]g_bÁP7úá S�ýà°O§ee ôïßß)Ü­‹�3CØ>�öû~Œ™¬[�hÿYg�eðY›Tjr s)ı% ßjXZ7€Q™á }�lö°”ÇOñ2Ë,“-yl­Þ[pŸ>}º«+ý7|‘§µ E‹ÿ~�5,ËFÚŒG’&¿•³d¯ÊîbÏM|aÛ`ÜÎ`«Nþ¼po2HÄ7uš‚•rxžòNðZ?{ëx˜òN⽕Í*Ùç爥n® ^<û™5‡4ë×ÕeÅð…÷?AÄ­ÏW_œ–&€‚’ï†Þ½{»%Vçôi0šà·ìÅÆ¨Š¬!™Ýè�Ž˜=‡KÐPÙÎ5çÛ —B¹„sâ>ÁA–Cã fó É7N6á[‘~ßU|£ñýÃ7W¶‚|—áF ûbÙÊo‹ý¾~œwLIe;m Hc8ã1[=ÃÁ6ú¢áw%³U1vc°£5«O/XŸ§ דo]úfܸ Cpóâ‹/:‹vt<3Â~.3¸®Xîú~s1n†Òê¢}" " "�—€íüTUFމcóŠüY‹ƒŒ€e()Ó×m«­¶Jå@pÛY,ë\�I �¢ü¹KY&ŠYÅyÞòàg;*±ª|*y~kÝK£�ú"PÍ ©NÞ/9!€ªõéžá>´Ó7]�a;”±–&Û�ŽåI ä a–Ø�‡XZÎE =‚¨Z«÷Œí€»`'Çwœ vœ¬K¶@¡¶s�±.j2Öú=c]µdì‡cì”ˆÖ ´¤óÙi–NÙæëí—Ö]DIåùúR§PP~ùc¹–(üBAa†,Ì#…{H¨þÖ«©pGáÞ+Å®soåêࢬç#¢ØrIÏ>åI±Vù%—I¹(ã >ެÅ`Iõçc„Èâ¡ ¬O²°nv¢$¤G©ŸLc­œ¢4ÉĹEúdþB·ílž¨xk-_r¹|$Z ´¨¬´>ì ­W¶tt¼ ‘´�b>*%" Å �agêÅ~»6 ªS~ a€ÏÎbruÖ"6JÇ{ |ž—«ôµ®„’É—UβR\*¡ð²Ö¬|ásÞ ~ ¬bà<©L°nBZ4ßäŽ °£Ü´.2 rð.CÉɽÀ zx.k±îÊâÀ Š ÷ w2k…£ îÒpIùÂß, l‡×ʯ£�µÁ)3vfD‹“2øåÓ»´>Ù£òì,ç÷J®òÒîÆ \š9WYvöDT�J­ >¼h.Öòë²"™ÍmÛiyn$Ö§•Â=SÝ쬦ÂÝN1na5ìï›|K>¢“iP­Ë�ŒõßYðó+~Ieµ/ÛºF)ªC”lõNZù²Ó–Ô?iÕŸ,3¹Í9°øK IÉ´Xˇ‚…x˜†gm.ÁzE˜§ÔuÑ=:U¹erßæ”o6Øs‹©Rê‹b¦kOê@»’çà¼ÖÅQ®*ꘈ@ žÍn¸a‹ßTò7ncÉJ%�”W®’)¬S¹ëår©¤Â‹ç¯ nYÐ5¢OOˆ/yìtwçµ�üJ#"'€_gëvÌX™ÁÏpšX‹E÷L'0æ–[nKBkAíöÑ÷² :c‡÷ñuø½ZËy—Ÿ‰¹„8"ø¦ã�Þ~8»zöÃØgÏ_ÒZ÷]±ç.Ç*!årÁ�3þŒñ¹œOh¾Öy·Â3)IJó.ØbZyV‰çžÓÛl³M2klÛ*ÔŒµh7ÖdÖg´u-â‚§«Åy¸ü\GâÂXe˜óíÎNúg÷Âýƒ¯æ©S§ú]U¿Fщš`%ù;ã]_ªð­Ä½ÀõÃW?ןêÖPªè"é§ð[·³ �_nüvX•ØøŠGø³ ­œeó½ffÜŸ|s1lxvð‡o÷°o•³ 8WxoǺrq|ù}[C®¢kGL;³Ïù߇#1oüï²èÂ*”ÿêô¥ù­s]x¾Û™†ÑõÎuTø€'öþû‰ B»ˆYAì5Ió ?Áw«uj쌭Š7œØ"v°ÇÝ«iß—þ;‡¾}úô©øùU ˆ@M˜aŸ¿“½¦¯‘*'Ũ¶Â=Y#>ÒŸ|òI×駃ÌG ®èÜò‡ò¿PE{²l¶é4£(§ÓÍÇA>ùpC!ã?´ÒòÕÂ>”ᢣî(™"ÇàA›ì´ú6øF½P:¡Ä·þv ƒ#°åƒxýõׯé�O>æ šå?žùðæÞàÏ@Óž0`[1÷Á¤éDs é(`¶ž>Æ‹i«ÒŠ@k@ñf-ÝûE¨üNùC‰–- a%�¾­µ¤d*•‹oK%—(7Qz3°á•’(àxŸ#¼óx·p�üç}ÍuæÈ@+’Ú"P�ßY5[hý'CÈ�‚�ûB‚…V³>*[D ¶T[á^[­UmD@jŒ€S¸ÏVc•RuD@êŒÖ46¸UÕj�rš¿z”ÕV[ÍðW«‚r�¿zë¶ÇYa¡ª†`Ùj7V£h•)MK€™Cüf«õ»-,ƒsÖma1Yª–¶–¸`éocû¸¿rÌÀ;¨4…}ôQsñÅGE3(.�Z" …{-] ÕED@D@D@D@D@Z‰€ éÜ(1£Ë ®ƒÂ�‡ téf½ùc­¹d¦™�¡åfJøó2{búôé~ÓÍl+Öõ_”Y+" " " "P%R¸W ¬Š(�@-+Ko•rŠ@í˜2eŠ‹…“¬.ÛÜâáZˆ8-m!øùÏ�r#FŒÐlж¸8:§ˆ€ˆ€ˆ@Nr ˜�Š€ˆ€ˆ€ˆ€´6¯$˜_˜E JÀÁƒW%Zk·Sç�¶$@I‹´8Mȉô¶é¦%&À!‡bž{î9P¾­ê§óŠ€ˆ€ˆ€ˆ@6齫l©µ_D@D@D@D@ªLÀ+ ÊýóÏ?·8[[+[TH;D  ¼èßÿ½!øx( '�q[ ¿è¢‹Ì¹çžk¾üò˨jÄp!½DD@D@D@j™€îµ|uT7hBµ®lÂK¢&70¬ÈÓ,Ék¡Éø’ïСC-TEu�‚ Há^0*%hMµ¬lM:—ˆ€ˆ€ˆ€ˆ€ˆ@ý�÷ú¹Vª©ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ �½†/Žª&" " " " " " " " " "P?äR¦~®•j*" " " " " " " "PÃöØcóñÇG5ìÞ½»9öØc£m­ˆ@¹Æ�g† bÆŒc~þùçÔâî¸ãÅAI%Ó:;¥poÎ:‹ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ƒ=z´™=ëq¨ ²p¯�ë Zˆ€ˆ€ˆ€ˆ€ˆ€ˆ@Ãøì³ÏÌ�7Þµ§wïÞ¦S§NѶV*C`æÌ™æ¥—^2ï¾û®™6mšiß¾½Yh¡…ÌÒKÿ?{g.Iu­í=È0¸» 2Øà0È@pOp‡àÜ!.îÁ ,HH !l°Ààîî2¸Kê_ï¾ÿª»»ººOé>}æ|ëyúTuÕ¶z«ºNÕ·×^{æ0tèÐ0ÖXíûÊ�°7räÈpÿý÷‡ï¿ÿ¾× ׌LD ¹FŒ~øá‡X ÷íÇ{,,¼ðÂÍ­T¥w‹Àøã�þð‡?„sÏ=7†”Áã]Ö~Ú÷¿oû±R‹D@D@D@D@ºH@â[Á5˜í¯ýkxá…bêi¦™&l½õÖ æT2hÄ߃:(/|Þyç•àžÓ處k¯½6xà�Ql/+qÒI' 7ÜpCXf™eÊv÷ú¶›nº)¬µÖZ¥íX}õÕ;-¸óæºë® «­¶Z*a›m¶ —\rI{6¸¶J‚{?<é:dh5‰oåÄÿýï‡Ï>û,¬·ÞzaÌ1Ç,OÔÀÖ?ÿùÏáúë¯�)Yd î 0SèË«7Úh£\h);B0©^» î=í}¿ï¾û†Ë.»,,±Äá?ÿùOm�–Xh¡…ZR�* 0 ‚𥨴 îíqÔ �~F¯²UVY%õ¿þõ¯°êª«ö3:ÜÑ™ÞÕxÛ¹Í8㌾ªeØm·Ýr±oT<ÂÇwÜðî»ï†·ß~;¼õÖ[1œÌ¶ÛnÛµ5§Úüè£�æ!eÞ|óÍpúé§w¹2BÓ`=ôP ÔÎØc�Ýå²”QÚ�ÀÿûßÇ{òÉ'o÷¦Æö}ñÅñž5ñÄ·¬½ÔIø•î844£±x¤òÉ'ñÝJÍ8•Y›€÷Úl´GD@D@D@D ‡H|«éâ{XïŽà¾Â +iS(…jÖÚÒz3Ì0C¸ð [_q?¨‘Co¼ñF<Ò)§œ2ƒy‚ &è“GŽ'°{#”wGp÷8ðÄ3æ#Á½O^}²ÑtrýóŸÿŒsüôÓO¥Çpê©§ž…:2ÄX~ÓŒ€{ç�wòä›l²IXrÉ%Ã1Ç÷FîÛo¿ “M6Y d×Ê+¯8à€0pàÀÏ+­´Rgœq|sé’ûÔgœëxúé§c'  'g]sÍ5Ã[lfši¦ÒüÅ�t&ÂøÁŒjé~æ{øå/7qLÄ7ç¹ F´s±Å‹Ü–^z阱G‡{î¹'2LË¢}K-µTìÄd> 7ê½õÖ[Ã+¯¼â›òåtÓM™,·ÜraŒ1ÆÈ·³Âù¼÷Þ{c]<ð@Œ‘¿NxvcÎ ¸î¿ÿþ�²ÚѾþúëx]<ÿüóqTæüóÏߎÍl«6µLpç‚.^˜Åá}çæ|óÍ—ä„?÷Üsñ;yùðƒ¨÷ƒ}ýõ×±Ý<=K†²Í5×\U7¦´ÍžžÊX÷%žé�0îÐ� ß*pÄ/.ñ%]¯NÙñ–]wݵãDJ! À#¯cÞq˜tÓß}x�B¤á·Ì»“oo Èn'A°@`¦þé§Ÿ>Ì1Ç�ž ”w@ÞG?ÿüóø¾È¤œ�S5ÑäÉ'ŸŒñš\pÁ0Þxãu”¥Ûûkܨ³«b;bÝË/¿>üðÃX¢ïÒ=ÁÅÛ×W—üqŒ��&@üí!C†t™s_e v7F€ûÓŠ+®^|ñźŽ>úè†÷¿ÿýïa�uÖ©* Qÿ©§žÊ¯ž€kôî»ïŽBH]zé¥QÐöýÅå7ß|_|ñè_ÜÇ÷»îº«ls¾í”SN ¿ÿýïÃ~ûí—oKW]‚Ð~ÄG„/¿ü2Ý׉m�xÍçÈ#� Ûo¿}8á„:ü}17Ç_fsÎ9gìŒØ{ï½cX)ΉõÁç¿øE´O<ñÄX'sßÔ2&#e?ÆD²„ªªgÇw\ áµÁäɈ‡OçD1N~žÀVøŸÄÿ>üãÃa‡V1ÿIš¶·Ö¹f¸/bœ[®çƒ>¸·šÔ7êµ ±©fÿijáÇgÖËÃß­�M•·ÕâÕeö PUž=fö0•§ó›¹=³‡ªªôÞ&{0ÊvÜqǘ܄üÌn@ ·Ù:³_ýêWÙI'�”Ù�Ù«ÔRz…€õPÇëܼ]z¥~U*" "�e6Ì7³‡ìì–[nÉî»ï¾Ì„ªNcùá‡2{y‹eØ‹Bfë�.£'2Ø‹@vç�wfö’�ËËäøÌÓ'{öÙg+¶ûþf-ÍÃ)3¯¤X7\aÝSöÁd·Ýv[f¢\CEZøƒÌâgÿøÇ?2óÌ,}­WПþô§üÙÔ&>¬—´eûLx‹Çcέut©nÿ p�ðlb/à�.‡gz{!ÏÌ /38³÷N—¡ µ Ø‹sfÂ@6í´Ófæu?¿ûÝï2ó–̯K yÿæí—oãý‰w%îEã÷¹îºëf&PæezÙ›nºi1yÕ÷+¯¼26lXžwùå—Ïl~‚ÌDöŠúy´xÝïš™Ím�™×afepœ{ì±Gf¡WjaÂSÌKZ?–Ü#¸_ì¼óÎï‘þN9É$“dæYY³¼îì0±-3.²�h¢‰ò:Íy¬¢m´Ï:$2BJ«£ó‚ÍÌ«<#¯·Ý—N8aöÛßþ65jTU~ιMršM5ÕTy�æ•Y‘Î&ìË,ÄM¾Ÿöð¾Üˆ�92o�‰]�dÉ8¿&„ÅúRÍ�s‘ž3oǯýëšïìÖy’]pÁÙ,³Ì’·Ã¹˜×k¶öÚkÇëÓ<�j›õ�]vÙ%žC/›Þ›+¡T›òkÇ—õî5i#M̬ºþ¼ŒF–ܯ¸¿×2sZíVù´aóÍ7/-žgˆyæ™§ÓåÏ=÷Ü™ÍgSZ&¿úê«ÌBfÕ,×Äøø¿¬>{|1®j€6ˆ@‹HpohU#" %ÌS0³!­éÅgî1,lHÆq-3Îø"cñ&«Ê0» ÑŠ—j\«ˆ.moGñ-=ó6ŠBS‘+ÂÏ›©°bš™Å-®xàå%M·Ã;Ä*llhlo„Æ2á�º]œŠmá;Ž&t´Ô2B^T R¡1'm›¯#$Ýpà ¥Å�sÎ9Ù ,Pšï‰'ž(ÍSkcWEÉžH%xÕ:C=¿ý¢‹.*½†Ë®ë²müöŠ2g�uVÍ2-|@‡aajæ/k¢q± ^ Íf›mÖayüÖ®»î:ÏV±¤C¢¬^óìË,´Bé>Ò7CtoTðIÛ[&ºqÿJÓÔZ· UÂôñÇ_•wÑE­`V&dY åŠ4µ¾tEp§�µŽ¡Öö²{4בM.ÛpYh²ö%ÐJÁ Ü k]sloTp'�…>©ëjÑbç�M¸;ÏŠõúóM­3ds@Ô½‡Ëóïtjñ›ÇÉ hÆ)3OÿRˆåt r\e޳”ožîÅ"+¾›|Uç«·«lɳ8ÏÜt"¦ûy¦¢#—gêt{ºNg¤…îÉëï½÷2:Ò4é:çÃ<è«l\›IÓÒaʳ÷b‰é´LŸIK›»"f7Kp·CUÇÎs³¬&�ÖîØe/Œé×èº îx‘ã½[/Þ4©Ù°šºé)ˆHdÜ$ð K{ÇëÕSk½’2è ~S—‡{oÐW�" ý™€ ±­ë}S|f°¡£U¸x -ó8,æåûúë¯_•¿;ÚQ|ãxl¨tfÃq;|Ž+cdñ;#‹Zšßâ�Foܲ¼lCO=hmHqi9Åü8qÔðlxrCe¤eZÌÖÒS[ïy˜Ñ��XwEÉžH%x5rÆz. /úéõÆ;B@Ñ›�ïõÔ»šÑ7©!!¸�—÷©ô�ªÁ�Q¼“¥ía�r¸Ö,Nof!=+ö#”YQ,Çë“ãEà°ðmã}õöÛo¯*†‘µ<ÁÓ6"<¤bÌž{îYUVw70¢‡ö;Û´~gíKFì¾ûî¥Uâñëy9nÆè(Æi A,}w·°e0êjÙe—Í,&r^FQp?ûì³c™é¹o¦àŽpû´Ý~Í8_ríâ¡oá*Ž‹/Ç{l~Lä§ÍˆƒtÚБZü�XØ�ª2´¡}´Zp÷#çˆW1ŸbçV£‚»—Uæ¼Êo�çÍôÙ„ôŒÎóß5KîwÚ÷•Ã?¼"/¿a?†âoþZvÈ!‡T”C;8<‹1jÓ�¶3zˆ{NÚfÖËîÞϗp¼øâ‹«òzYüÞ¹ÿy‡#£uh÷EêL…l ÏÅoÏË’ŽÅ²{õ“žgÃ4=ÞßõFà1B�ûËUW]•YüóÜkÞ�‡%ÞýÅÿm]éÔk–àεÂ3³�ãyàÚk¯MAë•Z#¸S'Þ^ühæ‘^˜<Œíµ×^u? ó<.¸S&ˆ WÃCÈ÷§K<˜ ãÆÂ�T.têLËå¡…¡c tûìþç*ʶ†måæAÏTñŸ/íàB¼é¦›¼8-E e$¸· µ*�œÞÁésÏ„\ÀÝâëV;ž®(ÈâPPôÂÁSшÐuxm{^–x—ö¤µ£øÆñŸõðH"$µ¼Éx΃›¿àÞ„rxME ”'ëœ7¼¡üَΆG»^'=GÔÃy¦lêK_Âl¬Š—:/ƒçS„GÊñêfÝE!_" 1š�Ñ—evòÉ'GqÒÓ§ÇÓ¨àÞ]Q²'R ^eg¹ùÛø-ùµƒ¨í¡DR1Ä&q‹ït´fŸ}öÉÓÛäzuHÈ%/»Á�€<K‚GlP¯§Á+¹h©Ãïƒ�ME…2Þ½Ębš´\DWOëKò#a¼o"¨ê†ûij‡zh¶ÝvÛ5üñδŒt=íüCé¬áIÎ;CÙè€Ô“ž–2KÏQQpOÓ3rVÍÜÓúÒ{pQ�LÓ•­ÂÆÏ+×W*Ê‘žP¿¤éŠëéožzº"¤âh›>ÓPBtG†yzŒ<÷6¦™ÎÐ4Ÿ¯#Zßia;c„ôü,é„,þþ½<îñiZ:û¸÷÷„ñL—–Mgbg­Y‚»·ƒóÌ[¾öíZVh�àîUsÁ¤Ðyç�ç»j.‰?çyRÁÝ3ð2áû‹K›ÄÁ“U-Ór‰û^fˆîi™<$•fü¨‹C‘žè¬eù´MšA@‚{3¨ªL¨M€8ÓixD%^ÌSC¨å¹'}®( î8ø~Dåâœ4<Ð3 –.Òñâß k'ñÍ&´Ê™ >Ÿz꩞A<ƒCÙ¹±¤c¢žñ²š¦g�—DÂýàM�!&ñ‰wYÑð˜Â«7uÔð4�¯8�ðÿ„çEÄ}FÒàü@ûÓ6¤ÿwk•YÜÞlÁ½XŸ¾×$÷±ì„¶µY¯xÞ¾t=ßXgÅ‚=󫓪û»ìÅ7ØD<áž{î‰Kf0Æl¸M°I⠾ݯE%ˆ€ˆ€ˆ€´#s(æE›Æ3‡½tó�®hª cO3>+ØÃyÜg^1iÌ[;ÿn�þÁ<2ƒ=|ópsÍ5W°øŽÁ†'{Ñ#FŒ{ï½wž¾Y+§�vZ0¯ðX¼…/É«9ꨣ‚‰ªUÛMÀÉÓôÄŠ³¢,›ä/Ø(ÅŠby³Q”ÁÄŸ`“`Uìkô‹9^Ρ‰Õy–™gž9˜•OWlm°8�ÁDÀpÇw Eì/ÀÇ„¿`qyL¨‰ßÓüí´Î³²›M–8¯Eãx,Vk<8[GC¼í¥®˜4~7�4X‡D0�èŠý[mµU° *ƒ�6–¢bŸIÏ7ƒ< áL€ØÓ ëmñíñÇÏsÿý÷Ï׋+ìëŠàÎ90�÷`aŠEÖün©Î#/vþÌY3qïh–(Ù�Ô1IðrZv‡�`næ}…yÿ^¶´¡ùf‹Wœ¯×[±8àõvWí3�ÍØ9Pµ£Æ†Î:šÕ(¦j3ïÇ´Ýæ’¨Ú×ß7Љg!<¢ÐžŠjp±‘ áÞ{ï� “øXÜûþŽLÇ/9w:Í7tcÅõ¿Î�ÃKWÅvêáùÛ¼×sAÝb­å6Þxã¼61n¾ÎÊAÔáÿDv›{$pï•õ?ÿ×]ÓËÇN/²…l‰/=:?Ñ1ÇóFØ•v·v%a†àEx›Ô10Â��Åx�!ü%Ü/¼Ïp¶‘‰@J€ŽMD îÇx*#”¬±Æi’|�� éˆ!œ§FW#T !™ÜŽ8âˆpðÁWýáž‹˜Ô¨µ«ç¦ e�ס„xoÿË_þÃYCZÀ…ÑTìÇlþÝ�«4ý‚€Å@6¡h~¬6™u—CÊ4;$tÞÈ Ï8pðÌ�=ýôÓáúë¯�ZbÑ»Ýæý©;¢•üÜS�çF(*:8q*æùÖCñ|Ëó#!­Ð2e£�^Üm’«À§Ìð ïªá �ç/<qýðšo•§yñŸ³÷®žIå�ö'@8›<=6ô¦›njèƒg¼[R#Þ%ÃS c“†uÖY'~< b Þñ oåžP6äIc�{ÚÑeIÌ\D„bµó‚SftR4Û!ãϧ61kŒ£O˜Ÿ¢ÙÄ{Á&^,nîð{gÄ¡ k A»‰’¼8iJÒFñ;d~WÄáEh.vÎØ˜aÏ=÷ 6ù^,—X½¼3Ž®†ƒÛW_}á‡Xäi‡-¬lbîpì±Çvˆ€ÎaåŠ(ň«´�Nýï¾û®Ã²z2AãšiÂÓ¦F{n¼ñÆ8× #jø_‹1*Þç A$#dL±Ó�û>#ò]p÷À´|­‹Àè@ +±ß‹"ùçŸHš5Z§œùÀ}Ñçô „vîw6x^%óÉà\ÏÞ~ûí@ìv7î÷Ýw_é¨JœIøØdÍž\ËÑ„@Û„”éIžüóçŸäÀ�óby!e˜v+lèСÕðc“‰€ˆ€ˆ€ŒžÙæ†g:“¦ÖOxvß}÷…÷Ô‡~øá(ºãÁ^|á!žúꫯð"rÝ_ø‰{éÆˆED|#%aާs³-�OŠHWÛñNB¼q1¦‘öÅ¡²†ðý�•û/Ç�?ÇsÄ0]1‘ý¡Ã“Ž(7DdÒá‰H{uᆃUz,”åâ­§éé%B1ÇM½L¨í�´-SM5UXvÙec­§a‰˜ÃhŒß5šx[r¡3^Œâáÿ�ü9¶â±ˆëÌE‚q¨¡Šë‡Q?\)/:‰IÃïÛ ¡žÐ,éõ²Ê*«øîpûí·W“'Rªž¥ÿ7ß|óxNð¥ýŒx'<ÙFmç�cÛ[o½‹K'rÆI�c^sÍ5ãäät@�– SÓë¹(æ×k—ö‰@;üñ+šÇˆ¾ZÆóÂ=÷Üï¥+®¸b>Î'iD îü^ÜQ¡Vylçy—ûaÑÖ›Æ=ŸP[nŒ²+†Ža¤K1ô£§÷å£�>ê«qɽ»VCK˜Tžûq»ç³³s’´û15µ}öƒi™Ù(³ƒiècC´j—õ\W”·÷Þ{çùìá¡bßä“OžÙ�ä¸ßþ‰æûlöú2ŠŸ—˜>›ðÜaÃZ3ó²É?üðXå™0‘ç7ƒÌD‚<wW>þøã̉ÌDà¼h²³Î:+mbR¾Ý^b»ØabF¾ÝČ̟Åìe+ãˆm‹òœËuælYZ§LžÖ¾�s@{yFHí£�>ÊLdËóPǰaÃ2=c;l´EÆószL&¼¦Edö‚˜YçCž†6˜�—Ù0ì<��ÉLœÊÓpíšøVÁÙF§æû©ž&Æe{íµWf¢lÆõg"c'o�ÅFÍëÐJç ØHŒœ¥3eÉuË}-ýͳ�óf/Û¿yÏga�2 JËó4eKΧ æ±ñÖ¡T3ÿüóÏŸ ¿“²²L`ÍÓ°ÂõnÂIiÚb~~Çsj—_~yCyÓ²zòžœ¶…uëÜíT{¸—í‚ .èTé±qŽS3g¶xM¤i:Z·ŽÃ¼þWt”¾¸ß¯Á¼�Љc™�k¨\þ'øÿ`îùźê}çºr]¡Ð}mõ žSþW6ÓlÔDf#h2®mþ¯¥ëüª¸®L”®ØÏoÔ:3묬h¢ÅþŽåñ¿4½­C0³N±Ì:I+Ò[˜µx_fšÞïŒßiñÞV‘Ù¾ð»IóY<öÌæuÈFŒ‘YX®Œÿáæ’Ù(Êÿ÷äá¹ÉÂÆ"yÖ1�öв,¼WfqÙÕW_�™PŸ—g£3ë¤ËL´ÏÌ»»"�u°›˜¡ÍuÔQñYÆ6×KEžeØž~¬#6þ_2çÛªòêmà|¦<Òuž§¬±^ö¸Ï:ó*Ê€ Ïñüß…·MÐßxîNŸÝÒºxÆ5‡‡ŒÿEé9„7÷ržÑÒãe�ö¥epŸKÓÀî´¡³f�y[§›nºÌŒ:[DJÿµ�û…´ÐŠ‚;/’œp>Å›IOî\ˆ¼ˆ¤ –¾ ñ2Rf]Ü-ÆjE�<ÊD U$¸·Š´ê�ÿ#`!b²%—\²âÿúüQ¶Ž€›šyöu*£ÏJiõÖÛM|ó¶ò"iC•fS&¸ÓqPvjmóçEoKó’ÍÌ#·Såxùõ„aêòtõ–¼¬ùK¨y&7”§XžM˜˜R\ïŽ(Ù“©¯ªSÓô ü¶Ìk7£ãɯ*Ÿw|¥‚;ïKttaiç;æý·›×[ì°I;E¼Ü²%b*n i§ùÌk2³ ,=YfæVˆ-ˆ°æŸ™gržÆWp„:à€¢(TÖ†¥–ZªJ¼ò¼ªbƒ Êù”•Á68ð;OE/§§–ˆ.æUÞa[h˜6ò§´j8Ä’²cá�^é>Ä7?ÇÅ}Ên:áu\HâQ¶�rÈ‹0øØÚèõ‚°ç×`^HÉŠyÆgtФÇàëtäÑqg£á3›�#Ïm£¥2ÄIþ MECÏO§9€ÞI” •¶#Ð*Á�kɯ�®.ѦÒ{Ç´ÓN[·L~W<¸Ñ_¯î[o½Õ“–.¹þ‹b}½òÒ}¼<»Ù(”ºmIóÖZçÜ džZé;ÚÎïÞæÖ)Yó;÷îeåÚ¨®šùŠ;:û\_VŸoKÿ¿]|ñÅ¥mó´�,ù¿êŽÅv—}¿ûêäÿŒ¬&�ÞÜÏ;ï¼¼uô:¥† eÌ÷±B�:E«çáNÚ{ï½·ªç�Áf îÅŽ›Ý¼Øl}�¦�àÞ4´*XD@ê° ú2›|/C°JŸiÒu^â-6{©0„G0žã¼ì×+�é2ìº�k`g»‰oi“-dAË„/¼šN=õÔœy™àŽ—~Ñ“;=/¾îÂ]­—S ˜Y8‚¼.ÏǯwD)<ßîå¥/Jéq±þõ×_G¬Tôôü,¹&™øÿžžåˆ iÚZë§9³™…ŠH‹È×»*Jö¤@*Á+?Zi ½’ѱxÚi§e>)ÃIª¿÷�;î¸#vdœqÆÙßþö·Œ´®Nn¼sÛ\™…ÔÊ,^µœo:+QÄÿ’FŒ_‡>z‘òÿ…ëÅBD4äÙÚHùJÓ|­Üñº®õ¿·Ñítäà)�!‚ò¿^^ž¡æÆh°zéédëÈ•˜Žp¬Wžï£c€ÐÔh?Ï\éˆFOßÈ’g©|0-2®wÖq¢XWñªª‚ÂôÈbŒøãY¿Q³Ð]YwÛímHÏaÚéíû;»¤c»O}?Vê/ÖÁ9öëÖÓi™h/ÁJÂË(ÿÐܸ‰ñÂb±¥2‹ûæ›ã²#Á�D L/›¥â&ÖÓî¼¥õ=Ø*@_D ‡ Hpïa *ND@:Iñ�ç›|.CÈàeŸ—~¼Cõ°A,`H1ù(*¼ö,®u'[3z%G4ã¥Ðb¹Ç!¶È(¼Ôø³^;Í6„)¼GeÀKB¢uwŒ‹“ž�{î¹N) ½N=غSv£yÛI””àÕèYS:�"�V î<×ÑÙÞ‘Wº?£¤K<ÕñÜ&¤Zjt1£ªŽÑ „):§ò,´ÖZkåzš×ÁH“wܱaQ”0#„ŸóüeKÄþÕV[-v^ÖŸá²ÕV[U9¿Ö*g“N8¡f¨&:Àqäu !2Ú=±³†�\ Tö°£ry–±yòÑ>Þ¶tió„Äp=„ìK·³^v)“�“Åöó–}GkÅ1„çèΣŠNŒ‚“Õ$÷ì¶Ñ³apÁ†ÚåuÙËD°ø›ùw ƒÅ2 Ë,³L°‹ ß΄:>Ãï�,žT¾�ÉÒÉQ,\8å”Sòý¬0‘“¬0™U™YOU°‹¶j—yÕWÌlCuâ ÷U “ LÊC{Ìc"ßj7®8)M¾A+"ÐDüVøÍذË`YM¬IE‹€ˆ€ˆ@{°‰`/•±1LŽØ™‰KÛãÔ �ž"À”Lm1܃͋ÒSÅö‹r˜ÀÔb·ÇÉËÑÐÌ16˜¸u. ñ¬# aL˜lN � àù˜H'5/þ8!5“R[gE°‘x —Ù2<“�ZØêðî»ïÆc6Gà8A3“p[ç@Û‰ÛhÜ8Á­�Ö�“x÷…v÷ØoŒÍøcõRå¥Õ"òI�YÏ]lg;âug�„ k \Í4óB ̬žŠíOPb{3¡«l�~K€çD‹ ,”OÎÀ¼Åòu­ˆ€ˆ€ˆ€ˆ€4N`Þyç |zÂ,LMXh¡…â§'Êë«e ®óéËf!d‚MüÚ—¡åmo+Á½ìè‹ø6ĺ,Y‡ÛÖ^{í°Á‹¿ÖaÚÎ& �K5X¬öØÛãùm¸M°Ùœý«–" " " " ]$€W�MÐÞ|óͼ<¯lŽŸü;Së­·^þ]+" " " " " "Ðj-Ü-†i°˜KÁbQVÞH„™©gõvò^yå•Ù-žf ÌÌ\sÍ,þTXsÍ5óý6‘K°ÉYC!:²«®ºªj8²M–[n¹<+mã%�!!;4ßî+»=Ì7ß|þUK�.°9yê†JcXò�wÞlÂÙ.Ö l" " " " " "Ð}MÜmb«°îºë–¶ôÅ_ |ºb6qXE6®±Æa÷ÝwC† ©™†”…ÀŽýZk­Î?ÿü8³b‡ÖŦ�" " " "Ð% ŒXôÏDMÔ¥r”ID@D@D@D@D@šE é!e¥O=õÔøéÉƒà… o¦®âÿ·ß~[3ëcŒÎ8㌚ûµCD@D@D@D@D@D@D@D@D@D@Ššîá^¬PßE@D@D@D@D@D@D@D@D@D@D`t$ Á}t<«:&�–�àÞräªPD@D@D@D@D@D@D@D@D@D`t$ Á}t<«:&�–hú¤©-?"U(" " " " " "0Z¸øâ‹Ãûï¿�iÈ�!aýõ׭ޝ«óã�?†Gy$¼úê«‘Ï$“L¦˜bŠ0óÌ3‡¡C‡†±ÆjßWþ,ËÂÈ‘#Ãý÷ß¾ÿþû ³Í6[Øpà +¶é‹ˆ€ˆ€ôíûß·¯T;E@D@D@D@D@D@šJଳΠ?üp¬c­µÖ’àn$®½öÚpà�F±½ þ¤“Nn¸á†°Ì2Ë”íîõm7ÝtSà\–ÙꫯÞiÁý£�> ×]w]XmµÕÂàÁƒËŠÕ6h …”i fU"" " " " " " =C±z£�6ª)¶S˧Ÿ~®¹æšž©° ¥ô´÷ý¾ûîvÞyç°é¦›6¡µ*RD@D@' ÷ÆY)¥ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@/XsÍ5Ã|óÍk^h¡…z¡íUån»íÉ‚-¼ðÂ�ðqÇ7¼ûî»áí·ßo½õV '³í¶Û¶WÓÖÐæG}4)óæ›o†ÓO?=IѹUBÓ`=ôP ÔÎØc�ݹ”ZD@D@zˆ€÷©bD@D@D@D@D@D@šCàÐCmNÁ}°TbÙ¿ñƱåSNÝ€L·@IDAT9e1bD˜`‚ úà‘„@ç‰w  ”wGp÷8ð?ÿüsà#Á½O^j´ˆ€Œ$¸�§Q!" " " " " Ý'ðÅ_D¯c&ÞdÒÍÄB_ýõðÒK/…f˜!Ì5×\ùöZ5~ûí·áå—_~øaLÂ$ž3Í4S8p`­,MÝN|ïW^y%|þùç±LÊÙmù駟“O>¾ûî»°à‚ †ñƯ©ÇAá>y,ëÔÙU±½ÝÎÇÓ.öñÇÇp=Ÿ|òI˜zê©õv•s»“Ú!" "Ð:ŠáÞ:ÖªID@D@D@D@D@Ú‚À¨Q£â¤”ÓM7]˜l²Éâçàƒ³Ì2KX~ùåcø&Ÿ¼ë®»ÂÒK/·¯²Ê*ažyæ K.¹d@€/Ú;ï¼'ñ$ÄÉDMæŸþ°ÒJ+Å‚%"þA1kÙ7ß|6ß|ó(ì{»j-/¸à‚ZÅäÛÿú׿ÆãA4¥ÝÇ0í´Ó†=÷Ü3†_ÉVð‡Åä“Ož3¢-¯¾újìHØe—]ÂÄOYd‘°ÔRK…é§Ÿ>œyæ™…Rzæ+l×]wÝ0Í4Ó„e—]6/ôÎ;ï¬hí›sÎ9Ã!‡’§IWºsŽ8çk¯½v ýœ¬¸âŠiñáÒK/�<|?Ëgœ±"MO~áür^©‡p:nœß´ ÞŽ-¶Ø"¸'¼§õ%^ñ^xa˜uÖY#_|ñª‡ë™ï묳NXl±Å#Þ�i)" "P›€Å}“‰€ŒFžyæ‚9föP8•ED@D@D@D ' \tÑEñ™‘çÆ®|L„ÌL¸¬h’‰± •e¢efáyýËßÿþ÷†Ê Íg�u–g«Z~õÕWÙf›mÖaY“N:ivÝu×UågÃlPšÿè£�ÎL„/ÝG»þð‡?”–×��gœqFÍúj�?óÒ®ª²;çèøã�¯jâ‹.ZQ‡‰ÕUiÆüŠ4µ¾Œ92ÏkñÝk%«ØÎµTëøkm¿å–[*Êà ×ò2Ë,ÓpYO=õTUÚÐ>¬3,žËÃ;¬}¥–ˆ€ô_ÛÿŸ w(ÈD@D@D@D@D@D ÀÓ{…V¨Šs�5^ÌLÀ™^ÞxX㹎1Ùåƒ>˜&‰áM|ØcŽfŸ}öðË_þ2àUŒ§8Û0Vƒ‰Òž´bI:òL8á„aŒ1ƨúxˆ›ŠL%_¶ÞzëpÅWä{ðpæx7Úh£èNÙØ§Ÿ~·ÝqÇyZ_Ù~ûíc|ñ±ÆªŒÄŠ÷8#ÜðäŸ{î¹ýk ¥“é¡•µÖZ+¶Ÿóâm÷¢‹œðæß}÷Ý£g¾§ñ%!hÜ:{ŽÖ[o½è]?Î8ãxUËýöÛ/ž÷b«öІ=öØ#²÷kË‹-2á;×.ñ‹_x²|yòÉ'‡»ï¾;ÿn�qd‡uÚ„áÇWýN^{íµ<­VD@D@D H òÉ¡¸WßE@D@D@D@D@D@F;ë·ß~{0/î`Þñøæ�wÞ8'âô–[n.»ì²¸�°3ˆ‘Ä=ßwß}Ã)§œ·»</?üð(–#V"¶c¤#²#�b÷ß\ÿ'û¦›n*nοSÇG‘/[¹ä’Kµ×^w!´î¿ÿþÁ<]+:h;âû /¼'ØDXEDM;V]uÕÀ#dL±Í„n9÷Üs£ýßÿþ7\sÍ5�‰?�S£nB¹4jÛm·] “’¦'>ç {üñÇó‰FW^yåpë­·¦Ië®wçˆCLØ:xðàÒzvÞyçÀƒ%±í›i„⃺æí·ßŽë_ýu4hP\oäÏ=÷Ü“'#,Ðo~󛼃ˆœ?®Ý믿>¦«uüy!Zè×$¸÷ëÓ¯ƒ�ÿ%pÚi§Å¸×|#fµÛQGÅöâö²XØÃ† ?üðC°0‡1Ö9"6âüÄpw{óÍ7}µÇ—§žzj^æï~÷»@û‹†W:â8Kb“ðÁáꫯxÆ7b›nºi8ï¼óò‰4ö7Þxãø)æ'θ… )n®ùÝB›T î5waG;œ£.4»©Yˆùîvúé§æàÚ Þ?B>ñùÿô§?Ź ˆãNç”LD@D@j�à^‹Œ¶‹€ˆ€ˆ€ˆ€ˆ€ˆ@?"0öØc—m1¤Ji"ÛȤ“x—ã�ÞLA½Výlï½÷ÂO<“ ðãÑ]Ë[sä‘GFo~ÒÜ|óÍ î'�tRôô¯Un;oo‡sÔŽ|vÚi§8¢ãÇ /½ôR8à€òfr�,°À1¤8Œ‘‰€ˆ€ˆ@=ÜëÑÑ>� äûŸÿüg‡i›™àÕW_Í‹· =+‚ä;’•%–X"ÿÖh\n޳3öÀBÎ4j� …Òh™¤k—sÔ™6·*-^ë6aoÚ‹£¾üòËpï½÷ÆÏùçŸø0Ï€LD@D@j�à^‹Œ¶‹€ˆ€ˆ€ˆ€ˆ€ˆ€4D€¸å©ØN¼w&f%Ç_|c`#†§±²*¸“‰&™d’<ǻロ¯×ZI=ñ'žxâZɺµ}¼ñÆëVþžÊÜ.ç¨§Ž§§Ëáz%f?“ú'Ÿ¡‘ðxÿý÷cuŒ øÕ¯~ãõ3ÿ�LD@D@ÊHp/£¢m" " " " " "   ñ­Ý)sðÁWy—#n3ùg3�ÉZ ‚W2žÊt¬±Æ¥UâuNx·\ÐWG»e³Î^óíhY–5Ü,®b÷Ó!ô—¿ü%,¾øâñ“ÀµËä»ìÇN>ùä8ápšFë" " "àÆð-E@D@D@D@D@D@D ³ðþꫯb6â[çzÌ1ÇÌ‹AüdâÐõ×_?ßÖ¬•qÆ'l»í¶±xêÝl³Íµ×^[UÝ'Ÿ|¶Új«ð¯ý+îcÒSâx�®Ö“爑 ˆ¨ž~úéðÙgŸU`£“Ñú»ï¾«ØÞì/éH‚Gy¤ª:ÚsÍ5ׄM6Ù$œrÊ)ùþÇ{,Æo¿ï¾û¢ðþÆoäû|e¦™f Ûm·�Í=Þó Z�„€<ÜZ�þ@`Ô¨QQ`f¢P·í·ß>ìµ×^a—]vñMq‰·:ñÍ;ì°Ší'žxbxûí·Ã 'œ&˜`‚(º#d3ÁärË-˜´”�?üp(Š˜Ll:Çs„5×\3z WÜÍ/‡rHŒÇM›?ÿüó°á††aÆE˜6½ð áÖ[o 0p;è ƒÞñnˆÈp Bm**#&§ “N:i 3’Џ^NO-o¼ñÆïçŸ>üôÓOy±wÝuW˜rÊ)óïásÏ=wìô <ŠÛ�!Czì¶gÎ9çŒmÁs~Ùe—�1Í?üðÃ@¼zÎyjß|óMLsì±Ç†¥–Z*îB¨ÿío¯ ÷’O�ëöÛo¯8.Ž¡üÐCM‹®X_d‘E‹/¾·m¾ù汃‡|üqxýõ×Ãm·ÝÑàꫯŽ×!�<ÛÿýïÇër•UV‰×ù¹NåGŒA’hK/½´¯j)" " Õ¬×_&"0°\ÆOföp8•ED@D@D@D ' \tÑEñ™‘çÆôcÞË™…ØÈöÙgŸŠí&äfŸ~úivÜqÇUl'ïË/¿œ]pÁUÛÓrë­“¿Q3Ñ?¯ç¬³Îª™�gb‹#Ÿ§­WÿÎ;ï�9-ìòË/o(oZ® ·i=º>|øðNµg¥•Vªª¿'ÏÑ%—\’qM¤ÇßѺ æy›öÞ{ïNå¥l¿óB +s=wÜq*×&IÍLè�%Üÿý åñã㺲΅BíúÚN¬³,žSî2h1�¯íÿEPH(ÈD@D@D@D@D@D `‚ÈVX!‚Åmúé§�qªñ’N ¯ðÝvÛ-¤’²Ÿï[l±E`‚T¸˜¦›nº4k¾Ž×û�gÏpÏ_±£¾Ì3Ï</zêÄK¹Ìð¶ÆÃÿì³ÏÎC¤xº•W^9˜h ä›j.áðë_ÿºÂC¾fâ.îØu×]£Wy#Ù9ö²ð8=y޶ÜrË·ßîª& <8zØ�=öØq×ç›m¶ÉÓnºé¦ÁDï@(ŸFŒsXv ¦y©ã¦›n óÏ?º9_8p`X~ùåÃùçŸî½÷Þ¼nÚ±úê«ÂƬ¸âŠa¬±Ê.é˜cމÞîµ®©¼2­ˆ€ˆ€ôkPùû5¼Œfž}öÙ0tèÐøbÁ°N™ˆ€ˆ€ˆ€ˆ€´ŠáC|ðÁ¦ã‡~ˆ“¤Î5×\1LGO´�0$„°ÁÎ;ï¼°Ã;tX,aOÌ‹9†Å!ÄÌ 3ÌZh¡0묳v˜wtLГçˆsüÐCEzê©§„®Aø.vÚ´’#aŒ)ôÞ{ïÅk�0;t ÕÓÓöBfäÈ‘1ï_|;õÂu\ÖÁ�æÕz{ ƒŠŽ4Â`~øáíÑ(µBD ¿øÆþŽ/Á½¿œng¿! Á½ßœj¨ˆ€ˆ€ˆ€ô+©Ä}·4ñ¸U‰Û-�”€÷”†ÖE@ZL îåc¥ZÜU'" " " " " " µ¼ùæ›áÜsÏÍÅö 'œ0,¸à‚µ’k»ˆ€ˆ€ˆ€ô ^‹€ˆ€ˆ€ˆ€ˆ€ˆ€¤áq衇†ûî»/|÷Ýwq×O?ý^xá…�FCŃuÌ1ÇL³j]D@D@D@Ú‚€÷¶8 j„ˆ€ˆ€ˆ€ˆ€ˆ€ˆÀõ×_N?ýôº öÙgŸpÜqÇÕM£�" " " "Ð[›¼·Z§zE@D@D@D@D@D@ú �e–Y&0Áeј쒉N/ºè¢pòÉ'w뻈€ˆ€ˆ€´ y¸·Í©PCD@D@D@D@D@D ˜uÖYóÏ>>ýôÓðý÷ßG “O>y@t—‰€ˆ€ˆ€ˆ@»ÐK»Ÿ!µOD@D@D@D@D@ú�I'�´Ÿ±WD@D@D`t! �2£Ë™Ôqˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ô* _•‹€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€Œ.$¸�.gRÇ!" " " " " " " " " "ЫýWñ«r�¾HàÅ_ �?þx—›¾á††o¾ù&üãÿˆe¬¶Úja¢‰&êryí”ñ§Ÿ~ ×_}lÒòË/¦œrʆš÷Úk¯…‡z¨¡´žhÌ1Ç ë¯¿¾ÕRz�€÷^?j€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@_#pÓM7…}÷Ý·ËÍ^o½õ‡~6ÞxãXÆÓO?†ÚåòÚ)# ~\#FŒhXp¿ãŽ;ÂöÛoß©CwÜqû¬à>jÔ¨ðú믇±Æ+,°À�:n%n_ÜÛ÷ܨe" " " " " " " " mJ`Š)¦¨)�?óÌ3±Õ“M6Y˜vÚiÛôÚ»Y³Í6[4hP‡�l$M‡…ôR:m¶ÞzëÀu‚ø.=Hp=ΣŽBD@D@D@D@D@D@D@D …¶ÜrËÀ§Ì 7o¾ùæáŒ3Î(K·M:é¤á˜cމëSM5UÍtýqÇu×]'¯ïþxâGƒc–à>œD‚ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ß#0É$“„ßýîw}¯áj±ˆ@MÜk¢Ñhï¾ûn \ÍüóϦžzꪆ}õÕWaäÈ‘aœqÆ ³Ï>{išªL¶áûï¿O<ñDȲ,,²È"1¦xYºâ6Ò¿üòË� d§™fš°ÐB …1Æ£˜¬Ï}ï*?Ð>ø òœqÆãy{ì±}W—–ÿýï#ã7Þx#0I,ç~Î9ç ìRyÊÔ\-Üxà�pã�7†W_}5¼ýöÛ�xW³Ì2Kü13™“Œ.Æ Ž‰f˜a†0|øð9¬®–IL(&¬èŒqóžk®¹:“EiE@D@D@D@D@D@D@D@$ðÚk¯…Yg�5¦N'M½í¶ÛÂÊ+¯ã¿#²_xá…áÈ#� ®nsÌ1G¸ùæ›c~ïm¶Ù&Ší?ýôSL‚ð½þúë‡3Ï<3Ô WóÜsÏ…ßüæ7á?ÿùOøñÇc¾ &˜ ,µÔRÑó~™e–ñê*–ŸþyØm·ÝzÓgŸ}–ï›rÊ)ÃÁ¶Új«|[«VN?ýô°×^{Åêà:xðàÒªÿøÇ?†]vÙ%L4ÑDáý÷ßLºêÖYÅót饗†£�>:¼ôÒK^dìü`ìz¨¡e—]6Ü}÷ÝyšO>ù$߷ꪫ†ýë_ù>B�zê©QcÌ7Ú š*眲%¼§dz½eêöã�?öØc�pÏ=÷Ô<êÿùŸÿ Çw\>‹qÍ„}dÇYg�ø¡m°Á=&¸wµÌ�wÞ9vptÝ 'œÐgwþIÑIOb­*�a¡´" " " " " " " "ÐN:餰ÿþûGQu‰%–_|ñE@Fd_{íµÃ¹çžÖ[o½ðñLJ!C†Dïgöøá‡ášk® ˆ¹ÿþ÷¿sA×�á²Ë.‹b;šˆÎx§÷ÝwáÙgŸ ·ÜrKÔðpš]a…ø` ƒBDеÖZ+îC³{þùçÓ¬aë­·Žb;akÐ]ðpÇÁO|Äz4'<òÝ;ÓC8oäãåã]¿úê«Çªþò—¿”VI§Äˆ#â¾-¶Ø"OÓB¹xõ£k²Ž ιÁyذa±žSN9%�>�g<üùçŸ÷1y.ßùÐÉ�ÑQB Ï}ÂÔÜyç��óKdžÇþçX~øá˜NÚƒ@K<Üé1úè£�bOÌwÜãLŸ8Q •!ç /¼ø¡ôeó�xJí–eÅW ýë_û2Vµ]D@D@D@D@D@D@D@úÄä�6Ú(V$µu×]7,¾øâQ$Ç£g¼ªÝpx=öØccä¶!ÓÝ�(?üðCŒÊ@șԈŽ Où�>úh  áZ0Ä`Âcx„£ù¥6÷Üs‡ûî»/ŠîˆþÝ1ª;*ãÞ{ï��¤CôþûßÿhÂY{¸/ã†n?ÿüs˜yæ™C.§«<¼\:~ñ‹_D&¾�å ,ÅòÍ7ß<|úé§1Þ=!œ=¦»/ 5CFjt€»Ûa‡bìvßO™cŽ9&\yå•f„øFyyZ6�@Ó=ÜÐéÍÁˆáÄEUf\€ ½À¸½·©,m_Ù†—5½M 둉€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@g Ô �B w GÏTl÷ò§Ÿ~ú¡W0ÂÊÍÃÉüú׿ÎC°t‡GZþ�˜~Í×é¡Scô@£F˜�ùNØço¿ý¶*+^ôŒ0`„¬}4ÝÃ�^-7f9®g+­´RôjG¤gˆ âõŒž8zè˜�™²‰Õ¨ug¶a~\Ðü€™ðµ;¡Wø±ø²ôZQ&�Å^­F�«ÝÓÁŽX_ÄœböêΓ~0< fóÌ3OCÜ}XQ­zžÃ°!†ûpgši¦0ÝtÓÕJ®í" " " " " " " "ÐRx�—™Oö‰·v-4hP•PKH Q�utš2CŸÃpŒE#t¯Çm_mµÕ“²Ö2„ï8 Öã©^ëØÓf˜a†ü+žß›nºiœ(–P+©ÎqyÛrË-ó<Ýá‘b+e�ìç<Á Ïú2Ñ<-#]ŸvÚiÃòË/ÛÌ‘Äá'L7Ñ+†õ«ñÆ/Í¢õ6!ÐtÁ�Dn÷ßÅp ßîKzm²Âš‹*5zƒö±í¶Û&Ød“MbÌ"†l`\¸üNÁÅW˸‰teöeŸà€+1“Rã&s衇†%—\2݇±ø¤©Å^5^ÚJL+&»H�Y’Cœ&n~½ið¥G”sBŒ®‹.º¨´9t�ŽØb—Ç‘"1ûˆÙÏ%ö»Ñ»Æk„ã�?>Jãû–^zé8‰‰?žnŠ_ýµ' ‹-¶XøóŸÿ'a#ÃgŠyУ꽪tâ0¹†ÈNÿö·¿Ÿ½;î°?Ì}ÔQGÅ¡@¾MKè õ„mÚÓÑþb›‰³Ž¡‡Ö¹cVŒ‰Q±gœ1.ký©× P+Oq;N‘iœâþZßÑ�Р‡Ã¼’^:z’� ŒîðHÛ0ÕTS¥_{d�>ûî»oœ—¸íçœsNüP8ºQ5ˆïÞ×Ãr÷¬6*¤éj.1½Kx£Ÿxâ‰�^'†mÔ2âÕ3Ûå–[.z¶S.åã¥Ìˆ)„yÄïÃ?¼ª˜®Î6üæ›oÆ ø‘G‰eÒ3…:u"œ3É+P°, ¾U�° xä#Ò{yÇ /9áÁ�ÿ‡?ü!ŠË\pAY-ÛF,)n¾Äê¢Ãœö�‘ œ:MÒóˤæˆá7K†ÑñÁ¤|àH‡DY¹L²êª«†‡z(pãbÆl!¼3 �XUtR4jÔÇ5Ä�Šör.)›ö3b‚pFL²�ÀÏõ%�Ñ…€ ôh>8B6bîIí¡Q|Y+¯‡B©µ¿™ÛñÄ'2B:zÓA«ó‰fSïvvt‡G3�ƒ²áN ýÃ;,üóŸÿ ·Þzk f=ññÑÔˆÓ�†È$¬Ò°š}6:Q¾…Ühº�tÒILGœ¬g)3¯ãÌzi2óœn¨þuÖY'ÏOYæE�Ù0Œ<¯]h™Mv�§ùÇ?þ‘ïcÅ&aÍLÐ�ûmöåì›o¾É÷›ÐšÙìËqŸ‰é™‰Áù>VLð�ûÈÉ%—dÖy÷[O`v×]weC† ‰û-FUf1±ò¼öŽÛ-4N¾�•C9$nŸp 3Úiq°òý“õNÅý"'£ŽÔj•™¦)[·ŽŽX&ÇIû;úX�_^ŒõƼp¿é¦›òíéŠM.Ó˜��nάW1n·žÍìî»ï®ØwÅWd“L2IÜ¿Í6ÛTì³¶ãvú”Ùd™ÝTòý0¶ÉBâ~ÚdÞóqŸyÒG–ð¤>ö�|òÉù6öcÖó÷Q®Ý|ã6ÿc‚{fq¿ýÓñÍ}jiO±ýÖ»Ù§Ú­ÆŠ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@w ì²Ë.ñ�ØÊîÕ­üh|,¶vÝr,ÌpLGZ Û’§µð!ùöTÃÊØÊŽ;îÓXø–tsźEžˆiгÜÌa4n3¡9׸|_GKs�y©»ž™Óq\hg�ÚŸþô§<ŸÍ Ùh¶ªtó<–cqÐã>sèÌ,|sf� ™9ÏV¤ï�FΕQ/,,†|EÝ?nŸl²É*¶wô=‹kݵNspí(‹ö·†@ ÍQ;Ø’]=e } 7†YŽ1<Œñ˜fRQ†<0‚°Ä"²cï°Z¼× B*7ân“h¬8éCq¶a�sEZŸ}/sb)ÑV·{î¹'ŸH‚‰!裣7�ð#„¸ÁðÆ¦§©#óxQLh@Ob¯�còI)ð„§·ª'�øWx’wôÁÃÛ ¦>Ù-!uŠÆ9»þúëãæ´—�.„Ô!,ÞñÅÑ ÄÔ"¤Fhž7üÿ?LÊaÂ|ô8÷íÄê‡�ÿñÙ±é=…%ïIå\·Úc6êb,0âmùèÎ}1ÜŒ·AKè‹ðþÆüä“OÖ<„wß}7œzê©ñã!~çœsΘý«žfB(”Þ4¢/ Û™hà ÓÂE£Ãù¤ªÞ¾îðð2š±´ŽŠpöÙgGÏöbùèYg�uVØyç�ã.¢sBÖZ"¸s¨ÄMã�7¢Küõ4¶�yŸóX«¬²J ­Bh–Z†ØJl¢2CDöØáÄi" Ö�Ù†‰�„™ÇtØxã�ãzñ1㉷~ÄGóZ/î®úNçóöÛo_µ� iLwŸº4a 7š§z¬�xW„JíÁŒ³,Ó‰‘Ntk½’±…ŽfV.3B1�*1´èÐ(Àj…éñÙ°;3Ã3åÓ±‚q�=ðÀq=ýÃM™ž¹n:"•æÓºˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€´;⯯´ÒJ±™„*©e{ï½wØgŸ}Âyç�Æü˜ }{ýõ×kÎó‡C*aNzÓpÌõc$¬Œy–Çæ¤Ž¢Þ¾îðð2º»,s@~â‰'‚Eé6š ¦ƒ2!“ÝÐLeíA`¬V6Oã-¶Ø"~¸�˜¸Á“8Cô4ñƒ¤ç‰™Œñ˜¶ð'UÍÃKÚB·Tm÷ iì)„üaÃ†ÅØîìïÊìË´ÃãÛc:Å …?Ü„µ�6Ú¨*)¢11èáAïU³Œ›MêÁ_«žti6ß|ó8³3çè–[n‰£<¯ß´,ìOE‡ƒÏòŒ—ùÕW_íÉ«–6l&n³�3U3Xךᙠ~#éÌ Ïä£Ã‡š&ÎêÌŒÏ\7LÔŠO{ë]c”!�¾JÀB®œ-Ôqœ{‡S÷üþôÓOÃUW]<ÊÁ;ì�&Ñp˜ÅÃïj(ÙïÑ ˆj�3&×Ý5&hõr;*‹èEÝçQ4,¢/àTiáu¢æXVVWy”•Õ™m´ CoÃqxèСñ˜9nw@%^ûÖ[oG¸†Fæ"d¾LŒ|©ssܨ?½F ¥‚{z”„ü` ~ü@ñ' 눢\P~áy^<Íë“ L3Í4ñ¢{饗bÒîÌ6ì³/3ÙkOšÅ®�¢/áeøA!þºY\s_íñ%"µÏÎܙ »Ãä¥Üˆ¹áâµîæ“NЙ’šs'½ß¤ÓýÅõ²�2͘á™0@LrËÍŠQœóC�-<ÿ4ÒΛb[õ]D@D@D@D@D@D@D@ú* ³ÿþûGïo´ô"t¸Gy$üüóÏñÐ6ÜpÃPt2%¢ H‡ö~ûí# ã¹ÐÎD¥6ç^·ðxdƒF !,³{á{zC'šh¢èðË6ôG¢c”Ywx”•×è6M‰®oŸôý�¨ D„8òÈ#á‡; pfeçÈâÐÇp@äC íí�oI×tÁýÊ+¯Œ1�ˆ^Ï[™ž›<0z¡óCÅk™P%«­¶ZŹ ¾TGæ1¤|é=\ÔѨˆÊÅŠ¾ML«Ã;¿§Œ8êt(pŒxÝóƒâc“¯FFôÊÙÄ�=U]�•Ã� Á�ö÷ &Ü\_·aDtrÐÙš‡cáØf�uÖtWé:e´ÊrCg qæ9&âb†ˆ˜d61lüpŽ.¿üòªÒVµQõˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@³òxøðáq^ÅÇ{,¸ã*õM;í´á·¿ým íóäy;Árï½÷F¡�9ûÚÑW<ñf›m– îÅü^N³—Do ÊXÑQ´XWyËéÌwô2"QœtÒIÑ ¿ÅÇdœ€O;í´(°?üðÃyñèœDá<¹XŸïÔJ¯hºà~üñÇÇ ‚‹š!½WîbnQpÇ#¹žóœ^Ì=¹}bLz}ˆÛÄÙ¨Í6ÛlOmï¡«•�:ç꧘bŠZÉN0Y(? z¬`Rôâ~ï½÷jæïÍüˆéEch=mÄ®÷p2ÜH]`÷6Òq@ˆÒuÔQ¾¹m–´—02|0Î ÇÃ$¸O=õT>E'Â6ÛlÓ6mVCD@D@D@D@D@D@D@ÚŸ@YLî²VÏ2Ë,¥ñ¹ ÜQçž{nàSÏ>ùä“z»c(æûï¿?:Ëš}‹6!òºkYƒ gžyfü u!Ö£!Á­£ö{ºt¹ÝvÛ>=eçŸ~àÓ¨šº3<9OÔ]œ1m!yÒ°=é>ÖÑ¥øÀ™�ÔÌýˆ–ˆ³.ü²ö#0F³›ä=,÷ÜsO>¥^�.–“�ï¢Ýwß}qBËâvÿ~óÍ7ûj.¸wg¶á9æ˜#–ç!Gò“D~¼÷ wÃpœzF {ÍsS,ŠíäýàƒêÑkûðh÷‰c=DŒ îe½„Î�¸üõŒxýp#ÌK³ vbäó!¬Ojô|rÄ÷â†ç»LD@D@D@D@D@D@D@FgD` 8axgši¦ºb{‘”’/Û‹iúÚ÷îðhÖ±Â�‘þùç—ØÞ,Ð=PnÓw&9Å;RŒùTÖþ+®¸"nf¸‰O�¦#&ÓÉ'ŸœnÊ×ñ`wÁ›Øð ‹Áº3Û°Ç‹bPB�”ÙÅ_œ‹ä…¬yõÕWcˆ×ÓO?}Yq�‰*ܺÒèy›±$¬ Æ$·„üa2 BÆ,¸à‚UÕm»í¶q![ˆS_fx’#â3ëuÚÙR–¶+ÛŠü�ÀpbŒ1ì©Ì6ÅõƒM8á„eI´MD@D@D@D@D@D@D@D@D@ª4]pÇc˜I 0ø;‰¸PEc¶`ỷŸ]+4ËÑG9ä�ÜSœ²"ÃDxÒc‡~xEˆfFÄGü%ݨQ£b:þ"…xIîµ�ãØ|óÍñç1ÚDüòTÄEt>öØcãþ%–X",¹ä’q½Öz 1b )-ë³Ï> {ì±GÅp ¶õ¤19+!rù”yÚsŒxýSÎN;í›VæÝÎŽ¥–Z*Æ’â „ÀíÇË’ë€2ˆµ�§?!kzÊ|²]bˆqm0 �:¹ˆßŽ1gÀm·Ý×ýióóä“OÆMžÖ÷k)" " " " " " " " " 5 ˜ÀØt3q6[tÑE3kDþ±a&™‰·™ š™ÅxÊLÍ÷­·ÞzÙ�?þXÑ.íãþ•W^9³8Rq݆wd&†gº¤"ÿ^{í•ÙäªùùbwfñÛc^ê³�5™ ÅÈ,–w^·‰ñUyMÎ,.RžÆÄÜl™e–‰ù½Ý“M6Yf^üun¹å–1Ïl�o·8K™ ÖyY”»âŠ+fæQ�q<0²Ž‡ÌâÏÇu8YçAž¿¬Ì|g�g–žƒŽÖ-–~i‰ÇsLÞ~‹ç•Ùä¥éØh±ï+νŖÊläAÆqyýÊ%³Ž‹Š2L¬�û8à€Šíéo‡…óI7Çõ­·Þ:/ßë1ñ=î³xW™�zÈ÷³ÎuÈ'm—ŞϬc¤ªìvß`£1â±M9å”íÞTµOD@D@D@D@D@D@z”À.»ì߉;ì°-W…‰€ˆ@¾624ÝÃ�J&˜`‚~䪫®Š1†Ø†÷4j#ûùçŸ�ÞÇx‡_vÙeáꫯÄJ*3ÂÃàÅn"vÜ�—4ÞÚx.ã=N^¼äù^4f&<õÒ… FŽcËFäôÓOþóŸ«ò.å‰'žˆ˜°=âï¾û $˜¸€�3ÄpïÈQ‚—ýꫯ“j‡Øå/¾øb`fb<èO9å”`‚qÜ'CÓQÙ­Ú�G»Oœa��RµŒósÎã„LìÀäî=ÏèF x¬ÿZåtv»‰ñq²ÖÉ'Ÿ´‹óÀ$¯L°;pà@Ϧ¥ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€Ô%0e¾nŠ&ìdV]Dd>TÏd ˆœõëu×]7†$!.ø\[…xK pÄõX Œ?þø ·–0&�™}9-˜�ëši·yͧ»^OÅtâ Ó1‘Úk¯½>ÿüó8!k­ˆ4}_X'”ÏÓO?&žxâ0Ûl³õzŒt&°5/ü`^úñ�Ž—Á6ËsY‡M_àK逢óÉ<ÜÇ~ØWš­vŠ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@· 0gÛÙgŸÌÃ=†îv�*@D@'ð�iŠã—»‘7^H—R"TóYz饻”ß3Yx’'Ü¿wf‰€íñÔ;“�´ž%~:›¯˜Þ—Ô�Áy–Yf)féóßñ8gæêv1&Qµ�FñÓ.mR;D@D@D@D@D@D@D@D@D@ú&�–„”é›hÔjhœ€÷ÆY)¥ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€Ô$ Á½&í�Æ ôJ ÷Æ›÷)÷ßÿ°Ùf›…Ñ1®ùÿ¥ÖD@D@D@D@D@D@D@D@D@D@ú*�>#¸>¼¯2V»E@D@D@D@D@D@D@D@D@D@ú…”é'Y‡(" " " " " " " " " "Ð|Ü›ÏX5ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ôÜûÁIÖ!Š€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€4Ÿ€÷æ3V " " " " " " " " " " ý€€÷~p’uˆ" " " " " " " " " " Í' Á½ùŒUƒˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@? Á½œd¢ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ó Hpo>cÕ " " " " " " " " " "ÐHpï'Y‡(" " " " " " " " " "Ð|Ü›ÏX5ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ôÜûÁIÖ!Š€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€4Ÿ€÷æ3V " " " " " " " " " " ý€€÷~p’uˆ" " " " " " " " " " Í' Á½ùŒUƒˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@? Á½œd¢ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ó Hpo>cÕ " " " " " " " " " "ÐHpï'Y‡(" " " " " " " " " "Ð|Ü›ÏX5ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ôÜûÁIÖ!Š€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€4Ÿ€÷æ3V " " " " " " " " " " ý€€÷~p’uˆ" " " " " " " " " " Í' Á½ùŒUƒˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@? Á½œd¢ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ó Hpo>cÕ " " " " " " " " " "ÐHpï'Y‡(" " " " " " " " " "Ð|Ü›ÏX5ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ôÜûÁIÖ!Š€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€4Ÿ€÷æ3V " " " " " " " " " " ý€€÷~p’uˆ" " " " " " " " " " Í' Á½ùŒUƒˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@? Á½œd¢ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ó Hpo>cÕ " " " " " " " "ÐãŽ;n˜d’I AƒZP›ª�j2³êÍÚ""ÐW <ûì³aèСaÊ)§ ~øa_= µ[D@D@D@D@D@D@D@D@ú�o 0¾<ÜûÒ)S[E@D@D@D@D@D@D@D@D@D@Ú–€÷¶=5j˜ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@_" Á½/�-µUD@D@D@D@D@D@D@D@D@D m HpoÛS£†‰€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ô%ÜûÒÙR[E@D@D@D@D@D@D@êȲ,|úé§á«¯¾*M×ÑþÒLÚØ/èÚè™ÓüÍ7ßÄßàÏ?ÿÜ3ö@)œ[™´ŠÀX­ªHõˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ô,��>ú(¼öÚkaâ‰'sÎ9gÏÞGKƒÉ³Ï>f›m¶0ÁTEGû«2ÔØðÅ_„çŸ> 4(Ì?ÿü5RUnnõù¢ãᥗ^ ã�?~:thecô­Š@zmü÷¿ÿíôù­*°›¸Žé8âZž|òÉ»YZë²?ýôÓáÇ K.¹d`~Ž9æ“L2Iëa5!øsüðÃÃ?üÆwܰøâ‹·´ í\ÙgŸ}¸�q��9æ˜a¼ñÆ SM5Ugœqê6›<äýúë¯Ã€âýeÒI'-½ßÖ*ˆ{'� sÏ=w­$ùvê5jTøöÛoóvv¶¾¼°­HpohU#" " " " " " =Mà§Ÿ~Šb¢og !êñÇ�YZh¡0Æ•à;Úß™ºZ�öÝwß�Ç3Í4Ó”VÝÑþÒL%a„�X´zìºz¾Šu4úÝÛˆ˜&ë˜@zm B–�ߎKé¹ßÿ}l籯B,Üf˜a†ø;üî»ïzí^yå•À9Å‘ý>Wï7ÚW8w§�܇^xá…@SÑè ˜i¦™ÂàÁƒ‹»�Ptà½÷Þ{UûÞgœqÆ0묳Ví+nøòË/Ãûï¿ß¡°O}t:}üñÇÅ"¢Ð?í´Ó†!C†Äõª½¼A‚{/ŸU/" " " " " " ­&€g!¢Vj¡£ý­no£õá‰à7å”S†±Ç»*[Gû«2ÔÙ0ÖXc¼,‹Þ }•]�Cí»Š×F­óÛJŒÐ@$8p`+«íV].Æ"†ö¶¹P‹wýtÓM—7§¿ÿFŸzê©ðùçŸÇ{äÌ3ÏGH1"�s‡ÿúë¯Çk.e<¶“ÆÅõÉ&›,þÿ o¾ùfÌGgK-£3½£S€sÈo‘NFH0R�mŒZ Nî¿C»™÷v;#j�ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@—¸ØWм°Žö{ºF–N8aX`�Iª4}€@ñÚh‡ó‹÷n_2<§_ qE£Þ4DuÄY¬/…ãi63ÄjÄvF½0º‰02nè/¿ürxûí·£Òû(£-Þzë­˜”Œ´C…ŽG:…äñ�g_:ªq¡ÝCÑà¹Þ‘ÑðÁÄd„�IÏáSLø}âmO›ÚQp¯3ÖÑÑj¿ˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@[ \±uHZiˆ(Ô‹ÐÕ¨ÑFBw°ìL¾²òÉO˜â4#­£ýžžãhe(‘Þ8_„ùèéëƒòàÖˆ˜æ¬D»ÊnõòÒ¼ÖiO£×†·;]’—v 6·ÚüÚélýÝi3yáZv¼¤ðNÅØ2&¤éì½ÂËéJ^<²»kÀw™Á‚ãáCºFÍ�Å;ÉGÎ7ç¡+æ"6!·R±ÝËrñÚ¯-ߎPO�Ü_ËÎ/èŒ*"ß'Ÿ|âÙâÏwÄx¶ÓþF qû=Û=/¢;{îgífòpo·3¢öˆ€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@ 0â�Èär.j V0¼щp+Ï<óLEé<ð@üÎdy„b©·ß=n‰ÿޏ4Ï<óDoH���w+ å Ññ�âTh¢­´a–Yf© 3räÈ(d!ö,¼ðÂÅ"ãw!Ê#™u´Qï\Ž ~´�O&£}î¹ç¢Wè|óÍ&šh¢X¼³ô6ù÷´î”­³óý�œ/O‹Hƹ¥#æe–ž“²މ ˆ^. Ž�0 ´�ãí¬q x™â1ëeRe¶Ðe“d’Žc�ù1¼a ŸÂ¹+ËóÐCÅs»Øb‹E/Y®:j¸–üºÁëc¼\åzœzê©Ãì³Ï^áuÿÿ?e׆ŸO?¿izÖñÚŻ֯¶‘q�8Ö/œíx ¿ñÆ1üÅ¢‹.ʦ*#ÄÓ“O>ÛÈÄžü^ ý�ðÈ5è#áÍq2)njxýÖúÝ‘®3m&½·Ûï!üF8fÎá¼óÎ[Ñ&ÒâÃÏߋƵי{EzMs®ÉËùðù)¼~®Œk‹óšZÙoô?ÿùO¼ ><^G/¾øbÌÇ5šž¿wÞy'ðáÞ—ç�k™ûG™‘‡ûmå¸0Äêé§Ÿ>Þ¯Ë~‹Ü›¸†<i¸á…ž^eõ¥Ûü7Wö;óvP¶ Ù>RÁ¹•Ý[ÈÇõÎÈ~K¤MïýÜ_Òxq.ë¿%ŒûŒŠ�&û÷Žv ¹Ôù»i<ýhˆO<ñD‡ðZdUD9D„9D ŸÌñÂEÚïëéÒ×Ëö³�rÝð7I�…h„@ˆxˆp�øçõ’{úé§c§€ 4ˆ%åäC°CH]pÁ+KêâS—ýK ylá2ïKÒ p!Ú÷ÓvuŽCè�!í`mƒõ³t#_±Mlããæë¾ôí�9_äñúSÑÊËò¥Ÿ“´�¾�úsÂà�(ì“Yrþ`OgB™Ç«—Q\"ö‹œKDFÄ/®;êáz¤s ÞØGD?ò "îq½°�é("qñ:¥|®e ¡#�I°F|NÅvös¿ãþĵ�(ß]ãÚ¤ƒ sÁßËä^‰ñ[ªe¾ÏÓ$;`ð£IDATÖJ×èvŽ×G¥ð;¥3‹N%Äv8sMï#�–ÛŠtµ)µ¢vÕ!" " " " " " "ÐmˆîEžÆvÄ1¬§¼Óò|R±5ÝçB5âB+æâmÁs¼Ø&DLb$wä…™ÖÃ:^ ˆ•`eVk?b0Ùt¤õiÅPé¾®®·ú|!„Õ:¸¹øW&—£ ‚”™ ¯žQ� ´. {Dj.=½/61 ã—äO™÷7ÇæžµÅ²²ßë+k]Iµù*B+×,×|­k”ß› ®~ÌÀõE>„u~©9wÏ—î+®ûo៑ ©qœü~øøï²;mö²9ǰeçš4x#׺ÆHÓÙ{yܺ“×ËèÊ’s–vbz´‡øîŒ)â· ò¬»ùyàyç‹ïó%£øÍ"£Œë�kª¬¤qæ\Cœƒ®í¤cA›uîÝÅ6¦ÇÒ•:º’‡NFàP7÷)Î÷*î×ë£�>^·Ñíh )ÓŽgEm�NH‡þ³¹HÖ Á¤èq™Ö�H„¸Dø÷ÞEhFpÅ«�EÄNçaÎx´#¬³­h~-p~j];lO…u?wÜC ­R˸¾ùÍбY<ÿµòøv:ICÛ©ŸÑ)îiïiXz›Ë:­<�ÿ�©õ{ót�,ù�ЀÑÙC'€—KÃÿw:›Sn�”ßì4Ü›MXå‹€ˆ€ˆ€ˆ€ˆ€ˆ€ˆ@“ ¸ÒäjªŠ¯%€zBö#¥Ô�!C¢@BBU øð!ä"Þ£,�bB ùʬÞ~oW-¡ÖËëiÁ½Ñcóú»»lä?ŽZûÛa{=ÏÓŽÚïû�G½ãALCð¢>Ñë¥gyþ_{ç²*Õцámˆƒ�©�‘ˆâYpæµeäoÈâ TfâÌ ‚&ý¬ðnÊÚµzUw¯n;{?íê½êü¬¯*ÿÿÖ×ß⃠—¾ÆêDXl=ϱ:ëÜgËl§Õfø¬;<Ñ9P@|Åî #”÷x·gL!ªó¡­ˆŽ´…‰ç;±ÇiÓ1ÓgÚHÿå5±ÃǼRvŠYò[}%/mÕ×ä·êÖeWù{¬=j‰ÅA¿8à— Ý9¸#¿ܓ׻fgÖvƒÀ<•°­žÄ:ÄF8ðÄ–ˆ)?eŒ/ýxÝ·úI^ÆÝ*Ó{/caÂhî±ý±_8õö7w9c¸ÏMÔö$  H@�€$  H@'„âÞXBŒ¸!¡‡{ =€p‹˜Dìb^Šš¸ïľžÁéa‹¶ÆÄ¾©üxs2�1ÁAg,olîsßO(…eíÆƒ¶U¦|­ü<Ç<§V™ò^B½D+óòïÙ/^ ψ{%딩¯ˆí±™”¯ËÌõ÷”m´úɘcírá’òe™ÄÆŽÐΕu°,KêÓ'|ˆû<3Ú䥚7oÞTì•,Rưɘ‡†ÿÐÂ2^Ý˾P56Öhf84ÈœZ6¸IÝV›ÞËËOyI-B8{XuÚníY3¥[c@ÐfÍ †ÓF¼ÕaÃ÷±}óéõ,�ØÎ3ã×Sb;c�Ŷ[ãO^ÆÝ*Ó{�ƒRÏÞ×S¦·ß¹Ê)¸ÏEÒv$  H@�€$  H@'Œ¢eK\y$„¦ˆMïÞ½;¸{÷î×VŠàN^¯àŽ7å˜$cX–O…„‹©=R3><îtŠ˜‡Wt‹7coÝϸɋ'rî劘ñ·õâÝ”+¯ ß0Ö&Âù‡†PñvMÛ„ŠH色M¾¢ƒ„¸›nláŸ)Ûhuɼc/ yQ—ãp#bwæ\–‰¸ sÄWDJ¿ä—eëï<+ÖϽ{÷¾ÝSÖî³~æsÚ¯¯ØcÊ‹;ëüòïU÷йê–íÌñ�µÑåè'/|óæÍ v¥>ÂÚÛ·o1ºä‘ü±kY¶Åv¬Þ²û°`ŽpÎAFÊ#ÄñÁ©„Çy}¨�Ð\¸ã}�¶ZÜÉ#|Þ´�¯_¿NñáŠöû÷•ó̉ÃLˆ˜ð2Ä©Œ½dnÄðßfê±�VÿØKâI3Çš'Ê/_¾æŽ`Xó¤M8sÐƒíæ¹E„oõYÞ£„RS·ö²‡)Â'‰>HsŒyh¨ñÏ ;hͳ.¾ê^QÖߤnÙN¾o²F© SRß´ÛÏýò`‰µ�_â°fêý�µÄ¾HŠ= ¶ÇÞ^½zu¤¡tbC=Ï€¶s¨Å¾Lû½‰Ãl—}‘ñ'Œõ±eöOv±|¸±æ?98ÂÆêƒ½pfó}:ˆ‚ñdFpŠUÇãETFt+ExDDèˆXS®Sù)‡ Eßx�rx€( î!.‘Oÿ™-a?íäÚË.å{®0‚[ˆÓÙ¼Œ ïS„Ø1oÐ0FèF(ÆëÁ Þˆøˆ¼0±ž_‹;ãå9c+HÀ�‘6©Oì çÏŸ?<¼A˜=wîÜÂ!å>|8<D?ê01±™ë6S¯m´ÆÀ ãÅ^à‰'?¶$p‘û�çXB $T˜¼‡ÇÊ—÷‰·ÍAB$õ±Úàyb£eGöž…’iÈ‹÷xî#È^¸pað²D0¤NYá„:¥X˜ºå•±"6âu‰¸Y§©ü²Ö/©‡ë2åß«îsÕ-Û)¿o²FóSÖ vÌ'6ÌþÆ>Æ=lƒçC_$žÉõëס›5ˆṗijc¯)ÃjqŸgwéÒ¥á`'"~&Y¿ðÇ[½Ç†R�vÙC¦öY&lïÚµkÃú¥-HÌ�5Ï>�¾¬·îwÚ£]þûÂAA hñ�_Â0¦}L§'ÿìãÀ“$°NOÙàù†åx×kÍZ�€$  H@�€ŽÀ+aá/Þ¹ˆ!ˆ™x¡—bßÑÚÿÝAŽÀ+”b^Óx—÷$Ä"Ä„-„Ú:Må×åË¿Bb‰¿‰›�çò­[·º„­²½¹¿36XGà[µ}æ�ÈüZìVm�ò0¢M‚[Ø 7–üÃaO<²{Ã%Mugmb­NÂûå³ËÄzcý0†ü2»˜JsŒ™Ú)Á2Õoò{÷Š9ö™ô¹�+ódž±ÖRmÃì‘d�¾ð«êS¦×vX/ðc�¥^ÏóÞÆÜË}ˆ5_Ï}î>™7¬˜ï*{ÌÜãèhïËbŒ¿Ž·u´` H@�€$  H@�€$�2ÜK„#>«&ꌅ’¡­©üô‡P–È¿-B2 Œ1®R0ްH›Û•2®eWÆP{Ž/+_ç1·¹C0Àl�1Íé [Ïsìï^Û«_ßßϺ�±¿]{·êúsŒ'¿uÓª{EÙÏ&uËvæøÇev¿,�þ9$é=dÌxÙ£æ^¿i{•ë¦ûÐ*}Q–yÏ~Õ~×-¯à¾.9ëI@�€$  H@�€$ð¿&€PLhÂ?�ƒR&¼¶ç¸õP–ó»$  H ÜC«$  H@�€$  H@'Žñ®y %1Üy1!qÆñ\%1² �geo¬êÐ K@�ÀwÜ¿Ãá�€$  H@�€$  Làçý„²Ø‡+Sc�Êç¥|W¯^^BÉ EÞ“ˆ«Ì ñnÇÞ$ ìŽÀqÚgvGÍžö�€/M݇§à$0#_š:#L›’€$  H@�€N^ÈK(¹îâE€' ®“•€$pü øÒÔãÿŒ�¡$  H@�€$  H@½ðØÿ/òìŸå$  H`ÿ ü´ÿCt„�€$  H@�€$  H@˜&pûöíƒ+W®ܹsgº°%$  l�€‚û Ú¤$  H@�€$  H@�Àî |üøñàùóçŸ>}Ú}çö( H`A@Á]3�€$  H@�€$  H@�€$  Ì@@Á}ˆ6! H@�€$  H@�€$  H@Pp×$  H@�€$  H@�€$  H@3PpŸ¢MH@�€$  H@�€$  H@�€ܵ H@�€$  H@�€$  H@�À Üg€h�€$  H@�€$  H@�€$ �Ÿ¾ˆA8>¾}ûvj1›_þY¤Åõ¯ã33g" H@�€$  H@XNàëׯ§%N/®/®|L�€vE@�}W¤íG;&p~ÑbûŸ;î×î$  H@�€$  H@?šÀ‹ðÿ‰ÿѱ HàdøYØ´ô©ó¤IEND®B`‚bpftrace-0.27.1/images/ci_appimage_artifact.png000066400000000000000000001701541526721631600214760ustar00rootroot00000000000000‰PNG  IHDR†¿“ØhsBIT|dˆtEXtSoftwaregnome-screenshotï¿>-tEXtCreation TimeFri 17 Nov 2023 09:32:58 AM MSTÄX" IDATxœìÝwtÕÛÀñïì&›Þ+ �„z'¡÷ª( " ŠXPDPü‰ åµ슂 ÒQŠHGz¡÷z!½'›ìîÌûG ©�PĘçsŽçÈîÌ�»7SîsÛ(š¦i!„B!„¨²tw;B!„B!î. …B!„¢Š“ÀP!„B!ª8 …B!„¢Š“ÀP!„B!ª8 …B!„¢Š³º‰¤gIIË 3+›LcöíHR!„B!D{[ìílpqrÀÑÞö¶§¯ÜÊ{ Ó2²HHJCÕTíl±··½#™B!„Bˆª,=ÓHf¦‘ô,#:E‡‡›Nv·-ý› ã“RIÏ4â`g‹“ƒ-ÖVVèt Š¢Ü¶Ì !„B!„MÓPU “ÙLZ†‘Œ,#Žö¶xº9ß–ôo*0ŒOJ%3ˈ»«3v6ôz™ª(„B!„ÿ‹E%+;‡ÄäTìínOpXáˆ.-#‹ôÌÜ ÐÞÖF‚B!„B!„øéõ:ìmmpwu&=ÓHZFÖ-§Yá¨.!) ;[ìl èt2lT!„B!þi:�‚��;[’Òn=½ŠlœžiDÕTœl¥§P!„B!î"½^‡“ƒ-ª¦’ži¼¥´*Ý¥¤eàh—»ÐŒB!„Bˆ»ËÚÊ G;[RÒ2n)� †™YÙØÛÛÊR!„B!„øÐéìímÉ̺µ÷ÉW¨ë/Ó˜-ï)B!„Bˆ EQp´·%Óxk�¡LB!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨â$0B!„Bˆ*NC!„B!„¨âªn`¨^få—òæ´ÝĪw;3ÿ<5n+ÿ7ž K/b¹åÔr8¹äK^ùp!ûÒ´Û�»Ëþx·Bˆÿ •Ôsá¬Ù¸�ÃçcIÌ0¡Ø8àáãG�ú-éÑ£)þ6 Ù‘Ø”àOïæÞ7ßb¬%slë) -C©ë¤Ü¶_!„âŸQ¹CÅ‘†Ýûa(è•R‰;´‘ÍçmiÚ³õóDz|üoðhÓ0ðÍ (ÈãëVhôÈL¬ Ha¥eq~Ëb~]q’T]鑟â\—ž÷YSjg«9šÝëëæ†[ÕíßBT˜Fú±?ùü—=$:вuG:8@fj ñÑ9t ’ö½›åmk"bû Vf?@Ï[ µ„#¬X¾ŸÆÁ! !D%TÉC{[u °à §âw°å‚uÛt §WgÞF– &°kÖ¯Ì9d&¸ßÓÜwu63•ÜLq ¤CÏÀRÐH ŸÅ‹-º¶ÂSÊWQ^Z {6î'Ϊ6�¾ü Ý<Š>- ú¼ZÖ9œÌ„ [9 …¸#ǹd�Æ·’ŒBˆ»¦r†bæÐìù9±7¾Ð�¨¿—ñ×®3\Ír£ç‹cy0 ’?>ú™Í.÷òþØNxåWºM Z·†UáD¥š±qó§IÛôoï7àõôžj|­ØÔ”³¬[þ7ÛŽ]&1Ç ¿º´íÑ›.¦U¼½@屟¤½ýµ½)îë×ne×É+Äg¨ØyT§iû èZ׼綳™‰Ÿm£ÆsãyÐ~/‹þÜÂþK)Ðà!>z¦ŽJùÒ@3¾Ž¥›�p&&³Á…šM:0°³ëëŸË꯿eiRs^xg0Íl ©‘±oÏ™t‹ßZ„öº—ûšy\÷øjÌf&NÜBµgÆÑ#m=‹6æ\‚ÅÞƒ &mé߯=uò[¤µ6OþŒùÑ­ûÁC4,<Ü2oøñ²œÎŒß—šºÜs#îèVVl:ÈñÈÒrÀÆÑ�j5ëСï=t °¹Ö` @æ¹�Ìý{7‡ÎÅ“®p­V‡¶½ïáÞ&î׿€t.Ô nÄ=m:roÍ4_oë’,WؼáFŸ.ôjb_ŽF ZêiÖ,ÙÄÎãQÄg‚�‡?�ÛõâÁnµq)R/TI9»‹•ëörøB©&+=«Ó8¤#÷t©�—õµí¢VO⣵*}ǽÌÀ€Â‰X8³ä ¾ÜæÂ  ÏÓÓCá†×] Vþ²/¦BçS¯csÂ)Ö¯ÝÊîQÄf¨Ø8{Ô¸5½{µ¡ž‹Œß•�–Ez¦ŠâàKu×’�¦z½ÐÈ8±ŠïfïàbºŠ–4›ö(¸t|†O×Å •ä³{ظó(§.Å›”FŽÞŸ Æô¼¿7íümQÔ«lþu&‹�&bÒà¯OÇó€¾CÞyŽn®©»G«©œÚºž5»Oq>6£j�ƒ»5ë4§ïý v”V2!„¸þÃ�a.55ŠÍó·³åœ+-Zw¦¥�#uËêYÔRÙ3÷g~=�MµæÔÐëÌXN„ÿΗ{lɰ€WáÍ3#øý‡ßØœèBãN}¸ÇÏŽìøó„/ú™ýv­z‘ä-±aLùî/NÛÖ£{ïÔt´:œ¿—M'"ö Þ|¤>Ï;ÍHìñ¿ù!|/Æ:MéÚËkŸêØ+IÇLÔ†|¹üV�!ÜópîJQÇ÷0uz: eœÎ‹ÐК¬X|‚ðY4mnw­Â®epxï)² uh×Â¥¬åk’Ï~ÆD�Æm ñvÅÁÇ�Í›YóÛohcÇò`à�N?#§–Oå„Å��ö}hç)±içr¾¹�ÌØ—ï%ضâ„ìÓ+øæ—pÔàô€«’Eb\4g#RÉ1X LÔÄ0¦Í°" MBÑ¥_&|óNVN�Á<ö¥ü+üÚ÷Ã3Z…æ_j¤ÞÂÖk>Ò–åŠM®°ê§…Ø×¥Û€68¨)DìÞÆ¶e¿§¼È«Ýó‡ˆi$îÿ�/fÆX­)]ú¶ÇÇÞBÒ¹ClYùNöcÜÈNT¿nËÁõ•uÝeŸþ«Üe_Byϧ ^Çæ˜0¦Lú‹J ÚuìK/wkŒñg Û¾œoŸeøØÇhç!ãxE%£ó ¨†Úîcl;܉Z-\)yQ0TkÁÃOذìçõœ«Ý‹Ñ}‚ÐÖ.Õ ¶Ï:wˆ#iî4mÛˆn�Áæu;™õsN㢉­3õ{ âQûÅÌÞ£ÐîÑi례Ο )µpií &­M¥fûÎ<ÜË ëìTâ¢#9yÕˆÞF‚B!„¸Sþó�¡w€ÍöÝyù�^Ô¶+ô@)%–1�ÝÌŸÓpmó¯i€CÞæÛ7`áW?³žÂÝf*W¶®bk¬�¦CžcT[×¼Jwk:·ØÌ—_­¡ÈŒ2-�=­á„ZŸá/>A;×¼Ä[4ÆOý†)»×²¥K0ýªåW@ÍœÜz�Ö�½ÈÓ!n×þPZ:aåLGK?²uÉñíÌØÑ÷R+/ mÓ‚ÀÙßòsBÑ rQ î-ZÓpÅBŽì9Az³–tÐ¥c÷éì·¦ÅuúÖµû1þõ¢Ÿµ0sù‹M>ÃÀ@ÿÌeQIJõâ©ñ�ÓÖ9ï8¡­iæ1•OþÚÉÒ]my­›G‡«Äž9O¢À Gǵ½{•¶uЉÚÏŒæÉ‚»æ„)|øÍ6öˆb@``)•­Û@�eë†cd¸†Ð»•Kù~£)]³‘¼20°àL mîƒùãßÛœØ®Þøê€¬“,[rˆdïÎŒ{/u 6%¤ú >^¸–;2®KEËöšÒ¯;•È ”}qå=Ÿ*tk©ì^ºšcÙ5xpܳô©–¥µ¦SS¾øf=üu˜ÆO5G¦L‰ÊÅ@£{Òñüïlÿí.î ¡k»Ö„4ðűÐMËÚÕ�ºŽ 8ê@çèCpÝZÅ*:ªõzŽw‹\¤� ¶ŠcÂ⓺¨Ò¤¾=¾µ‚0Ÿ2€¢àY3ˆzÕ ÝÝ+Ò(¦¥qöL ¯Î<2¨KÞ(�\ý*òó…BTØ¿\çJûþÝ‹…¥²y쉸ҡ^Ae›´oå[´°Ô$Ž�AulHç–®E¾³òmEû }‘Jµ–ÁþSFl‚›ÑÈÎDvvNî9z‚‚kbPc‰8ŸQèù©`]§ƒZ»yHW$ÓùÓœ6ê¨J`á®AÅ�&!õoXÑUÒ®‘=Ù§r(5?g av¦e›zØW°²¬s÷ÀC¯‘™‘Å�ߢ`ܜ΅¢Ç·M(õ¬-\)!„¸Kþó=†è¼©áWž>•¤„4]mªy�vtxz¸¡#éÚGZ2qI*:o|Š—¢b�§‡-œ-´yR¥ôDZyRÍC‡š˜@¼ 7ÛZêuW±²/®|çSÅ®c-9‘³‚‹�%F%+vøú8¡œN$.Y»ÿ~;šø2xÒ¼÷#4ï9€ØˆClÝ´…-ËgpäX_^Õ•š7lx²�|v/váä¥8Ó�˜,*šj&]ÅzËÅŠº÷=É“–%,Ù4�7;Ô¤íÛ·¡m°{ÙÓ„Bܲÿ~`¨èÑëÊ9ä>ßJ[«T§/^)Ì{* ¥�·ÓéŠUŠ5 ÐáÚr#:û–RÙW°õpA½Pz½¾dÒH'7� J)¿_ÑéÊ5LÐP·!{Ø´÷0±»àuõ á‘~}ZQë:Aƒ³“¾]F„M0={ßÏ€wm­Ð�2ûëÕ\-DZ´R'æ©äÆdåù*ZñøM±#°Ó`ÞnÓ‹3÷²}×^ÖÎÙǺõ­6òAB E‚Š^O9OŸÛ&ûÌ66\°P­g'šV¤K¶œçºš_¦eTè4 Ptå H-j‰”•— ”}‘‘ؽ‡aaÌ�¼�5Mû3ú‰6øßÂüg!„eûï†å¦ÃÕÍ EM$&Aû"ÎHMM/ZwT\ðpÑ¡&Äoï¢K"’š–U$uÅÍ+�8£žjA�7=_©"é8¸¸`à"qq©h¸]T%5•T­c‰õ´kíÆ¿±7¦�÷æŠ.€‡Z—”¤ÎŰœÊr£ËÓÃx°îµÂÑ’*òD×HMH"›@ì šGtš†®š ¹S,uèt ¨ZÉú½–FRš v%SW nÔ íEÝÐn 8²œï¦ïfÁÚ&4Rïú+¶ÞIZ2»×ï'ÑP—a�üïÀªàìå�¹“ŒÚسèßÑË•�Ÿ;ùë­èt *%c@))™h¸V<*ûŠœO»Ž7O¼¬4ŽÇÄ’©Õ(z=i™D_MC³ªŽ—‹ôŠÿņšMêâ¶1–ÄÄ44®j‰ìÙzŒd»&<÷lZj¨ÊŽ*sÙ±RÜÜ=ÚÊ9€�^„ôèÍéU3ù~Ý þ:Ø„Q!åY¥Y!DEIm§€ž êâB{ÃÎ’Uøé¥Æ³ÿ@Tч Îƒ†õ=QÒŽ±ýHZ‘‡�–rŒ=¦¢Pûz´ ¶Åtz;kÏÝüÜªŠ¤cT—º6*çÃ÷Ud>I6û�“X®‘�:üZ·$H¹ÊÁC‡Ø{8뺭 ¹îKõ4²sLhŠnE–ú×H>yŠKå�©‘q€}I…¥‰È�»‰0[Q«AíÜ9ŽŠ-.N0Æs5¥h‰dŸ=ÆñbKöBZá^¿!µì!;Ëx‡æ –�éÂÖ�6áÒ™�âãˆo«ZMiáªq),Œ³ÆÂea!6<Œ#YV5m@î¨T''tZ1Åæjé§8xÆT¡sùæÊ¾"çSÅ®cÅ®.­Øa:½›mÑE_'bŠ cëY öõSß¶?RˆÍLŽ©´«ÓÄåSçHÖ ø '·Â` –Œ 2‹\ä9dgk(¶Î¸^ TËäı‹OÞ`°FѲHË(öE…îÑZÉœuŽÔnR 7ÅBVVNy~½Bˆ› =†…‚»1 ÑqfmŸÇׯtjà…!;�³û÷p<ÅÙ…¶ÖÐõÚï›ÍŽùSQ¯´£¹Ÿ=æäHìy*q�ZìaÈ}]ŶDÚ7bØ€¦²"©¨|ŒGøåƒµ¤àå‚‹³K1玱ïd<6uï£_“¼×éý ²!ìĦ/SiëoM¶m :5ö¢~°+·dùÚ@´òÅ&+–“aÙpÞªØâc:ÜkâÁ6v.Z„K×`Ü4ðlÜœ:N¸Gk)lùu&‡ìëR×ÏOW[Ô´ŽìØE¬M Ý8Ko¡BÜ!¦s£ýð‘Ø¬]Ú½Ûù}¿ k—j4lÓŸÜ÷ðɼsE6WðØKÃñ\¾�;Vq8G�“w¡÷ §cįü^4y½W#_ugËß[Ùyt‹wd£ZÙââåO½æÍ¨QοFùÓ±¦fï§çô7K·aõÂ=XlÜlÚ‘çÆø±ÿ»©,ÏgZµ©Ç’YGHqjMûF7Æ£`ßdc¶fѦ�üôÕ*°uÁ¿^k}/)|™ûòã×ÐÁ<æt�?7¯ak|6:jµÀ€~m©esm;û†÷óÒc6,Ùx€¹S¶aÒÛáY½!�¤ëÑ©ü|îÚ¶nµ‚ñ9½ŸÝö“b´ X;àY½6}žìIŸæNw­ÒaŽÚÅßÇ�8¶èD‡²Þµy[(87y�7^ `õúpÂמ 9[ÁÞ߆}žà¾î ‹ �V\ZòäÈþ\¹‹�s¦²Ìb�³Wu·y”×Ûmçã™å>îÍ•}ϧ ^Ç:�Ö<ûŠ ›×mc箵„§š°rô$¨é=¼Ü§õÝd`…¨„ ~´ `Ûé‹8›JfŽŠbm�›omö§OÇ`<òŸŠ3íJü«Ù¾}9³4;¼;¥CcoêÞ7œ§XÉê øìoƒ“7Á­»1æe+V<ŸÂíŸVA½98‹뎲â÷ÃX»ÔãÁºÍ¨ã¤+ÿ=Z±'¨~uí<Ìúý©dšÁÚÁÿZmxâ±î´»£÷F!„¨Ú­ôÕ=JuèäyšÕº“ùù—ÒHÞþ o-ЧÓè×R÷FK5æ°ï·�˜z´#?}Œ–2Q¾ÂÔ˜ÍLœ¸c÷Ѽwuó,nƒŠ^ÇB!„•Ç­ÆjRß.KûDb±®FMßYîÃô~Õ©.uO!þ*x !„BT%2”´0Ëyþüa-qþµ òuÃÅÞ͘ș½»ØqVÅ¿GWZšl¤FoeÊ‚ ¸Ö©�¿— Ž6 9I‘ìÛ¾›c™n´Òõ"Ä?¬‚×±B!„�À°(�;Á <ˆ|´_j¶UAVem‹2¦ñ¿ÿ»À§çÿ�ïÒ¨´åzÛ¨D­œÏúÄü»²ÇFƒøpÚ|V._Ȣ߾å“W£OSjöç±Î·çy*„¢òªTs 322 š¹ÕžÂâÜÝÝHII!3#“ŒŒ Y­´¼2N°3<†Œl[ÂΣöñª|­ BÜE¦g\uCÆ ™ìËѸç:ž–÷>G}9o0•µ\o çN�Çœ_ú žøè]†5Éì7¦uÇ> }a<&ì ÍÉÌøk -Çm ?ÜÀì!ž\›‚¨‘¸p$mÇoËkü4Ðãómüò 3ŧ)šް|Þï,Û¼—£ç®’”iFoç†_­´lß�þõ§s�C‘ýnfSì~–ÌZÀ_›÷rüb<éÎÞ4lÕ…�Ãg`sÏ’K‡VÌgβ­ì=~�è¤LÌVv¸xúS»AsÚwëÃÀ{Ûèxí¤SS#X;oK6îáÈÙË$¤›ÐÙ8áîHƒæ¡tí}ý»ÔÅUÖ³BTB•*0LMMrš¹ªW÷'*ê2©©i–—SWF¿= —£ôÞ¼r�PâÈaݸ<·&”¯Ã&óÀíî„ÐÒ8òû—|òë:D¦¡8Ð÷íé|5À·Ò6H”çåõZF*£>ŽÃé~_üÄ2?J£F¨?´·0y^¨hâñç“™²!•-sH´(¸¸Ùо¥/tq z‘›†Êú¹çwÆ‘)oySóT"Ÿ­KeO¬™ 3šTcÇŽØÞ¦rý¯Óé ÿŒdd˜)ùØ×ãàp'¢•Ø-_1rÜL&ÊjN�çüámœ?²‹Sv!t]ý­ì³ù ž7‹Ã)j¡}L$F�d{ÔIv¬XÈ£¾æ§±mpÏ/ãI¦??‚�w$`)z ¢N‘uŠðu‹X}e!+_n€`¾´”±ÃÞaÕeSÑ¡¹™ÉDŸ9Hô™ƒlüs']Í'Ës– !Ä¿K¥©Çggg¼§0::š¸¸¸‚ïj×®�««kÁ¿#""pppÀÏϯà³+W®�‘‘AíÚµ9uêx{{|ñâÅ‚W\�F²³³±±±¹Ó?ëßIQJ´ú–½­3Í‡Ž§ù�Ì�h¤mžÈ³ïþ…Öö)Þy©>ÖÉI¸·(¥—:ëß y‚I'ÜyrÎZÞ )y«3Ç…1ùµ7ù~—žaelS.–XÂæüÄ�‹6qðBG?v¸Ÿ/ŽÑQú¨Î¤cWy~[´q`l@îÕ{n{4Ï-7âÛ̃·ûÚচ ß™ÀŒß/“dSƒ�é ®s-3ƒ�§^e£‹3cò ž“BvZ6ë6'ðÆÏ&¬_ñ¥G~[™ÞŽOúÑñH<ÿf¡s?õÍOI¡šoÑ»GÊ©Xžú-•ÔžìI°ƒFdD ?­�føUæu»`uü (G² ßÏç«2ðiíÊÝ­±WURm \íiq�žà&õ±ùcY`¹Â¼×ÇâöÞÛ<×½öwøè¦“ÓõÒ d”¡+6-4 ú[ØÇñ£_žÉ¡ôÜ}�#ÍZì’Å…ƒ9›lF³$>åe^õ_Ì/û¡C#fÙ7|U*è콩[ÇcÏ_!Ť¡Ø¶dÈ zy¥ 6Mú‚ÕA¡‚�gõüÈI¾Ì…È$Œ*XÕy€ÇÚJP(„¨œ*M`˜™•»lŸ¯¯cÆŒaÁ‚ßÍŸ?Ÿþýûüûµ×^£E‹¼ûM›6�0oÞ<ž}öY}ôQÆŒSðý—_~Iff&?üðW¯Æ�™•uýÀÐt•í³&óã¢-º˜„É·úíûóÂ+�acSz`¥eF²sÅŸ,[·“=ÇÎq%1 ÍÖ¿z­é;d$£ÔǹЎæßsßÀ)œmþæÜGÌS™ºx{#bÈPœñ¯Â=OŽfô½uJ]f<óÂffÿ2ŸÛ�r.6“Á�š�ÚÐwðÓŒ¸¿>.¥v±(X¬É<»šï¾žÎ_aÄdYã^³1ÝÉØam©V¸ff cB—g˜«§Ý{3÷ñõÜä°ñ�ÎŒXÑ‚/v|K›ý¿0qòR¶ŸºJ†Î…ê ÛÒÿÉx®O­"¿Éö�ž˜Ob§�ûå¡k­¾y,§¤ÿIœnöæ?I�üLXØ¿ð¦.Ù¾ÓWHÊÒ°qõ%¨A3Úw�'‡¶Å¯ÈU C±Ä°sÆT¦.ÙÄ�ó dé]ð¯Â}OŽfÔ=µK­Pež[Ï/Sf³lÇ1.&š°õ ¢E÷yáÅ¡´õ.y™ii§ùëç)Ì\Ωè4pªN㮃ûÊ@ld™ý2˜9¸a+±ºæLøä õ/ëLË üÛ·™¡–q.ZˆÝù3ã^û‰™T\n>Kj?˜¶Õt$]>Çñ=ÛØpµ ÷ç_Ç7µO"+¿ý™}ùA¡UMÿ÷òÅ P“ÃùtØsür"MMfË�³Ù?ð Z[›9{ìdnÀ  dÄÌ¥¼Õ"÷U³®p`Ã*VF5à�ücY"9z"¥`½Îs“7|Jϼ“ì¸ãlY¹’£¾ƒiPijVBQT¥¹}å÷ÚÚÚ’““C—.]x饗X±bW¯^å¹çž`„ ¬^½šW_}•/¿ü’W_}&L˜P�–Éd*’~NN999ØÚÚ9^©,—X4v8o®»ŠYSÐYÛã¤%plÍOŒÚµ›N�”R–�Iß5™—'üEœ¦`pñ¥z ƸH.ì[Ã�û·3‡#ë•h7ŸÞÆo,`éòK˜õ¶89ÐR9` S…q$y¿=V“kƒ�Tâ¶|ÆScçp4]E���-º¬8Îì^Î÷ákùkãÌúj�%Îý¥?ñÈvö§pñpÆ)'‘¸ˆ0|º—-û?â÷ïPãGiæs¬ÿâE&.Þ�MãVtèÕSÌIÂ÷­â»ýÛØ>v³G7½µVm-™Mï 幑è}šÐ¡û}x()DG]àäÞ•ü–Ì#�µ-²‹B:›ß{Œ�;-4iIÏÆ¶/bûî5|?6Œ£i¿óëà€BU�ä°¯yâùéÉr 0¤#ý»Ø�Îöy|Ó^&Îû†A… LK çóa/ðÓ±L Þ hÛ§î–D"vüÀð�áô¨¦/�í-Z¸øOvïÞCÔåË8;;ѶM(ƒˆ³³ó-¦¬ ÜöÚ¼‰¤Ä44+ü¼ÊJ\#yÛ—¼>;‹~·gÕ‚ÓÅ¾Ïæøocxzâ^ìúLà×�� û0â¦sd>4ƒ‰K¯Psøo,z«5Ž À †lƨ‡Þáë�ÓgæPªß¦²p÷2ঀb«ÃQQðõ°Â`£ÇÈÎÑÐEÑÓ­ŸÝŠí¯Ø[ãgû2,¤k 'Õ9èqÇÂöIlqs¡�¯ w·gHǛϯš”ÉŽX Ÿ64P4² ÝvkÔw æ†$ÂΚ° î_Ö4̵Üx©¡…·Ä!”7§|HÊèXr&3·§KË!fß">±”›àå ¯0´…;·s0©–¸•;Ó †[ê¼îçÃož§G^˧Cp+ª·¢÷­î“¼�å[Óò‚5›¶O3®§oAÅFçÂè™÷ê24°\Þɶ3Z7P°³³½vŸU/³nÖbî x˜žVèìühußZùUvØÛše™Ƽ9a4|²-~6`ãÕ�ÞO6,’?!„¨l*M`˜Èå÷  oß¾$&&rúôi¦OŸÎ°aÃhݺ5ééélܸ‘�?þ{{{:uêDëÖ­ÉÌ̼îqòÓ/8^£rõÏOø`ÝUÌŠ#ÍŸùœIc»RÃN##*Œé^ç›íi¨¥Tí�º<Ãø1Áºô£gSl 'ŠeãŸä]æÀôÙlþÝŠ�BÑÒv²pu î{ÿ÷Ps¼m42/mdâèW™}"™�Óæ³ÿ‘7É §Æ®àíWçp4ÜÛ¾ÀW?M—š(Æöü1‘×>]ËÅUïñ¿ Yø|Ýb'�JÊÁÄôý?þzMÝ­ ç*Û|�'ï!úïOøpy¦ô¼µàÅr‰5K¬:eïw÷Î˃JbØ× v:ûx—©ÝòrÛ?EµäMÌ^‰ø3þ|›v…ÖbWÓ£ˆHr¥V±Ú�–s˜ G{3qÙg<”ÿ‡°på¯q |m-Û~ùƒ#�£YÞ~Zê6&¾>ƒ#Ù�<:e:öðÉû-™™<‚G¿ÝÀ‡-£ãOà«Èfï÷ï0íxN!/1{ÚHš9æ•dö%¿6œ×We¡Ýá… RSSynÔ‹„í/òùßë60}Æ,~þñ{5lpóÐY£]ÙÈ×ßNfáŽâLvøÖkÇ€çÆ2¦o…X#·1oÖÖ…Ÿä|d4 &;|궦ÿÈ×Û§6h$nÿ‘7¿ZÈöc9hê*žo¸ Ð8bëß¼6·U‹ßÀo/Æ2ð{ƶ\IJÅ3f F³Üÿú(F=Ùõ�µ×ÿj2‡þœÎ´…ëÙ}*šTÕOÿ Ú>ù.Ÿ ââîp"©Å¨ZàXè‚°ª>€žÎ¦_W²æò£Œ¸á�‚­!w4‚¢(胕’ÿŠ’»@K>KZ 7&±üT6R-ÕÜï-–’ËQëýÝøàÞlÆÿ�À˜¯°s²¡ym;Ú5t¢_c[Jéô.5ÕL¬ Ñ;.ÓfGéÛx¥˜Q¹¢…:µìp“®ß2Cí|¹¤1]¾û„Ïçí"*¿›L3“ph1ï ÙÎÆ7¦ðÃS ¹]3ë-gŽs2'ÿdTpnß‹NÎ×ÿcÞÔ>G9^hCÚAæ|[äüV£±V P¯pñ²¨ß­3þ3æpÉh9œ_þ®ŸFȽƒyâñ‡éÓÄ£h#­¾:]ºÖå«C'ÈÑ@³\eãOÓõ·Fô~xO ¹—Ðj2„TQ¹UšÆXÕRö‹†Š‹‹ S¦L)èºvíJ¯^½˜0a½zõ¢k×®·çxêUV/ÙEš¦`Ýä9¾|­5ì@‡CõöŒþì%:Ø•ñ0³ªËƒ/=Í}Íò‚BCuî~5õ ¦Dp*º´5Öuø |›‰C›ãm `_£¯�é�‹,1Ç9—Ÿ_ ç–Ìfc²ŠâÔ™·¾C·šèÅÖ‡Ð'>á³!è5#‡fÍfg)/ÖVº2îýGrƒBƒ/_üˆšPÔ4¶.YGÌ-¿—BÁ©Ç(^ëæ](0ÕáÞv WGgŠ`ÉÒ#ÜÒ LF²- G_,ÐÒ9V§^€cÉàV1Ðâ™q<Tø¯ÇïÞǸ×W�9êÇ“ò+"ñkç²,Zãß+¼UØÓäéQÜï©ÛÿdMt^�e‡³hy$f]-†½õ̵ À¦¼þ4­mî|mø‘¡O¶;'GGž>Œùsfòo¿Iƒúõˆº|™!� çØñ7�¾¢äëg>"Ì­7/¾÷ _¼õ¡j?ŽÆ‹ #)22ñjËvgS»û#¼ôÞç|ûîpZeïâ§—_àÛƒ9€‚}í®Œxó}žii…bÛ–W~›É‚¹3øvh�k…z•¥ï½ÏJ»!|>¾Îjig�‚c‹'yûé–¸ë@Óʞ˄–Èæ÷gð›3Ù§´`ð¨ÿñú¨AtvÄÍÝ =�‘ž :'\�ŠÿÍôÔDo>ËÉ3·ñ½ å=5LF&O»ÌÇ»sðjåÉ7#øãå,ëMÏÒ¦=*:šuñcùÿ2s˜ÃY“™Êwó"é?9ž�7ŸeP#Ô—Ùc˜[Ê“»Ø–ÚBéh¯«<¨9ž6ýÇÿÊÆõ³™øLg‚ìu׿—šcØã½>Õ¹v‹Öȉ;ÊŠ)oóH÷Þ zw!‡“eÕ#!DåUiz ¯[�û'�g:Áá“&4ô4èÕ� â‡WGº7¶bÛžë…4Œ)‰$¥ÉQ5ÔtrE-›RG°*´éZ¢5×¶F ¾ $k¤§ç·§²OMÁЪ7=¼Š×$íh}OW|çÎârÂvž¶Ð¹YÑaÕ ”×bûéüéÜ¥6Ÿí?�éÄ1NZÈë»YVÔiAÉa[Ztk‹ûì…D;NœÚ‚j7yų÷µsa×Ö9Œ’ÌsÏgp�x\oõ ]¡!þ%+¤:O|¼ˆË =S#·†žÃÁÝɆÎ]ÛPbNÛ†4 ¶bÁÎ3?c–‹G9’¬¢÷ëH·%3¢«J»Z:vy-\ü''NžÂÉÑ‘U+–�·Êo»¶¡<üÐ<ûüv‡ïaúo³øêóOoêZNrˆè¹¿ò\ý¼›�m]†~¿”6ëfñÝ乬>žPðZÍÇÞ¹ïòèþ‹ü6¡ŽÒÝ-„¨|*M`¨(J™ÁÚ„ °X,L›6­`ŽàìÙ³Y·n[·neÚ´i\¸p�aÆUèx¥ÑÒ“H0j Xáà_²¢¤óÄÏ×¥D_—FÆÙ¿™6em9ÌÅ”œ’Ë©ëËxÈé<ñó)Y±TôzôJnÚE£Æs5΂†‚›5J{6éªùã¯ƒËæX®ÄX Ø¯Ð¹yàV22ÂÛÇ '0g&’häÖ꺊O÷R{ô¾þøê ))�D ªÝì1tÕyô»è>û�¯/ã³1ËøÆ³!=“Ãî'Ô·”U^tîx{”ö·Ï[PHÓ®�‡j2W¯f¡i&Ö¼BàËeeD)ÔÄ8Õkƒ’Ç÷Ä×S·)0Ü^â\^¼d)/�Sæsvvæ� ãé×ÿAÖ­Û@Øî=%ÒlØ Þ�ç êêлo= /»¢8†0èž@æNÝͶ“f:·(ûöcå_+�£É©åªø™ÎÌæõÏ÷4zc›Ûqk!!€™ãë7IuF<Õ«” @Á³ç zû*Ë?}‡fNc¹¿±ÄG°iî×LZ‘„¦XacóÏ÷{i9*™šBug}‘›|äþTv™M£p§ä±Dæ]´fp_'‚ ²«P£¾=µuéĘK–§^ÉM'»¬Q÷€ÎÅžN~ ûO¦°.Å�þ…Öùɼ˜Ä— GW7:¸–�†¸ý¬¼CõÝû\ìù< bT@#ûÜ.ZÀ½Äe©‘““»çµ;‰…¨ —)«/ÜÊÙävÎiÄ\ŽÁBýëV8nf½›;® \Õô�^Ȫÿ5¨@ÅF�[£þ¼ñÓýŒ¹¸“Å3eê°‚á¶jÊ~¦ü¼™¡ßô¦ ÙGq vïQLêýÑ{V2ó—éÌÙtžtU42OÎeÒ²aÌê#=ÞBˆJ§Ò†:½‹ùÚchÏž=‹É Ú·oO‹-˜9s&çÏŸ§W¯^têÔ‰ .pöìYfΜÉÃ? ÀªU«HHH(’^£F�НTÚµàMWFó¹¾ø¸EÀtú7žzôKÂS5쪷aðã]iè…“­¢ÿ泉«ˆ,ó×[c(w¦�ÿêªW�ËDÕÒlj^‹Ë•òµæ^÷Ðj™/Ë_•®ü#ç4‹¥è»¨ò(Ž xäÃy s�5‹±à�Õ¬™:�Õ³¦ÑoÂ÷|ùHÝ¢ïDSôX[•û¨¹Á½â@£~�ÒÙ¿¬ý¬ ®e•¿K.]YU+¬nÓU¹pñŸ¼öÆ[e~ß°Aésó禦¥ñècO”øþ¡Þ¸'Qï�‰.eÕkú£SÃ‰Ž±�û1FmgÞŒEü~‚ 1ɤͨš…œp/ÏH�ìãüøÆ÷œlü2KFÔçö,êjærT,ª>”º�e÷“)}øøçx”ñßóÁã«yWË].¿vß1¼ý¬c¾‰Æ·Ì…rî+?{Zؤ²}_«ë¹ÓÒÆÂñCÏ4ЫZKãŒìŽ5ÓÍÝ gkpRsX»%‰=ifžnf‹Ÿ-dgä¶+‘Ýz^lZ²·ÐÝ×O%‹µk⨙b‡—¢’šf&ÚÞ‘—ÛØän¯3ðÈ}®¬ú%‰�¦]%º»Í�àjd:ó·¦rÎÅ�ûîùÇ‹§jPãÙû÷ìC:Ò°´aŠúB7rE¯+xvXÙÚäþ.œ>KÕ®Ý+³³~{eÍ(ÐÕ¥–U•”íkØšÒ™^.Åî‘Z6F“ ¶†›ÛÇ*¸ mp5KTÎoݹ\á{¨‚CÍ<ñN=ò+OþаŒÜ4ÓÏžå²ꕸ ØR-ä!Þ éÏc‹^á�·Ö¯š‰sg.¡"�¡¢ò©4�¡µµ5³MÓhÚ´)ñññìÛ·Èí1ìСCÁ¶Ô­[· ‡pذaÌœ9“ˆˆôz=íÚµãÌ™3ûøøøÐ´iÓ‚Þ këÒ#1ÅÑ 7ƒ9b¢ãP (zó×2IJÊ.pe³ë·_Ù›ª¢÷éÏ·K&Ò§Ðxó‰Óüp+…S˜Î‹j>V(DzIŽºLšF‰¡Ajt—Õ¼m½K>º,q1ÄZ(6LVåêåhT@çàŽÇ-¯À¯‡J�Oó•(®¨ ¸y,>¡Ü(MI"å:_Ûø4gÀ Í0rG–|Åk.aåïÐ4tÏ\^:¼½lPP©ÑóyÞ¸Ïñ†»(®¹-ÜñqW‰-­7TK!é6ÍQiÛ&”^=»“ššVäóãÇO�–žNjZj©û¥¦^û¼MhH‰ï=ø@¹Ž_ZL§å½3,Ÿùì\F<ò »:0â…7×8ºôu¼ùðל»áQ2Ù7é-&Ÿ fÔÔ.Ø\½LTÞ7iIFÀBzÜ¢.ÛàäåƒK¹£ÆÜža Ý Aœ›>Τ•�ð~äy.§h8V«IM;ß��ÅЀàë–wŠâäÄÿ=–Ã+SxRØYÓ¬©ïqÂþ¨…ƒKÓù`rQ#]CÁµ‰7¿<žÄ�ÛRùbN‰9`°³¢v�#Fºó oÉB0Ôrç“>f¾Ø•ƤE©Xtx¸hZô:p òdúHk¦lHaÑÒh¦dƒ£« ­[ûðNwgVÑ×ÅÞqZ<['½È÷ç]¨×©7}»„ÒªAM|\lQSγmÖ×,ŽÉolÕáØ°qÁb\z_?|upΠ·b_v¯ÎØÎþ(qÇXñݻ̽TöÜY�_{º[±ï˜9wÍ—¸å¼õb5Ìoél}Sû(î]ØÅ…Ík’QÑ0�ÊKïUgÒ÷ì”ÿdQÉŠ=EØÆuìÒ÷åõ‡ƒ±ÂÌ¡éïñ§Úž{ºw e-—‚0¶žÕð°Q ïµн}îê½–s,øpqM{Ó»s+‚=mòîdV¸úz¬ð `g/ƒ¦…•S¥ mmm1f1�¼öÚk¼öÚkenûÑG•øløðáÿÿý÷ß—¹oVÞû󇤖`¨G³zV,ßgæØÆmDZdH –ζ#ņ‘jé\¾’»¤¶Mó.t*©idœ=“¨•™­òSœmßæ}äì_Çú¸\$ø3²oí®Z@çÑŠ6õJž–S;Øû4A…'÷YαaÓy,(Ø4lB)»U�™“»÷‘ôt ŠŽÜ4²SɪžMSÐÙbï€=—šBj‰`×Â¥CG‰³”£‡QïF“‡ßa‘í<1ÿGN—ˆ€+À†æ¡M°]¹›Ýëw�Ô¯Ï WQ´ lL#g§.†±ó‚…fµ‹[K=̾3·´äN�€êþLûir‰Ï¿ùî¾û~23~›MŸ^=K|ÿëŒY4¨_�ßçͺ¹ƒ[.séŠ n…ŸJä…HT�~¾zÀÂÑE³Ù•æÇã?Lâ�B/…V£Ë¹ºŸåÖŸ!;÷�õáÛR6YøRêk0bþJ&´,ï‰k�¯ŸzËEÎ\T¡é�ÎkÜ‚q ÈûgúV–oŒÇ¦U7:Ü`eE�BÉaåÅÙ:ñý'…f±:»ð˧…Æeúº³h¢{‘]¼ë{ðC}�’iµòeY«âê¨Õă/š”²}Y=!Ý«ñG÷oêRÃ…ñO¹0¾ÉZ×óaûç>åÏGt·:ªá?B3%rrãNn,±DoÅ&˜ÇŸêZ0OÚª~WºúÏà\^ð§eá—‘÷ðKyª¯Ã�ç{3{ì*bU@³·óGF ø±èv:7ßÊ>Š;÷¾ú‹Â>bk² Z'¼Nß??¥zMoùöî2<ª3aãø}f"3q#‚ .ÅÝ‹;õÂÖ}Ûí[Ù¶ÛÒ­n·²êîN‹wwww‹»Íœ÷CH @ŒÒpþ¿ëâCgÎyÎs¤pîy,KɱÇt,.]9¦]Õné¤ÇrÏHÉûê«ï~Õ¯ØäXUQ5Âà‘¦£»véHr^[¨á©]:¨ªM’+KGWþ¢·¿ùQožò¯RC5+É;;F{vT|~N¶WU×®gÏö C…ééàãÌýîøñ—ô8ùåçï¶HõÖV>†©ôãõèøe:š‘;¶ óä:}õÔ«ú#þ¬6†Ÿ*WÎ�Ôµw›v˜`&ûè½üÎ<¥”O#‘$›ª »Uƒ+Ûe&/Ò~Wó¥åvùÉŽÕ†žÖ?¿;$—á­ènT—"NÓÌX©·žüDK�fÈ”d¦Ò¬ÿþKnÍ‘i T�½WYP IDAT^æ—.Si ?Ôg/0Ó­øãõÒ/Gåön¨QßþÇÕ#ª¡¢} ¹¶ÍÒ´½…ƒ“;f¾Þý~˹£:ÓöhÕúãg1ΗuH[w%É´UVdDYZslŠ8Vƒ«ŠŸö²ýr“ÎúÝÌ<¥­ö+9¿Îö9°Šl9[ôÉË?hGÁYa]'5÷�4§ü†"�9\þ~~Z¾b¥î¼çþB-„ù¡QʃXj®ýš>iƒ .c&¯ÐÏ”Y©ƒº4ð�äVZZ†L#Dá[èÝ:±x¡¶'Ûjjø¸·õÑûãÏùó¿±Mäa U¯ÿ{K½;N£Ï^›ä‚<Ô¤{g…ë ~ÿj^n±âÊ9¦é/þG¿žŒÔ¨;^t’&OÌ%Áu½@�õ‚ÛøÖ×u¯¾­‡šhºõn¥{ÿ5JuÎ7C²-H~R×W;ßÿS†Âú�Ó»¶S˜ýÂ7¢@gÖRì#yÔºNã?ù?õŒôÊûÜ”;3Nwn×Ö�{u(6]E ‘=Ãt+3á°¶o\«•k·ëp²+·Ç�aWH»¿ëÅ[êŸÓ�Ú4³•tt�6­[£Õ›(>›ŸšÞúœþÞ†fpS…ùQËÛÛ;·Õ0oqúóuõ,‹ü¥.‡¼½Ï÷»MUG?©'çŒÕ3 b´ôíÛÔù_ø¸•š”.wXW]ÓÇÔO3�¬½Ú�¡º“?ÓÎÝŸëæ¡[Ô³U5y$îÖŠE•Ö¨»Ú…Ï×òØó²„Œ zæwjïÝjíò÷tKÏ�ä ð•-#E©™.™†—ª_ý/½}wã"Æcy¨þÕýåXò–nìöŽœ¾2Ò’•–í–ix(²ÿ“zj`hÙ`·…ªM—@M¿�–4k£–µeÆlײå;ë T»Gþ­ÛêøçØ¿‡n½¡žf´A¯�ù›ö_ÛGMÃìJ>ºIs~Ÿ©½á�ulãén„’d&.×ë׿¬Ma ÔªyU¯ä+[Æ)íZ¹D«f©R¯;tC“²uó3»ê_¯ß¥=w Ù/^¯N_4V«F‘ òÈQJìaíØ¼S'£Ðô_ï’¿]’êðп5vÕú|þ‹Úg¢:¶©­`3AûÖ¯Ö&w{ 霠ߖ–©ZT½Z¤^{õeÝuÏš9kŽšÍj§%%ŸérzËØ›‹lM,.[P-ÙþxH7Ä_£amkÈ?ã ýüµ& V¯—îPG§$y¨qçv ý~ª¾{ýkEßÛUµ<âµmÞwzû§ý ò1”y±þª×±§ê�ó…©Ää_d3âT£uOõmSò¿êœîÖ¿-ÒƒÕÈØáÕ½¾Bl©:¾k£öÕ¼KoÞÖHrëÈâ ZpÊGžÙJ8¼E 'MÔœ=^êøèûz¼ãÅW†sÚó'Ü@yrþù=xÿZìѺï‹=eºf/]«Í;÷ëpL’Ò²Lyú…ªjT´®êÜW×\_ÔD\†Âz>£ ?·Òþ¤+·ëp|¶¼‚ª¨^ËÎtÃ-º©s¨í_?Ž/z¬¡ 6÷}ª]¦ê«o'kÎÊ­Úw,Ain›œáªÑ¨µú »QëäY¶}d( Å­útZO-øå'M˜µLkwÔ‰Ät¹ où‡«zýfêÐýj�–¿æ©‡š�ù·þ4[s­Ö–'Ÿ’)·á%Ÿ�ÊŠŠn©n®Õ˜á-Ϭái¯©‘ÿú·ìÓçiÁòÍÚs,N)9’‡�+WWt‹ê7úF]Ó)R¬f ¢ª0ÁP’ü•‘‘¡Ã‡�(*ªV¹—øð‘Óǹ �ÚºñÝïUõóñú`Âbm:” t³Š÷¦»]í7?¡)³ŽÚŧõ?ôÕ'Ázõ�Ÿ5oÓJM9°AAÕ¨Ó�oëÿnï ÝÏöÖÊßËëL ´ù»¾Ÿx•¾þè+ý¾`½vO•Û7LõZ´QßÑ·è¶Á� ÷òËg¯©Þw¿¤{è¤7ßøBSWîÑ)éJõš©÷5wéï7·S™Ùò™Ùª~ýGzyäzýãÉZøÇq¥ÙU­ù@�¹í>ÝѧÖYÿ¸:tÕßéëÊãõîÏ 4ýã×ô«|ÕT�n|M¯Þ ¯ߢo ìa é¤[îªoç®Ö–ÅhYZŽlÎ`EÖk§1coÒ]×·W•2Ÿ‹¡€6èûÉmôÝ'ßhâÂõZ;w³ÒM/ù…E*ºûͺ}h_U-p#¨“žþî5zï=}=cµ–NÛ*ÿššv»[Ÿ=2FQÓoÕ¤¥§ÊZ± ººOoM�4AϽð²V¬\u:FV­ªgž~¢L¡P2äl¯¾Ü¡/^¯žß¥˜EDwÔýï<¤{ûæÏæk(°÷Súdœ—^úüCÝ=â5ɯ²¢;�Ôã_=¢Ï Ðåp®¥f«¬�¯|§Ðæé“ óõùk?+ÉåTX­¦Ð)8¯»…©¸õ?ë¿ïoQRއüª)ºõh½ôâ-Ù2´XÁú{H ˜Ù¥ã_¡þu»4<ëßß«ßßJ³·M��†èñ·†èñólÑû¿Kµ÷¿*îÐfCô�fCô�b·4ûH†O-u󘺟;_VQ[+ nÝüpÝüpq�àTÍŽ#õ`Ç‘z°õ€ŠÄ0K°@à†íûÔ<:êRÖç¢Nœ<©´Ô4*$$¸ÜÊ�‹‹Wbb¢||}T9<¼ÜÊÅÙ²4÷ñ®ºmB¦¾³Bãû•Ï’(›eËWªq£è‹/C�K"&KJ"–›O)Œ¿ZSÖ¬VaÆæ •ÝîÄÄD%''_|‡bHNNVbb¢ìv……–`òà Ñ¡}[Báeæ%]†å¯HÞ6B!¥Qá^Eìv»*……É0 ÅÄÄ*..¾LåÅÅÅ+&&V†a¨RXX‘kÀ¥VÙA8,+o[îu%W!_CœN§*W?Ýr¸oßþÓÇWvv¶öíÛº¥°råp9Ï7)\b†éÌ퉒 ð̽~ÌF @©TØáùN§S‘U«*&6Vi©i§'މˆ¨,‡Ã!£ˆU©MÓTFFF¡%/||}r»§ÒRà/ ÌK ô�’s¤t—”mc�C ²¹KR8í¹ÍxVÈŸ9øë¨p“Ï%55UIIÉÊÈȸøÆy‡üåë{ñéä௬¬Y­Â¶äëëKÀ€R¢ó XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Åy\î \IÜ'æë?ÿ™¡Œž÷éÙÁÕJ‘ºs´éÛ5~M �}áoêèc\‚Z–�ûÔr½óÖlev»E�ô‰ä×…+Äyï«™¡ËþÐ/s7kol† gˆZ ¿C·´ Ô_ó @IU¬`è>©?^S¿r]x;ÃS­oyVw¶(Áé™ Ú²p‡¼ZµU=^w%ÉLÙ§Åk²Ô¨k…¼$f޲³³••ã–yÙjgE¦b}¬q¿ìShïûôÌàj²—¦”ÝWSé['ëÝŸÖJõºêÚþUdOM•”¹‡ÂóÖ —\Å ††Ÿõ(¯äü×V·Nm˜«ùûjÖ»“øå¿MÚU9²díXfì&M™¼VMê·!J’L¥m[¨ŸçëþÎ Z �ØÂ;ë‘ÿt’ ®ÓŸÊ}BË–îWŽM:±j¥v\]M�¼JZHIï«[û6íP¢QS×\ßO]C.Õ=?½péU°`è£ZWuR­Ó¸´#f‰ì÷W½v�Ô»Ri;5ºtjÓVtIMÊ¥¢Wwª6mا,ý=¡ðO—½o•–óR³N upÉ&-ÚÜO [ù”¬å®Ä÷Õ¥””tÉ à€KxÏ/V/\R+–”™¦+çé�Å[´ëX¢2íN…V­«6]º«OË9 Iîãšÿé—úusœ²MiâËOh¢$ÙkëúgîT�`CÙ±;´pÁj­ßsT'b”âòR`Dmµí3@ƒš‡Ê³UsÅïÔÌ)s´dÛÅ¥ò«\Gí®î§ºžgÝ3Qóß}Eß»J>7R� ¶¤äu­�”ÕUO<ÑO5m’\ûõÓ kËU÷êén™šóëTÍÛv\Iž­tϸ‘jâ:¡u‹–jùÖ:r*^ñ©n9Cªªa»^Ù»¾‚m’·A_}8AËŽgÈm.ÑkÿX"I²U饧ï«ÈSçKYœë-IÊц¯Ÿ×‡1½ô̘­Ÿ6OK·VLšä �Tãö}4²g2x±€ mYº^±^µ5¸w+nZ¯eK7*¾e{nÄË»¶q}õü½�txæ$M\¶[ÇÓƒÕ{l%Oý½˜÷5RiÛçè«)+µí�K¦¹A<¼A’Má=ïÖ¿‡Õ”-ãâÏÒifšö¯\ Y˶hDZ¥»½RIõ»טÇõÍž·êJÒŽ…³5}Åí;™¤ ·§|C*©fÝê7¸³êûñ#@Y]¹ÁÐLÓÖ ê½…ñ mÒNý;FÈÏ�¢ƒ›VhÆ—ïiã‘[ôð (9�E÷¥ë|~Õ׫ u¸n„Ú‡’Í¡Êù]JvkåîlÕhÒ^mƒä›sJëæÏ×ô/¾�ùàƒQ«d—ÑLÞªoÞþFK“CÔ¼[ ¬âTVÜ~­úý­1²ËáäÝJ<¾^?¿»Rk=¨u·FòuDªª‡¤œm^{TözMÕ³m˜‚½3tpÍÍšú•b=Ô£=+Éð­®®£FÉùÛ÷š“ØP׌é¤j6ÉðVøùÞÁ‹}½Ïìâ:¶RŽÏ�GTuÔZ¾f’v¯X¬%“¿PŒí=Ò3œ‰mò˜I›µhSªœ [¨YP”ÂZiÑ•Z~¼­T9÷*¹“kþ÷‹µ`o�Z¶îªVÞ~ª[½†¼‹}_ yWn¨>C«+rê—úãP”†ÜÑKuí’WpåÜûb^üYÊÝ.U›ù@ï/Ž“_íêܧ½üÌT�†‡j·n¡Ê ækéòƒê;¼Ö9ÿ#›§Öi¾OO=ôxÕ)˜Æƒ<Š}_=ƒ#U/8Kñ~†dóSÕºµÕ à�Šó,Rö¾yúaIŒ|[^§'Æ6WÐ9YÎçüÏ›™ =»OÈU©«®Õ-·U<ÏÀb_?\ÌúÚíÖ¡M[uJ¡jÛ9Z…zšþjÑ¥¹BÍ“Z»áx‘!§8l!¡ µ›JKM/Yî8mÛ+Ó·‘º¶,<Ý¿G•–jS½|n‰ál¬¡ƒ…çã¢ð`Cîô4¥•jšÑR^o[%]ÕºæéP(IrTSíªv™É‰JbÊÓ\®£Zºü�ÜÁMÔ¾~îl3¶ÈjièÔšUÚšYÄ>¶ uÒ³p(ü3œó,¹thãVÅ(Díº7)"^„á§j‘�Ò©UúeêFN-íÿ±¸�+´ÅÐ¥¸ØD™¶:ªRéÜ7Q[x¸Âm¦vÅÄÉ¥‹·öeÇîÔÂù+µ~÷Q�HLSF¶K¦éVvŽä_ÒÌ$Å&ºe WøÙWßðW¥POKVdQl•"UÍqî¹›'´nÑ-ßr@‡c’•–™-—iÊ•ã–*›¥\~¢”×Û¤°sf¹´Én“L·»Ô¡ýJ“µk¥–Ÿ”[G) !V'%IvEÕ —1o³o详mý OBc W�ª—vjÏâ=KnÅÆ%å>á¥ùÑÃCõýMsMЄyßéùùŠjÚR;¶Sûú!*ñ¤¬(Ò %w^Â)2èä}h+ÆÌšîK5þÍIÚå]_½ûÖÐê!òsxÈ–±Y_¿1MÇK\³Üƒ6£ˆ‰= Ùì%yyvË-¨“Z¶l¿Š7ŸmIîëjVìgÉ®�ë+H±Z¹`ëÆ�ž¯^¦ÎùÍÂæ§:Mk+Øp)=ýìRPWh‹¡d¯ÖM7ôÜ¡·gÿ¨WÓ¨KÓ*òWŠnX®…Û2U½× ê[-?ìÙR»–BµHKùE�Ýë+ؔš4W�µå¿xƒN^¢È¾Ñ ·§ê𖥚ºì”|½Œb¾Œª™ju¿ZmÖ|¯•ß}$×ávjáPNÂ!­[¶]‰Á>2 MKê¡z­+hÍjýñítù÷o®H—mÑÌi•^‚éú=kÕS]Ç&í˜÷‡…tVƒ S 6kÖÌ Jñ?+²EÕ­*�m[4áëYJi&»ËOÑmë¹yÉ®7Š%ç ¯8&³Rõhì,²UÌÝQ]ª¬Ñ”µ+´i`”Z]¬õ¸„÷õ|Jò,yÕï©Ñ­vè“Õ?è•”ÖêØ(B~F¦ŽÒ‰°º½g¤lç«W›JÚôù—ÚàSOõª†),È!wò mZ²L'½k©GÃZ ÊÁ e8ToÐ�z,b�¦/Ù¨–*ÍôVHdmõ¼©—ú·®RhM=�¨>ºëštý0k³¦ü¸Qž� 4¢^sÕm:T÷�öÔ/óæêƒ×ÿ��ŠlÐZÃï ÄŸ^ÓÄÒT- ™ÆþÝKSæjé’iZŸi( ¢®: »CcÓ&é_?ÚZ>�ëï7zkÂÜuúö½Eʶ;V­®ÚŒ¼KÝ7¤÷ó¸ÁmtËíiúiòrMx­2ìN…U‹V·ëîÔð½_é¥Õ·¶©J÷kuKÒïš´z�¾ßj—Íîª~¾QÂë�‹ËؾR+cìª3¼ÝÙ½sϰE¨K׺šõÃV-^Ÿ¬–|.Rj ïëy”èY2uÕ�÷ʯÖ<Í^±Ms&¯TšÛS•ª«uß¼`w¾zÕTTt5mXºQ³×&)-Gòô RdívscOu¨D4@y0LóœŽZçµaû>5�Žº”õ”PY³?·€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`wEC÷Éiº¿cÕªÛPµê6TÝok«ërת°ÌãëôÛûÏéî뇩sÛÖjР‰ê6i£V݇éÚû_ÔG3w+Ù}±RL%müZwuo®¨¼smpÏ¥þ'€ËγBoŽé¢ºõrï}íöÏhQöå®*2�Ë]�rã>¦ßžyQœü‹%Á|îšûÚãzêË•:–iþΕ¢¸Ã;´âð­˜ñƒ>íô�>«šûE”®�¿þ[÷=;I»ÒÍ"¾Ç•ËT↯ôȃ¯köálq÷P^®�C—ü8N/Ì�ÕEÛ.[ *9Ó”˜u‘×y3G'–üO½³^Yg—uHÓþ}³F=1‘Ph9iÚñó?5â¦W4‹P€rvEܽßé‰W—(þ/› %É¡¦w¿¤´öW@�nºõ©7ôÃäZ¶t‘–ÎøFoü­¹òï†éÒ¡ µ³@ãgÎÉÅzuìuºÿ›-JúKŸ'Ê]æAMw“F=5I{øA—@ÅïJš½KŸ>ù––%¹e ¾Jm+oÐòí9çÙØ¥ ¯ ÖÈö)Gjþè$M¸3L»¦|¡�š©%[)&Ý®ÀÈújÛ{”î¾{¸šÙ”sj�~úôký6w•¶N”˪�ÚkÐßîÖ½jÊQܺzÖÕmÍÔ5>A ´ø<ÊþòG­.ÆØ²´ õÃ7¿iú’ Úu(VÉY’—_°"jÖU³6�ÕgÐ õi&¯âžþ<îCúáþôÔüX¹LI†‡ªö¼YŽ|­_Ïûœ%SÁƒa¦6ø/½¹&U¦áTËÛnQ—Ùiy±öuiDzyš?Y�}º]ibb÷¯×´O6hî‚�úä�¦úéî'4%/”I’²ŽkDzߵcÅ<-ò}ñ·ºò,f�mþA ,ꋜ4¥�îfj““fª“��vݯ¶¦|¶SYŽ:ñï·ô\çUºë«‹Í­SsŸ× þxN×ÓœÄÚ»ñ„ön\¢‰¿¬Ó[sÞÔ� ¢Æ4â²²Eª×è.zwáD2ýÔìæ—õþ£Õõëè¯/wÍp©ÐÁ0mýûzìýMJ7 9›ß©ÇVÓŒ©Åíjg*sÉkz`‰)³È]LeîúZc†Jr›E�ér'jÙø÷4cØëTÚPåÎPìž5šüÁ+šx*·�¨-¨�º¯‡üò·1üÕþ‘75.ùe\ûOÝÒÜ_æá%ºØpEe¯×/ü|&ž ®QO5ƒÜJ¾¹‹š¶l›û§õX}²ÿÌ"®=Ÿitë¶jÚþqMK/¢8Ã!ÇE&]ñô*öŒ£%eØ<ä Wí½tË ïé©n¾yÎTΡ)úeyÙ[ =ªõ×+&é«'GªM„w�l*'a«&¼|›Fýk®bh<,«‚CSéié§»mš®L¥&'+ùôŸ4e¹Î$œ3ß§Ÿg¢CÆ_e2N#H5ªœ¹!î4?ž¨rYËÞ// IDAT©.·¾ ŸçÍÑÄ7Ðà†A²Ÿz˜­¿�×w»h6¬ª‚à Ì�¡Œ¬ |ï: ÕëbÎAÃSAA~å{ƒýÕ·Kk5�ŽRd¨Ÿ;é�yj†^y}‡j\Ý[=ÚG«Š3/fÚýT%Â÷L·RÃ)'¿VUÁ‚aÅ–·]ó¾Þ®Y__dCÃ[ ÆÞ¯a•ËÖÌœ­Ÿø¾>øå}v_…׬¡ª!>rÇï׎½±§»×Ú‚:ª{sÀªH1†=X-Ǽ ñÿhQ®‹Î›®T�Ø»M'öžuï2•S²`èôVZZ†Ün‚!\nn·©´´ ù8ÿÄ`à磔ô eçä”é €²ËÎÉQJz†ü|ÊTN‰‚¡ÃËC6æäÔ ¹\î2Pz.—[É©²69¼<ÊTV‰‚¡a òSjz†Ò3³èR —�Ûm*=3K©é ò“ae*¯DÁÐf³ÉÓn“Ÿ�Cq IJËȤåþD.—[i™ŠKH’Ÿ�Cžv›l¶²-8a˜%œb4;;[n·[Éi™JIË�¯Ó!_‡<=Þ¹ xžže*¿ÄÁP’233s+år+.!EnÓ-?§C>>ùù8ÊT!@a)iJKËPJzî˜Â� ¿¼–BCÞÞe›‘T*e04MSYY¹c ív›2³]JJISZz¦Ò22Ë\)À>où8½àç#oO»\.·l6C^^^åÒk³TÁ0_vv¶rr\e® ø<<ìeî>ZP™‚! â+ÛÔ5€ �`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8�²`š¦SÒ•”œªôÌ,edf•G½yÞ^rz{)ÀßW�~N†Q®å¦iš¥Ý9>)Uq Ér›¦|¼½äpzËÇá]žõËKËÈTFz¦Ò2³d3 …ù+8À·ÜÊ/U04MS'b•šž!§··|œÞò´ÛeØŒrO®`u¦iÊt›Êv¹”–ž©ôÌLù:ªX.¬TÁðxL‚ÒÓ3à'‡§§lv†*ÀŸÁír+#;[II)r:Š *s™%NtñI©JÍ…^^„BøÙì69¼¼à§Ôô Å'¥–½Ì’llš¦â’åôöÎm)´Ñmþl6›!‡§§œÞÞŠKHV¦ŽÉ-¯$'¦¤çN4ãô¦¥.#›Ý&§·Üy+E”©¬’lœ”œ*o/yÚíe:( ì<ívùx{))¹lÝIK Ó3³äpzË  )\v†Í�Ãé­ô2®'_¢î32³X§þ" Ã��Ã[e † ‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹«˜Á0yŠîkÕL çþi~Ç/Š5K°¿ëˆ¦=w³z´k«Ö=®×“÷+ç’Uå){ñ8ulšï[iä‡{åºÜ•*¸Š ËÈuà}úëOÉPêÉ-šüñDm#]°(KCÃ7@FþÉð �ÿe­\>—»—ƒ­òpýûÍ };c‡’|ëª÷õ׫–ýr× .�+#6ߪ/Uï2Vÿìr‰êÈ //yfìÓŒ�ÇëÓ)+µëd†<‚"Õ¸ã ÝrïÍêVÍ»ðÉSt_·'573÷?½:>£¹�Rh^ºÌ^Ÿ¼Z»ŽÆËÞÿ Ýzð¿z{c¶LI²…jÄø?ôb7çYÕØ©wG_«ñ;òQÚkë®ïÕC�Ï­±yê7Ý=ðY-LÍ�ÉÇð馗f¼­a!…c·ûø�ºmÀKZž™»�-|¤>úcœ:圹®¶ÀAzgÎKê’¸B?|ö�&/Ø ½'•ã SÍ&5èæ;4¦k5y+]ûæ|«Ïž©%èTºMþµÕ²ûpÝ~çµ¶dogàOuCCžöúâ®ÿèƒ5Irç|j¯VL|[«æ/ÓC¾­;šú–¢lS™jÂ÷ËôÃ+3u4§ÀÔ§q‡´iÎ7Ú¼`––>ÿ…^Yèbæly_7Üð±vçœ5]jv²NجS6kñ¤_4ù±÷õÖ�õå8Ïñ3¶nÔ¶˜-¼ïúlsJÞùÙU%0Jƒ†·ÖÇ›–)Í”äŽ×‚Y«•Ö­‹| ”àÚ;O³÷äϬcÈ£Á Š.ºß¬Ö[#»¿©ÅSãå–d¦¯ÒÌEñ:4¤@‹¬[§ÌÑú¬üó²+òêÁjã””|¦,wÊ:-�ù“~ýßËšwÊ¥ÓW!û„v.ýMÿ[¾P«Ÿ~OwƼ »ßߤ÷™}ãnÒœ¯6kÑ¢ízç›§Ô5¨díÁJæŠhŽI�û±Þ_[ àN\­·Ÿx_«ÓKW¶™ñVTÝ‚ÛÛU¯K'E(Àð�RÝÊg>0³2•Uê¦^ÅqEC[P¨‚Î:[XeU²趘œ¨¤R ›ÂkT=gr»§g¡™H íŽÑünÔ°;^Ô'“—jó�SJJÏ–Ë,MlŠlÖTaçM_Q2ü*åç8wìbÍX“!¹�jÞœmÊi 鮡�嬇­R�ì�÷p˜J[1K‹M™ K5kezÞ¹òi7H}*Ÿÿ²U­¦ª…Z yzy¨ƒ]áágÍèê%¯‚Y’P\rWD04]n¹Ï¦ f¨„kžÙÑáô)Ѿ) ßÖ¸w)5?”ùGkÄcoèë_&jÆÌéšùÅí*rXÞyŽïåí}�ãÛT¥ß0uò?� µ`æ¥�¯Ù[ròr•]•{T{ŸórÖ!ÕmDoUÊ{:Ì´Uš¹8^ Kfke~s¡-@]÷PÈ.ŒátÊy¡ gòòº&Æ*¸+â­ÜŒ9®S¦Qà3×±Ã:î:“ ÿ@”rÕÃ(ÉŽÙÚ°`ñ™n«†�:üß;z~tåÓ)Ü•éSĺ‡¥gw×Èž¡šû{ŒÜr+nÉ-ˆ>¨-ùÍ…öHõÒJÞ.¦Ÿ¶Ã5¨Æïút¿+wŒæüEZ`_“»4†$[p7 îr±H£”aÀŸéŠh1Ì9´\Köœ×Ó¥ƒóçiÇé�l ¨uþî˜åÊ¥¤„”3= mjÜ0¬À…6•ºs»–ë„*¾ê8²Ÿªå¥MWìMš·EÙy•ð¨3@ƒ›xžµ�[i±‡´ÿhbÑ“òx6Ö°¡Ñy“ИJß9SS×§žn� ï3XJ³4$€¿œ+"*g»>}êuMÝtTñ §´cÆëzüÃÍg&-±ù«]ç"ÖÚ»$ì ò?ÓRæ>® kç…/S©»'ê¹7ç*¹œgÚôj>\CêåMB“³EËWç­ëhxªá€þªWh@dœþçZuï1HýûöTï;¾Ò¶Ì³K´«öàaj�7xÑup…VÍ«´½ªúnuθKÓÑ•Tr+eÓ7zäºoŠøÎ�gí‘ÓÍÿOª‹‡µi!¿ŸgåNvc¦iÅG«÷¯õé§=;�*ÙmÈn3ä:g`dØëhèðæúø?k”if)3¯Ððj®ÁjºB?ÿ²SÉ.SR¶N­øA“¶Ý †- ?¶ˆ¾Ñùm-Ÿ•,3;ëtË¢GÔ jzv $€Šê h1´+¼acUñ*j4›!{h=òÊÝj^’veb(¨÷]º³•ÿ™‹kfèÔîMZ¿íˆ’ÝÞª{Í«zý¦jå:ÎP²)²ÿuò-x 9Û ÒÕUϺÍvo9 å:/9Šº~F°zŒè]¸ ®á¡èAýÕ |+à2ªðÁÐði£{ÞþZ¾zVc»7Rd�Cv/ù…×S§Qÿ§�~zGc¢ÿäN�^õuë_éÕ;z«id ¼ívyú„ªV³^ºýåoõýÓ}ÔkàÕªUÎáÊí®aÝÏÜTÃOõP¥³3Ÿ³£îxd�šVò•3 º:Œý‡®‹.º2¾í‡¨•3ß^Í4x@­rµ.'Ã4‹¿¸Þ†íûT?ªÚ¥¬ÊÂ}\ßÝ6X/¬Ì”)É4PoMY½ËЋÖLœ¡‡û?¦é‰¦$C>ŸÖŽÒ–/ð'۹ﰚGG•z^ï¯ i¾Õwk³òfµ©RïAêX¦¡•ÙÚóó7Z�”÷Û�á§ŽCz)œ§¸¢\!“ÏXTv’b“ 9¼³t|ÝïzmÜ7Ú›·v¡áQG#¯m§â®iŸÏ•«x—SN3NÛ¦�×3ïmTþšööˆþº®w0kW‚aæ:ô³îþ–6åœõ…á¡£ÖØ†%½½¦’f>­^O/>wmC[˜z?t§:8K__MÃ+�ᩪ=×Û�vR@95íöPµ»ÿz~`8}�€+Á°3¼U)ÔOž1é’3D5¶UßQÓØ PÊg÷ U¥oOuÉ©úWõЈ±c5¬E( p…bVR¨à˜•P&C°8‚!XÁ,Ž`G0‹#€Å Àâ†`qà +G›¿A=ù�V¥_Ȇ`qC°8‚!XœÇå®@i™™§´aÁ<-\¿WGâ3d:Q»±:vë¬v5|eäoè: ßþû™¶5¿M÷5:¢é³WkËþX¥º½¥Ö½ú©oãàÓÂux�ƺPñµèþ›¯RØy¢³ûäBýï�ÅŠówuK™§‰ó7k\† gˆj6n«þýÚ«¶_~-Ü::ó=½:Ç­Þܯ�Õ êÒÞIÿÓ;K5ô±ÛÕ=Ä�”£˜­‹5cáFm?§”,ÉË7H5ê¨}ï¾j_ÍûÌùÉ&3y—fOZ¨•Û�(6]r„TU£¶=5¸kmý\DÅ †Y‡5óã/4í¨C ÚvÔÐêþ²¥žÒ¶U+õÃÛ´ÿ¦Ûum#¿áÉTÌÆ‰zo•©JWµR¿–~2RŽjýâšùõ)¹î½Wƒkä^Šì˜#:’š©¬ƒGg^¥° V$C»¦}¦®`µj×[mü¤¤ƒ›´hÅzï`¢î¾÷jÕu,¡(™»§é½/WË]·ƒz«¦@#]ñ1ǵow’²¼×¤ß?ÖûGÛ©e�ÙÒNiÛªÚ�¬ö7õTï‹—T”Œ-ÓôÉÏ[•åBOQý ÎLj“¯ó¤¦|øµŽµk¨ê6%X¯ùË�ÊVµ›¶Êkµ4äÛ ©8wió´_5˳«šTòRfÜ!­™7O;äU uÓ­#s¾ÔO‡CT¿F¸ÂBäíJÔ¡�˵&ÍWMšÖ’WéN ŠTƒ¡$Ï*êyë]ª´h�¬[¦‰«ÒäòôWåZ-5zd7u¨éWên¤žaÕé³Gñ5"rÑB ¶©kü6jÊ¢YZ›)›Oˆjµ¤ýÚªV�pj´Ð�·eiòôZøãgšæò”X¤µ­}—êõ_ÒO—UWá»×kõ‚õJÊpÉðôUhÕ(õº±§z6óÿºÈ°Ã,zö”"mؾOõ£ª]ÊúTî“ õ¿7f+³Û]úgÿÈ Ø'€ÿgï¾ã£¨ó?Ž¿gûf7 Cé`¡ ˆ»ˆØ ‚í–ÓÃrÞï¹]®š. €Ugƒ¡aÊÊÎQN $_‚G‰>�œ‡l6£¦KÔb>¯[^·KI‰ ÊÊ jofŽ|Þˆý>z–UgƒaVvŽÁ�¤&ÉëvÉngº$àÐ Ã�ÝnÈnwÉépÈëqi÷ÞLI’ß—PÃÕP3êdš …ÃÊ „T/%I 7¡P)v»M ·ê¥$)'R(®é’¨u.Q†¡½ûräózäu»: ¨›Í�×í’ÏëÑÞ}92 þ_XO�  IDAT†¡pX13¦DŸ‡žB@\Øí6%ú<Š™1z –Tç’UVv@~oþB3Ä‹Óá�ßëQVv ¦K ÚÕ¹`†”�àa) ®l6C x.À‚ê\·[n0Äs qg†ü å Tçz ñE0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,ÎQÓÔv߯_ iéßè—mk´iïVmÞ»U’tJó®:&¥‘z·ï¥žÍ»(Ù“XÕ@å ËñÙâ‰ziöÿŠ‚à�~X¿P?Hú|ñ$%yüº­çuÔ³@�ÃPÒì fé‚×oÔ�qO• ”ÌÖ‹³ßVÏ¡Whù¶ÕG¸Bˆ/‚a1Ë·­Ö¯ß¤_¶­©Ôñ™Ál]óÞ]úlñĸÔóþ‡«yëãÔ¥Û)qiïP^~å5µ?±‹þóâÐÛßsŸš·>Nƒï¹¯Bíµ=¾“š·>N_ŒÏ2«Åˆ×ßRóÖÇé´^çÖt)åªì}©.7 ¼MÍ[§þ[M—€C`(i�}Á, ù×Ãî%,Of0[CÆ=¥ÒÚêÄ´¶qª®z|óí\ƒAÍš=G=pM— Šæ-\¢·ÞûDíÛ¶Ö�{n«–sF¢QÍþæ{ý8o¡¶ïØ%‡Ã¡´£�ÒygŸ¡“:w(±ï¶;5kÎwú%}�öìÝ+Iª_/U];uPŸ ΑË嬖šÁ°ÈÕï®r(,îš÷îÒWw~¨cRÅ­Í#íÁ!÷iÔctå—×t)ªh÷ž½úø³±r8ªïŸù¼¼ˆžyáíØµKÝ»vÖé§ôP8/O?þ¼Po¼ó‘®º´�.<¯—$)++[Ͼ8\©)Éê~R'ÕOMU^$¢¥ËWjòW3µeë6Ý}ÛÍÕV;VG0TþB3+¶¯�k›™Ál½8ë- ½â±*·eF*:´Szž¬Szž\-çp䘦©ÿ}0RM§)7¨¶ó:�]yéEjÒ8MõRSж÷:½§{êM�1»(&&úõä£))Ñ_¢�³Ï8E/ {CK–­P0’Çí®¶ú°2‚¡¤g½}DÚµd²8û¶*÷ºÝnåää襡¯hÊ´¯´sç.5¨__^pžîûóÝJMI)±ÿåWõÓâ%K5 ?=óäã¥Úë7à&ýôó¼R¯¾ç>M™ú•.ê}�F ù°jÛ½{·†{U_OŸ©]jØð(]Ú·�î½ç.yýl”Ö®['C†Úµk«AoVß‹/*ó|_}=Co¾ýŽV¬X)›Ý®'ž ?ß3XnOÅ?Œþû?/jÄo«eËšùÕäR¯6\C‡½Zêõ÷?üXÿ|â)ýé¦ôðCCôò°W5qòíØ±ó ÷ù`¢Ñ¨¾3N£ÇŒÕÊôÕ ‡ÃjÜ(Mçžs¶nô'¥}t©c2224öË šöÕt­^³F9Ù9JJJR×.�u×àÛÕµKçRÇD"ýïÝ÷õÅè±Ú°q“ü~¿N?í=ôÀýòTâ=D|Lùz–6lÚ¬G¾OÃßx·Ôë;vfèÑ'Ÿ×}ƒoÑ®Œ=š1g®víÚ­ÄD¿ºwí¤Ëû^¨-[·kÜÄiZ÷ÛÙm65;¦‰®¾¼�ŽiÒø çîpBûRÛÜ.—šÓDK–­P^^DNgþ=†B)?ÔæåEäõzäv¹Š¶/_±JÓg«M›W RrR¢š7kª‹.8GÍš¼&ph–†ß¯_ -û¶Uúøk:õÑÐ+Óg‹'jȸ§J½þÖ#õ¯‹þR•%Cº¶ÿ�úeÅJÕ«WO^¯G[·mÓ{|¤Ùs¾ÑØÑŸU(4ÄKFF†®¸º¿6nÚ$IJðzµg÷�xãm};÷{%x”™™U¡6ç~ÿƒîò�$)%%YÍ›7×ÖmÛ´`á"-X¸H;vìÔ�·*u\úªUú¿Gÿ©‘Ÿ!‡Ã!�Ç£ììl-Z¼D÷Ü7D™™™п_‰cÞ|û=óÜ$I6›M‰‰þüÀ|ãÏ:çì^•yKªdá¢Åpß´xÉR¹\.9öJÝçH$¢Ûî¼[³f#Ir8r»\úmý½ýÎ{3öKýï­êÒ¹S‰ãF¼ñ¶Þ~ç=IRÚÑG«^½zÚ´i³¦Ïœ¥Ùß|«‘¿¯n'u-Úß4MÝyן5}欢óD"y?a’æ|ó­Ú¶i§w±~ãfM˜2]ý¯¹Li �R4+wß/¾œ¬p(¬ÓNé®D¿_ /ÕW3¿ÑŽ]J_µVÝOꤓ:_¬Œ={5}æ·zqØ›zæñ¿*Áë­p]{”’œ\ E"åæ ‡µs×nÍ™û£¶lݪ›\S4ZbÕšuöú;jצ•®¼´�ìv»vìÜ¥é«åq»Ê:¨ ˯J:uå7•>¶0J*·WðÇ +Ý~¡­[·)kú´‰ZøówZ²à'½9b¸Ün·Öoب?ÿb•ÏQÏ<÷mÜ´I‡CÃþû‚–/™¯ËjôçŸ(c÷nmÛ¾½Âmž{öYºç®;õå˜Ïµxþ�š>m¢ü4W^pž$éµ×ßP4-u\ Ô¨ÑcõÌ“�kÅÒZ¾xžfL›¤–-[H’^yõõûÿöÛz=ÿŸ—$I§�ÚS?Î�­% ~ÒÒ…?é–?ݤ3gW¸öªZºl¹¶oß¡Ï>ù@+—-Ô/Kèå—þ#‡ÃQ¡ûo [(ÖÛïªÇ·Ó™§zXøÎ]zdÈÝêsÁ9:ãÔº÷Ž�JMIÖ⥿¨Ï…çèÆë®Òé§ôÐe}.Ð%}ÎWn  •«*>ì>}õ:mþ}«z�Vº¦%ËWêÁGŸÒßÿõ¼†¾ö¶2vïÖ}ƒ©{×ý?¸X½öWIÒMý¯Òi=»©g÷.º´ÏùzdÈÝjxTƒ ×J³|0ü¥’Ï, ÷³ôøÔ¡eîWÙG_è±Gÿ¦Ö­ZIÊŸsxÁùçjàÍ7H’Æ�ŸXá!›U•h¤)’¤ëú]£K/¹X6[þ·ÓI]»èá+×Kj†rŸ:uÜ¿z¡ÇãÑ·å÷fffé÷­e/Ôç¢ 5 ?¹ †ŸµjÕR÷ß{·$ië¶mÚ¹sWѾ£Ç~©H4*‡Ý®ÿóœ6[Rþ¼¼Õkâ»xΡ¤§¯* )—öíSêõÞ\PåsìÛ—©-[~×ú K¢@ Xæþ½/<¿Ô¶6­[}�•µÿí’¥Ë$IÝ»w+5ß.?xŸW¥Ú+ë¬^g”ÚV8?òpîó/+V]çe—ö-õz³cŽÑI]óç ÎþæÛ2Û0MSÚ´y³ÖoØ(ÃÈÿg"Xì}�ÅbZ¶üIÒ%eÜÿÆ�©Ã‰'´VÄ×ÂÅËôýOó5ð†kåó%Ö1ň)äp8d³ÙJÍÿ+\Ý4+hê�vïÙ«—†¿¥�G÷Þ1°Ô0R)žá ǵÓI]:êü³ÏÐ#CîV—N'jòW3µî· ’¤N'§×\®µ¿nÐcO¿ †½¡ç-,sô¨ËÏ1,o~á “ûé_ý¥ÔÜÁІBIÊ Vì'ìòû}r—±2_ZZâ¯322ªtŽŠÚµkÿùš4.½ðƒ×ëQrr’öíË,±½[ÏÓKõ8 ºåfýõÁ!’ò‡x>Bs¾ùV»÷ì)óܦi–¹½QZZ©m®b‹W?nWÁûÕ¤œ…4ÒÒJ/Îòþ‡ëégŸ/µ}ñ‚+5çê@>ŸO~éÅ87Ú?LùP÷yÇŽE_—u_$©i“&úyÞmÛVr¨ï·s¿×›o¿£yó(,¾‹¿ÙÙ9 …Bí•ÿpY{÷íÓ‡#ǨÇI�Õð¨ÊؽÿïN4S$QÆî=r:�%ŸËYösm6[•WCÞ¹+C/ K‡]üù%%%Öq†a¨g÷®Z¸x™Öþº^­Zä÷ÞŸuÆ):­g7Í[¸Ds˜§w>üL“¿š©ûﺵ̀ *ÆòÁ°<ÉžüOý:ç÷º ÷T¥Ba<„Be CE_WäC\Yú+ªxH°;ìeîãq{´O%ƒa(.52’‘$­[÷«.½òZåää¨iÓ&ºáúëÔ¼ysyùùm»ÿxqd¤¯þU9¹¹úiþ"ý4Q©×÷îÛ§¿=þœN8®­î\zñ¦xÛº}‡þ;ü-ùý>Ý×­e®>z0á‚óœ<ƒÑétêÔ“»éÔ“»iñ²zí­÷5yÚLÝpÝ•q««²|0ìylý¸¡ô©—æüOMS©_ç¾ê×¹¯ŽIi¤S›çϹ©h(,<®²B¡�öíËTrrR‰í[‹ÍµkÐ`ÿ …á!VÎ0«íÛw”¹½"êÕK-úzÛ¶í¥†cF£Ñ¢^¹â–-ú¹Ü6ÿ÷îûÊÉÉQjJŠÆ}ñ™4¨_ôÚ/+VV¹æâêÔ¿u[Ù äl/cáœ[Þ¤[ÞT~£‡zßwü}…BÚ³wo©•G7oÞRôuñû\–Æ�ö÷šnÞò»7.½(Ò–ßóÛ+ÞÃúòð×dš¦NîÑ]Ÿ~ô^‰ù�[·–îUOLôËét*//¯Ü÷ðÀI9íÚ´Ô]·–ý½ùáÈÑJNJÒ¥}ίp@«Œ�›×ÐWßÖÑ èÞ;–Û›ž••-¯×S4DµP,Ó¬o¿—$×>e[Ó4KýP¤ã íår9•�›{®ë±|0<&¥Q™ÁPRÑÒ~�ûV:6I.=¼±2¦ÏœU´I¡ÂÅ_¼^O‰¹t~~ÏÙ–ßKÏŸL_µºR«…èøãÚ<ž ¢)S¿RçNK¼>÷»ï+<ÿgÓæÍ’¤.]:•…’´"ÎÁ°cÇúîûõãO?—Ææ|3·Âmú z,·ïØ¡h4Z¢'-‰hîwß²�3féê«®(±mâ¤üg&x½%îsYÚ¶m£FiiÚºm›ÆOœ¤ÝKþPbóæ-Z°p±$©gÏEÛ7mÊïÏ=ç¬R‹Æ”õÞÛl6�xÂñZ´x‰¦NûJƒï¸µÄë{öîÕ²eËZ+â'5%Y©)Ée¾öÙ˜ òû}êÜñÈÏùü}ëv½øÊÊ ç©uËæš1»ôߣfM›¨S‡ãµdù }ñåduîp‚Ò¥¤$¿23³5oámÚò».:ÿl5::¸üÄ©3´~Ã&µnÕ\õë¥*//Oó.U8œ§n]:–:¨8Ë/>sJ‹®}}ȸ§ôÙ≒*7|ôÔæoÿp½4t˜–,Y*)ÿ'ê㾜 qãÆK’®¸ìÒ¢•'%©Ã‰'J’¾ÿáG-.8FÊ_IôÙ¿—z|>Ÿ.ê�¿ÀÌ}¬¯§Ï(^¸beºþõôsn³aÃü�k×þZbÈæÆM›ôâ‡Å¡êý®¼ü2Ùl6…B!=üÈ£Ú½{·¤ü÷hØðZ´xI…ÛìØ!ÿ}‚zç½曦©W^Qb^fy^:¬èܱXLcÆ�×—«‡^yåå%îsYl6›n»u $iäg£4ê‹1ECT7lܨûxXÑhTõRSuíÕWwtÁð+ÓK´7kö77~b™çº¦ À.YºL/¿òZÑœÃ;vê‘ÿû‡r�C^/þX¶lݦ@ ¨H4ªi3æh”é¥~-Y¾B’Ô®mkõìÖU¿®ß )ÓgéÑc4}Î\¥¤$é®ÛnÖ—ô.j·}ÛVŠÆbš6cŽÞùð3�™0U±XLwßv3Á€8±|�aïö½ôO÷•Ê)wŸ!ãžÒ¨Å“õ˶ÕÊ f—»_Y®írqUKT×.�•™™¥Ë®ê'ŸÏ'3+úÐÝ¢Es=\°pK¡¯ï¯�?©}û2uu¿ëÕ¹SGy½-]¶\ápX�;u,+ëÑÿû«,\¤ßߪÛî¼G ^¯ ›M999:¹Gw9�N¥ðˆƒƒpݵúòË Ú¸i“z÷½\ÝNêª�;wjîw?¨KçŽÊ‹Dâ¶ÈN›Ö­4äþ{õÂK/ëëé34cæ,%'%)++K¦¤®ï¯�>þ´Bmžvê)êÔ©£–,Yª§Ÿ}^£Ç~©´£�ÖšµkµeËï:¥çÉúáÇŸÊ=¾I“ÆJðzuÅÕ×É—� Ó4‹îs«V-õÐ�û«Ž�7ߨåËјqãõÐ#×ß{B^¯§h! ¿ß¯×†-±È�×ÐsÏ¿ q_NÐï¿ÿ®æÍ›kݺ_µ`á"õé}¡&O�Vê<×õ»FS¿š®o¾�«ÿ¾üІ¿öº|¾íÛ—© êëâ‹zkÒ”©y q<ûø#¥¶5<ª¾Þöï2÷¿ó–ÊÜÞ²y³r�)Ô½k§Ï<˜£ê×ÓuW_zXû¶iÕB÷ßuäçF`e–ï1Lö$ê¶ž×r¿Ö/¬p(ìyl—*Ï/”¤‹ûôÖèÏ?ÑM7 PRb¢ò"5JKÓÀ›oÔØQ#•rÀ²F�Ò4vÔHõ½ø"%''kñâ%J_µZgœ~šÆ~ñ™ú_wm•k’¤£6Ô—£?×€þýÔ°áQÊ‹D”šš¢»î¼]¼û–zt«ØµŸÔµ‹F~ò�N?íeddhü„IÚ´i‹î½{°>|ï:ëÌÓãRw¡{îºSǽ¤Î�:Êår)/ÑÉ'w×È�ß×�ûï­p{6›M½÷¶ ¼YÇ4mªµk×iÁÂE:¶Y3½õúp=÷Ì¿z|,ÓèÏ?ÕÀ›oTRRRþ}n”¦[þt“Æ|þi©9¦å1 C/½ðo½2ôE�Òódù”›P³cŽÑ ×÷×Ô‰ãÔóä%޹óöAzñùguÂñÇiÙò_4iòT™¦©—_ú�^>´ÌÕ[m6›þ÷ækzè�ûÕ²e‹‚mv]vi_�3J_Ü»Ô1¨� óp—T”´$ý7µmÑôHÖsH«Û¬Ní[ĵÍ}Á,�üßËÚkX£þôj\‚!þØÞÿðcýó‰§T/5U çz"€#«6ü_@EU5'Y¾ÇPÊï5übà%ºÿq‡òxïû …¨� üŒˆ+‚a�ÓÚꉋþ—¶®éÔç°†§@m@0,¦_羚vçUê9|¼÷ýzÅcq¬ Ž,‚áNLk«¯¤k:õ©Ðq=�í¢Qz•žBu‹ÏĦ½[õÖ#õÃúZ±}m©×›$§éÔæ]um—‹™Oµáÿ:*ªª9ÉòÏ1<˜cRé_Åæ.ß¶Z™Á,I"øÃ VÀ‰imkºˆ;æ€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâê\0Lð¸•�”iš5] àÄ4Meç•àq×t)T»: ½·rsƒŠÅ†€ø‰ÅLåæå%,¨ÎÃD¿WÙ� ò"‘š.ð’‰(;T¢ß[Ó¥Píê\0t»\²6eå�ÆjºÀ@4SVNP6Ã&·ËUÓåPíê\04MS)É>å‚ „ )TI,f* +'TJ²�9ìKªsÁPÊï5ôyÝÚ½7S¹Á=‡€J‰FcÊ †´{o¦|^7½…ËrÔt••è÷I’víÉ”ÏëQ¢Ï#§Ã!›Í�a5\ ¶2MS±˜©¼HDY9Aå‚òyÝJôÓ[°®: MӔߗ §Ó¡½ûr”•“+¿×£„�ü žš.PKåBÊÍ *;�?§0%Ù'·ËE(XZ� †…Ü.—Òº ‡••о»• ÕtY€Z*Áã–×ãVýÔ$!ê|0”ò{]N§ê§:kº@B( _�\|?C°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`ç¨é€º (ÈU0V8®–sºÜ.yÜ.y½ òz½Gü|5q�uIuß�êD0"(+;[’)�Ë­õýòx<Õrî`0¨` ¨¬ì,eeg+Ñï?"�¤ðMÓ”ÛíR½ÔÔj»ÆCY¿~ƒš7?¶¦Ë�Tp?BAefÙûQ†@9²23 ‡”àõÈëõÊn·Ë0Œj;¿Ûí–Ëå’/U PNN¶"yyJLJŠÛ9²23 …äu»å©�k¬K ïG4!ª`  ììøß�šB0Ê�•™©p$O‰‰Ir¹œ²Ùì’iÊ4%Ó4«­C†§|>›œN—²s²••™—0’•™©P^X~¢\.§ìv{*þã2 C†aÈf³Éf³Éát)'7[ŠÓý¨I,> (ÉïóËívË0l2MSÕ÷3•D Ã&·Û-¿Ï¯P8¤@ P¥v�€‚¡�| ~y.Ûl6y<^If¥{©�€LÓ,šSˆÊ³Ûíòx½2ÍÊß�Ú ö}§5(È•Ç宕¡°�Íf“ÇåV �[©ã�\¹Ý.BaœØív¹Ý®Jß�Ú ö~·5  ËíñÔêᕆaÈíñ(XÉg CayܵûëÃ0äqWþ~Ô¬J …åq»kd¡™Ã•DÜ•~}8®5Ï)ü#0 C�§Ò÷£6 ¨h(LO_¥Y³ç”ØÖ¸Ic]vIßr�™7¾æÏ_Xb[ûvítöÙ½ŽH�ÀÁ €*xô�küÄIe¾–™™©¯Pj{zú* ºmp™Ç´k×Vï¼ùº“ãZ'p0Ì1*)=}U¹¡Ðç÷«ûI'•ùZ“Æ�Õ¶m›2_[µjµÆM˜·QÒ¼EËôå¤éÊÊΩéRjz €J*>|té¢y‡}\bR¢¾øì“RÛot‡æ/\¨Y3ç”ÙÓˆª›·p©$)}ͯêÞ¥C WS{ÐcG0‹#€Å €JjÔ¸‘¤ü…fâ¡qA{…¿Õ…Åg€JºüÒK”••Uîê£õׇP“&�uÀþqi8\C  â¹zhbR¢ßy{ÜÚÁÀAÍ[´¬è1••è÷©ßå}är»âTUÙ·Öy —–»_uÕZ›0ÇÀAmù}[•ÛÈÊÎQf5ÕUkmB0pP‰~ŸºwéPÓe–CÕZ ›4N«3×TJ TAzú*eefÅ­½yóçÇ­-àp €Jš7¾®íƒn¹ýθ´7âõ75è¶Áñú›qi8\C ’æÏ_(IZµju\Ú›7oA‰ß�êB0‹#€Å XF¢/ARþ#)°�«*©]Û¶E_ºµä4�7ÒÃQbRb™ÇŽxýÍ¢9Š…Ò׬Éo·}Û²Aô>'EÎ IDAT»âbefçXî9…‡B0*éœsÎRÛ¶m´zõÍ[pÀ‚1 òÃáà;o/uܼùó5â�·ÊlÓç÷ë²KúÆ¿XH’\n—¸]5]F­C0ªàÝ·Þи 4kæœÛ7n¤ô/ó˜îݺið·•Z}´]û¶ºì’¾j߾ݫ( Á¨‚ĤDÝxýÝxý€ 7øÎÛ58>�?ªŒÅgÀâ†@1N·KÁ`P¦iÖt)å2MSÁ`PÎJΕsÕ�k¬K Ï]$Åx].Cµ;4™¦©`((¯«rAÄã®ý×X—ÞÁøcp{< …ŠF£5]J¹¢Ñ¨B¡°ÜO¥Ž÷zjý5Ö%…÷ÃëM¨éR*�`ãr¹d†‚�@­ NÑhTÁ@@†aÈUÉC¯×[«¯±.)~?¼^oM—SiC Ã0ä÷ù …çժᖦi*ÎS0’ßç“a•n+Ñﯕ×X—¿‰~M—S%<®(Æf³É0lò¸ÝÊÉÍ–$¹\NÙíö­+�*ÎSNn¶‡CÙ99Ê åv»äq{ä©ä¢/ …  …‹†¸†M’!§Ó—s$&%É(+;»F®±.9ð~$úýu¾§°Á(ƒËåR8V,fSjr²Âyy ƒÊÈÝ£¼P¸Zjpº]òº\òû|r9�ŠDc²Ù*¿èLy¼^¯¼^¯�€�\íÞ³GájºÆÃ±~ý†š.ARþó=n—’ÿ0�°Á(ƒar»ÝÊËËS$•Íf—7Á'o‚¯Fê‰Dcr8ìqë),Ka@„õ €ƒp:�G4Œµ�«‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°¸ C�Û¥Ü`H¦i©z‡É4MåCò¸]Uj§BÁÐëv)ÉŒ  ¦™1SÁ@HÞê †‰~¯rCaåE£U:) êò¢Qå†ÂJô{«ÔN…‚¡Ïã’Í0”)�UéĀʋEcÊ „d3 ù<ÕØch³ÙT/Ù¯@(¤`^žb )€j‹™ æå) ©^²_6[ÕÖ­p0ô¸òy=ÊÌÌV0¦çªQ,S0Vff¶|^�<.G•ƒ¡£";Ûl69v¥ø=’¤½™ÙòºÝJðºå´ÛeØ †Q¥‚%™¦)3fæÏ) „…äóz”â÷Èn·W9f%ž= …ò».ÃíÞ—­˜i*Áí’ÇëV‚Ç]¥‚%åC BÊ …e3 ÕKöôr»«žÁ* MÓT8V,fÊf3”ÊSVv@�PXÁP¸ÊEöó¸]òº]Jô{•àve1—Ë—Q›• †…òòò‰ðè ¨N‡]N§3níU)JR,S,S4Í÷ÊB¥W†!†Q4Ÿ°ªs Kµ_Õ`¨Ûâ3uÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†`qŽx4’�Ô¾¬åBÊ †âÑ$ @‚Ç­¯[ɉ>ù¹èM™¸H¡¸ž)¦ ï\¯¶mŽSóö×jĺ²ûô _’’FáŸd$&+©dqÚ0æM�Ù‘¹ÿ(ÙìvÙ C¶Ô³ty¯$ªæn�¹£»Z´>N­ÎzNóËêêð‡â¨éª.ª•“§jmAF3l6fL13ª­_MÖÏí¡3<ñ:Õoš0~©ò̃ïfK»JϾÔûSÒµÏ×FÞp½ZØKÖ¼6}�"…íØRtö?>Ôðë[Ëޣͻbjä�SÍÛ1]c¿ÏÑ!.ÀH݆‘åš8u}Á>»šœwžêÏš¦%yRlç �ÿáa�qvB|N•>QãWF#4¹Ô¬×@ý£Wy¯› ÃûÛ±·Q¯s[Êg“äIU³¦q)·bÚ2e‚~ +©óÁ0oÑdMÙXÐ]hKÕé× R£M3´deDŠíÖŒ‰?(ûìsUº.ª%/\¢«^ÿM9ÕãS5òæÆÊÛü­Þ}å-�úv…6ìŒêôg¦ëÝ«½Z7åUýã鵦pôhd™þ}á‰úwasîÞzmÑÕÇ%)k¼nëùW}]0ŽÕuúúþÝkÕÀ�›ÐÈ7GèÍYáb1O�Ÿy‚ÏoH½ü£F\œßÍÙ�®Y“§êëoçkéªõÚ’±O�¨KþÔFjybw�õ ºé¼Vò•7î4¼M?�©‘S¾Ñ¼´m_P¦Ó¯MZªC·ÓuÁeWè’�å mѬ7ŸÖ?ßX PA.Œn~_W·¿¨)ç)�éÛ÷û+­`rî†o4ò£±šúÝ­Ù”¡¬°äò§*íØÖêØýt�ß·¯ÎïÐ@®ŠÜPÕ®ŽÃ�æOúZ[ ‡‘&öP¯îÇ©q¯fze寊(¦½s&iNæ9º8é`3ö"J_ò‹v/›¢?zI?ìŽå÷æ JLò)cÌ_tÙ#³•SÕŽ4s‡Fÿí=ñÃa.Š“û�»ì}²õÀ¹ŒíݾN ·¯Ó™cõÙ%Oêƒÿ\¢fö’{åmœ¬G?¦ÏW044š©mëkÛº%únK�Ñí ýò�«të˜}‡9„4¦�3ŸÔ€û>Óš@É#"û¶ë×¥ÛõëÒïôå‹ôòŒ¡º4¥FfK8Lu{ñ™À|Møz{Ác %t;S'û:þ¬ÓÕ¨ $ÅöÍÕøÙ‡ <¦r~|[·Ý;t(”$[’ê¥Ú%W=Ûº•š$Ù÷/cxÔ ykµmSð«uš™ìJnÚJmÛ´R£Äbo½áUÖ…mµR£Â†zê¦þÇÉeH2 9¼õÔ¤U{�Ðúhùìû˜!­Ÿð¤ž»C±â§Ê™¯ÿÜñ·Ò¡°8#Q½®ºPGÛ$grµisŒê¹ö_„áLÑ1mö_c›¦Ér’òëõ§Fí…†S©Ç¯Î�Ú«ÅQ^å—fW£‹ûéÖGÛ¢’™­¹g)ã’+Ôà %ºc©I2ì‰jqòYêÕ©¹ê9ýêÔÌ®=žÖäKšù×35hô¾üìm4è�O5¸•½üFdÔ×%ÏŽÕ% jâ==uÏÔ‚±¦Žºûýwus£sº]ínú‡žómÐѧ�®­Så”$Å´wÞ ºî¦÷”žgJf¶¾›:W{¯ºRõ IŠê·‘/éýµ…ó ¹š÷Ößž¼O—wª¯è®ÍZ»ügÍø6¨sÎM‘!éÌ¿�ÖW‘%z¶÷õzc}~Ô¶}™þ;áu;à»$–‘®E½˜†µK1™Êýa²¾Þy¹ú7KW8KÍm’­Á¹zðÙ4ð¢njÛ8U>—]†a“Û¢FmNRïÒ›_ŽÒ¿{§)>ý§Ž$Ã4ÍÞ·$ý7ujßâHÖ¨ ªfµºÕcˆ;‚!XÁ,Ž`G0‹#€Å Àâ†`qC°8‚!XÁ,Ž`G0‹#€Å Àâ†qÛù�žûËßôè¸ ŠÖt1‡PõZMåþüžîºïq½»<çêòÅvþ¨—}JϽE±#r†º,¬ô1/hÈ“£´ ˬébðà¨é*#¶u†žyþ+m,H5†a“ÃãWý´ctüI§éÂÓZ)Õ^³5¢ŠÌˆòòòŽÄdÙècîÕ/߬’«kµI4J¼Í‹(/œ§¨eßü{wÅÕ·qü;»qâA,xðâ… Å­.”ÊKû”¨S·§Þ§@¡^ZêÅ­P¬¥hR,hÐ,�„¸íÎûGB !¡ žìý¹.® fG~»2sÏ9sΕT"ƒa6¯z�èÛØ‹™EJü "·nã¯;Ù¼ïvž½¿)þÆ¿ïEnL–òxúÝö`8î—hžÞÆüy›hX§e¾`èBƒÛŸcÂm†#<""""r•è`èØ€Nª‘Û8xK'þúr¿nùƒÅûqGM5–h�zlÄlÛÁa4,ðu…B¹rJp0,€S9Úµ­ÍÌÝ<�Y3Ãv�©o}EDóÿðrçt–Íø�¿v'Á¹�¾:„FÎ`¦ŸdÓ²eü¹)’¨Ø4Lwk6¤S·Î´«V†<×ßfQáK˜½|‘'’Èrñ¡Z£ö ìdÁ9O1vŽ,œÀ[‹ìôzj4«œÿ8§�È™ðáJ†¾ô¡çŽ�yz.]Ãú�G8‘˜�ÕÇr•›0èžîÔ/cä”pœ K—±ìŸýDÇ¥a”)KÍÆméß»5ÁeΫ¶Èµ^Dæ)6-úƒ?6D}&'ïŠ4hÛƒ~Nù>—3,Ÿô¿kΨ7†PÿüLn?É‚�Æ17£cÇö¢šø—ï¥AìrÞ}wi]ãµ~•±öËy÷Ý=ü$7',gÞÊíì=ž@¦“k6¢G¿´®ä’÷[8³�%ó³2"šØ '|kÓ¦[:g.àÅ_íÜýæý´ó($aýK�!góÂÄpÊ z†§»øåù<²¶þ“ßl§Þ½¯ðŸ®€IâÚoynº…{_éƒëªÅ,ÞÉ‘¸ ,enÔŽ�ýZìa€ý8Ë¿™ÂŒí±dš0ç�±Ì°ÖàÎWþ�›ýllùáM>Ý\ƒáo £�ûÙZ¿dûM#rˆ9 Ö±-*Ž4«�µ›Óop7Z°lÁŸ¬ÞEL x”«NóÐÞ nY ×ó‹7“9ö Vm'òDéV/‚j5!´O7Zº¢<*"""Rú”®`Xœ¬¹-ˆ&ä\ÄÚ9s|3Ó&…³É¹.-:×§Œ[�N@F >ýš¹GÜ iÛ‘¡U½°$Ÿ$",Œï'ì`ÿðG¸§¡gÎ~²8²ì[>œw§ê-¹åÖ`ü�dŽìXÏ—“3°˜àR`UE“ul5“>™ÇN[š´nOgRãOï�·{ÎåxÆ|öóŽûÒ¼swºVr#íÄN–ÿ9›�œaÌèžÔt¹BµÚcYýígüa#¨yn )‹Kj »Â§1>ùJ´Æ^ä{)T*;ç|ɶ š·ëÂm¾N¤�àï¿Wñíçixʆ嫘£mÎmÓ¾M~ûèk–O[LóÚƒ©ï fÒ6æ.9DFÅNŒz¬75r®¥[µ¾‰ê?Œã‹ÓPîRK7ϰvö"v¦ÑwÔúU-(¶Ù9¹z ¹Óö¡Ü×Ð#'°6¡±_:¯ý¼ŠyëÛ0ª½\�ZÓwÿÅœˆ|[ßÇ“w†p¶1²mëZLýàK–âz©ï6WÁß ‰ÔN\¼/÷à³ð]hz¯oŠwÎ÷Ø*Øà­ÿbó–(n«S+�µ‚ßV�¢|×Gx²Õœo¸1-ëºóÁ{ Y°xí†5ÂãRÞ»ˆˆˆˆÜ°Jôt¶ôdâãÏ{ú$‡vofÑÏ_ñÕšxÊ„t¥kpÞV ýúÖÍsa�ǶmÑØ<ЩYÞ i¸Ó¥u F|dG€Ì{Ø“f¡Z«VT??·ehÔ²mÌùfÊ^6ïËÀ¹N[n®RH[žÏÖ-QØ|êÒ¢†é¤§g�žž‰[ÍÚTµd²?2Ь+R«�¨]‘$þ´lW‡ó{¨âZ�ÖMÊ^‘ž¿—‹o�K�f´ð? eƒ«àmdræLZö(¦ö8"vœÀîYÿ‚ïÖ©bsÚ[‹Ü%²ø5^Œ…ê-šåmq4Ê\=‹=‘3—9ý„áU�æµÝÎ[âJ•Êå°®ÔkV?7X+äl’”˜”3m‰�#[¶s‚ ÜÔ´<äþ|e�éU“zå-¤ì?@ô�>‹ˆˆˆˆ[ n1´szõÆ®>ûoÃÕ�z�ïàŽ¾M)—ï"ÞR.ˆÊnù¢€=ž˜X;–€rT¸à“°P¶b9œ9NÌ©TL_à •-–¢?'w)5š¹aë‚#cµ^½á[ «¥�Z‹2Š©™ý3o­Æ-÷¦‘[«X<Ñ#†""""¥O‰†®e«Ñ¨ÁyÓU—ÅŸ ì'Op< Êçi†²sêx ™d·.”ññÁ…CÄÄ$`’wJ{B fÞ¾¹‹���ü29s&ßsïÆÇ?«IäÉS¤™Uóv�Q IDATÝÌ]É�rþÌS™¸V®N­‹<âWÜZ øpðõõİÅrâ”òŒªj'áLb¾gô,Ùº @d&—h÷‹ðÊ2|ð±`?}ŠSYP>Ï0¬™$$¦^þ!ŒìvöÂ9&‰gJàäóVÊúb˜Id¹W¡V° ˆˆˆˆ£(ÑÏ^6Ã�ÆM«âœ¼ƒåâò3u?Ë×Ãô ¡Yõìüì\›Ú®v„oäHæù;Jgï¦ÄæIJ^>^XÌDNœLË–̤ÝlŽÌ̳Ìð¬E£êNdìcűB†5±øÓ¤INÉÛY¼ò™¯u µÄJ•º5ñ4cذîiç›u‚õ›�å ††>^.�vŠãgò&¢ô}ìHºÆ)É@ýze1#Xµ-1ïç&‚õ{3 k(.2ÃÛÃΩ§ò~f<[¶árÅsqqÆ0SIL¾VŸ�•ªMPžX–n"FÏŠˆˆˆ8ŒÜbx%”oߟþÛ¾bÆôÏÝ–Õ¼±¦œd{ØZ6ÅùÓ~xwBrZæ ¯ÆôíÆî2áÓº¶¬†Ÿ%•ã{6vÄ™<ã¡`àÒ„ú{Ø2o* �»Ð¸¼ é§¾t;M—¼= : ¸™ðIK˜óÉgD·kB-²’Osx¿�¦ÃúÑÌÝBÅŽéñ5³æ}ÁÛ[Ъny¼¬6’c�±o×ú=Æíu­Å¬µ`®!7Ó¯ÞN~^ù#¥¶§}Ý\ÒO¹q{²üpÉ󔢵›5Àwãüô^·4!ÈÃÆ™¨/ÜJªëÕë>Y0 UºÜB»�?°ú—/±mKÓ@²â£øgÍv޹¹`d\æÊÖ§EµeL_?—ï+ö¥[_¬©§Ø³vuÆé²`Á¿FuXÉšéÓñéR?Ê6lJ-¯Ë«ûbœªÝÌ]]ö2鯙¼ûq$í›SÞÝ #é4Q‘{9UãVÆô tð;J""""¥�ƒCÀ9�#£üò¿X¶a3ÂRÈrö¦R�æÜu{W:Ÿ?Pˆ3Õz<ÀS^‹™ý÷6N[�ÍÕ�ê�;ð#Ù4þK6Ÿ·kç÷�È`ÖïkùóÇ/™ksÆ»\e¶¾ƒgۮ⿿¦ä)Å¥jWF�.Ë¢%alZ·Œ’2±¸ûX»~N9U¸ÑëÑ‘.ÿ“¥¶°0"‰ œðð-OpÝÆ4ª`¹¤Z d)KçGàñÇ"m\ÉÔ�™8ûҰÞlt”/Þûëüw‹Gý~]I¦Õ�²•kÑrȺlÿ’/ö_âwt‰ Ïî~beç-cõêlͰâU>˜V· £ÃÞoø<ü2`)O·á÷a›»”U‹äý9&®>¨Ù° ÿy4�é/º¬Ý;wgÄm©üºd;óÛŠ³O]×nrUƒ!†;õŒàùª+X¸r+kn#1ÓÀµŒ/�5êÒ¦Ž¯&¸)… ó¤ µe×šÔ ¾šõˆ\lüî-¾Ü^—ïÜM3çßBDDDDäFv¹YM=ÂÄád?c˜�5°2•5¾Šˆˆˆˆˆº’Jée?¶‚O=ˆo­ª•óÁÓÕ #.Š�«Ö‘âG»;[\0ߥˆˆˆˆˆ#R0”RËð©Fý ¬ßº†�qI¤f�“›ª5cèíÝèZ·Œž—AÁPJ1ã]oF×ë]ˆˆˆˆˆÈ NéDDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœÓõ.à’Øöóë_ñgœ,~´ø îkà�QÀªöcËxûýÅ6êpßëÐÁ« µDDDD.�™vœM¯då–}>™@ŠÍ‚‹‡7å+Q«n}Z´hH-?gÀ$9b.þ°�äÊ¡Œ|´3U­×»z‘’ Ïg�gíÌÅ´ª1€w…>¹¶ìq[ù~Òo¬=™…™»ÔFZâi'žæðÞ�÷¨Á¨ö>˜ÄìÛ˱” ìû÷p ¹U½uý""×_Ɇ˜ØO…óëMxaP0®×»qf*[çÏaíÉ,p­D‡AèÕ¨^F*ñ±q;¸›Í;³hÚÔ;§g“…*í{Ó'e;É�­h®žL"rƒ(ÙÁÐZ‘&õ³Ø¾ýÇWÎaa³ÇXÍùzW%"""ŽÂ~”{’1±P±ã`înW•ìž¡n¸{úQ©j šuÊ»‰5 >ý)\Ɇ¦A•.}ñŽþž•±ÇY2mÍFw£jß•™ËîMߺ—È#1œNÊgüƒ¹©ýÍôjˆÇy7òìÑKx󃥜¨Þ—×kDÌŠ¥, ßÅ�˜l.ÞÖjLhŸPZUr&ùÐz.]ÏæÈãÄ¥xÑ uWu­�ïCþdqjçj.ÿ‡ˆƒ1$dZq÷«H�Æ­èÚœjet7QDDäÆd#Ë`àêæZàxy™Ä­üЧíÃæÓ†1¯ ¢ž̸5üï�9ì¶²™Q†ö�¼È°�s$šÉÑ„-[Ί-û9›ŠéêEùªµiÝ¥+]ëû£[å"R%;’A†slÌÖo7s&j9¿,oÈÓ¡(ÊsÜi{–òõ¯IÀÀÉ݇²å<ÉHˆåäþ­üq`{Ï<ÂS¡•.ø�lÇvóû�kX·9ÓÉ7+¤§ÆqhëßL>Cb_VNãx–w¬ö4Nìgí¼ÃL~˜T?×åÕLcÿ¢oùdáA’1pñ  ‚¯�ø“‡Ù¸ì0[·äÁ‘Chæ«p(""rñ”£rE+F¢�¨u+ÙÚz0M}.aÐw'O*T "-_0´%Ÿ&:6 ÓpÁÕåÜr{ì¾›8•u§²Àꎹr8§Ært÷zfîÞÁö~02´²±‘"+áÁÐFVx5¹…A ö0e{ ûÏáï&ѵܿÿRv¯ß‰¡½*âT¿ MªúàlY±„ÿò%“×DZÿ¯Õìì<”Fùn¹™©{YQ‰NÃÆ0¸iÜ� Žo˜É'?m&&qS1ðéÅ“w¶§Ž¯3fÒA~ûs÷¦r|Í"zV§™[ö¾Ò#3ù�C$ãIƒÃxèæª”1À¿‹©ŸÿÀò£øiVmjßß=† ""rƒ1|iÚœeûɉÙÀçïFÓ¢óÍôèЀªžEnÔðjÌ=O6λ0ó(¿OøŒèXŸ&½èU#gf,+™ÉºS6œÛðàÃýhàfQÿÂøY»Øóût×{œ~•5䩈MÉžÇд‘e _Ú êN]73m?s§¯ç”½Û[+Òæ–N´¨– œüiѹ å-`¦œàh\A;²àߦ?·5«€»0\¨Ø¢'7gœ†K-úßÙ™º¾Î€Å³:=z6Á×fú ¢NçìÓL柿7c×z=– ¬¾õÔ· ^†IÒö lI4 ¨CDDD®/ƒ2!ýuokª—10“�¾à'þûê{¼ÿóßl9™Á¥�Á3Ø¿h g`øÝÄ]C›p¶ó�=*œe{Ó0-þt¾-'nTéÔ�îU­˜¶¬ �¢°ž©""ù•ì`œýmk)ךۻWÁÅ0IÙµˆ©Îd¿dEèïo'3%‘ØØXbN�&&�ì hf’‘YÀê†+µëUÉÛwßð¢œN¬T›ºù†žvòÀÏH'--§hÛvïKÇÄBÕúµñÉW¨kÕjYÁÌ:ÁáãEIº"""rí9Q¾Ù žéqê}5|œ ó ‘a øôÝÿ1qé!’‹•MÒ"3eÙ1²Œ:ÜÞ�¦¹Ý†LNïÛÏ);žµhX-_ç/‹ÁÕ¼°`'>úº¯,"EU»’žÏJP—þ„nüœ…G“Ù2÷w6Ô»“NN…ظ’¹ ×°ãtÛæMá;¯'øOkß"ܬ3e/3~YÃq»… �‡0$Äã¼íìÄÇ%`Ì„uŒ³®Ðýéi¤™P¤ƒŠˆÃ+EÁp®B¯!­Ù8i '¶1cnSêõq.pT®¬c+™0n{SÁ% &í;Ö#¸œ7îÎˆÛÆÌ9[8Uè�¬X/Òeß0 Œ"ýæÏ ž†ïÀšT)t‚[*_�4EDDä†dõ"¸UožhX—©ã¿áÏcÉD¬ÙJL«N”ÿ·Ó¹™Ä–™3YyÊŽS¥Î ëS÷|Û˜öì›Å†[YjV÷ǵ�}ZÊùã¢Ë)¢Ò ·Z¡ÜÚ*‚OÃâ‰Û0�ÙõÚátÁ/Å,v/ÿ›ÈT‹ÏM<øÔíÜt^ð²Gç÷kP«áî…�‹)ÛßμtSODD¤”0<‚騬Ë?Š=>žx;”¿èX0&ñÿÌåç q˜Î•éuw(5/VÔÀÛ× ƒxp¯ÃÀ¨£ñeDä (ùÏægxШoošy˜ö8VÏ]MtþÇóÌ4bãÒ0kõêçi�3I;q‚ØkÑsÓ© u«;c`ãÀ–í׿˜"""r�drút"vÀ(S†›–ØŒÝÈO3¶oºR³×­ÜR¥ >OÊÕ Æßö3»Ù¸?ãj."¨ôCÀðnÌ�>u)c˜ØããˆÏ 7|}²'¡µ�<ÊÑó˜ÉŠ‹`ú¤]‹�fxÑüææ”µ@úž?ølêF%ž?Ì´¥p"r3†&í”#"""Åc?¹ŠOÇÿÄ´?ÿ!âP ñ)dee’{„� æ§õI˜†•›6 ÒÅ®ºì§YñëïlM�Ú=¹¯kÅB»uY«µ!´–†=–¿ø‰…;Osn(“ô3Ñl]»–­E¢]D$[©ëJšÍ  u?ú¬?À´Èô�q¢NÛTÚ¸‚£ÇW0îýhÕðÚ|‚=»¢H¯Bï�ìNºú•ºÕ½…‡ûÆ0qþ>¯žÊÛkgáîé�+™¤$¥’n7qª7˜-«â¦~¦"""73‹øƒ[Ù¼o+K zݰâß /÷ß\ñ"wãM6ÌgÖîLç7ðÍGó­c¥r—{¸¯¥†%€Îw%곩¬>¾‹YŸíf®«^îNØÒ“INËÂnøÑõñV4.{%߬ˆ”f¥4–²tÒ™ðÿ-á`æ…ÑеF/F?R†Y ÃÙvxN9QÆ¿!¡÷2 k-ŽM{—=ë¯E¡®T}�Wjndéߛغï1‰ ¤Δñ­DÍÚõhÖªî¿v?‘kÏâ߈“ Û±ŸCÇb‰KJ#ÓnÅÕÓ‡ŠUjиe;n¾©=�›¤$$æ´úÙI9}”C§ó¯cÅš˜uî¸~�¸÷©Š4^¹’•›#9x<ž3gLœÜÊP¾z5ê7nJ‡ÀRÙ1LD®Ã4/˜¤¡P[v I½à«Y�ˆˆˆˆˆˆÓåf5ÝJqp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qpNÅÝ`÷�è«Q‡ˆˆˆˆˆˆ\'ņuƒƒ®F""""""r‰¶ì:pYÛ«+©ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ9l0 [·ž°uë¯w""""""×�Óõ.àZ›>s6o¼ù6 ‰‰T âå—ž§g÷Ðë\™ˆˆˆˆˆÈõá0-†kùãîa<ýìØÜPp$:š�>Îw#bÇÎëX¡ˆˆˆˆˆÈõQêƒaÔ‘hž~öî¼gaëÂhݪ%¿ü8…_~œBP` aëÂéÓ0o¼õ ׳d‘kÊ0MÓ,êÊ[v I½à«YÏ“��Àäï~`ò·Sr[ƒ=j$·”gÝo¾�¸ñILJÀÛˋѣFòÀý÷]óºEDDDDDŠër³Z© †‹–,åÍ·ÞåHt4^žž<0|¿ooï·IHHàãñùvʹË*ñÁ{oÓ¶M«kR·ˆˆˆˆˆÈ¥P0ƇŸ|AJjê5®êú(Ñ-†ÓfÌâ™ç^Èý÷ða÷2fÔÈ+Þ¢—��Àëo½ÃŒ™³s—}ñÙ'šûPDDDD¤û¿'ž [çö4mÜ wùéØ8¾ûiO=þÔ­]óºÔWÝb8}Ƭ<ÿöññ¹jÇ20.zl)™š6n@ÝÚ5sÿ´kÝâz—tÍ9]ﮤq&2ùÛ)¼òò <ðŠìsòwß3nüÄÜ)/ÎJHH,d ¹Ñ¤¤¦r$úX�¯‰>†aEz-Àß�¿«RãõT*‚áða÷’�˜ÈŒ™³IHLäégÇ2}Æ,F=þØ%?g¸6,œgž{!wÊ‹³Ç [ÎÎ]»¯Té…Ê\ñ­šA¬píÎ'&ÐÏý*ÔLaÏ‚¯˜øËŸlØELbk4¤ß˜ÿ2¦ƒÿwR÷3û�1¼8=’2w~Íê7Úâ\ÔM7Ì໾b§½OÍ�Æãu¬ç½šÉÉÍ ùù·ßùs]ûŽÇ“n¸ã[©7uìǃ�ÜA› E¹¬ËdÅ ]¸j,v¬Ô9�ßG‡\ü‚0åožéö¦ÅØÁ)ä‚ڒ猤ÙSËHÏ]b`X¬¸yúR>¨&�Zu¢ß·Ò£¶—®#äºúöÇ©lÙ¶£À×~›9¯Ðíò¿æîîÆø÷^¿¢µÝJE0ôööæÕ—_`èàAŒ›0‘uáë [Nغp†Ĩ'+ÖtÏ<÷Bž)/Z·jɇï¿C•ÊAÜ~Wi�ôÞäô—¸{ÌBbìç-NŒáÀö#àï�dî[Ä׿ï%÷·ÝÓŽJ%º3²ˆˆÈ•“ydïŒz�ï¶$`ÇB™âlœº…O^úŽ]æ…Wgf¾q�ÿIŠáAÅ�Æ´o\[<6‡³ìÇ·ùkq8ïýö1C*[ Üý ;‘óæ±å±šš^MÎü=‡%§í…­pv‡8UjD—å²ÃŸ=ƒäøãìßµ�ßw®ã÷_§2ôßó^Ïò%û9&)ÑÊ^¡V¾¿Ò×Z¥$žÕ¶M+Ú¶ùži3f1nüD¢�eúÌY,^²”†»èT Œ›0‰Éß}Ÿ»,(0�ßÇA&¸OaÍ‚åœÊù½o”©A—¾vNæ”ÙœAu­@*k¾y›¦žÄ¨þ �îR0'VM≧¾$<¹*ýîlÊÚßVcû4þ™ô*_ï¯F“úÑlÙ“ïeצ]ÚqStg�~ˆõ}É�G˜ûüýŒ™·Œw&¬ ×û7-�ZkÒ¢a ·-dÖú'hÞέàõÌX–ÌZA‚k3ÚÔÙFXÁƒ7àÖjŸ~Ô—ó7O=Ä‚ÿŽäÉß"™ùÞ·ÜÑí9š—ª«O)InÒŸÛ‡ô¿ÞeܰJåeý­C±pþ¬Ü©&7a"½û .pª‰é3gÓ¡shn(ôòôdÔã�±zŲ&^õ®f2gldQk¥âàWùò¿cyåµ·˜ðú ‚­`&¬dÆâSüÛ=CGbžœË O|γO|ýÃVŒíSþù”±“#);à1n«ZÐYÖÀ¿óX~üòiŸ \*ÓçÿQÇb'~ó&"‹z`ÓÊMÝ»RÎ<ÉsÂH.d5û±EÌX“Šg‡P:”)þÕˆá^�ÞÏŒ ‹»�íØv¶žÐU„È�ªTCÈî^:fÔHÌŸM÷Ю‰ŽfÄ£�sÇÝÈر“µaáôî7ˆ§Ÿ›;¸Ì�ÁY½bcF�¼žåçaX]pNßÇœ·GЫ] j‡4£Yè=<ùù*Žfæ]7sÅK4«BõZ éúÁV²R0ÿ½G¹¥ÐíL’÷-câÓ�ñqøÙ…6Žý0ŒÚµB¨^« ÷ür‚˜�?óì}¯òû™ì_趃ß0¨^Õk…P½N^ËÌ{üÚ-ùG2ØNþý«ÜÕ³ ê5¢Û‡ÛÈ �cç2éµÑÜÙ¿Í›ÞD­ºMhÐ2”[î{Ž�çí"¡À‰Tì$ìúƒO^Aÿ®hÒ�Z ZÒ2ôv†??�©›OsþfY§¶ðÛûOr[ÏN4¬ß�Ú�ÚҾ߃<=q{’Šyi {úðêSmpÍ0)öÙÉjÁjV'ŠØ‘ÈÀÚ¬?½ b—Íå¯3ÕÆÁùsØ�áK·mqϸ´ó¦á@@0)ú$i"WÏÒ嫸gëEš¿ uä(Ë–¯*Õs–úÆü*•ƒøêóI¬ ç�·Þfç®Ý„­ §OÿÁyÖkݪ%¯¼4–õC®S¥…3\Ž3õÑ{øk}|nk]ìÁ�ÌüèÖF¼Ãôñýº âÛ8ü÷O¼¾e%?…Å]d;;~}‡�çD~w3k o=ðs’‹ñÛÜLeÛÆUÌÿûcžœ~ˆìs‰Þ¾>€™°ŠËÌSyïfÅE³sM4;×.fÁ¦Oøí•øçÞ ÌdÿôgöÊ"¢òœœ’ˆ9¸•¿Eb»é†6ÍnaM‰˜Âˆ‡>`UŒí¼“l<Ñ;×0}çZÌÌGß½Î-•Š~¹�Õ{ÝIõÜ9²qâk|éÏÀ‰ÏÑ#Àdº½¸É)•ís±Ûf¥|«ÖÔ*ò)ÍF–µ)ûVã‡/V0{Y,}äí¡dÛËœ9ØÊ apG7"¾º´Tg;¼�ˆ8;Ö &4­XjÛ$¤„ؽwSs“÷Þkx¸mtÇßfÎeOäL ´K‡«XáõSêƒáYmÛ´báüÙL›1‹7Þ|›Ä¤$ û9ÂW^{COVo�ßÈŸ½îЗV•lì_óë£Ó0MǽË{‹;1¾—ÏÝM³vÍåGKÎv�&‡Âþ"ìpJ¾í¼¨Öóq^«rŒu?Ldþ`Á¿Ý0ï„ �-á6öj­ù‰ñ ’XÚòàºQÙÔ Î&²qø×±<“–š V‹þþ¾Xû3ÝU‡yŸ�¤VÇî„¶ªK%�ö,ø�×� ËL#ò—�øþö¶Œ®—½ïÌ_ñÄ«gC¡�“_mÚwl€úIöïØJDbnëY.»H�§DDäKÙ8‰¾ÝGÙãy1Ôƒ¸"·¨Ù29¹ þú)ÿûe/®õïãÝQ­)äIÁda³9Ѱ_j=‘Õ³s|à�yÆÈÜ<‡9‘Pù¾þ´v³±­8½@MɱÜú'ß¾÷%Û¬Õ¹mìpš:Ì•§”QGŽyâú=‘HIQ‹a©që�AT âÎ{†”ŒÁe gB�ÌÌ1 q̸å<7h$S�ØÀDz9+8Ó³¾ù“aþí×ñúàùî@ÞíÊ·À½ÍNÀ’Os‚¡�wýÜ{oÓs? õjP+k)ÌÞµW}zß}77]ä'ÈLM%Ý«>w<ó #z7§º¯»Íš ÄG¼qIDAT`�>‘Åw”%¸¼ë¹�úW#þæQÌŽ³cfígÓÖxÌz¤±ê‡ŸÙ‘ž}Æ´”ïɇ3>d`nk_:§Ž'ãã›ÝU%nɦÈÂ,¾Ýxó»÷X6ûȽÛûqºçK,K´sfåt~?ÚŸ*+ŠˆÈ5”²‰ñ/OdÙþ|>¶kvï˜ …™¬z¥÷ý“ÓÈÀê[‡Þc¾àùárý—Íó1k­> lø9ïn˜Çü¨Ûy¸ÚÙóaa³ÿ Šê<: ).ü—Ðj’4ç1êÌÉ·Øp£j§{÷ÞÃô«§é*äú+j,L•Ê�W¨’�®†Kkúôɽ høuäž¾ÕsB›IÚ®ˆ‚6Ï¿�W níSãß·»R,þôzãKÞ¹« Á¾ÎX±ž×°hxå …îU¨^ñìiÃ$919ûÞ™ï´añ£¬¿Rl€�Cûc÷à`Ë Ê`!;^ýƳîãîx\õw&""rq™f1c&Yöé o1½�µvòQï†|„3ÍÆÎgúƒU/ά•¨䄱%‰˜S黌áK×7ã·x> æ¬ç© ‘Ì\—ŽW—~ô,w%n!;S¹j,œ"æ„æC–GTôÑ"­·{ïþ«\É�A-†%�m?ó§­Ï�×Ï~r)ßÍ;;½„�[HjÔ¯2ßvfü~ûýpÎ�:�ú�¨]ä[ÎNN¹-ŒfRq—ð(€ýh4ÑgÏ N�|_›ìP˜IˆV.ØwÞ*ÞçþîÞ”Ñ_!êá7ùýp:Y±Ìÿ:‚ùùjq­Q¬�@DDäÚ³dÞ£YðŠjÖ£npEüÝ-¤Çc÷–­ì�ËÂЊ§>IËK¾nu¡YÿÞÿð%‘6+U{÷§u1ÇØH[ÿ5��œ“Ó"h’•–À‰ÈìˆN$Ëð¤ÑƒoñdÛÒ}a-%ùg ÓŠ´þéØìÁgÜKñÀ3PƒáÃïc]øzvìÜÅ�÷ £G÷n¼üâXªTº¢Ç‰:Í3Ͻ@غðsǾØ=F¡ 'jÞ÷1ÿm¸•~^ÄÚ]G9“éŒoµÆt»õÆÜß&Ïd´ç3mõxü§Wˆÿ1S–n':ÙŠoÕÆô¸k$cîiN¹âöåp»‰§¾ž€Û‡_1gÍNŽœÉÂÙ»<Á ZÒ­žGѲ±Öä�ϾÁcü'LY´‘ÈÓé8yU fÓnÜ󸏵âìþ*§äÿ,üéøüÌoû+_ÿ¼�U[ös4.…,§2”«BÛ^·ñpËswJ]ká“y71à発8Œ-{£9�’…áâI@P µèÈ-··£tÿ‘Ϲ5�½7ÿ…+Yq€�Ë·’šÎ¾T nÃ�»ûpϽ}iP”i% çÔ /ýëLæ{ªÑ@Ób>©h’uôå>²e`qrÅ3 ˆ¦=Ñ÷Îû¸³CÅœjQäªð÷Ëý{Jjj‘G­Tzž0ÌüÃ[^Ä–]hR/øjÖSl‹–,å�7ß!ú蹇GG?1’î¿ooï·Yž;Áý/?N)´¥1!!�q&1ù»ïs—òáûï\õÖÉK•¹â%Z?4ƒX;àÚ�O6L Ÿ’�ˆˆˆˆ�Ý5tìkïP%¨Ò¿¶î‰Ì|æþ»o¥]ëW½¾Ku¹Y­D·ôìJÏî¡|<~"“¿�BbRã&LdúŒYŒ5’¡ƒ^Ò~'÷=ãÆO$!1/OOF�ɃïQK¡ˆˆˆˆˆ\qþ~4iTŸ-Ûvù9C?_š6np•+»¾J|0c£¬È-|kÃÂyæ¹8�»lø°{3jd¡-�"""""Rr<öð0–._Åî½ûþu>Ã:µjzs‡R=¹=”¢`P¥r½ÿCgÄuáë [Nغp†Ĩ'+ôùè#ѼùßwX¼dYî²Ö­Zòáûï\ñgEDDDDäú íÒ�Ð.®w7ŒR9•LÛ6­øíçïùཷñòÌysúÌYôé7ˆq&åY7!1û9ÂŽ]BsCaP` _|ö ¿ýü½B¡ˆˆˆˆˆ”z%~ð™“��À7ß~ÏøOÎBo/¯ÜgÏçåéÉÇ1fÔÈkY¢ˆˆˆˆˆÈe¹Ü¬V*[ Ïçíí͘Q#Y¹|)ÝC» ‡ ÈêË EDDDDÄá”ú`xV•ÊA|õù$~ùq !õêæ.oݪ%¿ü8…�ÞGƒËˆˆˆˆˆˆC*UƒÏEÛ6­X86;vР~Èu®HDDDDDäúr¸`x–¡ˆˆˆˆˆH6‡éJ*""""""S0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""®XÁÐÃÍ•¤”4LÓ¼ZõˆˆˆˆˆˆH™¦IRJn®—µŸâCwWRRÒ°Û EDDDDD®7»Ý$%% ÷k ½==HJM#3+ë²*""""""—/3+‹¤Ô4¼==.k?Å †n.NX ‰ÉiØlöË:°ˆˆˆˆˆˆ\:›ÍNbr›‹Óeí«XÁÐ0 ü}=INM#5=C]JEDDDDD®»Ý$5=ƒäÔ4ü}=1 ã²öW¬`h±Xp¶Zðôp#6>�”´tµŠˆˆˆˆˆ\C6›�”´tbãðôpÃÙjÁb¹¼ ' ³˜CŒfffb·ÛILI')%�2înx•qÃÙÉ ‹Å¸ì¤*""""""y™¦‰Ýn’™•EbrÉ©ixz¸áåášÝ€çì|Yû/v0HOOÏ.Êf'6> »iÇÓÝ 7<=Ü.« É+)%�””4’R³Ÿ)ô÷õÌi)4pu½¼Iსišddd?chµZHÏ´‘�”BJj:)ié—]”ˆˆˆˆˆˆœãáæŠ‡»+Þž¸:[±ÙìX,...W¤×æ%ó233Éʲ]v""""""RtNNÖËî>z¾Ë †v»»ÝŽÍfÃ4M.oo""""""’ŸadÏaµZ±X.°™ ö¹ÁPDDDDDDJ¶+3EDDDDD¤ÄQ0qp †""""""NÁPDDDDDÄÁ)Šˆˆˆˆˆ88C§`("""""âà EDDDDDœ‚¡ˆˆˆˆˆˆƒS0qp †""""""îÿÙ^ïã3·eIEND®B`‚bpftrace-0.27.1/images/ci_job_env.png000066400000000000000000002452351526721631600174630ustar00rootroot00000000000000‰PNG  IHDRØÔ° ,asBIT|dˆtEXtSoftwaregnome-screenshotï¿>-tEXtCreation TimeMon 21 Aug 2023 01:45:42 PM MDTÏ›ï IDATxœìÝw|ÓÕþÇñwÒ–Ò½[F›e+Ã�â@½n¢(¸½†pëU¯çu� ‚ˆ KöP6BYe–QJ7�Éï�ÒÐК6iмž��Gòç|ò=‰ôí9ÇЬu‹T‹ÑÕç6Àl€Ø;°v `ì@ÀØ�€ °`6ÀîŽhÄ`4ÊÃÃCîîrs3Ê` ·À?S­6//o5ðôtD-@½Wã€ÍÍÍMÞÞ>2º¹9² ^«QÀæææ&Ÿ†& G×Ôk5Ú,ÍÛÛ‡p ç%»6//o–…ÀyË®€Í`4ª�§§³jê=»6gÕœì ØÜÝ Øp~³+`ss³{Ë6àž=Ø l8¿‘˜v `ì@ÀØ�€ °`6Àl€Ü]]À?‘¯É¤^½z¨O¯2™LjÖ,^¾&“²sr´cÇNåääè�%Ë´dÉ2eç为\ØÁЬuKu/öópf-ç¼ÈˆÝ~Û-téÅÕ¾gíºõš0éU¥:äÄÊà(l2jä]7tH�ïÿ~ê4}úÙ—Ìh¨çØjÉ×dÒ„Æ©cb‡Z·•¼c§F�~”�  3ºº€s™¯É¤·Þ|Õ!áš$µh¯ï¿ýR‘iŽGÀV ^¯ÍâÚ¦¯É¤_'_“É¡íÀ1ØjhÔÈê˜ØÞ)m·h¯;n»Å)m×GC‡\­ßgÏÐí·Þls<((HKÎÕ’…sÕ´Ic»Ûí˜ØAKÎÕósT©.Wö<Ú·Kpu)œ·Ü]]À¹(2"B× âÔ>®:D,Y¦µëÖ;µIqÏ]~Ó° Ç •“›«ÔÔCÚ¼åoÍ™;O[·%;¼ÿž=’äåå¥ ûôÖ§Ÿåðö‰l5PW³Ëêz›ÅbQQQ‘õŸ‡‡‡‚Õ¶Mk]?tˆ>þà]Ý{Ï�ï÷ç³´;%ES¦ýèð¶! MŸú�õ€«K‘$5j­% çꢾ}\] 5 6;ùšLºìÒ‹ÒÖäϾÐÚutýÐ!êÝ«G…ó;(2"B©‡9¤¿³Ù´y‹FŒms,00@ mÚèö[oV‹ÍuóM7hé²Ú¸i³Ãú]°è-Xô‡ÃÚƒ­6­[)4$ÄÕeX]ا·«K V˜Áf§Ê‚°š˜0éMþìK­]·^ßO�æôþjêøñ -^ºL£}Bùù’¤ÎttiM°Ï%¸º+wõ»¨¯«Ë V\6ƒ­m›V?öOÏÐ˯½¡]»STRRrÖû ƒÂÃÂôèãԦu+=÷ÂD­Xµº*.Õ»WÏZ·1aÒ+š5{ŽõýõgØÏ­w¯žg àêJVV¶ÒÒÒÔ¨Q´<<Øœ»õ–áºûÎÛ´åï­ºgDåËÆÅÆè‹O?’$]zÅ5ÊÉɱž{ìáQºêÊ+4oþB�}îE»êjܸ‘þ5üFuîÜI�ÊÉÉÕê5jòç_ª¸¸Ø®¶Ê uëÚEõí­víÚ*,4LnnF¥Kןþ¥Ï¿úZ©©g~ýåd5iÜX/»Ržž tËðÕ¥óŠŠŒ”Ù\¢”={õëosõÓÏ3d6[*íÛd2iø�׫oŸ^ŠŒˆPQQ‘þÞš¬/ÿ÷�Öüù—JJJäææV­Ïѵ˺ÿÞ{'IrÍ•rÍ•Öóÿûú;½÷áÇ6÷DFFhØuת[—Î Un^žvíÚ­Ÿfü¢ +ŸeؼY¼†¹ZmÛ¶QxX¨JJJt4-M;wíÖ¢EK´dÙr麡×è–›nPPP�$éùñÏÚ´óÈãOieþ–¨)—l‰:ÈÏ×Wáá7æi�~‚vîÚ}Æ�­,\ó̿նM+IRBB›: ØL&S­î?=\{úÉÇÎ8K-""¬Vý9Š¿ŸŸ"##$I›·lqq5¥’ºuÕ‹Ï�‘§§§,‹ŽK—»»»è§¾}zé�÷>¨Q»ƒ¯¤Ç)]*³¨¨HGŽ•·——"#ÂuÅå—©oŸÞºëÿî×�ƒ+½¿s§ŽzpäEFF¨°°P'òóåïç§6­[©MëVJlß®Ò 122BÿyýësÎÊÊVaa¡:&¶×�õɧŸëøñ …„WësÄÅÆ*;'G™ ðWZÚ1í?pÀzþ@jªÍõݺvÑóãž‘���Ìf‹ÒÒÒäÓÐG�/è¤ÎtÒÜßçëù “lÂÁ«¯¼B�<ô  ƒ u,ý¸|}MŠ�‰QlLŒzvOÒ5CoTQQ‘Zµh¡½ûöËÏÏOîîîJIÙ£ŒÌLk[ÙÙÙÕú\¸šË¶ßç-P¿‹úªY|œš6i¬±Ï>uÆ�­²pmó–¿5ó—_ë´îæÍâÏx~íº jÞ,^&Sà ç* ×ζŸ[dDDÍ u7775o¯GŽ�›››–-_¡eËWº´&I Ö¸1OÉÓÓS7mÖ ^¶^ÑQQzxôH=<ªòÙtg3þB%´m£yóè¯uëTTT:.>>N¯L|Aaa¡ºõ_Ã5aÒ+•ÞÿܸguàÀ�õ°6lÜ$³Ù"??_�ø¿»5øòËÔ¿ß…šöãÏZ¿a£õƒÁ ñcžVdd„ŽK×ø&꯵ë$I¾¾&Ý|Ó ºóö[íúß~?Uß~?UãÇ<­þý.Ô‹—êõ·Þ®ôÚȈpkXùéç_éß|«üü õéÝSO=ñ˜è§äí;ôÍwS$IÞÞÞzàþ{e0ôáÇ“õí÷?¨°°P’äïﯤn]äå奜Ü\IÒó^’$ý<ý{ê“O¿`ï=À9Ée{°>rDϽ0Q»Nje![|\l…%ðª מ{a¢9Z§uWœ•™üÙz`ô#ºî†›µ}Ç.›s5 ×êZ›Ö­ôËÏ?XÿÍž9] æÎÒǼ+www½ñÖ;ú÷3ãd±T¾¼a]rõU25l¨üü=ùÔ›ÙdÔ¿Ÿ§#GköÝÈÉÍÕ„I¯håê5ÖpM’vîÜ¥/¾úZ’Ô±Cû3¶ñØ“OkÝú�ÖÙ^YYÙzõõ·¬uvëÚÅæúÎtR›Ö¥ßí‰/¿f ×$);;Gï}ð±.Z\£ÏS÷Üu‡¼¼¼ôãÏ3õɧŸ[÷Û³X,Zôǽr)É®*£±ô?‘áòôôTqq±¾úú[k¸&I™™™úmÎïúéç™N«WqYÀ&I{öîÓ¸ç'œ1d;[¸V×aONNn•ç:,IÊÎÉу£±†lçB¸&•ÎVó÷ó³þ3™LÖ0%<,L11Mäâ*Kõì‘$Iš·`¡2³²*œ/,,ÔܹóÞïž½û$I��U^³jõ¥žü.”WRR¢M›ÿ–$…‡Û.ýYöyL­r²Nš­Ù AõêÙ½´�™³*½fÉÒå’¤àà ÅÆÆH’ÒŽSII‰ÜÝÝuõUƒ�Rõ‘Ë–ˆ,S²�{ö)ÅÅÅÚ,¹kwŠB‚ƒëM¸&IÛwìTÇÄÊg/=0r„vìØ©ä;­![bb-^²Ôz�½áÚ™=GÛ¸i³FŒm}ïîî.???µmÓZ7ß4L×\5Xú]¤û|H»v§ÔY]§3 Š�i*IÚPn™ÅÓmÝ–\‹>Œj—ÐVÍâã$//O FJR…Y–åmKÞ^å¹ãéÇ%I xØ�‹�‘$mظ©Êïum>Ï™ÄÄ4•···$éÉÇ©´ƒÁ`}¬�;w)++[S~˜®®ª‡G= KД¦kÑKTTTä”Z¨\°IU‡l¯¿ù¶î¾ó6µnÕR’ëÃ5IÊÉÉ©òœ¯É¤·Þ|U£F?j Ùj®I¥�ž«+==]‹—,ÕŠ•+õÁ»ÿQ‹Íõðè5rÔÃ.«Ëǧ¡uf]ZÚ±*¯;ž‘Q£ö/¹x€î¿÷nÕl¶^ffæY¯1È`óÞÏÏOR鬰3µk6[d4ª¼¦&‚O††’Ô¢y³³^ß AëëwßûPSSuÇ­ÿRÛ6­Õ¶Mkeffjæ/³õ픩:~¼fc@}V/6©ò�í­×_–Tº´^}×$iñ’¥êÝ«G•çOÙÊÔtYÈò�+ë癳ôèã”Ø¡�L *'·ú³ëÜÝ÷U+7™JùU^WRRbwÛ—\<@Ï>õ„$é—Y³5sÖl¥ìÙ£ÜÜ\™ÍuLì ·ß|õŒmԤ߲�T¶÷YUÌæ�ŽýÙ–ÍÆ³X,êÛÿR™Íæjßk±X4múÏúeÖoêQ_ ¾b�Ú%´Õð›†éš«ëåWßÔïó8´^\Í¥{°�îô=Ù¤ú®IÒâ%ËÎzMYÈÖ1±ƒ|M&=U‹=×Ö­[_£ûœ!ýøqë뀻î-›¡å¹¹y2›-g­£aÆv·}Çm·H’æÌ�§‰/¿¦�›6+;;ÇÚŸ‡‡s2éì“3#Ïôy<==T–9v,]Ré2�á5j£  @³fÏш‘£uÇ=÷iíºõòññјgžT|\¬#ËÀåêUÀ&� ÙvìÜ¥ÜÜ\mÚ\Â5©4Y»nÃY¯ó5™ôö›¯ê×™Ó5¨†áÚÚulfÁ¹Z£èhë댌SË æççK’ü«‡Z¶lî°:Ìf³öîÝ+IjÓºU•וíkV]^^^ŠŽŠ’$-XøG¥×”�w´Ý'÷´säç)cQéïÆPÅÊ’{÷íSaa¡$©[×.5꣼ääíýÈJÞ¾CF£Q½zv?­ “¿cÇ®t @�©w›T²=õÌ8½ÿá'3þùz®•™0é•:égòg_ÔI?Õááá¡+_.IJÙ³×fyÈ£ii’¤ðð0………V¸×ÍÍMW\v©CëY¾r•$éÒ‹ÊÛÛ»Ây£Ñ¨K/hW›EEEÖ™jžžžλ»»kðƒjPíÙ-_QúyZ·j©V-[TzÍ Ë.©QÛÙÙ¥³ãÂÂÂ*=Ÿ››§eËWJ’n¹éùùùÖ¨ŸòJJJtøÈ‘JÏe�¬'¼Šz¨ïêeÀ&I‡�ÑôŸfèØ±ôz®IRê¡Cš2ušSûX»nƒÖÖƒå!=<<Ô¾]‚^™ô‚E—ÎÞúêëom®Yóç_*..–›››žù÷ã6![£FÑšôâsŠ.7ûÍ~˜ö“òóó¤‰/ŽWDø©¥ ÃBC5ö™+¦i»Ú,))ÑÖmÛ$I· ¿Aa¡§>G|\¬^{y¢š4nä˜pš«VkÇÎ]2 zá¹1j—ÐÖzÎÇÇG· ¿QW ¾ÂÚcçÎ]’¤n];+±C{ëñ X_¿ÿÑ':qâ„ÂÂBõßÿ¼¡n]:[÷f3�Š��Ó�·ßªQÜg½§Q£h=þÈhuhßÎféJ£Ñ¨‹öWR×®’¤¿ÖÚ~�Ëê¹æêÁ6ß»?®àœ ¥Î“?ûR‰‰‰jÞ,Îámoß±KO=3ÖáížMÛ6môûìÖ÷ƒÁf&—ÙlÑ—ÿûZ³›ks_VV¶>øh²îq�:uLÔ´ï¿Öñãrww—¯¯If³Y“^~UO<ö°5´©­C‡ëù /iܳO«s§Žšòí—J;vLnF£‚‚‚TPP 'Ÿ£—'½`W»~ü©^e¢âãã4åÛ/•šzH~~~òóóUvvŽî{à!½óÖkƒÌf³ÆŒ{Ao½ñ²"ÂÃõÞ;o*3+K  ’›››Þ}ïC ì‘Z´°o¹Íßç-Ð-ÃoTxx˜Þyë59zTînnZ±j�u6æþýôô˜ñ¥ÁdLS½öÊD•””èD~¾|¼½e4–fñËV¬´¶Ûà䬯+_®¢¢">rTfs‰B‚ƒåãã#Iš:íGmÜ´Ù¦žï¦ü ¾}z):*JS¾ùRGަÉ×ÔPÿyç=Íš=§6�€:Qog°ÕwÙ99zpô#ÊÉÉ=ûÅvÈÉÉÕÄI/+;'Ç¡íV‡Ñh�———õŸ§§§òòò´oß~ýôóLÝ3b¤>úä³Jïýæ»)ú÷ÓcµjõŸÊÌÌ”ÉdR^^ž~Ÿ·@wß;R³fÏÑ�ƒZï¢?–èÎ{Fhîïó•ž~\A��’Á _gÏÑ¿n¿GËV¬´._Y]kþüK#G=¢•«V+/ï„"##TTT¤¹¿Ï×Ý÷Þ¯äí;”¼Ý9ûâíÝ·O·Ýy¯¾ýnªö8(o5ôi¨?ÿZ§‘£Ñ7ßMQÊž½v·›“›«‘£Ѽù •™™© À@—”Xg’•YµúOÝrû=úäÓÏ•œ¼]¹¹yòñöVÞ‰JNޮϾøJïþ÷ëõûöï×ó^Ò²+•™™¥ð°0EFD('7W‹þX¢Çž|ZoþçÝ õlù{«zôI­[¿A ÐñãJ=tØþ‡€ šµîPí5çüüœYË9)2"B^ï�™lÛwìÒÄI/+y‡sÔž[Phĸê^ìéååÄRÎM999š?¡<4PÛ6­kÜÎÚuôèãÿf@=Ç 6ê˜ØAwÜö/uLl_í{Ö®Û ÉŸ}¡µëÖ;±28 ›DFD¨w¯êÝ«§"#Ân=—““«í;vjñ’¥Z·n=ËAœcØ;]]p.!`ì@ÀØ�€ °`6Àl€ì Ø,³³êÎ vl%%l8¿Ù°9«àœ`WÀVTDÀ€ó›}{°™Í*,(pV-@½gWÀ&Iùù'd.)qF-@½gwÀ&I'NäÉb±8º Þ«QÀVRR¢¼Üf²à¼S£€M* Ùrr²Ù“ ç÷Ú6�ŸB…òðð�»»‡ÜÜŒ2jœÛõZ­6I²˜Í*,(`6þñ˜jØ�€ °`6Àl€Ø;°v `ì@ÀØ�€ °`6Àl€Ø;°v `ì@ÀØ�€ °`6Àl€Ø;°v `ì@ÀØ�€ °`6Àl€Ø;°vpwuÿd¾~~ ‹PPp°ƒ‚äåå-Iúí×™*ÈÏwqu¨ 6'jÖ¼¥7iêê2êL«Ö­õ‹lŽ•””(33S;¶o×ì_Õ† ë]T]ý`2™ôþ‡Él6ëÿî¹['òò\]’¾ùî{yxxhè�kÚîeƒéλîÖ�Ó§é«/¿thÛåÅÄÆêÕ×^×Ö­ë™§žªu{Õ£-Zh¤—´yóf�}ö™Z÷[^^^úêëo*¿õ–›•››[guôéÛWŽ­¹s~Óï¿ï´~œù;ªOã  þ"`s¢ÌŒ �8‘§ôcÇ”•™¡‹/»ÂÕ%Õ‰’’mÙ¼YRéþ£5R×nÝÔµ[7}ûÍ7š:å{Wè:ƒ.¿B^^^úaêÔz®Ù«I“&zýÍ·´kçN=þØ£®.Ç)ÎÅ1*..Ö÷ß}g}ÕUWÉÓËË…9×¹8FþYØœh×ÎíÖ×F77VR· 4~ÜXëû èλîRÿ5솴jå íÝ»×…º†———]~¹ 4sæ W—cõÅçŸÉÍxþ|?ÏÄž1:räˆ>›^S§M·9öÌÓOiëßWÚF“&Mª5FgÚ·­cÇŽzúÙ1Z½j•^š4±Ò~¢¢£uë­·©M›6’Á ääd}÷Í×JNN®ôúòª3FíÛwИqãlŽ�m¯®O?ÿB¾¾¾~ã ºlÐ õ0P!!!ÊÌÌÐÜ9s4í‡d±X*½×ËËK—^6HIÝ»+:*JF£QGŽÑšÕk4û×YµžeUÓçííã£ë¯¦î=zÈßß_GŽÑÌ3TP�ÆþÂÃÃuÍ�kÕ¾CéĉÚ²e³¦|ÿ}µþcÏï($$TW^u•ªÂÂB0²ÞìÏÔ¯ÿhÞïs•žî¸¥çºtíªÇBF£QÉÉÉ:v,M­ZµÖ¸çžWƒ *½Çl6Ûì×5ôºëd4«ìcOÊëõþþþºäÒKuüøqÍ�3Çæº´£i•Þ_Wcäï _œ ‚ÂB­[¿N¡¡aêСƒÚ¶m«_x^7l8ãýգÇYŸEpp°úPíúîºûõèÑC;vîTNv¶š5o®o®ââbýôã�® ѳcÇ)::ZyyyÚºu«òóó©k† ‘›»›¾øì³j÷ï(?þ9ÅÅÇ+##C®Y£€Àýß½÷ž1Èlß¾ƒòIyyyéàÁƒúëÏ?¢nÝ’Ô©Óšðâ #Ij×¾½ü yûø(--Mk×þ%ƒ Š�‹Ó�wÝ­#GŽèÏ5k¬××f\kâÆ›†+¾Y3mÙ¼Y)))j›� n¼I±±qzåå—¬×-X0_Ão¾YIÝ{è“�?VÞi¿•°ðpµm› ÌÌL­ZµÒ©5°EÀv[²x±†^w½¢££«¼fÊ÷ßUyÎ M&ÅÆÆÉl6;ôÁIÝ»ëÛo¾ÑÔ)ßK*�Yó℉jÒ¤‰zôè©y¿ÏuX_5åææ¦«¯¹Ff³YÓ§O?û Õäéé©÷Ý/£Ñ¨ÿ¾ûŽæÏ›WzÜËKcÇ�Wddd¥÷Y,›ýº®2äÌÛžíÙ“"©t&Ú%—^ªãéé6mœI]�Qdd¤Öþõ—^~i’ŠŠŠ$�š4â¾û5ò¾2›Í•Þ[Ý1:|ø°õs·hÑ® ¦u›6zhô(9rD’Ô¯ÝwÿH]~Å•l=üˆ¢££µbùr½ûî;6Ad\\œšÆÄT»oGºêꫯíÉÉ?n¬òOÎëÝ»�F=ôP¥÷è‘G•———>üà}Íùí7ë¹.]ºêñ'ŸÔŽÒ}÷þŸÍ ®òª;Fzô±Çåíã£ÿ}õ¥~œ>Ý:CÐ`0¨{�Ê͘¤h¯ IDATɱ¹§6ãZñÍšiü¸±Ú²y³µæ '©[R’’ºw׊åË%I¹99Z¶t‰ú^x‘z÷é£ßf϶i§_¿~2 Z0žJJJœZ3[UÿUÿx‹åŒÚîÝ»´zÕªZõÑ AÅÇ7Óã�?!OOO}ôáÚ¿o_­Ú,ïPjª~˜:ÅúþD^ž~Ÿ[:³ªY³fë§6z÷é£ÐÐP-[ºT‡RSÖnç.]äçç§ämÛ¬áš$äçë«/¿pX?µU—côéäO¬áš$ý2s†<¨°°0%$´«ò>g�QyS¾ûήIÒ‚ùó•��­  `Ú\›�ÐN-[µRvv¶þ{Z¸&•Î,]0¾Sê<›‹úõ—$}ùåÖpM’/þC›OF§»ô²Ajh2iá‚6áš$­^½JË—-SPP�:]pA•ýVwŒ.¹ô25lØP7lÐôiÓl–ß´X,Z¶t©¶nÝZ­Ïê,Kÿa פÒ}ߦL)ý�ôïoîÍ99SôôÙÆƒA^ÔO‹E¿ÏuýÿHœoØÎsK—,Ñ�*=W~A{øøøhê´éš:mº¾þö;½ôÊ+ Ô£�<\aYÁÚÚ–¼­ÂþUG�•$ùúú:´¯š0 ºfȵ²X,š6퇶ݲe+IÒúõë+œÛú÷ßUΪku5FÇŽÓÁƒmŽY,mÚ¸Q’Ô¬yóJïsæ•·u«íþt‹EÇÒJ—Õ<ý9´ïÐA’´bù² ˺’¯¯¯ÂÃÃURR¢m•„T7Tü.JRbb¢$U¹GXò¶m’¤¸¸øJÏÛ3FN>»ßëÁìÕªl<ù�,oÓÆÒå1OÿžnÛºU{÷ìQ\\œbbc­Ç;tHTHHˆ6mܨC‡9·`°Däy®lÛ臶9^›Ùkf³Yÿ]&4lØPMš4QTt´žü÷SzòñÇ”sÚòlµ‘q<£Â±â“3˜ÜÜÜÖOM%%uWtt´Ö¬^­½{ö8´í€€Iªt/*³Ù¬ŒŒ …„„8´Ïš¨«1:^ÅÞ~Ç�—÷÷÷¯ô¼3Ǩ¼ŒŒŠÏ¡l¶�ñ´çP6nõ-8){†™™™•.IXÕþŠ!¡¡’¤?õôÛ÷õ5UzÜž1 >ùì׳gW^eßÕãÇ�K* 1ÝÜÜlžïœ9¿é®»ïÑ€õñGJ’u˹sû?-¨6hé’%zÝõjÔ¨‘õXMg¯IR~~¾Æ>ûŒõ}tt´ž;Nºõ¶Ûôî;ïT»-ƒáÌ“,-–Ê÷Ôª/† ½V’4퇩NëãôÙaeÜÝëÇÏÛQctöïBåÏÁz^•Ÿ¯‹1’Tåþogr–�äTg~Þ5+læÌÊË­zFÞÎ�;*=^“1rå³;›Êj;Ó÷wÑ¢Eºå–©wŸ>úü³Oåéé©Î]º(++K«V:nOKÕW?þ—²X,š:å{ë,6Gì½VÞ�ôî;okì¸ñºð¢~úéǵÿ~ëùséL ww� ÷8¬ŽºÖ±S'ÅÆÆiãÆ�JNNvxûe3¢‚‚‚+œ3�UÎØªÏÊfíTží»\ñ9HR``�$)³’dΣšJ;¹tddd„Sû±÷y—}çüüü+̲’¤   JûIKKS@@€–üñ‡vì¨^µwï^­Y³Ú©}­\±BÏ�¯ë®¿^-Z¶T\\œ6lÜ O?ùD“^~Y’tâÄ ›{]~…""*îíuý°aÖ×G�­4`“¤÷Þ}W™™êÜ¥³úõïo èÖ¬YSë€M’Þ|ãuÝ~ûêÒ¥‹Z¶l©=))zyÒD™Íæ3l™š4i¢n½õ6uîÒE‹Eë×­Ó·ß~£í§íÝU“1òñö¶yFeBCCmŽ/\°À!AÌÑ£Gõø£�è²Aƒ””Ô] íd4uôÈÍøù'ý:kV•÷¦¤¤hâ‹/ê†oTBB;묾?-² Ø$ûŸwQQ‘ÆŽ£aÆ©{�žê–”¤Ã‡ëÃÞWAAA¥›$­_·N�¥ÁW^¥ÄŽÕ!1QÅÅÅ:––¦… ækÕªU:zäˆõúÚüŽÊ÷Õ!1Q�»tQaa¡RSSõÙ§ŸjËæÍÖkëz\%éÿûJ-Z´Pÿ¤´´4ý2s†~œ>½B\^Ù,¾Üœ­\±Â!µ¨C³Öªþk»=öÄêÖ-Io½ñ†/þÃ%5xzzꫯ¿Qzzºþïî»\RC}VÆgöO£gÆŒQbbG�ó¬6oÚtöN3äÚ¡ºiøpÍúåMþäc'T º˜Á8�»»»RvïÖ®�;µté§÷ ââbåääØ¿vèu¥Kî-«z¹¹óU]�ìÇUäçç§ÁƒËb±è·Ù¿ººà¼GÀ8Pqq±¦|ÿ}�õ×¾CÝ?òmONVjêA—(>>^qññ:xð ¦L™Rgµœ+êzŒ`?Æè”¡×]§¨¨hµïÐA¾~~š?ož8àê²€ópÛµk—–.Y¢æ-Z(&6VnnnJKKÓO?þ¨iÓ~Pîi3Ûœ[ºví¦¸øxeeeé—™3õÕ—_¸º$b6À.FWœKØ;°v `ì@ÀØ�€ °`6Àl€Ø;°v `ì@ÀØÁÝÕÿ­n.¯  IÒΟRöÞ½.®èÜàîí£„;ï´¾_ÿÞe))qaEpÆÀ?à �ô—o£Æ’¤Ô•+تÉÝÛKqW^i}¿ñÃTBsÎc\ü“°9‰›››¢¢)"2J�Aòôô”¹¤DYYYÚ·7E{÷¤Èb±¸ºÌsZÜà+•øÀÊOO×ì[n–¹¨ÈÕ%9…_LŒ|ø‘$©(7W3®¹Ú)ýø6n¬�ŸL–$ççëç+׺ÍsmŒ"º%©ÇóÏWznÚÅ묎đXéäï¾Ó¦O>vZ_çÚ@}@Àæ$Íš·TËÖm$IEEEÊÉÎRƒž VPp°""£µzå2™ÍfWzn2¸¹©Åõ×K’¶ÿ0õœ  nnºæ×ÙÖ÷³n¦üôtVäxçú�#¨6'±È¢û÷i÷®:žžn�­®®Ýº+<"BqñÍ´c{²‹+=75é×_>áá*ÌÎÖî™3]]Ž$iîw¸º„z¥ºc”Ÿž^§³ÃÎ$sç­yi’$©�¿¿Úß;ÂÅ9—3Gõi\ÀÑŒ®.àŸjÇödý¹z¥Ò�³Y òè‘ÃÚ¹c»$)úä~]°�Á`P‹aÃ$I;œ®â'\\Nw®ŽÑ‰´4í�7O{çÍÓÁ¥K]]ŽS�«cõ3ØœÄ\RRå¹ÌÌ I’§§W]•ó�Õ«·|›4Qñ‰Úùã�kׯiS%Üu·BÚ·“ÅlÑ‘¿þÔ†÷Þ×ÀÉ“åîU:V¿ßs·²RR¬÷\öõ7ò ©ÐÖÒ§ŸÒáÕ«mŽy˜L °N�dp3êðš?µþÝwl–˜,¿—XÖžý~÷ÝÖsýßÿ@þqq’¤eÏ>«C+WTÚ�›§§ÚÝójtá…2º»ëø¶mÚüéd¥ÿýw¥×—w¶12EEéâÏ>¯ôÞŸ®¸\%……Žw{vŒ¢{÷–$mxÿ=åæªÅ°aj©¼#G´íÿÓž¹s*mÓ`0¨qÿþjzñ%ò�‹“»··òÓÓ•±s‡öΙ«ƒË—IµØ±¦ÏÛÃdR›ݪèÞ½åá뫌äd­ÿïÏÚŸ§¿¿š_½"“ºË'<\³Y¹êà’ÅÚþÃ4ŸÈ;kÕýyøø(þê«Õ³—L�¢e0º)ïÈ¥mÜ ”Y³t<ùÔ,ÜšŒkMt}úi5ê{¡$iãG*+%Emo¿]¾Mšª03SûæÏ×ß_~aíÏ/6V>øP’d1›õëM7Úü^ F£}û�<$I«^|Aû-rH­þ™Ø\ÀËË[’”›—ëâJÎM-o¼A’´{æLfg;¤MßF�Õ÷�7åa2Y�E÷î#ÿØ8ÝÜÒ‡£$�§à6m­ï£{÷–Wp��íÐ~º=;F]»Z߇&&ª÷+¯jñc�ž5dsÆ•™Ô]¡‰‰Ö÷¦¨(]ðØcÊO?¦Ãþis­ÑÃCIcÇÙ|Iò —Ox¸¢zôÔÏW]Yç3¸Œîîê5q’[¶´ NHPŸ×^Õ±Í[ª¼Ï/&F½&½$¯  ›ãþqqò�‹S£~ý´øÑGϺ§_uƨaD„zNzI¦¨(›ã¾�Ë·qc6o¡ù÷ßwÆ~œ-¸m[%Üy— ÆÒ ÙÞ¡¡j1l˜|›4Ñò±c$IY»wëØ–Í nÓV£Q�/ê§í?Lµ¶šØÑ®feéà²euÿAœSØê˜Á`P“˜IÒþ½{\[Ì9(¼KW4k®’ÂB›?�×Vûûï·†k%Ú7ož¼‚ƒÑ-éŒ÷­÷ëì¶„»ï©z”W’ŸoÝßKF£:?ö¸õܺwÞVqî©ÀõÄÑ£•¶áѰ¡üccµkÆ ù5mª�öí%IÁmÚÊ/&¦ÊYoör÷òRD×®:º~� 22Õ£‡ŒrkÐ@íGܧ…>På½Õ£üãǭϽaC%ެº½Ê„&&êèúõÊØ¾]1—^j»˜A—WØî¼Ó&\ËØ¾]i›6•¶Ó¡ƒuvY]‹¹ì2›píø¶­Ê9pP‘ݓ޹s¥÷ÝÝ•4f¬õ{v|ÛVí[°@Fw58P~M›Ê·Qcuzèa-{ö™*û®ÖïÈ`P·gÇœ ×,Z½ZY)»ÕÀä«ðÓK©öãZQ=zêDÚQ¥._®À–­Ø¢…$)²{w…wéªÃ«WI’vÿò‹5˜n2`€Íçn|ÑEÖ×ûæÏ“¹¨Èéu8·°Õ±fÍ[Êß?@™ǵwOŠ«Ë9ç´ºñFIÒžß~;ë �êò Ux§NÖ÷«'NÔÁe¥ûouzøaÅ\zY•÷–ß§«åðág ØÌÅÅÚ;ož$Éàæf°\²¤ÚŸçÏW_Õ�Å‹e0téÿþ'ï�PI’l¬Ã6IÚýËL­}ë-IR£ /R×§ž’$µj¥†Ê=t¨Òûª3FÅ'NXŸ…WP�ÝALæ®]ZòÄ㲘ÍÊÞ¿O�F?$©ô”ça2)öŠÁÖ÷Û§NÕÆ�>´Y²Qß¾2ÛÕ¿#4ºðT¨shÕ*-öY,'$¨ïëoTzOT¯Þ25j$©tVÖ¢‡²Ö¾û—™ºø³Ïåé﯈nÝdŠŠRÎÁƒ•¶S�1 ïÜEÍ›[ß/;F©+N-oéÖ �"’lèÚŽkMççkუt"í¨ŒîîêûÆ›Öà²Ñ…}­Û�E‹ÔaÄ}ò0™äo ¤�îîŠêÙÓÚ^ÊìÙN¯À¹ÏèêÎ'aájÕ¦­ µzå Yj±çÓù(¤];'$ÈRR¢äï¿;û ÕÔº•d0H’ò¶†k’´ã‡iëÇ!,¥._~ò¥EY)§fAº{û8´«òŸ}ÿ¢…6AŒ\|¥÷8kŒNwhåJYÌfI¥ASwÛg’� · $IE99ÚòÙ§öZÛ¿h‘Kf,ùÇŸz†;œnýïÁ±M›t|ÛÖJï »àTœµw¯Â.謈nIŠè–¤à„v:qôˆõ|pÛ„JÛ¨î…uêh}}xõj›pM’J uà�?Îð ëFê²¥:‘V:ãÓ\\¬Ý¿Î²ž ˆof}]RX¨=sNíÑ×dÀIRx×®Ö�Ç““•¹kW]” àÇ ¶:¬.]“d6›µjÅRå±ÿšÝZÞx“$iß‚Ê;|Øaí–Ÿu–½¿Í¹ìýûd±Xd8À¹Zщ6³­Ì……§NW£ÅbQÎÁå(çàë³jà_é}ΣÓdfZ_—”{§�“wh˜õuÖÞ=6׺’ÑÝ]åÂÀœÓ¿wûö+°e« ÷ù”û<�úöU£¾}«ìÃ30°ÒãÕ£ò}eìØQåu®–sÀv–^î�Sß[OÛïéî_fªÙ�!’¤Æýúkó'ŸØ,¹ç7f¯¨f°Õ?%õè)ƒÑ¨5+—+ýØ1W—tÎ hÖ¼t_*‹EÛ¾ýƱ�Êý NŸUh±T<æJuUKeŸÛl±=§ŽQÅ«wYù¼­ ãéNŸÍj±˜kݦѽâÿ?aו{vçÖlÛS…Ÿ^wö¾}JÛ¸Q’䢈¤$E&u—trïÅ ê®Lç4f°9YÆ&uïÑ[îîúkÍ*>\ù¾U8³V7•κ9¸t©²÷îuhÛ…™Ö× £¢lÎ5ŒŠ’Áè„Úé�Å©ö� lΜ>«§2£Q>‘‘Ê-·‡WÃÈHëëÂ̬ ÷8sŒjêDZšõµo“&2zxT{9HK‰mÈåÖ ÁfÀÙ÷¼ÍÅÅ*Ê˳Îb3EEÙÌ&3EGWÚK~¹pþï/¿Ðß_~yÆÏp:{ÆèÄÑSÏ. Y³3\éZe{ÒUö¾0«â÷t÷Ì i×N’ÔqÔh¹yzJ’.]¢¢œ'V àŸ„lNäíí£î½úÈÓËKë×þ©û÷¹º¤z£ÿûhàäÉ8y²ZÝ4üŒ×ú6i¢¨ž=%I[¿ùÚ®~:=ô°µŸîÏ=_é5Ç·m³¾6EE)¬Ó©}®â®lWÕe1›e))±¾÷ðièÐö‹óò¬¯}BC­AN`‹ò ®VqƒO}öȤ$y‡†ZßgîÚismmÆÈ™ŽmÚd]R³�¯¯ÚüëVë~{e»t‘Ñã½E9Ù6A¨o“¦UöS“ç�¹óÔ3Œ-÷= hÖ\Á­ÛTzÏÑõ묯÷ë_é¾{Fww58°Âq{ÇèÈÚµÖ×]»*¢kW›ó£Q‘IIgmÇ1ƒY¯'O¶î�v&Q=zÈ'<\’dôðPì僬çÊ?ã2/VáÉ%FË/›ò+ËC¨>f°9‰§§—º÷ê-mX¿V{÷¤¸º¤zÅ·qck¨Qþ�Ü•iyÃ�’Á ÃkÖ(cûv»úñ •o£Æ’dh•—sð Ò·lQP›ÒP£Û3Ïj÷¬_ä¬&TÙvXÇŽ6µ—ÉBåéçg}Ÿº|¹ŠÊ…0’”{ø°L'gÌu=Z{çýnÝS-uÅ åÖ|Ÿ¾¬={¬{Ç=<Ô륗ulóf5ºðÂj·ÑüÚ¡j©‚Œãjܯ¿õøñmÛ”{Èv&¦½cÔ¸_?ë~iî mÃÅF]$ËÉP¬¤°P/®vͧ+ÌÊRʬYŠ»òJIR‹aÚ˜¨c[¶H³‚Û&(°eKý|Õ•f¶çç+{ß>ù6i"IêüÄÚ=s†u–SúÖ­Ê9¹ßWMž÷þ… ­3©¢{÷V¯I“”³ÿ@é=Uìù·áBµþ×­ò “):Zú©ö/Z¤G�Èèá!¿¦1 ïÒE jïܹ6÷Ú;F‡W­Tæ®]ò�‹“$õxþZµJY{RäѰ¡Â;wQaV–RW¬°ÞSÛqõôó³þ^%ÉàævÖ:Ý<=uá[ÿѡիؼ…µ^IÚ¿ha…ëÍÅÅÚ3gŽš_w�õXnjªŽnXÖ¾  ›“´jÓV&“¯JJJÔ¸qS5n\ùì—¥‹Êl®ý~KÿT>ááj|ÑE’¤mNœµî�·Õçõ7äîå%“I-®&IÊ;|X^AA§f8•[ٱŠ7*¬cÇJÛkqÝõ6ïçÞyG…€mßüùj}óÍ’¤�öíÒ¾½õÜÿ³w×ÑQ\mÀŸÍF6î !J܉àÁÝŠÓ¯Ô…z�Z´X‘z¡un¥ÅÝ � ñ‹'Äu“ýþÙ²l6ÉF[x~çpÌÜ{çÎÜ�%™wÞ{¿øB‹l•……H;u Ö½z ��aè쌲œlß½+7­Þ£ÄååÈ»q]šñT§F,Fôúu2Ûš3Fþ³ç(œzÓïÝ÷¤¯¸¿E6ˆùþ;ètê$ÍL¬»M‘¸s'|Þ| gk ¯×fJ÷E}ñ¹4ÀÖœë�ú×~t2D:ý¢™¯Ì|ýP]Q�ÌK—`îç'W§º²çÌGèÒeAdd‡1cäÊIùNiÎI$\X²=V¬¬Í`ѽ;,ºw—–yt Æö×:igÏÀ²{º ,³=ãÂydDDÔ['åÏ}p?^ȼuàÀ¿k­E"""""""""ú×ã‘mDåÁCf¡PC##…eªP-牓  ‘{ý:rbbÚì8ù‰‰8ñö[ÈŒŒ„¸¬ â²RdDDàôûsdÆH\^ÖjÇŒûãw\߸II—•µúþËk×àÖÁƒ¨*.†¸¼™—.áÔìÙ ¬#&ëü¢ÅHýë/T¢º¢9×bpzölä^¿.S®½Æ¨¹ª+*pff r¢£QU\Œ±¥YYȈˆÀ…%K ./¯·nÊŸûpùÓµ(HNnôº){½kÄbœž3)ûÿDE~>ª++‘{ã:NÍž…’�»ú$%áðK/âæ¯¿â~|<ªJKQ#£ý+‰ŒŒ0ø×ß ¢¦†³ÎS˜�ÒTTU!©®†ä‘ —‰»z­]  6{hïèQÒ5½¨}Ljšçq£ÀyóЩwµŠ [·*UßvÀ@øÍšÈŒŒÀ™yóZ»‹DDDDDDDDDô˜ã‘ô¯¥ij†¸Í›Q]QÑæAý®]ºt2/_FYVªJK ef†N}ûIËdFF2¸öˆö#jŽQ-Cggh™›CÛÜÎS¦H·'lÛÖ�½"""""""""¢ÿ*Øè_ë~\,îÇŶÛñÔõõ¥ëT=ª²°×~ø¾Ýúò_ÑÞcDÊãÕr3�û…ÉlK;}YQQÔ#"""""""""ú/c€�@iv6’÷î�Q·nÐ45ƒºŽjÄb”d¤#ëÒ%$lÛ†²œœŽî&µ‚Šü|Ü=q‚As"""""""""j6®ÁFDDDDDDDDDDDD¤•ŽîÑ lDDDDDDDDDDDDDJ`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °)�6"""""""""""""%0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘`#""""""""""""RlDDDDDDDDDDDDDJ`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °)�6"""""""""""""%0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘T;º�+MM-ØÚÙÁÐÐÚ::‰D¨©©AQQ!îݽƒÔä$ÔÔÔtt7ÿõÞ›5AÁÁXºd1¢¢¢Úì8Ÿ¬Z�®öö²ÛV®@Ä… ë<ýÌ39r”̶?÷íÃÆ ?¶I[ÓÒeËáìâ‚ù~ˆ7®wtwZÌËÛÍ_€k×b°pþ|éö.vvX½f-bcoâùs›Õö˜±c1uÚtl Ç–ðÍ­ÕåF)£9À@,^¸ÑÑWÛ­?M1dèP<÷ü صs~ûõ׎îο†¾¾>&MžC]]“'N@UU•L9�@€þbРA°²¶FEEboÞDxøf¤¦¤Èµkai‰/¿ú•ÈÎÎÆÅ‹‘ØŽÊÊÊö:5""""""""¢'lmDßÀNÎÝ ‘HPYQ�â¢B¨ª©ÁÐІ†F°¶î„³§O¡ºZÜÑ]%‡„áE#@pH0:w¶i´ÎÕ+WP^V°wp€ŸŸ_›ö±µ¸¹»ÃÙű±7‹àŒ7°cÛöîIëxÇèIöêk3áçï�´{÷pðÀß(--«÷‹ç_xƒ†X,ÆÍ7 ¯¯�€À@xûø`ñ¢…¸yã†Lùâ¢"lÛºÚ:ÚèÞ=£ÇŒ…ŠŠ ~ùùçö:5""""""""¢'lm¤¸¸‘Î!';K&KAWW݃Cahd G'gÄÞäÃóƒCJÿnÝɺɶ«W®ôŸ °�ÿx£œ]\àææ†ÄÄÄ6É芾�ªÊ ˆ��kõ¶yÜÆèI& áíã‰D‚çÍEaaa½å<=½0hð`”””`ÞÜp÷ÎÿdP¾þÆ›xýµWQ]]-­S\\ŒðÍ›§OžÄ²+áëçÏQ;àlm¤¸¨éi÷ä¦+**D|ÜM€¹…EGt�ž`ðôôBjJ ._¾ÔÑÝiuÁ¨íÛ¶¶IûII‰Ø·o/âããÛ¤ýG=Žcô$ÓÕÕ…P(DAA�Âà 6 °{×.ip ví܉´´4˜™™! 0PaýÔÔT€¡¡aëtœˆˆˆˆˆˆˆˆˆÄ ¶P#‘¨]oçI£©¥…!C†"´G(LMÍ TQÁýü|$ÄÇãÐÁƒ N‡ˆ±cÇÁÆÖUUUˆŒˆÀÆ ?¢´´´Þò®nn1b$œœ�¡££ƒû÷óp1ò"¶n GAAA[�b“ tîÜPRR‚ÜÜÜ6?æ¸ñO¶oßVïþ†Ö¼›6}:F�‹Ÿ6lÀ¾}{eö5w\ß|ëmôìÕ kV­Bbb&Mž O/ohkk#''Ç�Ŏ튳¸ºØÙÁ××wîÜÆÅÈÈÏÝÊÚÿûß3puuÄÇÇ#|ÓõÎ&O™* ÜÕil ¶�?ÿ]]]L�< C†EXÿ011AAA><ˆÛ·CòàÞoHccTG "Àˆ‘#1hÐ`˜˜š"77§NžÀömÛäû&&&èѳ|||`ai }}}”••!9) ‡Äùsçê?†@€={bРÁ°°´„¶¶6 pçömœ={ÇŽUØ?L™: Ý\]¡¦¦†ØØ›Øøãܹs»ÑkЖ4µ´0bÄHÃÂÂ555HMIÁÞ½{páüùV?žP(ÔÔT7XÆÃÓqA¶‰‘5z4|||ŽUݺkªŽGDDDDDDDDDm‹¶v¦­£'g@Nvv÷¦} …B,^²vv]‘——‡«W¯ ¦¦ææ Eee¥Â@Lh�žèÕ»7RSS'''ôí×úúXöñÇråë¦U“H$HJLD|\:ÛØ`ð�!ðó÷ǼÞG^^^[Ÿrƒ444°ö³Ï§NžÄçŸ}Ú¦ÇëÜÙþH»wOáCúæhɸÖ126²çWÂÀÀ÷îÝCYi)Ì-,Ü`€m\ÝÚk�¯ôõ °té2TTVâÊÕ+055ƒ——ÜÜܰôã%ˆ‰Ž–)-&Z:_·nݤÁ�¦xþ…‚Ĥ$ÁÁÑ“§L…X,Æî]»¬«ÌMœ8 ŽŽ¸~ý:nß¾ 7wwŒj�œññâE2×#$´¦MŸŽ¢ÂB¤¤¦ .6úúúpsw‡—·7öìÞUï´‚Ï=ÿ‚Šòr\»v %%%015�‹‹ ,­¬Ø,,,±tù äç#!!vv]áéé…ù â�×g¢LAP¼­™˜˜`Á¢Å°´´D~~>bbb ‰àää„Y³ç`Ó¿cû¶†›mÁÜ‹ŸwïžÜþ[·R¶¶¶íÜ3"""""""""R„¶6¦"¢{p(@C¤]äæd#.öFGw¯]ùúúÁή+’“’0÷ƒ÷!‹¥ûŒŒŒaee¥°n�ž=±dñ"i ¤S§NXµf-|}ý`ii‰ôôtiYooL�6%ÅÅX¶l)âbcÔfãL›þ4F��gŸ{«W}ÒFgúï4vü8ìܹ£I™TMÕ’q­3fì8¤¦¦`ά¯¤�OMMMøû(¬cee… à`dffâÌéÓ ¶oii‰¨Ë—ñÉÊÒì®á#Fâ™3ðÊ«¯a櫯 ¦¦FZ>&&111ú6V©[7WW¼ýÖ›ÈÊÊô ë¯Íİáà °)3FöX²h¡´ŸúúúXºl9¼¼¼Ð·_?=rDZöVj /\ˆ˜˜h™vÍḬ̀â“U9j4N?! äµ/ 4ååxó�ב““#ݧ!ÁÛË[aß‚‚ƒ±yÓ&lÛº@mÖØÒeËaccƒ��P9|¨Ásk+ï¼û,--qìèQ|ÿÝ·Ò¬/+kk,\´“&OÁÅÈ‹2ס¥ÔÔÔb±â 6ccc@~þ}H$XZZâù_Â�;·ñóÆ�¸ÿàž061iðX555PUSƒ@ hÕ{œˆˆˆˆˆˆˆˆˆäq ¶6¦"ÀÔÔ &¦¦ÐÕÕƒ@ Àí[©8wö´Ü4n�;ƒk%''Ëa //×®Å(¬{òÄ ™,£»wïJ×§²wp�);þ©Ú)ö~úi£4¸ÔNµöÇï¿!77݃‚ ££Ó²ú177Ghhäädã䉭ÚvKÆµŽªª*Ö®^-“UXVV†S§N*¬3flm0j×Î2Á1E6nøQæžûsß^éÚVîî�Öoª­ááÒà;zEEE022np},eÇèìÙ3Òà |sí–ýÂÂdÊ^½zÑÑWå‚.YYY8yâ8ÀÕÍUfŸ¾¾>TTT�wÿ¾Lp *ÊËqá‚âé3ÒÓeÖÄ++-ÅáCÔ®1×<<=áäìŒôôt|»~�4¸i÷îaû¶­r×®¥êÖÚlhý5‘H¨¨¨íÓ !Càåå…áÃGÀÆÆ2å)((€P(„±qÃ�8"""""""""j9f°µ1±XŒ=;·A @SK ÖÖ�àäâ CC#œ?wºÃ¦Jë©©)€ÐÐP\¿~ —.^T¸~Ú£bcoÊmË~0Ŧ®®®t›H$‚“³3jjjê]O©ººÉII066†]×®rS¶§òòrŒ;¦]Ž5fì8¨¨¨`÷®]Ò©[KKƵÎñãÇ”ªcbbŠ^½{#//Ç�k´|nn.ÒÒÒd¶I$\‹‰�••}U©>+òègU"‘ 7'ºººÐÕÕÅýû÷ë­§ì]‹‘\ÆÄÔ~žííêÍbêÒ¥ 졯¯UÕÚ¯ÿNÖÔÓÓ—)›•™‰ÒÒRXZZbÂĉ8røp“× Œ‹�“;v}÷k{òz�q!€¸¸8€½½}«OMM ÖÖÖ˜;wìÀè1cðæ[oC"‘àÞ½{Hˆ�ÇéÓ§põÊ…uóïçËm?ÈFª¥ÛŒŒ�¡¢R›˜ùËo¿7ØŸ'%ƒÍÈÈ}úöEAAŽ>Üêí·d\ë¤?üjÌè1c  ±wÏî&e‚ÞW°ÞÞýûµÛõõõëÝßùùòŸÕº>ª…rû€æ�Q}kæççC"‘@MM ZZZ())˜™›ãí·ß�£““ÂöênuÄb1¾ùú+¼öÚLL˜8 &NBnn.’“’�Ç�+ Þ4x¿*¸Íѽ{úõï/·ý‹Ï>•ž{SSSÀÈ‘£0rä(…m¶Æ÷BXÿxåÕWÔ^ÇMüŽ�;v(,_^^ÐÐPÄDGã™§§K÷k¨×n/�ɦÈ�?ü€ÒÒ2 1�Ý»–.YŒ¨¨¨æŸ Õ‹¶pïîxùøÁÔÔ "*<\}üþÛ¯8rø|}ýÐÍÕnîîèÛ¯úö뇭[¶ |ó¦zëI$�Oø°’’ü¹o_ƒeîݽ«T›ÿU#G�‚ªª*öîÙ#3-ž²Å3Ê6w\ë(ž>ïQëßEEE8xð`“ê4¶•­·^US¦«|T³Æ¨±sz°_EEsç}ˆN�:áÔ©“Ø»gÒÓÓ¥Ù³£ÇŒÁ´éOC �oãü¹s¸~í||}áææW7w" 0½z÷Æ¢ ê½¶ÊÞ¯Íena???¹íuëžÕ'⤦¦*Ü_TÔôÏ¢")ÉIصsllmáëë‡Aƒãü¹s¸wï^½åë2 ëÍ<¬›†5÷‘©:ÕÕÞýÂÂPSSƒóçÏ!3#é->"""""""""’Ç[�H$Ò¨š"Í'*ÀØ¿ÿOìßÿ§tÍ£—^~ãÆ�Ǿ}{QR\Üì¶órs!‘H ¢¢‚­[ ¬Ô«9UZ/>Óªtõô0 ÿ”””àÀ�¿-_]S›‘¤ª* 004h°n[ŽëÆ� 555lß¶­É÷Ž‘±q½Û �õd�µeǨN}çd``�@€ÊÊJ”••¨]ó¬S§NHMMÅŸ}&wO˜›[4xœ¢¢"œ‰‰ Ò@š¾~m`43#C.¸¦¦¦__¥ú‹sgÏÌÍÍ•ªÛ‘¢¯ÖNUÚ½{P»72¢6ikk«°Luuµt=Ⱥ©ë¢._nðX6¶¶�H$¸tébKºLDDDDDDDDDMÀ[ñðô†•u'¹õ†ŒŒŒáëWû°477å²LžÞÞ>ððð€à‘¹èºví +++ˆÅbdeeµø8;¶o¼:ó5¸ººÉí·±±ÁS&(¬çA–HPP°\_«ãéåM-­&ÕÑÐÐÀê5k±zÍZL�6­Iu”¡©¥…ÁC† ¢¼þÙðt™u’““aúCSSSº}ÌØ±°²²ª·N{�+ :ššš8ð÷_JgÄ=3ãY™uÆkkkdddàúõk­Ò?e5gŒê„„„Ê|¾utt0qâ$ÀÑ#G¤ÛÓÓk×·sww— œ …B<3ãY˜(~ZYY¡WïÞP°þWmxûøÒLyøo�Ä„89;ã…_‚H$’Ù¯!¡wï>ð¨'pÙ%%µŸS-míËíßÿ'`ôè1°²¶–n1r¬­­‘���ÈȈÛÐÒÒBeEÄbq {MDDDDDDDDD�á‘mÄÐØvö�H$(..BµX ‘¦–ô¡nyY®\~²² 0iò 11ÅE…042‚››;„B!þøý7”*‘Á£È¥K—ðÇï¿cò”)XüñǸu+iiiªÑ¥K˜™›#//[·l©·þ‰ãÇ1nüSðñõÅÊU«qçö-H$@dd.œ¯Úµ´´4œ;wÁÁ!øô³ÏpóæMT‹«‘––& øµ·!C†@[[ûöîAQaÓÖ•:wö,&O™ [Û.øòëo�šš33sàì™3 •«Ó^ãª!aè°á¨ªªÂ¾½{•ª›‘ž'gg|ñåWˆ��‡‰© \\ºA,cÝ7_ËdvÙÚvA÷ ²œºuë 6;l&I·GD\@jJJ‹Î©9cT')) -BLL4ÊJËàîá]]]DEEáÄñãÒrwïÞýç³ùùˆ¾z•èÖ­tuõpüØ1ôéÛW®}=}}¼ñæ[x饗‘�˜€ÜÜ\hijÁÍÝZZZˆŠŠÂ•+WZtþíI"‘`ÍêU˜¿p Œ�ÐP¤¦¤   ÆÆÆ°wp€ºº:Ö}ó ӪǕ†ƒõW¯\ÁáC‡ÐÀ¬Yû)®_¿==}tíÚb±_}ùgDDDDDDDDDÿ" °µ‘›×c`aa#ccˆDšPÓÖAMM òó‘‘‘†äÄDTUUvt7ÛÕ¹³g¡®®777ØÛÛC[[ù¸rå öíÝ#�"­5ìØ¾ 7®_ÃÐaÃáÒ­;£´¤ÙÙÙ8wî.œ?§°nee%/ZˆgfÌ€›«ºví ÈÍÍU`€o¾þÅEÅ BÏž½±±7;$À¦®®ŽaÃG@,cÏî=M®WZZŠÅ‹bÆŒgáìâ''g\¿~ +—/Cß~ýê­Ó^ã:hà èêêâï¿þB¾’k¦åäcÅŠåøßÿž�@$ ®^¹‚Í›7!!>^¦¬m[L˜8Q® 777¸¹ý“1–��Õ¢[sǨNøæM°³³Ã€�ƒ`llŒ¼Ü\üý×_ر}›ÜT�Ÿ­]‹„á èÓ·/¼}|PQ^Ž7o |Ó&xzzõØîܹƒ_ùîžèܹœ�]PRR‚;·oãÈ‘Ã8qüxóÖ8ì@ÙÙÙ˜ýÞ»2t(‚‚‚áàèUUUäååáê•+¸x1çÏ)þnhkß®_‡””d 8nn¨ÀÅÈHl ß,]Ó�ˆˆˆˆˆˆˆˆˆþݼþ[OH‰¨QC‡ óÏ=�Çaýºo:º;-¦¦¦†oÖ ===Ì|õdggwt—Zìq#ªŸ¾¾>~Üø ðÜŒgÚì8ªªªØ¼e+ŠŠŠ0ãO·Ùqˆˆˆˆˆˆˆˆˆ¨3؈C•ØŽcG�4^ø?ÀØÄ‡DVVæc\¿1¢ú¡ªª zzz000P:û²©ìdÚÞÏËk“ö‰ˆˆˆˆˆˆˆˆH3؈ˆˆÚл³f!88éé鈺|eeeؾÕÕÕ-jWGG#FŽ‚ŽŽ»w‡¡¡!¶m݂͛6µRωˆˆˆˆˆˆˆˆHf°µ¡ïÖ¯GaA!¼¼¼0`à@¨©©aÛÖ--°éêbÜøñ¨¨¨@VV&Ž9‚íÛÚÍG""""""""¢'3؈ˆˆˆˆˆˆˆˆˆˆˆˆ” ÒÑ """"""""""""ú/a€�ˆˆˆˆˆˆˆˆˆˆˆˆH °)�6"""""""""""""%0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘`#""""""""""""RlDDDDDDDDDDDDDJ`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °)�6"""""""""""""%0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘T;ºO--môí?B¡Y™™8öTGw‰ˆˆˆˆˆˆˆˆˆˆˆˆ”Ä ¶väåã ¡PØÑÝ """""""""""¢`€­�t²±…©™9ÒîÝíè®Q 0ÀÖÔÕ5àîቻwn#7'§£»CDDDDDDDDDDDD-À5ØÚ�»§T*¸~-VV�:º;J  Oß~ ƒ�­-ÔÔÔ�‘‘ŽÇ�cßÞ½‹Å2åß›5AÁÁXºd1TÕÔ0vì8ØØÚ¢ªª ‘ظáG”––JË{xzbÁÂEˆ½yΛ[oÞ|ûmôìÙ ß|ýŽ9"·_SS¦¦¦€Ü¼<”·â """"""""""¢ÿ:f°µ13s têlƒØ›7PQ^ÞÑÝéPB¡sÞÿ¯Íœ ;;;¤$'#&&ú˜6ýi¼?w.TTêÿH†öè‰Y³ç@¨ªŠøøx¨©©¡o¿~xë�wdÊ]‹‰Áýû÷áìâ¹vÔÕÕˆªª*œ?w®Þc¹º¹aígŸcígŸ#((¸å'NDDDDDDDDDDD�f°µ!¡PžÞ>(,(@JrbGw§ÃMš<þHJJĪ•+‘ó`ºL---Ìšó>¼½}0hð`üµ¿\Ý={bÉâEˆ‰ŽtêÔ «Ö¬…¯¯,--‘žž�H$8sæ4†��Ðس{—L;~þþ‰D¸pþ¼LæQS1ƒ­ usuƒ––6¢¯FA"‘ttw:”¦–†‰D‚O׬‘× ´´?~ÿ ¬ÿ€zëŸnß¾�¨Ë—pîìÙV=æÉ“'ááé 8uêÉ™’“ˆˆˆˆˆˆˆˆˆˆˆÚŽÀ¡›—¤£;ADDDDDDDDDDDDô_Á5؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘`#""""""""""""RlDDDDDDDDDDDDDJ`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °)�6"""""""""""""%0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘`#""""""""""""RlDDDDDDDDDDDDDJ`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °)�6"""""""""""""%0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆ”À‘`#""""""""""""R‚jGwàq¥ªªŠ¡#F7XfÏÎmíÔ›'Çó/¼ˆÁC†~ûõìÚ¹Sf¯Þ½ñÆ›o"#"°rÅr¹6ÂúÀ+¯¾ ر};þøý·�)Ð/¬?zõî [[[ˆD"äåæâêÕ+Ø»w/ÒîÝ“–566Æ·ßÿÐ`{W®DáãÅ‹ëÝghhˆ‘£FÃ×Ï&&&¨ªªBVf&"""pøÐAäçç7ØvC<=½0áBÀ™Ó§ñéÚ52ûmll°ö³Ï‘ŸŸ�çŸ�!ÝþÊ«¯!¬ÿÛžûþÄÇǼ¼½ñÑü(--ÅÌW_Aaa¡\ùÉS¦bÜøñˆ�½‰�æÍƒD"iöyÕ±·wÀ°áÃáêæ}}}!-íN�<…“'Ž£ªªJ®Ž……¾úf >.s?x¿Ñã4uŒž~æŒ9 Ç�ÃW_~!×Îø§žÂ¤ÉSpþÜ9¬^õ‰tûÛヒÐÐ ö!!>¼?§Ñ¾*"‰ðÛ›¤ÿ‹Å(**­[©¸‰#‡×{½ÖÔûÈÚÚŸùU£}Zºd1¢¢¢‚wgÍD]¾Œ¥/‘)gllŒõß}�@€ÒÒR<=mªÌ~}}}L˜8 ~þ~000DQQb¢£±%|3222dÊÖ}àÛõëqèà™ýC†ÅsÏ¿€3gNãÓ5µ÷‹Ÿ¿?>˜;OZ¦¢¼……HHˆÇé“§Qïù){À–mÛ¡¢òÏ{2‰%%%¸uëN�<�£GŽ ¦¦¦Á6;‚ŽŽÖ÷=jjjðÒ‹/ ¬´TºoãÏ¿@WW“'Nhô3ö_7eê4Œ7á›7aë–-Ý�ÇÞõz/X¸žžÒïÀ–hèÞ£†ÕýìríZ ΟßÑÝi''',[±ׯ_Ç‚�>ìèî´Šçχ··Ìÿׯ]ëèîü«½7k6‚‚ƒ[廤-¨««cä¨Q �……%TTT�““ƒK—.bǶmõþ¾ð(333|úùÐÐÐhð÷)e4öóz;;,^ò1455±~Ý78røp³�UßÏøUUUÈÍÍÅõk1س{7î=ô{%ý;0ÀÖÆ$ îçåvt7žH!¡=äl!!¡�Ö øçï� Ø4551wÞ‡èæê ‰D‚[©©())�¥•% „^½zcê”ÉÒòUUUˆ�½)ý·­mhjj"#=ùµ�—Û·o×{,WW7|0w.4µ´PZZŠ”äd¨¨¨À¶KL²·GII1þÚ¿¿ÑókŠîAAÐ××GAAA£eÓÓӥ礭­�Î�m ‹‘˜˜ -SZV&ýûÕ+WpîìY‡„`ò”©øvý:™öÌÍÍ1rÔ(ˆÅb¬_·®U‚k#FŽÄÓÿ{�¹¹¹ˆ�‹ƒ¶¶6\]Ýàîî�„ø¸z¯{@` ôïŽNN�^“ö£œœääd×»ïÎí;­r ˆ�½ I�†††ðöö�··FŒ…¥/‘ ?J™ûèác)R\R"·ÍÓË :::(..–n …@ ¨· ccc,_ù ŒŒŒPTXˆ¸¸8XZZ WïÞ ÄGóæ"55µÞºƒ– °5¤ªª ±7oBC$‚™™BC{ 4´¢¢¢°võ*”=tOÊßGKˆ�Gyy9TUUaai 777¸¹¹!(8Ë—.Euuu“û݆‘H„íÛ¶=±øµ´´0xÈ”••a+}'�b¼ÞµÚêÞ«{Ù`ÏžÝøå§ŸZ­Ý“±ãj_¶Ø±m{÷„èñ£®®Ž%K—ÂÞÞe¥¥¸yóªÅÕpptÄðá#‚¹ï¿�œœœÛyéåW ¡¡ÑN½®}Ilþ‚…ÐÒÒÂO6´(¸ö°¬ÌLdffôôõ`ee�°þЫw¬\¾W®üû¤DDDDO2ØÚXUUNŸ<ÞÑÝxâ$&$ÀÁÑ––ÈHOPûÐÚÛÇ ññptrª·žºº:<<=QUU…¢¢"tîlsssé/9�zãÍ·ÐÍÕII‰øtÍ™ ooüoÆ32å ñáܹÒ/_±ŽNNعs'Ž>¤ð|LLLðÁ¼yÐÔÔÄ®�;¾y“4»CMM ýÂú£¬¬u–I$¨ªª¢_XvîØÑhù];w`×ÎÚr>>>˜÷Ñ|Èœç£6nøÞ>>è?`ø©))Ò}3ž}jjjضu îÞiy (°{wüªªÂW_~�³gÎHƒvúúú3nœÂ,ÿ€Ú[ff&ÌÍÍáçï�£GŽÔ[¶=ÇŽ9‚-á›[­=E¾øì3dee¨}3xÆsÏ! ~øÞyû-”——ËÕQö>ªÓÐgæQu÷x÷  ™¡¡=Þã/¼øŒŒŒpéÒ%¬þd%ªªª ð‹/aà A˜ùú˜õÞ»rA]‰D‚.]ºÀÉÉI&ƒ¬!ùùùX´p�ôßÎ..xõµ™ðññÁ«3gbͪU2å›sÕùöÛõ2÷Pÿðò+¯ÂÛÛý Ä�¿ÿjRŸÛƒH$ÂÐaÃPQQ�}ûövtw:Ì�¡C¡¥¥…Ý»v¡ä¡1µ ^oÞ{-áìâ777$&&":újGw§Ù²²²ðÓ† ÈÍ}|^ü;xà®\Ž’þ¬OÿM †½½233ñþœÙ(z�­¦!aþüpvqÁ„‰“ðÍ׊g<èÝ»¼¼½¥/ñµ5333,X´zzzؼiS«~¯?~\æg|###¼óî{péÖ ¯Î| ¯¾ü2Äbq«�ˆˆˆˆZ†k°Ñcéüù󨮮–ÉX ìÞªªª8wö¬Âz^^ÞÐÐÐÀ�ë×qùÒ%€ÿC™82e½½ˆ²ÒR,_ºTnz¹+W¢0ïƒZálj§¶ÒÔÔÄùsçðÛ¯¿ÈL�VUU…ÿ…“'N´Ê±îÞ½ƒ¼¼< 8Ha&PKååå!|ófÌxö9év__ø íÞ=lßÖò)Tnÿ—Ÿ™ӧe‚'øiÃܽ{W®®¶Ž\\\P^^Žm[k§ó÷¯ÿ³´ïu”¬¬,¬Z¹·n¥ÂÌÜC‡ «·œ2÷Qs¥§§#5%!M¥cfnGÇzïq333ø@"‘à»õë¤ã#‘H°qÃ�().F;;¸º¹ÉÕ�‰‰P›ÅÖ\q±±X²h*++'gçf·Õ˜Ã‡áÂ…ó€îAÝÛì8Í1hð`èèèàСƒÒhO >UUUØ»gwGwç±Çë]‹÷^óÕM¼}ÛÖîIËäççcß¾½8wNñÏÁÿ5.`ß¾½�UÐðIäêê 8vô¨Ì÷SEy9¨�=ÀÁÁAa}]==<3cNž8�7®·mgQ;üü…‹`ddŒÝ»vIOh+yyyøâ‹ÏFFÆpvqiÓã‘r˜ÁF�¥¢¢"\‹‰AHh(vl¯ Ô„„öÀ­[©¸—¦xZ»º @ÔåËÈÎÎFÿàˆ?÷í“+V»^Ò±cÇ®}VÚ S0ijiIßÄܳ{W‹ÛkLuu Ž9ŒñOM€·�¢._n“ãìÿsúôí 777‡„ 2"3ž}‰ë×­k•õ—<½¼`jjвÒR:xP©º~~~ …¸|é.FFB"‘ÀËË jjjr}kï1êH5558ð÷ßxñ¥—Ñ»O_ìØ.?]–2÷QKœ={'M†®žŠ Šššœ¿pO?óŒLY/o@JJŠÜƒ¸ªª*DGG#8$¾¾~rë¸Ü¹}jªj í��6ÈLI©ŒœœlDFF 4´úô鋸¸¸fµÓ ñ èÞ=††† ËhjjÂÔÔ�›—׿™=jjj1²vú×=»t¨¨¨`ô˜1ë?&&&((ÈÇ¡ƒ±cûöz§�µ´´Äø§ž‚‡§'ôõ P\\ŒØ›7±}ÛV$''Ë”ýâ˯``hˆß~ý“&O�ŠŠ vlߎȈ xóíw`kk‹”äd¬]³FnV�@€>}û!,, 6¶¶PSSCFF:N?Ž}{÷6é�òBOOþþ«Áu3ß|ëmôìÕ kV­Bbb&Mž O/ohkk#''Ç�•ÞuSôíÚ¹¿ýú«L;u‘�®;Z·®fB|<>þx ¦N�†€À@èèè =- ›6ý�ÈÙ5›S§Ž¦–FŒ‰ à`XXX ¦¦©))Ø»w.œ?_o KK|õõ7¸sç6Þ~óMô톡ÆÂÊÊ•HNNÆ�?þÐàtµŠ®÷o¾…^½{cÙÇãòåK ëÿ¬]´pþ|\» ö³0`à@ô ë�N�:AEEééi8uòþÜ·WáÿaÊŒkC:w¶Á‚E‹ ££ƒO׬‘Õë£Ì½×Tõ­9rä(Œ9JúïššL?N®®2÷ÑK/¿Œá‡ï¿ÃСÃ`lb‚ çÏcÃ�?àÅ—^†@òïßÇúuëd²ËÆŒ‹©Ó¦cKx8RSS0þ© èܹ3JJJpéb$þøý÷&MƒÝÅξ¾~¸sç6.FFÊì300À6âÒÅ‹ÈËËC¯Þ½‘ŸŸ�ïÖ¯ƒšº:ž}îyàÂùóøêË/d¦ë  „¿œ��adl UUUäääàòåKصc‡ÂïwwL˜4ö]í!®®FLt46nø‹–| <ÿì ™º¯¯[§©k°‰D" 2AÁÁ°¶²‚ŠŠ ²²³p1ò"þþk‹ƒZo�ŒHDDDDMÅ ¶6& áåã‡Ðž½Ò®nÐÕÕíèn=Μ9�.]ºÀÊÚºººðôôÄÙ3g–ðó÷DE]FtôUTWWÃÕÕÚÚÚråë2]b¢£Ûæptp„ššÊËË‘��Ðx…VpøÐ!ÔÔÔ`Рægì4¦¦¦ß}»‰OÿïŒÿ¬¬¬pôÈáV{ûÔÕµvŒnÆÞTú@Àƒé!£¢.£¨¨I‰‰Ð‰àéé)W¶#ƨ#ÅÅÖ†¬¬¬ ¥¥%³OÙû¨%Μ> ¡Pˆ  `@h�P\»ƒÂzšÚØØ€ÂiGï<ØÞÙ¦s½û8555ôíׯE}Ž‹�8:9¶¨�ƨ©Õ¾?“—w_aW77¬ýìs¬ýìsé5lKýÂúÃÀÀ'ŽC^#k“>ÿ‹xê© ÈËËCjJ Œ�M0yÊTŒ5J®lW{{|²j5z÷é‹ÒÒ2D\¸€ÜÜ\t ²+áëë'WGSScÇ�Ã�ë×!‰ðôÿþ‡ç/@EERSRàäìŒiÓ§ËÔ …˜óþxmæLØÙÙ!%911Ñ0Ð7À´éOãý¹s¡¢Òð�Uªªª1jª««åÖUÄÈØËV¬D¯Þ}PRR‚œìl˜››·Ú˜©©©aÑ¢Åè„Û·n!;;6¶¶˜5{œL§¬l|²j5&Lœ===ÄÄÄ )) ö˜5{Ž4C¨!“&OÆk3gÂÄØéii€@/ooXZZ*¬ÓÐõ¾y³vÍCESF?ÌÁÑÕÕÕHxhMÄ7Þ| /¾ô2lllpóÆ \½z¦¦f˜6}:æ}ô„Baƒm¶d\íìºbñ’%ÐÖÖÆÊË ®ÊÝ{Mu12òAÀ"\ú"N|\œtÛ–ðplÝ.W¯¹÷Ñ”©Ópëö-”••¡WïÞXñÉ*Øvé‚«W¯ÀÌÜ3ßx½Þ¬{oÌš]û ýâÅHTVV"¬ÿ,]¶:::�žç¸ºµ×÷ëŽaïà€¸¸X˜››ã�·ÞÆë¯¿�””däçç£g¯^è&Sç­·ÞF¿°0i�ìêÕ+ …>|V¯ýõ|®1áB¸ººáÖíÛˆŽ¾ g,\¼êêêõö-33C:ʬebb‚•«VcÚôé°²²Bll,._¾Œjq5ÆŒ‹a#F4¹­ÆXXXbéòèÔ©âQVV& j>ò3P7Eví9=:{D}Ö¯[‡ŒŒ Œê)éÏ…u^xé%XXZbïžÝ­\óðôħŸ}†¡Ã†A]CQQ—qãúuâ¹ç_€»»»Lù “&aô˜1ÐÕÑEbB"##�?=zöÄŠO>A`÷ú3Ñ•=N�Ð=1köUU/ýÙæ­wÞ‘+Ûÿï5Å•¨+€>}ûAOOOº]$Ig8ø÷ßõÖõññAÏž½°yó¦_Zi šZZøhþtîlƒS'Oâûユ+ �@{{Åw@íšÓºzzHNJjòK…îsNIDDDôï ¶6& aÛÅNúo3ssØ;:áÆµh$%>þâ;Ò… ðÒ˯ $$ùù÷! qöÌXY[×[ÞÑÑÈÊʽoÃÇÆÆÂÍÍ >¾¾8}ê”´¬¶¶6 i dĵëNµýÍÈÈPøp§µåääàò¥Kðõ󃉉I£‹Š7W|\Ž9Œ°þðÔ„ ÈÏÏÇ/?ÿÜxÅ&²~0ÖéiÊ­Í! áíí ¸U»�øåË—áàèÿ€@\º$û¦#ƨ#ee×®É&`nn!óvµ2÷QKeff"9) !¡¡¸ ;»®X¿î›zËò êøRð`»‰±I½ûÏ�;‹Ï=‡aßÞ½Íçì¬ÚŒ( s‹fÕo*w�Ú@ðùÉT`B¡£ÇŒAMM v6!°ÔÍÕo¿õ¦tý¿~aaxõµ™6|8vï’Í�9óuhjiaÏî]øõ—_¤c3tè0<ûüóxíõ×ñÊK/¢²²RZG `ÅòåHMIÁ”©S1vÜx`ÁGB(âÛ‡‡Ìq&Mžÿ€$%%bÕÊ•ÒïE---Ìšó>¼½}0hð`üµ¿ÂóêÓ·/Œ��qüØ1dgg+,÷°1cÇ!55sf}…¼¼<µ†¦¬UF;;\ºxóæ~€ŠŠ ¼6óuôéÛC†«wÝAeë¼óî{°´´Ä±£GñýwßJÇÂÊÚ -ƤÉSp1ò"nÝJ­·�††F6l8>ÿôSœ>}J:ÆNÎΨ(¯Pxn ]ïXi€­á`·¡¡!LLL�””(Í FÏ^½�ŸŸ�ç~ }ȯ§§‡%K—ÁÝÝÆ Çž¦¤lî¸:8:â£ù  *bÙÇKÓ`yeï½¦ŠŒŒ@ddm¶â�¡Cáãë‹Ø¸ØF×mî}´eófìÛ·^^^øhÁBã¹Ï ´´³fÏA÷  XZYÉe3:99á�ß—Îf  ñî{³ؽ;&NšŒø^a_­¬¬ŒÌÌLœ9}Za¹ââbÌ}Äb1–.[gi6©�­-Ö~úÜÝ=d2éÃÃÃqòÄq™€€@ ÀÔiÓ1zÌLúi¬Z¹RºOCC¯¼úTTTðÍ×_I׃Õ‰°`á"…�æÌÌLé˜899Ée*òö;ïÂÚÚçÏ�Ã×_…²‡2›ºví Û.]šÔNScó¦MÒiö4µ´°tÙrØØØ $$Tn�â‡×Âurv‚…EÃÿŸ–•–bíêUX¶b%Þ|ûm¼÷ÎÛ(**BÏž½Ð»w$ÄÇã÷ß~k•s100À{³fCSK ¿ÿö+víÜ)ý¾ ‘Ë?î,~ûå¹l=?¼ÿÁ\¼ôò+¸tñ¢LdsŽS§GÏžX²x‘ôÁN�:aÕšµðõõƒ¥¥%ÒZÏ®5þßkŠãÇŽÂÃýz÷Æ×ëÖ#>>5ÕÕppt„X,Æ7_UïÔ¦"^xéeܺ•Úâ>4F]]sçÎCW{{dddà«/¿¨÷gÁ›7o ´G8:9J3žëS÷rGlìÍ&ßÓÓKp¾s[>³“ˆˆˆˆ:3ØÚˆD"AjJ2Μ<Žû÷bÿÞ]8yìÒÓîA ÀÍà æŠßº¦–+).FôÕ«íŠÐÐHMI‘ù¥ñQþuKM‰X÷÷Gx=œ‰ÓÓ@6¤îX¥¥%mzœG`UUU¬]½Z„€²²2œ:u²Ém4D"‘àǾGEE…ôß{÷ìØ+XóF™:žžprvFzz:¾]¿N&ÐY»ÞæV¹ Ÿ‡éèè`÷îÝ8uê¤ÌÇÇÅ) Ê5v½ïÞ½ƒ’âb8:8JïEMMML˜8 ={ö’–«{Z—ñü3Î;¶o“É ),,Äo¿þR[f€âÏмquéÖ .‚Š@€%K7\”¿÷ÚRKî£ÔÔTÿܯ™™™ÒÿÛë2�MMä_�ÈÊÊ’ÿêêjüôÓF@Ÿ>}Ì43vvíÜ�šš…åîÝ»+Í(©ë_ÝÔ´÷¬ñjòHßöìÞ%—m#‘H°ýA ðÑL+ÿ€èéé=x1éŸSEy¹ô3×ZÜÝ=àìâ‚¢¢"|óHp ¨=·ÿ³wßáQTmÀïÍ&¤÷N¤‡ôR@zUB•"ņ+U?ßW±‚E±�НJUEéÒ $¤‡–„�HB*é}³ß›]²ÙMÙTÅûw]^’™9sÎÌîì&óÌóœÇ�w[wrsåæ·«®ªÂ±£’`d[ón©âÆ�øáûïajjŠç/†¥¥%ž~æTVVâã ëå‚W]1~ÂDèêê"9) {÷ì‘û¼‹ÅˆÝˆm?ýMMMøøøÀÏßúúúHMI‘}_·4÷‘G`aa�-›7·y�v‡Ð°0¸5ÍgeeÕêÜÂÒóîì|/;zà A˜5{ŽÜÜiÒõÍ¿[”Ñ70@øÐ¡xé•Wi©©²ÏC""""ú{`[‰DHJ�Ÿ»ª¤ä..F�GÐ�PX÷·�‹«òîôíÍŽûݹsg±øÅ—`k;;¶oosÛ `ÉJÒŒ%É¿ã0ÁøùûC(Þû¼Ù�ñ–O/núâK¹§iýåìØ¾­ G!hê§ »è„øø8äççcô˜1JË7‡¢Èsç0ÁBL˜8III(//W$»wÉ*‘¤ï‘¶^£G#bÊŒ?¾Ó¥a{â:^·~ƒÜÏUUUXûÑšVƒ�R±11˜9}Z÷W‰¢± IDAT¨�@€iÓg@,cOK-Ÿè‹Å(*,„¾¾>ôõõq÷®¤ô¥³³$ûèòåKJßW °³·‡“³3Î�»—�R[[+»'½yÜ<_S+ÉTÒÒÒBEE MMMÜHOWz½Þ¾}UUU4hP«ïñðð¡°²¶Æ…óçeÙ�qòä‰}�£¨¨H.˜ MYª­•´V¥���$øâÅh¥e­Ršæ"tttlsœüÙæú–Ú;ßb±×RR ÉÚÈÉÉ�§—fÍž�ÒÒRY¦œô&hÊÕ{7«]šÞw‰ ûMJL„X,†�� ´ut‚Rª¾®ž^Þ˜0a4µ´ðñ†õ² ¼¶tæÚëI]¹Žªª›®Ó¦<šŸ»Zéõª­­°ÏË—.)ü�Ÿ—‡üü|XXXÀÆÆFkÎÌÌ Žââbœüp›YlÇŽk·WOi~SzPý:j©å„ó‘ŸŸ�ëiiprvnsŽEi¹Öæ©ÑÔÔlÚ®¦Õ}ܹsI‰‰"—E¥ éMÖšêên+'z#=Õ55Ðì×¶@GG/½ü VÝ} ©MÁ‹¾ Ä\¼ØêSè-)›GE:G‰Z³ŒCCI©ÞÖ‚ÊÒù¦¤%}¥š?é.ýwóe"‘äßÒÖÒÏrGGü²§í2{ººº(kqÃMè�“ª­­EUe%tõô`hhØj€MÕ×uÊÔ©²sOE"[¿"¦LÅœ¹s[ýN$Ÿ?Ò¾¥ŸaÊæÐkllDII‰B–\gI÷Ó‘ùÍZZ²lú5…¤âbcqøÐÁVÛ”ÜUüVú™dÚtîòT8w>¾¾xañb˜˜´þPUËàigú‘jó|«Ý;ß]ýÞ{xÖ,89ËÏqYTXˆÍ_¥Ð~þüùðóóÃÿûŽ>,[~æÌi4ˆ°dé2<ñä"¼ÿÄb1„B!ž{áTWWãÇn,-ß–¬¬,¬þðÔÔÔ xH<<<ðô3Ï`ýÚµrÛ‰Åb¤¤¦À××OVfß×GòÝâíí 555ØÛÛ#''Gá¼’‡òòòuõõ(.*ÂåË—uáB‡çk#"""¢ÞÃ[¨¬”ÔÄè§©ÙêÍ꺪ª*¼óöÛÐè§Ñfi¤à¦Œ¥††¼ºd©Ü:éµ�AÁ÷l(++ƒ��¬¬$O¾K}ö©$X²ð±ÇÚ¼™ØQÒÀ–¥••ÜÓ̽á¯cÇ0{Î\Œ?[¿û¶[÷­®®ŽgŸ}�?ü¹ˆ à!ˆ˜2'Oœ�;§�%=wÖÖý;ÜÆÎÞ^vS!bê4Lzh²l�4310(;wìPè§/^£¾`an@r!??O¶\Õ먻|¾i,,-påòåV·‘Þ”4lh‘24”<^T¤<+PêÈáÃðñõÅè1c:UÎÔÜBòÞº“§úM±Ö|ñÅçÈÌÈ ¹ÉõÚÒeðññÁâÅ/âÕW^îó‡8¦Ïœ@µÀRGK=µWeSÐÉ,ÖÖdfd ::ºÍmš—@” ÂÀAƒ/+×Qe¥Š7ßT!ÍŠi�¸eµ:Ó&:*ªÍ²Våå­gYY©J}uô|KKy99;ãÔ©“ðññőÇ1bäHøúù"33ŽŽNÈËË“eMvˆô�ÙÆûNÕ×5??ï½³ Ï<÷<<<<0áB|ÿÝwm¶é̵×:{µKÉçA{—¾@I####Œ3ååå8ÒlÞ´®hÞËÐaððÑGQZZŠ-›¿FbB"JKKdŸÕÛvì”=ôÑRkŸeÝ•½&ß—êmüýüe%™¥Š‹ÚžÇW,îÙÒ~ÍyxzBßÀàåí]=½Vç*$¿×(,×ÐÐh³ŸŽž; KK¬|ý …BìܱgÏžAQa¡,ˆòoþ~þþ­~×uæ5Rõ|wözurvQ8w-çH”>b$ 6æ¢Âº˜‹!‹amm SSSÂÊÊ ƒÙáîÝ»XüÒKrÛK‡wtpÄ›ÿý/Š ñåÊççmNM­íïÊéé¨nÊ ýê‹Ï±þãO†ðð¡ròpíê5øúúÁÉÙ��bØ€Ï7}†¿'''ˆD�ÐÐÐh5óîäÉ“}ö©Ž¶>ÐüÏ>…Öã®\iý¦»T`SY;---¥H’v̓LW¯^Á�!!ððô”Í]ÐÒÒÒÐÐÐmmm8::âúõëí7ê&¥¥¥ˆºp¡aa°îßñ UGL�6¶àÊ•Ë8uRR~i÷Î�xbÑ"<¹è)¼ûΪ.÷!�×ÀÍÍ­ÃÙ¢AÍæT�–àiÉÎÎffæ(,””ÔéËר/¸¸ºrrrä‚L�¹ŽºÃ­[YJç/i.+K2GÏÛJ×Û6-oo?11Q\\„1cÇaÿï¿©;z¾¯§¥¡¾¾Î..°°´„•µ5ââbahh__?Ä\Œ�¶¶6¢££dmD"*+* «§…ò“šššÐiÊf.U’™ÐYß~³999ølã'Xÿñ'xðÁ‡�”�Øêï=}íuFW¯£Î01QþÙ ÍSöÙðÐähhhà×_~i3«¹³FŒ”6õ•B•±±±Òàšì³NI–“šššì!‘î ½f­­­ÚÙRѼGævÛ8º›……^Xü"ª««qòÄ Lœ4 /¾øVøA«m~ÿm~ÿ­ãŸ[E……055…•µU‹RâÊ…‡‡CCCþü¿ü¬8߬¥•ò×@Õ~:£«×ë‡ï¿×¡íô d¥½k”\o hhh€††ŒŒŒäæ‚366nµ¢€¾�|}ýä‚z²ïJ %ß•­<€¥Lnn.vïÚ‰ù bÑÓOãòåKr™ÝÒÀ™³³ tšJŸ>u S¦Nƒ¯ŸŸ,kMY¹N""""úçiûQ-êýmlå,óð7 «« 77ɤÕÏ=ó4fNŸ&÷ß¼¹sP__˦òwR'�K‚B£F�‚v–o¬ªª’Ý€™<¥ëqª:rø0Æ�ßmû´¶¶ÆŒ™3!‰°åëͲå‡Bvv6||}Öå~P\\ŒVRâGéükŸ}ú©Â{aæôi²?š¥e$�¾�z“@ Àøñ’÷ÂéS'eË;{õ–¤DÉ\Ivöö 7(ÕÕÕáåí @¾,¨2"‘û fffð÷WDl�©©)›¸ÍÏ]w+++ÃÞ½{ÓgÌlµÄ–¶Žììíagoßfy¾®˜1c&€ž ,]O“*=<<•§�¯�Üv�uíÚUÔÕÕÁÝÝCå9�¼½}àìâ‚kW¯âê•+]Gk*š20Ì›²K›“uûŠôÚ2$¤WúSå|×××ãFz:ììì„ò²2¤_¿Ž¸¸X vsƒ—·I6Bsi×%ï'éür-ûÈÎÎîÖ ÒÒˆ………øú«/!°ø¥—Z½)ÜÓ×^sÒßeµ•ÌÙ\W®£Îòðð�e²J™››ÃÂÒ555¸}û–Ü:]==ŒŸ0ÕÕÕ8xð@�ŒI ËU2ó�å×IJŠä=èíã­°Núžë.ÉI’yÞBá««ÛmûíKêêêxmé2èêêbËæ¯ñÝ·ß ))�AAÝRmB*©éÜ�;®CÛKß Êªl 4ÖÖÖÝÒOgôÖõZS]- |98(ÎÅicc#Ë”–åÍÎÎVú;úÌéÓðí7[ ñ˜9}^zq±l_ÒïJ33s…kÆu°jß•¿ÿön¤§C__Ï<ûœÜº´´TˆD"8»8ÃÇ×III‰Dˆ‹‹…¯¯ŸlþµkJæ_#"""¢Øzˆ³Ë`˜[X*üò>ÈÎÎ.’_ào\ï™ R�¿„B!nߺ%›ä»¹ÚÚZ\¾| |/»éâÅh$'%AßÀ+V®”{‚RMM­Ós4)³í§ŸP[Sƒðð¡˜3w®Ü�duuuŒ3Æ=Ðmý5wéR2r²³e“Þw‡§Ÿ}øcÿ~¹Œ!‘H„¾ß xôñÇÊ ©ª±±ßo•ìï±ÇŸP¸Á«¯¯�ù ÂÆÆ€äIw{‡¦ùÖâ•î366À½@œT_¾F½ÅÜÜË–¯€�½= pàÏ?eë:{õ–ÜÜ\$&&BMM O=ý´,ÓG `á£�A__Y7oâÒ¥KíîëØÑ#hllTéšpquÅþû455uáB�ßT9xàJJJ`nnŽ#G)ÝÆÝÝëÖoÀºõ0$$´ÛÇàîî�ÁnnHKMErRRû :!55·neÁÈÈHaÎÂqãÇÃÞÞåeeˆQRvJUUU8tð´´´°|ÅJXXȲ¼½}”ò¥eú~ýåç.�¡-7ÒÓþ²Ï3ðôôÂÇ÷X¿‘””„ëiipquÅSO?#ËT�ÒÔÒÂðá#àååÕ-ý©z¾¯]»uuuLŽˆ@||<Äb1.%'£±±ML´,ãõ×±cM}Í”{/èëëcÞüù€ãëò±´&òÜ9œúàÌéS ™í“&M‚¶¶6:ØféÀ®ÈÍ‘SF¶øl4ȳç(Ï‹‰‰AyYvðîý.¡¡¡!{Ïw—ääd¤¥¦BOOÏ=ÿ‚Â5kkk‹¡Ã†ukŸ=má£�ÁÉÉ §O�ÂéS§ ‹ñÙÆ�(++ü àââÒþN:àÐÁƒ¨ªª‚——¦N›®p=øûÈ‚+€äw:T®ì¤žžž{îùV¯'UûéŒÞº^ëëë‘Øô Ƽùóå‚ÒÖÑÁ‹RSR”Î{©ŠÒÒRA__ÃGŒ�-733ǬY³UÚWcc#¾ø|D"‚‚ƒå¾kkkk‘‘‘GGx{ûÈ2�ãccáäì ///”—•µZ2“ˆˆˆˆþYX"²‡˜YXÀÍÃ���¨®ªBCCtõôd7u³23�™¡Ú<,Ô3¤eíââ[Ï\‰‹‘†Þ~�ÆŒ???¥ëD�"¼ùÆÝÒÏK¯¼q£FÆÆ²'©óóóñÁûïÉŽèÚu$Õü=ÓÒ‘#‡qâøñÎ`óW_âƒÕkŒ¯6oAVÖMX[÷‡¹¹9jjj°é³O;4WWQQbcc‚¬Íá­·W¡_¿~°´²’e™$&&bӦ϶Wõ:jOmm-öíكǞxÓgÌÀÉÇ{}.¶3¥4Нuwúü³ÏðÖªw0mútàfÖMXYZÁÙÅ"‘Ÿ¾ µµµ]îgû¶m°±±E@` 6~¶ 7n   :ººprr‚¾¾>Μ>- ¾€‹‹ <=½�‘qññʃöÝáÎ�;ˆ��‡ŸŸ>Z·©©©ÐÑц��=N?Ž1cÇöXßí‹ÅX¿n-þûö*ŒŸ0aááÈÌÈ@ii)LMMáèä„~ýúIæÈéâüŒ�9ß×®^Å”©Saff.Ë`•>àëë‡ÊÊJ…,§ó‘‘8wö,‡ÅÇŸlDRrD "xyIætºrå2þØ¿¿KÇÒžo¿Ù‚ÁnnðññAÄ”)rå7{ëÚ“ºrù2Š‹‹0pà@|´n®^¹ŠººZ466bû¶mrÛvæ:êŠëiiX°ðQ„„„"//NNN°²¶F~^vlß.·­¦–&=øêëë{ôõÛ·o/‚‚ƒ19"^ÞÞȺy†FFðôôÄùÈHøÈÊŒJÕÖÔ૯¾ÄÒeËñÒ˯`Ô¨Ñ(,,„»‡êêjQXX333¹6Ú::˜<9Bö³©©$paaa�Y³çÈ–gff :*J®í†õëðß·W!$4^^^¸rõ jkjaii 'ggìßÿ;Ξ9Óݧ¦]AAÁ°wp�ýle%ù½däÈQððð”-ÿó�ý²ÖÁC†`ÒƒâÎ�;زùkÙ6wïÞÅçŸ}Š×ÿïM¼¶t)–¼öZ—ƒª%%%X¿n-–-_�ù `ÜøñHo*>ÈÎýû÷LJ¼/Ûþô©S˜2e*\Ʀ/¾Äµ«W¡®¡//o”ܽ‹K—’á驸ð�ªýtVo]¯ß}ó >p„í€øtÓ&¤¦¦ ¡¡ÎNÎÐ70@yyy‡æQ눃`þ‚xañ‹?~êêêàèä„3§OꕌÁÖdffâ·}{1}ÆL<ùä"\JN–¯]½'''hji!>Nò}tåÊÔÖÖÂÄÄۙ׎ˆˆˆˆþ9`ë!é×Q_W##côÓÔ„Ž®.êëë�ŸWˆ›™ÈÍákB¡~~þ€„¸ÖoÆÅÆÆà‰E‹àìì ###Y𥼼¯¯\�qãÇcèÐa°0ššš(.*±£G±ÿ÷ßäægÑÐÐPúD©¥¥%,--•U• ëI9˜—_\Œˆ)SáçïWÔ××#//1£qáüùNŸ‡öœ8q�Ì›‡~ýú)»•Â1©««Ë-ÓÖ–<ý¬¯¯�G›žßúÝ·­Îmò¿­ßa݆�19b N?®0Ç�ªöüú+’““ñàƒÁÝ訨@jJ Ξ=#{‚XZ¾¯­³Y7o¢°°ffæðõóÃùÈHÙºÞ|�LLL•ÎÅHžªí.ƒ»A$¡¼¼‰‰‰ˆ½xÇŽ•›Ð¾«×‘T[O[K3»"//Ë–¼†Y³çÀÏßž(//Ǚӧ±k×N¥%šZsäС6lðòöF]]JKKq>2gΜÆÅèh¥A¼ËJU88:ÂÇ×YYY]ÎkÏõë×±bù2Ìœù0¼¼½ŽªÊJDE]ÀÞ_í¶9°úÃ0ì�0rä(Ø;8ÀÑÉ ¥¥%ÈÊÊB|\¬Üç̘ù0`Ï/=èøäã xüñ'WWWÜÌÌÄG«?DcccŸØI†Óò¥K0qÒ$„„„ÂÉÙêêê(..FbBbb.vËçcgÎ÷µkWe×dB³Ìeé))×”^³?ùW®\Á¨Ñ£àíí555äææâ·ßöaÿï¿÷x@»ºº?ùï½ÿ™7—’/!=ýz¯^{RõõõXõÖ[˜7ÜÜÜ0qÒ$¥¶Î\G]‡}ûöbæÌ‡1$$UUU8þ×_ؾí'Ù<ØêC6ÝáFz:V,_†¹�<ggØØØàÎ�\lßööÿþ;¾ÿAùƒEQ.àÝU«ðð¬Ypqu…ƒƒ’’“°õÛo±ú£�@îÁmmÌš­˜•cnn.·üä‰ ¶–׬§§ÔÔÔP�Ÿ�ý¿ÿ†ƒz¦|f{ƒ‚”fLI絓:yâ8*++eó®‰D"|²a½Üù$MøóOLzðA¼øâKX³úÃ=hÓ–Ä„¼öÊ˘1>¾¾ B]]rssñýÖ­¸rùÞÜÐÕÕÕX±b9æÌ™_?‚ÒÒRœ9} ;¶oÇ ‹_ì–~:«·®×;wî`É«¯`ÊÔ© ’•/*,Ä™³g°oÏ^u¹ømß^¨««cÌØ±°wp@~~>víÜ�Çaì8ÕKnþ¼{7†„„ÂÆÆÏ<÷¼lW¯â¡ÉÈÌÌ”�]$!)1CBB8ÿÑ}DàäæÓµ¿"ˆˆˆˆšY¶b† ÁÆ�?Æ™3§ûz8}bÐ ;¬ÿøcädgãå—^ìòM[jÏ·¯=‰iÓ§cÞüؽkvïÚÙîöøâ«¯a``€ÅÏ?§´Ôñß•¦¦&~Ú¾ÅÅÅxæ©E}="""""¢f°Q·QWWGfFn¤§ãܹ³}=œ>chhˆÝ»váÒ¥äm°§7ñ|óÚë S33=rùùyÛàš‘‘PÑ¢ŒáŒ™C à|ä¹>Ñ¿3؈ˆˆˆˆè¾¡jÛ?ÁÇã…Å/"-5¹¹9hhÁÑÑŽŽÈÉÉÁë+Wty1""""""R 3؈ˆˆˆˆˆþÆnܸ�sgÏÂÙÅvöö …(,,ÄoûöaÏž_\#"""""êÌ`#ºÏ|¼q£ÊmÞ]µ ÅÅÅ=0š®?a"&Lœ R›è¨hìØ¾­‡FôÏñÂâáäì¤R›íÛ¶ábtt�ˆˆˆþNî·ßˆˆˆˆˆˆˆzlDDDDDDDDDDDDD*Pëëý“0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆTÀ‘ `#""""""""""""RlDDDDDDDDDDDDD*`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °©€6"""""""""""""0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆTÀ‘ `#""""""""""""RlDDDDDDDDDDDDD*`€�ˆˆˆˆˆˆˆˆˆˆˆˆHê}=€û�@ À€�v8hô ¡¦¦†Úš åÚUTUUöõï+B¡»~þPTT„çžy���rÛlýßÐ××ÇË/.Fvv¶Â>F�‹çž°ç×_±}ÛO Û„††aɲe€ø¸8¼ÿÞ»rëMMMñÕæ-¨ªªÂÂùó666ØøÙ¦v�ãýwßA|||ޏ{EL™Š…�>ŠØØX|øþ{=ÒfÕ;ïÂÃÓ?ýøöíÝ«t›ðð¡xuÉâÙ§ŸÂ¢§žÆ„‰@i»†ÇK/¿¸�5«?ìÐØ[3`À@øùùÁÅÕ.®®011,zâq”””(mcdd„À  ¸ººÂÅu0ú÷ï�@€�7¬Ç¹³g»4©Ánnxïýä–‰D"”––âzZ<ˆ¤¤Äné룵ëààè(¿lÍjDGEuËþ‰ˆˆˆˆˆˆˆˆˆþÉ`ëAjjjK++@UU%êë¡¥­ƒƒì�››Ã[255E`P�Ê�   {ÿR`kÎÛÇzzz¨¨¨�- ‡@ h³ÝµkW[]WQyÿ¾/ââbááé oŸVlÞ>>’mccÖ……UhÞ­cœ2u*FŒ ‹Åjãçï�gŸ{^ösGÛu†H$•˗ZZZ°±µEð�!2;wìÀ/?ïîrG��qŒ$°ŠvyŸDDDDDDDDDD÷ ØzÐ`wOXZY¡¬¬q1Ñ(+-•­366A]}]Žîþ'‹1nüx•lý’}ùÈ IDATúõƒ—·7êëëQ^^ŽÂÒÒyyyJ·¿ž–'gg Á_ÇŽÉ–‡‡EZj*œ]\ZíëÍ7ÞèøÁÜGbcc±`á£pss‡††êëë¶ññm °ÅÉؤçÛÊÚwrsºººðõók÷|«"#ã ‘’r ™Øòíwí¶).*Â�"åÚ5¤\KÁ’¥K»m<-ÕÖÖbÕÛoÉ~îׯž\´£ÇŒÅì9suYYY]êãè‘#²ÛØÚ0ÀFDDDDDDDDDÔ ç`ë!ý45áà脆†\8wF.¸wYÆu¿¤¤$øøøÂÒÒ²Ãm|||¡©©‰+—/˲§›e´µ”››‹ÌŒ „…•-³°´„“³3ÎGFv~ð÷±Û·n!??pwwWXß¿˜™™£¾¾ÉIIrë.\¸‘H$—±.3v,ƒ‚ñç´Ú&2òfÏ™ }”—•!,,���¸u {¬;EŽ••úõ뇑9Jæ�û'ˆ�‹Åø áíã‹ÄDù9äå!/_¾„ÚÚZ¹uåå帔œŒ°ðpìùU2×^XøPܼ™‰ìœæ¹è.õõõÈÈÈ€ŸŸŒ�MÖ Œ9 £G�ÆÀAƒ ¡¡�;wrqêäIü±?ºm,î˜<9.®®ÐÓÓÃݻň¹ƒŸwïBi‹‡ (8��’ùëLLM¡®®ŽÂÂBÄÅÅbßž=­Î{7ØÍ S¦L…½ƒ= �PYY‰ü¼<ÄÇÇá·}ûPW§˜%¬­£ƒÉ“# +++466"3#û÷ÿލ ºíÑý�l=ÄØDrƒ»° šššprq…Ÿ ¼||Ñ߯¶Ýù¹¨ë.%'#';£G�†††F»Û âãã�””‘Hwwwèêê¶ÚîÜÙ³ … „ Ç¥KÉ Y‹Ýåµ%K±á“�x{ÕªÙo�fú4Óšóññ•l£8ÿœ;wvvvèoc}}}x{{#òܹžì?ˆ††ä™‰ââb¹åB¡+V¾Ž/†½½=2nÜ@rrŒ �0ÁB¬|ã ¨©uÏ×Á´éÓñλï!0(ùùˆ‹�ECƒ&NÄê�ÖÂÄD1ø÷Ê+¯bÔèÑh‰�œ”„ÄÄ…B<ôÐd¬Ûð1¬¬­Ú„†…áÝ÷ÞG@` òòòq>2™™037—¼õõÚ˜™™á£µë0köl 99éééptr²å+0cæÌn9DDDDDDDDDtÿc[Ñi Ȩ««cÄèqÐÔÔ”­³wpBiI .DžEm-³ÛzÒÑ£Gðèc�#$$gΜns[ggg!??ÙM™a×®]ƒ‡‡üüýqöÌ¥íòòòp#=aáḔœ{{|õåÝ~,÷“äädÔÕÕa�� eYMB¡žžžç_“ŠŠŠÂ3Ï>‡°°p””Ü…P(Dä¹sèocÓkãÿ;ÒÕÓƒ½½-?ïàœ¹� 0(éé×±vÍttt°lÅJøúúaü„ 8xà@—Æàëë‡yó ²¢|ð>R®] ^Ï_°S¦NÅO.ºµɵ۵kNŸ:)—©&0oþL�6 .ÄÚ5käÚLŸ1�ëÖ~$—y&à€ªêj…ñ½¶d)¬­­qâøqlÙüµ,í¿� Þ^õæÌ}1cpóff—ÎÝÿ˜ÁÖC4Ô%±K/oTWUáôÉã8°Μ:޲ÒÁ×?°�Gyÿ;qü8êëë1~„v· ’Ì['[&ýw``ëó°’2‘˜ôàC‰D*5÷Ëž½JÿÛ±kw»mÿéêêêpùÒ%x{ßËbsvv†¶Žr²³qçÎ¥m++*�”˜ˆð¡áŠÌŒ äææöÖÐÿvúõëGG',_¾šššØ²ùkܾuK¶^[G“|b±¯_/ ®@UU¾Ý²0zÌØ.�eæÃ¾ÿ~«,¸b±Û·ý„¢¢" �žžž\»ßÛ§PR,ãצ2 îî }IË`¦¥¦*´‹�‰AuU•Ür/oo¸¸º"77_õ¥\ùÈœìlüúËÏ5z´ª‡MDDDDDDDDDÿBÌ`ë)M% …jB\ˆ<‹º:É\Rw‹‹u£ÇN€¥•ôôôPQQÑ—#½¯UTT 2ò†��"++«Õmƒ‚%A´„øxÙ²„ø8Ì_°~þþ …‰DJÛFž;‡ù bÂĉHJJByy9´´´Ú[ËÀ€T}C}›í–/[ÚæúŠØØøùûÃÛÇG–]è--ÙJöšÔ¹sg±øÅ—`k;;¶oïñ±þÝèèèà—={å–ådgcé’×ä‚k0xð`hjjâFzºÒ åíÛ·QUU…Aƒµùo�––\\]ÑØØ¨4À,‰p#=¦¦¦°wp@rR’ÜzmxzzÂÊÊ ZZZ$ÏÔ××C__�b±X¶½t¾¹'ž\„ŸwïFVÖM¹õ-IK�^¼­t¾¹””€£££êODDDDDDDDDÿ: °õQÓ Ü¼¼;²àšTUe%JKJ`dl cSØzØáC‡0|øŒ?ß4eë´dai‰¢¡¡ÉÉ÷nügff¢¸¸&&&pwwGrr²Òöùùù¸ž–'gçÏöúʪÌ}$.6x ðñ½—Á&�“-6¶í[tTžk€ºº:"#ÿ}ó¯566âêÕ«]]] 8ýml°òõ7°rù2¹Ï33s€ƒ££BP®%]]]”••ujL&¦¦²yÜ~øi[›Û¶Ì`‹˜2sæÎE¿~ýZm£®®Žúú{ÁçÿmýÖVo $4!¡¡¨¬¬DFÆ $%&âè‘#(//—kon.9S1¥Ãc#"""""""""R†¶RS#™[­ººª•õՌۼ¡LÝ#5%7ofbøðáøñÇ”nÜT²¡¡¯.‘ÏSo*÷Üj€ >ß´ –¸rùr7�üþ–ŸŸ�Û·oÃÖÖ¶¶¶(*.†“³3jjjpõÊ•6ÛVUUá�·ß†F? Üù–‡¬©©Á[ÿySö³�� þóÖÛ°²²Â£�=†Ï7mRh“™‘�èèè6÷Û¼lbgUVVâÏ?þhs›ìÛ·eÿ:l>ú(JKK±eó×HLHDii‰,“nÛŽ�rsXJݾ}¯¾ò2¼¼¼áåí 777¸»{ÀÓÓ &NÂÊåËQ\\¤Ð.:* ™™™­Ž­¼¼sF"""""""""úwa€­‡TTH²'44”Ð444 ÓåØH5GÆSO?ƒaÆ)]ØTRKK Ê· ÂÖï¾mµ�[·²pëVë%(IQ\\,lmmáíヂ‚…BÄÄ\TZ¯¥+WÈ”ÊÎÎÆç›>Ã[o¯Âˆ‘£ðÛ¾}¸ÝÄ*jšs­øn1vïÚÙ¹Z¯¼(S\T±X 555ü¼{W›å›1r$`óW_!*J¾´¤±±±ÒàšT}}=ââbe%EÍÍÍñò«¯bð`7LŽˆÀÿ¾ß*ÛV:÷\JÊ5ü¶o_‡ÆFDDDDDDDDDÔµ¾Àýª ?`jjAÓ|lRB¡ú†€òN–c#Õœ>u 5557~‚Â:]]]¸¹¹ž{æiÌœ>Mî¿ysç ¾¾–Me$ûZÿþýagoÛúz(]# ŒøøøÊæÈŠ‹�ëË!ýc%'%!>.�3ž%[~íÚUÔÕÕÁÝÝúúú�ÚwiY)´Ù¾¦¦©))ÐÖÖ–½–ah(ù,̽£˜‰8$$D¥qà�ýû–––rë’$û¢Ú>‰ˆˆˆˆˆˆˆˆˆ”a€­‡¢¼¼ ºzzpì&·n°»úõ뇪ÊJ¥%̨ûUWWãÌéÓpppP˜cÉß?B¡·oÝBAA�BÛÚÚZ\¾| Ô”éÖ—^yõ5¬[¿ÿ}ë­¾J—]½zÕUUððô„¯Ÿ >®íùרu;w섊þ66$å4<---,_±rm¼½}0z̘V÷{+K’™ªðÀ@s{~ýðüâàîî¡°~àÀ�xxÖ,¹e¹9’ÀÚÈ‘£ä–d‡Ùsæ¶Ú×”©SeÁ9)555„……rr²åÖ%%%ázZ\\]ñÔÓÏ@KKKn½¦–†//¯Vû$"""""""""’b‰È"‹‘ƒ°aÃá:Ø6¶PQ^}}èêéA$!>îb‡Ë¨Q×>|cÇ�SHËCÆÅ·ž9 __?cϯ¿vËx>\½¦ÕuGŽƉãÇ»¥ŸÎëêêðΪ·ñØã�ÃÃÝCvŠŠŠäl€$‹íÊåK˜ôàCìæ†àਪ¬DAAΟ?�¨ çå¶¿‘žŽË—aî#�ÀÙÙ666¸s'Û·ý„ý¿ÿŽïøQ阾þêKx{ûÀÞÁAAÁhllDAA>~Þ½þ± m °|éLœ4 !!¡prv†ºº:Š‹‹‘˜�€˜˜‹¸pþ¼’Þˆˆˆˆˆˆˆˆˆˆä œÜ|˜BEDDDDDDDDDDDDÔAœƒ�ˆˆˆˆˆˆˆˆˆˆˆˆH °©€6"""""""""""""0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆTÀ‘ `#""""""""""""RlDDDDDDDDDDDDD*`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °©€6"""""""""""""0ÀFDDDDDDDDDDDD¤؈ˆˆˆˆˆˆˆˆˆˆˆˆTÀ‘ `#""""""""""""RlDDDDDDDDDDDDD*`€�ˆˆˆˆˆˆˆˆˆˆˆˆH °©€6"""""""""""""¨÷õîWCS³v·;{úŠ‹ŠzaDÿN¡¡a5f ¡­­�»ÅŸqãŽÿõââb‹žz&NüôãØ·w¯Ü>>/½ü àbt4Ö¬þP¡+++lúâK@jJ Þx}¥Òñ|´vñù¦Ïpâøq…õ#G�Æó/¼€êêj¼õŸÿ #ãà›ï¶ÂÈȨÍcÝ·w~úñÇ6·iÏî_~…šš|ܽ¦¦9ÙÙˆŒŒÄŸìG}}½l��½=Ö­ß€ÆÆFÌš9CaáC‡âÕ×– 33K_{U¶¼ù9mͶŸ~ÄÞ={d?;::aÍÚµ¨­©Á¼Gævèx¤çQYQ�;wî 11‡@III‡öÓ–Y³ç`ÖìÙÞþ䉈‰¹ˆ¥Ë–£¤¤‹Ÿ555 Û©©©aÃ'akk‹ï·nÅû¼ºd ÂÇÊm[__�¢¢"\¾”Œßû ÙÙÙr땵i)-5¯¯\Ñáãè.o½½ ^ÞÞrËjjjp'711±ÿ÷ßQYYÙå~ñúÿ'·¬åû’ˆˆˆˆˆˆˆˆˆ¨£`ë!ee¥­®SWW‡�¡D (+m};ê<¡PˆW^} ¡aa€Û·n!+ë&ÌLÍ OO<þèB…vaáClaaáíö,û·³‹ Qªâk†çžuµµøà½weÁµæ²²²PU¥<Ø�ŸŸ¯RmIKM•}b��Š·þó&jkk»´ÿÒÒR\»v €®ƒn¤§£®¾PXXصƒhæö­[(--…¾¾>áìâ‚É“'cãÆOÕ¥}ÈŽEÊÌÌfff(/+CvŽ|°+''ΟǥKÉðôôÂÔiÓ°sÇ…ýŽ3¶¶¶ÈÉÎÆÁ*¬ÏÏËC^^ÀÀÐýûÛ`ô˜±x`ø¬ùðC$$Ä+k! ”Ç­¬[>æž�““ƒ¢ÂB@ €¹™ÙÙÁÎÞÃGŒÄ›o¼Ž¢.>ˆ�›“ƒÝ»v dAu"""""""""¢Î`€­‡$)¹¹-åèä /#ääd£¡¡¡Gõï±ðÑdžü¼<¬[ûnܸ¬8h¦L�ªÐæzZœœ�aem�;¹¹]]]øúù!-5Î..­ö$ °åååÁÒÒ��8þ×_¯¿^yõ5ˆD"¬Y½×®]SºÝ·ßlÁåK—:¼ßÎúúë¯�™‘!ûÙ«Þ}NNN˜8i’BRU‰ HLHhhh`Ǯ݀ ÖËÎ}wúí·}²ŒAmL�: 3fÎÄ’¥Ë°rùr¥ÁÌŽ:þ×_ ¯µ4«-)9 ¯_¯´ÝÖo¿ÃÚõë1yr:„»wïÊÖijiaÖì9€ï·n…H$RhòäIìÞµSö³‰‰ ^[²ƒÝÜðüâðü³Ï*|¾ÿë/¹6'GÂì—ýìâêŠ×ßø?˜››ã±ÇŸÀúuk»´ÿœœÙ±ÛØØ0ÀFDDDDDDDDD]Â9ØúÀÀAö€[73ûv ÷©þýûcÒƒB,ã£5«å‚k�uó&>Û¸Q¡Ý…  ‰ä2Ö‚‡ �ºº:ÎGF¶ÚŸ®žŒššüò³$PÔáñº{x`éòå€ ë×!))±Ãm{K~~>Ž>ðöñéãÑtMuUvl߆CB(bþ‚}2Ž›73ñ×±£ÐÔÒœ¹ò%/#""`llŒø¸8Y)ÓöãÓO%ïkSYVà?UjJ ~Þ-É8 ‚P(ìãÝà ¶^flb}TUV¶Zª�ºfÄÈQHHˆGfff‡Û•——ãRr2ÂÂñç×_HJFÞ¼™©P毹€€…BÄÅÆ"æâEˆÅbøøø@CCCn¾2eœœ�ñúÿ |úÉ'¸Ýáñö¶Š IiJ-M­>I÷8xàOL˜8Þ>>066–Ë ë-Û·oGXøPŒ5ìÿ·neÁÐÐS¦B$aëÖïTÚ_~^JJJ`dd \î¦qjkkÃÜÜPT\ŒÊŠŠnÚsÛÒÒÒH²utuQ^V&·ÞÒÒӦπ·�LLLP]]�+W.ãçÝ»å20»J[G“'G $4VVVhllDfFöïÿQ.(loff†¡Ã€ŸŸ¬¬­ahhˆêêjÜHOÇÑ£GpáüùVû™8q‡†ÃÜÜB55Ü-)AZj*Ž9‚+W”¿¢î˜<9.®®ÐÓÓÃݻň¹ƒŸwïR¹T-u 3ØzÙ iöZÖÍ>ÉýËÝÃ�œ”¤rÛsçÎÂÎÎýml ¯¯oooDž;×f› ¦ò�ññq(//GúõëÐÔÒ‚··w›í„7ÿó_hkkcó×_áÌ™Ó*�·79::rssúx$Ý#;;•prrî“1”—•áçÝ»¡¦¦†ù %sΚ=ÚÚÚ8xàOäd·Øm�f¿~ЭågÝ=<°á“�ØðÉF„„„vÛ~Û£¡®¨¯¯GEy¹Ü:oo¬ÿøŒ; ˆ‹�EA~>† Á‡«×À«�믣ÌÌÌðÑÚu˜5{6 �œœŒôôt8:9aÙò˜1s¦B›°ð¡˜¿`ˆììÛˆŽŠBÖÍ›ððôÄÒe˱ðÑGÚ…B¼óî»xdÞ<èë 111±1¨¨¨@Xx8†�¡t|Ó¦OÇ;ヌÀ  äç#.6 "L˜8«?Z “n9DDDDDDDDD$�l½H(TGÛ`ëI66¶€ÜNÌå…gž}aaá()¹ ¡PˆÈsçÐ߯FéöB¡¾¾¾€„xɼ{qqqprvF`P0bc•—÷³²²Æ¼ù  §§‡“'Nàè‘#*�µ7!$4#G�BCCüy ¯‡Õmò òa¯§K+«>ÃÁbܸqÀØqã1fìX”••a÷®]*ïËÛÛÚ::€[YYÝ=Ô^' ’E]¸±X,[ndd„%K—BKK ›¿þ G–­ Æò•+ñâK/ãùgŸér ñµ%Kamm�Ç�cËæ¯QWWèocƒ·W½ƒ9sAÌÅÜlVò÷ffÞyûm$''É�Û«?Z‹ˆ)Sqêä)¹6þþ°·wÀ�ôt¼ñúJ¹q›˜˜¢ÿþ cóõõüù PYQ�>x)Ms7 Ì_°S¦NÅO.ºµué‘"Øz‘�í¨««£° UU•}=œû–NS€¡ª²Jå¶•HJLDøÐp”Ü-AfFrss[ °yzyA[G·oßF~~>I&Û¬Ù³�@ wƒ]júŒ€!!!صs Ú/ºê�w[]÷ÆÊHMMíÈa¶kÝú Ëâ±kçN¤§_ï–>þjªkÜ{Ïô‘H„ï·nÅo¾‰gž}°cû6TUuüý«o`ooo<þÄ“€´ÔT¥åQgÍž�Y³g+ÝǶŸ~ÄÞ={T?€`llŒ!!!˜2u*ÒRSñ}‹R™&N‚nSpºyp .^ŒÆùÈH„…‡Ã? ÑQQ�‡—·7\\]‘››‹¯¿úR.è•“��_ùO=ý F��­ß}+[—˜¨|Åüü|œ>uMŽ€»‡»\€ÍÈØpãÆ … `qqŠ‹‹ö7óá‡ß¿U\±XŒíÛ~ÂÐaÃ0$$zzz¨è¥²žDDDDDDDDDÿ °õ¢�vv€[Y™}:Žû�4p%†b`«#Î�;‹Å/¾[Ûر}{›ÛJËC&ÄÇÉ–]OKCyy9LLLààà¨4 %°o[ |èP<¿øE¼óö[JƒqÍݾ}Õ­^ª›‚EÝ!åÚ5T×TC Ðߺ?<=½P:¡YYY¨­é¾¾úRgß#Ý-.. ñðõõCÖÍ›8vôh»mZ –ݾ}Ö¯SÚ¦¸¸E…Š�(.*nµ¯Ø˜Ìœ>­Ý1uÅcO<�ÇžxBö³X,Ư¿üŒÝ»v¡±±Qn[iÖèùó‘J÷•š’‚°ðp888v)Àæã#éçâÅh¥™p)))î•OmÉÎÎŽNÎ044„ººäëÖv€$‹ÙÀÀPnÛÌLÉœqááá¸|ùbcbÚ ²jiiÁÅÕ���Jç�‰D¸‘žSSSØ;8tªd.µŽ¶^¢¯oS444tj^%긪ª*èééu:+):* Ï5@]]‘‘mÏ¿ˆ�»`‹ÅHLHÀÐaä4ÀvòÄ üôã�000€·�¼¼¼0~Â:x°Íþ¶lþ—/]êÄQ©fË–ÍÈÌÈ�ý¬££ƒ'-Âð#¡¥­�µkÖHV´”éèv½L[[TÊë)™ðõõÃÍ›7Û ´@~^òòòuõõ(.*ÂåË—uáêëë•¶9vôvïÚÙ­ãî.wîÜAQQ„B5X[÷‡¡¡!f>< åååøó�?ä¶537¼þÆÿµ¹O}}½.�ɼ©Ÿˆˆ)ˆˆ˜ÒêvzzòýXXZâÕW_ƒ³‹K«m¤7©´ÔwÐ�¤ IDATTìݳS§MÃ˯¼ ±XŒììl¤¥¦âìÙ3HLH�ÛÞÄÔjj’iTøi[›ÇÑr|DDDDDDDDDÔu °õiöZNömˆD]›ˆÚ–}û6\†µµâœEQUU…wÞ~ý4p§�yÜììíafÖt~ê4Lzh²l�UÓœ^�AÁعc‡BÛË—%A²²²2lýî[¼ôò+X°`!âãqçÎ�N�»'UUUá«/¿DXøP kkkäææ*dµFÔ(êávŽ…¹ ïoxÎÛsòÿÙ»ï°(®5€Ã¿©¢ `¡ˆÒAº ¢‚5Šc‹ÆnÊ51ÉMbŠ%1Æ’DMÓÜTSL³Æ^b¬±�½ ¢i0JµÐaï+«ë.bÌ÷>��ËÌ93gvwfvæ›ó�Ý»Ú`YulÙ´‰�ÿTc6œAO>Éè1OsìØ1�ûâÆ�T˜ ¶¦Ò™>tHgÊÍ2ׯ_S¿ÖÓÓcÊ»S±··'""œ?6l --MÝótÀÀ�Œ=†[m5,Y¼ˆm§uë6x¶j…—·7]»u£k·n¬\±‚å¿kKnÞ¼©€¼Û¥‹+·¡B!„B!„BˆJ“Û §§‡}ó\¸cÌQ;Ξ=‹»‡Þ>ÞlX¿®ZË8s&úžeÕ¯ýüüt–iÙ²%ÖÖ�IO/|µð={ ¥uë6ü÷•W™öÞÔJõ`zÐŠŠŠ¸rå vvvØÛ7W òòÕw\×xsúúúêr[;;ê›™¡T*9w.¾®›#îPRR²¥KðôôijU+† Îÿ>¿=.`zz:ì çܹªÑ*»w¥§§Ãúu•;–¸¸¸`ooOrr2_þïZûDÓ¦Í*¬ùòe6mú“M›þD¡PЭ{wƽøOÌÆ�póÖXj™(•JôôôX¹bùCyÌB!„B!„âQ¦W× ø7hfc‹‘‘7oÞ ##½®›óÈÛ½k'J¥ÿš7w¨µõ”�¿öÕ—_2xÐ@­1gÏ·ÓHVä‡ï¾#//ÏV­xüñ¾µÖæû¡§§‡¥¥%  €dffª_[YYkÕ)K±—~õáûÞ÷êÝ€¨¨H²²²ê¸57SSZ::ÒÒÑñ�¥T*•üöÛ¯t ÁÎÎN=/ò”*]b»àöÕZvNN 4¨°œz=í‚+½lss @Õ+òî —��­[WzYJ¥’ýÅÅ‹ÑÓÓ£±õí},??Ÿ¸ØXLLLÔcÅ !„B!„B! °=-¸�’RÇ-ùw¸xñ"Û¶nEOO�Io¿�C‹ómíìxù¿¯Ü×:,--qtrº5ÞÚ �eŽ; ÜÄU$==�%‹0bÔ(lm«—Þ²¶èëë3zÌÓ˜˜˜PPP@ll   ´?~ €Q£GkŒ+ekkKï>�päÈáßèr˜˜˜0løpz÷îCII ‹.¬ë&=ôZµjÅgsçñÙÜyÕjUǹøxŽ=ŠB¡`ð�§ÔÓ·lÞLnn.ýú÷§GÏž(îʷبQ#D£F�t.÷æ�deeaee…[ã¤EFFr.>7wwžaÆÆÆó�Œ�éܹ >>>êiii©x{{«Ì Ú‡žyö9¬­µÑþþøøøhm‹““¶¶¶såÊ�ykV¯àåWþK«V^ZËtpp`ÈSOiMB!„B!„BÜ?IYËLLLiܤ J¥’ $Àö üúËÏXZYÄÜyŸ“’’BNv6VÖÖØÛÛsýúuø¦úËoˆB¡ 1!�ììl�eŽ;ÆÈQ£ñòöÆÄÄäži·nÙBHH(žž¼òêk¼;å­0Ï¿0N=–ÓÝâÏÅóó‚ÕÛ »Œ÷"ùùù€*ˆ`oo�©©)J¥’?þÀÍ›7ÕeûåÜÜÜ ÅÏÏ�äädŒŒ�qvvF__ŸösøÐ!�åûû0tØ0�€Â„ )**TA”={vkµÍÐȈ9}\nÛ�;ƪ•+4¦õï?€.]ºbÖÀ {ûæèëëSPPÀW_~AbbbÕÞœ°ÇzƒS'Oª¿ïß|ý•z¿S*•ÌýìS¦Í˜IX¯^tèØ‘ä¤$rrr°²²ÂÙÅCCCæû-DEªÿ�ûiß¾Ÿñ%‘§NQPX€§§' 4d÷®]téÚU«=.®. >‚œœÎ�;Ç�ë×hdi‰——7úúú,]²˜Ü»öýcÇŽ±tɆ�Áû~HJJ2©©©èëéÓ²eKš4mJff+W¬ÐZŸB!„B!„âþH€­–5oÑ…BÁÕ«WÊ ŒˆšWTTÄÇsæÐ1$„nÝÃÉÑ{{{²³³8rø0;w츯巽5þÚ‰º{¯œOI!=ý*ÖÖ�ñàÀþý.S©Tòí·ß0wÞ縹»Ó¯­qŸìííË­_ ¨ ®wôê),,$##ƒC²yó&4Ê^¾|™ o¾Á 'ÓºMZyyQTTDbB;wîà¯íÛµ… Íj¬£LKGGõëÇiÍU@NWÝ2—.]Òšfß¼9vööܼy“¤ÄD"#O±yÓ¦]jHKK+,-­tÎ+--}À­©œ¤¤D:D»à`ž<„¯¿ú€S'Oòæëãy¢_üðó÷§¸¸˜ŒôtvïÚÉáǹzW�¯;mݲCC#zõêE»à`u wþ·ß¨Óž\½z•IÞ¢wŸ>·ÇÅÕ•zõê‘™™É©“'9zôï äýoÞ<âûÆÓ¥kWü(ÈÏçÌÙ3,_¶ __?Ð`;°?††FxyyáììLýúõÉÉÉæäÉ“lücQ‘‘:·cÍêUœ‰>MŸÇûâáéIPPsroÞäêÕ«8p€CË2 !„B!„B!ªOáâé§¼w1!„B!„B!„B!ÈlB!„B!„B!„BT‰Ø„B!„B!„B!„¨ ° !„B!„B!„BQõêºBˆšõù_T¹Î3g’™™Y ­ùçpqq`¾Z¥:™™|ðþÌZj‘B!„B!„Bˆ‡•ÂÅÓOY×�B!„B!„B!„âŸBRD !„B!„B!„BQ`B!„B!„B!„¢ $À&„B!„B!„B!DH€M!„B!„B!„Bˆ*�›B!„B!„B!„U 6!„B!„B!„B!ª@lB!„B!„B!„BT�Ø„B!„B!„B!„¨ ° !„B!„B!„BQ`B!„B!„B!„¢ $À&„B!„B!„B!DH€M!„B!„B!„Bˆ*�›B!„B!„B!„U 6!„B!„B!„B!ª ^]7àQgßÜ�-ihn�¾¾>……d¤§õœœºnÞ#G__Ÿå+W�‘‘ÁKã^ ´´T£Ì/¿-¤AƒŒõ.]º@§Î�ymüë.{ÉâE¬]³sss¾üúêׯÏ3gpêÔ)­ò¾¾~L›1ƒ›7n0þµWÉÎήòö<5tO Zéò»wíâ믾ԚþÝ?bmmMqq1Ï>=†¼¼<­2žž|8k¶Æ´’’rrr8Ï–Í›‰ŒÔÞÎ2666ôëß_?,--).*"1)‰ð=»Ù½k%%%ê²=ÃÂxaÜ‹÷ÜžáCŸ¢¨¨ˆUkÖÞ³ì�^~qW®\©R�º6jô ÈãÇsáÂy\\\øè“OYþû2V®X¡.7ùíw âý3*ü¥Ü¶(•J­÷ÀÃÀÄÄD 4斻̇•›»¹¹¹\¼x@ýŒ‹�­Ëf P(˜8i®nn$&&r:ê4%%%dff–[§,�=jÄpòóó`kÿyŠ‹‹Y±|¹úïþýûcdl|ÏzÛ·o£ÑQUЪ}‡ö4oîPkm¬ŽþÐ¥kWàö¾|/­[óâK/«ÿ®l=!„B!„B!4 °Õs Z:9SZZʾðÝdeݾíí뇓³+>~ìØ¶¥[ùhS*•ô «T€íÔÉ“œ:y–-W‘æÍ›Ëå´4�u¶mÝB×nÝpqq!,¬›6ý©ž×çñDZ··çÌ™hvîø«ÚÛ°sÇvîØ¡1­¬W[dT$ŸÏ�{Ïe´ àï¿ÿ¦iÓ¦´ ¬0ÀVPPÀÌÓÕòŸ±céþX†ÆáC9þ¼z¾‹‹ ãßx…BÁÏ °eËfu¯Á 0ä©¡èééÎF›˜”Äô÷¦Þs¦N™¢5­¬WÛŸÏS÷Dü§Ò××ÇÙÙ…˜³gÕ7ww”J%qññuÜ:U°ÚÕÍ�ÔÔT&Oœ A�¦ °ý®þ»gXXålÛ¶©_ÛÙÛ=t¶¤¤DÒÓÓ‰��!9)‰úùžu232Ø´éObcbˆ�‰å­ pus{­B!„B!„¢jd ¶ZbeՀ̌t�à@­æõë›a`høÀÛöo‰ŸŸ?M›6­•å+•J~øþ;”J%C‡ £Aƒ€*ÅÙSO ¥¨¨ˆïæÏ¯ó`D`P ‹. uë6å¼t),,dÁ�?’���B¡ 0(Hcþsÿ‹žžë×­eÓ¦?5Rr^¿~�ŸZÀ¶­H®H‹–-122"öŽÞjîî\8ž¼ÜÜ:l™ŠÕ­�W®ü]çßgñÏñçÆ�ü¾l)'ŽçÆ�•ªsêÔ)~^°€}{÷’ž~µ–[(„B!„B!DõI¶ZRZªJ¨óV´¢¬L)ÅEE¬Mÿ6Û¶nÁÏÏ�=ÃX¼ha­¬#1!�­[¶Ð«wo† Î�?üÀè1c015å÷eËH­ãžUVVV8::qãÆ :HJJ2-Z´ÄÝógÎTz9EEE$%%@£F–êéööö¸¹»SZZʆõëË­Ÿû‰ Í›7àæÍ›dddÔq‹nsww >N`³´´ÂÚÚšíÇ�•[G¡§à‰~ý ë…uãÆddd¾‡Õ«VQt×qeê´iøû0sú4\\]éÑ£'�,-ÉHOg÷î]¬[»–ââb�:½ûôá?cŸ×˜æï 1Þ�c°YYYñý� ´Úy÷Øb¿/[ʪ•+µÊu¬/½ü2[6ofáo¿òäà!„„†biiÉõë×ˆŽŽæë/¿T§b ¢m[ÕX]–VVÔ«W�ôôtŽ?ƺ5k*LËjmݘ~ýûãïï�uãÆ’ššJDøvîÜIÁ])-MLMyâ‰~·oO³fÍ(--%9)‰?þØÀ¡ƒË]ÏÃÆÇ×—é3fsö,SßÕî 0þ�7 íÄ·ß|ÍÎ;°°°`ÁÏ¿pìèQ233éÔ¹3ÙÙÙüðÝ| yî?c±°°àÐÁƒ|ýÕ—©r…B!„B!„x”I€­–¤_½‚R©ÄÊÊšF––dÝ«H¡Pàì¢Jw•’œ$½AjÑé¨(R/]¢{÷î,ÿ}™VС¦,]²˜àöíéÑ3Œ¤¤$:uîÂÅ X·vM­¬¯*ÊÒCž:u’ÒÒRN?A‹- ¬R€ ÀÀ@u¸¸sÜ­V^^¤¤$síÚµjuí022bÞÿ¾ "<œ/þ÷y�¶gæâuëý+óî{Ó4þîÑ3Œ=ÃûܳA£¡C‡áâêJtt4çÏŸÇËÛ›ÁCžÂÕÍ�ߟ©óØ2|ÄHœ]\8Mrr2^ÞÞ >GG'>ýäc�²ñññêqÁ7¶¦k·î\¾|™ð={ÔerrrÔ¯sóò4Æ0p †††¬Y½Z#xw&ºâï�B¡àÝ©ïáåíÍÕ«WIM½D³¦Í íÄ÷óç«8¯¿þ†FF¤¤¤‰ž¾-èÛ÷ BBB™úî�é]}|}™4i2&¦¦¤§§sâÄq(ptrâ?cŸçÊ•+;zT]ÞÚÚšé3ßÇÆÆ†ììl¢¢¢066ÆÍÍ�‰“&³léV¯ZUá6=,NGE‘••…»‡ÖÖÖãJ‚*l``EEE~þ„têJVf………4hØccÎÅs6:ª®›ùÈÛ¾}O?ó,ÁÁ퉈¯•uäææòÛ¯¿0þõ7xñ¥—Q*•ÌŸÿ­V� ºP–òÄñãªÿOgÀÀ�´ báo¿Uz9õÍÌptt¢´´”Ço�iggg@jjj ¶úßáø±£êP×nÝÈÎÎâÄñøøøÐ¤iSvïÚ¥(jÔwvqკ3ˆŠRGÌÍÍ™5{~~~tíÖMkì¾²:3gLçLt4 Jg:{ÎG´ &¸}{� Ê¹øxÎÝJgëáéy+À–¦1VØ�òrs5æõîÓçV€mùwõ«H»à` ˜S^^žÖ2Ë\¼uÓ¾¦äçç3xÐÀ]fMðñõ *2€F�aggÇöm[+¬w:J»lT”jÎÎ.( ­4‘Q:ꜾUÇÅÕµê�¯ÉII•N_jbjŠ··7Íš5ÃØØ…BõÌHQQ 4Ðzüüüøë¯í•Z¾ŸŸ?GŽÖÙ#56V5fž³³s¥–÷0HH8Gjj*NÎÎ4³±Q÷¢411¡u›6äåæj¤È,“—›wûuž*Ø[X/))¡¨¨“°B!„B!„B<$ÀVKlíìquóàïËiœŽ<©žž‘žÎ¡ƒûèöXnîž\HI!7÷f¶ôÑ·uË:wîBϰ^,øñ‡_~}33žyî9”J%ë×­cÀÀ�ƒfÍšñô3ÏðÍ×_«ç]ºt €f66ËˆŠŒ$*2ccc/]V³÷X±j5zzšz—Üõ>½5a"—/_æ•—_Ò^È=‚·º‚»ºªÔeX—k׮ݳLHh(cž~šœœ~üá{N�Ô‰?_¹�«¤²4ƒÆwõàª æææ¤éè!Ü.8¸Üz‘‘§x¬GÏJ­'ò”*½o»vå/³6\»T- ’WFεªÕ)ë©Ö1$”àöíÑ××gïÞ�´�B!„B!„BˆòI€­–\NS�#ÔÒÑ KËÛ=M ­¼066¡¸¸˜«Wn, qòòòˆÇÉÉ©Üñ’ªjà AØÛÛÇ_Û·kÌ[¶tÉ­€^ŽŽº{�Õ¦¶mU�³ãw�¿Væø±£øûP¯’ã&ý¾L•°cH¶vvêé¿þò3J¥’¡Ã†Ñ©sg�:ַƼzñÙÜy|6w#G�ªÕu½þÆ›|6wÓ¦O¯°œ——7………ÄÅŪþöVÀNŸ>}ÏutèБV­¼Ô›™™1tè0vîØ¡³NHh'<<<Ô7hØ�ÁC†Ôx:Óô«WU/Ïš––ª ¬uíÚMcz‹-:¬ü^c[6o&77 „B¡™Ô°uë6¸º¹©ÿŽŒŒä\|5jĤÉo«ÿnîàÀðá#èÛ÷ N�:ÅïË–Öh[…B!„B!„¨* °Õ’Ò’ì §¥£3v͛Ӱ¡9úúú�zé"çâcÉÎʪëfþ«$'%§ÑC¥LCó†:§·ttT¿>|ø�úõ¸_ÂÀÀ€M›þ$))Qçúþذž={âæîN×nÝÊíUTÓU½×ââbËÿM©TrâÄq:wîB`P`¥lË_FÛÀ@BC;±rÅ .§©zíøk;ñq±ê€G«V^ªžY±±ìÙ³›];wê 0š˜˜è|ßÕóMM*Õ®"gggLLLˆŽ¾Ý[ÍËÛ›¤ÄÄJ�e·ü÷e8::Ò£gVVVdfd°eófÖ¬^Un0wɒŸ¹¹Ñý±XZZ’žžÎŸÿ`ÝÚµ5Þºe ††tíÞ�àöí100 ??ÿ¾l‰ Lž4‘á#Fàêê†��—/§±tÉbþذ�_.*·î©“'yóõñ<ѯ?~þþ´ ¤°°�´´4~ýå­àæÕ«W™4á-z÷éCpp{\\]©W¯™™™œ:y’£G�pðÀ�ûÚž»%''3gÖ,† Ž··�º—iøž=åØ yæ žyöY¼Zy©Ç^ÌÈÈÐ`ÇÇ×€ˆˆˆÝ€†ææ:÷ï;Ç…4·0טg`` ³N3šÙØpåê•n©B!„B!„U§pñô{0Ýj„BÔ‰©Ó¦áïÀôiï]‰ô“B!„B!„B!*&c° !„B!„B!„BQ`B!„B!„B!„¢ $À&„B!„B!„B!DÈlB<...ü÷ÕW«T'3#“ÞŸYK-B!„B!„B!DuI€M!„B!„B!„Bˆ*�‘B!„B!„B!„BT�Ø„B!„B!„B!„¨ ° !„B!„B!„BQ`B!„B!„B!„¢ $À&„B!„B!„B!DH€M!„B!„B!„Bˆ*�›B!„B!„B!„U 6!„B!„B!„B!ª@lB!„B!„B!„BT�Ø„B!„B!„B!„¨ ° !„B!„B!„BQ`B!„B!„B!„¢ $À&„B!„B!„B!DH€M!„B!„B!„Bˆ*�›B!„B!„B!„UP¯®ð(S(´ptÂÁ¡ 4…‚›7®sáüyâQ*•uÝÄGÒŠU«ÑÓ»;V*•ܼy“””"Â÷°sÇJKK5ê,\¼SSS¦¾;…˜³g5æYXX°àç_xzô(nÞ¼ À‡³gãáá ÀøW_áÒ¥Kõ&LœDpûöüðýwlÛº•™|ˆ——W¥·ã›¯¿b×Î�|ýí|š5kVnÙ¢¢"†} € ò˯¿�››ËsÏc&>¾¾ÓŠŠŠ¸zõ*§Nždíš5dffhÕ[²tFÆÆLž8‘„„sn€��_|õõ=ËÍúà}Nœ8qÏrÿ&}û>Á3Ï=ÇêU«X¶tI]7GËà!C6|ëÖ®añ¢EuÝœû6ùíw âý3ˆŒ÷,ÙÙÙuÝœ:aeeÅ÷?. õÒ%^{õ•ºnÎCçQ?‡=HÕ9ïÝëXgllÌâ¥Ë´¦ßy½Z—Z::òÙÜyÄÄœeê”)uÝœZWv�öù¼¹ìÛ»·®›óHøå·…4hÐ@çõ½xø¸¹¹1û£�‰ŽŽfú{Sëº95bê´iøû0}Ú{DŸ>]×ÍyhÕåùH>#ñ°�[-jÝ6;ûæ”––’�•Eii �,ñòñ¥q“&:°O‚lµ(>.Žüü|êÕ«G3¼¼¼ðòò"¸}{æÌšEIII�­«gX/~ùù§ ËœOIA__³Óh ‡˜˜šrùòe²³³4æÝy³#!áœz~ãÆM°²²âÚµk¤¦ª‚zEEš´2¦¦¦øpôÈõ4'''up­<éé餧_Õ9ïÂù Ö½—˜˜³ZÓÊ•‰‰‰hÌ+,,Ôø;/7—”ó)å.ÿî}ê™gŸ¥ïý¸|ù2çSR0­oЇ‡^^^˜šš¨oäßÏgT]YYY\¼xSSìììéF�ž=Y»f5K—h@ÒÒÒÔïaýúõiÞÜ�ââbÎ�‹W—ÉÍËÓ¨ckgÇû|ˆ……ùùùœ?ŸB~~666tíÖ�®Ýº1üpù.���·_–`+“ššJFzºº�6¶¶ôîÓ‡�ÐP¦NyG+}?t}ŸÊÜxn.ñ(6|ý ==�ƒ¨�×Ew·ïÔºuÆ¿þùùùœügìólذž…¿þZ×͹oò{¦öÝïùH>#ñ(�[-±±µÃξ9EEEì�ØCNŽêF¼‰©):v¢IÓf8´hIJrR·ôÑõý÷ß©{f<Ö£/¾ô2þþ<Ö£'[·l®‘õ(•JºtíÊ’Å‹´‚AwúiÁ�ZÓÊzLmX¿Žm[·–[÷ó¹sÕ¯G�Í€�ƒ8uò$_üïórëdff¢T*éС£F€­CÇòóóI¿zûæÍuÖݹcG¹Oºß/]O0–õjûâóy÷ ¾$&%Uú‰¨€€ú>Ñ�›7oòñGs8­žgbbBHh'êÕÓWO»ŸÏ¨ºN�<É×_} €žžCBxaÜ‹ zr0™™™lÙ¬ù=]·v ëÖ®Qoß»ïMãÚµœ Ÿ }õÕ×°°°`×Î�üüóOäåæªç99;kô¤»›¡¡!>¾¾qýúuš7w iÓ¦üýwù7¶mÙÂÆ�¨ÿ611áõ7Þ¤MÛ¶<óìsÌúðƒŠß”*ø7<+ÄÃ*¸}{¦¼ý¶ÎÞ©Õùþ»ùD„‡×ZÛfVVV¸º¹‘ššÊä‰jõa«ÈS‘þL\\l¹eRSSÕç|;;»‡>À¶ð·_Ñ×Ó¿wA!„xT÷¼w¯c�ê†æí뵞aa`BÔ™+W®ðëÏ?“‘Q¹k‚‚m[·ròø .§¥ÕuSjuy>’ÏH<,d ¶ZbßÜ€äÄup T½oÎDGÐÒɹNÚöoõ×öí:t€vÁíjl¹‘‘‘Ô¯_ŸŽ!¡5¶Ìš¡äÀ�ý©ÓvtèØ‘cG�V |T„têÀêU«4‚kyyylß¶•Í›6ÕEÓt*--%"<œo¿V¥?1r†††÷µÌ¦M›âêæÆÍ›7ùnþ·Á5€Ä„þ÷ù¼r{¯ùùùcddÄ™èhŽ;¨RnVE^^«W­ÀÇ×…BQ�-B.žví‚iÔ¨Q�-3|ÏÜÝÝ c×Î5¶Üš°ß>úö}‚€Ö­9|è®nn4iÒ„ß~ù…'®ëæÕ:ËF–\½r¥Ž[R5 ++‹F�ľ}ÕÏãßÈRõdffT+-jY0íÄñã\½z•Çzô m`nÜX¥å”¥k¬W¯õêÕ«ó<úÍš5ÃÐÐ�â’Rk0e%ÜÎ>sú4\\]éÑ£'�,-ÉHOg÷î]¬[»Vk\Ä2?,X€¥¥Ï>ó4vvv yj(...èé鑚z‰•+VhôHU(ôèÙ“nÝÃÞÞ===ÒÒR‰�àÏ�Tø>·iÓ†!O Å¡E òòò8yâ8K/)7XÒ´iSz_??,--ÉËËãÌ™hV®X¡Ñ[¸6˜˜š2uê{¸{x°~Ý:-üM=¯lŒ’§ÇŒf̘1µÃÈØ˜óçÏóÇúõåî?Ílløú›oÕã^uíÖ�>�÷ÁÖ֎‚ùé§ßSSS Dpûö4nܘ¢¢"’““ؼiö—1©ÐSðD¿~„…õºqc222ˆßÃêU«ÊýŒZyyñÄýpswÇÌÌŒ¬¬LŽ9ÊÊËÉÉÉ©æ;©ÍÇ×—~ýàêꊱ±1™™™?vŒU+Wh¥Á-Kßq'}}}­±5l �;Íþèc�¿u�EÓ¤iS ˆ·��*˜WXHFF§OŸfãÆ?¸¢£'­B¡ K×ntïÞ‡-000àòå4öìÞÍÆ?þÐØ÷:uîÌkã_רïä쬵=ºÆg­ª²t;wò÷ÐX—®1؃‚hÛ6www,­¬¨W¯ééé?~ŒukÖèLU<|ÄH­s|Ec°=h&¦¦ôî݇Ž!iܸ úzzdegÇömÛ8sFó�}}}–¯\¥µœŠÆ`»s<ÚòlÙ¼™?þ 5½¶÷½²ýHט¶,[¾‚ÜÜ\ÆŒ©U·:û„ŸŸO‚³“3Å%%DEFòë/¿èl[]ìºÆÜ,ë¡äða>þhŽÆ<…BAHh(aa½hfcCýúõÉÉÉáÂùóìß¿OçØ¸ …‚°^½èÖ nܸÁÞˆ¶mÝ¢³mºÆ>¾{œÂ¨ÈHfΘ^�M× ç°[ë¨Æçú0«Îy¯:Ǻûñ ~g€*]ýÓO?C«V­@¡ ..ŽåË–ê|ø£:ç=¨ÞñÑÄÔ”'žèGpûö4kÖŒÒÒR’“’øã� :xPçzšÙØ0bÄH||}122")1‘¥µ0®qu÷‰Ê~®eãÌ;z”ÌÌL:uîLvv6?|7CCžûÏX,,,8tð _õ¥Æudu>£êë@•åeÀÀ�t¬ÖÖÖääd³}Û6Ö¬^­óA¥êëªzV•÷û~TwŸpswçñ¾}ñððÄÜÜœk×®‘’œÌ_Û·søð!õû§kœ÷~ýúkdº)--å©ÁOj”ñõõcÚŒÓ*ƒíÃY³ñðôdæŒéDEFjÍ/;·¥§_å¥qãÔí³¶¶&$´4³±ÁÜÜœ¼¼<ؾ}ÐXÎýüžùpölõ&eî5¾WU¯Éïü-øá‡0rä(ƒ‚033#-5•eË–räðár×WY_~õ5�±xÑB† �žžkV¯æÈáCŒãMZ´hARb"óæÎÕ"¦¢ñç|ô1®nnLxëÍûºð ?£ªºsLÁ?üÀÓÏ>ƒ‡‡'ÊÒRbbbX¶t ‰‰‰:ëv¬/½ü2[6ofáo¿òäà!„„†biiÉõë×ˆŽŽæë/5�«666 2__ÌÍ-¸qã1gϲzÕÊr×`mݘ~ýûãïï�uãÆ’ššJDøvîÜIA~¾Fùª\+—©êµ[Ùz¥ßu•!¶Z¢¯¯Jç ë¢£¨èvÏ¡f È�Ûc` úÊgffÝ£dåååå²7"‚ÇzôÀÉɩƒ߃GzúU:v áð¡CtìØ‘¼¼<Ž?ö¯°]¹Xkß¡øÇŒy¨T*‰‹‹¥]»`\Ý\ï+ÀV\´µµ£eË–$''Wº®B¡ MÛ¶œ8qœÌÌLJJJhÕªõëׯҀµÎ·z즧_­óàÀ›oMÀÉÙ™ÌÌ ^;¶VÖ1|ÄHœ]\8Mrr2^ÞÞ >GG'>ýäã ëúûûóÊ«¯Q\\LZZfff899ÓÊËKãÂîµñ¯Ú©………DŸ>MqI1^^ÞŒ=ÿ>˜9Sg`ÕÇ×—AO>IrrÇŽÅÉÉ™Î]ºâåíÃ;“'‘•¥yŒôõõcÒÛocllLjj*Ç�ÃÚÚšví‚iݺ ³g}¨ó"©&Ô73cÚôé8;»°jå ~_¦=€2À»ïN¥yóæœ>}C##¼½½yã­·0·0gÓŸV¸ŽaÇ3xÈS\¿v�´ÔT¬¬­ñó÷ÇÆÆF}sÒÔÔ”YsæÐ¼¹999?v SSSZyyѪ•«V®ä÷eKu.èÐa¸¸ºÍùóçñòöfð�§pusçÃ÷gj›ÄÈQ£Q*•$œ;G\l,ÍèÕ»7mÚ¶åÝwÞ®‘ñºëуq/¾@ll YYY¸¸¸Ò«wo‚Úñî;ïpõêí‹­œœ�üúCžz ¥Rɪ•+5–{÷ƒCë×­ÅÐЀ.]ºÐ¤iSvüõ—Æ“†.jŽïÙÌÆ†O>ý SSSΧ¤pøÐ!ŒŒŒ°µ³£Ïã�sî\¼ÖÍ2}}}&NšLÛÀ@ òó9wî…¸º¸2jô¼}|˜ýᇔ––�’œ¢ÞsssÂzõ"++‹íÛ¶i,7ýjzåßÔrÄÇÇ«×Õ¸±5]»uçòåË„ïÙ£.£ëFÌ믿�¡‘)))DEF¢§¯‡ƒC úö}‚��P¦¾;E+%Êé¨Hõ~ïéé‰�¯ï}·¿¦èëëóþàèèDff&§N�¤´´”¦M›Ñ¡cG µ.ÒJKK5¾wƒ‡ AO¯â$…êtÊw j‡­�ÅÅÚ碵ïUGuö‰ŽCxýÍ7ˆ9{–k×®áÙªïø¡ÎòrŸ¨®ÿŒ}ž^½{S�ŸÏéÓ§¹yó&Ö�­ñððÀÆÖVçûØçŸ'¬Wo ‰ŒŒDO¡ WïÞ¸{xè\Ǧ?7bf¦ ŽtèØ{{{öFD�ššª.SQªìêø·ŸÃªó¹>̪sޫα®ºä±ÎÜÜ‚Y³fSPXÈÉS'iܸ ~~~xyy1ëô~?Vç¼W�㣵µ5Óg¾��� ÙÙÙDEEallŒ››'MfÙÒ%¬^¥ð´µ³cöœ�033ãâ… \¸x‡L›>ƒ”*\cUFuö‰ê|®þ¤¤¤ƒ¯¯¯½þõôõ9}GG'B;uâÌ™h�ó@u>£2Õ9Ö�}þ:tèÀ¹„n\¿Ž‹«+ÃGŒ¤¸¸˜õëÖi”½Ÿc�ú=©äu؃Ú�ªû~8�‘£F£P(HNN&.6Võww' ukF�Nþ­›ïG�QŸ\]] hÝš¸ØXNž<©^žRYªµŽ¿ÿ¾¬>nYYYiéîއ§'!!¡:¯Cne…Ú¡qnéÐ1„Q£GsýÚ5’’“ˆ�‰ÁÜÜ/ooüüýÙ°~ »ý`ÕýüžÙ¹c‘§TmëÔ¹³Ö7ºT÷šÜÀÀ€™3ß§‘¥%ÉII4nÒ‡-˜8i2S§¼S#(LLLô䓜‰Ž¦m` cž~š°^½HOO'9) 7wwF�Íÿ>Ÿwß몊ýUW# >˜5‹üüâøñcZË÷ñõeҤɘ˜š’žžÎ‰ÇQ ÀÑɉÿŒ}ž+W®hŒ\Õkå²:U½vƒGïw]eH€­–bjZcyg�MLt¾µÏÛGu“é` w[ߺe �õèAϰ^|7ÿÛ]öýP*•ìß¿Ÿž=U9�ÛwèÈÑ£GŠÇƒ°cÇ_tëÞ�;bckCÄžp"£"9Ÿ’¢qÒx•ÆšÞç�…ŒŒ Nœ8A@@s>þ„=»wsüø1õ�¶Š¸ººbaaÁ•+WÔcãÅÄÄàååE@ëÖì�ˆ¸çúë›™áééɨ1cذný}mÏ?‰³‹ 3gLW§'µ°°`öœ�hLpûöZOÚÝéégžå� X±üwu:WkëÆ4w¸=nbpûö„vêDvv6S§¼Ãå[©‡6lȳfãííÃã�÷eÃí÷ÜÍÍ�ß—-cÕÊ€ê‡Óo¾EpûöŒ3†¯¾¸ÝKÉ‚·&LÀØØ˜¾ÿNc,ÂÀÀ &½ý6¯¾6ž—_Wnϼêjذ!Óf̤eË–,Y¼ˆµktß0UoÍ×^}Eôðð`Æû0zÌÓ:x°Ü´�Yòøã}ùâóÏÙ»÷öÅœ›»;ù·EÃGŒ¤ys¢££™=ëCõÓ`®nn̘ù>ȎÇIH8§µg>˜9ƒ¨(UŠhsssfÍžƒŸŸ]»ucçŽÛ½Ÿýý9j47oÜ`öìYÄÆÄªè£F�¡ÿ€<÷Ÿ±|öé'Uy+µXYY©{T}òÑG9¢zJR__Ÿ×Æ¿NÇ�Æ>ÿsfÏR×QØn÷‚ìªsޫα®:ô±ÎÆÆ†Ç�óÉÇ©¯Aû>Ñ�gž}–—^þ/¯¼ü’ÆuYuÎ{ÕùÍðæ[°±±a×Î�üøÃ÷êßÛ¶vv̘ù>Æ�àè‘£êc"ÀóÏ¿€™™[6oæ§?¢T*Q(¼0n=z†Ý÷{U¦:ûDu?×7n0åíÉ3köÜ=<Ô=‹Z´`ÞçÿÃÛÛGã¦wu>£2Õ9Öy¶jů�W?<Û­{w^þï+<Þ·¯Ö¹ü~Žue*sö ÷£ê¼ßþþŒ=†üü|>ûäNž<¡žghhÈ€�5XGŽV_ ôîÓ‡€Ö­‰‰�¹çùÿï¿ÿV—qss»g€mÿ¾}<÷Ÿ±óÃ÷ßi�:†t ü®ñ*S’“xÆ ¢¢"5ÚݤI>úäSúõÀžÝ{Ôûëýüž¹óœææîvÏàÍý\“·ttäØÑ£¼;å P(ü÷•WéÒµ+½û<^#6…BÁGsæ�œ”Ĉ‘#ôä`rrr˜þÞTôõõùþÇxûøÜ÷zªêA~F÷ÃÖÎŽcG�òé'«Ï%ý `ô˜§yñåÿòæëãË­Û.8˜Â‚&Oœ¨>æèééªñÝå•W115eÃúu,Z¸PýïÓçqž;–ÿ¾ú*/�{Ac˜ &Lœ„‰©)K/bÝÚµêz …‚ö:póÆ �öTõ$Xâ¾ IDATZªwíö(þ®« ƒ­–”¥†´±µÓš×¼y õ벞n¢öèééÑÌÆ†±Ï¿€——;þú‹ýU£ëHJJäܹs„††bbjZ£Ë¾_û÷íÃØØ˜#FbeeÅþ}ûîYç©¡CYµf­Î z­.Ÿ——W¹m›:mšFÙ¸ØXæû y¹¹8::1æ™gølî<~ùm!¯¼úöÍ›—³–ºWö4™©iýû^Ö7_}ITT<Ö£“&¿ÍO¿üÊ'ŸÍ%¬W¯r�CmƒUzÈ2e¯Û¶-¶gž{Ný™ü¶po¿3…¼Ü\¾øüs6mªø)ìª*ï»°lùŠ]Ouì�×û/;;›•·zútï^ñÅÇ… X¼h¡Æ�¨ôô«ŸE÷Çz°fõ*õy€k×®±xÑBU™=t.?==�5«o?•[RRÂ/?ÿ„R©¤C‡Žƒ÷ê݇úffìÞµK#¸ª‹±û÷ciiIë6m*ܦªjÔ¨ïð!-[¶äçŸT\U ¼;{ÞÅÄİoo„Þ�Q333Ö¯_ODD¸Æ[\l¬úG¿¾¾>]ºvàç 4R-ÄÇű}û6 E¹•û÷ïSߘU jù懲‡nÝ»k”¥«Z�°¶nÌ›o¾…R©ä³O?Ñê©û ö½êªê>ÔŽúffDŸ>­‘+/7Wã)ïsssôôôÈÌÊÒØÇ òóÕc-ß©[7Õ1öÏ?7j¤K¼xáB•Ó]צó9¬:Ÿ«¨¾º8ÖýòóOxþ¹ñRSSiÒ¤ ÞÞš7v«sÞ«êñÑÇ×7wwÒÒÒøþ»ù¿·S/]bõª•( �ï·µµ5>¾¾äç³hÑí J¥’ß~ýU+ ×ý¨Î>QÝÏõÒ¥‹êóñùóª÷éÿíÝwxTUúÀñï$„Ò ¤÷$t”®HUQ°¯î®XwíÁîZW±¬®þt)¢t�Þ¤’@$@„THÏd~LfÈ03If&õý<ÏCæÞ3÷Ì=÷ž[ÞS4#òœ=sPÿöÆ,¹71§®ûyáBmp `ËæÍ\¾|77w�ûTKë:�–<‡µçydÎþžØ0”ã²¥Kt‚k555ü´p!Õ0’ÖåË—IMM¥‹£# ‰‰:ËzôÀß?€Ó§OsúÔ)�eiii¤§§éõ˜¾xñ"Û~Ý @TtT›æÝKžÉU*ÿýækmY¨T*V®X¨·´•J¥ÝŸšs<§áW*•œÏÏÇÅÅ…N�¤ÿ�1ßþ÷�ç–Ë—sñ 5šÎÅÅ…O?ý·N@¿¾¾žm¿þª½&††…У%%%Ì›;Wç_½úrsrpvv&©áÝœÆÈQ£éÒ¥ ‡ÒÓYºd‰N:•JÅÎß~ãh£ºÉÜgesžÝþ¬÷urµ‘ÜœôèH7_?Â""9}*—ze=¾~Ý � ¦¦šÎ�mù�ŒX÷»ôþº]œ+**ø×{ïOÝRë×­åï�Îà†n`íš5m² sÏV‰1fìØ†y–6›¦¨¨�ÂK†[ÊvÌÐH•••œÉË3¸ìLÃC@c›7mb÷®]ôëߟ¸¸x"£¢pwwçÆ¡CEfF&›6mÔkháá¡>N MŽ}­.]º4;DîõbÜmã¹sêTƒóeitêÔéw3ôsvVK—,aü„ <ñäS¨T*Ξ=KvV;vl7ør¢5<üÈ#óëÖ-ïÑÚóÜ3—©ç„æ¿¶§¨[Ï–––êõJ¸ÞÕÕÕñùœÏxôÑÜ~Ç�Ü~Ç�ròÄ öíÛ˯[·ê]W¯î׈šOÏ�?ó5ÌœrµDß¾ýf Ë¿?þȤù…�:¢®3vžiÎÉÆ÷œ`ÞuÏÔúѳáÞvܸÛ7î6£Û¹¶§¥:߆çr/2PǘËÔsÂ’rmÜàNó�Ï”J¬¯éÙbɽ‰9uݵ½·íw[5‰ÅÒºN£¹ç°ö>�LÝß®®®X[[S]Uepßu´½ûöR]UERr2�;wÖö0p*•Êà4^ÞÞ<õÔÓ„†…ýÞŽè�eé3ySÇvk�vÖÜ9®Tªÿ/=Ø 3~ S×[M=+_Û¸ÄMzcŠŠÔ�©këG÷†{ø ͼ#Ñ0÷YÙœg·ö¾¯»^ÈÔ†òNçRx©?»8¢T*¹xñçóÏ1èu×õòòëë¥þÉçŸÏ!7GmïÒ¥ Oÿóâãã™1ã1žzò �º¥óq)›X¯¦¦†_·neÌØ±DDFZ–ùV¶jå ŽÉ$ïôéæWþÈÍÉá½wßá£Oþ�¯¯/q±qF{çtO// åLSUVT°aýzjjjyìñÇIJNÖ °%7tA¯««ã©èööÒÜ|õIJ6`»V}}=kV¯¦_¿þDÇÄ0xÈ�ë²5]k3�oi0¿´5^þ+Æ3BÓù0”ÏU«Vj[´ÒÔ\¦ª­­åý½Ghh“§LáɧÿÁK/¬ž`>:š¨è’’“IJNfÈ 70kæLƒ×°ßán¸êOp 3·\ÍáíãCoÃZÿÞztZ¢=ëºæÊMÕèì4÷ºgný¸wÏrss�æíòe÷ãíT™˜sN´U¹6®BÚôÞÄH]ÕÒw5×u ZúÖçÑñ^°ºªŠ½ûö2xðz÷îî]; ÁÇLJ£G�èõè²²²âÅ—^Ö·ºrÅ òóóµÁªñ&0mú=Í–‡iâÀSµðؾž(Ú`nÐ뙪™J_ÑÄ�×’�Í×[êŒ]KM½52çYÙœg·ö¼¯»^H€­�UT”“}LwšN�lpqq¥®®Ž+—/wPÎþ\ÊËËùä£ùô³9øúù1즛t&ê­¬¬Ôö(¹–æ3•JEM3½nÖ¯[˘±c9jTëþ •””´éÄì¿GJ¥’œ“'ñõõ¥«sÇ '`ŒB¡ ,,€ì,ÃÝÍ[Kv¶ºGÛµ-oú4 igggð%@Ÿ¤$¾ûö¿-ÞÖÙ³g‰Ž‰¡{÷îfæö÷ÅÍÝMï3ÍåW®XÔjG©TR~å ]qssãl£ye@=4ˆCÃ|�†ÝÜÜ ~¯&¥�ZÓ]ºt vlÛÆñã­DkÊš5«IÙ¿ŸÔƒ‰��'4,Œ©wÝ­ÇÞ777 t>sqQ�^ZÚü Ȧ”””j·aˆkÃçÆ¶ãæ®¿¿]\\P(ÔÔÔPY©ž§¨°•J…••?ÿ´°Mo:KJÕelì7¹5ó›Ú‹NÏ[{{¦M¿‡‘£F1õîi:/Ë Æw/*nÙäØ¿šyDþóå—zcÕ»ºº¶É •özÌ9þ<«WÿÂêÕ¿hç¹yä¯cÒäɬZµ²Õz•‡……qÿråÊþõî»Fƒ«íyîiêþN6ú�aMõTÒhé9¡iíæ¦?�¢•••^¯‘ö¦ÝZL»¸6½._¾Ì¶_eÛ¯¿êaoþùìsÄÄÄÒ»O�amKJŠqvvÆÍÕ�óùù:ßãj¤þër 3­\-±bù2V,_Ö*ßõ{Óžu�†¡ã ßsZzÝkiý¨™æØ±£,_Ö²c¡¤X�OWu*€›kë×'-='Ú³\--£ë¹®k©ë}S__�­�...×e/¶Û¶1xðÄ®];8h0Û·é÷^ ¡{÷îäææòï�?ÖÛßÞÞ>í’gC,}&¿^]½WµÑë‰Ú’{Õ?ãïMÔû¡´Ô²óK{¿nàÝ‘z;†ë­ÂK—pwwǧ›O‹:[ú¬lγ[{Ý×]/þ\¡çëDPHVVVäŸ;ÛâÖ8Âreee,]º€‰“&ëÓ ZÉhºÍ6¦BâÒ¥KÍÞ<�9s†ÌÌ úõë�S×®­•ua¦æºÕûúù–_[[rß¾¸ººRYQÁþý–]t E“-âýüüÝá ºtéBd¤z’à¿=ò0“'NÐùw÷Ô;©­­Å»aÉ–òðTwc× CБ|}}騳½-ÄÆÆê}¨ço°”æ;4óH4�B¡àìÙ³zCQDEGëµ¶rssÃ××—ÚÚZN5šX:=MÝí¿o¿þfåS¡PÐ30�ž��ëXCênê•J%Ÿ|ü•••Ü6~]ýý ®ë¢¢£õÒŵ`¾$Íœ®m]7È5L_Så*ô•µ þnÏû wwwºuë¦÷¹öž¸QcÂÖ¼î5U?jïmû¶ü;5ÇzHH¨^PÃÖÎŽ°&†®k-ÆÎ‰ö,WKËèz®ëZêzßßÕÕÕÚ¹fo>Âämj®ÿömxÝKMMårY½ûôÁÁÁ�¢T*Ù¹ó7½u5 �/œ?¯÷>ÎÆÆ†Ä^½šÜV[ßã[òL~½ºz�¦ûìîáቻ‘F�µäzÔØõø¦áåå…×5×…B¡½¿¶´>Ѥ�ŽŽ1øþ2>Áp½¥™»´¥ç¸¥ÏÊ�™ûìöG¿¯“[òôòÖyxU(E}}=Y×LÖ*ÚÞšÕ«)))ÁÓÓ“‡Ó~¾¯!r>~Âx�öL½ëî†ušîF«±~Ý:lllˆŠŠjÅœ sÜu÷4úËÃø6‘4lll¸sê]QUUepòöŽ`eeÅ Áƒ™1ã1ÌŸoñ\e|øÑÇ õ4ïð!¯ÎœÙfÛ4x�^–:uíÊä)Sزy³Åß¿iãF&NžŒ—×Õ”NNNÜ=m›7m4˜ÖÃà 'jÿ¶²²âÞûîG¡P°cûv�ãníš5TTT0î¶Û>b„Þ aWWW&Lœˆ««á½¶¶¶¼ÿÁ‡¼ÿÁ‡Ú|™âüùó|ûßoP(<öÄt5ÒxaÊ”):õwHh(ƒ¡®®ÎàXþ¦P*•üºu <ø ÎAÁÁ 1•JÅæÍ› ¦0` QQW_î:::rÇwhç†ÔX²xŸñ¨N�€€¦Ü~»E¿`û¶mÔÖÖ’Ü·/½z]í¥jmmÍ>„µµ50:×H[vÓM{»¬náz¬]³;;;ž}îy�sÔ÷`qqñÜd`ÞPÏ›P__�—··Ñ–Ší-ÿœúeÊÐF÷+=zôäŽ;§¶É6˯\¡¸¸ww÷6yY˜��Hll¬^=„¯¯/uuuMÂZÊÚÚš§ÿùOÜÜÜY0^‹ævk�soöëoðáÇŸðäSO]§´´”ÂÂBœœœ¸áƵŸ{xxrûíwMgê9±oß^ʯ\!66–¤ädíçvvvÜsϽMþ0ÿœ¸eÜ8m�ïái¼QÅÉ'èÕ»·¶±@LL,Cn¸Á`___†ÜpƒÞ<4]IHLô÷Ö-êëíØ±cññ¹ÚÊÝ×Ï�±coiö÷\Tßµõ}ýŸùfN¹ }§¦è×@“ëµ×}Fc÷Ýÿ€NÀ}ÔèÑøùùqþüyí3˜Ý3µ~LOOçxv6aááüåáGô^êÚÚÙqà 7ê4–+,,$==;;;¦Þu—ös…BÁôé÷`ÛŠ/†Í9'Ú«\-½7¹žë:S\ïû{É’ÅL˜0AXÔ°¶¶fܸیÎé¦yþ�ˆlrø;K¨ƒi;±±±áÞûîÃÝÝ�´4uÐíZùùêy¬bbbt>ÖÖÖÜwÿÍÎ'ÛÖ÷ø–<“_¯4÷h·Þz«öèܹ3>ôP‹Ž‰–^�4®Çç°Æî¿ÿ�àט±cñööVÏEfa€-++‹¼¼Ó¸¸¸pçÔ»t–�9’ÀÀ .—•é5¼×¼£‰��eü„‰zåÒ«Wo�9 Í}V6çÙíÏz_'CD¶¡�°pÜÝ=¨¬¨ ¶¶–.Ž]°±éL}}=öï•ù×:@uu5Ë–,á¾`â¤Ilݲ¥Rɺµkè׿‘|ñÕ8ž��²^IpP0öœ;wŽŸú©EÛØ½ke–} lŽ<ó îêÍd– ¼ýλ€ºuí«/¿ÜjÛ»yøÍ$6T|×RÖ+yùÅ[m[¦ ÒþnC¾üâ N�ÊÔÃ�=šQ£GsñÂ.\¸€Mgºw÷ÇÑÑ‘úúz¾úò m �ŽŸ�ÀÌY³±··ÇÏÏ{{{–-]Êš5«õÖŸ8iI ó£9té@×®Î:ûäó9sÈË»:ß^wž|êijjj8}ê帻¹á×½; …‚'޳¬¡w'\òÀÁFó}` ‰ôIJfÉâÅ:ËFŒEï>}uxû\½QÚ²yiii¿óÑÇ£ºªÊà²ââbÞ{÷½Ï›:Ö¯_×*�,såœ<ɬ×ß ==�ªÊJbãâptt$eÿ~vþ¦ß:ÏT»vîä·;8h}ü é‡ÒQÖ)‰��¥‹£#™™¬Z¹Ò`ÚãÙÙL½ën’ûöã|~>AÁÁøúúréRóæþOgÝ¢¢">xÿ_<óìs<ò׿1aâ$NŸ:EMM ¾¾¾ôèÙ…BÁ®]»,þMÆlÙ¼™ÄÄ^ 8�G{œ·ß|Co�²²2>ùô3ÒÓÓ°µµ%..žN�:ñÃ÷ß ›jþüùDÇÄËœ/¾$33‡.ÄÅÅammÍÒ%KŒ¶`;qâ3gÍâСt*+*‰‰�ÅÉɉƒòëÖ­:릤¤0Þ<¦Þu³ßxƒS§r9wîÖVÖôìÙ/ooŠŠ [|M2æÒ¥K|÷íyø‘¿òÂK/‘™‘Aqq1¡aax{{S\\Ì7_mÑ6,1xðþþè òóóÉÍÍ¡¶¦–îÝ»Lmm-óæÎÕK3Þ<üüºÓ»O>ùô3rNž¤  ‡.] ÁÉɉíÛ¶i„«®®fÏžÝôï?€wÞ{�”ýûµ÷iëÖ®m•cÈTË–-%)9™[Ç�#6.ŽÓ§NáìâBLL »vî¤WïÞÚag4zôè©Ó¢9²aNØè˜nçNíç{÷îÑÎS{­Å‹~æ¡¿<Ì+3_#-5•ª†zyÎgŸZ< RHhwN½‹ÒÒRŽ?ΕËe¸º¹i[mΟ7—ŠkZøŽ;GÇ«--5¸·ßqõ÷T”—³jÕÕú.)9™¨¨hª«ªpqqåþÔËË‘#™ìnToµ×¹ê_Ó¦OçÑ�1rä(jjj aû¶møè馟UUUü端xòé§yö¹ç9|ø0ee¥DGÇPSSCIII“Ãü´õ9qþüyQÑÑüû³9dgeáååEXx8µµµz×0sÍùôSfΚ̈́‰éÝ»7§NŸÂÇۇа0”J%sæ|¦×𾤤DûŽfÚôéŒ9R;òL�ž=ñõõåí·ÞÔIcγ²9ÏnÖû: °µ¡¼S¹X)8:uÅÞÁ�êêjÎçŸâxö1ƒ-3DûX·n-ãÆ�ÇÛÛ›!7ÜÀ–Í›©­­eÖÌ™Œ½å LpH …‚‹/²gÍj–.]Úâ.ÝuuulÞ´‘ñ&6¿r é´ºuoÍ0”׎‹l)77w£-Gê|¿ IDAT:zXS{{{�–zËìµÿ_¼ègòòNÓ»Oüüº†•µ5ÅEE¤ìßǪ•«ÈÉ9ÙÙ6ÊÕÕU=de%………ÉÌdýºuFóåÝp¡m¬S§N:ŸÙÛ_mAYQQÁ+/¿DRr2ÑÑÑxxzèä¤Úb×Î�¬]»†ºº:@ý0¯éi–z@2p�””ý<ðÐC„††ê�íîë닯¯zøÍºº:ÊÊJÙ¿o[¶lfÏîÝÆ¾’€ãÃM{àjêXHIéØyçÍ›KXX7Ý<777.]ºÄ/«V²léÒV«ÿ“�?"33“a7 #..^=üp~>Ë—/cåŠFçyKKKcñ¢EL¹ývúöëGee%[·laþ¼¹ÇéOKMåé'ŸàÖq·‘�˜H|Buuu^ºÄÖ-›Ù»w¯v¨Ý¶òÕ—_NïÞ½{Ë-z“Š¿ñúlî½ï>ú$%cggÇéS§X±b¹Å­a5ʯ\ᥞgÂĉôíן¾}ûQ[[KvVkÖ¬æ·;Œ¦]øã>b$îîî²vÍ–,^dðXX²x™‡3ö""#INö§¢¼œ‚‚víÚŞݭÌ\¿n.\`ܸÛ %"2’¢¢"Ö­]ËâE?STTÔ*Û1ÇÒ%KÈÏÏ'<"œ¸Ø8l:wæÒ¥KlÞ´‰eË–lõVWWÇ;o¿¥~ :ŒÀ  ‚CB(--áôéÓ<�¢–Â�/æÌ¡´¤”>I}vÓMÚ—›û÷ïï�ÛÉ'xîÙg˜z×]„††5´öÏgþ¼¹¬\±‚ÿûázizôìÁíwè÷‚ŠŽŽ&ºÑy�ØÖ­]KçζŒ5оýúi[,~ñù‹æŽõKˆÎ�m‰ŽŽ&88˜.]ºPZZBjj*«V®àPzº^š1coÑ»t~gAA�ÎKgMÙÙÚÙ1fìXƒy±¶¶Ö °�eçž½ƒƒvÈ•t¿£±åË–Ò©S'n>œÀ  .^¼È°níZ†�0<Ô‹9çÄo¿íàJù&OžBXÃCzZZ*ß÷¯Í~½ÉII¨T*ÒRSùñÇÚ¡l5̹î�yõcAAÏþóŒ3†~ýúJ§N�(**"-5•ýû÷é]#Î�=Ë Ï=Ë]wO#..ŽnÝ|9yò³^›É�7mµ›¹çD{”«¹e¤q=×u¦ºÞ÷÷µùëѳ'eeeäæä°iÓF£#åhÞ�Ý=m:‘‘‘Œ3…B¡`s°·7xÏééé©óùÖ-[ ØŽ=JAAžžžTWW³w¯ñ£>þðC²oÉæÆ¡CIHL¤ºªŠÌ#™,\°@=…@6hùýLŸ¤$ƒ£]\ÀÛºe³NðÆÜgòëUÖ±c¼ÿ¯÷¸ãŽ;ñõóÃÁÁ�=»w1wî\^}µù€L¹i´u™«¨¨ˆ÷ß{�{î»z ;xð ?Οߢ¹ÏZâøñã<÷ì3Lž<…ظ8 HEy9{öìféâÅ72eCãw4ñ ôIJ¢¦¦†üü|þï»ïÈÌÈÐYßœgesžÝþ¬÷uŠ�Èø?Þ¯B!:È˯¾JBB"3_}…ŒÃ‡›O ,²`áOØØØ0yℎΊâO¬ORÏ¿ð"åW®ð÷¿ýµUêÅŸ\ÄR× !~OÂÂÂxë�wÉÈÈ`æ+­7Z˜øã’9Ø„B!„±±q€zø ® !„B!ÄŸƒØ„B!„±qq”””°ú—_::+B!„B!Ú‰ÌÁ&„B!„xúÉ':: B!„B!Ú™ÌÁ&„0Ë£3#$4Ĥ4óçÍc_“×þ}ôÉ'&§y}Ö,ŠŠŠÚ 7Bˆ?“‘£F3jô(“Òìݳ—óç5¿¢Ð#û[M®{B!„B!„šØ„B!„B!„B!„0�ÌÁ&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ $À&„B!„B!„B!„ :ut~/œºvÅËË7ww\Ýܰ³³`ÝšUTWUMçàÐ…ˆ¨h<½¼°±éLEy9y§s9ž�…J¥j¯ìÿi,Z²Ô¤õÿþ×G¸xñ¢öï2fÌXzôè�••gÏžeãÆ lX¿Þhy3iòd¢"£°³·§ðÒ%vïÞÅ¢Ÿ¦ÊÀ±1oþlíìxî™g8qâx‹óУ·�OLL,...”——s© €Ã‡Ù»{7G�5é·7ìٯ·xý‚‚þöÈÃ<õ�0pà &×ÏÎÊâ…çŸÓùÌÚÚš‘£F1xðü°²²¢¨¨ˆ¼¼ÓÜÊ9æh�rú>ûü |||xè�û)))éèì´™ž��¼ÿÁ‡=z„—_|±£³#„B!„BˆkH€­…BBÃñèaRGG'ß8 ʯ\¡¬´W7w"£cqs÷`ïî�dkeG�Ñû,""€“'ORSS­³¬¦¦Fûÿ;§Neò”ÛQ©TäääPWWGHH?òWÂÃÃùôßÿÖûî„„D^xé%¬­­9þ­—/KÊhä¨Qz6!®Gß}ÿNNNL»kªÁÀ~kùç3ϪÏé·Þ$eÿþ6ÛŽh_R®B!„B!DÛ’[ •–”PY©îaRVZˆѷ4›&¡WolllÈÍ9Izêììì4d(Þ>ÝèÑ“S¹9m�õ?C-¼5½Ÿ>ùèCΞ=k0]PP“§ÜŽR©ä�Ù³8tèÌ~ãMn¸q({÷ìeÏžÝÚ4¶¶¶Ìxüq¬­­Y0‹- K—.¼òêLBBC™:õ.¾ýoÓ½sšÓµkW�ñ�:uâ¿ß|ͺµkµ=‡¬¬¬HìÕ‹øø‹¶‘“sRoßizµ]¾|¹E-ç7oÚÄO lÑö¦L™BDd$'Oœàý÷ÿÅÅ ´Ë<<<1rÕÕWƒdæ–«9Ú«\5ÒRSùìSuðÖÊÊŠ�ƒñð#eâ¤É±vÍíº)ûSèÕ«7qñ Ú|5æåí���õõõ¤¦¥ê-7¥Œ4¾úêKrs®ÖS7Î_ÿöw¹yøÖ­½š?SË ¬¬L§|ß~ç]BÃÂXºt)›6n0˜'KÊH¥RѳgOÂÂÂÈÊÊÒ[þ{¶~Ý:Rä|~~GgE!„B!„Bˆ?<™ƒ­…NžÈæhf/œ§¦¶¶Ùõ�]\ps÷ ¶¶–ŒCW‡…ªªªâè‘ ƒCÚ,¿Â4£ÇŒÔMp Ô=g–-]À˜[tƒªý ÀÅÅ…sgϲdñbíçååå|óÍ×€:akkkQÞú$%aggGJJ kV¯Ö–¯¾¾ž”ýû[-ØÓ^ ¨‡êk„u/«ùóæ’™™ÑYk·r5¤¾¾žíÛ¶ñùgŸp×ÝÓèܹ³vù�u„ððplíìôÒÇ7ô^;vô(åW®´zþ6nØ  4÷í×WgY{•«%etèP: îÅöG³wÏV­ZIaaaGgE!„B!„Bˆ?<éÁÖF¼¼}(¸xAg5€óùçP©Ttíꌽ½=•••‘EÑHb¯^¤¤è¡´ÿ~¦M¿‡ÈÈH�òJLÔ¤IÑêóxv6eeetíÚ•èèЮ¯¥ÜÜÜ(°pN±ë‰æ7],¸þ~S{•kSvïÞEqq1®®®$%%óÛo;õÜwgòòèîïOtT´ÞöµÃC¶Q¾4²³²éÛ·®®®:Ÿ·W¹ZRFy§ó°édÀ�ƒøîÛo¹bB ÒÇLJÎ�;S§Tr®{M6¦°Rpë¸qŒ9 OO Ù¾íW/ZD­�Æo¼õ–v¸T�ææ`S( 1‚a7ÝL÷îݱ²²"?ÿÛ·mç—U+ n "2’ÛnO`P ÎÎêy /^¸ÀÁƒX¾l™ÎЬ|øñ'dgeñƯs÷ÝÓHJNÆÑÑ‘üsçX°`>ûöî5¸�nݺ1yÊbãâpvváÊ•+=r„Å‹~æäÉ“­’fÁŸ°±±áÞ{¦sÏ=÷�œÜ[;;NŸ>ÍÊå˵ç\kii¹›“pîü:ÿ¸`>‹~þÙ¢>žIS¦L�RÉ¡ôtþï»ïšýmÿùæÜÜܹÿ¾{ñóócÊíw‚••çÎ�åçŸ~bÿ¾}Úõ?a"ýú÷ÇÓÓ“ÚÚZrssX³z5»vîÔûþ 'r÷´éü´p!¹¹9Lžr;þþþ”——“²óçÍ£´´´Ù|šÂ×Ï�{ï½�¨¨(P(ÈÊÊbá‚ùz=q--W!„B!„B´œØÚH׮Δ5Ì!ÔX]]åtéâˆSWg °u0'''\\\8“§?Õ¹³gQ©TXYYáççÇñãÇðP§9cx¼<¢££ñð·(àq±!°–Ø«×& {ñâE|||0` Îƒ×ƒö*צ¨T*²²ŽÑ·o?BÃBu^>8�Bwââu¶¯P(ˆ��Ô�§¶dc£¾téÎÅ×^åji­_·ŽÈ¨(†ÆÊ+Z¼Ý§ÿñO‚‚ƒ)**äá‡2/ó͸ãŽ; %##ƒÓ§OÃä)·Î³gé7oÚDzšºWÞ�nÐ{±nÈãO<Éà!C¨©©!ãðaê”uDGÇ0mútx}Ö,½†!ý àéü•JÅ‘#GÈÌȤ«sWzpÇ�SÙ¼i“Ážs666Ìš5W77rsrðôò" Gžyö9^~ñ½à@Pp0³fÍÆÞÁ�3gÎpìè1¼}|èÛ¯½ûôá½wÞÑ+SsÒh¼ôÒËøûûsøða:ÛÚÃSÿøÎ.άþå—f÷eKµ´\+*+ùiáBmºñ&йsg–,^L]]�öóÌŒL‹ó´ú—U8::0`à@ºwïÎŽíÛ9wîœv� ×ôDmœ¯»§MG¡P�››KÖ±cØÙÙNb¯^FçŒ3e8ˆ'Ÿ~€£GŽPVVFdT³ßxC§goS˜ñØãÔÕÕ‘ŸŸ�££#AAÁDEGkl¼ùöÛøûPZZÊ�”ˆŠŽ&**šE?ÿÌ� æþþÄD¦Ü~;999ìß¿�àànºy8ÑÑ1<ÿܳ&ð›âìì›o¾EuM ©i©xzzOtt4o¾ñ:‡ÒÓµëZR®B!„B!„0�ØÚˆ½½=€öSXxž^ÞdN§¤¸˜ªª*ºtqÄÞÞ¡#³)P÷Ð()шÖ××SVV†³³3îÚ›&�¡4 ž·ÀÝÃâü¥ìßOqq1ÞÞÞüû³9lÙ¼™´´TŽggS]]mÑww”�60mútþòðÃôêÕ‹Ý»w“™qøºxé×^åÚM�Eïk&)))Œ»m¼v8H�àà`¹té§O�jÓ¼Å4òvïÒíÙÑ^åjiíÚµ“û|�á#F²jåJ½ UG  áõY¯i‡ªuvvæÍ·Þ&>>ž¡Ã†±yÓ&�õÿÖl€­_ÿþ 2„’’^~ñΟ?¨çz|ýÍ·ˆ‰‰eìØ[X±b¹Nº‰“&¡P(xÿ_ï±g÷Õ¹( ½z÷¦ÂHà¿g` )û÷óÒ‹/P]]�B¡àÑ�qãСŒ3V/À6cÆcØ;8°bù2þ÷ÃÚ²3f,<ô�>ö{äa�Þræ¤ÑpusãñÇfP\¬GDDðÚì×™~ϽìÙ½»Õ†Ûli¹VVTèÌ“8z̘†Û"ƒ+K4hн{w¶oßFÊ~ýžÜ�%$$2mú=TUUñþ{zP»¬sçÎŒŸ0Áè9ÕÒýmooÏÃ�<‚B¡àƒ÷ÿ¥íEfïàÀk³fÜÂ!¶ï½ï~V®XÁO Ô–¿‡‡'þþÚu¦Þu7þþdddðÖ›oPݰŸCÃÂxmÖl&MžÌ¾½{9qâ¸Þ÷‡……1Þ<–,VÏimmÍ?þù É}ûrÇ�SùoÃ�µ–êÖ­à½wßÑöx¼åÖqÜwÿýüíï�2ãïÓmn¹ !„B!„Ât2[±î¤Ž]*•JlllˆˆŠÁÝÓаõçuêÞ�:YwX…Z㹬 ½€mü¹��½ö3»†tÍ¥±70W–)ÊËËyïÝw¸pá®®®Lœ4‰Y³_çûÿÍå¥W^%11Ñ¢ïo-·ßq‹–,5øoÂĉ:ë®X¾Œ5«W£R©èݧ�ΘÁœ/¾ä‹¯þÃ]wOÃÑѱƒ~Eû•ks4/Óºè|~ôÈ***ð÷ÐÉŸ�ÀÁ&zÕ™RFײ²²Â§[7úËÃDGG³iãF6mܨ³N{•«¥eTWWÇ–Í›ñõõ%&6¶UòÔZvîüMgÈÒÒRþ¨¸ »é&‹¿ÿ¦›‡°dñ"mp  ¬¬Œ¹ÿûA½Îðázé\]ÕÇZö51•JEÊþýTVTÜžJ¥â¿ß|­m  R©´½ƒCtƒ$¡aaôèAII óæÎÕ Ò¬^ý ¹998;;“””lQšÆ~Z¸Pì8zô(¿íØŽ�� ƒ‡ 1˜Æm]®íiâäI,[ºD'¸êsï§… �6þhéþNNîKGG2Ö¢±²¢‚¾ÿ¾ÅyÍËËcîÿ~Щ+.]*àà�€: vãС|ûÍ7Úà¨�õ Ö£P(¸éæ› ~ÿÅ‹Yºäê<�J¥’ÿû?õ–7Þx#ÖÖ­w�÷Ý·ÿÕNô—U+9wî^^^ÄÄ\_õ˜B!„Bñg!=ØÚAmm-çóóñððàlÃ�f EgJh5. c­îµŸZÞLšÖè“�•Åã3¥W¯Þ$$&E@@‰‰‰$&&²jÕJþïÛo-ß�ŠŠ )¼d¸·GQa‘Îßõõõü÷›¯Y¹b9ý :&†ˆˆH<==™8iC‡ ãµW_álÍsÕ"íP®fl¥RIZZ*ýû .>ž­[¶¯°H9`ô;M)#�÷?øPç þõÞ»:½˜4Ú½\-(£ ë×1î¶Û1r¤ÎðjMyö™šœESn„Ñ8tH�¿àà …E=îÂBCHKMÕ[–ž–†J¥ÂÏÏ{� YNN‰‰‰<ðàCüüÓOœ>}ªEù(,,Ôs«QÐ0GŸ“““Îç¡ yËÈ8¬7D%@jj*= ½:lª9i;|H¿ì:Ä 7%$$´Ùß×Rm]®íÅÖÖ–ðpuC¡�6˜œ¾¥û;¤¡\ÖßoG23©­­ÅÆÆ¦Ùí­þeU“Ë»w÷ÇÞÞž’’N�ÊÕ[ž–šÊ-·ÜªÍϵ2Ö+·‹.pñâE¼¼¼ðóóãôéÓÍæ³9………:C<‚ºž;|è¾¾¾„„†’žžfñv„B!„Ba °µeÃ\)šÖË{wÿ¦³Üªáóº:ý‚¢}U5jißÙÖV§»†­­múW—UWWãàà`t.Ci,¡T*Ù·o/ûöíÀÃÃQ£ÇpÛøñÜrË­LI!-­ã^°mܰQgh³–¸xñ"Ë—-cù²eX[[Ͻ÷ÝO÷îÝùû£3xéÅÚ(·Æµw¹co¯î}UQQ®·ì@Êú÷@||[·lÁÖÎŽððpjkkI7ð[Ü2:yâ•UUØvîLwxü‰'™U<“¬cÇ ¦iërm�2:þ<éii$'÷ÅÕÕÕ¢ü´¦¢"ý@gII *• (/×?&ZÂÚÚš. ½ m§ººšŠòrº8:âìì¬`ûþ»oéæó"ýú÷§_ÿþ”——““s’ô´46¬_ÏåË— nÓÐ0žš^8×öîqvVÏ…i,Ø[T¤kæÌ47�îrýtšVÆÒ˜£-˵=¹ººbmmMuU•Ñ!Z›ÒÒýíì쬳¬±úúzJKKñhÁ0½ù×¥®¥ÙŽ¡|ÁÕãÊÅÅÙàòâbÃéJŠ‹ñòòÂÙÅZ!ÀVl$šík~‡B!„B!Ú— ÙF*棱32D™�­]Ãz†‡Õí§¨Ñ;.^R) mO‹ÆóñhÒ9y «}q×Jsø\ëÒ¥KÌýßlݲ€¤ä¾m²�ö¢T*9xào¾>•JExDN]»¶{>:º\5<½¼¸Ðh?�ƒRP©TÄÆÅ¡P(ˆŽŠ¦S§Ndfd [âóÏç0ó•—yþ¹gyä/‘––†­­-3f<Ö¢áÏÚ¢\[«ŒÖ¯[‡µµµÑáß:D3½˜Ú¼—“¦{õ5Û9sæ O=ùo½ñ+W¬ ÿÜ9¢¢¢¹ëîi|ðÑǸ¹¹ø2P5Ì eʦ�/W4dMÕè3ÓÓ´:â7]åªP(  »¡|+))!çäI\\\èA\B<))ûÛ,O žð“�>¤üÊ|ýüLš;ª5˵µÊhÿþ}róðXY]—C7wý@•‹‹ …‚ššmã s(•Jʯ\Qo§Ñü}¶¶¶888†µµµ8�Â÷ÿ÷Ï?÷,�þí¯=z777n7Îì|ihzD¹¹ëç ®Î§9ŽÌMÓ˜¡ýàââÚds´e¹¶§ââbêëë±µ³3«‡_K÷·¶\Ýô{—ZYYµÚµ¡¤¤Ôh¾\ÝL?~àjo¼Ö:† ?Ðèø6£7¡B!„B!,w}¼Qüºxá^Þ>z½<¼}º¡P(¸\V&=Ø®iiêùˆz÷,±W/Ž=ª3dš&M¯^½õÒáììLmm-‡32,Ê[s½„üºû†‡b»^5õ›4ÃÓAë¾àn©ö*צ$÷U[XYQÁþýû ®“’’@||<ññêÛ�Æç_k-eee,]º€‰“&ë”e{•kk•‘R©dÓÆMxxxü®kùúúÒ30Ðh`¯5ÄÄÆê}ÀñãÙ÷tÊ>®ØÆ7ÌÙ×X\\< …‚³gÏêÔuưjåJ¼½½-ÊÀñluÞ¢£c Kñ �dÍzæ¦i,&6Nÿ³˜è&Ó€:°Ò30�ž��têÔühÛæ–«f8Mc½á[Km]˶S]]ͱ£G¸yø“·ÓÒý��•@TtŒÞú‘‘-š­%ΜɣªªJÝX¡G½åšºÕر­í%©áé鉗·7UUUœi˜w÷ZöÚãDZaØÖ¦¸»»Ó­[7ýí7C†b@ËËU!„B!„æ‘[)))¦¨¨¢b®¾P²µµ#2JýBää‰ã•=q�µkÖ0즛ˆŠŠÖ~îëçÇĉ“XýË/:i~Û±ƒË—/Ó½{wÆO˜¨ýÜÞÞžú ›6n& X| ~IDAT´xȾ^½{óâË/eàE^ß¾ý5j4ûöîµh;íéåW^eü„ Ú¡75œ��yâÉ'Q(=z¤Czx¶W¹beeÅ Áƒ™1ã1ÌŸOu£9;p@`rã�øûpîÜ9Îçç·zž Y³z5%%%xzzrãÐaÚÏÛ«\[³Œ6nXO}}=q /Ò›òäSOóþòêÌ™æg¾ Ô©ƒ¹ãŽ;ؼi“Åß¿iãF&NžŒWÃ0¤NNNÜ=mZÃv6ꥻmüx½^CVVV 0€sçÎê¥1UVVyy§qqqáΩwé,1r$��A\.+Ó :›“¦±)S¦èôÄ eÐà!ÔÕÕ±cûv£y½eÜ8ÞÿàCÞÿàC<<=›ýmæ–륂"£¢šÝ†% .ª·Õ‚í,Y²€ &hPÖÖÖŒw›Ñù[º¿÷íÛKù•+ÄÆÆ’”œ¬ýÜÎÎŽ{î¹·å?¬J¥’_·nà�ÔÉwPp0ÃGŒD¥R±y³á2òòöfÜm·iÿ¶¶¶æž{ï`û¶_Q* ϳ¥=~úöëߢ¼Þwÿ:ÁÜQ£GãççÇùóçÉÈ8l0�)å*„B!„BÓ5ßìZê^gaá‘ê?Å8úõH}½ºåùñìcä7zɘv …A7 %0(O//ʯ”ãæîŽ�� /œçô©œöü ¢ ÇŽeÅòeŒ»m<³^�ãÙÙÔÕÕ޵µ5Û·mc×®�:i*++ù|Îg<óìsL›>�aÆQXXHPP]9“—Çüys�nóÑÇ3(..æ½wßÔÃöêÕ›^½zsùòeÎäåQ§TÒ­›ê»Ö¯#==­•ö†yn~3‰‰‰—)땼üâ‹Ú¿�ºveÚô{¸{ÚtòNŸ¦¸¸'''ü°±±áòåËüçË/Û+ë:,-×1cÇп¿ñ¦ï½ûÅÅÅÚ¿ã˜9k6öööøùùaooÀ²¥KY³fµÑï9ž�MYY={ö®ÜšbJ5¥ººšeK–pß0qÒ$¶nÙŒR©4«\»víÊ /¾¤ýÛ? €‰“&qsÃÜhDzŽñß~«]ÇÒ2j¬°°�””ý$%%7¿r;8qâ3gÍâСt*+*‰‰�ÅÉɉƒòëÖ­:ë&%%¤ýÛÇGÝÃeèÐaD7êùó˪•”——°kçN~Û±ƒ�ƒñÑÇŸ�~(e�’ØØXº8:’™™¡í•ÖØÝÓ¦s÷´éääœäܹsX[YŠ———.]2˜Æs>ý”™³f3aâDz÷îͩӧðñö!4, ¥RÉœ9Ÿé�ÍI£QVVÆ'Ÿ~FzºznÁ¸¸x:uêÄßOACp«5˜R®�mÛö+aáá<öø$'÷m˜TEêÁT>ÔjùÛùÛÆO˜ÀÈQ£ñòò&ïLõJ%ùùùÚ ¬ÆÁ˜?oSﺋWf¾ÆÉ'8{î,vvv„……ãììÌúõë n§¥û»ªªŠÿ|õO>ý4Ï>÷<‡¦¬¬”èèjjj())1kˆJCæÏŸOtL,11±ÌùâK233ppèB\\ÖÖÖ,]²Äh¶ãÙÙL¿ç^úõëÏ…  Á§[7.^¸À‚ùó[%çóó çߟ~FVVžDDDRWWÇŸÏ1ÚÒ”rB!„B!„é$ÀÖB�;ÛjçâhÌÙåêü ¶¶¶:Ë._.cÛ–MDDEãáé…§W**Ê9ž}ŒÙYõ%Z×ßONN£G�Á? +++N�:Ŧ�Y¿n­Á4ûöîå¥_`â¤IDDDâåíMaa!7ndÑ¢Ÿ›f- !�`Hã�à_ï¾KRr2AÁÁø`ooÏåË—IIIaóÆ�ìÙ³ÛüÞJÜÜÜqs3ýúõ#>!///|ýüPÖÕ‘îdåŠå:ä¥%åêáá© |ríÐf®®®êá ++),,äHf&ë×­#'çd“yT©T<� 7à`Jó6Sʨ9ëÖ­eÜøñx{{3ä†زy³YåjccChX˜Þ÷{{{k‡,¯(×[nI]kýÚµ×M€má�  døˆ‘¸»»STXÈÚ5kX²x‘Þ5£OR75!»qèP�¿·nÙ¬ °|òñGdff2ì¦aÄÅÅceeE~~>Ë—/cåŠ{Ý|õåÄÅÅDRR2õõõ\äçŸ~â—U+¹Ò0·›¥Ž?ÎsÏ>ÃäÉSˆ�‹cÀ€�T”—³gÏn–.^Ìñãú=¿ÍI£ñÆë³¹÷¾ûè“”Œ��§O�bÅŠåMö^3‡)åÚØºµkélÓ™¡7 £_ÿþÚú£ªªªUl¹¹¹¼ûö[L˜8‰ˆÈHíÐȇÒÓ b–,^DfÆaÆŒ½…ˆÈHzôìIYY¹99lÚ´Ñh@Ó”ýýÛo;¸R~…É“§Ö,MKKåûï¾ãµÙ¯·Úo/¿r…—^xž 'Ò·_úöíGmm-ÙYY¬Y³šßvì0šöÀ�,[¶”É“§Ð·_?***ؼióçÍÕÎíÚJJKxç�·¹÷Þûè“”„J¥"-5•\ NÓSËU!„B!„¦Q„DÆK”G!„ þ„�� “'Nèè¬ü)üÑö÷„‰¹{Út~Z¸�ŸþØÑÙB!„B!D‘9Ø„B!„B!„B!„0�Ø„B!„B!„B!„0�Ø„B!„B!„B!„0�ÌÁ&ÄÌGŸ|brš×gÍ¢¨¨¨ rÓ1BBBxô±ÇLJSTXÄë³gµQŽ„B!„B!„Bü‘H€M!„B!„B!„BÈ‘B!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜@lB!„B!„B!„B˜àÿ}zR†i©ŸIEND®B`‚bpftrace-0.27.1/libbpf/000077500000000000000000000000001526721631600146365ustar00rootroot00000000000000bpftrace-0.27.1/man/000077500000000000000000000000001526721631600141535ustar00rootroot00000000000000bpftrace-0.27.1/man/CMakeLists.txt000066400000000000000000000001431526721631600167110ustar00rootroot00000000000000add_custom_target(man ALL DEPENDS adoc_man man_man) add_subdirectory(adoc) add_subdirectory(man8) bpftrace-0.27.1/man/adoc/000077500000000000000000000000001526721631600150615ustar00rootroot00000000000000bpftrace-0.27.1/man/adoc/CMakeLists.txt000066400000000000000000000016421526721631600176240ustar00rootroot00000000000000find_program(GZIP gzip REQUIRED) find_program(ASCIIDOCTOR asciidoctor) file(GLOB FILES *.adoc) set(GZFILES "") if(NOT "${ASCIIDOCTOR}" STREQUAL "ASCIIDOCTOR-NOTFOUND") foreach(FIL ${FILES}) get_filename_component(NAME ${FIL} NAME_WE) set(MANPAGE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.8) set(GZ_MANPAGE_FILE "${MANPAGE_FILE}.gz") add_custom_command(OUTPUT ${MANPAGE_FILE} COMMAND ${ASCIIDOCTOR} ${FIL} -b manpage -o - > ${MANPAGE_FILE} DEPENDS ${FIL}) add_custom_command(OUTPUT ${GZ_MANPAGE_FILE} COMMAND ${GZIP} -nc ${MANPAGE_FILE} > ${GZ_MANPAGE_FILE} DEPENDS ${MANPAGE_FILE}) list(APPEND GZFILES ${GZ_MANPAGE_FILE}) endforeach() add_custom_target(adoc_man DEPENDS ${GZFILES}) install(FILES ${GZFILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man8) else() message(WARNING "asciidoctor not found, building without bpftrace manpage") add_custom_target(adoc_man) endif() bpftrace-0.27.1/man/adoc/bpftrace.adoc000066400000000000000000000432051526721631600175030ustar00rootroot00000000000000= bpftrace(8) :doctype: manpage :toc: true :toclevels: 1 //// Style guide: - one sentence per line //// == Name bpftrace - a high-level tracing language == Synopsis *bpftrace* [_OPTIONS_] _FILENAME_ + *bpftrace* [_OPTIONS_] -e 'program code' When _FILENAME_ is "_-_", bpftrace will read program code from stdin. A program will continue running until Ctrl-C is hit, or an `exit` function is called. When a program exits, all populated maps are printed (more details below). == Description bpftrace is a high-level tracing language for Linux. bpftrace uses LLVM as a backend to compile scripts to eBPF-bytecode and makes use of libbpf and bcc for interacting with the Linux BPF subsystem, as well as existing Linux tracing capabilities. == Examples Trace processes calling sleep:: ---- # bpftrace -e 'kprobe:do_nanosleep { printf("%d sleeping\n", pid); }' ---- Trace processes calling sleep while spawning `sleep 5` as a child process:: ---- # bpftrace -e 'kprobe:do_nanosleep { printf("%d sleeping\n", pid); }' -c 'sleep 5' ---- List all probes with "sleep" in their name:: ---- # bpftrace -l '*sleep*' ---- List all the probes attached in the program:: ---- # bpftrace -l -e 'kprobe:do_nanosleep { printf("%d sleeping\n", pid); }' ---- == Options === *-B* _MODE_ Set the output buffer mode (applies to terminal and file output `-o`). Valid values are:: *none* No buffering. Each I/O is written as soon as possible + *line* Data is written on the first newline or when the buffer is full. This is the default mode. + *full* Data is written once the buffer is full. === *-c* _COMMAND_ Run _COMMAND_ as a child process. When the child terminates bpftrace will also terminate, as if 'exit()' had been called. If bpftrace terminates before the child process does the child process will be terminated with a SIGTERM. If used, 'USDT' probes will only be attached to the child process. To avoid a race condition when using 'USDTs', the child is stopped after 'execve' using 'ptrace(2)' and continued when all 'USDT' probes are attached. The child process runs with the same privileges as bpftrace itself (usually root). Unless otherwise specified, bpftrace does not perform any implicit filtering. Therefore, if you are only interested in events in _COMMAND_, you may want to filter based on the child PID. The child PID is available to programs as the 'cpid' builtin. For example, you could add the predicate `/pid == cpid/` to probes with userspace context. === *-d STAGE* Enable debug mode. For more details see the <> section. === *--debuginfo* _DIR[:DIR]_ Add the directory DIR to the search path for DWARF debug information. Paths may be absolute or relative to the traced binary's location. Specify multiple paths either by separating them with a colon (`:`) or by repeating the option, e.g. `--debuginfo=/bin/debug:./lib/debug:..` and `--debuginfo=/bin/debug --debuginfo=./lib/debug`, respectively. Debug files in these paths are matched by build ID when available; prefix a path with `+` to enable CRC32 validation when needed. Files that do not match are skipped. By default, bpftrace searches under standard debug paths, including `.debug` relative to the traced binary and `/usr/lib/debug`; it may also query available debuginfod servers. Split debuginfo format (`.dwo`, `.dwp`) is not yet supported for this option, but continues to work with the default probe binary path. === *--dry-run* Terminate execution right after attaching all the probes. Useful for testing that the script can be parsed, loaded, and attached, without actually running it. === *-e* _PROGRAM_ Execute _PROGRAM_ instead of reading the program from a file or stdin. === *-f* _FORMAT_ Set the output format. Valid values are:: *json* + *text* The JSON output is compatible with NDJSON and JSON Lines, meaning each line of the streamed output is a single blob of valid JSON. === *--fmt* _FILENAME_ Output standard format for the bpftrace file _FILENAME_. === *-h, --help* Print the help summary. === *-I* _DIR_ Add the directory _DIR_ to the search path for C headers. This option can be used multiple times. For more details see the <> section. === *--include* _FILENAME_ Add _FILENAME_ as an include for the pre-processor. This is equal to adding '#include _FILENAME_' at the top of the program. This option can be used multiple times. For more details see the <> section. === *--info* Print detailed information about features supported by the kernel and the bpftrace build. === *-k* This flag enables runtime warnings for errors from 'probe_read_*' and map lookup BPF helpers. When errors occur bpftrace will log an error containing the source location and the error code: ---- stdin:48-57: WARNING: Failed to probe_read_user_str: Bad address (-14) u:lib.so:"fn(char const*)" { printf("arg0:%s\n", str(arg0));} ~~~~~~~~~ ---- === *-l* [_SEARCH_|_FILENAME_] List all probes that match the _SEARCH_ pattern. If the pattern is omitted all probes will be listed. This pattern supports wildcards in the same way that probes do. E.g. '-l kprobe:*file*' to list all 'kprobes' with 'file' in the name. This can be used with a program, which will list all probes in that program. For more details see the <> section. === *--no-feature* _feature,feature,..._ Disable use of detected features, valid values are:: *uprobe_multi* to disable uprobe_multi link + *kprobe_multi* to disable kprobe_multi link + *kprobe_session* to disable automatic collapse of kprobe/kretprobe into kprobe session === *--no-warnings* Suppress all warning messages created by bpftrace. === *--probe-filter* _REGEX_ Only attach and run probes whose name matches the regular expression _REGEX_. Probes that do not match are not loaded into the kernel. Special probes (`BEGIN` and `END`) are not affected by this filter. If no probes match, bpftrace exits with an error. === *--traceable-functions* _FILENAME_ Specify the file containing the list of traceable kernel functions. If not set, bpftrace uses `/sys/kernel/tracing/available_filter_functions`, which depends on dynamic ftrace. The format is the same as in `available_filter_functions`: each line is either "symbol" or "symbol [module]". === *-o* _FILENAME_ Write bpftrace tracing output to _FILENAME_ instead of stdout. This doesn't include child process (*-c* option) output. Errors are still written to stderr. === *-p* _PID_ Attach to the process with or filter actions by _PID_. If the process terminates, bpftrace will also terminate. When using USDT, uprobes, uretprobes, hardware, software, profile, interval, or watchpoint probes they will be attached to only this process. For all other probes, except begin/end, the pid will act like a predicate to filter out events not from that pid. For listing uprobes/uretprobes set the target to '*' and the process's address space will be searched for the symbols. === *-q* Keep messages quiet. === *--unsafe* Some calls, like 'system', are marked as unsafe as they can have dangerous side effects ('system("rm -rf")') and are disabled by default. This flag allows their use. In addition, it makes kprobe/kretprobe checks less restrictive. It can be used to probe functions that bpftrace reports as not traceable, but are supported if the kernel is configured to allow probing notrace functions. === *--usdt-file-activation* Activate usdt semaphores based on file path. === *-V, --version* Print bpftrace version information. === *-v* Enable verbose messages. For more details see the <> section. === Program Options You can also pass custom options to a bpftrace program/script itself via positional or named parameters. Positional parameters can be placed before or after a double dash but named parameters can ONLY come after a double dash; e.g. ``` # bpftrace -e 'begin { print(($1, $2, getopt("aa", 1), getopt("bb"))); }' p1 -- --aa=20 --bb p2 // (p1, p2, 20, true) is printed ``` or ``` # bpftrace myscript.bt -- p1 --aa=20 --bb p2 ``` In these examples there are two positional parameters (`p1`, `p2`) and two named parameters (`aa`, which is set to `20`, and `bb`, which is set to `true`). Named program parameters require the `=` to set their value unless they are boolean parameters (like 'bb' above). Read about how to access positional and named parameters link:https://github.com/bpftrace/bpftrace/blob/master/docs/language.md#command-line-parameters[here]. == The Language Syntax, types, and concepts for bpftrace are link:https://github.com/bpftrace/bpftrace/blob/master/docs/language.md[available here]. == Probes bpftrace supports various probe types which allow the user to attach BPF programs to different types of events. Each probe starts with a provider (e.g. `kprobe`) followed by a colon (`:`) separated list of options. The amount of options and their meaning depend on the provider. Optionally, the attachpoint specified can be prefixed by a user-provided name followed by equal sign (e.g. `myname=kprobe:...`); this is used for certain advanced features and is typically omitted. link:https://github.com/bpftrace/bpftrace/blob/master/docs/language.md#probes[Full list of probe types]. == Standard library The standard library of all link:https://github.com/bpftrace/bpftrace/blob/master/docs/stdlib.md#builtins[builtins], link:https://github.com/bpftrace/bpftrace/blob/master/docs/stdlib.md#functions[functions], and link:https://github.com/bpftrace/bpftrace/blob/master/docs/stdlib.md#map-functions[map functions] is link:https://github.com/bpftrace/bpftrace/blob/master/docs/stdlib.md[available here]. == Configuration === Config Variables Some behavior can only be controlled through config variables, which are link:https://github.com/bpftrace/bpftrace/blob/master/docs/language.md#config-variables[available here]. These can be set via the Config Block directly in a script (before any probes) or via their environment variable equivalent, which is upper case and includes the `BPFTRACE_` prefix e.g. ``stack_mode``'s environment variable would be `BPFTRACE_STACK_MODE`. === Environment Variables These are not available as part of the standard set of Config Variables above and can only be set as environment variables. ==== BPFTRACE_BTF Default: None The path to a BTF file. By default, bpftrace searches several locations to find a BTF file. See src/btf.cpp for the details. ==== BPFTRACE_KERNEL_BUILD Default: `/lib/modules/$(uname -r)` Only used with `BPFTRACE_KERNEL_SOURCE` if it is out-of-tree Linux kernel build. ==== BPFTRACE_KERNEL_SOURCE Default: `/lib/modules/$(uname -r)` bpftrace requires kernel headers for certain features, which are searched for in this directory. ==== BPFTRACE_VMLINUX Default: None This specifies the vmlinux path used for kernel symbol resolution when attaching kprobe to offset. If this value is not given, bpftrace searches vmlinux from pre defined locations. See src/attached_probe.cpp:find_vmlinux() for details. ==== BPFTRACE_COLOR Default: auto Colorize the bpftrace log output message. Valid values are auto, always and never. == Options Expanded === Debug Output The `-d STAGE` option produces debug output. It prints the output of the bpftrace execution stage given by the _STAGE_ argument. The option can be used multiple times (with different stage names) and the special value `all` prints the output of all the supported stages. The option also takes multiple stages in one invocation as comma separated values. Note: This is primarily used for bpftrace developers. The supported options are: [cols="~,~"] |=== | `ast` | Prints the Abstract Syntax Tree (AST) after every pass. | `codegen` | Prints the unoptimized LLVM IR as produced by `CodegenLLVM`. | `codegen-opt` | Prints the optimized LLVM IR, i.e. the code which will be compiled into BPF bytecode. | `dis` | Disassembles and prints out the generated bytecode that `libbpf` will see. Only available in debug builds. | `libbpf` | Captures and prints libbpf log for all libbpf operations that bpftrace uses. | `verifier` | Captures and prints the BPF verifier log. | `all` | Prints the output of all of the above stages. |=== === Listing Probes Probe listing is the method to discover which probes are supported by the current system. Listing supports the same syntax as normal attachment does and alternatively can be combined with `-e` or filename args to see all the probes that a program would attach to. ---- # bpftrace -l 'kprobe:*' # bpftrace -l 't:syscalls:*openat* # bpftrace -l 'kprobe:tcp*,trace # bpftrace -l 'k:*socket*,tracepoint:syscalls:*tcp*' # bpftrace -l -e 'tracepoint:xdp:mem_* { exit(); }' # bpftrace -l my_script.bt # bpftrace -lv 'enum cpu_usage_stat' ---- The verbose flag (`-v`) can be specified to inspect arguments (`args`) for providers that support it: ---- # bpftrace -l 'fexit:tcp_reset,tracepoint:syscalls:sys_enter_openat' -v fexit:tcp_reset struct sock * sk struct sk_buff * skb tracepoint:syscalls:sys_enter_openat int __syscall_nr int dfd const char * filename int flags umode_t mode # bpftrace -l 'uprobe:/bin/bash:rl_set_prompt' -v # works only if /bin/bash has DWARF uprobe:/bin/bash:rl_set_prompt const char *prompt # bpftrace -lv 'struct css_task_iter' vmlinux: struct css_task_iter { struct cgroup_subsys *ss; unsigned int flags; struct list_head *cset_pos; struct list_head *cset_head; struct list_head *tcset_pos; struct list_head *tcset_head; struct list_head *task_pos; struct list_head *cur_tasks_head; struct css_set *cur_cset; struct css_set *cur_dcset; struct task_struct *cur_task; struct list_head iters_node; }; ---- === Preprocessor Options The `-I` option can be used to add directories to the list of directories that bpftrace uses to look for headers. Can be defined multiple times. ---- # cat program.bt #include begin { @ = FOO } # bpftrace program.bt definitions.h:1:10: fatal error: 'foo.h' file not found # /tmp/include foo.h # bpftrace -I /tmp/include program.bt Attached 1 probe ---- The `--include` option can be used to include headers by default. Can be defined multiple times. Headers are included in the order they are defined, and they are included before any other include in the program being executed. ---- # bpftrace --include linux/path.h --include linux/dcache.h \ -e 'kprobe:vfs_open { printf("open path: %s\n", str(((struct path *)arg0).dentry.d_name.name)); }' Attached 1 probe open path: .com.google.Chrome.ASsbu2 open path: .com.google.Chrome.gimc10 open path: .com.google.Chrome.R1234s ---- === Verbose Output The `-v` option prints more information about the program as it is run: ---- # bpftrace -v -e 'tracepoint:syscalls:sys_enter_nanosleep { printf("%s is sleeping.\n", comm); }' AST node count: 7 Attached 1 probe load tracepoint:syscalls:sys_enter_nanosleep, with BTF, with func_infos: Success Program ID: 111 Attaching tracepoint:syscalls:sys_enter_nanosleep iscsid is sleeping. iscsid is sleeping. [...] ---- == Terminology [cols="~,~"] |=== | BPF | Berkeley Packet Filter: a kernel technology originally developed for optimizing the processing of packet filters (eg, tcpdump expressions). | BPF map | A BPF memory object, which is used by bpftrace to create many higher-level objects. | BTF | BPF Type Format: the metadata format which encodes the debug info related to BPF program/map. | dynamic tracing | Also known as dynamic instrumentation, this is a technology that can instrument any software event, such as function calls and returns, by live modification of instruction text. Target software usually does not need special capabilities to support dynamic tracing, other than a symbol table that bpftrace can read. Since this instruments all software text, it is not considered a stable API, and the target functions may not be documented outside of their source code. | eBPF | Enhanced BPF: a kernel technology that extends BPF so that it can execute more generic programs on any events, such as the bpftrace programs listed below. It makes use of the BPF sandboxed virtual machine environment. Also note that eBPF is often just referred to as BPF. | kprobes | A Linux kernel technology for providing dynamic tracing of kernel functions. | probe | An instrumentation point in software or hardware, that generates events that can execute bpftrace programs. | static tracing | Hard-coded instrumentation points in code. Since these are fixed, they may be provided as part of a stable API, and documented. | tracepoints | A Linux kernel technology for providing static tracing. | uprobes | A Linux kernel technology for providing dynamic tracing of user-level functions. | USDT | User Statically-Defined Tracing: static tracing points for user-level software. Some applications support USDT. |=== == Program Files Programs saved as files are often called scripts and can be executed by specifying their file name. It is convention to use the `.bt` file extension but it is not required. For example, listing the sleepers.bt file using `cat`: ---- # cat sleepers.bt tracepoint:syscalls:sys_enter_nanosleep { printf("%s is sleeping.\n", comm); } ---- And then calling it: ---- # bpftrace sleepers.bt Attached 1 probe iscsid is sleeping. iscsid is sleeping. ---- It can also be made executable to run stand-alone. Start by adding an interpreter line at the top (`#!`) with either the path to your installed bpftrace (/usr/local/bin is the default) or the path to `env` (usually just `/usr/bin/env`) followed by `bpftrace` (so it will find bpftrace in your `$PATH`): ---- #!/usr/local/bin/bpftrace tracepoint:syscalls:sys_enter_nanosleep { printf("%s is sleeping.\n", comm); } ---- Then make it executable: ---- # chmod 755 sleepers.bt # ./sleepers.bt Attached 1 probe iscsid is sleeping. iscsid is sleeping. ---- bpftrace-0.27.1/man/man8/000077500000000000000000000000001526721631600150165ustar00rootroot00000000000000bpftrace-0.27.1/man/man8/CMakeLists.txt000066400000000000000000000007441526721631600175630ustar00rootroot00000000000000find_program(GZIP gzip REQUIRED) file(GLOB FILES *.8) set(GZFILES "") foreach(FIL ${FILES}) get_filename_component(NAME ${FIL} NAME) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.gz COMMAND ${GZIP} -nc ${FIL} > ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.gz DEPENDS ${FIL}) list(APPEND GZFILES "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.gz") endforeach() add_custom_target(man_man DEPENDS ${GZFILES}) install(FILES ${GZFILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man8) bpftrace-0.27.1/man/man8/bashreadline.bt.8000066400000000000000000000025671526721631600201460ustar00rootroot00000000000000.TH bashreadline.bt 8 "2018-09-06" "USER COMMANDS" .SH NAME bashreadline.bt \- Print bash commands system wide. Uses bpftrace/eBPF. .SH SYNOPSIS .B bashreadline.bt .SH DESCRIPTION bashreadline traces the return of the readline() function using uretprobes, to show the bash commands that were entered interactively, system wide. The entered command may fail: this is just showing what was entered. This program is also a basic example of bpftrace and uretprobes. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace bash commands system wide: # .B bashreadline.bt .SH FIELDS .TP TIME A timestamp on the output, in "HH:MM:SS" format. .TP PID The process ID for bash. .TP COMMAND Entered command. .SH OVERHEAD As the rate of interactive bash commands is expected to be very low (<<100/s), the overhead of this program is expected to be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO opensnoop.bt(8) bpftrace-0.27.1/man/man8/biolatency.bt.8000066400000000000000000000037171526721631600176540ustar00rootroot00000000000000.TH biolatency.bt 8 "2018-09-13" "USER COMMANDS" .SH NAME biolatency.bt \- Block I/O latency as a histogram. Uses bpftrace/eBPF. .SH SYNOPSIS .B biolatency.bt .SH DESCRIPTION This tool summarizes time (latency) spent in block device I/O (disk I/O) as a power-of-2 histogram. This allows the distribution to be studied, including modes and outliers. There are often two modes, one for device cache hits and one for cache misses, which can be shown by this tool. Latency outliers will also be shown. The original tool, which is retained as "biolatency-kp.bt", currently works by dynamic tracing of the blk_account*() kernel functions, which will need updating to match any changes to these functions in future kernels versions. The updated version of the tool utilizes tracepoints instead of kprobes so that it can be compatible with a wide range of kernel versions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace block device I/O (disk I/O), and print a latency histogram on Ctrl-C: # .B biolatency.bt .SH FIELDS .TP 1st, 2nd This is a range of latency, in microseconds (shown in "[...)" set notation). .TP 3rd A column showing the count of operations in this range. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD Since block device I/O usually has a relatively low frequency (< 10,000/s), the overhead for this tool is expected to be negligible. For high IOPS storage systems, test and quantify before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO biosnoop.bt(8) bpftrace-0.27.1/man/man8/biosnoop.bt.8000066400000000000000000000035001526721631600173410ustar00rootroot00000000000000.TH biosnoop.bt 8 "2018-09-11" "USER COMMANDS" .SH NAME biosnoop.bt \- Block I/O tracing tool, showing per I/O latency. Uses bpftrace/eBPF. .SH SYNOPSIS .B biosnoop.bt .SH DESCRIPTION This is a basic block I/O (disk I/O) tracing tool, showing each I/O event along with the issuing process ID, and the I/O latency. This can be used to investigate disk I/O performance issues. This tool currently works by dynamic tracing of the blk_account*() kernel functions, which will need updating to match any changes to these functions in future kernels versions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace block I/O events, printing per-line summaries: # .B biosnoop.bt .SH FIELDS .TP TIME Time of the I/O completion, in milliseconds since program start. .TP DISK ID Major and minor device numbers of the disk device. .TP COMM Issuing process name. This often identifies the issuing application process, but I/O may be initiated from kernel threads only. .TP PID Issuing process ID. This often identifies the issuing application process, but I/O may be initiated from kernel threads only. .TP LAT(ms) Per I/O latency. .SH OVERHEAD Since block device I/O usually has a relatively low frequency (< 10,000/s), the overhead for this tool is expected to be negligible. For high IOPS storage systems, test and quantify before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool provides more fields. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO opensnoop.bt(8) bpftrace-0.27.1/man/man8/biostacks.bt.8000066400000000000000000000032401526721631600174740ustar00rootroot00000000000000.TH biostacks.bt 8 "2019-07-12" "USER COMMANDS" .SH NAME biostacks \- Show disk I/O latency with initialization stacks. Uses bpftrace/eBPF. .SH SYNOPSIS .B biostacks .SH DESCRIPTION This tool shows disk I/O latency histograms for each block I/O initialization path. This can help reveal the reason for different latencies, as some may be created by log flushing, others by application reads, etc. This works by attaching to block_io_start and block_rq_issue tracepoints. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace disk I/O latency with initialization stacks: # .B biostacks.bt .SH FIELDS .TP 0th An initialization kernel stack trace (shown in "@[...]") is printed before each I/O histogram. .TP 1st, 2nd This is a range of I/O latency, in microseconds (shown in "[...)" set notation). .TP 3rd A column showing the count of I/O in this range. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD The rate of biostacks should be low (bounded by device IOPS), such that the overhead of this tool is expected to be negligible. .SH SOURCE This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO biosnoop.bt(8) bpftrace-0.27.1/man/man8/bitesize.bt.8000066400000000000000000000030061526721631600173300ustar00rootroot00000000000000.TH bitesize.bt 8 "2018-09-07" "USER COMMANDS" .SH NAME bitesize.bt \- Show disk I/O size as a histogram. Uses bpftrace/eBPF. .SH SYNOPSIS .B bitesize.bt .SH DESCRIPTION This can be used to characterize the distribution of block device (disk) I/O sizes. To study block device I/O in more detail, see biosnoop.bt(8). This uses the tracepoint:block:block_rq_issue tracepoint, and is a simple example of bpftrace. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace block I/O and summarize as a histogram by process: # .B bitesize.bt .SH FIELDS .TP 0th A process name (shown in "@[...]") is printed before each I/O histogram. .TP 1st, 2nd This is a range of I/O sizes, in Kbytes (shown in "[...)" set notation). .TP 3rd A column showing the count of I/O in this range. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD Since block device I/O usually has a relatively low frequency (< 10,000/s), the overhead for this tool is expected to be low or negligible. For high IOPS storage systems, test and quantify before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO biosnoop.bt(8) bpftrace-0.27.1/man/man8/capable.bt.8000066400000000000000000000027141526721631600171060ustar00rootroot00000000000000.TH capable.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME capable.bt \- Trace security capability checks (cap_capable()). .SH SYNOPSIS .B capable.bt .SH DESCRIPTION This traces security capability checks in the kernel, and prints details for each call. This can be useful for general debugging, and also security enforcement: determining a white list of capabilities an application needs. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF, bpftrace. .SH EXAMPLES .TP Trace all capability checks system-wide: # .B capable.bt .SH FIELDS .TP TIME(s) Time of capability check: HH:MM:SS. .TP UID User ID. .TP PID Process ID. .TP COMM Process name. .TP CAP Capability number. .TP NAME Capability name. See capabilities(7) for descriptions. .TP AUDIT Whether this was an audit event. .SH OVERHEAD This adds low-overhead instrumentation to capability checks, which are expected to be low frequency, however, that depends on the application. Test in a lab environment before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool provides options to customize the output. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO capabilities(7) bpftrace-0.27.1/man/man8/cpuwalk.bt.8000066400000000000000000000023141526721631600171610ustar00rootroot00000000000000.TH cpuwalk.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME cpuwalk.bt \- Sample which CPUs are executing processes.. Uses bpftrace/eBPF. .SH SYNOPSIS .B cpuwalk.bt .SH DESCRIPTION This tool samples CPUs at 99 Hertz, then prints a histogram showing which CPUs were active. 99 Hertz is used to avoid lockstep sampling that would skew results. This tool can help identify if your application's workload is evenly using the CPUs, or if there is an imbalance problem. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Sample CPUs and print a summary on Ctrl-C: # .B cpuwalk.bt .SH FIELDS .TP 1st, 2nd The CPU is shown in the first field, after the "[". Disregard the second field. .TP 3rd A column showing the number of samples for this CPU. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD This should be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO mpstat(1) bpftrace-0.27.1/man/man8/dcsnoop.bt.8000066400000000000000000000040211526721631600171550ustar00rootroot00000000000000.TH dcsnoop.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME dcsnoop.bt \- Trace directory entry cache (dcache) lookups. Uses bpftrace/eBPF. .SH SYNOPSIS .B dcsnoop.bt .SH DESCRIPTION By default, this traces every dcache lookup, and shows the process performing the lookup and the filename requested. The output of this tool can be verbose, and is intended for further investigations of dcache performance beyond dcstat(8), which prints per-second summaries. This uses kernel dynamic tracing of the d_lookup() function, and will need and will need updating to match any changes to this function. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bcc. .SH EXAMPLES .TP Trace all dcache lookups: # .B dcsnoop.bt .SH FIELDS .TP TIME(ms) Time of lookup, in milliseconds. .TP PID Process ID. .TP COMM Process name. .TP T Type: R == reference, M == miss. A miss will print two lines, one for the reference, and one for the miss. .TP FILE The file name component that was being looked up. This contains trailing pathname components (after '/'), which will be the subject of subsequent lookups. .SH OVERHEAD File name lookups can be frequent (depending on the workload), and this tool prints a line for each failed lookup, and with \-a, each reference as well. The output may be verbose, and the incurred overhead, while optimized to some extent, may still be from noticeable to significant. This is only really intended for deeper investigations beyond dcstat(8), when absolutely necessary. Measure and quantify the overhead in a test environment before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO dcstat(8) bpftrace-0.27.1/man/man8/execsnoop.bt.8000066400000000000000000000035301526721631600175170ustar00rootroot00000000000000.TH execsnoop.bt 8 "2018-09-11" "USER COMMANDS" .SH NAME execsnoop.bt \- Trace new processes via exec() syscalls. Uses bpftrace/eBPF. .SH SYNOPSIS .B execsnoop.bt .SH DESCRIPTION This traces when processes call exec() (execve()). It is handy for identifying new processes created via the usual fork()->exec() sequence. Note that the return value is not currently traced, so the exec() may have failed. This tool is useful for debugging shell scripts, including application startup. It is also useful for identifying a type of performance issue: a flood of short-lived processes, that end quickly and aren't readily visible in top(1). Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace all new processes calling execve(): # .B execsnoop.bt .SH FIELDS .TP TIME Time of the exec() call, in milliseconds since program start. .TP PID Process ID .TP PPID Parent Process ID .TP ARGS Process name and arguments (16 word maximum). .SH OVERHEAD This traces the execve() tracepoint and prints output for each event. As the rate of this is generally expected to be low (< 100/s), the overhead is also expected to be negligible. If you have an application that is spawning a high rate of new processes for a reason (large build process), this could cause a small amount of overhead: test and understand overhead before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool provides more fields and options to customize the output. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO opensnoop.bt(8) bpftrace-0.27.1/man/man8/gethostlatency.bt.8000066400000000000000000000034231526721631600205520ustar00rootroot00000000000000.TH gethostlatency.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME gethostlatency.bt \- Show latency for getaddrinfo/gethostbyname[2] calls. Uses bpftrace/eBPF. .SH SYNOPSIS .B gethostlatency.bt .SH DESCRIPTION This traces and prints when gethostbyaddr(), getaddrinfo(), gethostbyname(), and gethostbyname2() are called, system wide, and shows the responsible PID and command name, latency of the call (duration) in milliseconds, and the host string. This tool can be useful for identifying DNS latency, by identifying which remote host name lookups were slow, and by how much. This tool currently uses dynamic tracing of user-level functions and registers, and may need modifications to match your software and processor architecture. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bcc. .SH EXAMPLES .TP Trace host lookups (getaddrinfo/gethostbyname[2]) system wide: # .B gethostlatency.bt .SH FIELDS .TP TIME Time of the command (HH:MM:SS). .TP PID Process ID of the client performing the call. .TP COMM Process (command) name of the client performing the call. .TP LATms Latency of the call, in milliseconds. .TP HOST Host name string: the target of the lookup. .SH OVERHEAD The rate of lookups should be relatively low, so the overhead is not expected to be a problem. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool provides command line options. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO tcpdump(8), gethostbyname(3), getaddrinfo(3) bpftrace-0.27.1/man/man8/killsnoop.bt.8000066400000000000000000000033131526721631600175250ustar00rootroot00000000000000.TH killsnoop.bt 8 "2018-09-07" "USER COMMANDS" .SH NAME killsnoop.bt \- Trace signals issued by the kill(),tkill(),tgkill() syscall. Uses bpftrace/eBPF. .SH SYNOPSIS .B killsnoop.bt .SH DESCRIPTION killsnoop traces the kill(),tkill(),tgkill() syscall, to show signals sent via this method. This may be useful to troubleshoot failing applications, where an unknown mechanism is sending signals. This works by tracing the kill(),tkill(),tgkill() syscall tracepoints. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace all kill(),tkill(),tgkill() syscalls: # .B killsnoop.bt .SH FIELDS .TP TIME Time of the kill call. .TP PID Source process ID .TP COMM Source process name .TP SIG Signal number or name. See signal(7). .TP TPID Target process ID .TP RESULT Result. 0 == success, a negative value (of the error code) for failure. .SH OVERHEAD This traces the kernel kill function and prints output for each event. As the rate of this is generally expected to be low (< 100/s), the overhead is also expected to be negligible. If you have an application that is calling a very high rate of kill()|tkill()|tgkill()s for some reason, then test and understand overhead before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg, Rong Tao .SH SEE ALSO opensnoop.bt(8) bpftrace-0.27.1/man/man8/loads.bt.8000066400000000000000000000037401526721631600166210ustar00rootroot00000000000000.TH loads.bt 8 "2018-09-10" "USER COMMANDS" .SH NAME loads.bt \- Prints load averages. Uses bpftrace/eBPF. .SH SYNOPSIS .B loads.bt .SH DESCRIPTION These are the same load averages printed by "uptime", but to three decimal places instead of two (not that it really matters). This is really a demonstration of fetching and processing a kernel structure from bpftrace. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Print system load averages every second: # .B loads.bt .SH FIELDS .TP HH:MM:SS Each output line includes time of printing in "HH:MM:SS" format. .TP load averages: These are exponentially-damped moving sum averages of the system loads. Load is a measurement of demand on system resources, which include CPUs and other resources that are accessed with the kernel in an uninterruptible state (TASK_UNINTERRUPTIBLE), which includes types of disk I/O and lock accesses. Linux load averages originally reflected CPU demand only, as it does in other OSes, but this was changed in Linux 0.99.14. This demand measurement reflects not just the utilized resource, but also the queued demand (a saturation measurement). Finally, the three numbers are called the "one-", "five-", and "fifteen-minute" load averages, however these times are constants used in the exponentially-damping equation, and the load averages reflect load beyond these times. Were you expecting an accurate description of load averages in the man page of a bpftrace tool? .SH OVERHEAD Other than bpftrace startup time, negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH REFERENCE For more on load averages, see: .PP http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO uptime(1) bpftrace-0.27.1/man/man8/mdflush.bt.8000066400000000000000000000032221526721631600171540ustar00rootroot00000000000000.TH mdflush.bt 8 "2018-09-07" "USER COMMANDS" .SH NAME mdflush.bt \- Trace md flush events. Uses bpftrace/eBPF. .SH SYNOPSIS .B mdflush.bt .SH DESCRIPTION This tool traces flush events by md, the Linux multiple device driver (software RAID). The timestamp and md device for the flush are printed. Knowing when these flushes happen can be useful for correlation with unexplained spikes in disk latency. This works by tracing the kernel md_flush_request() function using kernel dynamic tracing, and will need updating to match any changes to this function. Note that the flushes themselves are likely to originate from higher in the I/O stack, such as from the file systems. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace md flush events: # .B mdflush.bt .SH FIELDS .TP TIME Time of the flush event (HH:MM:SS). .TP PID The process ID that was on-CPU when the event was issued. This may identify the cause of the flush (eg, the "sync" command), but will often identify a kernel worker thread that was managing I/O. .TP COMM The command name for the PID. .TP DEVICE The md device name. .SH OVERHEAD Expected to be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO biosnoop.bt(8) bpftrace-0.27.1/man/man8/naptime.bt.8000066400000000000000000000030021526721631600171430ustar00rootroot00000000000000.TH naptime.bt 8 "2019-07-05" "USER COMMANDS" .SH NAME naptime.bt \- Trace voluntary sleep calls. Uses bpftrace/eBPF. .SH SYNOPSIS .B naptime.bt .SH DESCRIPTION This tool traces application sleeps, and can be used for debugging high latency that may be caused by deliberate sleeps placed in application routines, especially administration scripts. This tool works by tracing the nanosleep(2) syscall using the syscall tracepoints. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace application sleeps via nanosleep(2): # .B naptime.bt .SH FIELDS .TP TIME A timestamp in HH:MM:SS format. .TP PPID Parent process ID. .TP PCOMM Parent process name. .TP PID The sleeping process ID. .TP COMM The sleeping process name. .TP SECONDS The requested duration of the sleep. .SH OVERHEAD nanosleep(2) calls are expected to be low frequency (<< 100/s), so the overhead of this tool is expected to be negligible. .SH SOURCE This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO capable.bt(8) bpftrace-0.27.1/man/man8/oomkill.bt.8000066400000000000000000000035701526721631600171660ustar00rootroot00000000000000.TH oomkill.bt 8 "2018-09-07" "USER COMMANDS" .SH NAME oomkill.bt \- Trace OOM killer. Uses bpftrace/eBPF. .SH SYNOPSIS .B oomkill.bt .SH DESCRIPTION This traces the kernel out-of-memory killer, and prints basic details, including the system load averages at the time of the OOM kill. This can provide more context on the system state at the time: was it getting busier or steady, based on the load averages? This tool may also be useful to customize for investigations; for example, by adding other task_struct details at the time of OOM, or by adding other commands to run at the shell. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace OOM kill events: # .B oomkill.bt .SH FIELDS .TP Triggered by ... The process ID and process name of the task that was running when another task was OOM killed. .TP CGROUP ... If the OOM occurs in the memory cgroup, display the memory cgroup information. .TP OOM kill of ... The process ID and name of the target process that was OOM killed. .TP loadavg Contents of /proc/loadavg. The first three numbers are 1, 5, and 15 minute load averages (where the average is an exponentially damped moving sum, and those numbers are constants in the equation); then there is the number of running tasks, a slash, and the total number of tasks; and then the last number is the last PID to be created. .SH OVERHEAD Negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg, Rong Tao .SH SEE ALSO dmesg(1) bpftrace-0.27.1/man/man8/opensnoop.bt.8000066400000000000000000000035131526721631600175350ustar00rootroot00000000000000.TH opensnoop.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME opensnoop.bt \- Trace open(),openat(),openat2() syscalls. Uses bpftrace/eBPF. .SH SYNOPSIS .B opensnoop.bt -- [--depth=] [--errname] .SH DESCRIPTION opensnoop traces the open(),openat(),openat2() syscall, showing which processes are attempting to open which files. This can be useful for determining the location of config and log files, or for troubleshooting applications that are failing, specially on startup. This works by tracing the open(),openat(),openat2() syscall tracepoint. Since this uses BPF, only the root user can use this tool. .SH OPTIONS .TP --depth= Used to set the maximum supported path depth, default is 35. .TP --errname Show error message instead of errno. .SH REQUIREMENTS CONFIG_BPF and bcc. .SH EXAMPLES .TP Trace all open(),openat(),openat2() syscalls: # .B opensnoop.bt .SH FIELDS PID Process ID .TP COMM Process name .TP FD File descriptor (if success), or -1 (if failed) .TP ERR Error number (see the system's errno.h) .TP PATH Open path .SH OVERHEAD This traces the open tracepoint and prints output for each event. As the rate of this is generally expected to be low (< 1000/s), the overhead is also expected to be negligible. If you have an application that is calling a high rate of open()s, then test and understand overhead before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHORS Brendan Gregg, Rong Tao .SH SEE ALSO statsnoop.bt(8), execsnoop.bt(8) bpftrace-0.27.1/man/man8/pidpersec.bt.8000066400000000000000000000026611526721631600174760ustar00rootroot00000000000000.TH pidpersec.bt 8 "2018-09-06" "USER COMMANDS" .SH NAME pidpersec.bt \- Count new processes (via fork()). Uses bpftrace/eBPF. .SH SYNOPSIS .B pidpersec.bt .SH DESCRIPTION pidpersec shows how many new processes were created each second. There can be performance issues caused by many short-lived processes, which may not be visible in sampling tools like top(1). pidpersec provides one way to investigate this behavior. This works by tracing the tracepoint:sched:sched_process_fork tracepoint. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Count new processes, printing per-second summaries until Ctrl-C is hit: # .B pidpersec.bt .SH FIELDS .TP 1st Count of processes (after "@") .SH OVERHEAD This traces kernel forks, and maintains an in-kernel count which is read asynchronously from user-space. As the rate of this is generally expected to be low (<< 1000/s), the overhead is also expected to be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO top(1) bpftrace-0.27.1/man/man8/runqlat.bt.8000066400000000000000000000034321526721631600172030ustar00rootroot00000000000000.TH runqlat.bt 8 "2018-09-17" "USER COMMANDS" .SH NAME runqlat.bt \- CPU scheduler run queue latency as a histogram. Uses bpftrace/eBPF. .SH SYNOPSIS .B runqlat.bt .SH DESCRIPTION This traces time spent waiting in the CPU scheduler for a turn on-CPU. This metric is often called run queue latency, or scheduler latency. This tool shows this latency as a power-of-2 histogram in nanoseconds, allowing multimodal distributions to be studied, as well as latency outliers. This tool uses the sched tracepoints. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace CPU run queue latency system wide, printing a histogram on Ctrl-C: # .B runqlat.bt .SH FIELDS .TP 1st, 2nd This is a range of latency, in microseconds (shown in "[...)" set notation). .TP 3rd A column showing the count of scheduler events in this range. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD This traces scheduler functions, which can become very frequent. While eBPF has very low overhead, and this tool uses in-kernel maps for efficiency, the frequency of scheduler events for some workloads may be high enough that the overhead of this tool becomes significant. Measure in a lab environment to quantify the overhead before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO runqlen.bt(8), mpstat(1), pidstat(1), uptime(1) bpftrace-0.27.1/man/man8/runqlen.bt.8000066400000000000000000000031021526721631600171730ustar00rootroot00000000000000.TH runqlen.bt 8 "2018-10-07" "USER COMMANDS" .SH NAME runqlen.bt \- CPU scheduler run queue length as a histogram. Uses bpftrace/eBPF. .SH SYNOPSIS .B runqlen.bt .SH DESCRIPTION This program summarizes scheduler queue length as a histogram, and can also show run queue occupancy. It works by sampling the run queue length on all CPUs at 99 Hertz. This tool can be used to identify imbalances, eg, when processes are bound to CPUs causing queueing, or interrupt mappings causing the same. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace CPU run queue length system wide, printing a histogram on Ctrl-C: # .B runqlen.bt .SH FIELDS .TP 1st, 2nd The run queue length is shown in the first field (after "["). .TP 3rd A column showing the count of samples in for that length. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD This samples scheduler structs at 99 Hertz across all CPUs. Relatively, this is a low rate of events, and the overhead of this tool is expected to be near zero. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO runqlat.bt(8), mpstat(1), pidstat(1), uptime(1) bpftrace-0.27.1/man/man8/setuids.bt.8000066400000000000000000000030031526721631600171670ustar00rootroot00000000000000.TH setuids.bt 8 "2019-07-05" "USER COMMANDS" .SH NAME setuids.bt \- Trace setuid family of syscalls. Uses bpftrace/eBPF. .SH SYNOPSIS .B setuids.bt .SH DESCRIPTION This tool traces privilege escalation via setuid syscalls, and can be used for debugging, whitelist creation, and intrusion detection. It works by tracing the setuid(2), setfsuid(2), and retresuid(2) syscalls using the syscall tracepoints. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace setuid syscalls: # .B setuids.bt .SH FIELDS .TP PID The calling process ID. .TP COMM The calling process (thread) name. .TP UID The UID of the caller. .TP SYSCALL The syscall name. .TP ARGS The arguments to the syscall .TP (RET) The return value for the syscall: 0 == success, other numbers indicate an error code. .SH OVERHEAD setuid calls are expected to be low frequency (<< 100/s), so the overhead of this tool is expected to be negligible. .SH SOURCE This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO capable.bt(8) bpftrace-0.27.1/man/man8/ssllatency.bt.8000066400000000000000000000037321526721631600177010ustar00rootroot00000000000000.TH ssllatency.bt 8 "2021-12-28" "USER COMMANDS" .SH NAME ssllatency.bt \- Show SSL/TLS handshake latency histogram. Uses bpftrace/eBPF. .SH SYNOPSIS .B ssllatency.bt .SH DESCRIPTION ssllatency shows latency distribution for OpenSSL handshake functions. This is useful for performance analysis with different crypto cipher suite, async SSL acceleration by CPU or offload device, etc. This tool works by dynamic tracing the uprobes in OpenSSL and related crypto libs, and may need updating to match future changes to these functions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace SSL/TLS handshake latency, and print a histogram on Ctrl-C: # .B ssllatency.bt .SH FIELDS .TP 0th A function name is shown in "@hist[...]" followed by latency histogram and "@stat[...]" followed by total call count, average, total latency in microseconds. Non-zero failed calls are traced separately (in "@histF[]" and "@statF[]") for some functions. .TP 1st, 2nd This is a range of latency, in microseconds (shown in "[...)" set notation). .TP 3rd A column showing the count of operations in this range. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD SSL/TLS handshake usually contains network latency and the traced crypto functions are CPU intensive tasks, so call frequency should be low and the overhead of this tool is expected to be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. There is a bcc tool sslsniff that can show SSL/TLS handshake event latency before sniffing the plaintext in SSL_read/write. This tool provides more detailed crypto latency distribution during the handshake event. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Tao Xu .SH SEE ALSO sslsnoop.bt(8) bpftrace-0.27.1/man/man8/sslsnoop.bt.8000066400000000000000000000031771526721631600174030ustar00rootroot00000000000000.TH sslsnoop.bt 8 "2021-12-28" "USER COMMANDS" .SH NAME sslsnoop.bt \- Show SSL/TLS handshake events. Uses bpftrace/eBPF. .SH SYNOPSIS .B sslsnoop.bt .SH DESCRIPTION sslsnoop traces OpenSSL handshake functions, and shows latency and return value. This can be used to analyze SSL/TLS performance. This tool works by dynamic tracing the uprobes in OpenSSL and related crypto libs, and may need updating to match future changes to these functions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace SSL/TLS handshake events, printing per-line summaries: # .B sslsnoop.bt .SH FIELDS .TP TIME(us) Time of the call completion, in microseconds since program start. .TP TID Thread ID. .TP COMM Process name. .TP LAT(us) Latency of the call, in microseconds. .TP RET Return value of the call. .TP FUNC Function name. .SH OVERHEAD SSL/TLS handshake usually contains network latency and the traced crypto functions are CPU intensive tasks, so call frequency should be low and the overhead of this tool is expected to be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. There is a bcc tool sslsniff that can show SSL/TLS handshake event latency before sniffing the plaintext in SSL_read/write. This tool provides more detailed crypto latency distribution during the handshake event. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Tao Xu .SH SEE ALSO biosnoop.bt(8) bpftrace-0.27.1/man/man8/statsnoop.bt.8000066400000000000000000000032041526721631600175440ustar00rootroot00000000000000.TH statsnoop.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME statsnoop.bt \- Trace stat() syscalls. Uses bpftrace/eBPF. .SH SYNOPSIS .B statsnoop.bt .SH DESCRIPTION statsnoop traces the stat() syscall, showing which processes are attempting to stat which files. This can be useful for determining the location of config and log files, or for troubleshooting applications that are failing, specially on startup. This traces the tracepoints for statfs(), statx(), newstat(), and newlstat(). These aren't the only the stat syscalls: if you are missing activity, you may need to add more variants. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bcc. .SH EXAMPLES .TP Trace all stat() syscalls: # .B statsnoop.bt .SH FIELDS PID Process ID .TP COMM Process name .TP ERR Error number (see the system's errno.h) .TP PATH Stat path .SH OVERHEAD This traces the stat tracepoints and prints output for each event. As the rate of this is generally expected to be low (< 1000/s), the overhead is also expected to be negligible. If you have an application that is calling a high rate of stat()s, then test and understand overhead before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO opensnoop.bt(8), execsnoop.bt(8) bpftrace-0.27.1/man/man8/swapin.bt.8000066400000000000000000000030511526721631600170130ustar00rootroot00000000000000.TH swapin.bt 8 "2019-07-05" "USER COMMANDS" .SH NAME swapin.bt \- Count swapins by process. Uses bpftrace/eBPF. .SH SYNOPSIS .B swapin .SH DESCRIPTION This tool counts swapins by process, to show which process is affected by swapping (if swap devices are in use). This can explain a significant source of application latency, if it has began swapping due to memory pressure on the system. This works by tracing the swap_readpage() kernel function using dynamic instrumentation. This tool may need maintenance to keep working if that function changes in later kernels. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Count swapins by process, showing per-second summaries. # .B swapin.bt .SH FIELDS .TP 1st The process name. .TP 2nd The process ID. .TP 3rd The count of swapins during that interval. .SH OVERHEAD The rate of swapins should be low (bounded by swapin device IOPS), such that the overhead of this tool is expected to be negligible. .SH SOURCE This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO swapon(8) bpftrace-0.27.1/man/man8/syncsnoop.bt.8000066400000000000000000000030571526721631600175530ustar00rootroot00000000000000.TH syncsnoop.bt 8 "2018-09-06" "USER COMMANDS" .SH NAME syncsnoop.bt \- Trace the sync() variety of syscalls. Uses bpftrace/eBPF. .SH SYNOPSIS .B syncsnoop.bt .SH DESCRIPTION syncsnoop traces calls to sync() syscalls (sync(), fsync(), msync(), etc), which flushes file system cache and buffers to storage devices. These calls can cause performance perturbations, and it can be useful to know if they are happening, when they happen, and how frequently. This works by tracing the sync() variety of syscalls via tracepoints. This program is also a basic example of eBPF/bcc. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace calls to sync() syscalls: # .B syncsnoop.bt .SH FIELDS .TP TIME A timestamp on the output, in "HH:MM:SS" format. .TP PID The process ID that was on-CPU during the event. .TP COMM The process name that was on-CPU during the event. .TP EVENT The tracepoint name for the sync event. .SH OVERHEAD This traces sync syscalls and prints output for each event. As the rate of this is generally expected to be low (<< 100/s), the overhead is also expected to be negligible. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO iostat(1) bpftrace-0.27.1/man/man8/syscount.bt.8000066400000000000000000000047711526721631600174130ustar00rootroot00000000000000.TH syscount.bt 8 "2018-09-06" "USER COMMANDS" .SH NAME syscount.bt \- Count system calls. Uses bpftrace/eBPF. .SH SYNOPSIS .B syscount.bt -- [--sysname] .SH DESCRIPTION This counts system calls (syscalls), printing a summary of the top ten syscall IDs, and the top ten process names making syscalls. This can be helpful for characterizing the kernel and resource workload, and finding applications who are using syscalls inefficiently. This works by using the tracepoint:raw_syscalls:sys_enter tracepoint. Since this uses BPF, only the root user can use this tool. .SH OPTIONS --sysname Show the syscall name instead of syscall number. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Count system calls until Ctrl-C is hit: # .B syscount.bt .SH OUTPUT .TP Top 10 syscalls IDs: This shows the syscall ID number (in @syscall[]) followed by a count for this syscall during tracing. syscount.bt defaults to outputting the syscall number. .TP Top 10 syscalls NAMEs: This shows the syscall ID name (in @syscallname[]) followed by a count for this syscall during tracing. Use the --sysname parameter to output the system call name. .TP Top 10 processes: This shows the process name (in @process[]) followed by a count of syscalls during tracing. .SH OVERHEAD For most applications, the overhead should be manageable if they perform 1000's or even 10,000's of syscalls per second. For higher rates, the overhead may become considerable. For example, tracing a microbenchmark loop of 4 million calls to geteuid(), slows it down by 2.4x. However, this represents tracing a workload that has a syscall rate of over 4 million syscalls per second per CPU, which should not be typical (in one large cloud production environment, rates of between 10k and 50k are typical, where the application overhead is expected to be closer to 1%). For comparison, strace(1) in its current ptrace-based implementation (which it has had for decades) runs the same geteuid() workload 102x slower (that's one hundred and two times slower). .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc version provides different command line options, and translates the syscall IDs to their syscall names. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO strace(1) bpftrace-0.27.1/man/man8/tcpaccept.bt.8000066400000000000000000000041511526721631600174620ustar00rootroot00000000000000.TH tcpaccept.bt 8 "2018-10-24" "USER COMMANDS" .SH NAME tcpaccept.bt \- Trace TCP passive connections (accept()). Uses bpftrace/eBPF .SH SYNOPSIS .B tcpaccept.bt .SH DESCRIPTION This tool traces passive TCP connections (eg, via an accept() syscall; connect() are active connections). This can be useful for general troubleshooting to see what new connections the local server is accepting. This uses dynamic tracing of the kernel inet_csk_accept() socket function (from tcp_prot.accept), and will need to be modified to match kernel changes. This tool only traces successful TCP accept()s. Connection attempts to closed ports will not be shown (those can be traced via other functions). Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace all passive TCP connections (accept()s): # .B tcpaccept.bt .TP .SH FIELDS .TP TIME(s) Time of the call, in HH:MM:SS format. .TP PID Process ID .TP COMM Process name .TP RADDR Remote IP address. .TP RPORT Remote port. .TP LADDR Local IP address. .TP LPORT Local port .TP BL Current accept backlog vs maximum backlog .SH OVERHEAD This traces the kernel inet_csk_accept function and prints output for each event. The rate of this depends on your server application. If it is a web or proxy server accepting many tens of thousands of connections per second, then the overhead of this tool may be measurable (although, still a lot better than tracing every packet). If it is less than a thousand a second, then the overhead is expected to be negligible. Test and understand this overhead before use. .SH SOURCE This is from bpftrace .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg, adapted for bpftrace by Dale Hamel .SH SEE ALSO tcpconnect.bt(8), funccount(8), tcpdump(8) bpftrace-0.27.1/man/man8/tcpconnect.bt.8000066400000000000000000000036041526721631600176560ustar00rootroot00000000000000.TH tcpconnect.bt 8 "2018-11-24" "USER COMMANDS" .SH NAME tcpconnect.bt \- Trace TCP active connections (connect()). Uses Linux bpftrace/eBPF .SH SYNOPSIS .B tcpconnect.bt .SH DESCRIPTION This tool traces active TCP connections (eg, via a connect() syscall; accept() are passive connections). This can be useful for general troubleshooting to see what connections are initiated by the local server. All connection attempts are traced, even if they ultimately fail. This works by tracing the kernel tcp_v4_connect() and tcp_v6_connect() functions using dynamic tracing, and will need updating to match any changes to these functions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace all active TCP connections: # .B tcpconnect.bt .TP .SH FIELDS .TP TIME(s) Time of the call, in HH:MM:SS format. .TP PID Process ID .TP COMM Process name .TP SADDR Source IP address. .TP SPORT Source port. .TP DADDR Destination IP address. .TP DPORT Destination port .SH OVERHEAD This traces the kernel tcp_v[46]_connect functions and prints output for each event. As the rate of this is generally expected to be low (< 1000/s), the overhead is also expected to be negligible. If you have an application that is calling a high rate of connects()s, such as a proxy server, then test and understand this overhead before use. .SH SOURCE This is from bpftrace .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg, adapted for bpftrace by Dale Hamel .SH SEE ALSO tcpaccept.bt(8), funccount(8), tcpdump(8) bpftrace-0.27.1/man/man8/tcpdrop.bt.8000066400000000000000000000041011526721631600171620ustar00rootroot00000000000000.TH tcpdrop.bt 8 "2018-11-24" "USER COMMANDS" .SH NAME tcpdrop.bt \- Trace kernel-based TCP packet drops with details. Uses Linux bpftrace/eBPF .SH SYNOPSIS .B tcpdrop.bt .SH DESCRIPTION This tool traces TCP packets or segments that were dropped by the kernel, and shows details from the IP and TCP headers, the socket state, and the kernel stack trace. This is useful for debugging cases of high kernel drops, which can cause timer-based retransmits and performance issues. This tool works using dynamic tracing of the tcp_drop() kernel function, which requires a recent kernel version. This tool is limited to ipv4, and cannot parse tcpflags as bpftrace currently cannot parse socket buffers in the way that bcc can. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace all tcp drops: # .B tcpdrop.bt .TP .SH FIELDS .TP TIME Time of the call, in HH:MM:SS format. .TP PID Process ID that was on-CPU during the drop. This may be unrelated, as drops can occur on the receive interrupt and be unrelated to the PID that was interrupted. .TP COMM Process name .TP SADDR:SPORT Source IP address and source TCP port. .TP DADDR:DPORT Destination IP address and destination TCP port. .TP STATE TCP session state ("ESTABLISHED", etc). .SH OVERHEAD This traces the kernel tcp_drop() function, which should be low frequency, and therefore the overhead of this tool should be negligible. As always, test and understand this tools overhead for your types of workloads before production use. .SH SOURCE This is from bpftrace .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg, adapted for bpftrace by Dale Hamel .SH SEE ALSO tcplife.bt(8), tcpaccept.bt(8), tcpconnect.bt(8), tcptop(8) bpftrace-0.27.1/man/man8/tcplife.bt.8000066400000000000000000000044061526721631600171450ustar00rootroot00000000000000.TH tcplife.bt 8 "2019-07-03" "USER COMMANDS" .SH NAME tcplife.bt \- Trace TCP session lifespans with connection details. Uses bpftrace/eBPF. .SH SYNOPSIS .B tcplife .SH DESCRIPTION This tool shows the lifespan of TCP sessions that open and close while tracing, and shows the duration and throughput statistics. For efficiency, this tool only instruments TCP state changes, rather than all packets. This tool works by using the sock:inet_sock_set_state tracepoint, which was added in Linux 4.16. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF, bpftrace, and the sock:inet_sock_set_state tracepoint (Linux 4.16+). .SH EXAMPLES .TP Show TCP sessions with details: # .B tcplife.bt .SH FIELDS .TP PID Process ID .TP COMM Process name .TP LADDR Local IP address. .TP LPORT Local port. .TP RADDR Remote IP address. .TP RPORT Remote port. .TP TX_KB Total transmitted Kbytes. .TP RX_KB Total received Kbytes. .TP MS Lifespan of the session, in milliseconds. .SH OVERHEAD This traces the kernel TCP set state function, which should be called much less often than send/receive tracing, and therefore have lower overhead. The overhead of the tool is relative to the rate of new TCP sessions: if this is high, over 10,000 per second, then there may be noticeable overhead just to print out 10k lines of formatted output per second. You can find out the rate of new TCP sessions using "sar \-n TCP 1", and adding the active/s and passive/s columns. As always, test and understand this tools overhead for your types of workloads before production use. .SH SOURCE This tool originated from BCC: .IP https://github.com/iovisor/bcc .PP The BCC version has many command line options for customizing the output. .PP This bpftrace version originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This bpftrace version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO tcptop(8) bpftrace-0.27.1/man/man8/tcpretrans.bt.8000066400000000000000000000037631526721631600177110ustar00rootroot00000000000000.TH tcpretrans.bt 8 "2018-11-24" "USER COMMANDS" .SH NAME tcpretrans.bt \- Trace or count TCP retransmits. Uses Linux bpftrace/eBPF .SH SYNOPSIS .B tcpretrans.bt .SH DESCRIPTION This traces TCP retransmits, showing address, port, and TCP state information, and sometimes the PID (although usually not, since retransmits are usually sent by the kernel on timeouts). To keep overhead very low, only the TCP retransmit functions are traced. This does not trace every packet (like tcpdump(8) or a packet sniffer). Optionally, it can count retransmits over a user signalled interval to spot potentially dropping network paths the flows are traversing. This uses dynamic tracing of the kernel tcp_retransmit_skb() and tcp_send_loss_probe() functions, and will need to be updated to match kernel changes to these functions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bcc. CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace TCP retransmits: # .B tcpretrans.bt .TP .SH FIELDS .TP TIME Time of the call, in HH:MM:SS format. .TP PID Process ID that was on-CPU. This is less useful than it might sound, as it may usually be 0, for the kernel, for timer-based retransmits. .TP LADDR:LPORT Local IP address and local port. .TP RADDR:RPORT Remote IP address and remote port. .TP STATE TCP session state. .SH OVERHEAD Should be negligible: TCP retransmit events should be low (<1000/s), and the low overhead this tool adds to each event should make the cost negligible. .SH SOURCE This is from bpftrace .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg, adapted for bpftrace by Dale Hamel .SH SEE ALSO tcpconnect.bt(8), tcpaccept.bt(8) bpftrace-0.27.1/man/man8/tcpsynbl.bt.8000066400000000000000000000035011526721631600173500ustar00rootroot00000000000000.TH tcpsynbl.bt 8 "2019-07-03" "USER COMMANDS" .SH NAME tcpsynbl.bt \- Show the TCP SYN backlog as a histogram. Uses bpftrace/eBPF. .SH SYNOPSIS .B tcpsynbl .SH DESCRIPTION This tool shows the TCP SYN backlog size during SYN arrival as a histogram. This lets you see how close your applications are to hitting the backlog limit and dropping SYNs (causing performance issues with SYN retransmits), and is a measure of workload saturation. The histogram shown is measured at the time of SYN received, and a separate histogram is shown for each backlog limit. This works by tracing the tcp_v4_syn_recv_sock() and tcp_v6_syn_recv_sock() kernel functions using dynamic instrumentation. Since these functions may change in future kernels, this tool may need maintenance to keep working. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Show the TCP SYN backlog as a histogram. # .B tcpsynbl.bt .SH FIELDS .TP backlog The backlog size when a SYN was received. .TP count The number of times this backlog size was encountered. .TP distribution An ASCII visualization of the count column. .SH OVERHEAD Inbound SYNs should be relatively low compared to packets and other events, so the overhead of this tool is expected to be negligible. .SH SOURCE This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO tcptop(8) bpftrace-0.27.1/man/man8/threadsnoop.bt.8000066400000000000000000000032031526721631600200370ustar00rootroot00000000000000.TH threadsnoop.bt 8 "2019-07-02" "USER COMMANDS" .SH NAME threadsnoop.bt \- Trace thread creation via pthread_create(). Uses bpftrace/eBPF. .SH SYNOPSIS .B threadsnoop.bt .SH DESCRIPTION threadsnoop traces calls to pthread_create(), showing this path of thread creation. This can be used for workload characterization and discovery, and is a companion to execsnoop.bt(8) which traces execve(2). This works by tracing the pthread_create() from libpthread.so.0. The path to this library may need adjusting in the tool source to match your system. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace calls pthread_create(): # .B threadsnoop.bt .SH FIELDS .TP TIME(ms) Elapsed time since the tool began tracing (in milliseconds). .TP PID The process ID. .TP COMM The process (thread) name. .TP FUNC The name of the start routine, if the symbol is available, else a hex address for the start routine address. .SH OVERHEAD Thread creation is expected to be low (<< 1000/s), so the overhead of this tool is expected to be negligible. .SH SOURCE This tool originated from the book "BPF Performance Tools", published by Addison Wesley (2019): .IP http://www.brendangregg.com/bpf-performance-tools-book.html .PP See the book for more documentation on this tool. .PP This version is in the bpftrace repository: .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO execsnoop.bt(8) bpftrace-0.27.1/man/man8/undump.bt.8000066400000000000000000000023731526721631600170300ustar00rootroot00000000000000.TH undump.bt 8 "2022-06-03" "USER COMMANDS" .SH NAME undump.bt \- Catch UNIX domain socket packages. Uses bpftrace/eBPF. .SH SYNOPSIS .B undump.bt .SH DESCRIPTION undump.bt tracked reception of UNIX domain sockets. This program is also a basic example of bpftrace and kprobes. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace reception of UNIX domain sockets: # .B undump.bt .SH FIELDS .TP TIME A timestamp on the output, in "HH:MM:SS" format. .TP COMM The process COMM. .TP PID The process ID. .TP SIZE The size of the received packet, in bytes. .TP DATA Display received packets in hex or string. .SH OVERHEAD The overhead of this program mainly comes from the data packets received by the terminal output. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc examples/tracing of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Rong Tao .SH SEE ALSO opensnoop.bt(8) bpftrace-0.27.1/man/man8/vfscount.bt.8000066400000000000000000000032311526721631600173610ustar00rootroot00000000000000.TH vfscount.bt 8 "2018-09-06" "USER COMMANDS" .SH NAME vfscount.bt \- Count VFS calls ("vfs_*"). Uses bpftrace/eBPF. .SH SYNOPSIS .B vfscount.bt .SH DESCRIPTION This counts VFS calls. This can be useful for general workload characterization of these operations. This works by tracing all kernel functions beginning with "vfs_" using dynamic tracing. This may match more functions than you are interested in measuring: Edit the script to customize which functions to trace. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Count all VFS calls until Ctrl-C is hit: # .B vfscount.bt .SH FIELDS .TP 1st Kernel function name (in @[]) .TP 2nd Number of calls while tracing .SH OVERHEAD This traces kernel vfs functions and maintains in-kernel counts, which are asynchronously copied to user-space. While the rate of VFS operations can be very high (>1M/sec), this is a relatively efficient way to trace these events, and so the overhead is expected to be small for normal workloads. Measure in a test environment, and if overheads are an issue, edit the script to reduce the types of vfs functions traced (currently all beginning with "vfs_"). .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO vfsstat.bt(8) bpftrace-0.27.1/man/man8/vfsstat.bt.8000066400000000000000000000034351526721631600172120ustar00rootroot00000000000000.TH vfsstat.bt 8 "2018-09-06" "USER COMMANDS" .SH NAME vfsstat.bt \- Count key VFS calls. Uses bpftrace/eBPF. .SH SYNOPSIS .B vfsstat.bt .SH DESCRIPTION This traces some common VFS calls and prints per-second summaries. This can be useful for general workload characterization, and looking for patterns in operation usage over time. This works by tracing some kernel vfs functions using dynamic tracing, and will need updating to match any changes to these functions. Edit the script to customize which functions are traced. Also see vfscount, which is more easily customized to trace multiple functions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Count some VFS calls, printing per-second summaries until Ctrl-C is hit: # .B vfsstat.bt .SH FIELDS .TP HH:MM:SS Each output summary is prefixed by the time of printing in "HH:MM:SS" format. .TP 1st Kernel function name (in @[]) .TP 2nd Number of calls while tracing .SH OVERHEAD This traces various kernel vfs functions and maintains in-kernel counts, which are asynchronously copied to user-space. While the rate of VFS operations can be very high (>1M/sec), this is a relatively efficient way to trace these events, and so the overhead is expected to be small for normal workloads. Measure in a test environment. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO vfscount.bt(8) bpftrace-0.27.1/man/man8/writeback.bt.8000066400000000000000000000033211526721631600174650ustar00rootroot00000000000000.TH writeback.bt 8 "2018-09-14" "USER COMMANDS" .SH NAME writeback.bt \- Trace file system writeback events with details. Uses bpftrace/eBPF. .SH SYNOPSIS .B writeback.bt .SH DESCRIPTION This traces when file system dirtied pages are flushed to disk by kernel writeback, and prints details including when the event occurred, and the duration of the event. This can be useful for correlating these times with other performance problems, and if there is a match, it would be a clue that the problem may be caused by writeback. How quickly the kernel does writeback can be tuned: see the kernel docs, eg, vm.dirty_writeback_centisecs. This uses the tracepoint:writeback:writeback_start and tracepoint:writeback:writeback_written tracepoints. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace all writeback events with timestamps and latency details: # .B writeback.bt .SH FIELDS .TP TIME Time that the writeback event completed, in %H:%M:%S format. .TP DEVICE Device name in major:minor number format. .TP PAGES Pages written during writeback. .TP REASON Reason for the writeback event. This may be "background", "vmscan", "sync", "periodic", etc. .TP ms Duration of the writeback event in milliseconds. .SH OVERHEAD Since writeback events are expected to be infrequent (<10/sec), the overhead of this tool is expected to be negligible (near 0%). .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO biosnoop.bt(8) bpftrace-0.27.1/man/man8/xfsdist.bt.8000066400000000000000000000034371526721631600172060ustar00rootroot00000000000000.TH xfsdist.bt 8 "2018-09-08" "USER COMMANDS" .SH NAME xfsdist.bt \- Summarize XFS operation latency. Uses bpftrace/eBPF. .SH SYNOPSIS .B xfsdist.bt .SH DESCRIPTION This tool summarizes time (latency) spent in common XFS file operations: reads, writes, opens, and syncs, and presents it as a power-of-2 histogram. It uses an in-kernel eBPF map to store the histogram for efficiency. Since this works by tracing the xfs_file_operations interface functions, it will need updating to match any changes to these functions. Since this uses BPF, only the root user can use this tool. .SH REQUIREMENTS CONFIG_BPF and bpftrace. .SH EXAMPLES .TP Trace XFS operation time, and print a summary on Ctrl-C: # .B xfsdist.bt .SH FIELDS .TP 0th The operation name (shown in "@[...]") is printed before each I/O histogram. .TP 1st, 2nd This is a range of latency, in microseconds (shown in "[...)" set notation). .TP 3rd A column showing the count of operations in this range. .TP 4th This is an ASCII histogram representing the count column. .SH OVERHEAD This adds low-overhead instrumentation to these XFS operations, including reads and writes from the file system cache. Such reads and writes can be very frequent (depending on the workload; eg, 1M/sec), at which point the overhead of this tool may become noticeable. Measure and quantify before use. .SH SOURCE This is from bpftrace. .IP https://github.com/bpftrace/bpftrace .PP Also look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. This is a bpftrace version of the bcc tool of the same name. The bcc tool may provide more options and customizations. .IP https://github.com/iovisor/bcc .SH OS Linux .SH STABILITY Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO biolatency.bt(8) bpftrace-0.27.1/scripts/000077500000000000000000000000001526721631600150675ustar00rootroot00000000000000bpftrace-0.27.1/scripts/bash-completion/000077500000000000000000000000001526721631600201535ustar00rootroot00000000000000bpftrace-0.27.1/scripts/bash-completion/bpftrace000066400000000000000000000041551526721631600216710ustar00rootroot00000000000000# bash completion of bpftrace(8) _bpftrace_filedir() { # bash-completion 2.11-1091-g6e8a1546bde2 rename _filedir to _comp_compgen_filedir if [[ ${BASH_COMPLETION_VERSINFO[0]} == 2 ]] && \ [[ ${BASH_COMPLETION_VERSINFO[1]} > 11 ]]; then _comp_compgen_filedir "${@}" else _filedir "${@}" fi } _bpftrace() { local cur prev words argument _init_completion -- "$@" || return local all_args='-B -f -o -e -h --help -I --include -l -p --dwarf-pid -c --usdt-file-activation --unsafe -q --quiet --info -k --warnings -V --version --no-warnings -v --dry-run --mode --test --bench --probe-filter --traceable-functions -d --debug --debuginfo --emit-elf --emit-llvm' if [[ $cur == -* ]]; then argument=$cur fi case ${prev} in -B) COMPREPLY=( $(compgen -W "line full none" -- ${cur}) ) return 0 ;; -f) COMPREPLY=( $(compgen -W "text json" -- ${cur}) ) return 0 ;; -c) COMPREPLY=( $(compgen -c -- ${cur}) ) return 0 ;; -o | --include | --emit-elf | --emit-llvm | --traceable-functions | --debuginfo) _bpftrace_filedir return 0 ;; --mode) COMPREPLY=( $(compgen -W "codegen compiler-bench bench test format" -- ${cur}) ) return 0 ;; -I) _bpftrace_filedir -d return 0 ;; -p | --dwarf-pid) local PIDS=$(cd /proc && echo [0-9]*) COMPREPLY=( $(compgen -W "$PIDS" -- ${cur}) ) return 0 ;; -d | --debug) debug_stage=( all ast types codegen codegen-opt dis parse libbpf verifier ) COMPREPLY=( $(compgen -W "${debug_stage[*]}" -- ${cur}) ) return 0 ;; -h | --help | -V | --version | --info) return ;; esac # bpftrace directly specifies the script, like: bpftrace a.bt if [[ ! ${argument} ]]; then _bpftrace_filedir else # Just drop -e,--probe-filter content completion, because it's very complex. if ([[ ${cur} == -* ]] || [[ -z ${cur} ]]) && [[ ! " -e --probe-filter " =~ " ${prev} " ]]; then COMPREPLY=( $(compgen -W "${all_args}" -- ${cur}) ) return fi fi } complete -F _bpftrace bpftrace bpftrace-0.27.1/scripts/bpftrace_tidy.sh000077500000000000000000000017641526721631600202550ustar00rootroot00000000000000#!/usr/bin/env bash # Runs bpftrace --fmt against the codebase. # Requires nix. # # Example usage: # # ./scripts/bpftrace_tidy.sh # set -eu shopt -s globstar BUILD_DIR=build-bpftrace-tidy SCRIPT_NAME=$0 function run() { nix develop --command "$@" } usage() { echo "Usage:" echo " ${SCRIPT_NAME} [OPTIONS]" echo "" echo " Run 'bpftrace --fmt' for all '.bt' files with nix." echo "" echo "OPTIONS" echo " -d Change the default build directory. Default: ${BUILD_DIR}" } while getopts ":d:h" opt; do case "${opt}" in d ) BUILD_DIR=${OPTARG} ;; h ) usage exit 0 ;; * ) echo "Unknown option ${opt}" exit 1 ;; esac done # Change dir to project root, and build bpftrace. cd "$(git rev-parse --show-toplevel)" run cmake -B "$BUILD_DIR" run make -C "$BUILD_DIR" -j "$(nproc)" # Run the formatter on all files. run find src tests tools -name '*.bt' -exec "$BUILD_DIR/src/bpftrace" --fmt {} -o {} \; bpftrace-0.27.1/scripts/check_kernel_features.sh000077500000000000000000000023401526721631600217400ustar00rootroot00000000000000#!/bin/sh # Report missing kernel features # # Usage: ./check_kernel_features.sh [PATH_TO_KERNEL_CONFIG] set -e set -u err=0 config='' # Find kernel config for c in "$@" "/boot/config-$(uname -r)" "/boot/config" "/proc/config.gz"; do if [ -r "$c" ]; then config="$c" break fi done if [ -z "$config" ]; then echo "Could not find kernel config, please supply it as argument." >&2 exit 1 fi # Check feature check_opt() { if ! zgrep -qE "^${1}[[:space:]]*=[[:space:]]*[y|Y]" "$config"; then err=1 echo "Required option ${1} not set" >&2 fi } check_opt 'CONFIG_BPF' check_opt 'CONFIG_BPF_EVENTS' check_opt 'CONFIG_BPF_JIT' check_opt 'CONFIG_BPF_SYSCALL' check_opt 'CONFIG_FTRACE_SYSCALLS' check_opt 'CONFIG_HAVE_EBPF_JIT' check_opt 'CONFIG_FUNCTION_TRACER' check_opt 'CONFIG_HAVE_DYNAMIC_FTRACE' check_opt 'CONFIG_DYNAMIC_FTRACE' check_opt 'CONFIG_HAVE_KPROBES' check_opt 'CONFIG_KPROBES' check_opt 'CONFIG_KPROBE_EVENTS' check_opt 'CONFIG_ARCH_SUPPORTS_UPROBES' check_opt 'CONFIG_UPROBES' check_opt 'CONFIG_UPROBE_EVENTS' check_opt 'CONFIG_DEBUG_FS' # Status report if [ $err -eq 0 ]; then echo "All required features present!" else echo "Missing required features" fi exit $err bpftrace-0.27.1/scripts/clang_tidy.sh000077500000000000000000000036761526721631600175570ustar00rootroot00000000000000#!/usr/bin/env bash # Runs clang-tidy against the codebase. # Requires nix. # # Example usage: # # ./scripts/clang_tidy.sh # set -eu shopt -s globstar BUILD_DIR=build-clang-tidy SCRIPT_NAME=$0 FIX= function run() { nix develop --command "$@" } usage() { echo "Usage:" echo " ${SCRIPT_NAME} [OPTIONS]" echo "" echo " Run clang-tidy and optional apply fixes with nix." echo "" echo "OPTIONS" echo " -u Update with fixes." echo " -d Change the default build directory. Default: ${BUILD_DIR}" } while getopts ":d:uh" opt; do case "${opt}" in u ) FIX=-fix ;; d ) BUILD_DIR=${OPTARG} ;; h ) usage exit 0 ;; * ) echo "Unknown option ${opt}" exit 1 ;; esac done # Change dir to project root cd "$(git rev-parse --show-toplevel)" # Clang-tidy has native integration with compile_commands.json. # Generate it here so that we can teach clang-tidy how to "build" bpftrace. run cmake -B "$BUILD_DIR" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 # We also generate header files here and there. Rather than hard # code which files are generated, just build the entire project # to keep it simple. run make -C "$BUILD_DIR" -j "$(nproc)" # Note that `run-clang-tidy` comes from `clang` nix package but shells out to # `clang-tidy` and `clang-apply-replacements` from `clang-tools` nix package. # This may just be trivia but seems like a good gotcha to point out. # # Also note we explicitly pass in the files we want to lint. We could # omit the file list but then generated files from flex/bison will start # spewing. # # Also note $FIX is supposed to be unquoted. The problem is if it's quoted # and unset, then it's an empty arg and run-clang-tidy will treat it as # an empty regex which causes all sorts of trouble. run run-clang-tidy -q -format -config-file .clang-tidy -p "$BUILD_DIR" $FIX \ '(?!.*/(libbpf)/).*(src|tests)/.*\.(h|cpp)$' bpftrace-0.27.1/scripts/compare_tool_elf.sh000077500000000000000000000031371526721631600207430ustar00rootroot00000000000000#!/bin/bash # Compare the ELF generated for the shipped # tools between two bpftrace builds # set -o pipefail set -e set -u if [[ "$#" -ne 4 ]]; then echo "Compare IR generated between two bpftrace builds" echo "" echo "USAGE:" echo "$(basename "$0") " echo "" echo "EXAMPLE:" echo "$(basename "$0") bpftrace_master bpftrace llvm-objdump-7 ./tools" echo "" exit 1 fi BPF_A=$(command -v "$1") || ( echo "ERROR: $1 not found"; exit 1 ) BPF_B=$(command -v "$2") || ( echo "ERROR: $2 not found"; exit 1 ) OBJDUMP=$(command -v "$3") || (echo "ERROR: $3 not found"; exit 1 ) TOOLDIR=$4 [[ -d "$TOOLDIR" ]] || (echo "tooldir does not appear to be a directory: ${TOOLDIR}"; exit 1) TMPDIR=$(mktemp -d) [[ $? -ne 0 || -z $TMPDIR ]] && (echo "Failed to create tmp dir"; exit 10) cd "$TMPDIR" set +e function hash() { sha1sum "${1}" | awk '{print $1}' } echo "Using version $($BPF_A -V) and $($BPF_B -V)" for script in "${TOOLDIR}"/*.bt; do s=$(basename "${script/.bt/}") echo "Checking $s" if ! $BPF_A --emit-elf "a_${s}" "$script" >/dev/null 2>&1 || ! $BPF_B --emit-elf "b_${s}" "$script" >/dev/null 2>&1; then echo "###############################" echo "bpftrace failed on script: ${s}" echo "###############################" continue fi if [[ $(hash "a_${s}") != $(hash "b_${s}") ]]; then echo "###############################" echo "Change detected for script: ${s}" diff -u <($OBJDUMP -S "a_${s}") <($OBJDUMP -S "b_${s}") fi done [[ -n ${TMPDIR} ]] && rm -rf "${TMPDIR}" bpftrace-0.27.1/scripts/compare_tool_speed.sh000077500000000000000000000041741526721631600212770ustar00rootroot00000000000000#!/bin/bash # Compare the processing speed for the shipped # tools between two bpftrace builds # # based on scripts/compare_tool_speed.h # set -o pipefail set -e set -u if [[ "$#" -lt 3 ]]; then echo "Compare tools' speed between two bpftrace builds" echo "" echo "USAGE:" echo "$(basename "$0") [] []" echo "" echo "EXAMPLE:" echo "$(basename "$0") bpftrace bpftrace_master ./tools" echo "" echo "NOTE: assume that second bpftrace binary is newer" exit 1 fi TOOLDIR=$3 BPF_A=$(command -v "$1") || ( echo "ERROR: $1 not found"; exit 1 ) BPF_B=$(command -v "$2") || ( echo "ERROR: $2 not found"; exit 1 ) [[ -d "$TOOLDIR" ]] || (echo "tooldir does not appear to be a directory: ${TOOLDIR}"; exit 1) TMPDIR=$(mktemp -d) [[ $? -ne 0 || -z $TMPDIR ]] && (echo "Failed to create tmp dir"; exit 10) cd "$TMPDIR" set +e TESTMODE=${4:-codegen} if [[ $TESTMODE != "codegen" ]]; then echo invalid testmode: "$TESTMODE" exit 20 fi THRESHOLD=${5:-1} TIME="/usr/bin/time -f%e --" FLAGS=(--no-warnings --test "$TESTMODE") echo "$TESTMODE" test echo "Using version $($BPF_A -V) and $($BPF_B -V)" MAXLEN=0 for script in "${TOOLDIR}"/*.bt; do s=$(basename "${script/.bt/}") len=${#s} if [[ "$MAXLEN" -lt "$len" ]]; then MAXLEN=$len fi done echo -n " script" for _ in $(seq 0 1 $((MAXLEN - 6))); do echo -n ' '; done echo "A B diff" for script in "${TOOLDIR}"/*.bt; do s=$(basename "${script/.bt/}") len=${#s} space=$((MAXLEN - len)) echo -n "Checking $s" for _ in $(seq 0 1 $space); do echo -n ' '; done if ! a=$($TIME "$BPF_A" "${FLAGS[@]}" "$script" 3>&1 1>&2 2>&3 3>&-) || ! b=$($TIME "$BPF_B" "${FLAGS[@]}" "$script" 3>&1 1>&2 2>&3 3>&-); then echo "###############################" echo "bpftrace failed on script: ${s}" echo "###############################" continue fi d=$(echo "$b" - "$a" | bc) t=$(echo "$d > $THRESHOLD" | bc) mark="" if [[ "$t" -eq 1 ]]; then mark="*" fi echo "$a $b $d$mark" done [[ -n ${TMPDIR} ]] && rm -rf "${TMPDIR}" bpftrace-0.27.1/scripts/create-assets.sh000077500000000000000000000043551526721631600202000ustar00rootroot00000000000000#!/bin/bash # # This script creates builds the official release artifacts. # # Usage examples: # ./scripts/create-assets.sh # OUT=../out-dir ./scripts/create-assets.sh # # Arch-specific assets (the binary and the bundle) are suffixed with the host # architecture # # Tools and man pages are only built when BUILD_SHARED_ASSETS=1. # ZSTDFLAGS="-19" ARCH="$(uname -m)" # Whether to also build the arch-independent archives (tools, man pages). : "${BUILD_SHARED_ASSETS:=1}" function err() { echo >&2 "$(tput setaf 1)ERROR: $*$(tput sgr0)" exit 1 } function info() { echo "$(tput bold)$*$(tput sgr0)" } [[ -d tools ]] || err "'tools' directory not found, run script from bpftrace root dir" [[ -d man ]] || err "'man' directory not found, run script from bpftrace root dir" command -v zstd >/dev/null 2>&1 || err "zstd command not found, required for release" command -v asciidoctor >/dev/null 2>&1 || err "asciidoctor not found, required for manpage" # Take value from environment if set, otherwise use a tempdir : "${OUT:=$(mktemp -d)}" || err "Failed to create temp dir" TMP="${OUT}/tmp" echo "Using '$OUT' as assert dir" set -e info "Staging tools" # bit of copying to avoid confusing tar flags not great but works mkdir -p "$TMP/bin" cp tools/*.bt "$TMP/bin" chmod +x "$TMP/bin/"*.bt info "Staging man pages" mkdir -p "$TMP/share/man/man8" cp man/man8/*.8 "$TMP/share//man/man8/" gzip -n "$TMP/share/man/man8/"* asciidoctor man/adoc/bpftrace.adoc -b manpage -o - | gzip -n - > "$TMP/share/man/man8/bpftrace.8.gz" # The tools and man archives are arch-independent, so only one runner needs to # build them for a multi-arch release. if [[ "$BUILD_SHARED_ASSETS" == "1" ]]; then info "Creating tools archive" tar --xz -cf "$OUT/tools.tar.xz" -C "$TMP/bin" "." info "Creating man archive" tar --xz -cf "$OUT/man.tar.xz" -C "$TMP/share" man fi info "Building bpftrace appimage" nix build .?submodules=1#appimage info "Creating bundle" cp ./result "$OUT/bpftrace-$ARCH" cp ./result "$TMP/bin/bpftrace" tar -cf "$OUT/binary_tools_man-bundle-$ARCH.tar" -C "$TMP" bin share zstd $ZSTDFLAGS -q -k "$OUT/binary_tools_man-bundle-$ARCH.tar" xz "$OUT/binary_tools_man-bundle-$ARCH.tar" echo "All assets created in $OUT" [[ -d "$TMP" ]] && rm -rf "$TMP" bpftrace-0.27.1/scripts/generate_stdlib_docs.py000077500000000000000000000143331526721631600216130ustar00rootroot00000000000000#!/usr/bin/env python3 """ Python script to generate documentation in stdlib.md """ import glob import os import sys import re from typing import Optional class Helper: name: str = "" variants: list[str] = [] deprecated_variants: list[str] = [] description: str = "" def __init__(self): self.variants = [] self.deprecated_variants = [] def parse_variant_string(line: str) -> Optional[str]: pattern = r':variant\s+(.+)' match = re.match(pattern, line.strip()) if match: return match.group(1).strip() return None def parse_deprecated_variant_string(line: str) -> Optional[str]: pattern = r':deprecated_variant\s+(.+)' match = re.match(pattern, line.strip()) if match: return match.group(1).strip() return None def variant_has_no_args(variant: str) -> bool: return "()" in variant def parse_function_name_string(line: str) -> Optional[str]: pattern = r':function\s+(.+)' match = re.match(pattern, line.strip()) if match: return match.group(1).strip() return None def parse_macro_name(line: str) -> Optional[str]: # Pattern to match "macro name(" pattern = r'macro\s+([^(]+)\(' match = re.match(pattern, line.strip()) if match: return match.group(1).strip() return None def read_file_lines(file_path: str) -> Optional[list[Helper]]: helpers: list[Helper] = [] try: if not os.path.exists(file_path): print(f"Error: File '{file_path}' not found.") return None current = Helper() with open(file_path, 'r', encoding='utf-8') as file: for line in file: line_content = line.lstrip().rstrip() if line_content.startswith("//"): # Don't strip, because we may have markdown with meaningful # whitespace at the beginning of the line that we preserve. line_content = line_content[2:] if len(line_content) > 0 and line_content[:1].isspace(): line_content = line_content[1:] if line_content.startswith(":variant"): parsed_variant = parse_variant_string(line_content) if parsed_variant: current.variants.append(parsed_variant) if variant_has_no_args(parsed_variant): current.variants.append(parsed_variant.replace("()", "")) elif line_content.startswith(":deprecated_variant"): parsed_variant = parse_deprecated_variant_string(line_content) if parsed_variant: current.deprecated_variants.append(parsed_variant) elif line_content.startswith(":function"): parsed_function_name = parse_function_name_string(line_content) if parsed_function_name: current.name = parsed_function_name elif line_content or current.description: current.description += line_content + "\n" elif line_content.startswith("macro"): parsed_name = parse_macro_name(line_content) if parsed_name: current.name = parsed_name # There must at least be a description or it's an # undocumented macro. if current.description: helpers.append(current) current = Helper() else: if current.name and current.description: helpers.append(current) current = Helper() if current.name and current.description: helpers.append(current) return helpers except PermissionError: print(f"Error: Permission denied to read '{file_path}'.") return None except UnicodeDecodeError: print(f"Error: Unable to decode '{file_path}' as UTF-8.") return None except Exception as e: print(f"Error reading file '{file_path}': {e}") return None def write_markdown_doc(helpers: list[Helper]): print("Writing markdown file to docs/stdlib.md") current_lines = [] with open("docs/stdlib.md", "r", encoding="utf-8") as file: current_lines = file.readlines() in_helpers_section = False cleaned_lines = [] for raw_line in current_lines: line = raw_line.strip() if line == "## Helpers": in_helpers_section = True elif line == "## Map Value Functions": in_helpers_section = False elif in_helpers_section: continue cleaned_lines.append(raw_line) updated_lines = [] for cleaned_line in cleaned_lines: line = cleaned_line.strip() if line == "## Helpers": updated_lines.append(cleaned_line) updated_lines.append("\n") for helper in helpers: updated_lines.append(f"### {helper.name}\n") for variant in helper.variants: updated_lines.append(f"- `{variant}`\n") for variant in helper.deprecated_variants: updated_lines.append(f"- deprecated `{variant}`\n") updated_lines.append("\n") updated_lines.append(f"{helper.description}\n") updated_lines.append("\n") else: updated_lines.append(cleaned_line) with open("docs/stdlib.md", "w", encoding="utf-8") as file: file.writelines(updated_lines) def main(): stdlib_files = glob.glob("src/stdlib/**/*.bt", recursive=True) if len(stdlib_files) == 0: print("Didn't find any stdlib files") sys.exit(1) else: print(f"All stdlib files: {stdlib_files}") all_helpers: list[Helper] = [] for file in stdlib_files: helpers = read_file_lines(file) if helpers: all_helpers += helpers if len(all_helpers) > 0: sorted_by_name = sorted(all_helpers, key=lambda h: h.name) write_markdown_doc(sorted_by_name) else: sys.exit(1) if __name__ == "__main__": main() bpftrace-0.27.1/scripts/seccomp.c000066400000000000000000000130001526721631600166560ustar00rootroot00000000000000// Compile with gcc seccomp.c -lseccomp -ggdb -o seccomp #include #include #include #include #include #include #include #include #include void help() { printf("Simulate bpf(2) syscall failures based on the bpf(2) command "); printf("executed\n"); printf("\n"); printf("USAGE:\n"); printf("./seccomp [OPTIONS] -- command [args]"); printf("./seccomp -e map_create:11 -- bpftrace -e ...\n"); printf("./seccomp -e map_create:100 -k prog_load -- ./src/bpftrace -e "); printf("'i:s:1 { @=5 }'\n"); printf("\n"); printf("OPTIONS:\n"); printf("\t-k [NAME] Kill program when bpf is called with this command\n"); printf("\t-e [NAME]:[ERRNO] Set errno to ERRNO program when bpf is called "); printf("with this command\n"); printf("\t-l List known bpf commands\n"); printf("\n"); exit(0); } struct entry { const int value; const char* symbol; const char* name; }; #define ENTRY(symbol, name) \ { \ symbol, #symbol, name \ } static const struct entry bpf_commands[] = { ENTRY(BPF_MAP_CREATE, "map_create"), ENTRY(BPF_MAP_LOOKUP_ELEM, "map_lookup_elem"), ENTRY(BPF_MAP_UPDATE_ELEM, "map_update_elem"), ENTRY(BPF_MAP_DELETE_ELEM, "map_delete_elem"), ENTRY(BPF_MAP_GET_NEXT_KEY, "map_get_next_key"), ENTRY(BPF_PROG_LOAD, "prog_load"), ENTRY(BPF_OBJ_PIN, "obj_pin"), ENTRY(BPF_OBJ_GET, "obj_get"), ENTRY(BPF_PROG_ATTACH, "prog_attach"), ENTRY(BPF_PROG_DETACH, "prog_detach"), ENTRY(BPF_PROG_TEST_RUN, "prog_test_run"), ENTRY(BPF_PROG_GET_NEXT_ID, "prog_get_next_id"), ENTRY(BPF_MAP_GET_NEXT_ID, "map_get_next_id"), ENTRY(BPF_PROG_GET_FD_BY_ID, "prog_get_fd_by_id"), ENTRY(BPF_MAP_GET_FD_BY_ID, "map_get_fd_by_id"), ENTRY(BPF_OBJ_GET_INFO_BY_FD, "obj_get_info_by_fd"), ENTRY(BPF_PROG_QUERY, "prog_query"), ENTRY(BPF_RAW_TRACEPOINT_OPEN, "raw_tracepoint_open"), ENTRY(BPF_BTF_LOAD, "btf_load"), ENTRY(BPF_BTF_GET_FD_BY_ID, "btf_get_fd_by_id"), ENTRY(BPF_TASK_FD_QUERY, "task_fd_query"), }; void list(void) { for (int x = 0; x < sizeof(bpf_commands) / sizeof(struct entry); x++) { printf("name: %s\tflag: %s\n", bpf_commands[x].name, bpf_commands[x].symbol); } exit(0); } // Search the bpf_commands table for an entry for with symbol or name matches // the argument name // // Return the bpf command value or -1 if the lookup failed int lookup_cmd(char* name) { for (int x = 0; x < sizeof(bpf_commands) / sizeof(struct entry); x++) { if (strcmp(name, bpf_commands[x].name) == 0 || strcmp(name, bpf_commands[x].symbol) == 0) { return bpf_commands[x].value; } } return -1; } // Parse the errno string and add the required filter to seccomp int add_errno(scmp_filter_ctx* ctx, char* str) { assert(ctx != NULL); assert(str != NULL); char* substr = strchr(str, ':'); if (substr == NULL) { printf("Expected ERRNO format \"COMMAND:ERRNO\", got: %s\n", str); return -1; } // Copy command to a new string int keysize = substr - str; char* buf = malloc((keysize + 1) * sizeof(char)); assert(buf != NULL); strncpy(buf, str, keysize); // convert ERRNO to positive int int err = atoi(substr + 1); if (err < 0) { err *= -1; } // Find the command ID int command = lookup_cmd(buf); if (command < 0) { printf("Unknown bpf command: %s\n", buf); goto exit; } int rc = seccomp_rule_add(*ctx, SCMP_ACT_ERRNO(err), SCMP_SYS(bpf), 1, SCMP_A0(SCMP_CMP_EQ, command)); if (rc < 0) { printf("Failed to add ERRNO(%d) filter for command: %s(%d): %s\n", err, buf, command, strerror(rc * -1)); } else { printf("Added ERRNO(%d) for command: %s(%d)\n", err, buf, command); } exit: free(buf); } // Parse CLI args, setup seccomp and execve into the command int main(int argc, char** argv) { int index; int c; opterr = 0; scmp_filter_ctx ctx; ctx = seccomp_init(SCMP_ACT_ALLOW); if (ctx == NULL) { printf("Failed to init seccomp\n"); } while ((c = getopt(argc, argv, "k:e:hl")) != -1) { switch (c) { case 'h': help(); break; case 'l': list(); break; case 'k': { int v = lookup_cmd(optarg); if (v >= 0) { int rc = seccomp_rule_add( ctx, SCMP_ACT_KILL, SCMP_SYS(bpf), 1, SCMP_A0(SCMP_CMP_EQ, v)); if (rc < 0) { printf("Failed to add KILL filter for command: %s: %s\n", optarg, strerror(-1 * rc)); } else { printf("Added KILL for command: %s\n", optarg); } } else { printf("Unknown bpf command: %s\n", optarg); } break; } case 'e': add_errno(&ctx, optarg); break; default: printf("Unknown option: %s\n", optarg); break; } } if (argc - optind < 2) { printf("expected command with arguments\n"); goto abort; } seccomp_load(ctx); printf("Executing: "); for (int i = optind; i < argc; i++) { printf("%s ", argv[i]); } printf("\n------------\n\n"); int rc = execve(argv[optind], argv + optind, NULL); printf("Execve failed: %d, %s\n", rc, strerror(errno)); abort: seccomp_release(ctx); } bpftrace-0.27.1/scripts/shellcheck.sh000077500000000000000000000014051526721631600175330ustar00rootroot00000000000000#!/usr/bin/env bash # Runs shellcheck against the codebase. # Requires nix. # # Example usage: # # ./scripts/shellcheck.sh # set -eu shopt -s globstar SCRIPT_NAME=$0 function run() { nix develop --command "$@" } usage() { echo "Usage:" echo " ${SCRIPT_NAME} [OPTIONS]" echo "" echo " Run shellcheck for all '.sh' files with nix." } while getopts ":h" opt; do case "${opt}" in h ) usage exit 0 ;; * ) echo "Unknown option ${opt}" exit 1 ;; esac done # Change dir to project root. cd "$(git rev-parse --show-toplevel)" # Run shellcheck on all bpftrace shell scripts (excluding the libbpf submodule). run find .github scripts tests -path './libbpf' -prune -o -name '*.sh' -exec shellcheck {} \; bpftrace-0.27.1/scripts/sync_headers.sh000077500000000000000000000153201526721631600200760ustar00rootroot00000000000000#!/usr/bin/env bash # Syncs headers from a local kernel repository. # # This script attempts to find the transitive closure over the C headers that # are generally needed for BPF programs. This is not an easy task: headers can # include other headers based on `#define`s (e.g. whether `__KERNEL__` is set) # and these defines are often set for BPF programs, and headers can include # different headers depend on the architecture. This script is fundamentally # fragile, and contains hacks in an attempt to do the right thing. This script # should improve over time as these special cases are identified, and as our # requirements for C interop generally become less ambiguous. # # Please include the kernel commit used when checking in new synced headers. # # Example usage: # # ./scripts/sync_headers.sh ~/my-linux-repo # set -eu shopt -s globstar SCRIPT_NAME=$0 usage() { echo "Usage:" echo " ${SCRIPT_NAME} " echo "" echo " Sync vendored headers for the standard library." } if [[ "$#" -ne 1 ]]; then usage exit 1 fi declare -r LINUX=$1 # The `HEADERS` variable contains a list of general purpose headers that are # known to be important/useful for building the standard library and C # extensions. This is seeded by the set that have been vendored by `libbpf`. # # The key is the header (relative to the include path) and the value is whether # this require is required (failure to include is a failure). declare -A HEADERS HEADERS=( ["linux/bpf_common.h"]=true ["linux/bpf.h"]=true ["linux/btf.h"]=true ["linux/errno.h"]=true ["linux/fcntl.h"]=true ["linux/openat2.h"]=true ["linux/if_link.h"]=true ["linux/if_xdp.h"]=true ["linux/netdev.h"]=true ["linux/netlink.h"]=true ["linux/pkt_cls.h"]=true ["linux/pkt_sched.h"]=true ["linux/perf_event.h"]=true # These are not neccessary found transitively, since it depends on the # current architecture. So add these explicitly. ["linux/byteorder/little_endian.h"]=true ["linux/byteorder/big_endian.h"]=true # These are also not always found transitively. ["linux/kernel.h"]=true ["linux/netdev.h"]=true ["linux/sysinfo.h"]=true # This is not necessarily found transitively, and is not available at all # for certain archiectures. So allow failure for this file. ["asm/posix_types_64.h"]=false # These will end up coming from the non-uapi kernel directory, but may be # included when code is built as `__KERNEL__`. They won't be found be the # automatic transitive search, so we add them manually. ["linux/compiler.h"]=true ["linux/compiler_types.h"]=true ["linux/compiler_attributes.h"]=true ["linux/kasan-checks.h"]=true ["linux/kcsan-checks.h"]=true ["linux/compiler-clang.h"]=true # N.B. only care about clang. ["asm/rwonce.h"]=true ) # When a header is found to be sourced from an `asm/` directory, we will # identify all the other architecture variants that need to be copied. This is # a list of the Linux architecture directories that we will create and check. # Transient headers are subject to the same `required` status as the original. declare -a ARCHES ARCHES=( "x86" "arm" "arm64" "s390" "powerpc" "mips" "riscv" "loongarch" ) function sync() { local -r header=$1 if [[ "$header" =~ asm/.* ]]; then # We are but a single architecture. When copying any architecture-specific # header, we attempt to copy versions from all architectures and put them # in `asm/${arch}` instead. This is then resolved at runtime into the # correct directory. While we build different versions of the binary with # different files, this is a simple enough scheme. See the `ClangBuild` # pass for where this is effectively undone. asmpath="${header##asm/}" for arch in "${ARCHES[@]}"; do if [[ -f "src/stdlib/include/asm/${arch}/${asmpath}" ]]; then # This is done already. Since one assembly header exists, they all must # exist and we don't want to bother doing the transitive check. return 0 fi echo -n "Syncing arch-specific ${header} for ${arch}..." 2>&1 basepath=$(dirname "asm/${arch}/${asmpath}") mkdir -p "src/stdlib/include/${basepath}" # Attempt to copy from the arch-specific directory, but fall back to # the `asm-generic` directory if it is not present there. This is the # case for some files, as these may be merged in the exported version. if ! (cp --preserve=mode "${LINUX}/arch/${arch}/include/uapi/asm/${asmpath}" \ "src/stdlib/include/${basepath}" 2>/dev/null || cp --preserve=mode "${LINUX}/include/uapi/asm-generic/${asmpath}" \ "src/stdlib/include/${basepath}" 2>/dev/null || \ cp --preserve=mode "${LINUX}/include/asm-generic/${asmpath}" \ "src/stdlib/include/${basepath}" 2>/dev/null); then # We can specifically ignore this header. if [[ "${HEADERS[$header]}" != "false" ]]; then echo "failed." return 1 else echo "skipped." fi else echo "done." fi done else # This is a simpler header and is not arch-specific. if [[ -f "src/stdlib/include/${header}" ]]; then return 0 # Done already, see above. fi echo -n "Syncing ${header}..." 2>&1 basepath=$(dirname "${header}") mkdir -p "src/stdlib/include/${basepath}" if ! (cp --preserve=mode "${LINUX}/include/uapi/${header}" \ "src/stdlib/include/${basepath}" 2>/dev/null || \ cp --preserve=mode "${LINUX}/include/${header}" \ "src/stdlib/include/${basepath}" 2>/dev/null); then # We can specifically ignore this header. if [[ "${HEADERS[$header]}" != "false" ]]; then echo "failed." return 1 else echo "skipped." fi else echo "done." fi fi # In order to discover transitive headers required, we run a basic compile # and emit all touched headers. Note that this is run on the **system** # headers, and therefore assumes a stable structure for user headers. # Kernel-specific headers will need to be listed manually above, this step is # effectively best-effort. local -r tmpfile=$(mktemp --tmpdir "XXXXXX.c") echo "#include <$1>" > "${tmpfile}" local _nesting local transitive_header clang -H -o /dev/null -c "${tmpfile}" 2>&1 | grep -E '.h$' | \ (while read -r _nesting transitive_header; do local relpath="${transitive_header##*/include/}" sync "${relpath}" done) rm -f "${tmpfile}" } # Wipe existing synced headers. rm -rf \ src/stdlib/include/asm \ src/stdlib/include/asm-* \ src/stdlib/include/linux # Recursively vendor headers. for header in "${!HEADERS[@]}"; do sync "${header}" done bpftrace-0.27.1/scripts/tracepoint_variable_sized_types.py000066400000000000000000000023621526721631600241030ustar00rootroot00000000000000# This script lists all the types in the kernel's tracepoint format files # which appear with more than one size. This script's output should be # compared to the code in TracepointFormatParser::adjust_integer_types() import glob field_types = {} for format_file_name in glob.iglob("/sys/kernel/debug/tracing/events/*/*/format"): with open(format_file_name) as format_file: for line in format_file: if not line.startswith("\tfield:"): continue size_section = line.split(";")[2].split(":") if size_section[0] != "\tsize": continue size_val = size_section[1] field_section = line.split(";")[0].split(":") if field_section[0] != "\tfield": continue field_val = field_section[1] if "[" in field_val or "*" in field_val: continue field_type = " ".join(field_val.split()[:-1]) if field_type not in field_types: field_types[field_type] = set() field_types[field_type].add(size_val) for t in sorted(field_types): sizes = field_types[t] if len(sizes) > 1: sizes_str = ",".join(sorted(sizes)) print(f"{t}: {sizes_str}") bpftrace-0.27.1/src/000077500000000000000000000000001526721631600141675ustar00rootroot00000000000000bpftrace-0.27.1/src/CMakeLists.txt000066400000000000000000000161551526721631600167370ustar00rootroot00000000000000if(HAVE_BFD_DISASM) set(BFD_DISASM_SRC bfd-disasm.cpp) endif() # These add -fsanitize=... to all below compiler invocations, including # subdirectories. add_compile_options($<$:-fsanitize=address>) add_compile_options($<$:-fsanitize=undefined>) add_library(required_resources required_resources.cpp) add_library(compiler_core STATIC functions.cpp struct.cpp types.cpp ) add_library(runtime STATIC async_action.cpp attached_probe.cpp bpffeature.cpp bpftrace.cpp bpfbytecode.cpp bpfmap.cpp bpfprogram.cpp btf.cpp config.cpp disasm.cpp dwarf_parser.cpp format_string.cpp globalvars.cpp log.cpp probe_matcher.cpp probe_types.cpp run_bpftrace.cpp pcap_writer.cpp types_format.cpp ksyms.cpp usyms.cpp dwarf/dwunwind.cpp dwarf/dwunwind_loader.cpp dwarf/dwunwind_table.cpp ${BFD_DISASM_SRC} ) add_library(libbpftrace STATIC build_info.cpp lockdown.cpp parser.cpp ) # So it's not "liblibbpftrace" set_target_properties(libbpftrace PROPERTIES PREFIX "") add_executable(bpftrace main.cpp benchmark.cpp ) # TODO: Honor `STATIC_LINKING` properly. if(LIBBLAZESYM_FOUND) target_link_libraries(runtime ${LIBBLAZESYM_LIBRARIES}) endif() install(TARGETS bpftrace DESTINATION ${CMAKE_INSTALL_BINDIR}) target_compile_definitions(bpftrace PRIVATE ${BPFTRACE_FLAGS}) # TODO(Jiawei Zhao): this conditional can be removed when we no longer use bcc. if(STATIC_LINKING) target_link_libraries(bpftrace libbpftrace) else() target_link_libraries(bpftrace libbpftrace ${LIBBPF_LIBRARIES}) endif(STATIC_LINKING) # compile definitions # This is run on every build to ensure the version string is always up-to-date add_custom_target(version_h COMMAND ${CMAKE_COMMAND} -DVERSION_H_IN=${CMAKE_CURRENT_SOURCE_DIR}/version.h.in -DVERSION_H=${CMAKE_BINARY_DIR}/version.h -Dbpftrace_VERSION_MAJOR=${bpftrace_VERSION_MAJOR} -Dbpftrace_VERSION_MINOR=${bpftrace_VERSION_MINOR} -Dbpftrace_VERSION_PATCH=${bpftrace_VERSION_PATCH} -Dbpftrace_SOURCE_DIR=${CMAKE_SOURCE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/Version.cmake ) add_dependencies(runtime version_h) add_dependencies(bpftrace version_h) add_dependencies(libbpftrace version_h) target_compile_definitions(required_resources PRIVATE ${BPFTRACE_FLAGS}) target_compile_definitions(runtime PRIVATE ${BPFTRACE_FLAGS}) target_include_directories(libbpftrace PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_compile_definitions(libbpftrace PRIVATE ${BPFTRACE_FLAGS}) # Linking target_link_options(bpftrace BEFORE PRIVATE $<$:-static-libgcc> $<$:-static-libstdc++> ) target_link_libraries(runtime debugfs output symbols tracefs util) target_link_libraries(runtime ${LIBBPF_LIBRARIES} ${ZLIB_LIBRARIES}) target_link_libraries(libbpftrace "-Wl,--start-group" runtime symbols aot ast arch util cxxdemangler_llvm "-Wl,--end-group") if(LIBPCAP_FOUND) target_link_libraries(libbpftrace ${LIBPCAP_LIBRARIES}) endif(LIBPCAP_FOUND) if(HAVE_BFD_DISASM) if(STATIC_LINKING OR LIBBFD_STATIC) add_library(LIBBFD STATIC IMPORTED) set_property(TARGET LIBBFD PROPERTY IMPORTED_LOCATION ${LIBBFD_LIBRARIES}) target_link_libraries(runtime LIBBFD) add_library(LIBOPCODES STATIC IMPORTED) set_property(TARGET LIBOPCODES PROPERTY IMPORTED_LOCATION ${LIBOPCODES_LIBRARIES}) target_link_libraries(runtime LIBOPCODES) add_library(LIBIBERTY STATIC IMPORTED) set_property(TARGET LIBIBERTY PROPERTY IMPORTED_LOCATION ${LIBIBERTY_LIBRARIES}) target_link_libraries(runtime LIBIBERTY) add_library(LIBZSTD STATIC IMPORTED) if (LIBZSTD_LIBRARIES) set_property(TARGET LIBZSTD PROPERTY IMPORTED_LOCATION ${LIBZSTD_LIBRARIES}) target_link_libraries(runtime LIBZSTD) endif(LIBZSTD_LIBRARIES) add_library(LIBSFRAME STATIC IMPORTED) if (LIBSFRAME_LIBRARIES) set_property(TARGET LIBSFRAME PROPERTY IMPORTED_LOCATION ${LIBSFRAME_LIBRARIES}) target_link_libraries(runtime LIBSFRAME) endif(LIBSFRAME_LIBRARIES) else() target_link_libraries(runtime ${LIBBFD_LIBRARIES}) target_link_libraries(runtime ${LIBOPCODES_LIBRARIES}) if (LIBZSTD_LIBRARIES) target_link_libraries(runtime ${LIBZSTD_LIBRARIES}) endif(LIBZSTD_LIBRARIES) endif(STATIC_LINKING OR LIBBFD_STATIC) endif(HAVE_BFD_DISASM) # Link to bcc libraries (without LLVM) if possible if(LIBBCC_BPF_CONTAINS_RUNTIME) target_link_libraries(runtime ${LIBBCC_BPF_LIBRARIES}) else() target_link_libraries(runtime ${LIBBCC_LIBRARIES}) endif() if(STATIC_LINKING) # These are not part of the static libbcc so have to be added separate target_link_libraries(runtime ${LIBBCC_BPF_LIBRARIES}) target_link_libraries(runtime ${LIBBPF_LIBRARIES}) target_link_libraries(runtime ${LIBBCC_LOADER_LIBRARY_STATIC}) find_package(LibLzma) add_library(LIBLZMA STATIC IMPORTED) set_property(TARGET LIBLZMA PROPERTY IMPORTED_LOCATION ${LIBLZMA_LIBRARIES}) target_link_libraries(runtime LIBLZMA) add_library(LIBELF STATIC IMPORTED) set_property(TARGET LIBELF PROPERTY IMPORTED_LOCATION ${LIBELF_LIBRARIES}) target_link_libraries(runtime LIBELF) else() target_link_libraries(runtime ${LIBELF_LIBRARIES}) endif(STATIC_LINKING) if (LIBDW_FOUND) if(STATIC_LINKING) find_package(LibBz2) find_package(LibEbl) add_library(LIBBZ2 STATIC IMPORTED) set_property(TARGET LIBBZ2 PROPERTY IMPORTED_LOCATION ${LIBBZ2_LIBRARIES}) add_library(LIBDW STATIC IMPORTED) set_property(TARGET LIBDW PROPERTY IMPORTED_LOCATION ${LIBDW_LIBRARIES}) set(LIBDW_LIBS LIBBZ2 LIBELF LIBLZMA) if (${LIBEBL_FOUND}) # libebl is not necessary on some systems (e.g. Alpine) add_library(LIBEBL STATIC IMPORTED) set_property(TARGET LIBEBL PROPERTY IMPORTED_LOCATION ${LIBEBL_LIBRARIES}) set(LIBDW_LIBS ${LIBDW_LIBS} LIBEBL) endif() target_link_libraries(LIBDW INTERFACE ${LIBDW_LIBS}) target_link_libraries(runtime LIBDW) else() target_link_libraries(runtime ${LIBDW_LIBRARIES}) endif() endif() # We do not use add_link_options here since it doesn't work for some reason. # Instead, just pass -fsanitize=... to the linker when linking the bpftrace # target. target_link_options(bpftrace PUBLIC $<$:-fsanitize=address>) target_link_options(bpftrace PUBLIC $<$:-fsanitize=undefined>) if (STATIC_LINKING) if(ANDROID) target_link_libraries(libbpftrace "-Wl,-Bdynamic" "-ldl" "-lm" "-lz") target_link_libraries(runtime "-Wl,-Bdynamic" "-ldl" "-lm" "-lz") else() target_link_libraries(libbpftrace "-Wl,-Bdynamic" "-lrt" "-lpthread" "-ldl" "-lm") target_link_libraries(libbpftrace "-Wl,-Bstatic" "-lz") target_link_libraries(runtime "-Wl,-Bdynamic" "-lrt" "-lpthread" "-ldl" "-lm") target_link_libraries(runtime "-Wl,-Bstatic" "-lz") endif() endif() if (ENABLE_SYSTEMD) target_link_libraries(runtime PkgConfig::libsystemd) endif() unset(BPFTRACE) add_subdirectory(aot) add_subdirectory(arch) add_subdirectory(ast) add_subdirectory(btf) add_subdirectory(cxxdemangler) add_subdirectory(debugfs) add_subdirectory(output) add_subdirectory(stdlib) add_subdirectory(symbols) add_subdirectory(tracefs) add_subdirectory(util) bpftrace-0.27.1/src/aot/000077500000000000000000000000001526721631600147525ustar00rootroot00000000000000bpftrace-0.27.1/src/aot/CMakeLists.txt000066400000000000000000000022241526721631600175120ustar00rootroot00000000000000add_library(aot STATIC aot.cpp) add_dependencies(aot version_h) target_link_libraries(aot required_resources) target_compile_definitions(aot PRIVATE ${BPFTRACE_FLAGS}) if(STATIC_LINKING) target_link_libraries(aot LIBELF) else() target_link_libraries(aot ${LIBELF_LIBRARIES}) endif(STATIC_LINKING) # Only build aotrt if supported bcc is used # (https://github.com/iovisor/bcc/commit/719191867a25ce07dc96f7faf9b8ccedadc7ec44) if(NOT LIBBCC_BPF_CONTAINS_RUNTIME) return() endif() add_executable(bpftrace-aotrt aot_main.cpp) target_compile_definitions(bpftrace-aotrt PRIVATE ${BPFTRACE_FLAGS}) target_link_libraries(bpftrace-aotrt aot runtime arch ast ast_defs util cxxdemangler_stdlib) install(TARGETS bpftrace-aotrt DESTINATION ${CMAKE_INSTALL_BINDIR}) if(LIBPCAP_FOUND) target_link_libraries(bpftrace-aotrt ${LIBPCAP_LIBRARIES}) endif(LIBPCAP_FOUND) # Linking target_link_options(bpftrace-aotrt BEFORE PRIVATE $<$:-static-libgcc> $<$:-static-libstdc++> ) # ASAN/UBSAN target_link_options(bpftrace-aotrt PUBLIC $<$:-fsanitize=address> $<$:-fsanitize=undefined> ) bpftrace-0.27.1/src/aot/aot.cpp000066400000000000000000000222571526721631600162510ustar00rootroot00000000000000#include "aot.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "util/paths.h" #include "version.h" #define AOT_ELF_SECTION ".btaot" static constexpr auto AOT_MAGIC = 0xA07; static constexpr auto AOT_SECDATA_TEMPFILE = ".temp_btaot"; // AOT payload will have this header at the beginning. We don't worry about // versioning the header b/c we enforce that an AOT compiled script may only // be run with the corresponding runtime shim. We enforce it through the // `version` field, which is the "Robert Sedgwicks hash" of BPFTRACE_VERSION // macro defined in cmake. struct Header { uint16_t magic; // Header magic (can be useful to detect endianness) uint16_t unused; // For future use uint32_t header_len; // Length of this struct uint64_t version; // Hash of version string uint64_t rr_off; // RequiredResources offset from start of file uint64_t rr_len; // RequiredResources length uint64_t elf_off; // ELF offset from start of file uint64_t elf_len; // ELF length }; static_assert(sizeof(Header) == 48); static_assert(sizeof(std::size_t) <= sizeof(uint64_t)); namespace bpftrace::aot { namespace { uint32_t rs_hash(std::string_view str) { unsigned int b = 378551; unsigned int a = 63689; unsigned int hash = 0; for (char c : str) { hash = (hash * a) + c; a = a * b; } return hash; } int load_required_resources(BPFtrace &bpftrace, uint8_t *ptr, size_t len) { try { bpftrace.resources.load_state(ptr, len); } catch (const std::exception &ex) { LOG(ERROR) << "Failed to deserialize metadata: " << ex.what(); return 1; } return 0; } std::optional> generate_btaot_section( const RequiredResources &resources, void *const elf, size_t elf_size) { // Serialize RuntimeResources std::string serialized_metadata; try { std::ostringstream serialized(std::ios::binary); resources.save_state(serialized); serialized_metadata = serialized.str(); } catch (const std::exception &ex) { LOG(ERROR) << "Failed to serialize runtime metadata: " << ex.what(); return std::nullopt; } // Construct the header auto hdr_len = sizeof(Header); Header hdr = { .magic = AOT_MAGIC, .unused = 0, .header_len = sizeof(Header), .version = rs_hash(BPFTRACE_VERSION), .rr_off = hdr_len, .rr_len = serialized_metadata.size(), .elf_off = hdr_len + serialized_metadata.size(), .elf_len = elf_size, }; // Resize the output buffer appropriately std::vector out; out.resize(sizeof(Header) + hdr.rr_len + hdr.elf_len); uint8_t *p = out.data(); // Write out header memcpy(p, &hdr, sizeof(Header)); p += sizeof(Header); // Write out metadata memcpy(p, serialized_metadata.data(), hdr.rr_len); p += hdr.rr_len; // Write out ELF memcpy(p, elf, hdr.elf_len); p += hdr.elf_len; return out; } // Clones the shim to final destination while also injecting // the custom .btaot section. int build_binary(const std::filesystem::path &shim, const std::string &out, const std::vector §ion) { std::error_code ec; char cmd[1024]; int written; int ret = 0; // Write out section data in a temporary file std::ofstream secdata(AOT_SECDATA_TEMPFILE, std::ios_base::binary); secdata.write(reinterpret_cast(section.data()), section.size()); secdata.close(); // Respect user provided BPFTRACE_OBJCOPY if present std::string_view objcopy = "objcopy"; if (auto *c = std::getenv("BPFTRACE_OBJCOPY")) objcopy = c; // Resolve objcopy binary to full path auto objcopy_full = util::find_in_path(objcopy); if (!objcopy_full) { ret = 1; LOG(ERROR) << "Failed to find " << objcopy << " in $PATH"; goto out; } written = snprintf(cmd, sizeof(cmd), "%s --add-section .btaot=%s %s %s", objcopy_full->c_str(), AOT_SECDATA_TEMPFILE, shim.c_str(), out.c_str()); if (written < 0 || written == sizeof(cmd)) { ret = 1; LOG(ERROR) << "Failed to construct objcopy command"; goto out; } if ((ret = std::system(cmd))) { LOG(ERROR) << "Failed to execute: " << cmd; goto out; } out: if (!std::filesystem::remove(AOT_SECDATA_TEMPFILE, ec) || ec) { ret = 1; LOG(ERROR) << "Failed to remove " << AOT_SECDATA_TEMPFILE << ": " << ec; } return ret; } } // namespace int generate(const RequiredResources &resources, const std::string &out, void *const elf, size_t elf_size) { auto section = generate_btaot_section(resources, elf, elf_size); if (!section) return 1; // For development, we want to use the locally built AOT shim instead of a // "real" one that could be present elsewhere in $PATH. So we give precedence // to shim found "next" to the running binary. auto rel = std::filesystem::path("aot") / AOT_SHIM_NAME; auto local = util::find_near_self(rel.native()); auto path = util::find_in_path(AOT_SHIM_NAME); auto shim = local ? local : path; if (!shim) { LOG(ERROR) << "Failed to locate " << AOT_SHIM_NAME << " shim binary. Is it in $PATH?"; return 1; } if (shim == local) LOG(WARNING) << "Using development shim (" << *shim << "). Ensure you are a developer!"; if (auto err = build_binary(*shim, out, *section)) return err; return 0; } int load(BPFtrace &bpftrace, const std::string &in) { int err = 0; int infd = ::open(in.c_str(), O_RDONLY); if (infd < 0) { auto saved_err = errno; LOG(ERROR) << "Failed to open: " << in << ": " << std::strerror(saved_err); return 1; } std::error_code ec; std::filesystem::path in_path{ in }; std::uintmax_t in_file_size = std::filesystem::file_size(in_path, ec); if (ec) { LOG(ERROR) << "Failed to stat: " << in << ": " << ec.message(); return 1; } // Find .btaot section Elf *elf = nullptr; Elf_Scn *scn = nullptr; GElf_Shdr shdr; char *secname = nullptr; Elf_Data *data = nullptr; uint8_t *btaot_section = nullptr; const Header *hdr; if (elf_version(EV_CURRENT) == EV_NONE) { LOG(ERROR) << "Cannot set libelf version: " << elf_errmsg(-1); err = 1; goto out; } elf = elf_begin(infd, ELF_C_READ, nullptr); if (!elf) { LOG(ERROR) << "Cannot read ELF file: " << elf_errmsg(-1); err = 1; goto out; } size_t strndx; if (elf_getshdrstrndx(elf, &strndx) < 0) { LOG(ERROR) << "Failed to get ELF section index of the string table: " << elf_errmsg(-1); err = 1; goto out; } int i; i = 0; while ((scn = elf_nextscn(elf, scn))) { i++; if (!gelf_getshdr(scn, &shdr)) { LOG(ERROR) << "Failed to get ELF section(" << i << ") hdr: " << elf_errmsg(-1); err = 1; goto out; } secname = elf_strptr(elf, strndx, shdr.sh_name); if (!secname) { LOG(ERROR) << "Failed to get ELF section(" << i << ") hdr name: " << elf_errmsg(-1); err = 1; goto out; } if (std::string_view(secname) == AOT_ELF_SECTION) { data = elf_getdata(scn, nullptr); if (!data) { LOG(ERROR) << "Failed to get BTAOT ELF section(" << i << ") data: " << elf_errmsg(-1); err = 1; goto out; } btaot_section = static_cast(data->d_buf); break; } } // Validate .btaot header hdr = reinterpret_cast(btaot_section); if (!hdr) { LOG(ERROR) << "Couldn't find " << AOT_ELF_SECTION << " section in " << in; err = 1; goto out; } if (hdr->magic != AOT_MAGIC) { LOG(ERROR) << "Invalid magic in " << in << ": " << hdr->magic; err = 1; goto out; } if (hdr->unused != 0) { LOG(ERROR) << "Unused bytes are used: " << hdr->unused; err = 1; goto out; } if (hdr->header_len != sizeof(Header)) { LOG(ERROR) << "Invalid header len: " << hdr->header_len; err = 1; goto out; } if (hdr->version != rs_hash(BPFTRACE_VERSION)) { LOG(ERROR) << "Build hash mismatch! " << "Did you build with a different bpftrace version?"; err = 1; goto out; } if ((hdr->rr_off + hdr->rr_len) > static_cast(in_file_size) || (hdr->elf_off + hdr->elf_len) > static_cast(in_file_size)) { LOG(ERROR) << "Corrupted AOT bpftrace file: incomplete payload"; err = 1; goto out; } // Load payloads err = load_required_resources(bpftrace, btaot_section + hdr->rr_off, hdr->rr_len); if (err) goto out; bpftrace.bytecode_ = BpfBytecode{ std::span{ btaot_section + hdr->elf_off, hdr->elf_len } }; if (err) goto out; out: if (elf) elf_end(elf); close(infd); return err; } } // namespace bpftrace::aot bpftrace-0.27.1/src/aot/aot.h000066400000000000000000000006311526721631600157060ustar00rootroot00000000000000#pragma once #include #include "bpftrace.h" #include "required_resources.h" namespace bpftrace::aot { static constexpr std::string_view AOT_SHIM_NAME = "bpftrace-aotrt"; int generate(const RequiredResources &resources, const std::string &out, void *elf, size_t elf_size); int load(BPFtrace &bpftrace, const std::string &in); } // namespace bpftrace::aot bpftrace-0.27.1/src/aot/aot_main.cpp000066400000000000000000000076001526721631600172500ustar00rootroot00000000000000#include #include #include #include #include "aot.h" #include "bpftrace.h" #include "log.h" #include "run_bpftrace.h" #include "version.h" using namespace bpftrace; void usage(std::ostream& out, std::string_view filename) { // clang-format off out << "USAGE: " << filename << " [options]" << std::endl; out << std::endl; out << "OPTIONS:" << std::endl; out << " -f FORMAT output format ('text', 'json')" << std::endl; out << " -o file redirect bpftrace output to file" << std::endl; out << " -q, keep messages quiet" << std::endl; out << " -v, verbose messages" << std::endl; out << " -d STAGE debug info for various stages of bpftrace execution" << std::endl; out << " ('all', 'libbpf', 'verifier')" << std::endl; out << " -h, --help show this help message" << std::endl; out << " -V, --version bpftrace version" << std::endl; out << std::endl; // clang-format on } int main(int argc, char* argv[]) { std::string output_file, output_format; int c; std::vector named_params; // TODO: which other options from `bpftrace` should be included? const char* const short_opts = "d:f:hVo:qv"; option long_opts[] = { option{ .name = "help", .has_arg = no_argument, .flag = nullptr, .val = 'h', }, option{ .name = "version", .has_arg = no_argument, .flag = nullptr, .val = 'V', }, // Must be last option{ .name = nullptr, .has_arg = 0, .flag = nullptr, .val = 0, }, }; std::filesystem::path p(argv[0]); if (p.filename() == aot::AOT_SHIM_NAME) { LOG(ERROR) << "Runtime shim should not be run directly, please generate a " "binary using --aot option in bpftrace"; return 1; } while ((c = getopt_long(argc, argv, short_opts, long_opts, nullptr)) != -1) { switch (c) { case 'o': output_file = optarg; break; case 'f': output_format = optarg; break; case 'h': usage(std::cout, argv[0]); return 0; case 'V': std::cout << "bpftrace " << BPFTRACE_VERSION << std::endl; return 0; case 'q': bt_quiet = true; break; case 'v': bt_verbose = true; break; case 'd': if (std::string(optarg) == "libbpf") { bt_debug.insert(DebugStage::Libbpf); } else if (std::string(optarg) == "verifier") { bt_debug.insert(DebugStage::Verifier); } else if (std::string(optarg) == "all") { bt_debug.insert({ DebugStage::Libbpf, DebugStage::Verifier }); } else { LOG(ERROR) << "USAGE: invalid option for -d: " << optarg; return 1; } break; default: usage(std::cerr, argv[0]); return 1; } } while (optind < argc) { auto pos_arg = std::string(argv[optind]); if (pos_arg.starts_with("--")) { named_params.emplace_back(pos_arg.substr(2)); } else { // AOT does not support positional parameters LOG(ERROR) << "AOT does not support positional parameters"; return 1; } optind++; } if (argv[optind]) { usage(std::cerr, argv[0]); return 1; } check_privileges(); libbpf_set_print(libbpf_print); BPFtrace bpftrace; int err = aot::load(bpftrace, argv[0]); if (err) { LOG(ERROR) << "Failed to load AOT script"; return err; } // FIXME(#4087): We should serialize the C enum definitions as part of the AOT // payload in order to allow this printing to work. ast::CDefinitions no_c_defs; return run_bpftrace(bpftrace, output_file, output_format, no_c_defs, bpftrace.bytecode_, std::move(named_params)); } bpftrace-0.27.1/src/arch/000077500000000000000000000000001526721631600151045ustar00rootroot00000000000000bpftrace-0.27.1/src/arch/CMakeLists.txt000066400000000000000000000002001526721631600176340ustar00rootroot00000000000000add_library(arch STATIC arm.cpp ppc64.cpp s390.cpp arch.cpp x86_64.cpp mips64.cpp riscv64.cpp loongarch64.cpp ) bpftrace-0.27.1/src/arch/arch.cpp000066400000000000000000000014311526721631600165240ustar00rootroot00000000000000#include #include "arch/arch.h" namespace bpftrace::arch { std::ostream& operator<<(std::ostream& out, Machine m) { switch (m) { case Machine::X86_64: out << "x86_64"; break; case Machine::ARM: out << "arm"; break; case Machine::ARM64: out << "arm64"; break; case Machine::S390X: out << "s390x"; break; case Machine::PPC64: #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ out << "ppc64le"; #else out << "ppc64"; #endif // __BYTE_ORDER__ break; case Machine::MIPS64: out << "mips64"; break; case Machine::RISCV64: out << "riscv64"; break; case Machine::LOONGARCH64: out << "loongarch64"; break; } return out; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/arch.h000066400000000000000000000072771526721631600162070ustar00rootroot00000000000000#pragma once #include #include #include #include namespace bpftrace::arch { // Canonical enum for different architectures. enum Machine { X86_64, ARM, ARM64, S390X, PPC64, MIPS64, RISCV64, LOONGARCH64, }; // Allow printing of the machine type. std::ostream& operator<<(std::ostream& out, Machine m); // In order to ensure that all architecture sources are always compiled, we // define the architecture details as a specific instance of the various // architecture classes. Unused architectures should be stripped out at link // time as those functions are unreferenced. template class Arch { public: constexpr static auto Machine = M; // Returns the assembly name for the architecture. static std::string asm_arch(); // Returns the width of bits in kernel pointers. static size_t kernel_ptr_width(); // Returns additional C definitions that should be applied to compiled code. static const std::vector& c_defs(); // Given a conventional register name, return the expression that should be // used to access this from `struct pt_regs`. This will be dynamically added // and evaluated using the standard type inference mechanisms. static std::optional register_to_pt_regs_expr( const std::string& name); // Returns the offset into the context where this register resides. // // FIXME(#3873): This should be removed in the future. With BTF, there is no // need to statically encode the register offsets and we should instead treat // these as regular field references into the context (e.g. `ctx.ax`). These // field names can then be checked, and will support dynamic reloations, etc. // A pass can be added early to transform `regs("r")` into `ctx.r`, and we // can have proper type inference and type-checking while throwing out code. // However, for now, we retain this method to faciliate the transition. static std::optional register_to_pt_regs_offset( const std::string& name); // Returns the canonical sequence of registers used for the default calling // convention on this architecture. These should be in the form of fields for // `struct pt_regs` (the function above will not be called). static const std::vector& arguments(); // Returns the canonical offset into the stack where arguments start to spill. static size_t argument_stack_offset(); // Returns the canonical register used for the return value on this // architecture, also in the form of a `struct pt_regs` field. static std::string return_value(); // Returns the canonical register used to store the instruction pointer, // also in the form of a `struct pt_regs` field. static std::string pc_value(); // Returns the canonical register used to store the stack pointer, in // the form of a `struct pt_regs` fields. static std::string sp_value(); // Returns the set of valid watchpoint modes. static const std::unordered_set& watchpoint_modes(); }; // Returns the `Machine` for the compiled architecture. constexpr Machine current() { #if defined(__x86_64__) || defined(__amd64__) return Machine::X86_64; #elif defined(__aarch64__) return Machine::ARM64; #elif defined(__arm__) return Machine::ARM; #elif defined(__s390x__) return Machine::S390X; #elif defined(__ppc64__) || defined(__powerpc64__) return Machine::PPC64; #elif defined(__mips64) return Machine::MIPS64; #elif defined(__riscv) && (__riscv_xlen == 64) return Machine::RISCV64; #elif defined(__loongarch64) return Machine::LOONGARCH64; #else #error "Unknown architecture." #endif } // Alias for the current host architecture. using Host = Arch; } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/arm.cpp000066400000000000000000000213011526721631600163640ustar00rootroot00000000000000#include #include "arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "arm"; } template <> size_t Arch::kernel_ptr_width() { return 32; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_arm", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { static const std::unordered_map register_exprs = { { "r0", "uregs[0]" }, { "r1", "uregs[1]" }, { "r2", "uregs[2]" }, { "r3", "uregs[3]" }, { "r4", "uregs[4]" }, { "r5", "uregs[5]" }, { "r6", "uregs[6]" }, { "r7", "uregs[7]" }, { "r8", "uregs[8]" }, { "r9", "uregs[9]" }, { "r10", "uregs[10]" }, // Support the expressions as string literals. { "regs[0]", "uregs[0]" }, { "regs[1]", "uregs[1]" }, { "regs[2]", "uregs[2]" }, { "regs[3]", "uregs[3]" }, { "regs[4]", "uregs[4]" }, { "regs[5]", "uregs[5]" }, { "regs[6]", "uregs[6]" }, { "regs[7]", "uregs[7]" }, { "regs[8]", "uregs[8]" }, { "regs[9]", "uregs[9]" }, { "regs[10]", "uregs[10]" }, // Special registers. { "fp", "uregs[11]" }, { "ip", "uregs[12]" }, { "sp", "uregs[13]" }, { "lr", "uregs[14]" }, { "pc", "uregs[15]" }, { "cpsr", "uregs[16]" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "r0", 0 }, { "r1", 4 }, { "r2", 8 }, { "r3", 12 }, { "r4", 16 }, { "r5", 20 }, { "r6", 24 }, { "r7", 28 }, { "r8", 32 }, { "r9", 36 }, { "r10", 40 }, // As above, support expressions as string literals. { "regs[0]", 0 }, { "regs[1]", 4 }, { "regs[2]", 8 }, { "regs[3]", 12 }, { "regs[4]", 16 }, { "regs[5]", 20 }, { "regs[6]", 24 }, { "regs[7]", 28 }, { "regs[8]", 32 }, { "regs[9]", 36 }, { "regs[10]", 40 }, // Special registers. { "fp", 44 }, { "ip", 48 }, { "sp", 52 }, { "lr", 56 }, { "pc", 60 }, { "cpsr", 64 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "r0", "r1", "r2", "r3", }; return args; } template <> size_t Arch::argument_stack_offset() { return 0; } template <> std::string Arch::return_value() { return "r0"; } template <> std::string Arch::pc_value() { return "pc"; } template <> std::string Arch::sp_value() { return "sp"; } template <> const std::unordered_set& Arch::watchpoint_modes() { // See arch/arm/kernel/hw_breakpoint.c:arch_build_bp_info in kernel source. static std::unordered_set valid_modes = { "r", "w", "x", "rw", }; return valid_modes; } template <> std::string Arch::asm_arch() { return "arm64"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_arm64", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { static const std::unordered_map register_exprs = { { "r0", "regs[0]" }, { "r1", "regs[1]" }, { "r2", "regs[2]" }, { "r3", "regs[3]" }, { "r4", "regs[4]" }, { "r5", "regs[5]" }, { "r6", "regs[6]" }, { "r7", "regs[7]" }, { "r8", "regs[8]" }, { "r9", "regs[9]" }, { "r10", "regs[10]" }, { "r11", "regs[11]" }, { "r12", "regs[12]" }, { "r13", "regs[13]" }, { "r14", "regs[14]" }, { "r15", "regs[15]" }, { "r16", "regs[16]" }, { "r17", "regs[17]" }, { "r18", "regs[18]" }, { "r19", "regs[19]" }, { "r20", "regs[20]" }, { "r21", "regs[21]" }, { "r22", "regs[22]" }, { "r23", "regs[23]" }, { "r24", "regs[24]" }, { "r25", "regs[25]" }, { "r26", "regs[26]" }, { "r27", "regs[27]" }, { "r28", "regs[28]" }, { "r29", "regs[29]" }, { "r30", "regs[30]" }, // Support expressions as string literals. { "regs[0]", "regs[0]" }, { "regs[1]", "regs[1]" }, { "regs[2]", "regs[2]" }, { "regs[3]", "regs[3]" }, { "regs[4]", "regs[4]" }, { "regs[5]", "regs[5]" }, { "regs[6]", "regs[6]" }, { "regs[7]", "regs[7]" }, { "regs[8]", "regs[8]" }, { "regs[9]", "regs[9]" }, { "regs[10]", "regs[10]" }, { "regs[11]", "regs[11]" }, { "regs[12]", "regs[12]" }, { "regs[13]", "regs[13]" }, { "regs[14]", "regs[14]" }, { "regs[15]", "regs[15]" }, { "regs[16]", "regs[16]" }, { "regs[17]", "regs[17]" }, { "regs[18]", "regs[18]" }, { "regs[19]", "regs[19]" }, { "regs[20]", "regs[20]" }, { "regs[21]", "regs[21]" }, { "regs[22]", "regs[22]" }, { "regs[23]", "regs[23]" }, { "regs[24]", "regs[24]" }, { "regs[25]", "regs[25]" }, { "regs[26]", "regs[26]" }, { "regs[27]", "regs[27]" }, { "regs[28]", "regs[28]" }, { "regs[29]", "regs[29]" }, { "regs[30]", "regs[30]" }, // Compat registers for 32-bit userspace. { "compat_fp", "regs[11]", }, { "compat_sp", "regs[13]", }, { "compat_lr", "regs[14]" }, // Special registers. { "sp", "sp" }, { "pc", "pc" }, { "pstate", "pstate" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "r0", 0 }, { "r1", 8 }, { "r2", 16 }, { "r3", 24 }, { "r4", 32 }, { "r5", 40 }, { "r6", 48 }, { "r7", 56 }, { "r8", 64 }, { "r9", 72 }, { "r10", 80 }, { "r11", 88 }, { "r12", 96 }, { "r13", 104 }, { "r14", 112 }, { "r15", 120 }, { "r16", 128 }, { "r17", 136 }, { "r18", 144 }, { "r19", 152 }, { "r20", 160 }, { "r21", 168 }, { "r22", 176 }, { "r23", 184 }, { "r24", 192 }, { "r25", 200 }, { "r26", 208 }, { "r27", 216 }, { "r28", 224 }, { "r29", 232 }, { "r30", 240 }, // Full expressions as string literals. { "regs[0]", 0 }, { "regs[1]", 8 }, { "regs[2]", 16 }, { "regs[3]", 24 }, { "regs[4]", 32 }, { "regs[5]", 40 }, { "regs[6]", 48 }, { "regs[7]", 56 }, { "regs[8]", 64 }, { "regs[9]", 72 }, { "regs[10]", 80 }, { "regs[11]", 88 }, { "regs[12]", 96 }, { "regs[13]", 104 }, { "regs[14]", 112 }, { "regs[15]", 120 }, { "regs[16]", 128 }, { "regs[17]", 136 }, { "regs[18]", 144 }, { "regs[19]", 152 }, { "regs[20]", 160 }, { "regs[21]", 168 }, { "regs[22]", 176 }, { "regs[23]", 184 }, { "regs[24]", 192 }, { "regs[25]", 200 }, { "regs[26]", 208 }, { "regs[27]", 216 }, { "regs[28]", 224 }, { "regs[29]", 232 }, { "regs[30]", 240 }, // Compat registers for 32-bit userspace. { "compat_fp", 88 }, { "compat_sp", 104 }, { "compat_lr", 112 }, // Special registers. { "sp", 248 }, { "pc", 256 }, { "pstate", 264 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", }; return args; } template <> size_t Arch::argument_stack_offset() { return 0; } template <> std::string Arch::return_value() { return "r0"; } template <> std::string Arch::pc_value() { return "pc"; } template <> std::string Arch::sp_value() { return "sp"; } template <> const std::unordered_set& Arch::watchpoint_modes() { // See arch/arm/kernel/hw_breakpoint.c:arch_build_bp_info in kernel source. static std::unordered_set valid_modes = { "r", "w", "x", "rw", }; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/loongarch64.cpp000066400000000000000000000123571526721631600177460ustar00rootroot00000000000000#include #include "arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "loongarch"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_loongarch", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { static const std::unordered_map register_exprs = { { "r0", "regs[0]" }, { "r1", "regs[1]" }, { "r2", "regs[2]" }, { "r3", "regs[3]" }, { "r4", "regs[4]" }, { "r5", "regs[5]" }, { "r6", "regs[6]" }, { "r7", "regs[7]" }, { "r8", "regs[8]" }, { "r9", "regs[9]" }, { "r10", "regs[10]" }, { "r11", "regs[11]" }, { "r12", "regs[12]" }, { "r13", "regs[13]" }, { "r14", "regs[14]" }, { "r15", "regs[15]" }, { "r16", "regs[16]" }, { "r17", "regs[17]" }, { "r18", "regs[18]" }, { "r19", "regs[19]" }, { "r20", "regs[20]" }, { "r21", "regs[21]" }, { "r22", "regs[22]" }, { "r23", "regs[23]" }, { "r24", "regs[24]" }, { "r25", "regs[25]" }, { "r26", "regs[26]" }, { "r27", "regs[27]" }, { "r28", "regs[28]" }, { "r29", "regs[29]" }, { "r30", "regs[30]" }, { "r31", "regs[31]" }, // Support full expressions as string literals. { "regs[0]", "regs[0]" }, { "regs[1]", "regs[1]" }, { "regs[2]", "regs[2]" }, { "regs[3]", "regs[3]" }, { "regs[4]", "regs[4]" }, { "regs[5]", "regs[5]" }, { "regs[6]", "regs[6]" }, { "regs[7]", "regs[7]" }, { "regs[8]", "regs[8]" }, { "regs[9]", "regs[9]" }, { "regs[10]", "regs[10]" }, { "regs[11]", "regs[11]" }, { "regs[12]", "regs[12]" }, { "regs[13]", "regs[13]" }, { "regs[14]", "regs[14]" }, { "regs[15]", "regs[15]" }, { "regs[16]", "regs[16]" }, { "regs[17]", "regs[17]" }, { "regs[18]", "regs[18]" }, { "regs[19]", "regs[19]" }, { "regs[20]", "regs[20]" }, { "regs[21]", "regs[21]" }, { "regs[22]", "regs[22]" }, { "regs[23]", "regs[23]" }, { "regs[24]", "regs[24]" }, { "regs[25]", "regs[25]" }, { "regs[26]", "regs[26]" }, { "regs[27]", "regs[27]" }, { "regs[28]", "regs[28]" }, { "regs[29]", "regs[29]" }, { "regs[30]", "regs[30]" }, { "regs[31]", "regs[31]" }, // Special registers. { "orig_a0", "orig_a0" }, { "pc", "csr_era" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "r0", 0 }, { "r1", 8 }, { "r2", 16 }, { "r3", 24 }, { "r4", 32 }, { "r5", 40 }, { "r6", 48 }, { "r7", 56 }, { "r8", 64 }, { "r9", 72 }, { "r10", 80 }, { "r11", 88 }, { "r12", 96 }, { "r13", 104 }, { "r14", 112 }, { "r15", 120 }, { "r16", 128 }, { "r17", 136 }, { "r18", 144 }, { "r19", 152 }, { "r20", 160 }, { "r21", 168 }, { "r22", 176 }, { "r23", 184 }, { "r24", 192 }, { "r25", 200 }, { "r26", 208 }, { "r27", 216 }, { "r28", 224 }, { "r29", 232 }, { "r30", 240 }, { "r31", 248 }, // Support full expressions as string literals. { "regs[0]", 0 }, { "regs[1]", 8 }, { "regs[2]", 16 }, { "regs[3]", 24 }, { "regs[4]", 32 }, { "regs[5]", 40 }, { "regs[6]", 48 }, { "regs[7]", 56 }, { "regs[8]", 64 }, { "regs[9]", 72 }, { "regs[10]", 80 }, { "regs[11]", 88 }, { "regs[12]", 96 }, { "regs[13]", 104 }, { "regs[14]", 112 }, { "regs[15]", 120 }, { "regs[16]", 128 }, { "regs[17]", 136 }, { "regs[18]", 144 }, { "regs[19]", 152 }, { "regs[20]", 160 }, { "regs[21]", 168 }, { "regs[22]", 176 }, { "regs[23]", 184 }, { "regs[24]", 192 }, { "regs[25]", 200 }, { "regs[26]", 208 }, { "regs[27]", 216 }, { "regs[28]", 224 }, { "regs[29]", 232 }, { "regs[30]", 240 }, { "regs[31]", 248 }, // Special registers. { "orig_a0", 256 }, { "pc", 264 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", }; return args; } template <> size_t Arch::argument_stack_offset() { return 0; } template <> std::string Arch::return_value() { return "r4"; } template <> std::string Arch::pc_value() { return "pc"; } template <> std::string Arch::sp_value() { return "r3"; } template <> const std::unordered_set& Arch< Machine::LOONGARCH64>::watchpoint_modes() { static std::unordered_set valid_modes = {}; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/mips64.cpp000066400000000000000000000126451526721631600167420ustar00rootroot00000000000000#include #include "arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "mips"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_mips", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { static const std::unordered_map register_exprs = { { "zero", "regs[0]" }, { "at", "regs[1]" }, { "v0", "regs[2]" }, { "v1", "regs[3]" }, { "a0", "regs[4]" }, { "a1", "regs[5]" }, { "a2", "regs[6]" }, { "a3", "regs[7]" }, { "a4", "regs[8]" }, { "a5", "regs[9]" }, { "a6", "regs[10]" }, { "a7", "regs[11]" }, { "t0", "regs[12]" }, { "t1", "regs[13]" }, { "t2", "regs[14]" }, { "t3", "regs[15]" }, { "s0", "regs[16]" }, { "s1", "regs[17]" }, { "s2", "regs[18]" }, { "s3", "regs[19]" }, { "s4", "regs[20]" }, { "s5", "regs[21]" }, { "s6", "regs[22]" }, { "s7", "regs[23]" }, { "t8", "regs[24]" }, { "t9", "regs[25]" }, { "k0", "regs[26]" }, { "k1", "regs[27]" }, { "gp", "regs[28]" }, { "sp", "regs[29]" }, { "fp", "regs[30]" }, { "fp/s8", "regs[30]" }, { "ra", "regs[31]" }, // Support full expressions as string literals. { "regs[0]", "regs[0]" }, { "regs[1]", "regs[1]" }, { "regs[2]", "regs[2]" }, { "regs[3]", "regs[3]" }, { "regs[4]", "regs[4]" }, { "regs[5]", "regs[5]" }, { "regs[6]", "regs[6]" }, { "regs[7]", "regs[7]" }, { "regs[8]", "regs[8]" }, { "regs[9]", "regs[9]" }, { "regs[10]", "regs[10]" }, { "regs[11]", "regs[11]" }, { "regs[12]", "regs[12]" }, { "regs[13]", "regs[13]" }, { "regs[14]", "regs[14]" }, { "regs[15]", "regs[15]" }, { "regs[16]", "regs[16]" }, { "regs[17]", "regs[17]" }, { "regs[18]", "regs[18]" }, { "regs[19]", "regs[19]" }, { "regs[20]", "regs[20]" }, { "regs[21]", "regs[21]" }, { "regs[22]", "regs[22]" }, { "regs[23]", "regs[23]" }, { "regs[24]", "regs[24]" }, { "regs[25]", "regs[25]" }, { "regs[26]", "regs[26]" }, { "regs[27]", "regs[27]" }, { "regs[28]", "regs[28]" }, { "regs[29]", "regs[29]" }, { "regs[30]", "regs[30]" }, { "regs[31]", "regs[31]" }, // System registers. { "cp0_status", "cp0_status" }, { "hi", "hi" }, { "lo", "lo" }, { "cp0_badvaddr", "cp0_badvaddr" }, { "cp0_cause", "cp0_cause" }, { "cp0_epc", "cp0_epc" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "zero", 0 }, { "at", 8 }, { "v0", 16 }, { "v1", 24 }, { "a0", 32 }, { "a1", 40 }, { "a2", 48 }, { "a3", 56 }, { "a4", 64 }, { "a5", 72 }, { "a6", 80 }, { "a7", 88 }, { "t0", 96 }, { "t1", 104 }, { "t2", 112 }, { "t3", 120 }, { "s0", 128 }, { "s1", 136 }, { "s2", 144 }, { "s3", 152 }, { "s4", 160 }, { "s5", 168 }, { "s6", 176 }, { "s7", 184 }, { "t8", 192 }, { "t9", 200 }, { "k0", 208 }, { "k1", 216 }, { "gp", 224 }, { "sp", 232 }, { "fp", 240 }, { "fp/s8", 240 }, { "ra", 248 }, // Support full expressions as literals. { "regs[0]", 0 }, { "regs[1]", 8 }, { "regs[2]", 16 }, { "regs[3]", 24 }, { "regs[4]", 32 }, { "regs[5]", 40 }, { "regs[6]", 48 }, { "regs[7]", 56 }, { "regs[8]", 64 }, { "regs[9]", 72 }, { "regs[10]", 80 }, { "regs[11]", 88 }, { "regs[12]", 96 }, { "regs[13]", 104 }, { "regs[14]", 112 }, { "regs[15]", 120 }, { "regs[16]", 128 }, { "regs[17]", 136 }, { "regs[18]", 144 }, { "regs[19]", 152 }, { "regs[20]", 160 }, { "regs[21]", 168 }, { "regs[22]", 176 }, { "regs[23]", 184 }, { "regs[24]", 192 }, { "regs[25]", 200 }, { "regs[26]", 208 }, { "regs[27]", 216 }, { "regs[28]", 224 }, { "regs[29]", 232 }, { "regs[30]", 240 }, { "regs[31]", 248 }, // System registers. { "cp0_status", 256 }, { "hi", 264 }, { "lo", 272 }, { "cp0_badvaddr", 280 }, { "cp0_cause", 288 }, { "cp0_epc", 296 }, { "pc", 296 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", }; return args; } template <> size_t Arch::argument_stack_offset() { return 8; } template <> std::string Arch::return_value() { return "v0"; } template <> std::string Arch::pc_value() { return "cp0_epc"; } template <> std::string Arch::sp_value() { return "sp"; } template <> const std::unordered_set& Arch::watchpoint_modes() { static std::unordered_set valid_modes = {}; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/ppc64.cpp000066400000000000000000000077071526721631600165570ustar00rootroot00000000000000#include #include "arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "powerpc"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_powerpc", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { // PowerPC pt_regs structure field mapping static const std::unordered_map register_exprs = { { "r0", "gpr[0]" }, { "r1", "gpr[1]" }, { "r2", "gpr[2]" }, { "r3", "gpr[3]" }, { "r4", "gpr[4]" }, { "r5", "gpr[5]" }, { "r6", "gpr[6]" }, { "r7", "gpr[7]" }, { "r8", "gpr[8]" }, { "r9", "gpr[9]" }, { "r10", "gpr[10]" }, { "r11", "gpr[11]" }, { "r12", "gpr[12]" }, { "r13", "gpr[13]" }, { "r14", "gpr[14]" }, { "r15", "gpr[15]" }, { "r16", "gpr[16]" }, { "r17", "gpr[17]" }, { "r18", "gpr[18]" }, { "r19", "gpr[19]" }, { "r20", "gpr[20]" }, { "r21", "gpr[21]" }, { "r22", "gpr[22]" }, { "r23", "gpr[23]" }, { "r24", "gpr[24]" }, { "r25", "gpr[25]" }, { "r26", "gpr[26]" }, { "r27", "gpr[27]" }, { "r28", "gpr[28]" }, { "r29", "gpr[29]" }, { "r30", "gpr[30]" }, { "r31", "gpr[31]" }, { "nip", "nip" }, { "msr", "msr" }, { "orig_gpr3", "orig_gpr3" }, { "ctr", "ctr" }, { "link", "link" }, { "xer", "xer" }, { "ccr", "ccr" }, { "softe", "softe" }, { "trap", "trap" }, { "dar", "dar" }, { "dsisr", "dsisr" }, { "result", "result" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "r0", 0 }, { "r1", 8 }, { "r2", 16 }, { "r3", 24 }, { "r4", 32 }, { "r5", 40 }, { "r6", 48 }, { "r7", 56 }, { "r8", 64 }, { "r9", 72 }, { "r10", 80 }, { "r11", 88 }, { "r12", 96 }, { "r13", 104 }, { "r14", 112 }, { "r15", 120 }, { "r16", 128 }, { "r17", 136 }, { "r18", 144 }, { "r19", 152 }, { "r20", 160 }, { "r21", 168 }, { "r22", 176 }, { "r23", 184 }, { "r24", 192 }, { "r25", 200 }, { "r26", 208 }, { "r27", 216 }, { "r28", 224 }, { "r29", 232 }, { "r30", 240 }, { "r31", 248 }, { "nip", 256 }, { "pc", 256 }, { "msr", 264 }, { "orig_gpr3", 272 }, { "ctr", 280 }, { "link", 288 }, { "xer", 296 }, { "ccr", 304 }, { "softe", 312 }, { "trap", 320 }, { "dar", 328 }, { "dsisr", 336 }, { "result", 344 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", }; return args; } template <> size_t Arch::argument_stack_offset() { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ return 96; // Little endian: sp + 32 + 8 regs save area + argX #else return 112; // Big endian: sp + 48 + 8 regs save area + argX #endif // __BYTE_ORDER__ } template <> std::string Arch::return_value() { return "r3"; } template <> std::string Arch::pc_value() { return "nip"; } template <> std::string Arch::sp_value() { return "r1"; } template <> const std::unordered_set& Arch::watchpoint_modes() { // See PowerISA Book III v3.1B, Section 5.4.4 and 10.4. static std::unordered_set valid_modes = { "r", "w", "rw", }; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/riscv64.cpp000066400000000000000000000055261526721631600171200ustar00rootroot00000000000000#include #include "arch/arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "riscv"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_riscv", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { static const std::unordered_map register_exprs = { { "pc", "epc" }, { "ra", "ra" }, { "sp", "sp" }, { "gp", "gp" }, { "tp", "tp" }, { "t0", "t0" }, { "t1", "t1" }, { "t2", "t2" }, { "s0", "s0" }, { "s1", "s1" }, { "a0", "a0" }, { "a1", "a1" }, { "a2", "a2" }, { "a3", "a3" }, { "a4", "a4" }, { "a5", "a5" }, { "a6", "a6" }, { "a7", "a7" }, { "s2", "s2" }, { "s3", "s3" }, { "s4", "s4" }, { "s5", "s5" }, { "s6", "s6" }, { "s7", "s7" }, { "s8", "s8" }, { "s9", "s9" }, { "s10", "s10" }, { "s11", "s11" }, { "t3", "t3" }, { "t4", "t4" }, { "t5", "t5" }, { "t6", "t6" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "pc", 0 }, { "ra", 8 }, { "sp", 16 }, { "gp", 24 }, { "tp", 32 }, { "t0", 40 }, { "t1", 48 }, { "t2", 56 }, { "s0", 64 }, { "s1", 72 }, { "a0", 80 }, { "a1", 88 }, { "a2", 96 }, { "a3", 104 }, { "a4", 112 }, { "a5", 120 }, { "a6", 128 }, { "a7", 136 }, { "s2", 144 }, { "s3", 152 }, { "s4", 160 }, { "s5", 168 }, { "s6", 176 }, { "s7", 184 }, { "s8", 192 }, { "s9", 200 }, { "s10", 208 }, { "s11", 216 }, { "t3", 224 }, { "t4", 232 }, { "t5", 240 }, { "t6", 248 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", }; return args; } template <> size_t Arch::argument_stack_offset() { return 0; } template <> std::string Arch::return_value() { return "a0"; } template <> std::string Arch::pc_value() { return "pc"; } template <> std::string Arch::sp_value() { return "sp"; } template <> const std::unordered_set& Arch< Machine::RISCV64>::watchpoint_modes() { static std::unordered_set valid_modes = {}; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/s390.cpp000066400000000000000000000052671526721631600163200ustar00rootroot00000000000000#include #include "arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "s390"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_s390", }; return defs; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { static const std::unordered_map register_exprs = { { "arg", "args[0]" }, { "pswmask", "psw.mask" }, { "pswaddr", "psw.addr" }, { "r0", "gprs[0]" }, { "r1", "gprs[1]" }, { "r2", "gprs[2]" }, { "r3", "gprs[3]" }, { "r4", "gprs[4]" }, { "r5", "gprs[5]" }, { "r6", "gprs[6]" }, { "r7", "gprs[7]" }, { "r8", "gprs[8]" }, { "r9", "gprs[9]" }, { "r10", "gprs[10]" }, { "r11", "gprs[11]" }, { "r12", "gprs[12]" }, { "r13", "gprs[13]" }, { "r14", "gprs[14]" }, { "r15", "gprs[15]" }, }; auto it = register_exprs.find(name); if (it != register_exprs.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "arg", 0 }, { "pswmask", 8 }, { "pswaddr", 16 }, { "pc", 16 }, { "r0", 24 }, { "r1", 32 }, { "r2", 40 }, { "r3", 48 }, { "r4", 56 }, { "r5", 64 }, { "r6", 72 }, { "r7", 80 }, { "r8", 88 }, { "r9", 96 }, { "r10", 104 }, { "r11", 112 }, { "r12", 120 }, { "r13", 128 }, { "r14", 136 }, { "r15", 144 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> const std::vector& Arch::arguments() { static std::vector args = { "r2", "r3", "r4", "r5", "r6", }; return args; } template <> size_t Arch::argument_stack_offset() { // For s390x, r2-r6 registers are used as function arguments, then the extra // arguments can be found starting at sp+160. return 160; } template <> std::string Arch::return_value() { return "r2"; } template <> std::string Arch::pc_value() { return "pswaddr"; } template <> std::string Arch::sp_value() { return "r15"; } template <> const std::unordered_set& Arch::watchpoint_modes() { static std::unordered_set valid_modes = {}; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/arch/x86_64.cpp000066400000000000000000000047111526721631600165510ustar00rootroot00000000000000#include #include "arch.h" namespace bpftrace::arch { template <> std::string Arch::asm_arch() { return "x86"; } template <> size_t Arch::kernel_ptr_width() { return 64; } template <> const std::vector& Arch::c_defs() { static std::vector defs = { "__TARGET_ARCH_x86", }; return defs; } template <> std::optional Arch::register_to_pt_regs_offset( const std::string& name) { static const std::unordered_map register_offsets = { { "r15", 0 }, { "r14", 8 }, { "r13", 16 }, { "r12", 24 }, { "bp", 32 }, { "bx", 40 }, { "r11", 48 }, { "r10", 56 }, { "r9", 64 }, { "r8", 72 }, { "ax", 80 }, { "cx", 88 }, { "dx", 96 }, { "si", 104 }, { "di", 112 }, { "orig_rax", 120 }, { "ip", 128 }, { "pc", 128 }, { "cs", 136 }, { "flags", 144 }, { "sp", 152 }, { "ss", 160 }, }; auto it = register_offsets.find(name); if (it != register_offsets.end()) { return it->second; } return std::nullopt; } template <> std::optional Arch::register_to_pt_regs_expr( const std::string& name) { // All the registers in x86-64 are defined against the existing pt_regs // struct, and there are no aliases. In the future, we could define aliases // like the `rXX` variants as opposed to `ax`, `bx`, etc. or we could add // aliases like `fp` for `bp`. auto offset = register_to_pt_regs_offset(name); if (!offset) { return std::nullopt; } return name; } template <> const std::vector& Arch::arguments() { static std::vector args = { "di", "si", "dx", "cx", "r8", "r9", }; return args; } template <> size_t Arch::argument_stack_offset() { // The return address is pushed on the frame, so we need to reach up // the stack further to find the first argument. return 8; } template <> std::string Arch::return_value() { return "ax"; } template <> std::string Arch::pc_value() { return "ip"; } template <> std::string Arch::sp_value() { return "sp"; } template <> const std::unordered_set& Arch::watchpoint_modes() { // See intel developer manual, Volume 3, section 17.2.4. static std::unordered_set valid_modes = { "rw", "w", "x", }; return valid_modes; } } // namespace bpftrace::arch bpftrace-0.27.1/src/ast/000077500000000000000000000000001526721631600147565ustar00rootroot00000000000000bpftrace-0.27.1/src/ast/CMakeLists.txt000066400000000000000000000061571526721631600175270ustar00rootroot00000000000000add_library(ast_defs STATIC ast.cpp context.cpp helpers.cpp integer_types.cpp location.cpp ) target_link_libraries(ast_defs util) add_library(ast STATIC async_event_types.cpp codegen_helper.cpp diagnostic.cpp dibuilderbpf.cpp irbuilderbpf.cpp pass_manager.cpp signal.cpp passes/ap_probe_expansion.cpp passes/attachpoint_passes.cpp passes/builtins.cpp passes/c_macro_expansion.cpp passes/types/pre_type_check.cpp passes/clang_parser.cpp passes/clang_build.cpp passes/named_param.cpp passes/types/ast_transformer.cpp passes/types/cast_creator.cpp passes/types/parsed_type_bridge.cpp passes/config_analyser.cpp passes/control_flow_analyser.cpp passes/deprecated.cpp passes/field_analyser.cpp passes/fold_literals.cpp passes/import_scripts.cpp passes/link.cpp passes/loop_return.cpp passes/map_sugar.cpp passes/macro_expansion.cpp passes/pid_filter_pass.cpp passes/portability_analyser.cpp passes/printer.cpp passes/args_resolver.cpp passes/probe_prune.cpp passes/resource_analyser.cpp passes/types/type_checker.cpp passes/types/type_resolver.cpp passes/codegen_llvm.cpp passes/resolve_imports.cpp passes/recursion_check.cpp passes/tracepoint_format_parser.cpp passes/types/type_system.cpp passes/unstable_feature.cpp passes/usdt_arguments.cpp ) target_compile_definitions(ast PRIVATE ${BPFTRACE_FLAGS}) target_link_libraries(ast PRIVATE debugfs tracefs util stdlib ${LIBBPF_LIBRARIES}) target_link_libraries(ast PUBLIC ast_defs arch compiler_core btf) if (NOT SYSTEM_INCLUDE_PATHS EQUAL "auto") MESSAGE(STATUS "Using SYSTEM_INCLUDE_PATHS=${SYSTEM_INCLUDE_PATHS}") endif() target_compile_definitions(ast PUBLIC SYSTEM_INCLUDE_PATHS="${SYSTEM_INCLUDE_PATHS}") if(STATIC_LINKING) include(Util) set(llvm_lib_names bpfcodegen coverage frontenddriver frontendhlsl frontendopenmp ipo irreader lto mcjit option orcjit ${LLVM_TARGETS_TO_BUILD}) llvm_map_components_to_libnames(llvm_libs ${llvm_lib_names}) # It's extremely unclear why the clang static libraries export link # dependencies on the llvm and clang shared libraries. Regardless, we need # this hack to remove them. unlink_transitive_dependency("${CLANG_EXPORTED_TARGETS}" "LLVM") unlink_transitive_dependency("${CLANG_EXPORTED_TARGETS}" "$") target_link_libraries(ast PUBLIC libclang_static clangDriver clangFrontend clangCodeGen) target_link_libraries(ast PUBLIC ${llvm_libs}) else() if (TARGET LLVM) # llvm_config macro comes from the LLVM toolchain and will auto-resolve component # names to library names. USE_SHARED option will tell llvm_config macro to prefer # shared library / DLL on the system over the static libraries llvm_config(ast USE_SHARED bpfcodegen ipo irreader mcjit orcjit) else() # some build environment(e.g facebookexperimental/ExtendedAndroidTools) doesn't # have libLLVM.so, drop `USE_SHARED` to avoid forcing link to `-lLLVM`. llvm_config(ast bpfcodegen ipo irreader mcjit orcjit) endif() target_link_libraries(ast PUBLIC libclang clang-cpp) endif() bpftrace-0.27.1/src/ast/ast.cpp000066400000000000000000000234741526721631600162630ustar00rootroot00000000000000#include #include #include "ast/ast.h" #include "ast/context.h" #include "attached_probe.h" #include "log.h" #include "util/int_parser.h" #include "util/strings.h" namespace bpftrace::ast { Diagnostic &Node::addError() const { return state_.diagnostics_->addError(loc); } Diagnostic &Node::addWarning() const { return state_.diagnostics_->addWarning(loc); } bool Expression::is_literal() const { if (is() || is() || is() || is()) { return true; } if (auto *tuple = as()) { return std::ranges::all_of(tuple->elems, [](const auto &elem) { return elem.is_literal(); }); } if (auto *record = as()) { return std::ranges::all_of(record->elems, [](const auto &elem) { return elem->expr.is_literal(); }); } return false; } std::string opstr(const Jump &jump) { switch (jump.ident) { case JumpType::RETURN: return "return"; case JumpType::BREAK: return "break"; case JumpType::CONTINUE: return "continue"; default: return {}; } return {}; // unreached } std::string opstr(const Binop &binop) { switch (binop.op) { case Operator::EQ: return "=="; case Operator::NE: return "!="; case Operator::LE: return "<="; case Operator::GE: return ">="; case Operator::LT: return "<"; case Operator::GT: return ">"; case Operator::LAND: return "&&"; case Operator::LOR: return "||"; case Operator::LEFT: return "<<"; case Operator::RIGHT: return ">>"; case Operator::PLUS: return "+"; case Operator::MINUS: return "-"; case Operator::MUL: return "*"; case Operator::DIV: return "/"; case Operator::MOD: return "%"; case Operator::BAND: return "&"; case Operator::BOR: return "|"; case Operator::BXOR: return "^"; default: return {}; } return {}; // unreached } std::string opstr(const Unop &unop) { switch (unop.op) { case Operator::LNOT: return "!"; case Operator::BNOT: return "~"; case Operator::MINUS: return "-"; case Operator::MUL: return "*"; case Operator::POST_INCREMENT: return "++"; case Operator::PRE_INCREMENT: return "++"; case Operator::POST_DECREMENT: return "--"; case Operator::PRE_DECREMENT: return "--"; default: return {}; } return {}; // unreached } bool is_comparison_op(Operator op) { switch (op) { case Operator::EQ: case Operator::NE: case Operator::LE: case Operator::GE: case Operator::LT: case Operator::GT: case Operator::LAND: case Operator::LOR: return true; case Operator::PLUS: case Operator::MINUS: case Operator::MUL: case Operator::DIV: case Operator::MOD: case Operator::BAND: case Operator::BOR: case Operator::BXOR: case Operator::LEFT: case Operator::RIGHT: case Operator::ASSIGN: case Operator::PRE_INCREMENT: case Operator::PRE_DECREMENT: case Operator::POST_INCREMENT: case Operator::POST_DECREMENT: case Operator::LNOT: case Operator::BNOT: return false; } return false; // unreached } AttachPoint *AttachPoint::create_expansion_copy(ASTContext &ctx, const std::string &match) const { // Create a new node with the same raw tracepoint. We initialize all the // information about the attach point, and then override/reset values // depending on the specific probe type. auto *ap = ctx.make_node(loc, raw_input, ignore_invalid); ap->provider = provider; ap->target = target; ap->lang = lang; ap->ns = ns; ap->func = func; ap->pin = pin; ap->usdt = usdt; ap->freq = freq; ap->len = len; ap->mode = mode; ap->address = address; ap->func_offset = func_offset; ap->source_file = source_file; ap->line_num = line_num; ap->col_num = col_num; switch (probetype(ap->provider)) { case ProbeType::kprobe: case ProbeType::kretprobe: ap->func = match; if (match.find(":") != std::string::npos) ap->target = util::erase_prefix(ap->func); break; case ProbeType::fentry: case ProbeType::fexit: { if (match.starts_with("bpf:")) { auto parts = util::split_string(match, ':'); ap->target = parts[0]; auto prog_id = util::to_uint(parts[1]); if (!prog_id) { LOG(BUG) << "Invalid bpf prog id: " << parts[1]; } else { ap->bpf_prog_id = *prog_id; } ap->func = parts[2]; break; } [[fallthrough]]; } case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::tracepoint: case ProbeType::rawtracepoint: // Tracepoint, raw tracepoint, uprobe, and fentry/fexit probes specify // both a target (category for tracepoints, binary for uprobes, and // kernel module for fentry/fexit and a function name. ap->func = match; ap->target = util::erase_prefix(ap->func); break; case ProbeType::usdt: // USDT probes specify a target binary path, a provider, and a function // name. ap->func = match; ap->target = util::erase_prefix(ap->func); ap->ns = util::erase_prefix(ap->func); break; case ProbeType::watchpoint: case ProbeType::software: case ProbeType::hardware: case ProbeType::interval: case ProbeType::profile: case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::iter: case ProbeType::invalid: break; default: LOG(BUG) << "Unknown probe type"; } return ap; } bool AttachPoint::check_available(const std::string &identifier) const { ProbeType type = probetype(provider); if (identifier == "reg" || identifier == "__builtin_usermode") { switch (type) { case ProbeType::kprobe: case ProbeType::kretprobe: case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: case ProbeType::profile: case ProbeType::interval: case ProbeType::software: case ProbeType::hardware: case ProbeType::watchpoint: return true; case ProbeType::invalid: case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::tracepoint: case ProbeType::fentry: case ProbeType::fexit: case ProbeType::iter: case ProbeType::rawtracepoint: return false; } } else if (identifier == "__builtin_uaddr") { switch (type) { case ProbeType::usdt: case ProbeType::uretprobe: case ProbeType::uprobe: return true; case ProbeType::invalid: case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::kprobe: case ProbeType::kretprobe: case ProbeType::tracepoint: case ProbeType::profile: case ProbeType::interval: case ProbeType::software: case ProbeType::hardware: case ProbeType::watchpoint: case ProbeType::fentry: case ProbeType::fexit: case ProbeType::iter: case ProbeType::rawtracepoint: return false; } } else if (identifier == "skboutput" || identifier == "socket_cookie") { return bpftrace::progtype(type) == BPF_PROG_TYPE_TRACING; } if (type == ProbeType::invalid) return false; return true; } std::string AttachPoint::name() const { // If there's an explicit name for this probe provided, then this // is always used as the probe name. if (user_provided_name.has_value()) { return user_provided_name.value(); } // Otherwise, construct from provider, target, etc. std::string n = provider; if (!target.empty()) n += ":" + target; if (!lang.empty()) n += ":" + lang; if (!ns.empty()) n += ":" + ns; if (bpf_prog_id != 0) n += ":" + std::to_string(bpf_prog_id); if (!func.empty()) { n += ":" + func; if (func_offset != 0) n += "+" + std::to_string(func_offset); } if (address != 0) n += ":" + std::to_string(address); if (freq != 0) n += ":" + std::to_string(freq); if (len != 0) n += ":" + std::to_string(len); if (!mode.empty()) n += ":" + mode; return n; } std::optional Probe::attachpoint_name() const { if (attach_points.size() != 1) { return std::nullopt; } return attach_points.front()->name(); } std::optional Probe::args_typename() const { auto name = attachpoint_name(); if (!name) { return std::nullopt; } return std::string(STRUCT_PREFIX) + *name + "_args"; } int Probe::index() const { return index_; } void Probe::set_index(int index) { index_ = index; } bool Probe::has_ap_of_probetype(ProbeType probe_type) { return std::ranges::any_of(attach_points, [probe_type](auto *ap) { return probetype(ap->provider) == probe_type; }); } ProbeType Probe::get_probetype() { if (attach_points.empty()) { return ProbeType::invalid; } assert(attach_points.size() == 1); return probetype(attach_points.at(0)->provider); } void Program::clear_empty_probes() { auto it = std::ranges::remove_if(probes.begin(), probes.end(), [](const Probe *p) { return p->attach_points.empty(); }); probes.erase(it.begin(), it.end()); } Record *make_record(ASTContext &ctx, const Location &loc, std::vector> &&args) { NamedArgumentList named_args; named_args.reserve(args.size()); for (const auto &[name, expr] : args) { named_args.emplace_back(ctx.make_node(loc, name, expr)); } return ctx.make_node(loc, std::move(named_args)); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/ast.h000066400000000000000000001743261526721631600157330ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include #include "ast/clone.h" #include "ast/context.h" #include "diagnostic.h" #include "probe_types.h" #include "symbols/elf_parser.h" namespace bpftrace::ast { enum class JumpType { RETURN, CONTINUE, BREAK, }; enum class Operator { ASSIGN, EQ, NE, LE, GE, LEFT, RIGHT, LT, GT, LAND, LOR, PLUS, PRE_INCREMENT, PRE_DECREMENT, POST_INCREMENT, POST_DECREMENT, MINUS, MUL, DIV, MOD, BAND, BOR, BXOR, LNOT, BNOT, }; inline bool operator==(Operator lhs, Operator rhs) { return static_cast(lhs) == static_cast(rhs); } inline std::strong_ordering operator<=>(Operator lhs, Operator rhs) { return static_cast(lhs) <=> static_cast(rhs); } template bool ptr_deref_equal(const T *lhs, const T *rhs) { return lhs == rhs || (lhs && rhs && *lhs == *rhs); } template std::strong_ordering ptr_deref_compare(const T *lhs, const T *rhs) { if (lhs && rhs) return *lhs <=> *rhs; if (!lhs && !rhs) return std::strong_ordering::equal; return lhs ? std::strong_ordering::greater : std::strong_ordering::less; } class Node { public: Node(ASTContext &ctx, Location &&loc) : state_(*ctx.state_), loc(loc) {}; virtual ~Node() = default; Node(const Node &) = delete; Node &operator=(const Node &) = delete; Node(Node &&) = delete; Node &operator=(Node &&) = delete; Diagnostic &addError() const; Diagnostic &addWarning() const; private: // N.B. it is not legal to hold on to a long-term reference to `ASTContext&`, // as this is generally movable. Therefore, we hold on to the internal state // only, which will not be moving. // // See `ASTContext::State` for more information. ASTContext::State &state_; public: // This is temporarily accessible by other classes because we don't have a // clear `clone` operation at this time. Eventually this should be made // private and we should rely on a clear model for cloning nodes. Location loc; }; template class VariantNode { public: template VariantNode(T *value) requires(std::is_same_v || ...) : value(value) {}; template bool is() const { return std::holds_alternative(value); } template T *as() const { if (is()) { return std::get(value); } return nullptr; } Node &node() const { return std::visit([](auto *v) -> Node & { return *v; }, value); } const Location &loc() const { return std::visit([](const auto *v) -> const Location & { return v->loc; }, value); } bool operator==(const VariantNode &other) const { if (value.index() != other.value.index()) return false; return std::visit( [&other](auto *v) { using T = std::decay_t; auto *other_v = std::get(other.value); return *v == *other_v; }, value); } std::strong_ordering operator<=>(const VariantNode &other) const { if (auto cmp = value.index() <=> other.value.index(); cmp != 0) return cmp; return std::visit( [&other](auto *v) { using T = std::decay_t; auto *other_v = std::get(other.value); return *v <=> *other_v; }, value); } std::variant value; }; class Integer; class NegativeInteger; class Boolean; class PositionalParameter; class PositionalParameterCount; class String; class None; class Identifier; class Builtin; class ParsedType; class TypeArg; class Call; class Sizeof; class Offsetof; class Map; class Variable; class VariableAddr; class MapAddr; class Binop; class Unop; class FieldAccess; class ArrayAccess; class TupleAccess; class MapAccess; class Cast; class Tuple; class IfExpr; class BlockExpr; class Typeinfo; class Comptime; class Record; class Expression : public VariantNode { public: using VariantNode::VariantNode; Expression() : Expression(static_cast(nullptr)) {}; bool is_literal() const; }; using ExpressionList = std::vector; class ExprStatement; class VarDeclStatement; class AssignScalarMapStatement; class AssignMapStatement; class AssignVarStatement; class DiscardExpr; class Unroll; class Jump; class While; class For; class StatementImport; class Statement : public VariantNode { public: using VariantNode::VariantNode; Statement() : Statement(static_cast(nullptr)) {}; }; using StatementList = std::vector; class Config; class CStatement; class Macro; class MapDeclStatement; class Probe; class Subprog; class RootImport; class RootStatement : public VariantNode { public: using VariantNode::VariantNode; RootStatement() : RootStatement(static_cast(nullptr)) {}; }; using RootStatements = std::vector; class Integer : public Node { public: explicit Integer(ASTContext &ctx, Location &&loc, uint64_t n, std::optional &&original = std::nullopt) : Node(ctx, std::move(loc)), value(n), original(std::move(original)) {}; explicit Integer(ASTContext &ctx, const Location &loc, const Integer &other) : Node(ctx, loc + other.loc), value(other.value), original(other.original) {}; bool operator==(const Integer &other) const { return value == other.value; } std::strong_ordering operator<=>(const Integer &other) const { return value <=> other.value; } const uint64_t value; const std::optional original; }; class NegativeInteger : public Node { public: explicit NegativeInteger(ASTContext &ctx, Location &&loc, int64_t n) : Node(ctx, std::move(loc)), value(n) {}; explicit NegativeInteger(ASTContext &ctx, const Location &loc, const NegativeInteger &other) : Node(ctx, loc + other.loc), value(other.value) {}; bool operator==(const NegativeInteger &other) const { return value == other.value; } std::strong_ordering operator<=>(const NegativeInteger &other) const { return value <=> other.value; } const int64_t value; }; class Boolean : public Node { public: explicit Boolean(ASTContext &ctx, Location &&loc, bool val) : Node(ctx, std::move(loc)), value(val) {}; explicit Boolean(ASTContext &ctx, const Location &loc, const Boolean &other) : Node(ctx, loc + other.loc), value(other.value) {}; bool operator==(const Boolean &other) const { return value == other.value; } std::strong_ordering operator<=>(const Boolean &other) const { return value <=> other.value; } const bool value; }; class None : public Node { public: explicit None(ASTContext &ctx, Location &&loc) : Node(ctx, std::move(loc)) {}; explicit None(ASTContext &ctx, const Location &loc, const None &other) : Node(ctx, loc + other.loc) {}; bool operator==([[maybe_unused]] const None &other) const { return true; } std::strong_ordering operator<=>([[maybe_unused]] const None &other) const { return std::strong_ordering::equal; } }; class PositionalParameter : public Node { public: explicit PositionalParameter(ASTContext &ctx, Location &&loc, long n) : Node(ctx, std::move(loc)), n(n) {}; explicit PositionalParameter(ASTContext &ctx, const Location &loc, const PositionalParameter &other) : Node(ctx, loc + other.loc), n(other.n) {}; bool operator==(const PositionalParameter &other) const { return n == other.n; } std::strong_ordering operator<=>(const PositionalParameter &other) const { return n <=> other.n; } const long n; }; class PositionalParameterCount : public Node { public: explicit PositionalParameterCount(ASTContext &ctx, Location &&loc) : Node(ctx, std::move(loc)) {}; explicit PositionalParameterCount( ASTContext &ctx, const Location &loc, [[maybe_unused]] const PositionalParameterCount &other) : Node(ctx, loc + other.loc) {}; bool operator==([[maybe_unused]] const PositionalParameterCount &other) const { return true; } std::strong_ordering operator<=>( [[maybe_unused]] const PositionalParameterCount &other) const { return std::strong_ordering::equal; } }; class String : public Node { public: explicit String(ASTContext &ctx, Location &&loc, std::string str) : Node(ctx, std::move(loc)), value(std::move(str)) {}; explicit String(ASTContext &ctx, const Location &loc, const String &other) : Node(ctx, loc + other.loc), value(other.value) {}; bool operator==(const String &other) const { return value == other.value; } std::strong_ordering operator<=>(const String &other) const { return value <=> other.value; } const std::string value; }; class Identifier : public Node { public: explicit Identifier(ASTContext &ctx, Location &&loc, std::string ident) : Node(ctx, std::move(loc)), ident(std::move(ident)) {}; explicit Identifier(ASTContext &ctx, const Location &loc, const Identifier &other) : Node(ctx, loc + other.loc), ident(other.ident) {}; bool operator==(const Identifier &other) const { return ident == other.ident; } std::strong_ordering operator<=>(const Identifier &other) const { return ident <=> other.ident; } std::string ident; }; class Builtin : public Node { public: explicit Builtin(ASTContext &ctx, Location &&loc, std::string ident) : Node(ctx, std::move(loc)), ident(std::move(ident)), probe_id(-1) {}; explicit Builtin(ASTContext &ctx, const Location &loc, const Builtin &other) : Node(ctx, loc + other.loc), ident(other.ident), probe_id(other.probe_id) {}; // Check if the builtin is 'arg0' - 'arg255' bool is_argx() const { if (ident.size() < 4 || ident.size() > 6 || !ident.starts_with("arg")) return false; std::string num_part = ident.substr(3); // no leading zeros if (num_part.size() > 1 && num_part.front() == '0') return false; int arg_num = 0; auto [ptr, ec] = std::from_chars(num_part.data(), num_part.data() + num_part.size(), arg_num); return ec == std::errc() && ptr == num_part.data() + num_part.size() && arg_num >= 0 && arg_num < 256; } bool operator==(const Builtin &other) const { return ident == other.ident && probe_id == other.probe_id; } std::strong_ordering operator<=>(const Builtin &other) const { if (auto cmp = ident <=> other.ident; cmp != 0) return cmp; return probe_id <=> other.probe_id; } std::string ident; int probe_id; }; class Call : public Node { public: explicit Call(ASTContext &ctx, Location &&loc, std::string func, ExpressionList &&vargs) : Node(ctx, std::move(loc)), func(std::move(func)), vargs(std::move(vargs)) {}; explicit Call(ASTContext &ctx, const Location &loc, const Call &other) : Node(ctx, loc + other.loc), func(other.func), vargs(clone(ctx, loc, other.vargs)), injected_args(other.injected_args) {}; bool operator==(const Call &other) const { return func == other.func && vargs == other.vargs && injected_args == other.injected_args; } std::strong_ordering operator<=>(const Call &other) const { if (auto cmp = func <=> other.func; cmp != 0) return cmp; if (vargs.size() != other.vargs.size()) return vargs.size() <=> other.vargs.size(); for (size_t i = 0; i < vargs.size(); ++i) { if (auto cmp = vargs[i] <=> other.vargs[i]; cmp != 0) return cmp; } return injected_args <=> other.injected_args; } std::string func; ExpressionList vargs; // Some passes may inject new arguments to the call, which is always // done at the beginning (in order to support variadic arguments) for // later passes. This is a result of "desugaring" some syntax. When this // happens, this number is increased so that later error reporting can // correctly account for this. size_t injected_args = 0; }; class ParsedType : public Node { public: enum class Kind { Identifier, Struct, Union, Enum, Pointer, Array, }; ParsedType(ASTContext &ctx, Location &&loc, Kind kind, std::string name) : Node(ctx, std::move(loc)), kind(kind), name(std::move(name)) {}; ParsedType(ASTContext &ctx, Location &&loc, ParsedType *pointee) : Node(ctx, std::move(loc)), kind(Kind::Pointer), inner(pointee) {}; ParsedType(ASTContext &ctx, Location &&loc, uint64_t size, ParsedType *element) : Node(ctx, std::move(loc)), kind(Kind::Array), array_size(size), inner(element) {}; ParsedType(ASTContext &ctx, const Location &loc, const ParsedType &other) : Node(ctx, loc + other.loc), kind(other.kind), name(other.name), array_size(other.array_size), inner(other.inner ? ctx.clone_node(loc, other.inner) : nullptr) {}; std::string type_name() const { switch (kind) { case Kind::Identifier: return name; case Kind::Struct: return "struct " + name; case Kind::Union: return "union " + name; case Kind::Enum: return "enum " + name; case Kind::Pointer: case Kind::Array: return inner ? inner->type_name() + "*" : ""; } return ""; } const ParsedType &base_type() const { if ((kind == Kind::Pointer || kind == Kind::Array) && inner) { return inner->base_type(); } return *this; } bool operator==(const ParsedType &other) const { return kind == other.kind && name == other.name && array_size == other.array_size && ptr_deref_equal(inner, other.inner); } std::strong_ordering operator<=>(const ParsedType &other) const { if (auto cmp = kind <=> other.kind; cmp != 0) { return cmp; } if (auto cmp = name <=> other.name; cmp != 0) { return cmp; } if (auto cmp = array_size <=> other.array_size; cmp != 0) { return cmp; } return ptr_deref_compare(inner, other.inner); } Kind kind; std::string name; uint64_t array_size = 0; ParsedType *inner = nullptr; }; using ExprOrType = std::variant; inline bool expr_or_type_equal(const ExprOrType &lhs, const ExprOrType &rhs) { if (auto *const *p = std::get_if(&lhs)) { auto *const *q = std::get_if(&rhs); return q && *p && *q && **p == **q; } return lhs == rhs; } inline std::strong_ordering expr_or_type_compare(const ExprOrType &lhs, const ExprOrType &rhs) { if (auto cmp = lhs.index() <=> rhs.index(); cmp != 0) return cmp; if (auto *const *p = std::get_if(&lhs)) { auto *q = std::get(rhs); if (*p && q) return **p <=> *q; if (!*p && !q) return std::strong_ordering::equal; return *p ? std::strong_ordering::greater : std::strong_ordering::less; } return std::get(lhs) <=> std::get(rhs); } class Typeof : public Node { public: explicit Typeof(ASTContext &ctx, Location &&loc, ParsedType *record) : Node(ctx, std::move(loc)), record(std::move(record)) {}; explicit Typeof(ASTContext &ctx, Location &&loc, Expression expr) : Node(ctx, std::move(loc)), record(expr) {}; explicit Typeof(ASTContext &ctx, const Location &loc, const Typeof &other) : Node(ctx, loc + other.loc), record(clone(ctx, loc + other.loc, other.record)) {}; bool operator==(const Typeof &other) const { return expr_or_type_equal(record, other.record); } std::strong_ordering operator<=>(const Typeof &other) const { return expr_or_type_compare(record, other.record); } ExprOrType record; }; class Sizeof : public Node { public: explicit Sizeof(ASTContext &ctx, Location &&loc, Typeof *type_of) : Node(ctx, std::move(loc)), type_of(type_of) {}; explicit Sizeof(ASTContext &ctx, const Location &loc, const Sizeof &other) : Node(ctx, loc + other.loc), type_of(clone(ctx, loc + other.loc, other.type_of)) {}; bool operator==(const Sizeof &other) const { return ptr_deref_equal(type_of, other.type_of); } std::strong_ordering operator<=>(const Sizeof &other) const { return ptr_deref_compare(type_of, other.type_of); } Typeof *type_of = nullptr; }; class Offsetof : public Node { public: explicit Offsetof(ASTContext &ctx, Location &&loc, Typeof *type_of, std::vector field) : Node(ctx, std::move(loc)), type_of(type_of), field(std::move(field)) {}; explicit Offsetof(ASTContext &ctx, const Location &loc, const Offsetof &other) : Node(ctx, loc + other.loc), type_of(clone(ctx, loc + other.loc, other.type_of)), field(other.field) {}; bool operator==(const Offsetof &other) const { return ptr_deref_equal(type_of, other.type_of) && field == other.field; } std::strong_ordering operator<=>(const Offsetof &other) const { if (auto cmp = ptr_deref_compare(type_of, other.type_of); cmp != 0) return cmp; return field <=> other.field; } Typeof *type_of = nullptr; std::vector field; }; class Map : public Node { public: explicit Map(ASTContext &ctx, Location &&loc, std::string ident) : Node(ctx, std::move(loc)), ident(std::move(ident)) {}; explicit Map(ASTContext &ctx, const Location &loc, const Map &other) : Node(ctx, loc + other.loc), ident(other.ident) {}; bool operator==(const Map &other) const { return ident == other.ident; } std::strong_ordering operator<=>(const Map &other) const { return ident <=> other.ident; } std::string ident; }; class TypeArg : public Node { public: explicit TypeArg(ASTContext &ctx, Location &&loc, Typeof *type_of) : Node(ctx, std::move(loc)), type_of(type_of) {}; explicit TypeArg(ASTContext &ctx, const Location &loc, const TypeArg &other) : Node(ctx, loc + other.loc), type_of(clone(ctx, loc, other.type_of)) {}; bool operator==(const TypeArg &other) const { return ptr_deref_equal(type_of, other.type_of); } std::strong_ordering operator<=>(const TypeArg &other) const { return ptr_deref_compare(type_of, other.type_of); } Typeof *type_of; }; class Typeinfo : public Node { public: explicit Typeinfo(ASTContext &ctx, Location &&loc, Typeof *typeof) : Node(ctx, std::move(loc)), typeof(typeof) {}; explicit Typeinfo(ASTContext &ctx, const Location &loc, const Typeinfo &other) : Node(ctx, loc + other.loc), typeof(clone(ctx, loc + other.loc, other.typeof)) {}; bool operator==(const Typeinfo &other) const { return ptr_deref_equal(typeof, other.typeof); } std::strong_ordering operator<=>(const Typeinfo &other) const { return ptr_deref_compare(typeof, other.typeof); } Typeof *typeof = nullptr; }; class Comptime : public Node { public: explicit Comptime(ASTContext &ctx, Location &&loc, Expression expr) : Node(ctx, std::move(loc)), expr(std::move(expr)) {}; explicit Comptime(ASTContext &ctx, const Location &loc, const Comptime &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc + other.loc, other.expr)) {}; bool operator==([[maybe_unused]] const Comptime &other) const { return expr == other.expr; } std::strong_ordering operator<=>([[maybe_unused]] const Comptime &other) const { return expr <=> other.expr; } Expression expr; }; class MapDeclStatement : public Node { public: explicit MapDeclStatement(ASTContext &ctx, Location &&loc, std::string ident, std::string bpf_type, int max_entries) : Node(ctx, std::move(loc)), ident(std::move(ident)), bpf_type(std::move(bpf_type)), max_entries(max_entries) {}; explicit MapDeclStatement(ASTContext &ctx, const Location &loc, const MapDeclStatement &other) : Node(ctx, loc + other.loc), ident(other.ident), bpf_type(other.bpf_type), max_entries(other.max_entries) {}; bool operator==(const MapDeclStatement &other) const { return ident == other.ident && bpf_type == other.bpf_type && max_entries == other.max_entries; } std::strong_ordering operator<=>(const MapDeclStatement &other) const { if (auto cmp = ident <=> other.ident; cmp != 0) return cmp; if (auto cmp = bpf_type <=> other.bpf_type; cmp != 0) return cmp; return max_entries <=> other.max_entries; } const std::string ident; const std::string bpf_type; const int max_entries; }; using MapDeclList = std::vector; class Variable : public Node { public: explicit Variable(ASTContext &ctx, Location &&loc, std::string ident) : Node(ctx, std::move(loc)), ident(std::move(ident)) {}; explicit Variable(ASTContext &ctx, const Location &loc, const Variable &other) : Node(ctx, loc + other.loc), ident(other.ident) {}; bool operator==(const Variable &other) const { return ident == other.ident; } std::strong_ordering operator<=>(const Variable &other) const { return ident <=> other.ident; } std::string ident; }; class VariableAddr : public Node { public: explicit VariableAddr(ASTContext &ctx, Location &&loc, Variable *var) : Node(ctx, std::move(loc)), var(var) {}; explicit VariableAddr(ASTContext &ctx, const Location &loc, const VariableAddr &other) : Node(ctx, loc + other.loc), var(clone(ctx, loc, other.var)) {}; bool operator==(const VariableAddr &other) const { return *var == *other.var; } std::strong_ordering operator<=>(const VariableAddr &other) const { return *var <=> *other.var; } Variable *var = nullptr; }; class MapAddr : public Node { public: explicit MapAddr(ASTContext &ctx, Location &&loc, Map *map) : Node(ctx, std::move(loc)), map(map) {}; explicit MapAddr(ASTContext &ctx, const Location &loc, const MapAddr &other) : Node(ctx, loc + other.loc), map(clone(ctx, loc, other.map)) {}; bool operator==(const MapAddr &other) const { return *map == *other.map; } std::strong_ordering operator<=>(const MapAddr &other) const { return *map <=> *other.map; } Map *map = nullptr; }; class Binop : public Node { public: explicit Binop(ASTContext &ctx, Location &&loc, Expression left, Operator op, Expression right) : Node(ctx, std::move(loc)), left(std::move(left)), right(std::move(right)), op(op) {}; explicit Binop(ASTContext &ctx, const Location &loc, const Binop &other) : Node(ctx, loc + other.loc), left(clone(ctx, loc, other.left)), right(clone(ctx, loc, other.right)), op(other.op) {}; bool operator==(const Binop &other) const { return op == other.op && left == other.left && right == other.right; } std::strong_ordering operator<=>(const Binop &other) const { if (auto cmp = op <=> other.op; cmp != 0) return cmp; if (auto cmp = left <=> other.left; cmp != 0) return cmp; return right <=> other.right; } Expression left; Expression right; Operator op; }; class Unop : public Node { public: explicit Unop(ASTContext &ctx, Location &&loc, Expression expr, Operator op) : Node(ctx, std::move(loc)), expr(std::move(expr)), op(op) {}; explicit Unop(ASTContext &ctx, const Location &loc, const Unop &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)), op(other.op) {}; bool operator==(const Unop &other) const { return op == other.op && expr == other.expr; } std::strong_ordering operator<=>(const Unop &other) const { if (auto cmp = op <=> other.op; cmp != 0) return cmp; return expr <=> other.expr; } Expression expr; Operator op; }; class FieldAccess : public Node { public: explicit FieldAccess(ASTContext &ctx, Location &&loc, Expression expr, std::string field) : Node(ctx, std::move(loc)), expr(std::move(expr)), field(std::move(field)) {}; explicit FieldAccess(ASTContext &ctx, const Location &loc, const FieldAccess &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)), field(other.field) {}; bool operator==(const FieldAccess &other) const { return field == other.field && expr == other.expr; } std::strong_ordering operator<=>(const FieldAccess &other) const { if (auto cmp = field <=> other.field; cmp != 0) return cmp; return expr <=> other.expr; } Expression expr; std::string field; }; class ArrayAccess : public Node { public: explicit ArrayAccess(ASTContext &ctx, Location &&loc, Expression expr, Expression indexpr) : Node(ctx, std::move(loc)), expr(std::move(expr)), indexpr(std::move(indexpr)) {}; explicit ArrayAccess(ASTContext &ctx, const Location &loc, const ArrayAccess &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)), indexpr(clone(ctx, loc, other.indexpr)) {}; bool operator==(const ArrayAccess &other) const { return expr == other.expr && indexpr == other.indexpr; } std::strong_ordering operator<=>(const ArrayAccess &other) const { if (auto cmp = expr <=> other.expr; cmp != 0) return cmp; return indexpr <=> other.indexpr; } Expression expr; Expression indexpr; }; class TupleAccess : public Node { public: explicit TupleAccess(ASTContext &ctx, Location &&loc, Expression expr, ssize_t index) : Node(ctx, std::move(loc)), expr(std::move(expr)), index(index) {}; explicit TupleAccess(ASTContext &ctx, const Location &loc, const TupleAccess &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)), index(other.index) {}; bool operator==(const TupleAccess &other) const { return index == other.index && expr == other.expr; } std::strong_ordering operator<=>(const TupleAccess &other) const { if (auto cmp = index <=> other.index; cmp != 0) return cmp; return expr <=> other.expr; } Expression expr; size_t index; }; class MapAccess : public Node { public: explicit MapAccess(ASTContext &ctx, Location &&loc, Map *map, Expression key) : Node(ctx, std::move(loc)), map(map), key(std::move(key)) {}; explicit MapAccess(ASTContext &ctx, const Location &loc, const MapAccess &other) : Node(ctx, loc + other.loc), map(clone(ctx, loc, other.map)), key(clone(ctx, loc, other.key)) {}; bool operator==(const MapAccess &other) const { return *map == *other.map && key == other.key; } std::strong_ordering operator<=>(const MapAccess &other) const { if (auto cmp = *map <=> *other.map; cmp != 0) return cmp; return key <=> other.key; } Map *map = nullptr; Expression key; }; class Cast : public Node { public: explicit Cast(ASTContext &ctx, Location &&loc, Typeof *typeof, Expression expr) : Node(ctx, std::move(loc)), typeof(typeof), expr(std::move(expr)) {}; explicit Cast(ASTContext &ctx, const Location &loc, const Cast &other) : Node(ctx, loc + other.loc), typeof(clone(ctx, loc, other.typeof)), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const Cast &other) const { return ptr_deref_equal(typeof, other.typeof) && expr == other.expr; } std::strong_ordering operator<=>(const Cast &other) const { if (auto cmp = ptr_deref_compare(typeof, other.typeof); cmp != 0) return cmp; return expr <=> other.expr; } Typeof *typeof; Expression expr; }; class Tuple : public Node { public: explicit Tuple(ASTContext &ctx, Location &&loc, ExpressionList &&elems) : Node(ctx, std::move(loc)), elems(std::move(elems)) {}; explicit Tuple(ASTContext &ctx, const Location &loc, const Tuple &other) : Node(ctx, loc + other.loc), elems(clone(ctx, loc, other.elems)) {}; bool operator==(const Tuple &other) const { return elems == other.elems; } std::strong_ordering operator<=>(const Tuple &other) const { return elems <=> other.elems; } ExpressionList elems; }; class NamedArgument : public Node { public: explicit NamedArgument(ASTContext &ctx, Location &&loc, std::string name, Expression expr) : Node(ctx, std::move(loc)), name(std::move(name)), expr(std::move(expr)) {}; explicit NamedArgument(ASTContext &ctx, const Location &loc, const NamedArgument &other) : Node(ctx, loc + other.loc), name(other.name), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const NamedArgument &other) const { return name == other.name && expr == other.expr; } std::strong_ordering operator<=>(const NamedArgument &other) const { if (auto cmp = name <=> other.name; cmp != 0) return cmp; return expr <=> other.expr; } const std::string name; Expression expr; }; using NamedArgumentList = std::vector; class Record : public Node { public: explicit Record(ASTContext &ctx, Location &&loc, NamedArgumentList &&named_args) : Node(ctx, std::move(loc)), elems(std::move(named_args)) {}; explicit Record(ASTContext &ctx, const Location &loc, const Record &other) : Node(ctx, loc + other.loc), elems(clone(ctx, loc, other.elems)) {}; bool operator==(const Record &other) const { return std::ranges::equal(elems, other.elems, [](const auto *a, const auto *b) { return *a == *b; }); } std::strong_ordering operator<=>(const Record &other) const { if (auto cmp = elems.size() <=> other.elems.size(); cmp != 0) { return cmp; } for (size_t i = 0; i < elems.size(); ++i) { if (auto cmp = *elems[i] <=> *other.elems[i]; cmp != 0) { return cmp; } } return std::strong_ordering::equal; } NamedArgumentList elems; }; class ExprStatement : public Node { public: explicit ExprStatement(ASTContext &ctx, Location &&loc, Expression expr) : Node(ctx, std::move(loc)), expr(expr) {}; explicit ExprStatement(ASTContext &ctx, const Location &loc, const ExprStatement &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const ExprStatement &other) const { return expr == other.expr; } std::strong_ordering operator<=>(const ExprStatement &other) const { return expr <=> other.expr; } Expression expr; }; class VarDeclStatement : public Node { public: explicit VarDeclStatement(ASTContext &ctx, Location &&loc, Variable *var, Typeof *typeof) : Node(ctx, std::move(loc)), var(var), typeof(typeof) {}; explicit VarDeclStatement(ASTContext &ctx, Location &&loc, Variable *var) : Node(ctx, std::move(loc)), var(var) {}; explicit VarDeclStatement(ASTContext &ctx, const Location &loc, const VarDeclStatement &other) : Node(ctx, loc + other.loc), var(clone(ctx, loc, other.var)), typeof(clone(ctx, loc, other.typeof)) {}; bool operator==(const VarDeclStatement &other) const { return *var == *other.var && ptr_deref_equal(typeof, other.typeof); } std::strong_ordering operator<=>(const VarDeclStatement &other) const { if (auto cmp = *var <=> *other.var; cmp != 0) return cmp; return ptr_deref_compare(typeof, other.typeof); } Variable *var = nullptr; Typeof *typeof = nullptr; }; // Scalar map assignment is purely syntactic sugar that is removed by the pass // returned by`CreateMapSugarPass`. This is replaced by the expansion of // default keys, so that later steps (type resolution, code generation), // don't need to worry about this. Maps whose accesses are bound to a single // key will be automatically collapsed into scalar values on the output side. class AssignScalarMapStatement : public Node { public: explicit AssignScalarMapStatement(ASTContext &ctx, Location &&loc, Map *map, Expression expr) : Node(ctx, std::move(loc)), map(map), expr(std::move(expr)) {}; explicit AssignScalarMapStatement(ASTContext &ctx, const Location &loc, const AssignScalarMapStatement &other) : Node(ctx, loc + other.loc), map(clone(ctx, loc, other.map)), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const AssignScalarMapStatement &other) const { return *map == *other.map && expr == other.expr; } std::strong_ordering operator<=>(const AssignScalarMapStatement &other) const { if (auto cmp = *map <=> *other.map; cmp != 0) return cmp; return expr <=> other.expr; } Map *map = nullptr; Expression expr; }; class AssignMapStatement : public Node { public: explicit AssignMapStatement(ASTContext &ctx, Location &&loc, MapAccess *map, Expression expr) : Node(ctx, std::move(loc)), map_access(map), expr(std::move(expr)) {}; explicit AssignMapStatement(ASTContext &ctx, const Location &loc, const AssignMapStatement &other) : Node(ctx, loc + other.loc), map_access(clone(ctx, loc, other.map_access)), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const AssignMapStatement &other) const { return *map_access == *other.map_access && expr == other.expr; } std::strong_ordering operator<=>(const AssignMapStatement &other) const { if (auto cmp = *map_access <=> *other.map_access; cmp != 0) return cmp; return expr <=> other.expr; } MapAccess *map_access = nullptr; Expression expr; }; class AssignVarStatement : public Node { public: explicit AssignVarStatement(ASTContext &ctx, Location &&loc, Variable *var, Expression expr) : Node(ctx, std::move(loc)), var_decl(var), expr(std::move(expr)) {}; explicit AssignVarStatement(ASTContext &ctx, Location &&loc, VarDeclStatement *var_decl_stmt, Expression expr) : Node(ctx, std::move(loc)), var_decl(var_decl_stmt), expr(std::move(expr)) {}; explicit AssignVarStatement(ASTContext &ctx, const Location &loc, const AssignVarStatement &other) : Node(ctx, loc + other.loc), var_decl(clone(ctx, loc, other.var_decl)), expr(clone(ctx, loc, other.expr)) {}; Variable *var() const { if (std::holds_alternative(var_decl)) { return std::get(var_decl)->var; } else { return std::get(var_decl); } } bool operator==(const AssignVarStatement &other) const { if (var_decl.index() != other.var_decl.index()) return false; bool var_decl_equal = std::visit( [&other](const auto &v) { using T = std::decay_t; return *v == *std::get(other.var_decl); }, var_decl); return var_decl_equal && expr == other.expr; } std::strong_ordering operator<=>(const AssignVarStatement &other) const { if (auto cmp = var_decl.index() <=> other.var_decl.index(); cmp != 0) return cmp; auto var_decl_cmp = std::visit( [&other](const auto &v) { using T = std::decay_t; return *v <=> *std::get(other.var_decl); }, var_decl); if (var_decl_cmp != 0) return var_decl_cmp; return expr <=> other.expr; } std::variant var_decl; Expression expr; }; class AssignConfigVarStatement : public Node { public: explicit AssignConfigVarStatement(ASTContext &ctx, Location &&loc, std::string var, uint64_t value) : Node(ctx, std::move(loc)), var(std::move(var)), value(value) {}; explicit AssignConfigVarStatement(ASTContext &ctx, Location &&loc, std::string var, std::string value) : Node(ctx, std::move(loc)), var(std::move(var)), value(std::move(value)) {}; explicit AssignConfigVarStatement(ASTContext &ctx, Location &&loc, std::string var, bool value) : Node(ctx, std::move(loc)), var(std::move(var)), value(value) {}; explicit AssignConfigVarStatement(ASTContext &ctx, const Location &loc, const AssignConfigVarStatement &other) : Node(ctx, loc + other.loc), var(other.var), value(other.value) {}; bool operator==(const AssignConfigVarStatement &other) const { return var == other.var && value == other.value; } std::strong_ordering operator<=>(const AssignConfigVarStatement &other) const { if (auto cmp = var <=> other.var; cmp != 0) return cmp; return value <=> other.value; } std::string var; std::variant value; }; using ConfigStatementList = std::vector; class BlockExpr : public Node { public: explicit BlockExpr(ASTContext &ctx, Location &&loc, StatementList &&stmts, Expression expr) : Node(ctx, std::move(loc)), stmts(std::move(stmts)), expr(std::move(expr)) {}; explicit BlockExpr(ASTContext &ctx, const Location &loc, const BlockExpr &other) : Node(ctx, loc + other.loc), stmts(clone(ctx, loc, other.stmts)), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const BlockExpr &other) const { return stmts == other.stmts && expr == other.expr; } std::strong_ordering operator<=>(const BlockExpr &other) const { if (auto cmp = stmts <=> other.stmts; cmp != 0) return cmp; return expr <=> other.expr; } StatementList stmts; Expression expr; }; class DiscardExpr : public Node { public: explicit DiscardExpr(ASTContext &ctx, Location &&loc, Expression expr) : Node(ctx, std::move(loc)), expr(std::move(expr)) {}; explicit DiscardExpr(ASTContext &ctx, const Location &loc, const DiscardExpr &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)) {}; bool operator==(const DiscardExpr &other) const { return expr == other.expr; } std::strong_ordering operator<=>(const DiscardExpr &other) const { return expr <=> other.expr; } Expression expr; }; class Unroll : public Node { public: explicit Unroll(ASTContext &ctx, Location &&loc, Expression expr, BlockExpr *block) : Node(ctx, std::move(loc)), expr(std::move(expr)), block(block) {}; explicit Unroll(ASTContext &ctx, const Location &loc, const Unroll &other) : Node(ctx, loc + other.loc), expr(clone(ctx, loc, other.expr)), block(clone(ctx, loc, other.block)) {}; bool operator==(const Unroll &other) const { return expr == other.expr && *block == *other.block; } std::strong_ordering operator<=>(const Unroll &other) const { if (auto cmp = expr <=> other.expr; cmp != 0) return cmp; return *block <=> *other.block; } Expression expr; BlockExpr *block = nullptr; }; class Jump : public Node { public: explicit Jump(ASTContext &ctx, Location &&loc, JumpType ident, Expression return_value) : Node(ctx, std::move(loc)), ident(ident), return_value(std::move(return_value)) {}; explicit Jump(ASTContext &ctx, Location &&loc, JumpType ident) : Node(ctx, std::move(loc)), ident(ident) {}; explicit Jump(ASTContext &ctx, const Location &loc, const Jump &other) : Node(ctx, loc + other.loc), ident(other.ident), return_value(clone(ctx, loc, other.return_value)) {}; bool operator==(const Jump &other) const { return ident == other.ident && return_value == other.return_value; } std::strong_ordering operator<=>(const Jump &other) const { if (auto cmp = ident <=> other.ident; cmp != 0) return cmp; return return_value <=> other.return_value; } JumpType ident; std::optional return_value; }; class IfExpr : public Node { public: explicit IfExpr(ASTContext &ctx, Location &&loc, Expression cond, Expression left, Expression right) : Node(ctx, std::move(loc)), cond(std::move(cond)), left(std::move(left)), right(std::move(right)) {}; explicit IfExpr(ASTContext &ctx, const Location &loc, const IfExpr &other) : Node(ctx, loc + other.loc), cond(clone(ctx, loc, other.cond)), left(clone(ctx, loc, other.left)), right(clone(ctx, loc, other.right)) {}; bool operator==(const IfExpr &other) const { return cond == other.cond && left == other.left && right == other.right; } std::strong_ordering operator<=>(const IfExpr &other) const { if (auto cmp = cond <=> other.cond; cmp != 0) return cmp; if (auto cmp = left <=> other.left; cmp != 0) return cmp; return right <=> other.right; } Expression cond; Expression left; Expression right; }; class While : public Node { public: explicit While(ASTContext &ctx, Location &&loc, Expression cond, BlockExpr *block) : Node(ctx, std::move(loc)), cond(cond), block(block) {}; explicit While(ASTContext &ctx, const Location &loc, const While &other) : Node(ctx, loc + other.loc), cond(clone(ctx, loc, other.cond)), block(clone(ctx, loc, other.block)) {}; bool operator==(const While &other) const { return cond == other.cond && *block == *other.block; } std::strong_ordering operator<=>(const While &other) const { if (auto cmp = cond <=> other.cond; cmp != 0) return cmp; return *block <=> *other.block; } Expression cond; BlockExpr *block = nullptr; }; class Range : public Node { public: explicit Range(ASTContext &ctx, Location &&loc, Expression start, Expression end) : Node(ctx, std::move(loc)), start(start), end(end) {}; explicit Range(ASTContext &ctx, const Location &loc, const Range &other) : Node(ctx, loc + other.loc), start(clone(ctx, loc, other.start)), end(clone(ctx, loc, other.end)) {}; bool operator==(const Range &other) const { return start == other.start && end == other.end; } std::strong_ordering operator<=>(const Range &other) const { if (auto cmp = start <=> other.start; cmp != 0) return cmp; return end <=> other.end; } Expression start; Expression end; }; class Iterable : public VariantNode { public: using VariantNode::VariantNode; Iterable() : Iterable(static_cast(nullptr)) {}; }; class For : public Node { public: explicit For(ASTContext &ctx, Location &&loc, Variable *decl, Iterable iterable, BlockExpr *block) : Node(ctx, std::move(loc)), decl(decl), iterable(iterable), block(block) {}; explicit For(ASTContext &ctx, const Location &loc, const For &other) : Node(ctx, loc + other.loc), decl(clone(ctx, loc, other.decl)), iterable(clone(ctx, loc, other.iterable)), block(clone(ctx, loc, other.block)) {}; bool operator==(const For &other) const { return *decl == *other.decl && iterable == other.iterable && *block == *other.block; } std::strong_ordering operator<=>(const For &other) const { if (auto cmp = *decl <=> *other.decl; cmp != 0) return cmp; if (auto cmp = iterable <=> other.iterable; cmp != 0) return cmp; return *block <=> *other.block; } Variable *decl = nullptr; Iterable iterable; BlockExpr *block = nullptr; }; class Config : public Node { public: explicit Config(ASTContext &ctx, Location &&loc, ConfigStatementList &&stmts) : Node(ctx, std::move(loc)), stmts(std::move(stmts)) {}; explicit Config(ASTContext &ctx, const Location &loc, const Config &other) : Node(ctx, loc + other.loc), stmts(clone(ctx, loc, other.stmts)) {}; bool operator==(const Config &other) const { return stmts == other.stmts; } std::strong_ordering operator<=>(const Config &other) const { return stmts <=> other.stmts; } ConfigStatementList stmts; }; class Probe; class AttachPoint : public Node { public: explicit AttachPoint(ASTContext &ctx, Location &&loc, std::string raw_input, bool ignore_invalid) : Node(ctx, std::move(loc)), raw_input(std::move(raw_input)), ignore_invalid(ignore_invalid) {}; explicit AttachPoint(ASTContext &ctx, const Location &loc, const AttachPoint &other) : Node(ctx, loc + other.loc), raw_input(other.raw_input), provider(other.provider), target(other.target), lang(other.lang), ns(other.ns), func(other.func), pin(other.pin), usdt(other.usdt), freq(other.freq), len(other.len), mode(other.mode), address(other.address), func_offset(other.func_offset), ignore_invalid(other.ignore_invalid) {}; bool operator==(const AttachPoint &other) const { return raw_input == other.raw_input && provider == other.provider && target == other.target && lang == other.lang && ns == other.ns && func == other.func && pin == other.pin && freq == other.freq && len == other.len && mode == other.mode && address == other.address && func_offset == other.func_offset && ignore_invalid == other.ignore_invalid; } std::strong_ordering operator<=>(const AttachPoint &other) const { if (auto cmp = raw_input <=> other.raw_input; cmp != 0) return cmp; if (auto cmp = provider <=> other.provider; cmp != 0) return cmp; if (auto cmp = target <=> other.target; cmp != 0) return cmp; if (auto cmp = lang <=> other.lang; cmp != 0) return cmp; if (auto cmp = ns <=> other.ns; cmp != 0) return cmp; if (auto cmp = func <=> other.func; cmp != 0) return cmp; if (auto cmp = pin <=> other.pin; cmp != 0) return cmp; if (auto cmp = freq <=> other.freq; cmp != 0) return cmp; if (auto cmp = len <=> other.len; cmp != 0) return cmp; if (auto cmp = mode <=> other.mode; cmp != 0) return cmp; if (auto cmp = address <=> other.address; cmp != 0) return cmp; if (auto cmp = func_offset <=> other.func_offset; cmp != 0) return cmp; return ignore_invalid <=> other.ignore_invalid; } // Currently, the AST node itself is used to store metadata related to probe // expansion and attachment. This is done through `create_expansion_copy` // below. Since the nodes are not currently copyable by default (this is // currently fraught, as nodes may have backreferences that are not updated // in these cases), these fields are copied manually. *Until this is fixed, // if you are adding new fields, be sure to update `create_expansion_copy`. // // FIXME(amscanne): We are not currently cloning AttachPoints correctly, as // they refer to the existing ret probe. // Raw, unparsed input from user, eg. kprobe:vfs_read std::string raw_input; // The unique, user-provided name for this specific attachpoint. This is // the string the comes before the probe itself, e.g. foo=kprobe:xyz. If // this is not provided, then the attachpoint string is the unique name. std::optional user_provided_name; std::string provider; std::string target; std::string lang; // for userspace probes, enable language-specific features std::string ns; std::string func; std::string pin; symbols::usdt_probe_entry usdt; // resolved USDT entry int64_t freq = 0; uint64_t len = 0; // for watchpoint probes, the width of watched addr std::string mode; // for watchpoint probes, the watch mode uint64_t address = 0; uint64_t func_offset = 0; uint64_t bpf_prog_id = 0; bool ignore_invalid = false; // Used for attaching probes to statements in userspace programs via DWARF, // specified with source file, line and optionally column. // e.g. uprobe:/dir/foo@main.c:line:[col]. std::string source_file; size_t line_num = 0; size_t col_num = 0; std::string name() const; AttachPoint *create_expansion_copy(ASTContext &ctx, const std::string &match) const; bool check_available(const std::string &identifier) const; }; using AttachPointList = std::vector; class Probe : public Node { public: explicit Probe(ASTContext &ctx, Location &&loc, AttachPointList &&attach_points, BlockExpr *block) : Node(ctx, std::move(loc)), attach_points(std::move(attach_points)), block(block) {}; explicit Probe(ASTContext &ctx, const Location &loc, const Probe &other) : Node(ctx, loc + other.loc), attach_points(clone(ctx, loc, other.attach_points)), block(clone(ctx, loc, other.block)), index_(other.index_) {}; bool operator==(const Probe &other) const { return attach_points == other.attach_points && *block == *other.block; } std::strong_ordering operator<=>(const Probe &other) const { if (auto cmp = attach_points <=> other.attach_points; cmp != 0) return cmp; return *block <=> *other.block; } AttachPointList attach_points; BlockExpr *block = nullptr; // If the probes have multiple attachpoints, then neither attachpoint_name // nor args_typename will return a value; this must be handled by the // caller (although it will typically be a failure). std::optional attachpoint_name() const; std::optional args_typename() const; int index() const; void set_index(int index); bool has_ap_of_probetype(ProbeType probe_type); ProbeType get_probetype(); private: int index_ = 0; }; using ProbeList = std::vector; class SubprogArg : public Node { public: explicit SubprogArg(ASTContext &ctx, Location &&loc, Variable *var, Typeof *typeof) : Node(ctx, std::move(loc)), var(var), typeof(typeof) {}; explicit SubprogArg(ASTContext &ctx, const Location &loc, const SubprogArg &other) : Node(ctx, loc + other.loc), var(clone(ctx, loc, other.var)), typeof(clone(ctx, loc, other.typeof)) {}; bool operator==(const SubprogArg &other) const { return *var == *other.var && ptr_deref_equal(typeof, other.typeof); } std::strong_ordering operator<=>(const SubprogArg &other) const { if (auto cmp = *var <=> *other.var; cmp != 0) return cmp; return ptr_deref_compare(typeof, other.typeof); } Variable *var = nullptr; Typeof *typeof = nullptr; }; using SubprogArgList = std::vector; class Subprog : public Node { public: explicit Subprog(ASTContext &ctx, Location &&loc, std::string name, Typeof *return_type, SubprogArgList &&args, BlockExpr *block) : Node(ctx, std::move(loc)), name(std::move(name)), return_type(return_type), args(std::move(args)), block(block) {}; explicit Subprog(ASTContext &ctx, const Location &loc, const Subprog &other) : Node(ctx, loc + other.loc), name(other.name), return_type(clone(ctx, loc, other.return_type)), args(clone(ctx, loc, other.args)), block(clone(ctx, loc, other.block)) {}; bool operator==(const Subprog &other) const { return name == other.name && ptr_deref_equal(return_type, other.return_type) && args == other.args && *block == *other.block; } std::strong_ordering operator<=>(const Subprog &other) const { if (auto cmp = name <=> other.name; cmp != 0) return cmp; if (auto cmp = ptr_deref_compare(return_type, other.return_type); cmp != 0) return cmp; if (auto cmp = args <=> other.args; cmp != 0) return cmp; return *block <=> *other.block; } const std::string name; Typeof *return_type; SubprogArgList args; BlockExpr *block = nullptr; }; using SubprogList = std::vector; // N.B. These two import nodes are effectively the same // except there are restrictions on the StatementImport // which can exist in probe bodies, macros, and sub-progs. // Having a separate AST node reduces needing stateful logic // in the pass visitors if they were the same. class RootImport : public Node { public: explicit RootImport(ASTContext &ctx, Location &&loc, std::string name) : Node(ctx, std::move(loc)), name(std::move(name)) {}; explicit RootImport(ASTContext &ctx, const Location &loc, const RootImport &other) : Node(ctx, loc + other.loc), name(other.name) {}; bool operator==(const RootImport &other) const { return name == other.name; } std::strong_ordering operator<=>(const RootImport &other) const { return name <=> other.name; } const std::string name; }; class StatementImport : public Node { public: explicit StatementImport(ASTContext &ctx, Location &&loc, std::string name) : Node(ctx, std::move(loc)), name(std::move(name)) {}; explicit StatementImport(ASTContext &ctx, const Location &loc, const StatementImport &other) : Node(ctx, loc + other.loc), name(other.name) {}; bool operator==(const StatementImport &other) const { return name == other.name; } std::strong_ordering operator<=>(const StatementImport &other) const { return name <=> other.name; } const std::string name; }; using RootImportList = std::vector; class Macro : public Node { public: Macro(ASTContext &ctx, Location &&loc, std::string name, ExpressionList &&vargs, BlockExpr *block) : Node(ctx, std::move(loc)), name(std::move(name)), vargs(std::move(vargs)), block(block) {}; explicit Macro(ASTContext &ctx, const Location &loc, const Macro &other) : Node(ctx, loc + other.loc), name(other.name), vargs(clone(ctx, loc, other.vargs)), block(clone(ctx, loc, other.block)), is_stdlib(other.is_stdlib) {}; bool operator==(const Macro &other) const { if (name != other.name || vargs != other.vargs) return false; if (vargs != other.vargs) return false; if (is_stdlib != other.is_stdlib) return false; return *block == *other.block; } std::strong_ordering operator<=>(const Macro &other) const { if (auto cmp = name <=> other.name; cmp != 0) return cmp; if (auto cmp = is_stdlib <=> other.is_stdlib; cmp != 0) return cmp; if (vargs.size() != other.vargs.size()) return vargs.size() <=> other.vargs.size(); for (size_t i = 0; i < vargs.size(); ++i) { if (auto cmp = vargs[i] <=> other.vargs[i]; cmp != 0) return cmp; } return *block <=> *other.block; } std::string name; ExpressionList vargs; BlockExpr *block = nullptr; bool is_stdlib = false; }; using MacroList = std::vector; class CStatement : public Node { public: CStatement(ASTContext &ctx, Location &&loc, std::string data) : Node(ctx, std::move(loc)), data(std::move(data)) {}; explicit CStatement(ASTContext &ctx, const Location &loc, const CStatement &other) : Node(ctx, loc + other.loc), data(other.data) {}; bool operator==(const CStatement &other) const { return data == other.data; } std::strong_ordering operator<=>(const CStatement &other) const { return data <=> other.data; } std::string data; }; using CStatementList = std::vector; class Program : public Node { public: explicit Program(ASTContext &ctx, Location &&loc, CStatementList &&c_statements, Config *config, RootImportList &&imports, RootStatements &&root_statements, std::optional &&header = std::nullopt) : Node(ctx, std::move(loc)), c_statements(std::move(c_statements)), config(config), imports(std::move(imports)), header(std::move(header)) { for (auto &stmt : root_statements) { if (auto *map_decl = stmt.as()) { map_decls.push_back(map_decl); } else if (auto *macro = stmt.as()) { macros.push_back(macro); } else if (auto *function = stmt.as()) { functions.push_back(function); } else if (auto *probe = stmt.as()) { probes.push_back(probe); } } }; explicit Program(ASTContext &ctx, const Location &loc, const Program &other) : Node(ctx, loc + other.loc), c_statements(clone(ctx, loc, other.c_statements)), config(clone(ctx, loc, other.config)), imports(clone(ctx, loc, other.imports)), map_decls(clone(ctx, loc, other.map_decls)), macros(clone(ctx, loc, other.macros)), functions(clone(ctx, loc, other.functions)), probes(clone(ctx, loc, other.probes)), header(other.header) {}; bool operator==(const Program &other) const { return c_statements == other.c_statements && *config == *other.config && imports == other.imports && map_decls == other.map_decls && macros == other.macros && functions == other.functions && probes == other.probes; } std::strong_ordering operator<=>(const Program &other) const { if (auto cmp = c_statements <=> other.c_statements; cmp != 0) return cmp; if (auto cmp = *config <=> *other.config; cmp != 0) return cmp; if (auto cmp = imports <=> other.imports; cmp != 0) return cmp; if (auto cmp = map_decls <=> other.map_decls; cmp != 0) return cmp; if (auto cmp = macros <=> other.macros; cmp != 0) return cmp; if (auto cmp = functions <=> other.functions; cmp != 0) return cmp; return probes <=> other.probes; } CStatementList c_statements; Config *config = nullptr; RootImportList imports; MapDeclList map_decls; MacroList macros; SubprogList functions; ProbeList probes; std::optional header; void clear_empty_probes(); }; std::string opstr(const Binop &binop); std::string opstr(const Unop &unop); std::string opstr(const Jump &jump); bool is_comparison_op(Operator op); Record *make_record(ASTContext &ctx, const Location &loc, std::vector> &&args); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/async_event_types.cpp000066400000000000000000000046561526721631600212370ustar00rootroot00000000000000#include #include #include "ast/async_event_types.h" #include "ast/irbuilderbpf.h" namespace bpftrace::AsyncEvent { std::vector Print::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // asyncid b.getInt32Ty(), // map id b.getInt32Ty(), // top b.getInt32Ty(), // div }; } std::vector PrintNonMap::asLLVMType(ast::IRBuilderBPF& b, size_t size) { return { b.getInt64Ty(), // asyncid b.getInt64Ty(), // print id llvm::ArrayType::get(b.getInt8Ty(), size), // content }; } std::vector MapEvent::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // asyncid b.getInt32Ty(), // map id }; } std::vector Time::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // asyncid b.getInt32Ty(), // time id }; } std::vector Strftime::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt32Ty(), // strftime id b.getInt32Ty(), // timestamp mode b.getInt64Ty(), // strftime arg, nanoseconds }; } std::vector Buf::asLLVMType(ast::IRBuilderBPF& b, uint32_t length) { return { b.getInt32Ty(), // buffer length llvm::ArrayType::get(b.getInt8Ty(), length), // buffer content }; } std::vector RuntimeError::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // asyncid b.getInt64Ty(), // error_id b.getInt32Ty(), // return value }; } std::vector CgroupPath::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // cgroup path (pseudo-event) id b.getInt64Ty(), // cgroup id }; } std::vector SkbOutput::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // asyncid b.getInt64Ty(), // skb_output id b.getInt64Ty(), // time elapsed since boot }; } std::vector Exit::asLLVMType(ast::IRBuilderBPF& b) { return { b.getInt64Ty(), // asyncid b.getInt8Ty(), // exit_code }; } std::vector Join::asLLVMType(ast::IRBuilderBPF& b, uint32_t length) { return { b.getInt64Ty(), // action_id b.getInt64Ty(), // join_id llvm::ArrayType::get(b.getInt8Ty(), length), // join content }; } } // namespace bpftrace::AsyncEvent bpftrace-0.27.1/src/ast/async_event_types.h000066400000000000000000000050201526721631600206660ustar00rootroot00000000000000#pragma once #include #include #include // Forward declare some LLVM types here. We do not #include any LLVM // headers b/c that will pull in LLVM's ABI checking machinery. We want // this header to be independent of LLVM during link time so that AOT // does not need to link against LLVM. namespace llvm { class Type; } // namespace llvm namespace bpftrace::ast { class IRBuilderBPF; } // namespace bpftrace::ast // The main goal here is to keep the struct definitions close to each other, // making it easier to spot type mismatches. // // If you update a type, remember to update the .cpp too! namespace bpftrace::AsyncEvent { struct Print { uint64_t action_id; uint32_t mapid; uint32_t top; uint32_t div; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct PrintNonMap { uint64_t action_id; uint64_t print_id; // See below why we don't use a flexible length array uint8_t content[0]; std::vector asLLVMType(ast::IRBuilderBPF& b, size_t size); } __attribute__((packed)); struct MapEvent { uint64_t action_id; uint32_t mapid; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct Time { uint64_t action_id; uint32_t time_id; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct Strftime { uint32_t strftime_id; uint32_t mode; uint64_t nsecs; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct Buf { uint32_t length; std::vector asLLVMType(ast::IRBuilderBPF& b, uint32_t length); } __attribute__((packed)); struct RuntimeError { uint64_t action_id; uint64_t error_id; int32_t return_value; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct CgroupPath { uint64_t cgroup_path_id; uint64_t cgroup_id; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct SkbOutput { uint64_t action_id; uint64_t skb_output_id; uint64_t nsecs_since_boot; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct Exit { uint64_t action_id; uint8_t exit_code; std::vector asLLVMType(ast::IRBuilderBPF& b); } __attribute__((packed)); struct Join { uint64_t action_id; uint64_t join_id; char content[0]; std::vector asLLVMType(ast::IRBuilderBPF& b, uint32_t length); } __attribute__((packed)); } // namespace bpftrace::AsyncEvent bpftrace-0.27.1/src/ast/async_ids.h000066400000000000000000000034201526721631600171020ustar00rootroot00000000000000#pragma once #include namespace bpftrace::ast { // Add new ids here #define FOR_LIST_OF_ASYNC_IDS(DO) \ DO(call_stack) \ DO(map_key) \ DO(read_map_value) \ DO(runtime_error) \ DO(str) \ DO(anon_struct) \ DO(variable) \ DO(watchpoint) #define DEFINE_MEMBER_VAR(id, ...) int _##id = 0; #define DEFINE_ACCESS_METHOD(id, ...) \ int id() \ { \ return _##id++; \ } #define LOCAL_SAVE(id, ...) local_##id = _##id, #define LOCAL_RESTORE(id, ...) this->_##id = local_##id; class AsyncIds { public: explicit AsyncIds() = default; FOR_LIST_OF_ASYNC_IDS(DEFINE_ACCESS_METHOD) // For 'create_reset_ids' return a lambda that has captured-by-value // CodegenLLVM's async id state. Running the returned lambda will restore // `CodegenLLVM`s async id state back to when this function was first called. std::function create_reset_ids() { return [FOR_LIST_OF_ASYNC_IDS(LOCAL_SAVE) this] { FOR_LIST_OF_ASYNC_IDS(LOCAL_RESTORE) }; } private: FOR_LIST_OF_ASYNC_IDS(DEFINE_MEMBER_VAR) }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/clone.h000066400000000000000000000045021526721631600162300ustar00rootroot00000000000000#pragma once #include #include "ast/ast.h" #include "ast/context.h" namespace bpftrace { class SizedType; namespace ast { class Expression; class Statement; class Iterable; class RootStatement; template struct Cloner; template requires(std::is_same_v) struct Cloner { T operator()([[maybe_unused]] ASTContext &ctx, [[maybe_unused]] const Location &loc, const T &v) { return v; } }; template requires(std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v) struct Cloner { T operator()(ASTContext &ctx, const Location &loc, const T &v) { return std::visit([&](const auto &v) -> T { return clone(ctx, loc, v); }, v.value); } }; template struct Cloner> { std::vector operator()(ASTContext &ctx, const Location &loc, const std::vector &obj) { std::vector ret; for (const auto &v : obj) { ret.emplace_back(clone(ctx, loc, v)); } return ret; } }; template struct Cloner> { std::variant operator()(ASTContext &ctx, const Location &loc, const std::variant &obj) { return std::visit([&](const auto &v) -> std::variant { return clone(ctx, loc, v); }, obj); } }; template struct Cloner> { std::optional operator()(ASTContext &ctx, const Location &loc, const std::optional &obj) { if (!obj.has_value()) { return std::nullopt; } return clone(ctx, std::move(loc), obj.value()); } }; template requires std::derived_from struct Cloner { T *operator()(ASTContext &ctx, const Location &loc, const T *obj) { return ctx.clone_node(loc, obj); } }; template T clone(ASTContext &ctx, const Location &loc, const T &t) { using V = std::remove_const_t>>; return Cloner()(ctx, loc, t); } } // namespace ast } // namespace bpftrace bpftrace-0.27.1/src/ast/codegen_helper.cpp000066400000000000000000000007671526721631600204370ustar00rootroot00000000000000#include "codegen_helper.h" namespace bpftrace::ast { bool needMapAllocation(const SizedType &src, const SizedType &dst) { // For records (and records inside of tuples) the src and dst might have // fields out of order - for this case we need an allocation to copy // individual fields into so the original field ordering is preserved if (src.IsTupleTy() || src.IsRecordTy()) { if (src != dst) { return true; } } return !dst.IsInBpfMemory(); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/codegen_helper.h000066400000000000000000000007451526721631600201000ustar00rootroot00000000000000#pragma once #include "ast/ast.h" #include "types.h" namespace bpftrace::ast { inline bool needMemcpy(const SizedType &stype) { return stype.IsAggregate() || stype.IsTimestampTy() || stype.IsCgroupPathTy(); } inline AddrSpace find_addrspace_stack(const SizedType &ty) { return ty.IsCtxAccess() ? AddrSpace::kernel : ty.GetAS(); } // This applies to both map keys and map values bool needMapAllocation(const SizedType &src, const SizedType &dst); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/context.cpp000066400000000000000000000055421526721631600171540ustar00rootroot00000000000000#include "ast/context.h" #include "ast/ast.h" #include "ast/diagnostic.h" namespace bpftrace::ast { ASTSource::ASTSource(std::string &&filename, std::string &&input) : filename(std::move(filename)), contents(std::move(input)) { std::stringstream ss(contents); std::string line; while (std::getline(ss, line)) { lines_.emplace_back(std::move(line)); } // std::getline doesn't produce an entry for a trailing newline, but // the lexer advances the line counter past it, so the END token (and // thus the Program node) can reference a line beyond lines_.size(). if (!contents.empty() && contents.back() == '\n') { lines_.emplace_back(""); } } std::string ASTSource::read(const SourceLocation &loc) { std::stringstream ss; for (int line = loc.begin.line; line <= loc.end.line; line++) { auto &srcline = lines_[line - 1]; if (line == loc.begin.line && line == loc.end.line) { ss << srcline.substr(loc.begin.column - 1, loc.end.column - loc.begin.column); } else if (line == loc.begin.line) { ss << srcline.substr(loc.begin.column - 1); } else if (line < loc.end.line - 1) { ss << srcline; } else { ss << srcline.substr(0, loc.end.column - 1); } } return ss.str(); } std::vector MetadataIndex::all() { if (map_.empty()) { return {}; } std::vector result; for (const auto &entry : map_) { if (std::holds_alternative(entry.second)) { // Just provide the vspace count. result.emplace_back(std::get(entry.second).amount); } else if (std::holds_alternative( entry.second)) { // Load the comment from the serialized source. result.emplace_back(source_->read(entry.first)); } } return result; } MetadataIndex MetadataIndex::before(const SourceLocation::Position &pos) { MetadataIndex result(source_); auto it = map_.begin(); while (it != map_.end()) { if (it->first.begin.line > pos.line || (it->first.begin.line == pos.line && it->first.begin.column > pos.column)) { break; } result.map_.emplace(it->first, it->second); it = map_.erase(it); } return result; } ASTContext::ASTContext(std::string &&filename, std::string &&contents) : state_(std::make_unique()), source_( std::make_shared(std::move(filename), std::move(contents))) { } ASTContext::ASTContext(const std::string &filename, const std::string &contents) : ASTContext(std::string(filename), std::string(contents)) { } ASTContext::ASTContext() : ASTContext("", "") { } void ASTContext::clear() { root = nullptr; state_->nodes_.clear(); state_->diagnostics_->clear(); } ASTContext::State::State() : diagnostics_(std::make_unique()) { } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/context.h000066400000000000000000000140141526721631600166130ustar00rootroot00000000000000#pragma once #include #include #include #include #include "ast/diagnostic.h" #include "ast/pass_manager.h" namespace bpftrace { class Parser; namespace ast { class SourceLocation; class Node; class Program; template concept NodeType = std::derived_from; // Captures the original filename and source for a given AST. // // This is a heavy object, containing the full contents of the file. Only a // single instance of this class should be created and referenced. class ASTSource { public: ASTSource(std::string &&filename, std::string &&input); ASTSource(const ASTSource &other) = delete; ASTSource &operator=(const ASTSource &other) = delete; const std::string filename; const std::string contents; // Reads the contents of the source corresponding to a specific location. std::string read(const SourceLocation &loc); private: std::vector lines_; friend class SourceLocation; }; // MetadataIndex is an index of comments and spacing. // // It allows for looking up and removing comments associated with specific // source locations. It can efficiently claim all comments up until a given // location. class MetadataIndex { public: MetadataIndex() = default; // Allow, map will be empty. MetadataIndex(std::shared_ptr source) : source_(std::move(source)) {}; // The Variant describes either comments (strings) or vspace (size_t). using Variant = std::variant; // Returns all metadata in this index. std::vector all(); // Finds and removes all metadata that precedes this location, returning // a new index. This new index can be subsequently sliced, or `all` can // be used to retrieve all associated metadata. Note that `all` does not // remove the metadata from the index, this only happens with `before`. MetadataIndex before(const SourceLocation::Position &pos); private: struct CommentSentinel {}; struct VspaceSentinel { size_t amount; }; using InternalMap = std::map>; MetadataIndex(std::shared_ptr source, InternalMap other) : source_(std::move(source)), map_(std::move(other)) {}; std::shared_ptr source_; InternalMap map_; friend class ASTContext; }; // Manages the lifetime of AST nodes. // // Nodes allocated by an ASTContext will be kept alive for the duration of the // owning ASTContext object. The ASTContext also owns the canonical instance of // the ASTSource, which is used by the Diagnostics to contextualize errors. class ASTContext : public ast::State<"ast"> { public: ASTContext(std::string &&filename, std::string &&contents); ASTContext(const std::string &filename, const std::string &contents); ASTContext(); // Creates and returns a pointer to an AST node. template constexpr T *make_node(Location &&loc, Args... args) { auto uniq_ptr = std::make_unique(*this, std::move(loc), std::forward(args)...); auto *raw_ptr = uniq_ptr.get(); state_->nodes_.push_back(std::move(uniq_ptr)); return raw_ptr; } template T *make_node(const SourceLocation &loc, Args &&...args) { return make_node(location(loc), std::forward(args)...); } template T *make_node(const Location &loc, Args... args) { return make_node(Location(loc), std::forward(args)...); } Location location(const SourceLocation &loc) { // Occasionally, the parse default-constructs SourceLocation objects, // which therefore do not reference the original source. We fix up this // case and bind a location to the current source from this context. auto bound_loc = loc; if (bound_loc.source_ == nullptr) { bound_loc.source_ = source_; } return std::make_shared(std::move(bound_loc)); } template T *clone_node(const Location &loc, const T *other) { if (other == nullptr) { return nullptr; } auto uniq_ptr = std::make_unique(*this, loc, *other); auto *raw_ptr = uniq_ptr.get(); state_->nodes_.push_back(std::move(uniq_ptr)); return raw_ptr; } unsigned int node_count() { return state_->nodes_.size(); } Diagnostics &diagnostics() const { return *state_->diagnostics_; } std::shared_ptr source() const { return source_; } void add_comment(SourceLocation loc) { // Comments are simply stored as monostate in the map, they are // resolved only when the comment is used. state_->metadata_.emplace(std::move(loc), MetadataIndex::CommentSentinel{}); } void add_vspace(SourceLocation loc, size_t elems) { // Vspace is stored as a simple unsigned value. state_->metadata_.emplace(std::move(loc), MetadataIndex::VspaceSentinel{ .amount = elems }); } // This function returns a unique a metadata object for the AST. // // This object consumed by this call is a copy, and can be used // to iterate over all the available metadata while printing. MetadataIndex metadata() const { return { source_, state_->metadata_ }; } // clears all the nodes and diagnostics, but does not affect the underlying // `ASTSource` object. This is useful if you want to e.g. reparse the full // syntax tree in place. void clear(); // Root points to a node in `state_.nodes_`. Program *root = nullptr; private: // State owns the underlying nodes; they are permitted to take a reference to // this object since their lifetimes are bound. class State { public: State(); std::vector> nodes_; std::unique_ptr diagnostics_; MetadataIndex::InternalMap metadata_; }; std::unique_ptr state_; std::shared_ptr source_; friend class bpftrace::Parser; friend class Node; }; } // namespace ast } // namespace bpftrace bpftrace-0.27.1/src/ast/diagnostic.cpp000066400000000000000000000051221526721631600176060ustar00rootroot00000000000000#include #include #include "diagnostic.h" #include "log.h" namespace bpftrace::ast { std::stringstream& Diagnostic::addContext(Location loc) { loc_->contexts.emplace_back(std::make_shared(loc->current)); return loc_->contexts.back().msg; } void Diagnostics::emit(std::ostream& out) const { // Emit all errors first, following by all warnings. emit(out, Severity::Error); emit(out, Severity::Warning); } void Diagnostics::emit(std::ostream& out, Severity s) const { if (s == Severity::Warning && !Log::get().is_enabled(LogType::WARNING)) return; foreach(s, [this, s, &out](const Diagnostic& d) { emit(out, s, d); }); } void Diagnostics::emit(std::ostream& out, Severity s, const Diagnostic& d) const { // Build our sets of messages. std::vector> msgs; std::vector> parent_msgs; auto loc = d.loc(); if (loc) { msgs.emplace_back(d.msg(), loc->current); for (const auto& context : loc->contexts) { msgs.emplace_back(context.msg.str(), context.loc->current); } while (loc) { auto& parent = loc->parent; if (parent) { parent_msgs.emplace_back(parent->msg.str(), parent->loc->current); loc = parent->loc; } else { break; } } } switch (s) { case Severity::Warning: if (msgs.empty()) { LOG(WARNING, out) << d.msg(); } for (const auto& [msg, loc] : msgs) { LOG(WARNING, loc.source_location(), loc.source_context(), out) << msg; } for (const auto& msg : d.hints()) { LOG(HINT, out) << msg; } for (const auto& [msg, loc] : parent_msgs) { LOG(WARNING, loc.source_location(), loc.source_context(), out) << msg; } break; case Severity::Error: if (msgs.empty()) { LOG(ERROR, out) << d.msg(); } for (const auto& [msg, loc] : msgs) { LOG(ERROR, loc.source_location(), loc.source_context(), out) << msg; } for (const auto& msg : d.hints()) { LOG(HINT, out) << msg; } for (const auto& [msg, loc] : parent_msgs) { LOG(ERROR, loc.source_location(), loc.source_context(), out) << msg; } break; } } void Diagnostics::add(Diagnostics&& other) { if (diagnostics_.size() < other.diagnostics_.size()) { diagnostics_.resize(other.diagnostics_.size()); } for (size_t i = 0; i < other.diagnostics_.size(); i++) { for (auto& d : other.diagnostics_[i]) { diagnostics_[i].emplace_back(std::move(d)); } } } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/diagnostic.h000066400000000000000000000102141526721631600172510ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include "ast/location.h" namespace bpftrace::ast { class ASTSource; // Diagnostic reflects a single error at a single source location. This is a // simple wrapper around a string for that message, and the location class. class Diagnostic { public: enum class Severity { Warning, Error, }; Diagnostic(const Location loc) : loc_(loc) {}; std::string msg() const { return msg_.str(); } std::vector hints() const { std::vector msgs; for (const auto& hint : hints_) { msgs.emplace_back(hint.str()); } return msgs; } const Location& loc() const { return loc_; } // Each diagnostic can potentially have hints attached, which is how to // effectively resolve this issue. std::stringstream& addHint() { return hints_.emplace_back(); } // Add additional context for the error. std::stringstream& addContext(Location loc); template Diagnostic& operator<<(const T& t) { msg_ << t; return *this; } private: std::stringstream msg_; std::vector hints_; Location loc_; }; class Diagnostics { public: using Severity = Diagnostic::Severity; // Note that the state of the diagnostics is really only a vector, which // provides well-defined `move` semantics. After the move, the vector is // guaranteed to be empty, which matches the state required for an empty // Diagnostics object. Diagnostics() = default; Diagnostics(Diagnostics&& other) = default; Diagnostics(const Diagnostics& other) = delete; Diagnostics& operator=(const Diagnostics& other) = delete; Diagnostics& operator=(Diagnostics&& other) = delete; template Diagnostic& add(Severity severity, Args... args) { auto index = static_cast(severity); if (diagnostics_.size() <= index) { diagnostics_.resize(index + 1); } auto& diags = diagnostics_[index]; auto& p = diags.emplace_back(std::make_unique(args...)); return *p.get(); } template Diagnostic& addError(Args... args) { return add(Severity::Error, args...); } template Diagnostic& addWarning(Args... args) { return add(Severity::Warning, args...); } bool has(Severity severity) const { auto index = static_cast(severity); return diagnostics_.size() > index && !diagnostics_[index].empty(); } void clear() { for (auto& diag : diagnostics_) { diag.clear(); } } // ok is the recommended short-hand for `has(Severity::Error)`. bool ok() const { return !has(Severity::Error); } size_t error_count() const { auto index = static_cast(Severity::Error); if (diagnostics_.size() <= index) return 0; return diagnostics_[index].size(); } // emit implements a default formatter of all diagnostics to a given stream. // The use of `emit` should be generally discouraged, especially by tests, // who should use more structured checks and avoid matching against the // specific format here. void emit(std::ostream& out) const; void emit(std::ostream& out, Severity s) const; void emit(std::ostream& out, Severity s, const Diagnostic& d) const; // adds all diagnostics from some other set. void add(Diagnostics&& other); private: void foreach(Severity severity, std::function fn) const { auto index = static_cast(severity); if (diagnostics_.size() <= index) { return; } for (const auto& diag : diagnostics_[index]) { fn(*diag); } } // Two-dimensional vector with all diagnostics. The first level is indexed by // severity, and the second level is the set of diagnostics for that level. // // N.B. we store diagnostics as a pointer because the lifetime is returned // early above, so they must not be moving at any point. std::vector>> diagnostics_; friend class Node; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/dibuilderbpf.cpp000066400000000000000000000421321526721631600201170ustar00rootroot00000000000000#include #include #include #include "dibuilderbpf.h" #include "log.h" #include "struct.h" #include "types.h" #include "util/bpf_names.h" namespace bpftrace::ast { DIBuilderBPF::DIBuilderBPF(Module &module) : DIBuilder(module) { file = createFile("bpftrace.bpf.o", "."); } DILocalScope *DIBuilderBPF::createFunctionDebugInfo(llvm::Function &func, const SizedType &ret_type, const Struct &args, bool is_declaration) { // Return type should be at index 0 SmallVector types; types.reserve(args.fields.size() + 1); types.push_back(GetType(ret_type)); for (const auto &arg : args.fields) types.push_back(GetType(arg.type)); DISubroutineType *ditype = createSubroutineType(getOrCreateTypeArray(types)); std::string sanitised_name = util::sanitise_bpf_program_name( func.getName().str()); DISubprogram::DISPFlags flags = DISubprogram::SPFlagZero; if (!is_declaration) flags |= DISubprogram::SPFlagDefinition; if (llvm::Function::isLocalLinkage(func.getLinkage())) flags |= DISubprogram::DISPFlags::SPFlagLocalToUnit; DISubprogram *subprog = createFunction(file, sanitised_name, sanitised_name, file, 0, ditype, 0, DINode::FlagPrototyped, flags); for (size_t i = 0; i < args.fields.size(); i++) { createParameterVariable(subprog, args.fields.at(i).name, i + 1, file, 0, static_cast(types[i + 1]), true); } func.setSubprogram(subprog); return subprog; } DILocalScope *DIBuilderBPF::createProbeDebugInfo(llvm::Function &probe_func) { // BPF probe function has: // - int return type // - single parameter (ctx) of a pointer type Struct args; args.AddField("ctx", CreatePointer(CreateInt8())); return createFunctionDebugInfo(probe_func, CreateInt64(), args); } DIType *DIBuilderBPF::getInt8Ty() { if (!types_.int8) types_.int8 = createBasicType("int8", 8, dwarf::DW_ATE_signed); return types_.int8; } DIType *DIBuilderBPF::getInt16Ty() { if (!types_.int16) types_.int16 = createBasicType("int16", 16, dwarf::DW_ATE_signed); return types_.int16; } DIType *DIBuilderBPF::getInt32Ty() { if (!types_.int32) types_.int32 = createBasicType("int32", 32, dwarf::DW_ATE_signed); return types_.int32; } DIType *DIBuilderBPF::getInt64Ty() { if (!types_.int64) types_.int64 = createBasicType("int64", 64, dwarf::DW_ATE_signed); return types_.int64; } DIType *DIBuilderBPF::getIntTy() { if (!types_.int_) types_.int_ = createBasicType("int", 32, dwarf::DW_ATE_signed); return types_.int_; } DIType *DIBuilderBPF::getInt8PtrTy() { if (!types_.int8_ptr) types_.int8_ptr = createPointerType(getInt8Ty(), 64); return types_.int8_ptr; } // Create anonymous struct with anonymous fields. It's possible that there will // be multiple tuples of the same (duplicated) type but BTF deduplication should // take care of that. DIType *DIBuilderBPF::CreateTupleType(const SizedType &stype) { assert(stype.IsTupleTy()); SmallVector fields; for (auto &field : stype.GetFields()) { fields.push_back(createMemberType(file, "", file, 0, field.type.GetSize() * 8, 0, field.offset * 8, DINode::FlagZero, GetType(field.type))); } DICompositeType *result = createStructType(file, "", file, 0, stype.GetSize() * 8, 0, DINode::FlagZero, nullptr, getOrCreateArray(fields)); return result; } // Create anonymous struct with named fields. It's possible that there will // be multiple records of the same (duplicated) type but BTF deduplication // should take care of that. DIType *DIBuilderBPF::CreateRecordType(const SizedType &stype) { assert(stype.IsRecordTy()); SmallVector fields; for (auto &field : stype.GetFields()) { fields.push_back(createMemberType(file, field.name, file, 0, field.type.GetSize() * 8, 0, field.offset * 8, DINode::FlagZero, GetType(field.type))); } DICompositeType *result = createStructType(file, "", file, 0, stype.GetSize() * 8, 0, DINode::FlagZero, nullptr, getOrCreateArray(fields)); return result; } DIType *DIBuilderBPF::CreateMapStructType(const SizedType &stype) { assert(stype.IsMinTy() || stype.IsMaxTy() || stype.IsAvgTy() || stype.IsStatsTy()); // For Min/Max, the first field is the value and the second field is the // "value is set" flag. For Avg/Stats, the first field is the total and the // second field is the count. SmallVector fields = { createMemberType(file, "", file, 0, stype.GetSize() * 8, 0, 0, DINode::FlagZero, getInt64Ty()), createMemberType(file, "", file, 0, stype.GetSize() * 8, 0, stype.GetSize() * 8, DINode::FlagZero, getInt32Ty()) }; DICompositeType *result = createStructType(file, "", file, 0, (stype.GetSize() * 8) * 2, 0, DINode::FlagZero, nullptr, getOrCreateArray(fields)); return result; } DIType *DIBuilderBPF::CreateTSeriesStructType(const SizedType &stype) { assert(stype.IsTSeriesTy()); // The first field is the value, the second field is metadata associated with // the value, and the third field is the epoch, a number representing the // bucket's time interval. The interpretation of the value and metadata fields // depends on the time series's aggregation function: // // +-----+-------+----------+----------------------------------------------+ // | agg | value | metadata | explanation | // +-----+-------+----------+----------------------------------------------+ // | avg | total | count | avg = total / count | // | max | max | is_set | is_set = "value is set" | // | min | min | is_set | is_set = "value is set" | // | sum | sum | - | metadata not used | // | - | value | now | now is the timestamp when value was recorded | // +-----+-------+----------+----------------------------------------------+ SmallVector fields = { createMemberType(file, "", file, 0, stype.GetSize() * 8, 0, 0, DINode::FlagZero, getInt64Ty()), createMemberType(file, "", file, 0, stype.GetSize() * 8, 0, stype.GetSize() * 8, DINode::FlagZero, getInt64Ty()), createMemberType(file, "", file, 0, stype.GetSize() * 8, 0, stype.GetSize() * 16, DINode::FlagZero, getInt64Ty()) }; DICompositeType *result = createStructType(file, "", file, 0, (stype.GetSize() * 8) * 3, 0, DINode::FlagZero, nullptr, getOrCreateArray(fields)); return result; } DIType *DIBuilderBPF::CreateByteArrayType(uint64_t num_bytes) { auto *subrange = getOrCreateSubrange(0, num_bytes); return createArrayType( num_bytes * 8, 0, getInt8Ty(), getOrCreateArray({ subrange })); } /// Convert internal SizedType to a corresponding DIType type. /// /// In codegen, some types are not converted into a directly corresponding /// LLVM type but instead into a type which is easy to work with in BPF /// programs (see IRBuilderBPF::GetType for details). /// /// As opposed to IRBuilderBPF::GetType we need to emit proper struct type /// info for the c_type SizedType whose BTF must exactly match the kernel /// BTF (e.g. kernel functions ("kfunc") prototypes). For debug info the name /// and size need to at least be correct but the fields are not necessary. DIType *DIBuilderBPF::GetType(const SizedType &stype) { if (stype.IsCTypeTy()) { return createStructType(file, std::string(stype.GetBaseName()), file, 0, stype.GetSize() * 8, 0, DINode::FlagZero, nullptr, getOrCreateArray({})); } if (stype.IsByteArray() || stype.IsStack()) { auto *subrange = getOrCreateSubrange(0, stype.GetSize()); return createArrayType( stype.GetSize() * 8, 0, getInt8Ty(), getOrCreateArray({ subrange })); } if (stype.IsArrayTy()) { auto *subrange = getOrCreateSubrange(0, stype.GetNumElements()); return createArrayType(stype.GetSize() * 8, 0, GetType(stype.GetElementTy()), getOrCreateArray({ subrange })); } if (stype.IsTupleTy()) return CreateTupleType(stype); if (stype.IsRecordTy()) return CreateRecordType(stype); if (stype.IsMinTy() || stype.IsMaxTy() || stype.IsAvgTy() || stype.IsStatsTy()) return CreateMapStructType(stype); else if (stype.IsTSeriesTy()) return CreateTSeriesStructType(stype); if (stype.IsPtrTy()) { // We shouldn't need to handle bare void types as they can't be assigned to // variables or be used as map keys/values if (stype.GetPointeeTy().IsVoidTy()) { return createPointerType(nullptr, 64); } return createPointerType(GetType(stype.GetPointeeTy()), 64); } // Integer types and builtin types represented by integers switch (stype.GetSize()) { case 8: return getInt64Ty(); case 4: return getInt32Ty(); case 2: return getInt16Ty(); case 1: return getInt8Ty(); default: LOG(BUG) << "Cannot generate debug info for type " << typestr(stype.GetTy()) << " (" << stype.GetSize() << " is not a valid type size)"; return nullptr; } } DIType *DIBuilderBPF::GetMapKeyType(const SizedType &key_type, const SizedType &value_type, bpf_map_type map_type) { if (map_type == BPF_MAP_TYPE_RINGBUF) { assert(key_type.IsNoneTy()); return getInt64Ty(); } // Some map types need an extra 8-byte key. if (value_type.IsHistTy() || value_type.IsLhistTy() || value_type.IsTSeriesTy()) { uint64_t size = key_type.GetSize() + 8; return CreateByteArrayType(size); } return GetType(key_type); } DIType *DIBuilderBPF::GetMapFieldInt(int value) { // Integer fields of map entry are represented by 64-bit pointers to an array // of int, in which dimensionality of the array encodes the specified value. auto *subrange = getOrCreateSubrange(0, value); auto *array = createArrayType( 32 * value, 0, getIntTy(), getOrCreateArray({ subrange })); return createPointerType(array, 64); } DIType *DIBuilderBPF::createPointerMemberType(const std::string &name, uint64_t offset, DIType *type) { return createMemberType( file, name, file, 0, 64, 0, offset, DINode::FlagZero, type); } DIGlobalVariableExpression *DIBuilderBPF::createMapEntry( const std::string &name, bpf_map_type map_type, uint64_t max_entries, DIType *key_type, const SizedType &value_type) { SmallVector fields = { createPointerMemberType("type", 0, GetMapFieldInt(map_type)), createPointerMemberType("max_entries", 64, GetMapFieldInt(max_entries)), }; uint64_t size = 128; if (!value_type.IsNoneTy()) { fields.push_back( createPointerMemberType("key", size, createPointerType(key_type, 64))); fields.push_back(createPointerMemberType( "value", size + 64, createPointerType(GetType(value_type), 64))); size += 128; } DIType *map_entry_type = createStructType(file, "", file, 0, size, 0, DINode::FlagZero, nullptr, getOrCreateArray(fields)); return createGlobalVariableExpression( file, name, "global", file, 0, map_entry_type, false); } DIGlobalVariableExpression *DIBuilderBPF::createGlobalVariable( std::string_view name, const SizedType &stype) { return createGlobalVariableExpression( file, name, "global", file, 0, GetType(stype), false); } DILocation *DIBuilderBPF::createDebugLocation(llvm::LLVMContext &ctx, DILocalScope *scope, const ast::Location &loc) { return llvm::DILocation::get(ctx, loc->line(), loc->column(), scope); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/dibuilderbpf.h000066400000000000000000000050531526721631600175650ustar00rootroot00000000000000#pragma once #include #include #include #include "ast/location.h" #include "types.h" namespace bpftrace::ast { using namespace llvm; class DIBuilderBPF : public DIBuilder { public: DIBuilderBPF(Module &module); DILocalScope *createFunctionDebugInfo(llvm::Function &func, const SizedType &ret_type, const Struct &args, bool is_declaration = false); DILocalScope *createProbeDebugInfo(llvm::Function &probe_func); DIType *getInt8Ty(); DIType *getInt16Ty(); DIType *getInt32Ty(); DIType *getInt64Ty(); DIType *getInt8PtrTy(); // We need a separate type called "int" to mimic libbpf's behaviour of // generating debuginfo for some BPF map fields. For details, see comment in // DIBuilderBPF::GetMapFieldInt. DIType *getIntTy(); DIType *GetType(const SizedType &stype); DIType *CreateTupleType(const SizedType &stype); DIType *CreateRecordType(const SizedType &stype); DIType *CreateMapStructType(const SizedType &stype); DIType *CreateTSeriesStructType(const SizedType &stype); DIType *CreateByteArrayType(uint64_t num_bytes); DIType *createPointerMemberType(const std::string &name, uint64_t offset, DIType *type); DIType *GetMapKeyType(const SizedType &key_type, const SizedType &value_type, bpf_map_type map_type); DIType *GetMapFieldInt(int value); DIGlobalVariableExpression *createMapEntry(const std::string &name, bpf_map_type map_type, uint64_t max_entries, DIType *key_type, const SizedType &value_type); DIGlobalVariableExpression *createGlobalVariable(std::string_view name, const SizedType &stype); DILocation *createDebugLocation(llvm::LLVMContext &ctx, DILocalScope *scope, const ast::Location &loc); DIFile *file = nullptr; private: struct { DIType *int8 = nullptr; DIType *int16 = nullptr; DIType *int32 = nullptr; DIType *int64 = nullptr; DIType *int128 = nullptr; DIType *int8_ptr = nullptr; DIType *int_ = nullptr; } types_; std::unordered_map structs_; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/helpers.cpp000066400000000000000000000016331526721631600171270ustar00rootroot00000000000000#include #include "ast/helpers.h" #include "log.h" #include "types.h" namespace bpftrace { // N.B. there are other unsafe builtins but they are being checked // inside the macros themselves static std::unordered_set UNSAFE_BUILTIN_FUNCS = { "system", }; static std::unordered_set COMPILE_TIME_FUNCS = { "cgroupid" }; static std::unordered_set UPROBE_LANGS = { "cpp" }; bool is_unsafe_func(const std::string &func_name) { return UNSAFE_BUILTIN_FUNCS.contains(func_name); } bool is_compile_time_func(const std::string &func_name) { return COMPILE_TIME_FUNCS.contains(func_name); } bool is_supported_lang(const std::string &lang) { return UPROBE_LANGS.contains(lang); } bool is_type_name(std::string_view str) { return str.starts_with(STRUCT_PREFIX) || str.starts_with(UNION_PREFIX) || str.starts_with(ENUM_PREFIX); } } // namespace bpftrace bpftrace-0.27.1/src/ast/helpers.h000066400000000000000000000004261526721631600165730ustar00rootroot00000000000000#pragma once #include namespace bpftrace { bool is_unsafe_func(const std::string &func_name); bool is_compile_time_func(const std::string &func_name); bool is_supported_lang(const std::string &lang); bool is_type_name(std::string_view str); } // namespace bpftrace bpftrace-0.27.1/src/ast/integer_types.cpp000066400000000000000000000035401526721631600203450ustar00rootroot00000000000000#include #include #include #include "integer_types.h" namespace bpftrace::ast { SizedType get_integer_type(uint64_t n) { // Make the smallest possible signed sizedType based on n // or an unsigned SizedType if it exceeds the largest int64 SizedType ty; if (n <= std::numeric_limits::max()) { ty = CreateInt8(); } else if (n <= std::numeric_limits::max()) { ty = CreateInt16(); } else if (n <= std::numeric_limits::max()) { ty = CreateInt32(); } else if (n <= std::numeric_limits::max()) { ty = CreateInt64(); } else { return CreateUInt64(); } // Non-negative literals that fit in a signed type can be treated as // either signed or unsigned. Values exceeding INT64_MAX require // unsigned representation and are not flexible. ty.SetSignFlexible(true); return ty; } std::optional get_signed_integer_type(uint64_t n) { if (n <= std::numeric_limits::max()) { return CreateInt8(); } else if (n <= std::numeric_limits::max()) { return CreateInt16(); } else if (n <= std::numeric_limits::max()) { return CreateInt32(); } else if (n <= std::numeric_limits::max()) { return CreateInt64(); } else { return std::nullopt; } } SizedType get_signed_integer_type(int64_t n) { // Make the smallest possible sizedType based on n if (std::numeric_limits::min() <= n && n <= std::numeric_limits::max()) { return CreateInt8(); } else if (std::numeric_limits::min() <= n && n <= std::numeric_limits::max()) { return CreateInt16(); } else if (std::numeric_limits::min() <= n && n <= std::numeric_limits::max()) { return CreateInt32(); } else { return CreateInt64(); } } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/integer_types.h000066400000000000000000000004041526721631600200060ustar00rootroot00000000000000#pragma once #include #include "types.h" namespace bpftrace::ast { SizedType get_integer_type(uint64_t n); std::optional get_signed_integer_type(uint64_t n); SizedType get_signed_integer_type(int64_t n); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/irbuilderbpf.cpp000066400000000000000000002762001526721631600201420ustar00rootroot00000000000000#include #include #include #include "arch/arch.h" #include "ast/async_event_types.h" #include "ast/codegen_helper.h" #include "ast/irbuilderbpf.h" #include "async_action.h" #include "bpfmap.h" #include "bpftrace.h" #include "globalvars.h" #include "log.h" #include "types.h" #include "util/exceptions.h" namespace bpftrace::ast { namespace { std::string_view probeReadHelperName(bpf_func_id id) { switch (id) { case BPF_FUNC_probe_read: return "probe_read"; case BPF_FUNC_probe_read_user: return "probe_read_user"; case BPF_FUNC_probe_read_kernel: return "probe_read_kernel"; case BPF_FUNC_probe_read_str: return "probe_read_str"; case BPF_FUNC_probe_read_user_str: return "probe_read_user_str"; case BPF_FUNC_probe_read_kernel_str: return "probe_read_kernel_str"; default: LOG(BUG) << "unknown probe_read id: " << std::to_string(id); } __builtin_unreachable(); } } // namespace bpf_func_id IRBuilderBPF::selectProbeReadHelper(AddrSpace as, bool str) { bpf_func_id fn; if (as == AddrSpace::kernel) { fn = str ? BPF_FUNC_probe_read_kernel_str : BPF_FUNC_probe_read_kernel; } else if (as == AddrSpace::user) { fn = str ? BPF_FUNC_probe_read_user_str : BPF_FUNC_probe_read_user; } else { // if the kernel has the new helpers but AS is still none it is a bug // in bpftrace, assert catches it for debug builds. // assert(as != AddrSpace::none); static bool warnonce = false; if (!warnonce) { warnonce = true; LOG(WARNING) << "Addrspace is not set"; } fn = str ? BPF_FUNC_probe_read_str : BPF_FUNC_probe_read; } return fn; } // This constant is defined in the Linux kernel's proc_ns.h // It represents the inode of the initial (global) PID namespace constexpr uint32_t PROC_PID_INIT_INO = 0xeffffffc; Value *IRBuilderBPF::CreateGetPid(const Location &loc, bool force_init) { const auto &pidns = bpftrace_.get_pidns_self_stat(); if (!force_init && pidns && pidns->st_ino != PROC_PID_INIT_INO) { // Get namespaced target PID when we're running in a namespace AllocaInst *res = CreateAllocaBPF(BpfPidnsInfoType(), "bpf_pidns_info"); CreateGetNsPidTgid( getInt64(pidns->st_dev), getInt64(pidns->st_ino), res, loc); Value *pid = CreateLoad( getInt32Ty(), CreateGEP(BpfPidnsInfoType(), res, { getInt32(0), getInt32(1) })); CreateLifetimeEnd(res); return pid; } // Get global target PID otherwise Value *pidtgid = CreateGetPidTgid(loc); Value *pid = CreateTrunc(CreateLShr(pidtgid, 32), getInt32Ty(), "pid"); return pid; } Value *IRBuilderBPF::CreateGetTid(const Location &loc, bool force_init) { const auto &pidns = bpftrace_.get_pidns_self_stat(); if (!force_init && pidns && pidns->st_ino != PROC_PID_INIT_INO) { // Get namespaced target TID when we're running in a namespace AllocaInst *res = CreateAllocaBPF(BpfPidnsInfoType(), "bpf_pidns_info"); CreateGetNsPidTgid( getInt64(pidns->st_dev), getInt64(pidns->st_ino), res, loc); Value *tid = CreateLoad( getInt32Ty(), CreateGEP(BpfPidnsInfoType(), res, { getInt32(0), getInt32(0) })); CreateLifetimeEnd(res); return tid; } // Get global target TID otherwise Value *pidtgid = CreateGetPidTgid(loc); Value *tid = CreateTrunc(pidtgid, getInt32Ty(), "tid"); return tid; } AllocaInst *IRBuilderBPF::CreateUSym(Value *val, int probe_id, const Location &loc) { std::vector elements = { getInt64Ty(), // addr getInt32Ty(), // pid getInt32Ty(), // probe id }; StructType *usym_t = GetStructType("usym_t", elements, false); AllocaInst *buf = CreateAllocaBPF(usym_t, "usym"); Value *pid = CreateGetPid(loc, false); Value *probe_id_val = Constant::getIntegerValue(getInt32Ty(), APInt(32, probe_id)); // The extra 0 here ensures the type of addr_offset will be int64 Value *addr_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(0) }); Value *pid_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(1) }); Value *probeid_offset = CreateGEP(usym_t, buf, { getInt64(0), getInt32(2) }); CreateStore(val, addr_offset); CreateStore(pid, pid_offset); CreateStore(probe_id_val, probeid_offset); return buf; } StructType *IRBuilderBPF::GetStackStructType(const StackType &stack_type) { std::vector elements; // Kernel stacks should not be differentiated by pid, since the kernel // address space is the same between pids (and when aggregating you *want* // to be able to correlate between pids in most cases). User-space stacks // are special because of ASLR, hence we also store the pid; probe id is // stored for cases when only ELF resolution works (e.g. ASLR disabled and // process exited). if (!stack_type.kernel) { elements.emplace_back(getInt32Ty()); // pid elements.emplace_back(getInt32Ty()); // probe id } // If the offset changes, make sure to also change the codegen for "stack_len" elements.emplace_back(getInt64Ty()); // nr_stack_frames if (stack_type.mode == StackMode::build_id) { // struct bpf_stack_build_id { // __s32 status; // unsigned char build_id[BPF_BUILD_ID_SIZE]; // union { // __u64 offset; // __u64 ip; // }; // }; std::vector union_elem = { getInt64Ty(), }; StructType *union_type = GetStructType("offset_ip_union", union_elem, false); std::vector build_id_elements = { getInt32Ty(), // status ArrayType::get(getInt8Ty(), BPF_BUILD_ID_SIZE), // build_id[BPF_BUILD_ID_SIZE] union_type, }; StructType *stack_build_id = GetStructType("stack_build_id", build_id_elements, false); elements.emplace_back(ArrayType::get(stack_build_id, stack_type.limit)); } else { elements.emplace_back(ArrayType::get(getInt64Ty(), stack_type.limit)); } return GetStructType(stack_type.name(), elements, false); } StructType *IRBuilderBPF::GetStructType( const std::string &name, const std::vector &elements, bool packed) { auto search = structs_.find(name); if (search != structs_.end()) return search->second; StructType *s = nullptr; if (!elements.empty()) { s = StructType::create(module_.getContext(), elements, name, packed); } else { s = StructType::create(module_.getContext(), name); } structs_.insert({ name, s }); return s; } IRBuilderBPF::IRBuilderBPF(LLVMContext &context, Module &module, BPFtrace &bpftrace, AsyncIds &async_ids) : IRBuilder<>(context), module_(module), bpftrace_(bpftrace), async_ids_(async_ids) { // Declare external LLVM function FunctionType *pseudo_func_type = FunctionType::get( getInt64Ty(), { getInt64Ty(), getInt64Ty() }, false); llvm::Function::Create(pseudo_func_type, GlobalValue::ExternalLinkage, "llvm.bpf.pseudo", &module_); } void IRBuilderBPF::SetInsertPoint(BasicBlock *bb) { IRBuilder<>::SetInsertPoint(bb); SetCurrentDebugLocation(llvm::DebugLoc()); } void IRBuilderBPF::SetInsertPoint(Instruction *inst) { IRBuilder<>::SetInsertPoint(inst); SetCurrentDebugLocation(llvm::DebugLoc()); } void IRBuilderBPF::SetInsertPoint(BasicBlock *bb, BasicBlock::iterator ip) { IRBuilder<>::SetInsertPoint(bb, ip); SetCurrentDebugLocation(llvm::DebugLoc()); } void IRBuilderBPF::SetInsertPoint(BasicBlock::iterator ip) { IRBuilder<>::SetInsertPoint(ip); SetCurrentDebugLocation(llvm::DebugLoc()); } void IRBuilderBPF::restoreIP(InsertPoint ip) { IRBuilder<>::restoreIP(ip); SetCurrentDebugLocation(llvm::DebugLoc()); } void IRBuilderBPF::hoist(const std::function &functor) { llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock &entry_block = parent->getEntryBlock(); auto ip = saveIP(); SetInsertPoint(&entry_block, entry_block.begin()); functor(); restoreIP(ip); } void IRBuilderBPF::CreateLifetimeEnd(Value *val) { if (isa(val)) IRBuilder::CreateLifetimeEnd(val); } AllocaInst *IRBuilderBPF::CreateAllocaBPF(llvm::Type *ty, const std::string &name) { // Anything this large should be allocated in a scratch map instead assert(module_.getDataLayout().getTypeAllocSize(ty) <= 256); AllocaInst *alloca; hoist([this, ty, &name, &alloca]() { alloca = CreateAlloca(ty, nullptr, name); }); CreateLifetimeStart(alloca); return alloca; } AllocaInst *IRBuilderBPF::CreateAllocaBPF(const SizedType &stype, const std::string &name) { llvm::Type *ty = GetType(stype); return CreateAllocaBPF(ty, name); } void IRBuilderBPF::CreateAllocationInit(const SizedType &stype, Value *alloc) { if (needMemcpy(stype)) { CreateMemsetBPF(alloc, getInt8(0), stype.GetSize()); } else { CreateStore(Constant::getNullValue(GetType(stype)), alloc); } } AllocaInst *IRBuilderBPF::CreateAllocaBPFInit(const SizedType &stype, const std::string &name) { // Anything this large should be allocated in a scratch map instead assert(stype.GetSize() <= 256); AllocaInst *alloca; hoist([this, &stype, &name, &alloca]() { llvm::Type *ty = GetType(stype); alloca = CreateAlloca(ty, nullptr, name); CreateLifetimeStart(alloca); CreateAllocationInit(stype, alloca); }); return alloca; } AllocaInst *IRBuilderBPF::CreateAllocaBPF(int bytes, const std::string &name) { llvm::Type *ty = ArrayType::get(getInt8Ty(), bytes); return CreateAllocaBPF(ty, name); } void IRBuilderBPF::CreateMemsetBPF(Value *ptr, Value *val, uint32_t size) { if (size > 512) { // Note we are "abusing" bpf_probe_read_kernel() by reading from NULL // which triggers a call into the kernel-optimized memset(). // // Upstream blesses this trick so we should be able to count on them // to maintain these semantics. // // Also note we are avoiding a call to CreateProbeRead(), as it wraps // calls to probe read helpers with the -k error reporting feature. // The call here will always fail and we want it that way. So avoid // reporting errors to the user. auto probe_read_id = BPF_FUNC_probe_read_kernel; FunctionType *proberead_func_type = FunctionType::get( getInt64Ty(), { ptr->getType(), getInt32Ty(), GetNull()->getType() }, false); PointerType *proberead_func_ptr_type = PointerType::get(getContext(), 0); Constant *proberead_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64(probe_read_id), proberead_func_ptr_type); createCall(proberead_func_type, proberead_func, { ptr, getInt32(size), GetNull() }, probeReadHelperName(probe_read_id)); } else { // Use unrolled memset for memsets less than 512 bytes mostly for // correctness. // // It appears that helper based memsets obscure LLVM stack optimizer view // into memory usage such that programs that were below stack limit with // builtin memsets will bloat with helper based memsets enough to where // LLVM BPF backend will barf. // // So only use helper based memset when we really need it. And that's when // we're memset()ing off-stack. We know it's off stack b/c 512 is program // stack limit. // // Above 128 bytes use the inline intrinsic, which is never lowered to a // libcall; BPF backends cap how many stores a plain memset may expand to // (192 in LLVM 23) and an unaligned memset needs one store per byte. Small // memsets keep the plain intrinsic so dead store elimination still works // at least according to AI (take with a grain of salt). if (size > 128) { CreateMemSetInline(ptr, MaybeAlign(1), val, getInt64(size)); } else { CreateMemSet(ptr, val, getInt64(size), MaybeAlign(1)); } } } void IRBuilderBPF::CreateMemcpyBPF(Value *dst, Value *src, uint32_t size) { if (size > 512) { // Note we are avoiding a call to CreateProbeRead(), as it wraps // calls to probe read helpers with the -k error reporting feature. // // Errors are not ever expected, as memcpy should only be used when // you're sure src and dst are both in BPF memory. auto probe_read_id = BPF_FUNC_probe_read_kernel; FunctionType *probe_read_func_type = FunctionType::get( getInt64Ty(), { dst->getType(), getInt32Ty(), src->getType() }, false); PointerType *probe_read_func_ptr_type = PointerType::get(getContext(), 0); Constant *probe_read_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64(probe_read_id), probe_read_func_ptr_type); createCall(probe_read_func_type, probe_read_func, { dst, getInt32(size), src }, probeReadHelperName(probe_read_id)); } else { CreateMemCpyInline(dst, MaybeAlign(1), src, MaybeAlign(1), getInt64(size)); } } llvm::ConstantInt *IRBuilderBPF::GetIntSameSize(uint64_t C, llvm::Type *ty) { assert(ty->isIntegerTy()); unsigned size = ty->getIntegerBitWidth(); return getIntN(size, C); } llvm::ConstantInt *IRBuilderBPF::GetIntSameSize(uint64_t C, llvm::Value *expr) { unsigned size = expr->getType()->getIntegerBitWidth(); return getIntN(size, C); } /// Convert internal SizedType to a corresponding LLVM type. /// /// Only one type is not converted directly into an LLVM type: /// - C types (c_type) are represented as byte arrays llvm::Type *IRBuilderBPF::GetType(const SizedType &stype) { llvm::Type *ty; if (stype.IsByteArray() || stype.IsCTypeTy()) { ty = ArrayType::get(getInt8Ty(), stype.GetSize()); } else if (stype.IsArrayTy()) { ty = ArrayType::get(GetType(stype.GetElementTy()), stype.GetNumElements()); } else if (stype.IsTupleTy() || stype.IsRecordTy()) { std::vector llvm_elems; std::string ty_name; for (const auto &elem : stype.GetFields()) { const auto &elemtype = elem.type; llvm::Type *elem_ty = GetType(elemtype); auto align = static_cast(elemtype.GetInTupleAlignment()); if (module_.getDataLayout().getABITypeAlign(elem_ty).value() < align) { elem_ty = StructType::get( getContext(), { ArrayType::get(getIntNTy(align * 8), 0), elem_ty }); } llvm_elems.emplace_back(elem_ty); ty_name += typestr(elemtype) + "_"; } ty_name += (stype.IsTupleTy() ? "_tuple_t" : "_record_t"); ty = GetStructType(ty_name, llvm_elems, false); } else if (stype.IsStack()) { ty = GetStackStructType(stype.stack_type); } else if (stype.IsPtrTy()) { ty = getPtrTy(); } else if (stype.IsVoidTy()) { // Use i8 instead of void because void is unsized in LLVM and cannot be // used in GEPs. This matches C's treatment of void* arithmetic as char*. ty = getInt8Ty(); } else if (stype.IsBoolTy()) { ty = getInt1Ty(); } else { switch (stype.GetSize()) { case 16: ty = getInt128Ty(); break; case 8: ty = getInt64Ty(); break; case 4: ty = getInt32Ty(); break; case 2: ty = getInt16Ty(); break; case 1: ty = getInt8Ty(); break; default: LOG(BUG) << stype.GetSize() << " is not a valid type size for GetType"; } } return ty; } llvm::Type *IRBuilderBPF::GetMapValueType(const SizedType &stype) { llvm::Type *ty; if (stype.IsMinTy() || stype.IsMaxTy()) { // The first field is the value // The second field is the "value is set" flag std::vector llvm_elems = { getInt64Ty(), getInt64Ty() }; ty = GetStructType("min_max_val", llvm_elems, false); } else if (stype.IsAvgTy() || stype.IsStatsTy()) { // The first field is the total value // The second is the count value std::vector llvm_elems = { getInt64Ty(), getInt64Ty() }; ty = GetStructType("avg_stas_val", llvm_elems, false); } else if (stype.IsTSeriesTy()) { std::vector llvm_elems = { getInt64Ty(), getInt64Ty(), getInt64Ty() }; ty = GetStructType("t_series_val", llvm_elems, false); } else { ty = GetType(stype); } return ty; } /// Creates a call to a BPF helper function /// /// A call to a helper function can be marked as "pure" to allow LLVM to /// optimise around it. /// /// ** BE VERY CAREFUL when marking a helper function as pure - marking an /// impure helper as pure can result in undefined behaviour. ** /// /// Guidelines for deciding if a helper can be considered pure: /// - It must always return the same value when called repeatedly with the same /// arguments within a single probe's context /// - It must not read or write any memory in the BPF address space (e.g. it /// mustn't take any pointers to BPF memory as parameters) /// - It must not have any intentional side effects outside of the BPF address /// space, otherwise these may be optimised out, e.g. pushing to the ring /// buffer, signalling a process CallInst *IRBuilderBPF::CreateHelperCall(bpf_func_id func_id, FunctionType *helper_type, ArrayRef args, bool is_pure, const Twine &Name, const Location &loc) { bpftrace_.helper_use_loc_[func_id].emplace_back(RuntimeErrorId::HELPER_ERROR, func_id, loc); PointerType *helper_ptr_type = PointerType::get(getContext(), 0); Constant *helper_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64(func_id), helper_ptr_type); CallInst *call = createCall(helper_type, helper_func, args, Name); // When we tell LLVM that this function call "does not access memory", this // only refers to BPF memory. Accessing kernel or user memory is fine within // a "pure helper", as we can consider kernel/user memory as constant. if (is_pure) call->setDoesNotAccessMemory(); return call; } CallInst *IRBuilderBPF::createCall(FunctionType *callee_type, Value *callee, ArrayRef args, const Twine &Name) { return CreateCall(callee_type, callee, args, Name); } Value *IRBuilderBPF::GetMapVar(const std::string &map_name) { return module_.getGlobalVariable(bpf_map_name(map_name)); } Value *IRBuilderBPF::GetNull() { return ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()); } CallInst *IRBuilderBPF::CreateMapLookup(Map &map, Value *key, const std::string &name) { return createMapLookup(map.ident, key, name); } CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name, Value *key, const std::string &name) { Value *map_ptr = GetMapVar(map_name); // void *map_lookup_elem(struct bpf_map * map, void * key) // Return: Map value or NULL assert(key->getType()->isPointerTy()); FunctionType *lookup_func_type = FunctionType::get( getPtrTy(), { map_ptr->getType(), key->getType() }, false); PointerType *lookup_func_ptr_type = PointerType::get(getContext(), 0); Constant *lookup_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64( BPF_FUNC_map_lookup_elem), lookup_func_ptr_type); return createCall(lookup_func_type, lookup_func, { map_ptr, key }, name); } CallInst *IRBuilderBPF::createPerCpuMapLookup(const std::string &map_name, Value *key, Value *cpu, const std::string &name) { Value *map_ptr = GetMapVar(map_name); // void *map_lookup_percpu_elem(struct bpf_map * map, void * key, u32 cpu) // Return: Map value or NULL assert(key->getType()->isPointerTy()); FunctionType *lookup_func_type = FunctionType::get( getPtrTy(), { map_ptr->getType(), key->getType(), getInt32Ty() }, false); PointerType *lookup_func_ptr_type = PointerType::get(getContext(), 0); Constant *lookup_func = ConstantExpr::getCast( Instruction::IntToPtr, getInt64(BPF_FUNC_map_lookup_percpu_elem), lookup_func_ptr_type); return createCall(lookup_func_type, lookup_func, { map_ptr, key, cpu }, name); } Value *IRBuilderBPF::CreateGetStrAllocation(const std::string &name, const Location &loc) { const auto max_strlen = bpftrace_.config_->pad_max_strlen(); const auto str_type = CreateArray(max_strlen, CreateInt8()); return createAllocation(bpftrace::globalvars::GET_STR_BUFFER, GetType(str_type), name, loc, [](AsyncIds &async_ids) { return async_ids.str(); }); } Value *IRBuilderBPF::CreateGetFmtStringArgsAllocation(StructType *struct_type, const std::string &name, const Location &loc) { return createAllocation( bpftrace::globalvars::FMT_STRINGS_BUFFER, struct_type, name, loc); } Value *IRBuilderBPF::CreateAnonStructAllocation(const SizedType &tuple_type, const std::string &name, const Location &loc) { return createAllocation(bpftrace::globalvars::ANON_STRUCT_BUFFER, GetType(tuple_type), name, loc, [](AsyncIds &async_ids) { return async_ids.anon_struct(); }); } Value *IRBuilderBPF::CreateCallStackAllocation(const SizedType &stack_type, const std::string &name, const Location &loc) { return createAllocation(bpftrace::globalvars::CALL_STACK_BUFFER, GetType(stack_type), name, loc, [](AsyncIds &async_ids) { return async_ids.call_stack(); }); } Value *IRBuilderBPF::CreateJoinAllocation(const Location &loc) { return createScratchBuffer(bpftrace::globalvars::JOIN_BUFFER, loc, 0); } Value *IRBuilderBPF::CreateReadMapValueAllocation(const SizedType &value_type, const std::string &name, const Location &loc) { return createAllocation(bpftrace::globalvars::READ_MAP_VALUE_BUFFER, GetType(value_type), name, loc, [](AsyncIds &async_ids) { return async_ids.read_map_value(); }); } Value *IRBuilderBPF::CreateWriteMapValueAllocation(const SizedType &value_type, const std::string &name, const Location &loc) { return createAllocation(bpftrace::globalvars::WRITE_MAP_VALUE_BUFFER, GetType(value_type), name, loc); } Value *IRBuilderBPF::CreateVariableAllocationInit(const SizedType &value_type, const std::string &name, const Location &loc) { // Hoist variable declaration and initialization to entry point of // probe/subprogram. While we technically do not need this as variables // are properly scoped, it eases debugging and is consistent with previous // stack-only variable implementation. Value *alloc; hoist([this, &value_type, &name, &loc, &alloc] { alloc = createAllocation(bpftrace::globalvars::VARIABLE_BUFFER, GetType(value_type), name, loc, [](AsyncIds &async_ids) { return async_ids.variable(); }); CreateAllocationInit(value_type, alloc); }); return alloc; } Value *IRBuilderBPF::CreateMapKeyAllocation(const SizedType &value_type, const std::string &name, const Location &loc) { return createAllocation(bpftrace::globalvars::MAP_KEY_BUFFER, GetType(value_type), name, loc, [](AsyncIds &async_ids) { return async_ids.map_key(); }); } Value *IRBuilderBPF::createAllocation( std::string_view global_var_name, llvm::Type *obj_type, const std::string &name, const Location &loc, std::optional> gen_async_id_cb) { const auto obj_size = module_.getDataLayout().getTypeAllocSize(obj_type); const auto on_stack_limit = bpftrace_.config_->on_stack_limit; if (obj_size > on_stack_limit) { return createScratchBuffer(global_var_name, loc, gen_async_id_cb ? (*gen_async_id_cb)(async_ids_) : 0); } return CreateAllocaBPF(obj_type, name); } Value *IRBuilderBPF::createScratchBuffer(std::string_view global_var_name, const Location &loc, size_t key) { // These specific global variables are nested arrays // (see get_sized_type in globalvars.cpp). // The top level array is for each CPU where the length is // MAX_CPU_ID + 1. This is so there is no contention between CPUs // when accessing this global value. // The second level array is for each key where the length is // the number of elements for this specific global, e.g. if // there are multiple strings that can't fit on the BPF stack // then there will be one element per string. // The last level is either an array of bytes (e.g. for strings) // or a single value (e.g. for ints like the EVENT_LOSS_COUNTER) const auto global_name = std::string(global_var_name); bpftrace_.resources.global_vars.check_index(global_name, bpftrace_.resources, key); auto sized_type = bpftrace_.resources.global_vars.get_sized_type( global_name, bpftrace_.resources, *bpftrace_.config_); auto *cpu_id = CreateGetCpuId(loc); auto *max = CreateLoad(getInt64Ty(), module_.getGlobalVariable( std::string(bpftrace::globalvars::MAX_CPU_ID))); // Mask CPU ID by MAX_CPU_ID to ensure BPF verifier knows CPU ID is bounded // on older kernels. Note this means MAX_CPU_ID must be 2^N - 1 for some N. // See get_max_cpu_id() for more details. auto *bounded_cpu_id = CreateAnd(cpu_id, max, "cpu.id.bounded"); // Note the 1st index is 0 because we're pointing to // ValueType var[MAX_CPU_ID + 1][num_elements] // More details on using GEP: https://llvm.org/docs/LangRef.html#id236 if (sized_type.GetElementTy().GetElementTy().IsArrayTy()) { return CreateGEP( GetType(sized_type), module_.getGlobalVariable(global_name), { getInt64(0), bounded_cpu_id, getInt64(key), getInt64(0) }); } return CreateGEP(GetType(sized_type), module_.getGlobalVariable(global_name), { getInt64(0), bounded_cpu_id, getInt64(key) }); } Value *IRBuilderBPF::CreateMapLookupElem(const std::string &map_name, Value *key, const SizedType &type, const Location &loc) { CallInst *call = createMapLookup(map_name, key); // Check if result == 0 llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_.getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_.getContext(), "lookup_failure", parent); BasicBlock *lookup_merge_block = BasicBlock::Create(module_.getContext(), "lookup_merge", parent); Value *value = CreateReadMapValueAllocation(type, "lookup_elem_val", loc); Value *condition = CreateICmpNE(CreateIntCast(call, getPtrTy(), true), GetNull(), "map_lookup_cond"); CreateCondBr(condition, lookup_success_block, lookup_failure_block); SetInsertPoint(lookup_success_block); if (needMemcpy(type)) { CreateMemcpyBPF(value, call, type.GetSize()); } else { CreateStore(CreateLoad(GetType(type), call), value); } CreateBr(lookup_merge_block); SetInsertPoint(lookup_failure_block); if (needMemcpy(type)) CreateMemsetBPF(value, getInt8(0), type.GetSize()); else CreateStore(Constant::getNullValue(GetType(type)), value); CreateRuntimeError( RuntimeErrorId::HELPER_ERROR, getInt32(0), BPF_FUNC_map_lookup_elem, loc); CreateBr(lookup_merge_block); SetInsertPoint(lookup_merge_block); if (needMemcpy(type)) return value; // value is a pointer to i64 Value *ret = CreateLoad(GetType(type), value); if (dyn_cast(value)) CreateLifetimeEnd(value); return ret; } Value *IRBuilderBPF::CreatePerCpuMapAggElems(Map &map, Value *key, const SizedType &type, const Location &loc) { // int ret = 0; // int i = 0; // while (i < nr_cpus) { // int * cpu_value = map_lookup_percpu_elem(map, key, i); // if (cpu_value == NULL) { // if (i == 0) // log_error("Key not found") // else // debug("No cpu found for cpu id: %lu", i) // Mostly for AOT // break; // } // // update ret for sum, count, avg, min, max // i++; // } // return ret; const std::string &map_name = map.ident; AllocaInst *i = CreateAllocaBPF(getInt64Ty(), "i"); AllocaInst *val_1 = CreateAllocaBPF(getInt64Ty(), "val_1"); // used for min/max/avg AllocaInst *val_2 = CreateAllocaBPF(getInt64Ty(), "val_2"); CreateStore(getInt64(0), i); CreateStore(getInt64(0), val_1); CreateStore(getInt64(0), val_2); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *while_cond = BasicBlock::Create(module_.getContext(), "while_cond", parent); BasicBlock *while_body = BasicBlock::Create(module_.getContext(), "while_body", parent); BasicBlock *while_end = BasicBlock::Create(module_.getContext(), "while_end", parent); CreateBr(while_cond); SetInsertPoint(while_cond); auto *cond = CreateICmp(CmpInst::ICMP_ULT, CreateLoad(getInt64Ty(), i), CreateLoad(getInt64Ty(), module_.getGlobalVariable(std::string( bpftrace::globalvars::NUM_CPUS))), "num_cpu.cmp"); CreateCondBr(cond, while_body, while_end); SetInsertPoint(while_body); CallInst *call = createPerCpuMapLookup( map_name, key, CreateTrunc(CreateLoad(getInt64Ty(), i), getInt32Ty())); llvm::Function *lookup_parent = GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_.getContext(), "lookup_success", lookup_parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_.getContext(), "lookup_failure", lookup_parent); Value *condition = CreateICmpNE(CreateIntCast(call, getPtrTy(), true), GetNull(), "map_lookup_cond"); CreateCondBr(condition, lookup_success_block, lookup_failure_block); SetInsertPoint(lookup_success_block); if (type.IsMinTy() || type.IsMaxTy()) { createPerCpuMinMax(val_1, val_2, call, type); } else if (type.IsAvgTy()) { createPerCpuAvg(val_1, val_2, call, type); } else if (type.IsSumTy() || type.IsCountTy()) { createPerCpuSum(val_1, call, type); } else { LOG(BUG) << "Unsupported map aggregation type: " << type; } // ++i; CreateStore(CreateAdd(CreateLoad(getInt64Ty(), i), getInt64(1)), i); CreateBr(while_cond); SetInsertPoint(lookup_failure_block); llvm::Function *error_parent = GetInsertBlock()->getParent(); BasicBlock *error_success_block = BasicBlock::Create(module_.getContext(), "error_success", error_parent); BasicBlock *error_failure_block = BasicBlock::Create(module_.getContext(), "error_failure", error_parent); // If the CPU is 0 and the map lookup fails it means the key doesn't exist. Value *error_condition = CreateICmpEQ(CreateLoad(getInt64Ty(), i), getInt64(0), "error_lookup_cond"); CreateCondBr(error_condition, error_success_block, error_failure_block); SetInsertPoint(error_success_block); CreateRuntimeError(RuntimeErrorId::HELPER_ERROR, getInt32(0), BPF_FUNC_map_lookup_percpu_elem, loc); CreateBr(while_end); SetInsertPoint(error_failure_block); CreateRuntimeError(RuntimeErrorId::CPU_COUNT_MISMATCH, loc); CreateBr(while_end); SetInsertPoint(while_end); CreateLifetimeEnd(i); Value *ret_reg; if (type.IsAvgTy()) { AllocaInst *ret = CreateAllocaBPF(getInt64Ty(), "ret"); // BPF doesn't yet support a signed division so we have to check if // the value is negative, flip it, do an unsigned division, and then // flip it back if (type.IsSigned()) { llvm::Function *avg_parent = GetInsertBlock()->getParent(); BasicBlock *is_negative_block = BasicBlock::Create(module_.getContext(), "is_negative", avg_parent); BasicBlock *is_positive_block = BasicBlock::Create(module_.getContext(), "is_positive", avg_parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "is_negative_merge_block", avg_parent); Value *is_negative_condition = CreateICmpSLT( CreateLoad(getInt64Ty(), val_1), getInt64(0), "is_negative_cond"); CreateCondBr(is_negative_condition, is_negative_block, is_positive_block); SetInsertPoint(is_negative_block); Value *pos_total = CreateAdd(CreateNot(CreateLoad(getInt64Ty(), val_1)), getInt64(1)); Value *pos_avg = CreateUDiv(pos_total, CreateLoad(getInt64Ty(), val_2)); CreateStore(CreateNeg(pos_avg), ret); CreateBr(merge_block); SetInsertPoint(is_positive_block); CreateStore(CreateUDiv(CreateLoad(getInt64Ty(), val_1), CreateLoad(getInt64Ty(), val_2)), ret); CreateBr(merge_block); SetInsertPoint(merge_block); ret_reg = CreateLoad(getInt64Ty(), ret); CreateLifetimeEnd(ret); } else { ret_reg = CreateUDiv(CreateLoad(getInt64Ty(), val_1), CreateLoad(getInt64Ty(), val_2)); } } else { ret_reg = CreateLoad(getInt64Ty(), val_1); } CreateLifetimeEnd(val_1); CreateLifetimeEnd(val_2); return ret_reg; } void IRBuilderBPF::createPerCpuSum(AllocaInst *ret, CallInst *call, const SizedType &type) { CreateStore(CreateAdd(CreateLoad(GetType(type), call), CreateLoad(getInt64Ty(), ret)), ret); } void IRBuilderBPF::createPerCpuMinMax(AllocaInst *ret, AllocaInst *is_ret_set, CallInst *call, const SizedType &type) { auto *value_type = GetMapValueType(type); bool is_max = type.IsMaxTy(); Value *mm_val = CreateLoad( getInt64Ty(), CreateGEP(value_type, call, { getInt64(0), getInt32(0) })); Value *is_val_set = CreateLoad( getInt64Ty(), CreateGEP(value_type, call, { getInt64(0), getInt32(1) })); // (ret, is_ret_set, min_max_val, is_val_set) { // // if the min_max_val is 0, which is the initial map value, // // we need to know if it was explicitly set by user // if (!is_val_set == 1) { // return; // } // if (!is_ret_set == 1) { // ret = min_max_val; // is_ret_set = 1; // } else if (min_max_val > ret) { // or min_max_val < ret if min operation // ret = min_max_val; // is_ret_set = 1; // } llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *val_set_success = BasicBlock::Create(module_.getContext(), "val_set_success", parent); BasicBlock *min_max_success = BasicBlock::Create(module_.getContext(), "min_max_success", parent); BasicBlock *ret_set_success = BasicBlock::Create(module_.getContext(), "ret_set_success", parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "min_max_merge", parent); Value *val_set_condition = CreateICmpEQ(is_val_set, getInt64(1), "val_set_cond"); Value *ret_set_condition = CreateICmpEQ(CreateLoad(getInt64Ty(), is_ret_set), getInt64(1), "ret_set_cond"); Value *min_max_condition; if (is_max) { min_max_condition = type.IsSigned() ? CreateICmpSGT(mm_val, CreateLoad(getInt64Ty(), ret), "max_cond") : CreateICmpUGT(mm_val, CreateLoad(getInt64Ty(), ret), "max_cond"); } else { min_max_condition = type.IsSigned() ? CreateICmpSLT(mm_val, CreateLoad(getInt64Ty(), ret), "min_cond") : CreateICmpULT(mm_val, CreateLoad(getInt64Ty(), ret), "max_cond"); } // if (is_val_set == 1) CreateCondBr(val_set_condition, val_set_success, merge_block); SetInsertPoint(val_set_success); // if (is_ret_set == 1) CreateCondBr(ret_set_condition, ret_set_success, min_max_success); SetInsertPoint(ret_set_success); // if (min_max_val > ret) or if (min_max_val < ret) CreateCondBr(min_max_condition, min_max_success, merge_block); SetInsertPoint(min_max_success); // ret = cpu_value; CreateStore(mm_val, ret); // is_ret_set = 1; CreateStore(getInt64(1), is_ret_set); CreateBr(merge_block); SetInsertPoint(merge_block); } void IRBuilderBPF::createPerCpuAvg(AllocaInst *total, AllocaInst *count, CallInst *call, const SizedType &type) { auto *value_type = GetMapValueType(type); Value *total_val = CreateLoad( getInt64Ty(), CreateGEP(value_type, call, { getInt64(0), getInt32(0) })); Value *count_val = CreateLoad( getInt64Ty(), CreateGEP(value_type, call, { getInt64(0), getInt32(1) })); CreateStore(CreateAdd(total_val, CreateLoad(getInt64Ty(), total)), total); CreateStore(CreateAdd(count_val, CreateLoad(getInt64Ty(), count)), count); } void IRBuilderBPF::CreateMapUpdateElem(const std::string &map_ident, Value *key, Value *val, const Location &loc, int64_t flags) { Value *map_ptr = GetMapVar(map_ident); assert(key->getType()->isPointerTy()); assert(val->getType()->isPointerTy()); Value *flags_val = getInt64(flags); // long map_update_elem(struct bpf_map * map, void *key, void * value, u64 // flags) Return: 0 on success or negative error FunctionType *update_func_type = FunctionType::get( getInt64Ty(), { map_ptr->getType(), key->getType(), val->getType(), getInt64Ty() }, false); PointerType *update_func_ptr_type = PointerType::get(getContext(), 0); Constant *update_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64( BPF_FUNC_map_update_elem), update_func_ptr_type); CallInst *call = createCall(update_func_type, update_func, { map_ptr, key, val, flags_val }, "update_elem"); CreateHelperErrorCond(call, BPF_FUNC_map_update_elem, loc); } Value *IRBuilderBPF::CreateForRange(Value *iters, Value *callback, Value *callback_ctx, const Location &loc) { // long bpf_loop(__u32 nr_loops, void *callback_fn, void *callback_ctx, u64 // flags) // // Return: 0 on success or negative error // // callback is long (*callback_fn)(u64 index, void *ctx); iters = CreateIntCast(iters, getInt32Ty(), true); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *is_positive_block = BasicBlock::Create(module_.getContext(), "is_positive", parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "merge", parent); Value *is_positive = CreateICmpSGT(iters, getInt32(0), "is_positive_cond"); CreateCondBr(is_positive, is_positive_block, merge_block); SetInsertPoint(is_positive_block); FunctionType *bpf_loop_type = FunctionType::get( getInt64Ty(), { getInt32Ty(), callback->getType(), getPtrTy(), getInt64Ty() }, false); PointerType *bpf_loop_ptr_type = PointerType::get(getContext(), 0); Constant *bpf_loop_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64(BPF_FUNC_loop), bpf_loop_ptr_type); CallInst *call = createCall( bpf_loop_type, bpf_loop_func, { iters, callback, callback_ctx ? CreateIntToPtr(callback_ctx, getPtrTy()) : GetNull(), /*flags=*/getInt64(0) }, "bpf_loop"); CreateHelperErrorCond(call, BPF_FUNC_loop, loc); CreateBr(merge_block); SetInsertPoint(merge_block); return call; } Value *IRBuilderBPF::CreateForEachMapElem(Map &map, Value *callback, Value *callback_ctx, const Location &loc) { Value *map_ptr = GetMapVar(map.ident); // long bpf_for_each_map_elem(struct bpf_map *map, void *callback_fn, void // *callback_ctx, u64 flags) // // Return: 0 on success or negative error // // callback is long (*callback_fn)(struct bpf_map *map, const void *key, void // *value, void *ctx); FunctionType *for_each_map_type = FunctionType::get( getInt64Ty(), { map_ptr->getType(), callback->getType(), getPtrTy(), getInt64Ty() }, false); PointerType *for_each_map_ptr_type = PointerType::get(getContext(), 0); Constant *for_each_map_func = ConstantExpr::getCast( Instruction::IntToPtr, getInt64(BPF_FUNC_for_each_map_elem), for_each_map_ptr_type); CallInst *call = createCall( for_each_map_type, for_each_map_func, { map_ptr, callback, callback_ctx ? CreateIntToPtr(callback_ctx, getPtrTy()) : GetNull(), /*flags=*/getInt64(0) }, "for_each_map_elem"); CreateHelperErrorCond(call, BPF_FUNC_for_each_map_elem, loc); return call; } void IRBuilderBPF::CreateCheckSetRecursion(const Location &loc, int early_exit_ret) { const std::string map_ident = to_string(MapType::RecursionPrevention); AllocaInst *key = CreateAllocaBPF(getInt32Ty(), "lookup_key"); CreateStore(getInt32(0), key); CallInst *call = createMapLookup(map_ident, key); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_.getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_.getContext(), "lookup_failure", parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "lookup_merge", parent); // Make the verifier happy with a null check even though the value should // never be null for key 0. Value *condition = CreateICmpNE( CreateIntCast(call, getPtrTy(), true), ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()), "map_lookup_cond"); CreateCondBr(condition, lookup_success_block, lookup_failure_block); SetInsertPoint(lookup_success_block); CreateLifetimeEnd(key); // createMapLookup returns an u8* auto *cast = CreatePtrToInt(call, getInt64Ty(), "cast"); Value *prev_value = CREATE_ATOMIC_RMW(AtomicRMWInst::BinOp::Xchg, cast, getInt64(1), 8, AtomicOrdering::SequentiallyConsistent); llvm::Function *set_parent = GetInsertBlock()->getParent(); BasicBlock *value_is_set_block = BasicBlock::Create(module_.getContext(), "value_is_set", set_parent); Value *set_condition = CreateICmpEQ(prev_value, getInt64(0), "value_set_condition"); CreateCondBr(set_condition, merge_block, value_is_set_block); SetInsertPoint(value_is_set_block); // The counter is set, we need to exit early from the probe. // Most of the time this will happen for the functions that can lead // to a crash e.g. "queued_spin_lock_slowpath" but it can also happen // for nested probes e.g. "page_fault_user" -> "print". CreateIncEventLossCounter(loc); CreateRet(getInt64(early_exit_ret)); SetInsertPoint(lookup_failure_block); CreateRuntimeError(RuntimeErrorId::CPU_COUNT_MISMATCH, loc); CreateRet(getInt64(0)); SetInsertPoint(merge_block); } void IRBuilderBPF::CreateUnSetRecursion(const Location &loc) { const std::string map_ident = to_string(MapType::RecursionPrevention); AllocaInst *key = CreateAllocaBPF(getInt32Ty(), "lookup_key"); CreateStore(getInt32(0), key); CallInst *call = createMapLookup(map_ident, key); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_.getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_.getContext(), "lookup_failure", parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "lookup_merge", parent); // Make the verifier happy with a null check even though the value should // never be null for key 0. Value *condition = CreateICmpNE( CreateIntCast(call, getPtrTy(), true), ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()), "map_lookup_cond"); CreateCondBr(condition, lookup_success_block, lookup_failure_block); SetInsertPoint(lookup_success_block); CreateLifetimeEnd(key); // createMapLookup returns an u8* auto *cast = CreatePtrToInt(call, getInt64Ty(), "cast"); CreateStore(getInt64(0), cast); CreateBr(merge_block); SetInsertPoint(lookup_failure_block); CreateRuntimeError(RuntimeErrorId::CPU_COUNT_MISMATCH, loc); CreateBr(merge_block); SetInsertPoint(merge_block); } void IRBuilderBPF::CreateProbeRead(Value *dst, llvm::Value *size, Value *src, AddrSpace as, const Location &loc) { assert(size && size->getType()->getIntegerBitWidth() <= 32); size = CreateIntCast(size, getInt32Ty(), false); // int bpf_probe_read(void *dst, int size, void *src) // Return: 0 on success or negative error auto read_fn = selectProbeReadHelper(as, false); FunctionType *proberead_func_type = FunctionType::get( getInt64Ty(), { dst->getType(), getInt32Ty(), src->getType() }, false); PointerType *proberead_func_ptr_type = PointerType::get(getContext(), 0); Constant *proberead_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64(read_fn), proberead_func_ptr_type); CallInst *call = createCall(proberead_func_type, proberead_func, { dst, size, src }, probeReadHelperName(read_fn)); CreateHelperErrorCond(call, read_fn, loc); } CallInst *IRBuilderBPF::CreateProbeReadStr(Value *dst, size_t size, Value *src, AddrSpace as, const Location &loc) { return CreateProbeReadStr(dst, getInt32(size), src, as, loc); } CallInst *IRBuilderBPF::CreateProbeReadStr(Value *dst, llvm::Value *size, Value *src, AddrSpace as, const Location &loc) { assert(size && size->getType()->isIntegerTy()); if ([[maybe_unused]] auto *dst_alloca = dyn_cast(dst)) { assert(dst_alloca->getAllocatedType()->isArrayTy() && dst_alloca->getAllocatedType()->getArrayElementType() == getInt8Ty()); } auto *size_i32 = size; if (size_i32->getType()->getScalarSizeInBits() != 32) size_i32 = CreateIntCast(size_i32, getInt32Ty(), false); auto read_fn = selectProbeReadHelper(as, true); // int bpf_probe_read_str(void *dst, int size, const void *unsafe_ptr) FunctionType *probereadstr_func_type = FunctionType::get( getInt64Ty(), { dst->getType(), getInt32Ty(), src->getType() }, false); PointerType *probereadstr_func_ptr_type = PointerType::get(getContext(), 0); Constant *probereadstr_callee = ConstantExpr::getCast( Instruction::IntToPtr, getInt64(read_fn), probereadstr_func_ptr_type); CallInst *call = createCall(probereadstr_func_type, probereadstr_callee, { dst, size_i32, src }, probeReadHelperName(read_fn)); CreateHelperErrorCond(call, read_fn, loc); return call; } Value *IRBuilderBPF::CreateStrncmp(Value *str1, Value *str2, uint64_t n, bool inverse) { // This function compares each character of the two strings. It returns 0 // if all are equal and 1 if any are different. // // strcmp(String val1, String val2) // { // for (size_t i = 0; i < n; i++) // { // // if (val1[i] != val2[i]) // { // return 1; // } // if (val1[i] == NULL) // { // break; // } // } // // return 0; // } llvm::Function *parent = GetInsertBlock()->getParent(); AllocaInst *store = CreateAllocaBPF(getInt64Ty(), "strcmp.result"); BasicBlock *str_ne = BasicBlock::Create(module_.getContext(), "strcmp.false", parent); BasicBlock *done = BasicBlock::Create(module_.getContext(), "strcmp.done", parent); CreateStore(getInt64(inverse ? 0 : 1), store); Value *null_byte = getInt8(0); for (size_t i = 0; i < n; i++) { BasicBlock *char_eq = BasicBlock::Create(module_.getContext(), "strcmp.loop", parent); BasicBlock *loop_null_check = BasicBlock::Create(module_.getContext(), "strcmp.loop_null_cmp", parent); Value *l; auto *ptr_l = CreateGEP(getInt8Ty(), str1, { getInt32(i) }); l = CreateLoad(getInt8Ty(), ptr_l); Value *r; auto *ptr_r = CreateGEP(getInt8Ty(), str2, { getInt32(i) }); r = CreateLoad(getInt8Ty(), ptr_r); Value *cmp = CreateICmpNE(l, r, "strcmp.cmp"); CreateCondBr(cmp, str_ne, loop_null_check); SetInsertPoint(loop_null_check); Value *cmp_null = CreateICmpEQ(l, null_byte, "strcmp.cmp_null"); CreateCondBr(cmp_null, done, char_eq); SetInsertPoint(char_eq); } CreateBr(done); SetInsertPoint(done); CreateStore(getInt64(inverse ? 1 : 0), store); CreateBr(str_ne); SetInsertPoint(str_ne); Value *result = CreateLoad(getInt64Ty(), store); CreateLifetimeEnd(store); return result; } Value *IRBuilderBPF::CreateGetNs(TimestampMode ts, const Location &loc) { // If the BPFTRACE_DUMMY_TS_MAP environment variable is set, generate code // that simply reads an unsigned integer from a map instead of generating a // call to a BPF time helper. Currently, this is only used by tseries runtime // tests. Example: // // my_script.bt: // // BEGIN { // @ts = nsecs; // } // // interval:1:ms { // @ = tseries(5, "1ms", 5); // @ts += 1000000; // +1ms // @ = tseries(5, "1ms", 5); // @ts += 1000000; // +1ms // @ = tseries(5, "1ms", 5); // } // // $ BPFTRACE_DUMMY_TS_MAP=@ts bpftrace my_script.bt const char *dummy_ts_map_env = std::getenv("BPFTRACE_DUMMY_TS_MAP"); if (dummy_ts_map_env) { std::string dummy_ts_map = dummy_ts_map_env; auto map_info = bpftrace_.resources.maps_info.find(dummy_ts_map); if (map_info == bpftrace_.resources.maps_info.end()) { LOG(BUG) << "dummy_ts_map: \"" << dummy_ts_map << "\" not found"; } else if (!map_info->second.is_scalar) { LOG(BUG) << "dummy_ts_map: \"" << dummy_ts_map << "\" must be scalar"; } else if (!map_info->second.value_type.IsIntegerTy() || map_info->second.value_type.IsSigned()) { LOG(BUG) << "dummy_ts_map: \"" << dummy_ts_map << "\" value must must be an unsigned integer"; } else { AllocaInst *key = CreateAllocaBPF(getInt64Ty(), "dummy_ts_map_key"); CreateStore(getInt64(0), key); Value *val = CreateMapLookupElem( dummy_ts_map, key, map_info->second.value_type, loc); CreateLifetimeEnd(key); return val; } } // Random default value to silence compiler warning bpf_func_id fn = BPF_FUNC_ktime_get_ns; switch (ts) { case TimestampMode::monotonic: fn = BPF_FUNC_ktime_get_ns; break; case TimestampMode::boot: fn = BPF_FUNC_ktime_get_boot_ns; break; case TimestampMode::tai: fn = BPF_FUNC_ktime_get_tai_ns; break; case TimestampMode::sw_tai: if (!bpftrace_.delta_taitime_.has_value()) LOG(BUG) << "delta_taitime_ should have been checked in an earlier pass"; uint64_t delta = (bpftrace_.delta_taitime_->tv_sec * 1e9) + bpftrace_.delta_taitime_->tv_nsec; Value *ns = CreateGetNs(TimestampMode::boot, loc); return CreateAdd(ns, getInt64(delta)); } // u64 ktime_get_*ns() // Return: current ktime FunctionType *gettime_func_type = FunctionType::get(getInt64Ty(), false); return CreateHelperCall(fn, gettime_func_type, {}, false, "get_ns", loc); } Value *IRBuilderBPF::CreateIntegerArrayCmp(Value *val1, Value *val2, const SizedType &val1_type, const SizedType &val2_type, const bool inverse, const Location &loc, MDNode *metadata) { // This function compares each character of the two arrays. It returns true // if all are equal and false if any are different. // // cmp([]char val1, []char val2) // { // for (size_t i = 0; i < n; i++) // { // if (val1[i] != val2[i]) // { // return false; // } // } // return true; // } auto elem_type = val1_type.GetElementTy(); const size_t num = val1_type.GetNumElements(); Value *val1_elem_i, *val2_elem_i, *cmp; AllocaInst *v1 = CreateAllocaBPF(elem_type, "v1"); AllocaInst *v2 = CreateAllocaBPF(elem_type, "v2"); AllocaInst *store = CreateAllocaBPF(getInt1Ty(), "arraycmp.result"); CreateStore(getInt1(inverse), store); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *while_cond = BasicBlock::Create(module_.getContext(), "while_cond", parent); BasicBlock *while_body = BasicBlock::Create(module_.getContext(), "while_body", parent); BasicBlock *arr_ne = BasicBlock::Create(module_.getContext(), "arraycmp.false", parent); BasicBlock *done = BasicBlock::Create(module_.getContext(), "arraycmp.done", parent); Value *ptr_val1 = CreateIntToPtr(val1, getPtrTy()); Value *ptr_val2 = CreateIntToPtr(val2, getPtrTy()); AllocaInst *i = CreateAllocaBPF(getInt32Ty(), "i"); AllocaInst *n = CreateAllocaBPF(getInt32Ty(), "n"); CreateStore(getInt32(0), i); CreateStore(getInt32(num), n); CreateBr(while_cond); SetInsertPoint(while_cond); auto *cond = CreateICmpSLT(CreateLoad(getInt32Ty(), i), CreateLoad(getInt32Ty(), n), "size_check"); Instruction *loop_hdr = CreateCondBr(cond, while_body, done); loop_hdr->setMetadata(LLVMContext::MD_loop, metadata); SetInsertPoint(while_body); BasicBlock *arr_eq = BasicBlock::Create(module_.getContext(), "arraycmp.loop", parent); auto *ptr_val1_elem_i = CreateGEP(GetType(val1_type), ptr_val1, { getInt32(0), CreateLoad(getInt32Ty(), i) }); if (val1_type.IsInBpfMemory()) { val1_elem_i = CreateLoad(GetType(elem_type), ptr_val1_elem_i); } else { CreateProbeRead(v1, getInt32(elem_type.GetSize()), ptr_val1_elem_i, val1_type.GetAS(), loc); val1_elem_i = CreateLoad(GetType(elem_type), v1); } auto *ptr_val2_elem_i = CreateGEP(GetType(val2_type), ptr_val2, { getInt32(0), CreateLoad(getInt32Ty(), i) }); if (val2_type.IsInBpfMemory()) { val2_elem_i = CreateLoad(GetType(elem_type), ptr_val2_elem_i); } else { CreateProbeRead(v2, getInt32(elem_type.GetSize()), ptr_val2_elem_i, val2_type.GetAS(), loc); val2_elem_i = CreateLoad(GetType(elem_type), v2); } cmp = CreateICmpNE(val1_elem_i, val2_elem_i, "arraycmp.cmp"); CreateCondBr(cmp, arr_ne, arr_eq); SetInsertPoint(arr_eq); CreateStore(CreateAdd(CreateLoad(getInt32Ty(), i), getInt32(1)), i); CreateBr(while_cond); SetInsertPoint(arr_ne); CreateStore(getInt1(!inverse), store); CreateBr(done); SetInsertPoint(done); Value *result = CreateLoad(getInt1Ty(), store); CreateLifetimeEnd(store); CreateLifetimeEnd(v1); CreateLifetimeEnd(v2); result = CreateIntCast(result, getInt64Ty(), false); return result; } CallInst *IRBuilderBPF::CreateGetPidTgid(const Location &loc) { // u64 bpf_get_current_pid_tgid(void) // Return: current->tgid << 32 | current->pid FunctionType *getpidtgid_func_type = FunctionType::get(getInt64Ty(), false); auto *res = CreateHelperCall(BPF_FUNC_get_current_pid_tgid, getpidtgid_func_type, {}, true, "get_pid_tgid", loc); return res; } void IRBuilderBPF::CreateGetNsPidTgid(Value *dev, Value *ino, AllocaInst *ret, const Location &loc) { // long bpf_get_ns_current_pid_tgid( // u64 dev, u64 ino, struct bpf_pidns_info *nsdata, u32 size) // Return: 0 on success const auto &layout = module_.getDataLayout(); auto struct_size = layout.getTypeAllocSize(BpfPidnsInfoType()); FunctionType *getnspidtgid_func_type = FunctionType::get(getInt64Ty(), { getInt64Ty(), getInt64Ty(), getPtrTy(), getInt32Ty(), }, false); CallInst *call = CreateHelperCall(BPF_FUNC_get_ns_current_pid_tgid, getnspidtgid_func_type, { dev, ino, ret, getInt32(struct_size) }, false, "get_ns_pid_tgid", loc); CreateHelperErrorCond(call, BPF_FUNC_get_ns_current_pid_tgid, loc); } llvm::Type *IRBuilderBPF::BpfPidnsInfoType() { return GetStructType("bpf_pidns_info", { getInt32Ty(), // pid (TID in userspace) getInt32Ty(), // tgid (PID in userspace) }, false); } CallInst *IRBuilderBPF::CreateGetCpuId(const Location &loc) { // u32 bpf_get_smp_processor_id(void) // Return: SMP processor ID FunctionType *getcpuid_func_type = FunctionType::get(getInt64Ty(), false); return CreateHelperCall(BPF_FUNC_get_smp_processor_id, getcpuid_func_type, {}, true, "get_cpu_id", loc); } CallInst *IRBuilderBPF::CreateGetStack(Value *ctx, Value *buf, const StackType &stack_type, const Location &loc) { int flags = 0; if (!stack_type.kernel) { flags |= (1 << 8); if (stack_type.mode == StackMode::build_id) { flags |= (1 << 11); } } Value *flags_val = getInt64(flags); Value *stack_size = getInt32(stack_type.limit * stack_type.elem_size()); // long bpf_get_stack(void *ctx, void *buf, u32 size, u64 flags) // Return: The non-negative copied *buf* length equal to or less than // *size* on success, or a negative error in case of failure. FunctionType *getstack_func_type = FunctionType::get( getInt64Ty(), { getPtrTy(), getPtrTy(), getInt32Ty(), getInt64Ty() }, false); CallInst *call = CreateHelperCall(BPF_FUNC_get_stack, getstack_func_type, { ctx, buf, stack_size, flags_val }, false, "get_stack", loc); CreateHelperErrorCond(call, BPF_FUNC_get_stack, loc); return call; } CallInst *IRBuilderBPF::CreateGetFuncIp(Value *ctx, const Location &loc) { // u64 bpf_get_func_ip(void *ctx) // Return: // Address of the traced function for kprobe. // 0 for kprobes placed within the function (not at the entry). // Address of the probe for uprobe and return uprobe. FunctionType *getfuncip_func_type = FunctionType::get(getInt64Ty(), { getPtrTy() }, false); return CreateHelperCall(BPF_FUNC_get_func_ip, getfuncip_func_type, { ctx }, true, "get_func_ip", loc); } CallInst *IRBuilderBPF::CreatePerCpuPtr(Value *var, Value *cpu, const Location &loc) { // void *bpf_per_cpu_ptr(const void *percpu_ptr, u32 cpu) // Return: // A pointer pointing to the kernel percpu variable on // cpu, or NULL, if cpu is invalid. FunctionType *percpuptr_func_type = FunctionType::get( getPtrTy(), { getPtrTy(), getInt32Ty() }, false); return CreateHelperCall(BPF_FUNC_per_cpu_ptr, percpuptr_func_type, { var, cpu }, true, "per_cpu_ptr", loc); } CallInst *IRBuilderBPF::CreateThisCpuPtr(Value *var, const Location &loc) { // void *bpf_this_cpu_ptr(const void *percpu_ptr) // Return: // A pointer pointing to the kernel percpu variable on // this cpu. May never be NULL. FunctionType *percpuptr_func_type = FunctionType::get(getPtrTy(), { getPtrTy() }, false); return CreateHelperCall(BPF_FUNC_this_cpu_ptr, percpuptr_func_type, { var }, true, "this_cpu_ptr", loc); } void IRBuilderBPF::CreateGetCurrentComm(AllocaInst *buf, size_t size, const Location &loc) { assert(buf->getAllocatedType()->isArrayTy() && buf->getAllocatedType()->getArrayNumElements() >= size && buf->getAllocatedType()->getArrayElementType() == getInt8Ty()); // long bpf_get_current_comm(char *buf, int size_of_buf) // Return: 0 on success or negative error FunctionType *getcomm_func_type = FunctionType::get( getInt64Ty(), { buf->getType(), getInt64Ty() }, false); CallInst *call = CreateHelperCall(BPF_FUNC_get_current_comm, getcomm_func_type, { buf, getInt64(size) }, false, "get_comm", loc); CreateHelperErrorCond(call, BPF_FUNC_get_current_comm, loc); } CallInst *IRBuilderBPF::CreateGetSocketCookie(Value *var, const Location &loc) { // u64 bpf_get_socket_cookie(struct sock *sk) // Return: // A 8-byte long unique number or 0 if *sk* is NULL. FunctionType *get_socket_cookie_func_type = FunctionType::get( getInt64Ty(), { var->getType() }, false); return CreateHelperCall(BPF_FUNC_get_socket_cookie, get_socket_cookie_func_type, { var }, true, "get_socket_cookie", loc); } void IRBuilderBPF::CreateOutput(Value *data, size_t size, const Location &loc) { assert(data && data->getType()->isPointerTy()); CreateRingbufOutput(data, size, loc); } void IRBuilderBPF::CreateRingbufOutput(Value *data, size_t size, const Location &loc) { Value *map_ptr = GetMapVar(to_string(MapType::Ringbuf)); // long bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) FunctionType *ringbuf_output_func_type = FunctionType::get( getInt64Ty(), { map_ptr->getType(), data->getType(), getInt64Ty(), getInt64Ty() }, false); Value *ret = CreateHelperCall(BPF_FUNC_ringbuf_output, ringbuf_output_func_type, { map_ptr, data, getInt64(size), getInt64(0) }, false, "ringbuf_output", loc); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *loss_block = BasicBlock::Create(module_.getContext(), "event_loss_counter", parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "counter_merge", parent); Value *condition = CreateICmpSLT(ret, getInt64(0), "ringbuf_loss"); CreateCondBr(condition, loss_block, merge_block); SetInsertPoint(loss_block); CreateIncEventLossCounter(loc); CreateBr(merge_block); SetInsertPoint(merge_block); } void IRBuilderBPF::CreateIncEventLossCounter(const Location &loc) { auto *value = createScratchBuffer(bpftrace::globalvars::EVENT_LOSS_COUNTER, loc, 0); CreateStore(CreateAdd(CreateLoad(getInt64Ty(), value), getInt64(1)), value); } void IRBuilderBPF::CreatePerCpuMapElemInit(const std::string &map_ident, Value *key, Value *val, const Location &loc) { AllocaInst *initValue = CreateAllocaBPF(val->getType(), "initial_value"); CreateStore(val, initValue); CreateMapUpdateElem(map_ident, key, initValue, loc, BPF_ANY); CreateLifetimeEnd(initValue); } void IRBuilderBPF::CreatePerCpuMapElemAdd(const std::string &map_ident, Value *key, Value *val, const SizedType &value_type, const Location &loc) { CallInst *call = createMapLookup(map_ident, key); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_.getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_.getContext(), "lookup_failure", parent); BasicBlock *lookup_merge_block = BasicBlock::Create(module_.getContext(), "lookup_merge", parent); AllocaInst *value = CreateAllocaBPF(value_type, "lookup_elem_val"); Value *condition = CreateICmpNE(CreateIntCast(call, getPtrTy(), true), GetNull(), "map_lookup_cond"); CreateCondBr(condition, lookup_success_block, lookup_failure_block); SetInsertPoint(lookup_success_block); // createMapLookup returns an u8* auto *cast = CreatePtrToInt(call, value->getType(), "cast"); CreateStore(CreateAdd(CreateLoad(value->getAllocatedType(), cast), val), cast); CreateBr(lookup_merge_block); SetInsertPoint(lookup_failure_block); CreatePerCpuMapElemInit(map_ident, key, val, loc); CreateBr(lookup_merge_block); SetInsertPoint(lookup_merge_block); CreateLifetimeEnd(value); } void IRBuilderBPF::CreateTracePrintk(Value *fmt_ptr, Value *fmt_size, const std::vector &values, const Location &loc) { std::vector args = { fmt_ptr, fmt_size }; for (auto *val : values) { args.push_back(val); } // long bpf_trace_printk(const char *fmt, u32 fmt_size, ...) FunctionType *traceprintk_func_type = FunctionType::get( getInt64Ty(), { getPtrTy(), getInt32Ty() }, true); CreateHelperCall(BPF_FUNC_trace_printk, traceprintk_func_type, args, false, "trace_printk", loc); } void IRBuilderBPF::CreateSignal(Value *sig, const Location &loc, bool target_thread) { // target_thread = false: long bpf_send_signal(u32 sig) // target_thread = true: long bpf_send_signal_thread(u32 sig) // Return: 0 or error FunctionType *signal_func_type = FunctionType::get(getInt64Ty(), { getInt32Ty() }, false); PointerType *signal_func_ptr_type = PointerType::get(getContext(), 0); auto helper_func_id = BPF_FUNC_send_signal; std::string name = "signal"; if (target_thread) { helper_func_id = BPF_FUNC_send_signal_thread; name = "signal_thread"; } Constant *signal_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64(helper_func_id), signal_func_ptr_type); CallInst *call = createCall(signal_func_type, signal_func, { sig }, name); CreateHelperErrorCond(call, helper_func_id, loc); } CallInst *IRBuilderBPF::CreateSkbOutput(Value *skb, Value *len, AllocaInst *data, size_t size) { Value *flags, *map_ptr, *size_val; map_ptr = GetMapVar(to_string(MapType::PerfEvent)); flags = len; flags = CreateShl(flags, 32); flags = CreateOr(flags, getInt64(BPF_F_CURRENT_CPU)); size_val = getInt64(size); // long bpf_skb_output(void *skb, struct bpf_map *map, u64 flags, // void *data, u64 size) FunctionType *skb_output_func_type = FunctionType::get(getInt64Ty(), { skb->getType(), map_ptr->getType(), getInt64Ty(), data->getType(), getInt64Ty() }, false); PointerType *skb_output_func_ptr_type = PointerType::get(getContext(), 0); Constant *skb_output_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64( BPF_FUNC_skb_output), skb_output_func_ptr_type); CallInst *call = createCall(skb_output_func_type, skb_output_func, { skb, map_ptr, flags, data, size_val }, "skb_output"); return call; } Value *IRBuilderBPF::CreateKFuncArg(Value *ctx, const SizedType &type, std::string &name) { assert(type.IsIntTy() || type.IsPtrTy() || type.IsBoolTy()); Value *raw = CreateLoad( getInt64Ty(), CreateSafeGEP(getInt64Ty(), ctx, getInt64(type.funcarg_idx)), true, /*volatile*/ name); if (type.IsPtrTy()) { return CreateIntToPtr(raw, GetType(type), name); } if (type.IsBoolTy()) { return CreateTrunc(raw, GetType(type), name); } if (type.IsIntTy() && type.GetSize() < 8) { return CreateTrunc(raw, GetType(type), name); } return raw; } Value *IRBuilderBPF::CreateRawTracepointArg(Value *ctx, const std::string &builtin) { // argX int offset = atoi(builtin.substr(3).c_str()); llvm::Type *type = getInt64Ty(); // All arguments are coerced into Int64. Value *expr = CreateLoad(type, CreateSafeGEP(type, ctx, getInt64(offset)), builtin); return expr; } Value *IRBuilderBPF::CreateUprobeArgsRecord(Value *ctx, const SizedType &args_type) { assert(args_type.IsCTypeTy()); auto *args_t = UprobeArgsType(args_type); AllocaInst *result = CreateAllocaBPF(args_t, "args"); for (auto &arg : args_type.GetFields()) { assert(arg.type.is_funcarg); Value *arg_read = CreateRegisterRead( ctx, "arg" + std::to_string(arg.type.funcarg_idx)); if (arg.type.GetSize() != 8) arg_read = CreateTrunc(arg_read, GetType(arg.type)); CreateStore(arg_read, CreateGEP(args_t, result, { getInt64(0), getInt32(arg.type.funcarg_idx) })); } return result; } llvm::Type *IRBuilderBPF::UprobeArgsType(const SizedType &args_type) { std::vector arg_types; for (auto &arg : args_type.GetFields()) arg_types.push_back(GetType(arg.type)); return GetStructType(std::string(args_type.GetBaseName()), arg_types, false); } Value *IRBuilderBPF::CreateRegisterRead(Value *ctx, const std::string &builtin) { std::optional reg; if (builtin == "__builtin_retval") { reg = arch::Host::return_value(); } else if (builtin == "__builtin_func") { reg = arch::Host::pc_value(); } else if (builtin.starts_with("arg")) { size_t n = static_cast(atoi(builtin.substr(3).c_str())); const auto &arguments = arch::Host::arguments(); if (n < arguments.size()) { reg = arguments[n]; } } if (!reg.has_value()) { LOG(BUG) << "unknown builtin: " << builtin; __builtin_unreachable(); } auto offset = arch::Host::register_to_pt_regs_offset(reg.value()); if (!offset.has_value()) { LOG(BUG) << "invalid register `" << reg.value() << " for builtin: " << builtin; __builtin_unreachable(); } return CreateRegisterRead(ctx, offset.value(), builtin); } Value *IRBuilderBPF::CreateRegisterRead(Value *ctx, size_t offset, const std::string &name) { // Bitwidth of register values in struct pt_regs is the same as the kernel // pointer width on all supported architectures. // // FIXME(#3873): Not clear if this applies as a general rule, best to allow // these to be resolved via field names and BTF directly in the future. llvm::Type *registerTy = getPointerStorageTy(); Value *result = CreateLoad(registerTy, CreateSafeGEP(getInt8Ty(), ctx, getInt64(offset)), true, /*volatile*/ name); return result; } static bool return_zero_if_err(bpf_func_id func_id) { switch (func_id) { // When these function fails, bpftrace stores zero as a result. // A user script can check an error by seeing the value. // Therefore error checks of these functions are omitted if // warning_level == 1. case BPF_FUNC_probe_read: case BPF_FUNC_probe_read_str: case BPF_FUNC_probe_read_kernel: case BPF_FUNC_probe_read_kernel_str: case BPF_FUNC_probe_read_user: case BPF_FUNC_probe_read_user_str: case BPF_FUNC_map_lookup_elem: return true; default: return false; } return false; } void IRBuilderBPF::CreateRuntimeError(RuntimeErrorId rte_id, const Location &loc) { CreateRuntimeError(rte_id, getInt64(0), __BPF_FUNC_MAX_ID, loc); } void IRBuilderBPF::CreateRuntimeError(RuntimeErrorId rte_id, Value *return_value, bpf_func_id func_id, const Location &loc) { if (rte_id == RuntimeErrorId::HELPER_ERROR) { assert(return_value && return_value->getType() == getInt32Ty()); if (bpftrace_.warning_level_ == 0 || (bpftrace_.warning_level_ == 1 && return_zero_if_err(func_id))) return; } int error_id = async_ids_.runtime_error(); bpftrace_.resources.runtime_error_info.try_emplace( error_id, RuntimeErrorInfo(rte_id, func_id, loc)); auto elements = AsyncEvent::RuntimeError().asLLVMType(*this); StructType *runtime_error_struct = GetStructType("runtime_error_t", elements, true); AllocaInst *buf = CreateAllocaBPF(runtime_error_struct, "runtime_error_t"); CreateStore( GetIntSameSize(static_cast( async_action::AsyncAction::runtime_error), elements.at(0)), CreateGEP(runtime_error_struct, buf, { getInt64(0), getInt32(0) })); CreateStore( GetIntSameSize(error_id, elements.at(1)), CreateGEP(runtime_error_struct, buf, { getInt64(0), getInt32(1) })); CreateStore( return_value, CreateGEP(runtime_error_struct, buf, { getInt64(0), getInt32(2) })); const auto &layout = module_.getDataLayout(); auto struct_size = layout.getTypeAllocSize(runtime_error_struct); CreateOutput(buf, struct_size, loc); CreateLifetimeEnd(buf); } void IRBuilderBPF::CreateHelperErrorCond(Value *return_value, bpf_func_id func_id, const Location &loc) { if (bpftrace_.warning_level_ == 0 || (bpftrace_.warning_level_ == 1 && return_zero_if_err(func_id))) return; llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *helper_failure_block = BasicBlock::Create(module_.getContext(), "helper_failure", parent); BasicBlock *helper_merge_block = BasicBlock::Create(module_.getContext(), "helper_merge", parent); // A return type of most helper functions are Int64Ty but they actually // return int and we need to use Int32Ty value to check if a return // value is negative. TODO: use Int32Ty as a return type auto *ret = CreateIntCast(return_value, getInt32Ty(), true); Value *condition = CreateICmpSGE(ret, Constant::getNullValue(ret->getType())); CreateCondBr(condition, helper_merge_block, helper_failure_block); SetInsertPoint(helper_failure_block); CreateRuntimeError(RuntimeErrorId::HELPER_ERROR, ret, func_id, loc); CreateBr(helper_merge_block); SetInsertPoint(helper_merge_block); } void IRBuilderBPF::CreatePath(Value *buf, Value *path, Value *sz, const Location &loc) { // int bpf_d_path(struct path *path, char *buf, u32 sz) // Return: 0 or error FunctionType *d_path_func_type = FunctionType::get( getInt64Ty(), { getPtrTy(), buf->getType(), getInt32Ty() }, false); CallInst *call = CreateHelperCall(bpf_func_id::BPF_FUNC_d_path, d_path_func_type, { path, buf, sz }, false, "d_path", loc); CreateHelperErrorCond(call, BPF_FUNC_d_path, loc); } void IRBuilderBPF::CreateSeqPrintf(Value *ctx, Value *fmt, Value *fmt_size, Value *data, Value *data_len, const Location &loc) { // long bpf_seq_printf(struct seq_file *m, const char *fmt, __u32 fmt_size, // const void *data, __u32 data_len) // Return: 0 or error FunctionType *seq_printf_func_type = FunctionType::get( getInt64Ty(), { getInt64Ty(), getPtrTy(), getInt32Ty(), getPtrTy(), getInt32Ty() }, false); PointerType *seq_printf_func_ptr_type = PointerType::get(getContext(), 0); Constant *seq_printf_func = ConstantExpr::getCast(Instruction::IntToPtr, getInt64( BPF_FUNC_seq_printf), seq_printf_func_ptr_type); LoadInst *meta = CreateLoad(getPtrTy(), CreateSafeGEP(getInt64Ty(), ctx, getInt64(0)), "meta"); meta->setVolatile(true); Value *seq = CreateLoad(getInt64Ty(), CreateGEP(getInt64Ty(), meta, getInt64(0)), "seq"); CallInst *call = createCall(seq_printf_func_type, seq_printf_func, { seq, fmt, fmt_size, data, data_len }, "seq_printf"); CreateHelperErrorCond(call, BPF_FUNC_seq_printf, loc); } StoreInst *IRBuilderBPF::createAlignedStore(Value *val, Value *ptr, unsigned int align) { return CreateAlignedStore(val, ptr, MaybeAlign(align)); } void IRBuilderBPF::CreateProbeRead(Value *dst, const SizedType &type, Value *src, const Location &loc, std::optional addrSpace) { AddrSpace as = addrSpace ? addrSpace.value() : type.GetAS(); if (!type.IsPtrTy()) { CreateProbeRead(dst, getInt32(type.GetSize()), src, as, loc); return; } // Pointers are internally always represented as 64-bit integers, matching the // BPF register size (BPF is a 64-bit ISA). This helps to avoid BPF codegen // issues such as truncating PTR_TO_STACK registers using shift operations, // which is disallowed (see https://github.com/bpftrace/bpftrace/pull/2361). // However, when reading pointers from kernel or user memory, we need to use // the appropriate size for the target system. const size_t ptr_size = getPointerStorageTy()->getIntegerBitWidth() / 8; #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ // TODO: support 32-bit big-endian systems assert(ptr_size == type.GetSize()); #endif if (ptr_size != type.GetSize()) CreateMemsetBPF(dst, getInt8(0), type.GetSize()); CreateProbeRead(dst, getInt32(ptr_size), src, as, loc); } llvm::Value *IRBuilderBPF::CreateDatastructElemLoad(const SizedType &type, llvm::Value *ptr) { llvm::Type *ptr_storage_ty = getPointerStorageTy(); if (!type.IsPtrTy() || ptr_storage_ty == getInt64Ty()) return CreateLoad(GetType(type), ptr, true /*volatile*/); assert(GetType(type) == getInt64Ty()); // Pointer size for the given address space doesn't match the BPF-side // representation. Use ptr_storage_ty as the load type and cast the result // back to int64. llvm::Value *expr = CreateLoad(ptr_storage_ty, ptr, true /*volatile*/); return CreateIntCast(expr, getInt64Ty(), false); } llvm::Value *IRBuilderBPF::CreatePtrOffset(const SizedType &type, llvm::Value *index) { size_t elem_size = type.IsPtrTy() ? getPointerStorageTy()->getIntegerBitWidth() / 8 : type.GetSize(); return CreateMul(index, getInt64(elem_size)); } llvm::Value *IRBuilderBPF::CreateSafeGEP(llvm::Type *ty, llvm::Value *ptr, llvm::ArrayRef offsets, const llvm::Twine &name) { if (!ptr->getType()->isPointerTy()) { assert(ptr->getType()->isIntegerTy()); ptr = CreateIntToPtr(ptr, getPtrTy()); } if (!preserve_static_offset_) { #if LLVM_VERSION_MAJOR >= 20 preserve_static_offset_ = llvm::Intrinsic::getOrInsertDeclaration( &module_, llvm::Intrinsic::preserve_static_offset); #else preserve_static_offset_ = llvm::Intrinsic::getDeclaration( &module_, llvm::Intrinsic::preserve_static_offset); #endif } ptr = CreateCall(preserve_static_offset_, ptr); // Create the GEP itself; on newer versions of LLVM this coerces the pointer // value into a pointer to the given type, and older versions have guaranteed // a suitable cast above (first from integer, then to the right pointer). return CreateGEP(ty, ptr, offsets, name); } llvm::Type *IRBuilderBPF::getPointerStorageTy() { static int ptr_width = arch::Host::kernel_ptr_width(); return getIntNTy(ptr_width); } void IRBuilderBPF::CreateMinMax(Value *val, Value *val_ptr, Value *is_set_ptr, bool max, bool is_signed) { llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *is_set_block = BasicBlock::Create(module_.getContext(), "is_set", parent); BasicBlock *min_max_block = BasicBlock::Create(module_.getContext(), "min_max", parent); BasicBlock *merge_block = BasicBlock::Create(module_.getContext(), "merge", parent); Value *curr = CreateLoad(getInt64Ty(), val_ptr); Value *is_set_condition = CreateICmpEQ(CreateLoad(getInt64Ty(), is_set_ptr), getInt64(1), "is_set_cond"); CreateCondBr(is_set_condition, is_set_block, min_max_block); SetInsertPoint(is_set_block); Value *min_max_condition; if (max) { min_max_condition = is_signed ? CreateICmpSGE(val, curr) : CreateICmpUGE(val, curr); } else { min_max_condition = is_signed ? CreateICmpSGE(curr, val) : CreateICmpUGE(curr, val); } CreateCondBr(min_max_condition, min_max_block, merge_block); SetInsertPoint(min_max_block); CreateStore(val, val_ptr); CreateStore(getInt64(1), is_set_ptr); CreateBr(merge_block); SetInsertPoint(merge_block); } llvm::Value *IRBuilderBPF::CreateCheckedBinop(Binop &binop, Value *lhs, Value *rhs) { assert(binop.op == Operator::DIV || binop.op == Operator::MOD); // We need to do an explicit 0 check or else a Clang compiler optimization // will assume that the value can't ever be 0, as this is undefined behavior, // and remove a conditional null check for map values which will return 0 if // the map value is null (this happens in CreateMapLookupElem). This would be // fine but the BPF verifier will complain about the lack of a null check. // Issue: https://github.com/bpftrace/bpftrace/issues/4379 // From Google's AI: "LLVM, like other optimizing compilers, is allowed to // make assumptions based on the absence of undefined behavior. If a program's // code, after optimization, would result in undefined behavior (like division // by zero by CreateURem), the compiler is free to make transformations that // assume such a situation will never occur." AllocaInst *op_result = CreateAllocaBPF(getInt64Ty(), "op_result"); llvm::Function *parent = GetInsertBlock()->getParent(); BasicBlock *is_zero = BasicBlock::Create(module_.getContext(), "is_zero", parent); BasicBlock *not_zero = BasicBlock::Create(module_.getContext(), "not_zero", parent); BasicBlock *zero_merge = BasicBlock::Create(module_.getContext(), "zero_merge", parent); Value *cond = CreateICmpEQ(rhs, getInt64(0), "zero_cond"); CreateCondBr(cond, is_zero, not_zero); SetInsertPoint(is_zero); CreateStore(getInt64(1), op_result); CreateRuntimeError(RuntimeErrorId::DIVIDE_BY_ZERO, binop.loc); CreateBr(zero_merge); SetInsertPoint(not_zero); if (binop.op == Operator::MOD) { CreateStore(CreateURem(lhs, rhs), op_result); } else if (binop.op == Operator::DIV) { CreateStore(CreateUDiv(lhs, rhs), op_result); } CreateBr(zero_merge); SetInsertPoint(zero_merge); auto *result = CreateLoad(getInt64Ty(), op_result); CreateLifetimeEnd(op_result); return result; } bool IRBuilderBPF::HasTerminator() { BasicBlock *current_block = GetInsertBlock(); if (!current_block) return false; #if LLVM_VERSION_MAJOR >= 23 if (!current_block->hasTerminator()) return false; #endif return current_block->getTerminator(); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/irbuilderbpf.h000066400000000000000000000362371526721631600176130ustar00rootroot00000000000000#pragma once #include #include #include #include "ast/ast.h" #include "ast/async_ids.h" #include "bpftrace.h" #include "types.h" #define CREATE_ATOMIC_RMW(op, ptr, val, align, order) \ CreateAtomicRMW((op), (ptr), (val), MaybeAlign((align)), (order)) namespace bpftrace::ast { using namespace llvm; class IRBuilderBPF : public IRBuilder<> { public: IRBuilderBPF(LLVMContext &context, Module &module, BPFtrace &bpftrace, AsyncIds &async_ids); // LLVM 22+ requires lifetime intrinsics only on alloca or poison. // Since createAllocation() may return a GEP into a global scratch buffer, // this wrapper guards against calling lifetime.end on non-alloca values. void CreateLifetimeEnd(Value *val); // The builder must never carry a debug location: we attach locations to // individual instructions instead. Several IRBuilder::SetInsertPoint // overloads copy the !dbg of the instruction they land on, which then sticks // to everything emitted afterwards, which can cause leaking and segfaults if // a location outlives the function it came from. These wrappers clear it so // no insertion point change can carry a location along. // https://github.com/bpftrace/bpftrace/pull/5278 void SetInsertPoint(BasicBlock *bb); void SetInsertPoint(Instruction *inst); void SetInsertPoint(BasicBlock *bb, BasicBlock::iterator ip); void SetInsertPoint(BasicBlock::iterator ip); void restoreIP(InsertPoint ip); AllocaInst *CreateAllocaBPF(llvm::Type *ty, const std::string &name = ""); AllocaInst *CreateAllocaBPF(const SizedType &stype, const std::string &name = ""); AllocaInst *CreateAllocaBPFInit(const SizedType &stype, const std::string &name); AllocaInst *CreateAllocaBPF(int bytes, const std::string &name = ""); void CreateMemsetBPF(Value *ptr, Value *val, uint32_t size); void CreateMemcpyBPF(Value *dst, Value *src, uint32_t size); llvm::Type *GetType(const SizedType &stype); llvm::Type *GetMapValueType(const SizedType &stype); llvm::ConstantInt *GetIntSameSize(uint64_t C, llvm::Value *expr); llvm::ConstantInt *GetIntSameSize(uint64_t C, llvm::Type *ty); Value *GetMapVar(const std::string &map_name); Value *GetNull(); CallInst *CreateMapLookup(Map &map, Value *key, const std::string &name = "lookup_elem"); Value *CreateMapLookupElem(const std::string &map_name, Value *key, const SizedType &type, const Location &loc); Value *CreatePerCpuMapAggElems(Map &map, Value *key, const SizedType &type, const Location &loc); void CreateMapUpdateElem(const std::string &map_ident, Value *key, Value *val, const Location &loc, int64_t flags = 0); Value *CreateForRange(Value *iters, Value *callback, Value *callback_ctx, const Location &loc); Value *CreateForEachMapElem(Map &map, Value *callback, Value *callback_ctx, const Location &loc); void CreateProbeRead(Value *dst, llvm::Value *size, Value *src, AddrSpace as, const Location &loc); // Emits a bpf_probe_read call in which the size is derived from the SizedType // argument. Has special handling for certain types such as pointers where the // size depends on the host system as well as the probe type. // If provided, the optional AddrSpace argument is used instead of the type's // address space (which may not always be set). void CreateProbeRead(Value *dst, const SizedType &type, Value *src, const Location &loc, std::optional addrSpace = std::nullopt); // Emits the load instruction the type of which is derived from the provided // SizedType. Used to access elements from structures that ctx points to, or // those that have already been pulled onto the BPF stack. Correctly handles // pointer size differences (see CreateProbeRead). llvm::Value *CreateDatastructElemLoad(const SizedType &type, llvm::Value *ptr); CallInst *CreateProbeReadStr(Value *dst, llvm::Value *size, Value *src, AddrSpace as, const Location &loc); CallInst *CreateProbeReadStr(Value *dst, size_t size, Value *src, AddrSpace as, const Location &loc); Value *CreateStrncmp(Value *str1, Value *str2, uint64_t n, bool inverse); Value *CreateStrcontains(Value *haystack, uint64_t haystack_sz, Value *needle, uint64_t needle_sz); Value *CreateIntegerArrayCmp(Value *val1, Value *val2, const SizedType &val1_type, const SizedType &val2_type, bool inverse, const Location &loc, MDNode *metadata); Value *CreateGetNs(TimestampMode ts, const Location &loc); CallInst *CreateGetCpuId(const Location &loc); CallInst *CreateGetStack(Value *ctx, Value *buf, const StackType &stack_type, const Location &loc); CallInst *CreateGetFuncIp(Value *ctx, const Location &loc); CallInst *CreatePerCpuPtr(Value *var, Value *cpu, const Location &loc); CallInst *CreateThisCpuPtr(Value *var, const Location &loc); CallInst *CreateGetSocketCookie(Value *var, const Location &loc); Value *CreateGetStrAllocation(const std::string &name, const Location &loc); Value *CreateGetFmtStringArgsAllocation(StructType *struct_type, const std::string &name, const Location &loc); Value *CreateAnonStructAllocation(const SizedType &tuple_type, const std::string &name, const Location &loc); Value *CreateCallStackAllocation(const SizedType &stack_type, const std::string &name, const Location &loc); Value *CreateJoinAllocation(const Location &loc); Value *CreateWriteMapValueAllocation(const SizedType &value_type, const std::string &name, const Location &loc); Value *CreateVariableAllocationInit(const SizedType &value_type, const std::string &name, const Location &loc); void CreateAllocationInit(const SizedType &stype, Value *alloc); Value *CreateMapKeyAllocation(const SizedType &value_type, const std::string &name, const Location &loc); void CreateCheckSetRecursion(const Location &loc, int early_exit_ret); void CreateUnSetRecursion(const Location &loc); CallInst *CreateHelperCall(bpf_func_id func_id, FunctionType *helper_type, ArrayRef args, bool is_pure, const Twine &Name, const Location &loc); CallInst *createCall(FunctionType *callee_type, Value *callee, ArrayRef args, const Twine &Name); void CreateGetCurrentComm(AllocaInst *buf, size_t size, const Location &loc); void CreateOutput(Value *data, size_t size, const Location &loc); void CreateIncEventLossCounter(const Location &loc); void CreatePerCpuMapElemInit(const std::string &map_ident, Value *key, Value *val, const Location &loc); void CreatePerCpuMapElemAdd(const std::string &map_ident, Value *key, Value *val, const SizedType &value_type, const Location &loc); void CreateTracePrintk(Value *fmt, Value *fmt_size, const std::vector &values, const Location &loc); void CreateSignal(Value *sig, const Location &loc, bool target_thread); void CreateRuntimeError(RuntimeErrorId rte_id, const Location &loc); void CreateRuntimeError(RuntimeErrorId rte_id, Value *return_value, bpf_func_id func_id, const Location &loc); void CreateHelperErrorCond(Value *return_value, bpf_func_id func_id, const Location &loc); StructType *GetStackStructType(const StackType &stack_type); StructType *GetStructType(const std::string &name, const std::vector &elements, bool packed = false); Value *CreateGetPid(const Location &loc, bool force_init); Value *CreateGetTid(const Location &loc, bool force_init); AllocaInst *CreateUSym(Value *val, int probe_id, const Location &loc); Value *CreateRegisterRead(Value *ctx, const std::string &builtin); Value *CreateRegisterRead(Value *ctx, size_t offset, const std::string &name); Value *CreateKFuncArg(Value *ctx, const SizedType &type, std::string &name); Value *CreateRawTracepointArg(Value *ctx, const std::string &builtin); Value *CreateUprobeArgsRecord(Value *ctx, const SizedType &args_type); llvm::Type *UprobeArgsType(const SizedType &args_type); CallInst *CreateSkbOutput(Value *skb, Value *len, AllocaInst *data, size_t size); void CreatePath(Value *buf, Value *path, Value *sz, const Location &loc); void CreateSeqPrintf(Value *ctx, Value *fmt, Value *fmt_size, Value *data, Value *data_len, const Location &loc); // For a type T, creates an integer expression representing the byte offset // of the element at the given index in T[]. Used for array dereferences and // pointer arithmetic. llvm::Value *CreatePtrOffset(const SizedType &type, llvm::Value *index); // Safely handle pointer references by wrapping the address with the // intrinsic `preserve_static_offset` [1], which will ensure that LLVM does // not apply certain basic optimizations (notably, saving any intermediate // offset from this pointer). This is required for the context pointer, // which, if modified. will trigger an error in the verifier. This method // also automatically handles casts from integers and other pointers; the // output value is always a pointer to `ty`. // // [1] https://reviews.llvm.org/D133361 llvm::Value *CreateSafeGEP(llvm::Type *Ty, llvm::Value *Ptr, llvm::ArrayRef offsets, const llvm::Twine &Name = ""); StoreInst *createAlignedStore(Value *val, Value *ptr, unsigned align); // moves the insertion point to the start of the function you're inside, // invokes functor, then moves the insertion point back to its original // position. this enables you to emit instructions at the start of your // function. you might want to "hoist" an alloca to make it available to // blocks that do not follow from yours, for example to make $a accessible in // both branches here: // begin { if (nsecs > 0) { $a = 1 } else { $a = 2 } print($a); exit() } void hoist(const std::function &functor); // Returns the integer type used to represent pointers in traced code. llvm::Type *getPointerStorageTy(); void CreateMinMax(Value *val, Value *val_ptr, Value *is_set_ptr, bool max, bool is_signed); llvm::Value *CreateCheckedBinop(Binop &binop, Value *lhs, Value *rhs); // Check to see if the current basic block already has a terminator. This is // useful in cases where you've generated a nested block, but it may already // have a terminator and you can't unconditionally generate another. // // For example: // if foo { // return; // } else { // ... // } bool HasTerminator(); private: Module &module_; BPFtrace &bpftrace_; AsyncIds &async_ids_; CallInst *CreateGetPidTgid(const Location &loc); void CreateGetNsPidTgid(Value *dev, Value *ino, AllocaInst *ret, const Location &loc); llvm::Type *BpfPidnsInfoType(); CallInst *createMapLookup(const std::string &map_name, Value *key, const std::string &name = "lookup_elem"); CallInst *createPerCpuMapLookup( const std::string &map_name, Value *key, Value *cpu, const std::string &name = "lookup_percpu_elem"); CallInst *createPerCpuMapLookup( const std::string &map_name, Value *key, Value *cpu, PointerType *val_ptr_ty, const std::string &name = "lookup_percpu_elem"); Value *CreateReadMapValueAllocation(const SizedType &value_type, const std::string &name, const Location &loc); Value *createAllocation(std::string_view global_var_name, llvm::Type *obj_type, const std::string &name, const Location &loc, std::optional> gen_async_id_cb = std::nullopt); Value *createScratchBuffer(std::string_view global_var_name, const Location &loc, size_t key); bpf_func_id selectProbeReadHelper(AddrSpace as, bool str); void CreateRingbufOutput(Value *data, size_t size, const Location &loc); void createPerCpuSum(AllocaInst *ret, CallInst *call, const SizedType &type); void createPerCpuMinMax(AllocaInst *ret, AllocaInst *is_ret_set, CallInst *call, const SizedType &type); void createPerCpuAvg(AllocaInst *total, AllocaInst *count, CallInst *call, const SizedType &type); std::map structs_; llvm::Function *preserve_static_offset_ = nullptr; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/location.cpp000066400000000000000000000114001526721631600172660ustar00rootroot00000000000000#include #include #include "ast/context.h" #include "ast/location.h" namespace bpftrace::ast { std::string SourceLocation::filename() const { if (source_) { return source_->filename; } return ""; } std::string SourceLocation::source_location() const { std::stringstream ss; if (source_) { ss << source_->filename << ":"; } if (begin.line != end.line) { ss << begin.line << "-" << end.line; return ss.str(); } ss << begin.line << ":"; ss << begin.column << "-" << end.column; return ss.str(); } std::ostream &operator<<(std::ostream &out, const SourceLocation &loc) { out << loc.source_location(); return out; } SourceLocation operator+(const SourceLocation &orig, const SourceLocation &other) { // The parser constructs source locations that don't have any source. These // are quickly joined into locations that do have source, so we allow for this // and quickly converge to what is expected. auto source = orig.source_; if (source == nullptr && other.source_ != nullptr) { source = other.source_; } else if (other.source_ != nullptr) { assert(source == other.source_); } auto result = SourceLocation(source); result.begin.line = std::min(orig.begin.line, other.begin.line); result.end.line = std::max(orig.end.line, other.end.line); if (orig.begin.line < other.begin.line) { result.begin.column = orig.begin.column; } else if (orig.begin.line == other.begin.line) { result.begin.column = std::min(orig.begin.column, other.begin.column); } else { result.begin.column = other.begin.column; } if (orig.end.line < other.end.line) { result.end.column = other.end.column; } else if (orig.end.line == other.end.line) { result.end.column = std::max(orig.end.column, other.end.column); } else { result.end.column = orig.end.column; } return result; } std::vector SourceLocation::source_context() const { std::vector result; // Is there source available? if (!source_ || begin.line == 0) { return result; } // Multi-lines just include all context. if (begin.line != end.line) { assert(begin.line < end.line); for (int i = begin.line; i <= end.line; i++) { assert(i <= static_cast(source_->lines_.size())); result.push_back(source_->lines_[i - 1]); } return result; } // Single line includes just the relevant context. if (begin.line > static_cast(source_->lines_.size())) { return result; // Nothing available. } auto &srcline = source_->lines_[begin.line - 1]; std::stringstream orig; for (auto c : srcline) { if (c == '\t') orig << " "; else orig << c; } result.emplace_back(orig.str()); std::stringstream select; for (int x = 0; x < static_cast(srcline.size()) && x < end.column - 1; x++) { char marker = x < begin.column - 1 ? ' ' : '~'; if (srcline[x] == '\t') { select << std::string(4, marker); } else { select << marker; } } result.emplace_back(select.str()); return result; } Location operator+(const Location &orig, const Location &expansion) { if (expansion == nullptr) { return orig; } if (orig == nullptr) { return expansion; } auto nlink = std::make_shared(expansion->current); nlink->parent.emplace(LocationChain::Context(Location(orig))); nlink->parent->msg << "expanded from"; return nlink; } std::strong_ordering operator<=>(const SourceLocation::Position &lhs, const SourceLocation::Position &rhs) { if (auto cmp = lhs.line <=> rhs.line; cmp != 0) { return cmp; } return lhs.column <=> rhs.column; } std::strong_ordering operator<=>(const SourceLocation &lhs, const SourceLocation &rhs) { if (auto cmp = lhs.begin <=> rhs.begin; cmp != 0) { return cmp; } // If begin positions are equal, compare by span length. The shortest spans // are considered to be the first nodes here. This allows us to use // lower_bound matching to find the first reasonable matching node for // metadata. auto lhs_span_lines = lhs.end.line - lhs.begin.line; auto rhs_span_lines = rhs.end.line - rhs.begin.line; if (auto cmp = lhs_span_lines <=> rhs_span_lines; cmp != 0) { return cmp; } auto lhs_span_cols = lhs.end.column - lhs.begin.column; auto rhs_span_cols = rhs.end.column - rhs.begin.column; return lhs_span_cols <=> rhs_span_cols; } bool operator==(const SourceLocation::Position &lhs, const SourceLocation::Position &rhs) { return lhs.line == rhs.line && lhs.column == rhs.column; } bool operator==(const SourceLocation &lhs, const SourceLocation &rhs) { return lhs.begin == rhs.begin && lhs.end == rhs.end; } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/location.h000066400000000000000000000110661526721631600167430ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include namespace bpftrace::ast { class ASTSource; class ASTContext; // SourceLocation refers to a single location in a source file. // // It does not contain any additional context. It may be manipulated directly // by the lexer, and copied. class SourceLocation { public: struct Position { int line = 1; int column = 1; }; SourceLocation() = default; // Allowed, but see operator+. SourceLocation(const SourceLocation &) = default; SourceLocation &operator=(const SourceLocation &other) = default; SourceLocation(SourceLocation &&) = default; SourceLocation &operator=(SourceLocation &&other) = default; SourceLocation(std::shared_ptr source) : source_(std::move(source)) {}; // Canonical filename. std::string filename() const; // Produce a canonical string showing the filename, line range and/or column // range. This is of the form `::` but may also take the // form `:`. std::string source_location() const; // Produce a sequence of lines that highlights the specific source context. // Note that these should be emitted such that the columns for each line line // up when they are displayed. std::vector source_context() const; // Canonical line number, will be start of range. unsigned int line() const { return begin.line; }; // Canonical column number, will be start of range. unsigned int column() const { return begin.column; }; // Moves the cursor forward `lines` lines. void advance_lines(int lines = 1) { begin.column = 1; end.column = 1; begin.line += lines; end.line = begin.line; } // Moves the cursor forward `count` columns. void advance_columns(int count) { begin.column = end.column; end.column += count; } // Move the cursor backwards. void rewind_columns() { end.column -= 1; begin.column -= 1; } // Trims the last character from this location. void trim() { end.column -= 1; } // Resets the column. void reset_column() { begin.column = 1; end.column = 1; } Position begin; Position end; private: std::shared_ptr source_; friend class ASTContext; friend SourceLocation operator+(const SourceLocation &orig, const SourceLocation &other); }; SourceLocation operator+(const SourceLocation &orig, const SourceLocation &other); std::ostream &operator<<(std::ostream &out, const SourceLocation &loc); std::strong_ordering operator<=>(const SourceLocation::Position &lhs, const SourceLocation::Position &rhs); std::strong_ordering operator<=>(const SourceLocation &lhs, const SourceLocation &rhs); bool operator==(const SourceLocation::Position &lhs, const SourceLocation::Position &rhs); bool operator==(const SourceLocation &lhs, const SourceLocation &rhs); class LocationChain; using Location = std::shared_ptr; // LocationChain is what is used to represent a canonical location in the AST. // It is a effectively a linked list of source locations, where each link is // annotated by some additional amount of context. // // Note that each LocationChain should be wrapped as a `shared_ptr`, and the // `Location` alias should be the way that it is referred to broadly. class LocationChain { public: struct Context { Context(Location &&loc) : loc(std::move(loc)) {}; std::stringstream msg; const Location loc; }; LocationChain(SourceLocation loc) : current(std::move(loc)) {}; // See above. std::string filename() const { return current.filename(); } std::string source_location() const { return current.source_location(); } std::vector source_context() const { return current.source_context(); } unsigned int line() const { return current.line(); } unsigned int column() const { return current.column(); } // This may be modified for a node, typically when copying. For example, when // copying a node you may automatically modify the location in order to // inject a parent that has "expanded from <...>". When these are displayed as // diagnostics, they are unpacked in reverse. std::optional parent; const SourceLocation current; std::vector contexts; }; Location operator+(const Location &orig, const Location &expansion); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/pass_manager.cpp000066400000000000000000000045731526721631600201330ustar00rootroot00000000000000#include "ast/pass_manager.h" #include "ast/context.h" #include "log.h" #include "util/result.h" namespace bpftrace::ast { std::atomic PassContext::next_type_id_; std::unordered_map PassContext::type_names_; PassContext::~PassContext() { // If there are any ordering constraints between passes, it's possible that // the pass state objects have encoded references and may use them in their // destructors. Therefore, we need to teardown the state in the opposite // order that it was added. while (!state_.empty()) { state_.pop_back(); } } bool PassContext::ok() const { int type_id = TypeId::type_id(); if (state_index_.contains(type_id)) { return get().diagnostics().ok(); } return true; } void PassContext::no_object_failure(int type_id) { // Rely on the type being available, otherwise how did we get here? LOG(BUG) << "get<" << type_names_[type_id] << "> failed; no object available."; __builtin_unreachable(); } PassManager &PassManager::add(Pass &&pass) { // Check that the inputs are all available. for (const int type_id : pass.inputs()) { if (!outputs_.contains(type_id)) { auto type_name = PassContext::type_names_[type_id]; LOG(BUG) << "Pass " << pass.name() << " requires output " << type_name << ", which is not available; it must be provided by a prior pass."; } } // Check that the registered output is unique. const int pass_id = passes_.size(); for (const int type_id : pass.outputs()) { if (outputs_.contains(type_id)) { auto &orig_pass = passes_[outputs_[type_id]]; auto type_name = PassContext::type_names_[type_id]; LOG(BUG) << "Pass " << pass.name() << " attempting to register output " << type_name << ", which is already registered by pass " << orig_pass.name() << "."; } // Register the output. outputs_.emplace(type_id, pass_id); } // Add the actual pass. passes_.emplace_back(std::move(pass)); return *this; } PassManager &PassManager::add(std::vector &&passes) { for (auto &pass : passes) { add(std::move(pass)); } return *this; } Result<> PassManager::foreach(std::function(const Pass &)> fn) { for (const auto &pass : passes_) { auto err = fn(pass); if (!err) { return err; } } return OK(); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/pass_manager.h000066400000000000000000000273361526721631600176020ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include #include "util/result.h" #include "util/type_name.h" namespace bpftrace::ast { // PassContext holds the intermediate state of executing passes. // // This class is essentially a type-erased generic constant storage. class PassContext { public: ~PassContext(); PassContext() = default; PassContext(PassContext &&other) = default; // TypeId is a class which, when specialized, returns the type_id. This // works by storing a static variable for each specialization of the class, // which effectively memoizes an ID binding for the specific class. template struct TypeId { static int type_id() { // Register by dispatching via `type_name` for the passed type. This is // all going to be devirtualized most likely, but this does enforce that // the class passed at least implements the static method, which is // really all we can ask for. // // Note that the `static` here is doing all the heavy lifting; this is // ensuring that the compiler is linking this symbol at most once, and it // will be initialized at most once, giving us a unique identifier for // this particular type. static_assert(std::is_base_of_v, "type must be derived from State<...>"); static int type_id = PassContext::add_type(T::type_name()); return type_id; } }; // State is an object which is the result of some specific pass. // // Passes are allowed to mutate the AST, and produce intermediate results // that may be consumed by other passes. Each of these results must be a // State, and will be immutable once it is produced. class State { public: virtual ~State() = default; }; // get fetches the given type; which must have been previously stored. // // N.B. In the future, these objects should be made immutable. Right now, // this is preserved so that we can pass through the `BPFTrace` object which // is consumed by *most* passes in a read-write fashion. template T &get() const { int type_id = TypeId::type_id(); auto it = state_index_.find(type_id); if (it != state_index_.end()) { return static_cast(it->second.get()); } no_object_failure(type_id); } // has indicates whether the given state is present or not. template bool has() { int type_id = TypeId::type_id(); return state_index_.contains(type_id); } private: // for the failed lookup path, see above. [[noreturn]] static void no_object_failure(int type_id); // put emplaces the value into the map; it must not exist already. In general // this should not be called manually, it should only be called by individual // passes during execution (the `run` function below). template void put(T &&t) { int type_id = TypeId::type_id(); auto &pushed = state_.emplace_back(std::make_unique(std::move(t))); state_index_.emplace(type_id, *pushed); } // put can also provide an external reference for the map; its lifecycle is // managed outside the scope of the passes. While passes can produce results // that are references, this should be generally discouraged (and this // capability should eventually be removed). Like `put`, this should not be // called directly and should only be called by `run`, below. template void put(T &t) { int type_id = TypeId::type_id(); state_index_.emplace(type_id, t); } // Will register the given type id and the name, which is resolvable via // the `type_names_` map. This is called exclusively by `type_id` above. static int add_type(std::string &&type_name) { int type_id = next_type_id_++; type_names_[type_id] = std::move(type_name); return type_id; } // Provide a short-hand to determine: // - Whether the context contains an `ASTContext`, and, // - Whether this `ASTContext` has error diagnostics. // // If both of the above are true, then false is returned. This is a // convenience method provided for the `PassManager` below, as passes will // stop when an error diagnostic has been generated. bool ok() const; static std::atomic next_type_id_; static std::unordered_map type_names_; std::unordered_map> state_index_; std::vector> state_; friend class PassManager; friend class Pass; }; // State is the template class used for states that may be stored in a // PassContext. In order to consume or produce information in a given pass, // simply override this class with the desired type. // // For example: // // class Variables : State<"variables"> { // // my fields // }; // // The `Variables` class can then be stored in the pass context. template class State : public PassContext::State { public: static std::string type_name() { return name.str(); } }; // Pass is an arbitrary pass. // // It is permitted to produce either no output or a single output, which may be // wrapped in `Result`, and may consume zero, one or multiple inputs. // // In general, this type should be constructed automatically, e.g.: // // Pass CreateFooPass() { // return Pass::create("mypass", [](MyInput &input) { // return MyOutput(); // }); // } // // Pass functions must already return an `Result` instance. class Pass { public: Pass(const Pass &) = delete; Pass(Pass &&) = default; Pass &operator=(const Pass &) = delete; Pass &operator=(Pass &&) = default; // create is the standard Pass constructor. // // For convenience, this template is set up to match against lambdas, and the // partial specialization versions of `createFn` below are used to match // against the resulting std::function. (Of course, a std::function can also // be passed here and the same applies, but using a lambda is encouraged.) template static Pass create(const std::string &name, Func func) { std::function fn(func); return createFn(name, fn); } // run executes the pass. // // The inputs must be present in the context. Result<> run(PassContext &ctx) const { return fn_(ctx); } const std::string &name() const { return name_; } const std::vector &inputs() const { return inputs_; } const std::vector &outputs() const { return outputs_; } private: template static Pass createFn(const std::string &name, std::function(Inputs &...)> fn) { return createImpl(name, fn); } template static Pass createFn(const std::string &name, std::function fn) { // We need to ensure that the arguments are references, but can otherwise // simply wrap this in something that returns OK on the user's behalf. static_assert((std::is_reference_v && ...), "all arguments must be references"); if constexpr (std::is_same_v) { std::function(Inputs...)> wrap( [fn](Inputs... inputs) -> Result { fn(inputs...); return OK(); }); return createImpl(name, wrap); } else { std::function(Inputs...)> wrap( [fn](Inputs... inputs) -> Result { return fn(inputs...); }); return createImpl(name, wrap); } } template static Pass createImpl(const std::string &name, std::function(Inputs &...)> fn) { std::vector inputs = { PassContext::TypeId::type_id()... }; std::vector outputs; if constexpr (!std::is_same_v) { // Note that the Return value may be a reference, so we resolve the // `type_id` of the underlying type. The Input types are not references, // because of the way the template is constructed. outputs = { PassContext::TypeId>::type_id() }; } return Pass( name, std::move(inputs), std::move(outputs), [fn](PassContext &ctx) -> Result<> { // Extract a tuple of all input parameters, apply the function // and set the result. auto args = std::make_tuple(std::ref(ctx.get())...); auto result = std::apply(fn, args); if (!result) { return result.takeError(); } if constexpr (std::is_same_v) { return OK(); } else { static_assert( std::is_base_of_v>, "return value must be derived from State<...>"); if constexpr (std::is_reference_v) { // Add the external reference. ctx.put(*result); } else { // Just move the result. ctx.put(std::move(*result)); } return OK(); } }); } // N.B. external construction is done via `create`. using Fn = std::function(PassContext &ctx)>; Pass(std::string name, std::vector &&inputs, std::vector &&outputs, Fn fn) : name_(std::move(name)), inputs_(std::move(inputs)), outputs_(std::move(outputs)), fn_(std::move(fn)) { } std::string name_; std::vector inputs_; std::vector outputs_; Fn fn_; }; // PassManager holds passes in sequence. // // The PassManager is responsible for verifying the inputs and outputs of the // passes ahead of time, so that the produced graph is sound. class PassManager { public: // registers the given pass, adding to the current list. PassManager &add(Pass &&pass); // registers all the given passes. PassManager &add(std::vector &&passes); // foreach executes the given function on every pass. // // The first pass to encounter errors will result in execution stopping. All // warnings from all passes are collected. Result<> foreach(std::function(const Pass &)> fn); // put adds a pass which always pushes the given static data. template PassManager &put(T &t) { return add(Pass::create(T::type_name(), [&t]() -> T & { return t; })); } // run all registered passes. // // This is a canonical example of how to use `foreach` above, in many other // cases a direct call will be suitable. // // Even if the `PassContext` is returned, if an ASTContext is registered, the // user should ensure that no error diagnostics have been produced prior to // extracting state from the context. In this case, it is possible that not // all passes have been run, even if none produced an error. Result run() { PassContext ctx; auto err = foreach([&](auto &pass) -> Result<> { // See above: for convenience, once error diagnostics have been // registered, we skip all remaining passes. This helps to ensure that // users are not overwhelmed by diagnostics, and encodes a common pattern // without the need for explicit error plumbing. if (!ctx.ok()) return OK(); return pass.run(ctx); }); if (!err) { return err.takeError(); } return ctx; } private: // The set of registered passes, in order. std::vector passes_; // The set of registered outputs in aggregate for all other passes. Note that // this is filled in and automatically checked by add, above. The value of // this map is the index into `passes_` above. std::unordered_map outputs_; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/000077500000000000000000000000001526721631600162545ustar00rootroot00000000000000bpftrace-0.27.1/src/ast/passes/ap_probe_expansion.cpp000066400000000000000000000351601526721631600226400ustar00rootroot00000000000000#include "ast/passes/ap_probe_expansion.h" #include #include "ast/passes/attachpoint_passes.h" #include "ast/visitor.h" #include "bpftrace.h" #include "probe_matcher.h" #include "util/wildcard.h" namespace bpftrace::ast { class ExpansionAnalyser : public Visitor { public: ExpansionAnalyser(BPFtrace &bpftrace) : bpftrace_(bpftrace) { } ExpansionResult analyse(Program &program); using Visitor::visit; void visit(Probe &probe); void visit(AttachPoint &ap); void visit(Builtin &builtin); private: ExpansionResult result_; Probe *probe_ = nullptr; BPFtrace &bpftrace_; }; ExpansionResult ExpansionAnalyser::analyse(Program &program) { visit(program); return std::move(result_); } void ExpansionAnalyser::visit(Probe &probe) { probe_ = &probe; visit(probe.attach_points); visit(probe.block); } void ExpansionAnalyser::visit(AttachPoint &ap) { ExpansionType expansion = ExpansionType::NONE; switch (probetype(ap.provider)) { case ProbeType::kprobe: case ProbeType::kretprobe: // kprobe_multi does not support the "module:function" syntax so in case // a module is specified, always use full expansion if (util::has_wildcard(ap.target)) { expansion = ExpansionType::FULL; } else if (util::has_wildcard(ap.func)) { if (ap.target.empty() && bpftrace_.feature_->has_kprobe_multi()) expansion = ExpansionType::MULTI; else expansion = ExpansionType::FULL; } break; case ProbeType::uprobe: case ProbeType::uretprobe: // As the C++ language supports function overload, a given function name // (without parameters) could have multiple matches even when no // wildcards are used. if (util::has_wildcard(ap.func) || util::has_wildcard(ap.target) || ap.lang == "cpp") { if (bpftrace_.feature_->has_uprobe_multi()) expansion = ExpansionType::MULTI; else expansion = ExpansionType::FULL; } break; case ProbeType::fentry: case ProbeType::fexit: { if (ap.target == "bpf") { if (!ap.bpf_prog_id || util::has_wildcard(ap.func)) { expansion = ExpansionType::FULL; } break; } [[fallthrough]]; } case ProbeType::tracepoint: case ProbeType::rawtracepoint: if (util::has_wildcard(ap.target) || util::has_wildcard(ap.func)) expansion = ExpansionType::FULL; break; case ProbeType::usdt: // Always fully expand USDT probes as they may access args if (util::has_wildcard(ap.target) || util::has_wildcard(ap.ns) || ap.ns.empty() || util::has_wildcard(ap.func) || bpftrace_.pid().has_value()) { expansion = ExpansionType::FULL; } break; case ProbeType::iter: if (util::has_wildcard(ap.func)) expansion = ExpansionType::FULL; default: // No expansion support for the rest of the probe types. break; } if (expansion != ExpansionType::NONE) result_.set_expansion(ap, expansion); } void ExpansionAnalyser::visit(Builtin &builtin) { if (!probe_) return; if (builtin.ident == "__builtin_probe") { for (auto *ap : probe_->attach_points) result_.set_expansion(*ap, ExpansionType::FULL); } } class SessionExpander : public Visitor { public: explicit SessionExpander(ASTContext &ast, BPFtrace &bpftrace, ExpansionResult &expansion_result) : ast_(ast), bpftrace_(bpftrace), expansion_result_(expansion_result) { } using Visitor::visit; void visit(Program &prog); void visit(Probe &probe); Probe expand(Probe &entry, Probe &exit); private: bool is_session_attach_point(AttachPoint &ap); Probe *find_matching_retprobe(Probe &probe); ASTContext &ast_; const BPFtrace &bpftrace_; ExpansionResult &expansion_result_; ProbeList probes_to_erase_; }; bool SessionExpander::is_session_attach_point(AttachPoint &ap) { auto provider = probetype(ap.provider); if (provider != ProbeType::kprobe && provider != ProbeType::kretprobe) return false; auto expansion = expansion_result_.get_expansion(ap); if (expansion == ExpansionType::MULTI) return true; return expansion == ExpansionType::NONE && bpftrace_.feature_->has_kprobe_multi() && ap.target.empty() && ap.func_offset == 0 && ap.address == 0 && !util::has_wildcard(ap.func); } Probe *SessionExpander::find_matching_retprobe(Probe &probe) { ProbeList retprobes; AttachPoint *ap = probe.attach_points[0]; // Search for a probe which: // - has a single kretprobe attach point // - attaches to the same target and function as probe // - is multi-expanded (session expansion uses the same attach mechanism) // - is not already scheduled for erasure // - is eligible for session expansion std::ranges::copy_if( ast_.root->probes, std::back_inserter(retprobes), [&](Probe *other) { return other->attach_points.size() == 1 && probetype(other->attach_points[0]->provider) == ProbeType::kretprobe && is_session_attach_point(*other->attach_points[0]) && other->attach_points[0]->target == ap->target && other->attach_points[0]->func == ap->func && std::ranges::find(probes_to_erase_, other) == probes_to_erase_.end(); }); // If there's not exactly one match, we don't know how to do session expansion if (retprobes.size() != 1) { return nullptr; } return retprobes[0]; } void SessionExpander::visit(Probe &probe) { // If the probe has a single session-eligible kprobe attach point, check if // there's another probe with a single session-eligible kretprobe attach // point with the same target. If so, perform session expansion by merging // the two probes together. if (probe.attach_points.size() == 1 && probetype(probe.attach_points[0]->provider) == ProbeType::kprobe && is_session_attach_point(*probe.attach_points[0])) { Probe *retprobe = find_matching_retprobe(probe); if (!retprobe) return; if (!bpftrace_.feature_->has_kprobe_session()) return; AttachPointList attach_points = probe.attach_points; auto *ctx_builtin = ast_.make_node(probe.block->loc, "ctx"); auto *void_type = ast_.make_node(probe.block->loc, ParsedType::Kind::Identifier, "void"); auto *void_ptr_type = ast_.make_node(probe.block->loc, void_type); auto *typeof_node = ast_.make_node(probe.block->loc, void_ptr_type); auto *ctx_cast = ast_.make_node(probe.block->loc, typeof_node, ctx_builtin); ExpressionList call_args; call_args.emplace_back(ctx_cast); auto *expr = ast_.make_node( probe.block->loc, ast_.make_node(probe.block->loc, "__session_is_return", call_args), retprobe->block, probe.block); auto *stmt = ast_.make_node(probe.block->loc, expr); probe.block = ast_.make_node(probe.block->loc, StatementList({ stmt }), ast_.make_node( probe.block->loc)); expansion_result_.set_expansion(*probe.attach_points[0], ExpansionType::SESSION); probes_to_erase_.push_back(retprobe); } } void SessionExpander::visit(Program &prog) { Visitor::visit(prog); for (auto *retprobe : probes_to_erase_) { std::erase(prog.probes, retprobe); } } class ProbeAndApExpander : public Visitor { public: ProbeAndApExpander(ASTContext &ast, BPFtrace &bpftrace, FunctionInfo &func_info, ExpansionResult &result) : ast_(ast), bpftrace_(bpftrace), func_info_(func_info), result_(result), probe_matcher_(&bpftrace, func_info.kernel_info(), func_info.user_info()) { } void expand(); using Visitor::visit; void visit(Program &prog); void visit(AttachPointList &aps); private: uint64_t probe_count_ = 0; ASTContext &ast_; BPFtrace &bpftrace_; FunctionInfo &func_info_; ExpansionResult &result_; ProbeMatcher probe_matcher_; }; void ProbeAndApExpander::expand() { visit(*ast_.root); } void ProbeAndApExpander::visit(Program &prog) { // Expand attachpoints first. Visitor::visit(prog); // Expand probes. ProbeList new_probe_list; for (auto *probe : prog.probes) { if (probe->attach_points.size() < 2) { new_probe_list.emplace_back(probe); } else { for (auto *ap : probe->attach_points) { auto *new_probe = ast_.make_node( probe->loc, AttachPointList{ ap }, clone(ast_, probe->block->loc, probe->block)); new_probe_list.emplace_back(new_probe); } } } prog.probes = std::move(new_probe_list); } void ProbeAndApExpander::visit(AttachPointList &aps) { const auto max_bpf_progs = bpftrace_.config_->max_bpf_progs; AttachPointList new_aps; for (auto *ap : aps) { auto probe_type = probetype(ap->provider); auto expansion = result_.get_expansion(*ap); switch (expansion) { case ExpansionType::FULL: { auto matches = probe_matcher_.get_matches_for_ap(*ap); probe_count_ += matches.size(); if (probe_count_ > max_bpf_progs) { auto &err = ap->addError(); err << "Your program is trying to generate more than " << std::to_string(probe_count_) << " BPF programs, which exceeds the current limit of " << std::to_string(max_bpf_progs); err.addHint() << "You can increase the limit through the " "BPFTRACE_MAX_BPF_PROGS " "environment variable."; return; } for (const auto &match : matches) { new_aps.push_back(ap->create_expansion_copy(ast_, match)); } break; } case ExpansionType::SESSION: case ExpansionType::MULTI: { auto matches = probe_matcher_.get_matches_for_ap(*ap); if (util::has_wildcard(ap->target)) { // If we have a wildcard in the target path, we need to generate one // attach point per expanded target assert(probe_type == ProbeType::uprobe || probe_type == ProbeType::uretprobe); std::unordered_map new_aps_by_target; for (const auto &func : matches) { auto *match_ap = ap->create_expansion_copy(ast_, func); // Reset the original (possibly wildcarded) function name auto expanded_func = match_ap->func; match_ap->func = ap->func; auto new_ap = new_aps_by_target.emplace(match_ap->target, match_ap); result_.add_expanded_func(*new_ap.first->second, match_ap->target + ":" + expanded_func); } for (auto &[_, new_ap] : new_aps_by_target) new_aps.push_back(std::move(new_ap)); } else if (!matches.empty()) { result_.set_expanded_funcs(*ap, std::move(matches)); new_aps.push_back(ap); } break; } case ExpansionType::NONE: { auto pt = probetype(ap->provider); bool is_kprobe = pt == ProbeType::kprobe || pt == ProbeType::kretprobe; if (is_kprobe) { // Construct a string containing "module:function." // Also log a warning or throw an error if the module doesn't exist, // before attempting to attach. // Note that we do not pass vmlinux, if it is specified. const std::string &funcname = ap->func; const std::string &modname = ap->target; if ((!modname.empty()) && modname != "vmlinux") { if (!func_info_.kernel_info().is_module_loaded(modname)) { ap->addError() << "specified module " + modname + " in probe " + ap->provider + ":" + modname + ":" + funcname + " is not loaded."; } } if (ap->address != 0) { new_aps.push_back(ap); // skip pre-filtering if probing by address break; } } // We do this pre-filtering primarily for probes where we have to look // up `args` or `retval` in BTF (or Dwarf for uprobes/uretprobes) as we // fail hard if those `args` aren't available as we can't resolve the // type and continue with type resolution. In order not to fail hard and // respsect the missing_probes config we filter out early - notice // kprobes/kretprobes can bypass this by utilizing `--unsafe` for // situations when the user wants to ignore the // available_filter_functions file or it doesn't exist on the system auto matches = probe_matcher_.get_matches_for_ap(*ap); if (matches.empty() && (pt != ProbeType::watchpoint)) { if (is_kprobe && !bpftrace_.safe_mode_) { new_aps.push_back(ap); break; } const auto missing_probes = bpftrace_.config_->missing_probes; std::string msg = "No matches for " + probetypeName(probetype(ap->provider)) + " " + (ap->target.empty() ? "" : ap->target + ":") + ap->func; if (missing_probes == ConfigMissingProbes::warn) { ap->addWarning() << msg << ". Skipping."; } else if (missing_probes == ConfigMissingProbes::error) { ap->addError() << msg << "."; } } else { new_aps.push_back(ap); } break; } } } aps = new_aps; } Pass CreateProbeAndApExpansionPass() { auto fn = [](ASTContext &ast, BPFtrace &bpftrace, FunctionInfo &func_info) { ExpansionAnalyser analyser(bpftrace); auto result = analyser.analyse(*ast.root); SessionExpander session_expander(ast, bpftrace, result); session_expander.visit(*ast.root); ProbeAndApExpander expander(ast, bpftrace, func_info, result); expander.expand(); return result; }; return Pass::create("ProbeAndApExpansion", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/ap_probe_expansion.h000066400000000000000000000041511526721631600223010ustar00rootroot00000000000000#pragma once #include #include "ast/ast.h" #include "ast/pass_manager.h" namespace bpftrace::ast { // There are 3 kinds of attach point expansion: // - full expansion - separate LLVM function is generated for each match // - multi expansion - one LLVM function and BPF program is generated for all // matches, the list of expanded functions is attached to // the BPF program using the k(u)probe.multi mechanism // - session expansion - extension of the multi expansion when a single BPF // program is shared for both the entry and the exit probe // (when they are both attached to the same attach points) // using the kprobe.session mechanism enum class ExpansionType { NONE, FULL, MULTI, SESSION, }; class ExpansionResult : public State<"expansions"> { public: ExpansionResult() = default; ExpansionResult(const ExpansionResult &) = delete; ExpansionResult &operator=(const ExpansionResult &) = delete; ExpansionResult(ExpansionResult &&) = default; ExpansionResult &operator=(ExpansionResult &&) = default; void set_expansion(AttachPoint &ap, ExpansionType type) { expansions[&ap] = type; } ExpansionType get_expansion(AttachPoint &ap) { auto exp = expansions.find(&ap); if (exp == expansions.end()) return ExpansionType::NONE; return exp->second; } void set_expanded_funcs(AttachPoint &ap, std::set funcs) { expanded_funcs.emplace(&ap, std::move(funcs)); } void add_expanded_func(AttachPoint &ap, const std::string &func) { auto funcs = expanded_funcs.emplace(&ap, std::set()); funcs.first->second.insert(func); } std::set get_expanded_funcs(AttachPoint &ap) { auto funcs = expanded_funcs.find(&ap); if (funcs == expanded_funcs.end()) return {}; return funcs->second; } private: std::unordered_map expansions; std::unordered_map> expanded_funcs; }; Pass CreateProbeAndApExpansionPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/args_resolver.cpp000066400000000000000000000067211526721631600216430ustar00rootroot00000000000000#include #include #include "arch/arch.h" #include "ast/passes/args_resolver.h" #include "ast/passes/attachpoint_passes.h" #include "ast/passes/tracepoint_format_parser.h" #include "ast/visitor.h" #include "bpftrace.h" #include "dwarf_parser.h" #include "probe_matcher.h" #include "probe_types.h" #include "util/result.h" namespace bpftrace::ast { char ArgParseError::ID; void ArgParseError::log(llvm::raw_ostream &OS) const { if (arg_name_.empty()) { OS << "Could not parse arguments of \"" << probe_name_ << "\": " << detail_; } else { OS << "Could not parse argument \"" << arg_name_ << "\" of \"" << probe_name_ << "\": " << detail_; } } namespace { class ArgsResolver : public Visitor { public: explicit ArgsResolver(BPFtrace &bpftrace) : bpftrace_(bpftrace) {}; using Visitor::visit; void visit(Builtin &builtin); void visit(Probe &probe); private: void resolve_args(Probe &probe); Result> resolve_args(const AttachPoint &ap); BPFtrace &bpftrace_; Probe *probe_ = nullptr; }; } // namespace void ArgsResolver::visit(Builtin &builtin) { if (builtin.ident == "args" || builtin.ident == "__builtin_retval") { resolve_args(*probe_); } } Result> ArgsResolver::resolve_args( const AttachPoint &ap) { auto probe_type = probetype(ap.provider); switch (probe_type) { case ProbeType::fentry: case ProbeType::fexit: return bpftrace_.btf_->resolve_args(ap.func, probe_type == ProbeType::fexit, false); case ProbeType::rawtracepoint: return bpftrace_.btf_->resolve_raw_tracepoint_args(ap.func); case ProbeType::tracepoint: { TracepointFormatParser parser(ap.target, ap.func, bpftrace_); auto ok = parser.parse_format_file(); if (!ok) return ok.takeError(); return parser.get_tracepoint_struct(); } case ProbeType::uprobe: { Dwarf *dwarf = bpftrace_.get_dwarf(ap.target); if (dwarf) { auto args = dwarf->resolve_args(ap.func); if (args && args->fields.size() > arch::Host::arguments().size()) { return make_error( ap.name(), "\'args\' builtin is not supported for probes with stack-passed " "arguments."); } return args; } return make_error(ap.name(), "no debuginfo found for " + ap.target); } default: return nullptr; } } void ArgsResolver::resolve_args(Probe &probe) { if (probe.attach_points.empty()) return; // Everything should be expanded by now assert(probe.attach_points.size() == 1); auto *ap = probe.attach_points.at(0); auto probe_args = resolve_args(*ap); if (!probe_args) { ap->addError() << probe_args.takeError(); return; } auto type_name = probe.args_typename(); if (!type_name) { ap->addError() << "Cannot resolve ambiguous types."; return; } bpftrace_.structs.Add(*type_name, std::move(*probe_args)); } void ArgsResolver::visit(Probe &probe) { probe_ = &probe; visit(probe.block); } Pass CreateArgsResolverPass() { auto fn = [](ASTContext &ast, BPFtrace &b) { ArgsResolver resolver(b); resolver.visit(ast.root); }; return Pass::create("ArgsResolver", fn); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/args_resolver.h000066400000000000000000000015741526721631600213110ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" #include "probe_types.h" namespace bpftrace::ast { class ArgParseError : public ErrorInfo { public: static char ID; ArgParseError(std::string probe_name, std::string &&detail) : probe_name_(std::move(probe_name)), detail_(std::move(detail)) {}; ArgParseError(std::string_view probe_name, std::string &&detail) : ArgParseError(std::string(probe_name), std::move(detail)) {}; ArgParseError(std::string probe_name, std::string arg_name, std::string &&detail) : probe_name_(std::move(probe_name)), arg_name_(std::move(arg_name)), detail_(std::move(detail)) {}; void log(llvm::raw_ostream &OS) const override; private: std::string probe_name_; std::string arg_name_; std::string detail_; }; Pass CreateArgsResolverPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/attachpoint_passes.cpp000066400000000000000000001073321526721631600226620ustar00rootroot00000000000000#include #include #include #include #include #include #include "arch/arch.h" #include "ast/ast.h" #include "ast/context.h" #include "ast/helpers.h" #include "ast/passes/attachpoint_passes.h" #include "ast/visitor.h" #include "probe_matcher.h" #include "symbols/kernel.h" #include "util/int_parser.h" #include "util/paths.h" #include "util/strings.h" #include "util/system.h" #include "util/wildcard.h" namespace bpftrace::ast { class AttachPointChecker : public Visitor { public: explicit AttachPointChecker(BPFtrace &bpftrace, FunctionInfo &func_info_state) : bpftrace_(bpftrace), func_info_state_(func_info_state) {}; using Visitor::visit; void visit(AttachPoint &ap); private: BPFtrace &bpftrace_; FunctionInfo &func_info_state_; std::unordered_map test_locs_; std::unordered_map benchmark_locs_; }; void AttachPointChecker::visit(AttachPoint &ap) { if (ap.provider == "kprobe" || ap.provider == "kretprobe") { if (ap.func.empty() && ap.address == 0) ap.addError() << "kprobes should be attached to a function or an address"; // Warn if user tries to attach to a non-traceable function if (bpftrace_.config_->missing_probes != ConfigMissingProbes::ignore && !util::has_wildcard(ap.func) && !ap.func.empty() && !func_info_state_.kernel_info().is_traceable(ap.func)) { ap.addWarning() << ap.func << " is not traceable (either non-existing, inlined, " "or marked as " "\"notrace\"); attaching to it will likely fail"; } } else if (ap.provider == "uprobe" || ap.provider == "uretprobe") { if (ap.target.empty()) ap.addError() << ap.provider << " should have a target"; // --unsafe allows attaching to arbitrary files, and 0 is a valid offset if (ap.func.empty() && ap.address == 0 && bpftrace_.safe_mode_ && (ap.source_file.empty() || ap.line_num == 0)) ap.addError() << ap.provider << " should be attached to a function" << (bpftrace_.get_dwarf(ap) ? ", address, or source file and line (using DWARF)" : " and/or address"); if (!ap.lang.empty() && !is_supported_lang(ap.lang)) ap.addError() << "unsupported language type: " << ap.lang; if (ap.provider == "uretprobe" && ap.func_offset != 0) ap.addError() << "uretprobes can not be attached to a function offset"; auto get_paths = [&]() -> Result> { const auto pid = bpftrace_.pid(); if (ap.target == "*") { if (pid.has_value()) return util::get_mapped_paths_for_pid(*pid); else return util::get_mapped_paths_for_running_pids(); } else { return util::resolve_binary_path(ap.target, pid, bpftrace_.safe_mode_); } }; auto paths = get_paths(); if (!paths) { // There was an error during path resolution. ap.addError() << "error finding uprobe target: " << paths.takeError(); } else { switch (paths->size()) { case 0: ap.addError() << "uprobe target file '" << ap.target << "' does not exist or is not executable"; break; case 1: // Replace the glob at this stage only if this is *not* a wildcard, // otherwise we rely on the probe matcher. This is not going through // any interfaces that can be properly mocked. if (ap.target.find("*") == std::string::npos) ap.target = paths->front(); break; default: // If we are doing a PATH lookup (ie not glob), we follow shell // behavior and take the first match. // Otherwise we keep the target with glob, it will be expanded later if (ap.target.find("*") == std::string::npos) { ap.addWarning() << "attaching to uprobe target file '" << paths->front() << "' but matched " << std::to_string(paths->size()) << " binaries"; ap.target = paths->front(); } } } } else if (ap.provider == "usdt") { bpftrace_.has_usdt_ = true; if (ap.func.empty()) ap.addError() << "usdt probe must have a target function or wildcard"; if (!ap.target.empty() && !(bpftrace_.pid().has_value() && util::has_wildcard(ap.target))) { auto paths = util::resolve_binary_path(ap.target, bpftrace_.pid()); switch (paths.size()) { case 0: ap.addError() << "usdt target file '" << ap.target << "' does not exist or is not executable"; break; case 1: // See uprobe, above. if (ap.target.find("*") == std::string::npos) ap.target = paths.front(); break; default: // See uprobe, above. if (ap.target.find("*") == std::string::npos) { ap.addWarning() << "attaching to usdt target file '" << paths.front() << "' but matched " << std::to_string(paths.size()) << " binaries"; ap.target = paths.front(); } } } const auto pid = bpftrace_.pid(); if (pid.has_value()) { auto ok = func_info_state_.user_info().usdt_probes_for_pid(*pid); if (!ok) { ap.addError() << ok.takeError(); } } else if (ap.target == "*") { auto ok = func_info_state_.user_info().usdt_probes_for_all_pids(); if (!ok) { ap.addError() << ok.takeError(); } } else if (!ap.target.empty()) { for (auto &path : util::resolve_binary_path(ap.target)) { auto ok = func_info_state_.user_info().usdt_probes_for_path(path); if (!ok) { ap.addError() << ok.takeError(); } } } else { ap.addError() << "usdt probe must specify at least path or pid to " "probe. To target " "all paths/pids set the path to '*'."; } } else if (ap.provider == "tracepoint") { if (ap.target.empty() || ap.func.empty()) ap.addError() << "tracepoint probe must have a target"; } else if (ap.provider == "rawtracepoint") { if (ap.func.empty()) ap.addError() << "rawtracepoint should be attached to a function"; if (!bpftrace_.has_btf_data()) { ap.addError() << "rawtracepoints require kernel BTF. Try using a " "'tracepoint' instead."; } } else if (ap.provider == "profile") { if (ap.target.empty()) { ap.addError() << "profile probe must have unit of time"; } else { if (!TIME_UNITS.contains(ap.target)) ap.addError() << ap.target << " is not an accepted unit of time"; if (!ap.func.empty()) ap.addError() << "profile probe must have an integer frequency"; else if (ap.freq <= 0) ap.addError() << "profile frequency should be a positive integer"; } } else if (ap.provider == "interval") { if (ap.target.empty()) { ap.addError() << "interval probe must have unit of time"; } else { if (!TIME_UNITS.contains(ap.target)) ap.addError() << ap.target << " is not an accepted unit of time"; if (!ap.func.empty()) ap.addError() << "interval probe must have an integer frequency"; else if (ap.freq <= 0) ap.addError() << "interval frequency should be a positive integer"; } } else if (ap.provider == "software") { if (ap.target.empty()) { ap.addError() << "software probe must have a software event name"; } else { if (!util::has_wildcard(ap.target) && !ap.ignore_invalid) { bool found = false; for (const auto &probeListItem : SW_PROBE_LIST) { if (ap.target == probeListItem.path || (!probeListItem.alias.empty() && ap.target == probeListItem.alias)) { found = true; break; } } if (!found) { ap.addError() << ap.target << " is not a software probe"; } } else if (util::has_wildcard(ap.target)) { ap.addError() << "wildcards are not allowed for software probe type"; } } if (!ap.func.empty()) { ap.addError() << "software probe can only have an integer count"; } else if (ap.freq < 0) { ap.addError() << "software count should be a positive integer"; } } else if (ap.provider == "watchpoint") { if (!ap.address) { ap.addError() << "watchpoint must be attached to a non-zero address"; } if (ap.len != 1 && ap.len != 2 && ap.len != 4 && ap.len != 8) { ap.addError() << "watchpoint length must be one of (1,2,4,8)"; } if (ap.mode.empty()) ap.addError() << "watchpoint mode must be combination of (r,w,x)"; std::ranges::sort(ap.mode); for (const char c : ap.mode) { if (c != 'r' && c != 'w' && c != 'x') ap.addError() << "watchpoint mode must be combination of (r,w,x)"; } for (size_t i = 1; i < ap.mode.size(); ++i) { if (ap.mode[i - 1] == ap.mode[i]) ap.addError() << "watchpoint modes may not be duplicated"; } const auto &modes = arch::Host::watchpoint_modes(); if (!modes.contains(ap.mode)) { if (modes.empty()) { // There are no valid modes. ap.addError() << "watchpoints not supported"; } else { // Build a suitable error with hint. auto &err = ap.addError(); err << "invalid watchpoint mode: " << ap.mode; err.addHint() << "supported modes: " << util::str_join(std::vector(modes.begin(), modes.end()), ","); } } } else if (ap.provider == "hardware") { if (ap.target.empty()) { ap.addError() << "hardware probe must have a hardware event name"; } else { if (!util::has_wildcard(ap.target) && !ap.ignore_invalid) { bool found = false; for (const auto &probeListItem : HW_PROBE_LIST) { if (ap.target == probeListItem.path || (!probeListItem.alias.empty() && ap.target == probeListItem.alias)) { found = true; break; } } if (!found) { ap.addError() << ap.target + " is not a hardware probe"; } } else if (util::has_wildcard(ap.target)) { ap.addError() << "wildcards are not allowed for hardware probe type"; } } if (!ap.func.empty()) { ap.addError() << "hardware probe can only have an integer count"; } else if (ap.freq < 0) { ap.addError() << "hardware frequency should be a positive integer"; } } else if (ap.provider == "begin" || ap.provider == "end") { if (!ap.target.empty() || !ap.func.empty()) { ap.addError() << "begin/end probes should not have a target"; } } else if (ap.provider == "self") { if (ap.target == "signal") { if (!SIGNALS.contains(ap.func)) ap.addError() << ap.func << " is not a supported signal"; return; } ap.addError() << ap.target << " is not a supported trigger"; } else if (ap.provider == "test") { if (ap.target.empty()) ap.addError() << "test probes must have a name"; auto it = test_locs_.find(ap.target); if (it != test_locs_.end()) { auto &err = ap.addError(); err << "\"" + ap.target + "\"" << " was used as the name for more than one TEST probe"; err.addContext(it->second) << "this is the other instance"; } test_locs_.emplace(ap.target, ap.loc); } else if (ap.provider == "bench") { if (ap.target.empty()) ap.addError() << "bench probes must have a name"; auto it = benchmark_locs_.find(ap.target); if (it != benchmark_locs_.end()) { auto &err = ap.addError(); err << "\"" + ap.target + "\"" << " was used as the name for more than one BENCH probe"; err.addContext(it->second) << "this is the other instance"; } benchmark_locs_.emplace(ap.target, ap.loc); } else if (ap.provider == "fentry" || ap.provider == "fexit") { if (ap.func.empty()) ap.addError() << "fentry/fexit should specify a function"; } else if (ap.provider == "iter") { if (bpftrace_.btf_->has_data() && !bpftrace_.btf_->get_all_iters().contains(ap.func)) { ap.addError() << "iter " << ap.func << " not available for your kernel version."; } if (ap.func.empty()) ap.addError() << "iter should specify a iterator's name"; } else { ap.addError() << "Invalid provider: '" << ap.provider << "'"; } } AttachPointParser::State AttachPointParser::argument_count_error( int expected, std::optional expected2) { // Subtract one for the probe type (eg kprobe) int found = parts_.size() - 1; errs_ << ap_->provider << " probe type requires " << expected; if (expected2.has_value()) { errs_ << " or " << *expected2; } errs_ << " arguments, found " << found << std::endl; return INVALID; } AttachPointParser::AttachPointParser(ASTContext &ctx, BPFtrace &bpftrace, FunctionInfo &func_info_state) : ctx_(ctx), bpftrace_(bpftrace), func_info_state_(func_info_state) { } void AttachPointParser::parse() { if (!ctx_.root) return; for (Probe *probe : ctx_.root->probes) { for (size_t i = 0; i < probe->attach_points.size(); ++i) { auto *ap_ptr = probe->attach_points[i]; auto &ap = *ap_ptr; new_attach_points.clear(); State s = parse_attachpoint(ap); if (s == INVALID) { ap.addError() << errs_.str(); } else if (s == SKIP || s == NEW_APS) { // Remove the current attach point probe->attach_points.erase(probe->attach_points.begin() + i); i--; if (s == NEW_APS) { // The removed attach point is replaced by new ones probe->attach_points.insert(probe->attach_points.end(), new_attach_points.begin(), new_attach_points.end()); } } // clear error buffer between attach points to prevent non-fatal errors // from being carried over and printed on the next fatal error errs_.str({}); } auto it = std::ranges::remove_if(probe->attach_points, [](const AttachPoint *ap) { return ap->provider.empty(); }); probe->attach_points.erase(it.begin(), it.end()); if (probe->attach_points.empty()) { const auto missing_probes = bpftrace_.config_->missing_probes; if (missing_probes == ConfigMissingProbes::error) { probe->addError() << "No attach points for probe"; } } has_iter_ap_ = false; // reset for each probe } } AttachPointParser::State AttachPointParser::parse_attachpoint(AttachPoint &ap) { ap_ = ≈ parts_.clear(); if (State s = lex_attachpoint(*ap_)) return s; if (parts_.empty()) { errs_ << "Invalid attachpoint definition" << std::endl; return INVALID; } auto &front = parts_.front(); if (front.empty()) { // Do not fail on empty attach point, could be just a trailing comma ap_->provider = ""; return OK; } // First, if there is a '=' in the provider, then this is treated // as a deliminator for the user-provided name. auto pos = front.find('='); if (pos != std::string::npos && pos != front.size() - 1) { ap.user_provided_name.emplace(front.substr(0, pos)); front = front.substr(pos + 1); } std::set probe_types; if (util::has_wildcard(front)) { // Single argument listing looks at all relevant probe types std::string probetype_query = (parts_.size() == 1) ? "*" : front; // Probe type expansion // If PID is specified or the second part of the attach point is a path // (contains '/'), use userspace probe types. // Otherwise, use kernel probe types. ProbeMatcher probe_matcher(&bpftrace_, func_info_state_.kernel_info(), func_info_state_.user_info()); if (bpftrace_.pid().has_value() || (parts_.size() >= 2 && parts_[1].find('/') != std::string::npos)) { probe_types = probe_matcher.expand_probetype_userspace(probetype_query); } else { probe_types = probe_matcher.expand_probetype_kernel(probetype_query); } } else { probe_types = { front }; } if (probe_types.empty()) { if (util::has_wildcard(front)) errs_ << "No probe type matched for " << front << std::endl; else errs_ << "Invalid probe type: " << front << std::endl; return INVALID; } else if (probe_types.size() > 1) { // If the probe type string matches more than 1 probe, create a new set of // attach points (one for every match) that will replace the original one. for (const auto &probe_type : probe_types) { std::string raw_input = ap.raw_input; if (parts_.size() > 1) util::erase_prefix(raw_input); raw_input = probe_type + ":" + raw_input; // New attach points have ignore_invalid set to true - probe types for // which raw_input has invalid number of parts will be ignored (instead // of throwing an error). These will have the same associated location. new_attach_points.push_back( ctx_.make_node(ap.loc, raw_input, true)); } return NEW_APS; } ap.provider = expand_probe_name(*probe_types.begin()); switch (probetype(ap.provider)) { case ProbeType::special: return special_parser(); case ProbeType::test: return test_parser(); case ProbeType::benchmark: return benchmark_parser(); case ProbeType::kprobe: return kprobe_parser(); case ProbeType::kretprobe: return kretprobe_parser(); case ProbeType::uprobe: return uprobe_parser(); case ProbeType::uretprobe: return uretprobe_parser(); case ProbeType::usdt: return usdt_parser(); case ProbeType::tracepoint: return tracepoint_parser(); case ProbeType::profile: return profile_parser(); case ProbeType::interval: return interval_parser(); case ProbeType::software: return software_parser(); case ProbeType::hardware: return hardware_parser(); case ProbeType::watchpoint: return watchpoint_parser(); case ProbeType::fentry: case ProbeType::fexit: return fentry_parser(); case ProbeType::iter: return iter_parser(); case ProbeType::rawtracepoint: return raw_tracepoint_parser(); case ProbeType::invalid: errs_ << "Invalid probe type: " << ap.provider << std::endl; return INVALID; } __builtin_unreachable(); } AttachPointParser::State AttachPointParser::lex_attachpoint( const AttachPoint &ap) { std::string raw = ap.raw_input; std::vector ret; bool in_quotes = false; std::string argument; for (size_t idx = 0; idx < raw.size(); ++idx) { if ((raw[idx] == ':' || raw[idx] == '@') && !in_quotes) { parts_.emplace_back(std::move(argument)); // The standard says an std::string in moved-from state is in // valid but unspecified state, so clear() to be safe argument.clear(); if (raw[idx] == '@') { parts_.emplace_back("@"); } } else if (raw[idx] == '"') { in_quotes = !in_quotes; // Handle escaped characters in a string } else if (in_quotes && raw[idx] == '\\' && (idx + 1 < raw.size())) { argument += raw[idx + 1]; ++idx; } else if (!in_quotes && raw[idx] == '$') { size_t i = idx + 1; size_t len = 0; while (i < raw.size() && std::isdigit(raw[i])) { if (len == 0 && raw[i] == '0') { break; } len++; i++; } std::string param_idx_str; if (len == 0 && (idx + 1) < raw.size()) { param_idx_str = raw.substr(idx + 1, 1); errs_ << "invalid trailing character for positional param: " << param_idx_str << ". Try quoting this entire part if this is intentional e.g. \"$" << param_idx_str << "\"."; return State::INVALID; } param_idx_str = raw.substr(idx + 1, len); auto param_idx = util::to_uint(param_idx_str, 10); if (!param_idx) { errs_ << "positional parameter is not valid: " << param_idx.takeError() << std::endl; return State::INVALID; } // Expand the positional param in-place and decrement idx so that the next // iteration takes the first char of the expansion raw = raw.substr(0, idx) + bpftrace_.get_param(*param_idx) + raw.substr(i); idx--; } else { argument += raw[idx]; } } // Add final argument // // There will always be text in `argument` unless the AP definition // ended in a ':' which we will treat as an empty argument. parts_.emplace_back(std::move(argument)); return State::OK; } AttachPointParser::State AttachPointParser::special_parser() { // Can only have reached here if provider is `begin` or `end` or `self` assert(ap_->provider == "begin" || ap_->provider == "end" || ap_->provider == "self"); if (ap_->provider == "begin" || ap_->provider == "end") { if (parts_.size() == 2 && parts_[1] == "*") parts_.pop_back(); if (parts_.size() != 1) { return argument_count_error(0); } } else if (ap_->provider == "self") { if (parts_.size() != 3) { return argument_count_error(2); } ap_->target = parts_[1]; ap_->func = parts_[2]; } return OK; } AttachPointParser::State AttachPointParser::test_parser() { // Can only have reached here if provider is `test` assert(ap_->provider == "test"); if (parts_.size() != 2) { return argument_count_error(1); } ap_->target = parts_[1]; return OK; } AttachPointParser::State AttachPointParser::benchmark_parser() { // Can only have reached here if provider is `bench` assert(ap_->provider == "bench"); if (parts_.size() != 2) { return argument_count_error(1); } ap_->target = parts_[1]; return OK; } AttachPointParser::State AttachPointParser::kprobe_parser(bool allow_offset) { auto num_parts = parts_.size(); if (num_parts != 2 && num_parts != 3) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(1, 2); } auto func_idx = 1; if (num_parts == 3) { ap_->target = parts_[1]; func_idx = 2; } // Handle kprobe:func+0x100 case auto plus_count = std::count(parts_[func_idx].cbegin(), parts_[func_idx].cend(), '+'); if (plus_count) { if (!allow_offset) { errs_ << "Offset not allowed" << std::endl; return INVALID; } if (plus_count != 1) { errs_ << "Cannot take more than one offset" << std::endl; return INVALID; } auto offset_parts = util::split_string(parts_[func_idx], '+', true); if (offset_parts.size() != 2) { errs_ << "Invalid offset" << std::endl; return INVALID; } ap_->func = offset_parts[0]; auto res = util::to_uint(offset_parts[1]); if (!res) { errs_ << "Invalid offset: " << res.takeError() << std::endl; return INVALID; } ap_->func_offset = *res; } // Default case (eg "kprobe:(addr|func)") else { auto res = util::to_uint(parts_[func_idx]); if (res) { // We don't check whether the address is valid (it's passed directly to // the kernel), so allow this only in unsafe mode. if (bpftrace_.safe_mode_) { errs_ << "Probing by address requires --unsafe" << std::endl; return INVALID; } ap_->address = *res; } else { ap_->func = parts_[func_idx]; consumeError(std::move(res)); // ignore the parse error } } return OK; } AttachPointParser::State AttachPointParser::kretprobe_parser() { return kprobe_parser(false); } AttachPointParser::State AttachPointParser::uprobe_parser(bool allow_offset, bool allow_src_loc) { const auto pid = bpftrace_.pid(); if (pid.has_value() && (parts_.size() == 2 || (parts_.size() == 3 && is_supported_lang(parts_[1])))) { // For PID, the target may be skipped parts_.insert(parts_.begin() + 1, ""); auto target = util::get_pid_exe(*pid); parts_[1] = target ? util::path_for_pid_mountns(*pid, *target) : ""; } // uprobe attached by source code location (@source_file:line[:col]) const bool source_location = parts_.size() > 2 && parts_[2] == "@"; if (!source_location && parts_.size() != 3 && parts_.size() != 4) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(2, 3); } if (parts_.size() == 4) ap_->lang = parts_[2]; ap_->target = ""; if (!util::has_wildcard(parts_[1]) && parts_[1].starts_with("lib")) { // Automatic resolution of shared library paths. // If the target has form "libXXX" then we use BCC to find the correct path // to the given library as it may differ across systems. auto libname = parts_[1].substr(3); auto *lib_path = bcc_procutils_which_so(libname.c_str(), bpftrace_.pid().value_or(0)); if (lib_path) { ap_->target = lib_path; ::free(lib_path); } } if (ap_->target.empty()) { ap_->target = parts_[1]; } // Handle uprobe:libc@malloc.c:3538 case if (source_location) { if (!allow_src_loc) { errs_ << "Source code location not allowed" << std::endl; return INVALID; } if (util::has_wildcard(ap_->target)) { errs_ << "Cannot use wildcards with source code location" << std::endl; return INVALID; } if ((parts_.size() != 5 && parts_.size() != 6) || parts_[3].empty() || parts_[4].empty()) { errs_ << "Invalid uprobe arguments, " << "expected format: uprobe:TARGET@FILE:LINE[:COL]" << std::endl; return INVALID; } ap_->source_file = parts_[3]; auto line = util::to_uint(parts_[4]); if (!line) { errs_ << "Invalid line number: " << line.takeError() << std::endl; return INVALID; } ap_->line_num = *line; if (parts_.size() == 6) { auto col = util::to_uint(parts_[5]); if (!col) { errs_ << "Invalid column number: " << col.takeError() << std::endl; return INVALID; } ap_->col_num = *col; } Dwarf *dwarf = bpftrace_.get_dwarf(ap_->target); if (dwarf) { auto address = dwarf->line_to_addr(ap_->source_file, ap_->line_num, ap_->col_num); if (!address) { errs_ << address.takeError() << std::endl; return INVALID; } ap_->address = *address; return OK; } errs_ << (ap_->target.empty() ? "Unspecified target binary" : "No DWARF debug info found for '" + ap_->target + "'") << ", cannot attach by source code location." << std::endl; return INVALID; } const std::string &func = parts_.back(); // Handle uprobe:/lib/asdf:func+0x100 case auto plus_count = std::count(func.cbegin(), func.cend(), '+'); if (plus_count) { if (!allow_offset) { errs_ << "Offset not allowed" << std::endl; return INVALID; } if (plus_count != 1) { errs_ << "Cannot take more than one offset" << std::endl; return INVALID; } auto offset_parts = util::split_string(func, '+', true); if (offset_parts.size() != 2) { errs_ << "Invalid offset" << std::endl; return INVALID; } ap_->func = offset_parts[0]; auto res = util::to_uint(offset_parts[1]); if (!res) { errs_ << "Invalid offset: " << res.takeError() << std::endl; return INVALID; } ap_->func_offset = *res; } // Default case (eg uprobe:[addr][func]) else { auto res = util::to_uint(func); if (res) { if (util::has_wildcard(ap_->target)) { errs_ << "Cannot use wildcards with absolute address" << std::endl; return INVALID; } ap_->address = *res; } else { ap_->address = 0; ap_->func = func; } } return OK; } AttachPointParser::State AttachPointParser::uretprobe_parser() { return uprobe_parser(false, false); } AttachPointParser::State AttachPointParser::usdt_parser() { if (bpftrace_.pid().has_value()) { // For PID, the target can be skipped if (parts_.size() == 2) { parts_.push_back(parts_[1]); parts_[1] = ""; } } if (parts_.size() != 3 && parts_.size() != 4) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(2, 3); } if (parts_.size() == 3) { ap_->target = parts_[1]; ap_->func = parts_[2]; } else { ap_->target = parts_[1]; ap_->ns = parts_[2]; ap_->func = parts_[3]; } return OK; } AttachPointParser::State AttachPointParser::tracepoint_parser() { // Help with `bpftrace -l 'tracepoint:*foo*'` listing -- wildcard the // tracepoint category b/c user is most likely to be looking for the event // name if (parts_.size() == 2 && util::has_wildcard(parts_.at(1))) parts_.insert(parts_.begin() + 1, "*"); if (parts_.size() != 3) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(2); } ap_->target = parts_[1]; ap_->func = parts_[2]; return OK; } // Used for both profile and interval probes AttachPointParser::State AttachPointParser::frequency_parser() { if (parts_.size() == 2) { if (util::has_wildcard(parts_[1])) { // Wildcards are allowed for listing ap_->target = parts_[1]; ap_->freq = 0; return OK; } auto res = util::to_uint(parts_[1]); if (!res) { errs_ << "Invalid rate of " << ap_->provider << " probe: " << res.takeError() << std::endl; return INVALID; } if (*res < 1000) { errs_ << "Invalid rate of " << ap_->provider << " probe. Minimum is 1000 or 1us. Found: " << *res << " nanoseconds" << std::endl; return INVALID; } ap_->target = "us"; // res is in nanoseconds ap_->freq = (*res / 1000); return OK; } if (parts_.size() != 3) { return argument_count_error(1, 2); } ap_->target = parts_[1]; auto res = util::to_uint(parts_[2]); if (!res) { errs_ << "Invalid rate of " << ap_->provider << " probe: " << res.takeError() << std::endl; return INVALID; } ap_->freq = *res; return OK; } AttachPointParser::State AttachPointParser::profile_parser() { return frequency_parser(); } AttachPointParser::State AttachPointParser::interval_parser() { return frequency_parser(); } AttachPointParser::State AttachPointParser::software_parser() { if (parts_.size() != 2 && parts_.size() != 3) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(1, 2); } ap_->target = parts_[1]; if (parts_.size() == 3 && parts_[2] != "*") { auto res = util::to_uint(parts_[2]); if (!res) { errs_ << "Invalid count for " << ap_->provider << " probe: " << res.takeError() << std::endl; return INVALID; } ap_->freq = *res; } return OK; } AttachPointParser::State AttachPointParser::hardware_parser() { if (parts_.size() != 2 && parts_.size() != 3) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(1, 2); } ap_->target = parts_[1]; if (parts_.size() == 3 && parts_[2] != "*") { auto res = util::to_uint(parts_[2]); if (!res) { errs_ << "Invalid count for " << ap_->provider << " probe: " << res.takeError() << std::endl; return INVALID; } ap_->freq = *res; } return OK; } AttachPointParser::State AttachPointParser::watchpoint_parser() { if (parts_.size() != 4) { return argument_count_error(3); } auto parsed = util::to_uint(parts_[1]); if (!parsed) { errs_ << "Invalid function/address argument: " << parsed.takeError() << std::endl; return INVALID; } ap_->address = *parsed; auto len_parsed = util::to_uint(parts_[2]); if (!len_parsed) { errs_ << "Invalid length argument: " << len_parsed.takeError() << std::endl; return INVALID; } ap_->len = *len_parsed; // An earlier pass will ensure a cmd/pid was provided ap_->target = bpftrace_.get_watchpoint_binary_path().value_or(""); ap_->mode = parts_[3]; return OK; } AttachPointParser::State AttachPointParser::fentry_parser() { // fentry[:module]:function // fentry:bpf:[:prog_id]:prog_name if (parts_.size() != 2 && parts_.size() != 3 && parts_.size() != 4) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(1, 3); } if (parts_[1] == "bpf") { ap_->target = parts_[1]; if (parts_.size() == 2) { errs_ << "the 'bpf' variant of this probe requires a bpf program name " "and optional bpf program id"; return INVALID; } else if (parts_.size() == 3) { ap_->func = parts_[2]; } else { ap_->func = parts_[3]; if (parts_[2] != "*") { auto uint_res = util::to_uint(parts_[2]); if (!uint_res) { errs_ << "bpf program id must be a number or '*'"; return INVALID; } ap_->bpf_prog_id = *uint_res; } } return OK; } if (parts_.size() == 4) { errs_ << "Only the 'bpf' variant of this probe supports 4 arguments"; return INVALID; } if (parts_.size() == 3) { ap_->target = parts_[1]; ap_->func = parts_[2]; } else { ap_->func = parts_[1]; if (!util::has_wildcard(ap_->func)) { auto func_modules = func_info_state_.kernel_info().get_func_modules( ap_->func); if (func_modules.size() == 1) { ap_->target = *func_modules.begin(); } else if (func_modules.size() > 1) { // Attaching to multiple functions of the same name is currently // broken, ask the user to specify a module explicitly. errs_ << "ambiguous attach point, please specify module containing " "the function \'" << ap_->func << "\'"; return INVALID; } } else { // leave the module empty for now ap_->target = "*"; } } return OK; } AttachPointParser::State AttachPointParser::iter_parser() { if (parts_.size() != 2 && parts_.size() != 3) { if (ap_->ignore_invalid) return SKIP; errs_ << ap_->provider << " probe type takes 2 arguments (1 optional)" << std::endl; return INVALID; } if (has_iter_ap_) { errs_ << ap_->provider << " probe only supports one attach point." << std::endl; return INVALID; } if (util::has_wildcard(parts_[1]) || (parts_.size() == 3 && util::has_wildcard(parts_[2]))) { errs_ << ap_->provider << " probe type does not support wildcards"; return INVALID; } ap_->func = parts_[1]; if (parts_.size() == 3) ap_->pin = parts_[2]; has_iter_ap_ = true; return OK; } AttachPointParser::State AttachPointParser::raw_tracepoint_parser() { if (parts_.size() != 2 && parts_.size() != 3) { if (ap_->ignore_invalid) return SKIP; return argument_count_error(2, 1); } if (parts_.size() == 3) { ap_->target = parts_[1]; ap_->func = parts_[2]; } else { // This is to maintain backwards compatibility with older scripts // that couldn't include a target for a raw tracepoint. ap_->target = "*"; ap_->func = parts_[1]; } return OK; } Pass CreateParseAttachpointsPass() { return Pass::create( "parse-attachpoints", [](ASTContext &ast, BPFtrace &b, FunctionInfo &func_info) { AttachPointParser ap_parser(ast, b, func_info); ap_parser.parse(); }); } Pass CreateCheckAttachpointsPass() { return Pass::create( "check-attachpoints", [](ASTContext &ast, BPFtrace &b, FunctionInfo &func_info) { AttachPointChecker ap_checker(b, func_info); ap_checker.visit(*ast.root); }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/attachpoint_passes.h000066400000000000000000000054451526721631600223310ustar00rootroot00000000000000#pragma once #include #include #include #include "ast/ast.h" #include "ast/pass_manager.h" #include "bpftrace.h" #include "symbols/kernel.h" #include "symbols/user.h" namespace bpftrace::ast { // Provides function information (kernel and user space) to AST passes. class FunctionInfo : public bpftrace::ast::State<"function-info"> { public: explicit FunctionInfo(symbols::KernelInfo &kernel_impl, symbols::UserInfo &user_impl) : kernel_impl_(kernel_impl), user_impl_(user_impl) { } symbols::KernelInfo &kernel_info() const { return kernel_impl_; } symbols::UserInfo &user_info() const { return user_impl_; } private: symbols::KernelInfo &kernel_impl_; symbols::UserInfo &user_impl_; }; class AttachPointParser { public: AttachPointParser(ASTContext &ctx, BPFtrace &bpftrace, FunctionInfo &func_info_state); ~AttachPointParser() = default; void parse(); private: enum State { OK = 0, INVALID, NEW_APS, SKIP }; State parse_attachpoint(AttachPoint &ap); // This method splits an attach point definition into arguments, // where arguments are separated by `:`. The exception is `:`s inside // of quoted strings, which we must treat as a literal. // // This method also resolves positional parameters. Positional params // may be escaped with double quotes. // // Note that this function assumes the raw string is generally well // formed. More specifically, that there is no unescaped whitespace // and no unmatched quotes. State lex_attachpoint(const AttachPoint &ap); State special_parser(); State test_parser(); State benchmark_parser(); State kprobe_parser(bool allow_offset = true); State kretprobe_parser(); State uprobe_parser(bool allow_offset = true, bool allow_src_loc = true); State uretprobe_parser(); State usdt_parser(); State tracepoint_parser(); State profile_parser(); State interval_parser(); State software_parser(); State hardware_parser(); State watchpoint_parser(); State fentry_parser(); State iter_parser(); State raw_tracepoint_parser(); State frequency_parser(); State argument_count_error(int expected, std::optional expected2 = std::nullopt); std::optional stoull(const std::string &str); std::optional stoll(const std::string &str); ASTContext &ctx_; BPFtrace &bpftrace_; FunctionInfo &func_info_state_; AttachPoint *ap_{ nullptr }; // Non-owning pointer std::stringstream errs_; std::vector parts_; AttachPointList new_attach_points; bool has_iter_ap_ = false; }; // The attachpoints are expanded in their own separate pass. Pass CreateParseAttachpointsPass(); Pass CreateCheckAttachpointsPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/builtins.cpp000066400000000000000000000356721526721631600206260ustar00rootroot00000000000000#include #include "arch/arch.h" #include "ast/passes/builtins.h" #include "ast/signal_bt.h" #include "ast/visitor.h" #include "bpffeature.h" #include "bpftrace.h" #include "collect_nodes.h" #include "log.h" #include "util/paths.h" namespace bpftrace::ast { namespace { class ConfigBuiltins : public Visitor> { public: ConfigBuiltins(ASTContext &ast, BPFtrace &bpftrace) : ast_(ast), bpftrace_(bpftrace) { } using Visitor>::visit; std::optional visit(Expression &expr) { auto replacement = Visitor>::visit(expr.value); if (replacement) { expr.value = replacement->value; } return std::nullopt; } std::optional visit(Builtin &builtin) { if (builtin.ident == "__builtin_config") { return expand_config(builtin.loc); } return std::nullopt; } std::optional visit(Identifier &identifier) { if (identifier.ident == "__builtin_config") { return expand_config(identifier.loc); } return std::nullopt; } private: std::optional expand_config(const Location &loc) { std::vector> args; auto &cfg = bpftrace_.config_; auto add_bool = [&](const char *key, bool val) { args.emplace_back(key, ast_.make_node(loc, val)); }; auto add_int = [&](const char *key, uint64_t val) { args.emplace_back(key, ast_.make_node(loc, val)); }; auto add_str = [&](const char *key, const std::string &val) { args.emplace_back(key, ast_.make_node(loc, val)); }; add_bool("cpp_demangle", cfg->cpp_demangle); add_bool("lazy_symbolication", cfg->lazy_symbolication); add_bool("print_maps_on_exit", cfg->print_maps_on_exit); add_bool("use_blazesym", cfg->use_blazesym); add_bool("show_debug_info", cfg->show_debug_info); add_int("log_size", cfg->log_size); add_int("max_bpf_progs", cfg->max_bpf_progs); add_int("max_cat_bytes", cfg->max_cat_bytes); add_int("max_map_keys", cfg->max_map_keys); add_int("max_probes", cfg->max_probes); add_int("max_strlen", cfg->max_strlen); add_int("on_stack_limit", cfg->on_stack_limit); add_int("perf_rb_pages", cfg->perf_rb_pages); add_str("str_trunc_trailer", cfg->str_trunc_trailer); auto unstable_str = [](ConfigUnstable u) { switch (u) { case ConfigUnstable::enable: return "enable"; case ConfigUnstable::warn: return "warn"; case ConfigUnstable::error: return "error"; } return "error"; }; add_str("unstable_import_statement", unstable_str(cfg->unstable_import_statement)); add_str("unstable_tseries", unstable_str(cfg->unstable_tseries)); add_str("unstable_typeinfo", unstable_str(cfg->unstable_typeinfo)); add_str("unstable_dw_ustack", unstable_str(cfg->unstable_dw_ustack)); std::string missing_str; switch (cfg->missing_probes) { case ConfigMissingProbes::ignore: missing_str = "ignore"; break; case ConfigMissingProbes::warn: missing_str = "warn"; break; case ConfigMissingProbes::error: missing_str = "error"; break; } add_str("missing_probes", missing_str); add_str("stack_mode", STACK_MODE_NAME_MAP.at(cfg->stack_mode)); add_str("license", bpftrace::Config::get_license_str(cfg->license)); return make_record(ast_, loc, std::move(args)); } ASTContext &ast_; BPFtrace &bpftrace_; }; class Builtins : public Visitor> { public: explicit Builtins(ASTContext &ast, BPFtrace &bpftrace, bool has_child = true) : ast_(ast), bpftrace_(bpftrace), has_child_(has_child) {}; using Visitor>::visit; std::optional visit(Builtin &builtin); std::optional visit(Call &call); std::optional visit(Expression &expression); std::optional visit(Identifier &identifier); std::optional visit(For &f); std::optional visit(Probe &probe); std::optional check(const std::string &ident, Node &node); Probe *get_probe(Node &node, std::string name); private: ASTContext &ast_; BPFtrace &bpftrace_; bool has_child_ = false; Node *top_level_node_ = nullptr; }; } // namespace Probe *Builtins::get_probe(Node &node, std::string name) { auto *probe = dynamic_cast(top_level_node_); if (probe == nullptr) { // Attempting to use probe-specific feature in non-probe context if (name.empty()) { node.addError() << "Feature not supported outside probe"; } else { node.addError() << "Builtin " << name << " not supported outside probe"; } } return probe; } std::optional Builtins::check(const std::string &ident, Node &node) { auto *probe = dynamic_cast(top_level_node_); auto check_probe = [&]() -> bool { if (!probe) { node.addError() << ident << " can only be used inside of a probe."; return false; } return true; }; // N.B. this pass *should* include all the compile-time builtins (probe, // provider, etc.) but it presently cannot due to the expansion rules. All // builtins should be added here once probes are fully-expanded up front. // // All of these builtins should be directly evaluated and folded and not // associated with any code generation. These builtins should be kept to the // minimum possible set to support the standard library. if (ident == "__builtin_arch") { std::stringstream ss; ss << bpftrace::arch::current(); return ast_.make_node(node.loc, ss.str()); } else if (ident == "__builtin_safe_mode") { return ast_.make_node(node.loc, bpftrace_.safe_mode_); } else if (ident == "__builtin_probe") { if (check_probe()) { return ast_.make_node(node.loc, probe->attach_points.empty() ? "none" : probe->attach_points.front()->name()); } } else if (ident == "__builtin_probetype") { if (check_probe()) { return ast_.make_node( node.loc, probe->attach_points.empty() ? "none" : probetypeName( probetype(probe->attach_points.front()->provider))); } } else if (ident == "__builtin_elf_is_exe") { if (check_probe()) { return ast_.make_node( node.loc, util::is_exe(probe->attach_points.front()->target)); } } else if (ident == "__builtin_elf_ino") { if (check_probe()) { return ast_.make_node( node.loc, util::file_ino(probe->attach_points.front()->target)); } } return std::nullopt; } std::optional Builtins::visit(Call &call) { Visitor>::visit(call); if (call.func == "__builtin_signal_num") { if (call.vargs.size() != 1) { call.addError() << call.func << " expects 1 argument"; } else { if (auto *str = call.vargs.at(0).as()) { auto signal_num = signal_name_to_num(str->value); if (signal_num < 1) { call.addError() << "Invalid string for signal: " << str->value; } return ast_.make_node(str->loc, signal_num); } } } else if (call.func == "__builtin_kfunc_exist") { if (call.vargs.size() != 1) { call.addError() << call.func << " expects 1 argument"; } else { if (auto *kfunc = call.vargs.at(0).as()) { return ast_.make_node( kfunc->loc, bpftrace_.feature_->has_kfunc(kfunc->value)); } } } else if (call.func == "__builtin_kfunc_allowed") { if (call.vargs.size() != 1) { call.addError() << call.func << " expects 1 argument"; } else { auto *probe = dynamic_cast(top_level_node_); if (!probe) { LOG(BUG) << "Inner error: can't get probe for " << call.func; return std::nullopt; } ProbeType type = probetype(probe->attach_points.front()->provider); bpf_prog_type prog_type = progtype(type); if (auto *kfunc = call.vargs.at(0).as()) { return ast_.make_node( kfunc->loc, bpftrace_.feature_->kfunc_allowed(kfunc->value.c_str(), prog_type)); } } } else if (call.func == "__builtin_is_literal") { if (call.vargs.size() != 1) { call.addError() << call.func << " expects 1 argument"; } else { return ast_.make_node(call.vargs.at(0).loc(), call.vargs.at(0).is_literal()); } } return std::nullopt; } std::optional Builtins::visit(Builtin &builtin) { if (builtin.ident == "ctx") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return std::nullopt; ProbeType pt = probe->get_probetype(); bpf_prog_type bt = progtype(pt); bool has_error = false; switch (bt) { case BPF_PROG_TYPE_KPROBE: case BPF_PROG_TYPE_PERF_EVENT: break; case BPF_PROG_TYPE_TRACEPOINT: builtin.addError() << "Use args instead of ctx in tracepoint"; break; case BPF_PROG_TYPE_TRACING: if (pt != ProbeType::iter) { has_error = true; } break; default: has_error = true; break; } if (has_error) { builtin.addError() << "The " << builtin.ident << " builtin can not be used with '" << probe->attach_points[0]->provider << "' probes"; } } else if (builtin.ident == "__builtin_func") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return std::nullopt; ProbeType type = probe->get_probetype(); if (type == ProbeType::kprobe || type == ProbeType::uprobe) { // OK we don't use BPF_FUNC_get_func_ip helper } else if (type == ProbeType::kretprobe || type == ProbeType::uretprobe || type == ProbeType::fentry || type == ProbeType::fexit) { if (!bpftrace_.feature_->has_helper_get_func_ip()) { builtin.addError() << "BPF_FUNC_get_func_ip not available for your kernel version. " "Consider using the 'probe' builtin instead."; } } else { builtin.addError() << "The func builtin can not be used with '" << probe->attach_points[0]->provider << "' probes"; } } else if (builtin.is_argx()) { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return std::nullopt; int arg_num = atoi(builtin.ident.substr(3).c_str()); // argx in USDT probes doesn't need to check against arch::max_arg() if (probe->get_probetype() != ProbeType::usdt && static_cast(arg_num) >= arch::Host::arguments().size()) { builtin.addError() << arch::Host::Machine << " doesn't support " << builtin.ident; } } else if (builtin.ident == "__builtin_usermode") { if (arch::Host::Machine != arch::Machine::X86_64) { builtin.addError() << "'usermode' builtin is only supported on x86_64"; } } else if (builtin.ident == "args") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return std::nullopt; ProbeType type = probe->get_probetype(); if (type == ProbeType::fentry || type == ProbeType::fexit || type == ProbeType::uprobe || type == ProbeType::rawtracepoint || type == ProbeType::tracepoint) { if ((type == ProbeType::fentry || type == ProbeType::fexit) && probe->attach_points[0]->target == "bpf") { builtin.addError() << "The args builtin cannot be used for " "'fentry/fexit:bpf' probes"; } } else { builtin.addError() << "The args builtin can only be used with " "tracepoint, rawtracepoint, fentry/fexit, and uprobe probes (" << type << " used here)"; } } return check(builtin.ident, builtin); } std::optional Builtins::visit(Identifier &identifier) { return check(identifier.ident, identifier); } std::optional Builtins::visit(Expression &expression) { auto replacement = visit(expression.value); if (replacement) { expression.value = replacement->value; } return std::nullopt; } std::optional Builtins::visit(For &f) { // Currently, we do not pass BPF context to the callback so disable builtins // which require ctx access. CollectNodes builtins; builtins.visit(f.block); for (const Builtin &builtin : builtins.nodes()) { if (builtin.is_argx() || builtin.ident == "__builtin_retval") { builtin.addError() << "'" << builtin.ident << "' builtin is not allowed in a for-loop"; } } return std::nullopt; } std::optional Builtins::visit(Probe &probe) { top_level_node_ = &probe; return Visitor>::visit(probe); } Pass CreateBuiltinsPass() { auto fn = [&](ASTContext &ast, BPFtrace &bpftrace) { Builtins builtins(ast, bpftrace, !bpftrace.cmd_.empty() || bpftrace.child_ != nullptr); builtins.visit(ast.root); }; return Pass::create("Builtins", fn); }; Pass CreateConfigBuiltinsPass() { auto fn = [&](ASTContext &ast, BPFtrace &bpftrace) { ConfigBuiltins config_builtins(ast, bpftrace); config_builtins.visit(ast.root); }; return Pass::create("ConfigBuiltins", fn); }; Pass CreatePreExpansionBuiltinsPass() { auto fn = [](ASTContext &ast, BPFtrace &) { for (auto *probe : ast.root->probes) { CollectNodes collector; collector.visit(*probe); for (const Builtin &builtin : collector.nodes()) { for (auto *ap : probe->attach_points) { ProbeType type = probetype(ap->provider); if (builtin.ident == "__builtin_retval") { if (type != ProbeType::kretprobe && type != ProbeType::uretprobe && type != ProbeType::fentry && type != ProbeType::fexit) { builtin.addError() << "The retval builtin can only be used with 'kretprobe' " "and 'uretprobe' and 'fentry' probes" << (type == ProbeType::tracepoint ? " (try to use args.ret instead)" : ""); } } else if (builtin.is_argx()) { if (type != ProbeType::kprobe && type != ProbeType::uprobe && type != ProbeType::usdt && type != ProbeType::rawtracepoint) { builtin.addError() << "The " << builtin.ident << " builtin can only be used with " "'kprobes', 'uprobes' and 'usdt' probes"; } } } } } }; return Pass::create("BuiltinProbeCheck", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/builtins.h000066400000000000000000000007121526721631600202560ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { // Validate builtins that have probe-type restrictions before probe expansion // merges probes (e.g. session expansion merging kprobe + kretprobe). Pass CreatePreExpansionBuiltinsPass(); // Expand builtins that must be available before literal folding. Pass CreateConfigBuiltinsPass(); // Fill in the values of all intrinsics. Pass CreateBuiltinsPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/c_macro_expansion.cpp000066400000000000000000000042731526721631600224550ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/context.h" #include "ast/passes/c_macro_expansion.h" #include "ast/visitor.h" #include "clang_parser.h" #include "parser.h" #include "util/strings.h" namespace bpftrace::ast { class CMacroExpander : public Visitor { public: CMacroExpander(ASTContext &ast, CDefinitions &c_definitions) : ast_(ast), c_definitions_(c_definitions) {}; using Visitor::visit; void visit(Expression &expr); private: ASTContext &ast_; CDefinitions &c_definitions_; std::vector active_; }; void CMacroExpander::visit(Expression &expr) { // N.B. We only support raw identifier macros. The way expansion works is // that we see if an expression is a bare identifier, then attempt expansion // recurisvely. if (auto *ident = expr.as()) { if (c_definitions_.macros.contains(ident->ident)) { const auto &value = c_definitions_.macros[ident->ident]; // Check for recursion. if (std::ranges::find(active_, ident->ident) != active_.end()) { ident->addError() << "Macro recursion: " << util::str_join(active_, "->"); return; } // Parse just the macro as an expression. ASTContext macro(ident->ident, value); Parser parser(macro); auto expanded = parser.parse_expr(); if (!expanded) { ident->addError() << "unable to expand macro as an expression: " << value; return; } // Expand the macro expression in place. expr.value = clone(ast_, ident->loc, expanded->value); // Recursively visit the potentially expanded expression, ensuring that // we can catch recursive expansion, per above. active_.emplace_back(ident->ident); Visitor::visit(expr); active_.pop_back(); return; } } // Expand normally. Visitor::visit(expr); } Pass CreateCMacroExpansionPass() { auto fn = [](ASTContext &ast, CDefinitions &c_definitions) { CMacroExpander expander(ast, c_definitions); expander.visit(ast.root); }; return Pass::create("CMacroExpansion", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/c_macro_expansion.h000066400000000000000000000002101526721631600221050ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateCMacroExpansionPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/clang_build.cpp000066400000000000000000000176271526721631600212400ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include "arch/arch.h" #include "ast/ast.h" #include "ast/passes/clang_build.h" #include "ast/passes/codegen_llvm.h" #include "ast/passes/resolve_imports.h" #include "bpftrace.h" #include "stdlib/stdlib.h" #include "util/memfd.h" #include "util/result.h" namespace bpftrace::ast { char ClangBuildError::ID; void ClangBuildError::log(llvm::raw_ostream &OS) const { OS << msg_; } static Result build( CompileContext &ctx, const std::string &name, LoadedObject &obj, const llvm::MemoryBufferRef &vmlinux_h, Imports &imports) { llvm::IntrusiveRefCntPtr vfs( new llvm::vfs::InMemoryFileSystem()); vfs->addFile(name, 0, llvm::MemoryBuffer::getMemBufferCopy(obj.data(), "main")); const std::string asm_dir = "include/asm/" + arch::Host::asm_arch() + "/"; for (const auto &[name, other] : stdlib::Stdlib::c_files) { // If this include file is an arch-specific assembly file, then we // skip if it does not match the current architecture. If it *does* // match the current architecture, then we remap it as the `asm` // directory (without the arch prefix). if (name.starts_with("include/asm/")) { if (!name.starts_with(asm_dir)) { continue; // Not our architecture. } // Replace the arch-specific path with just the asm path. std::string nn = "include/asm/" + name.substr(asm_dir.size()); vfs->addFile(nn, 0, llvm::MemoryBuffer::getMemBufferCopy(other, nn)); } else { vfs->addFile(name, 0, llvm::MemoryBuffer::getMemBufferCopy(other, name)); } } for (auto &[name, other] : imports.c_headers) { vfs->addFile(name, 0, llvm::MemoryBuffer::getMemBufferCopy(other.data(), name)); } vfs->addFileNoOwn("include/vmlinux.h", 0, vmlinux_h); // Create the diagnostic options and client. We emit the error to // a string, which we can then capture and associate with the import. std::string errstr; llvm::raw_string_ostream err(errstr); #if LLVM_VERSION_MAJOR < 21 auto diagOpts = llvm::makeIntrusiveRefCnt(); auto diags = std::make_unique( llvm::makeIntrusiveRefCnt(), diagOpts, new clang::TextDiagnosticPrinter(err, diagOpts.get())); #else // Clang 21: DiagnosticOptions is NOT intrusive-refcounted anymore. // Keep it alive for the program lifetime (or store it on a longer-lived // object). static std::shared_ptr diagOpts = std::make_shared(); llvm::IntrusiveRefCntPtr diagID( new clang::DiagnosticIDs()); auto client = std::make_unique(err, *diagOpts); auto diags = std::make_unique(diagID, *diagOpts, client.release()); #endif // We create a temporary memfd that we can use to store the output, // since the ClangDriver API is framed in terms of filenames. Perhaps // we could use the internals here, but that carries other risks. auto memfd = util::MemFd::create(name); if (!memfd) { return memfd.takeError(); } // Create the compiler invocation. Note that the `-O2` introduces some passes // that seem to be load-bearing with respect to generating useful debug // information, for some reason. The generated module will be linked and // optimized again regardless, but it is better safe than sorry. std::vector args; args.push_back("-O2"); args.push_back("-Iinclude"); for (const auto &s : arch::Host::c_defs()) { args.push_back("-D"); args.push_back(s.c_str()); } args.push_back("-o"); args.push_back(memfd->path().c_str()); args.push_back(name.c_str()); // Configure the instance. We want to read the source file named // by `name` above, enable debug information and optimization. auto inv = std::make_shared(); clang::CompilerInvocation::CreateFromArgs(*inv, llvm::ArrayRef(args), *diags); inv->getTargetOpts().Triple = "bpf"; inv->getCodeGenOpts().setDebugInfo(llvm::codegenoptions::FullDebugInfo); inv->getCodeGenOpts().DebugColumnInfo = true; clang::CompilerInstance ci; // Cross-version friendly: assign into the existing invocation // (works across modern Clang majors, including 21) ci.getInvocation() = *inv; ci.setDiagnostics(diags.release()); #if LLVM_VERSION_MAJOR >= 22 ci.setVirtualFileSystem(vfs); ci.createFileManager(); ci.createSourceManager(); #else ci.setFileManager(new clang::FileManager(clang::FileSystemOptions(), vfs)); ci.createSourceManager(ci.getFileManager()); #endif // Generate the object file, which should include the required BTF // debug information. This also generates the module as a // side-effect, which is what we actually extract for linking. std::unique_ptr action = std::make_unique(ctx.context.get()); if (!ci.ExecuteAction(*action)) { // This is likely a build failure, we can surface this directly // into the user context. We first highlight the location of the // original import, then include the C message as a "hint". return make_error(errstr); } if (!errstr.empty()) { // If the compilation didn't fail, then these weren't errors but we // can surface them as compilation warnings. auto &e = obj.node.addWarning(); e << "found external warnings"; e.addHint() << errstr; } std::unique_ptr mod = action->takeModule(); if (!mod) { // This is an internal error, not suitable to surface as a user // diagnostic. Surface it directly as an error in the pipeline. return make_error("failed to generate module"); } auto data = memfd->read_all(); if (!data) { return data.takeError(); } return BitcodeModules::Result{ .module = std::move(mod), .object = std::move(*data), .loc = obj.node.loc, }; } ast::Pass CreateClangBuildPass() { return ast::Pass::create( "ClangBuilder", [](BPFtrace &bpftrace, CompileContext &ctx, ast::Imports &imports) -> Result { BitcodeModules bm; // Nothing to do? Return directly. if (imports.c_sources.empty()) { return bm; } // Construct our kernel headers. This is a rather expensive operation, // so we ensure that we do this only once for all files. std::string vmlinux_h = bpftrace.btf_->c_def(); // For each of the source files in the imports, we // build it and turn it into a bitcode file. for (auto &[name, obj] : imports.c_sources) { auto result = build(ctx, name, obj, llvm::MemoryBufferRef(llvm::StringRef(vmlinux_h), "vmlinux.h"), imports); if (!result) { auto &e = obj.node.addError(); e << "failed to build"; e.addHint() << result.takeError(); continue; } bm.modules.push_back(std::move(*result)); } return bm; }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/clang_build.h000066400000000000000000000012171526721631600206710ustar00rootroot00000000000000#pragma once #include #include #include "ast/location.h" #include "ast/pass_manager.h" namespace bpftrace::ast { class BitcodeModules : public State<"bitcode"> { public: struct Result { std::unique_ptr module; std::string object; Location loc; }; std::vector modules; }; class ClangBuildError : public ErrorInfo { public: static char ID; void log(llvm::raw_ostream &OS) const override; ClangBuildError(std::string msg) : msg_(std::move(msg)) {}; private: std::string msg_; }; ast::Pass CreateClangBuildPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/clang_parser.cpp000066400000000000000000000705031526721631600214250ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ast/ast.h" #include "ast/context.h" #include "ast/passes/resolve_imports.h" #include "bpftrace.h" #include "btf.h" #include "clang_parser.h" #include "log.h" #include "stdlib/stdlib.h" #include "types.h" #include "util/strings.h" #include "util/system.h" namespace bpftrace::ast { char ClangParseError::ID; void ClangParseError::log(llvm::raw_ostream &OS) const { OS << "Clang parse error"; } class ClangParser { public: bool parse(ast::Program *program, BPFtrace &bpftrace, std::vector extra_flags = {}); // Moved out by the pass. CDefinitions definitions; private: bool visit_children(CXCursor &cursor, BPFtrace &bpftrace); // The user might have written some struct definitions that rely on types // supplied by BTF data. // // This method will pull out any forward-declared / incomplete struct // definitions and return the types (in string form) of the unresolved types. // // Note that this method does not report "errors". This is because the user // could have typo'd and actually referenced a non-existent type. Put // differently, this method is best effort. std::unordered_set get_incomplete_types(); // Iteratively check for incomplete types, pull their definitions from BTF, // and update the input files with the definitions. void resolve_incomplete_types_from_btf(BPFtrace &bpftrace); // Collect names of types defined by typedefs that are in non-included // headers as they may pose problems for clang parser. std::unordered_set get_unknown_typedefs(); // Iteratively check for unknown typedefs, pull their definitions from BTF, // and update the input files with the definitions. void resolve_unknown_typedefs_from_btf(BPFtrace &bpftrace); static std::optional get_unknown_type( const std::string &diagnostic_msg); CXUnsavedFile get_btf_generated_header(BPFtrace &bpftrace); CXUnsavedFile get_empty_btf_generated_header(); std::string get_arch_include_path(); std::vector system_include_paths(); std::string input; std::vector args; std::vector input_files; std::string btf_cdef; class ClangParserHandler { public: ClangParserHandler(); ~ClangParserHandler(); bool parse_file(const std::string &filename, const std::vector &args, std::vector &unsaved_files, bool bail_on_errors = true); CXTranslationUnit get_translation_unit(); CXErrorCode parse_translation_unit(const char *source_filename, const char *const *command_line_args, int num_command_line_args, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, unsigned options); // Check diagnostics and collect all error messages. // Return true if an error occurred. If bail_on_error is false, only fail // on fatal errors. bool check_diagnostics(bool bail_on_error); CXCursor get_translation_unit_cursor(); const std::vector &get_error_messages(); bool has_redefinition_error(); bool has_unknown_type_error(); private: CXIndex index; CXTranslationUnit translation_unit = nullptr; std::vector error_msgs; }; }; namespace { const std::vector &getDefaultHeaders() { // N.B. the `cached` value here hangs on to a vector of strings, as well as a // vector of `CXUnsavedFile` objects. Since the `CXUnsavedFile` objects need // a C-style string, this is a `.c_str()` that comes from one of the saved // names. It is important that these objects are kept alive, even if they are // not returned from this function. static auto cached = [] { std::vector names; std::vector unsaved_files; for (const auto &[name, view] : stdlib::Stdlib::c_files) { if (!name.ends_with(".h")) { continue; // Inlucde only headers. } const auto &n = names.emplace_back("/bpftrace/" + name); unsaved_files.push_back(CXUnsavedFile{ .Filename = n.c_str(), .Contents = view.data(), .Length = view.length(), }); } return std::make_pair(std::move(names), std::move(unsaved_files)); }(); return cached.second; // See above. } std::vector getTranslationUnitFiles( const CXUnsavedFile &main_file) { std::vector files; files.reserve(1 + files.size()); files.emplace_back(main_file); const auto &dfl = getDefaultHeaders(); files.insert(files.end(), dfl.cbegin(), dfl.cend()); return files; } } // namespace static std::string get_clang_string(CXString string) { std::string str = clang_getCString(string); clang_disposeString(string); return str; } // get_named_parent // // Find the parent struct of the field pointed to by the cursor. // Anonymous structs are skipped. static CXCursor get_named_parent(CXCursor c) { CXCursor parent = clang_getCursorSemanticParent(c); while (!clang_Cursor_isNull(parent) && clang_Cursor_isAnonymousRecordDecl(parent)) { parent = clang_getCursorSemanticParent(parent); } return parent; } static std::optional getBitfield(CXCursor c) { if (!clang_Cursor_isBitField(c)) { return std::nullopt; } return Bitfield(clang_Cursor_getOffsetOfField(c) % 8, clang_getFieldDeclBitWidth(c)); } // NOTE(mmarchini): as suggested in // http://clang-developers.42468.n3.nabble.com/Extracting-macro-information-using-libclang-the-C-Interface-to-Clang-td4042648.html#message4042666 static bool translateMacro(CXCursor cursor, std::string &name, std::string &value) { CXToken *tokens = nullptr; unsigned numTokens = 0; CXTranslationUnit transUnit = clang_Cursor_getTranslationUnit(cursor); CXSourceRange srcRange = clang_getCursorExtent(cursor); clang_tokenize(transUnit, srcRange, &tokens, &numTokens); for (unsigned n = 0; n < numTokens; n++) { auto tokenText = clang_getTokenSpelling(transUnit, tokens[n]); if (n == 0) { value.clear(); name = clang_getCString(tokenText); } else { CXTokenKind tokenKind = clang_getTokenKind(tokens[n]); if (tokenKind != CXToken_Comment) { const char *text = clang_getCString(tokenText); if (text) value += text; } } clang_disposeString(tokenText); } clang_disposeTokens(transUnit, tokens, numTokens); return !value.empty(); } static std::string remove_qualifiers(std::string &&typestr) { // libclang prints "const" keyword first // https://github.com/llvm-mirror/clang/blob/65acf43270ea2894dffa0d0b292b92402f80c8cb/lib/AST/TypePrinter.cpp#L137-L157 static std::regex re("^(const volatile\\s+)|^(const\\s+)|" "^(volatile\\s+)|\\*(\\s*restrict)$"); return std::regex_replace(typestr, re, ""); } static std::string get_unqualified_type_name(CXType clang_type) { return remove_qualifiers(get_clang_string(clang_getTypeSpelling(clang_type))); } static SizedType get_sized_type(CXType clang_type, StructManager &structs) { auto size = 8 * clang_Type_getSizeOf(clang_type); auto typestr = get_unqualified_type_name(clang_type); switch (clang_type.kind) { case CXType_Bool: case CXType_Char_U: case CXType_UChar: case CXType_UShort: case CXType_UInt: case CXType_ULong: case CXType_ULongLong: return CreateUInt(size); case CXType_Record: { // Struct map entry may not exist for forward declared types so we // create it now and fill it later auto s = structs.LookupOrAdd(typestr, size / 8); return CreateCStruct(typestr, s); } case CXType_Char_S: case CXType_SChar: case CXType_Short: case CXType_Long: case CXType_LongLong: case CXType_Int: return CreateInt(size); case CXType_Enum: { // The pretty printed type name contains `enum` prefix. That's not // helpful for us, so remove it. We have our own metadata. static std::regex re{ std::string{ ENUM_PREFIX } }; auto enum_name = std::regex_replace(typestr, re, ""); return CreateEnum(size, enum_name); } case CXType_Pointer: { auto pointee_type = clang_getPointeeType(clang_type); return CreatePointer(get_sized_type(pointee_type, structs)); } case CXType_ConstantArray: { auto elem_type = clang_getArrayElementType(clang_type); auto size = clang_getNumElements(clang_type); if (elem_type.kind == CXType_Char_S || elem_type.kind == CXType_Char_U) { // See btf.cpp; we need to signal well-formedness. return CreateString(size + 1); } auto elem_stype = get_sized_type(elem_type, structs); return CreateArray(size, elem_stype); } default: return CreateNone(); } } ClangParser::ClangParserHandler::ClangParserHandler() { index = clang_createIndex(1, 1); } ClangParser::ClangParserHandler::~ClangParserHandler() { clang_disposeTranslationUnit(translation_unit); clang_disposeIndex(index); } CXTranslationUnit ClangParser::ClangParserHandler::get_translation_unit() { return translation_unit; } CXErrorCode ClangParser::ClangParserHandler::parse_translation_unit( const char *source_filename, const char *const *command_line_args, int num_command_line_args, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, unsigned options) { // Clean up previous translation unit to prevent resource leak clang_disposeTranslationUnit(translation_unit); return clang_parseTranslationUnit2(index, source_filename, command_line_args, num_command_line_args, unsaved_files, num_unsaved_files, options, &translation_unit); } bool ClangParser::ClangParserHandler::check_diagnostics(bool bail_on_error) { for (unsigned int i = 0; i < clang_getNumDiagnostics(get_translation_unit()); i++) { CXDiagnostic diag = clang_getDiagnostic(get_translation_unit(), i); CXDiagnosticSeverity severity = clang_getDiagnosticSeverity(diag); CXString msg_str = clang_getDiagnosticSpelling(diag); auto &msg = error_msgs.emplace_back(clang_getCString(msg_str)); clang_disposeString(msg_str); if ((bail_on_error && severity == CXDiagnostic_Error) || severity == CXDiagnostic_Fatal) { // Do not fail on "too many errors" return !bail_on_error && msg == "too many errors emitted, stopping now"; } } return true; } CXCursor ClangParser::ClangParserHandler::get_translation_unit_cursor() { return clang_getTranslationUnitCursor(translation_unit); } bool ClangParser::ClangParserHandler::parse_file( const std::string &filename, const std::vector &args, std::vector &unsaved_files, bool bail_on_errors) { CXErrorCode error = parse_translation_unit( filename.c_str(), args.data(), args.size(), unsaved_files.data(), unsaved_files.size(), CXTranslationUnit_DetailedPreprocessingRecord); error_msgs.clear(); if (error) { LOG(V1) << "Clang error while parsing C definitions: " << error; return false; } return check_diagnostics(bail_on_errors); } const std::vector &ClangParser::ClangParserHandler:: get_error_messages() { return error_msgs; } bool ClangParser::ClangParserHandler::has_redefinition_error() { return std::ranges::any_of(error_msgs, [](const auto &msg) { return msg.find("redefinition") != std::string::npos; }); } bool ClangParser::ClangParserHandler::has_unknown_type_error() { return std::ranges::any_of(error_msgs, [](const auto &msg) { return ClangParser::get_unknown_type(msg).has_value(); }); } namespace { using visitFn = std::function; int visitChildren(CXCursor cursor, visitFn fn) { return clang_visitChildren( cursor, [](CXCursor c, CXCursor parent, CXClientData data) { auto *cb = static_cast(data); return (*cb)(c, parent); }, static_cast(&fn)); } } // namespace bool ClangParser::visit_children(CXCursor &cursor, BPFtrace &bpftrace) { int err = visitChildren(cursor, [&](CXCursor c, CXCursor parent) { if (clang_getCursorKind(c) == CXCursor_MacroDefinition) { std::string macro_name; std::string macro_value; if (translateMacro(c, macro_name, macro_value)) { definitions.macros[macro_name] = macro_value; } return CXChildVisit_Recurse; } // Each anon enum must have a unique ID otherwise two variants // with different names but same value will clobber each other // in enum_defs. static uint32_t anon_enum_count = 0; if (clang_getCursorKind(c) == CXCursor_EnumDecl) anon_enum_count++; if (clang_getCursorKind(parent) == CXCursor_EnumDecl) { // Store variant name to variant value auto enum_name = get_clang_string(clang_getCursorSpelling(parent)); // Anonymous enums have empty string names in libclang <= 15 if (enum_name.empty()) { std::ostringstream name; name << "enum "; enum_name = name.str(); } auto variant_name = get_clang_string(clang_getCursorSpelling(c)); auto variant_value = clang_getEnumConstantDeclValue(c); definitions.enums[variant_name] = std::make_pair(variant_value, enum_name); // Store enum name to variant value to variant name definitions.enum_defs[enum_name][variant_value] = variant_name; return CXChildVisit_Recurse; } if (clang_getCursorKind(parent) != CXCursor_StructDecl && clang_getCursorKind(parent) != CXCursor_UnionDecl) return CXChildVisit_Recurse; if (clang_getCursorKind(c) == CXCursor_FieldDecl) { // N.B. In the future this may be moved into the C definitions, but // currently this is rather tied in to a lot of other plumbing. auto &structs = bpftrace.structs; auto named_parent = get_named_parent(c); auto ptype = clang_getCanonicalType(clang_getCursorType(named_parent)); auto ptypestr = get_unqualified_type_name(ptype); auto ptypesize = clang_Type_getSizeOf(ptype); auto ident = get_clang_string(clang_getCursorSpelling(c)); auto offset = clang_Type_getOffsetOf(ptype, ident.c_str()) / 8; auto type = clang_getCanonicalType(clang_getCursorType(c)); auto sized_type = get_sized_type(type, structs); auto bitfield = getBitfield(c); // Initialize a new record type if needed if (!structs.Has(ptypestr)) structs.Add(ptypestr, ptypesize, false); auto str = structs.Lookup(ptypestr).lock(); if (str->allow_override) { str->ClearFields(); str->allow_override = false; } // No need to worry about redefined types b/c we should have already // checked clang diagnostics. The diagnostics will tell us if we have // duplicated types. str->AddField(ident, sized_type, offset, bitfield); } return CXChildVisit_Recurse; }); // clang_visitChildren returns a non-zero value if the traversal // was terminated by the visitor returning CXChildVisit_Break. return err == 0; } std::unordered_set ClangParser::get_incomplete_types() { if (input.empty()) return {}; // Parse without failing on compilation errors (ie incomplete structs) // because our goal is to enumerate all such errors. ClangParserHandler handler; if (!handler.parse_file("definitions.h", args, input_files, false)) return {}; struct TypeData { std::unordered_set complete_types; std::unordered_set incomplete_types; } type_data; CXCursor cursor = handler.get_translation_unit_cursor(); visitChildren(cursor, [&](CXCursor c, CXCursor parent) { // We look for field declarations and store the parent // as a fully defined type because we know we're looking at a // type definition. // // Then look at the field declaration itself. If it's a record // type (ie struct or union), check if we think it's a fully // defined type. If not, add it to incomplete types set. if (clang_getCursorKind(parent) == CXCursor_EnumDecl || (clang_getCursorKind(c) == CXCursor_FieldDecl && (clang_getCursorKind(parent) == CXCursor_UnionDecl || clang_getCursorKind(parent) == CXCursor_StructDecl))) { auto parent_type = clang_getCanonicalType(clang_getCursorType(parent)); type_data.complete_types.emplace(get_unqualified_type_name(parent_type)); auto cursor_type = clang_getCanonicalType(clang_getCursorType(c)); // We need layouts of pointee types because users could dereference if (cursor_type.kind == CXType_Pointer) cursor_type = clang_getPointeeType(cursor_type); if (cursor_type.kind == CXType_Record || cursor_type.kind == CXType_Enum) { auto type_name = get_unqualified_type_name(cursor_type); if (!type_data.complete_types.contains(type_name)) type_data.incomplete_types.emplace(std::move(type_name)); } } return CXChildVisit_Recurse; }); return type_data.incomplete_types; } void ClangParser::resolve_incomplete_types_from_btf(BPFtrace &bpftrace) { std::unordered_set last_incomplete; while (true) { // Collect incomplete types and retrieve their definitions from BTF. auto incomplete_types = get_incomplete_types(); // No need to continue if nothing is incomplete. if (incomplete_types.empty()) { break; } // It is an error to attempt to continue if we've converge on a set of // incomplete types which is not changing. if (incomplete_types == last_incomplete) { break; } bpftrace.btf_set_.insert(incomplete_types.cbegin(), incomplete_types.cend()); input_files.back() = get_btf_generated_header(bpftrace); last_incomplete = std::move(incomplete_types); } } // Parse the program using Clang. // // Type resolution rules: // // If BTF is available, necessary types are retrieved from there, otherwise we // rely on headers and types supplied by the user (we also include // linux/types.h in some cases, e.., for tracepoints). // // The following types are taken from BTF (if available): // 1. Types explicitly used in the program (taken from bpftrace.btf_set_). // 2. Types used by some of the defined types (as struct members). This step // is done recursively, however, as it may take long time, there is a // maximal depth set. It is computed as the maximum level of nested field // accesses in the program and can be manually overridden using // the BPFTRACE_MAX_TYPE_RES_ITERATIONS env variable. // 3. Typedefs used by some of the defined types. These are also resolved // recursively, however, they must be resolved completely as any unknown // typedef will cause the parser to fail (even if the type is not used in // the program). // // If any of the above steps retrieves a definition that redefines some // existing (user-defined) type, no BTF types are used and all types must be // provided. In practice, this means that user may use kernel types without // providing their definitions but once he redefines any kernel type, he must // provide all necessary definitions. bool ClangParser::parse(ast::Program *program, BPFtrace &bpftrace, std::vector extra_flags) { std::stringstream ss; ss << "#include \n"; for (const auto &stmt : program->c_statements) { ss << stmt->data << "\n"; } input = ss.str(); input_files = getTranslationUnitFiles(CXUnsavedFile{ .Filename = "definitions.h", .Contents = input.c_str(), .Length = input.size(), }); args = { "-isystem", "/bpftrace/include" }; auto system_paths = system_include_paths(); for (auto &path : system_paths) { args.push_back("-isystem"); args.push_back(path.c_str()); } std::string arch_path = get_arch_include_path(); args.push_back("-isystem"); args.push_back(arch_path.c_str()); for (auto &flag : extra_flags) { args.push_back(flag.c_str()); } // Push the generated BTF header into input files. // The header must be the last file in the vector since the following // methods count on it. If BTF is not available, the header is empty. input_files.emplace_back(bpftrace.has_btf_data() ? get_btf_generated_header(bpftrace) : get_empty_btf_generated_header()); bool btf_conflict = false; ClangParserHandler handler; if (bpftrace.has_btf_data()) { // We set these args early because some systems may not have // (containers) and fully rely on BTF. // Prevent BTF generated header from redefining stuff found // in args.push_back("-D_LINUX_TYPES_H"); // Let script know we have BTF -- this is useful for prewritten tools to // conditionally include headers if BTF isn't available. args.push_back("-DBPFTRACE_HAVE_BTF"); if (handler.parse_file("definitions.h", args, input_files, false) && handler.has_redefinition_error()) btf_conflict = true; if (!btf_conflict) { resolve_incomplete_types_from_btf(bpftrace); if (handler.parse_file("definitions.h", args, input_files, false) && handler.has_redefinition_error()) btf_conflict = true; } if (!btf_conflict) { resolve_unknown_typedefs_from_btf(bpftrace); if (handler.parse_file("definitions.h", args, input_files, false) && handler.has_redefinition_error()) btf_conflict = true; } } if (btf_conflict) { // There is a conflict (redefinition) between user-supplied types and // types taken from BTF. We cannot use BTF in such a case. args.pop_back(); args.pop_back(); input_files.back() = get_empty_btf_generated_header(); } if (!handler.parse_file("definitions.h", args, input_files)) { if (handler.has_redefinition_error()) { LOG(WARNING) << "Cannot take type definitions from BTF since there is " "a redefinition conflict with user-defined types."; } else if (handler.has_unknown_type_error()) { LOG(ERROR) << "Include headers with missing type definitions or install " "BTF information to your system."; if (bpftrace.btf_->objects_cnt() > 2) { LOG(WARNING) << "Trying to dump BTF from multiple kernel modules at once. " << "This is currently not possible, use probes from a single " "module" << " (and/or vmlinux) only."; } } return false; } CXCursor cursor = handler.get_translation_unit_cursor(); return visit_children(cursor, bpftrace); } // Parse the given Clang diagnostics message and if it has one of the forms: // unknown type name 'type_t' // use of undeclared identifier 'type_t' // return type_t. std::optional ClangParser::ClangParser::get_unknown_type( const std::string &diagnostic_msg) { const std::vector unknown_type_msgs = { "unknown type name \'", "use of undeclared identifier \'" }; for (const auto &unknown_type_msg : unknown_type_msgs) { if (diagnostic_msg.starts_with(unknown_type_msg)) { return diagnostic_msg.substr(unknown_type_msg.length(), diagnostic_msg.length() - unknown_type_msg.length() - 1); } } return {}; } std::unordered_set ClangParser::get_unknown_typedefs() { // Parse without failing on compilation errors (ie unknown types) because // our goal is to enumerate and analyse all such errors ClangParserHandler handler; if (!handler.parse_file("definitions.h", args, input_files, false)) return {}; std::unordered_set unknown_typedefs; // Search for error messages of the form: // unknown type name 'type_t' // that imply an unresolved typedef of type_t. This cannot be done in // clang_visitChildren since clang does not have the unknown type names. for (const auto &msg : handler.get_error_messages()) { auto unknown_type = get_unknown_type(msg); if (unknown_type) unknown_typedefs.emplace(unknown_type.value()); } return unknown_typedefs; } void ClangParser::resolve_unknown_typedefs_from_btf(BPFtrace &bpftrace) { bool check_unknown_types = true; while (check_unknown_types) { // Collect unknown typedefs and retrieve their definitions from BTF. // These must be resolved completely since any unknown typedef will cause // the parser to fail (even if that type is not used in the program). auto incomplete_types = get_unknown_typedefs(); size_t types_cnt = bpftrace.btf_set_.size(); bpftrace.btf_set_.insert(incomplete_types.cbegin(), incomplete_types.cend()); input_files.back() = get_btf_generated_header(bpftrace); // No need to continue if no more types were added check_unknown_types = types_cnt != bpftrace.btf_set_.size(); } } CXUnsavedFile ClangParser::get_btf_generated_header(BPFtrace &bpftrace) { // Note that `c_def` will provide the full set of types if an empty set is // used here. We only want the types in `btf_set_` or nothing at all, so // don't generate anything if this set is empty. if (!bpftrace.btf_set_.empty()) { btf_cdef = bpftrace.btf_->c_def(bpftrace.btf_set_); } return CXUnsavedFile{ .Filename = "/bpftrace/include/__btf_generated_header.h", .Contents = btf_cdef.c_str(), .Length = btf_cdef.size(), }; } CXUnsavedFile ClangParser::get_empty_btf_generated_header() { btf_cdef = ""; return CXUnsavedFile{ .Filename = "/bpftrace/include/__btf_generated_header.h", .Contents = btf_cdef.c_str(), .Length = btf_cdef.size(), }; } std::string ClangParser::get_arch_include_path() { struct utsname utsname; uname(&utsname); return "/usr/include/" + std::string(utsname.machine) + "-linux-gnu"; } static void query_clang_include_dirs(std::vector &result) { std::vector args; args.emplace_back("clang-" + std::to_string(LLVM_VERSION_MAJOR)); args.emplace_back("-Wp,-v"); args.emplace_back("-x"); args.emplace_back("c"); args.emplace_back("-fsyntax-only"); args.emplace_back("/dev/null"); auto check = util::exec_system(args); if (!check) { // Exec failed, ignore and move on. consumeError(std::move(check)); return; } std::istringstream lines(*check); std::string line; while (std::getline(lines, line) && line != "#include <...> search starts here:") { } while (std::getline(lines, line) && line != "End of search list.") result.push_back(util::trim(line)); } std::vector ClangParser::system_include_paths() { std::vector result; std::istringstream lines(SYSTEM_INCLUDE_PATHS); std::string line; while (std::getline(lines, line, ':')) { if (line == "auto") query_clang_include_dirs(result); else result.push_back(util::trim(line)); } if (result.empty()) result = { "/usr/local/include", "/usr/include" }; return result; } ast::Pass CreateClangParsePass(std::vector &&extra_flags) { return ast::Pass::create("ClangParser", [extra_flags = std::move(extra_flags)]( ast::ASTContext &ast, BPFtrace &b) -> Result { ClangParser parser; if (!parser.parse(ast.root, b, extra_flags)) { return make_error(); } return std::move(parser.definitions); }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/clang_parser.h000066400000000000000000000015701526721631600210700ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" #include namespace bpftrace::ast { // When the imported definitions are parsed with clang, relevant C definitions // are centralized here to be consumed by later passes. class CDefinitions : public ast::State<"C-definitions"> { public: // Map of macro name to macro definition. std::map macros; // Map of enum variant_name to (variant_value, enum_name). std::map> enums; // Map of enum_name to map of variant_value to variant_name. std::map> enum_defs; }; class ClangParseError : public ErrorInfo { public: static char ID; void log(llvm::raw_ostream &OS) const override; }; ast::Pass CreateClangParsePass(std::vector &&extra_flags = {}); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/codegen_llvm.cpp000066400000000000000000005733201526721631600214300ustar00rootroot00000000000000#include #include #include #include #include #include // Required for LLVM_VERSION_MAJOR. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "arch/arch.h" #include "ast/ast.h" #include "ast/async_event_types.h" #include "ast/async_ids.h" #include "ast/codegen_helper.h" #include "ast/context.h" #include "ast/dibuilderbpf.h" #include "ast/irbuilderbpf.h" #include "ast/location.h" #include "ast/passes/ap_probe_expansion.h" #include "ast/passes/clang_build.h" #include "ast/passes/codegen_llvm.h" #include "ast/passes/control_flow_analyser.h" #include "ast/passes/link.h" #include "ast/passes/named_param.h" #include "ast/passes/types/type_map.h" #include "ast/visitor.h" #include "async_action.h" #include "bpfmap.h" #include "bpftrace.h" #include "config.h" #include "globalvars.h" #include "log.h" #include "map_info.h" #include "required_resources.h" #include "types.h" #include "util/bpf_names.h" #include "util/cgroup.h" #include "util/cpus.h" #include "util/exceptions.h" namespace bpftrace::ast { using namespace llvm; static constexpr char LLVMTargetTriple[] = "bpf"; static constexpr auto LICENSE = "LICENSE"; static auto getTargetMachine() { static auto *target = []() { std::string error_str; const auto *target = llvm::TargetRegistry::lookupTarget( #if LLVM_VERSION_MAJOR >= 22 Triple(LLVMTargetTriple), #else LLVMTargetTriple, #endif error_str); if (!target) { throw util::FatalUserException( "Could not find bpf llvm target, does your llvm support it?"); } auto *machine = target->createTargetMachine( #if LLVM_VERSION_MAJOR >= 21 Triple(LLVMTargetTriple), #else LLVMTargetTriple, #endif "generic", "", TargetOptions(), std::optional()); machine->setOptLevel(llvm::CodeGenOptLevel::Aggressive); return machine; }(); return target; } static bool shouldForceInitPidNs(const ExpressionList &args) { return args.size() == 1 && args.at(0).as()->ident == "init"; } namespace { class InternalError : public ErrorInfo { public: InternalError(std::string msg) : msg_(std::move(msg)) {}; static char ID; void log(llvm::raw_ostream &OS) const override { OS << msg_; } private: std::string msg_; }; char InternalError::ID; struct VariableLLVM { llvm::Value *value; llvm::Type *type; }; // ScopedExpr ties an SSA value to a "delete" function, that typically will end // the lifetime of some needed storage. You must explicitly construct a // ScopedExpr from either: // * A value only, with no associated function when out of scope. // * A value and associated function to run when out of scope. // * A value and another ScopedExpr, whose lifetime will be preserved until // this value is out of scope. class ScopedExpr { public: // Neither a value nor a deletion method. explicit ScopedExpr() = default; // Value only. explicit ScopedExpr(Value *value) : value_(value) { } // Value with an explicit deletion method. explicit ScopedExpr(Value *value, llvm::unique_function &&deleter) : value_(value), deleter_(std::move(deleter)) { } // Value with another ScopedExpr whose lifetime should be bound. explicit ScopedExpr(Value *value, ScopedExpr &&other) : value_(value) { deleter_.swap(other.deleter_); } ScopedExpr(ScopedExpr &&other) : value_(other.value_) { deleter_.swap(other.deleter_); } ScopedExpr &operator=(ScopedExpr &&other) { value_ = other.value_; deleter_.swap(other.deleter_); return *this; } ScopedExpr(const ScopedExpr &other) = delete; ScopedExpr &operator=(const ScopedExpr &other) = delete; ~ScopedExpr() { if (deleter_) { deleter_.value()(); deleter_.reset(); } } Value *value() { return value_; } private: Value *value_ = nullptr; std::optional> deleter_; }; class CodegenLLVM : public Visitor { public: explicit CodegenLLVM(ASTContext &ast, BPFtrace &bpftrace, CDefinitions &c_definitions, NamedParamInfo &named_param_info, LLVMContext &llvm_ctx, ExpansionResult &expansions, const TypeMap &type_map); using Visitor::visit; ScopedExpr visit(Integer &integer); ScopedExpr visit(NegativeInteger &integer); ScopedExpr visit(Boolean &boolean); ScopedExpr visit(String &string); ScopedExpr visit(Identifier &identifier); ScopedExpr visit(Builtin &builtin); ScopedExpr visit(Call &call); ScopedExpr visit(Map &map); ScopedExpr visit(MapAddr &map_addr); ScopedExpr visit(Variable &var); ScopedExpr visit(VariableAddr &var_addr); ScopedExpr visit(Binop &binop); ScopedExpr visit(Unop &unop); ScopedExpr visit(IfExpr &if_expr); ScopedExpr visit(FieldAccess &acc); ScopedExpr visit(ArrayAccess &arr); ScopedExpr visit(TupleAccess &acc); ScopedExpr visit(MapAccess &acc); ScopedExpr visit(Cast &cast); ScopedExpr visit(Tuple &tuple); ScopedExpr visit(Record &record); ScopedExpr visit(ExprStatement &expr); ScopedExpr visit(AssignMapStatement &assignment); ScopedExpr visit(AssignVarStatement &assignment); ScopedExpr visit(VarDeclStatement &decl); ScopedExpr visit(Unroll &unroll); ScopedExpr visit(While &while_block); ScopedExpr visit(For &f, Map &map); ScopedExpr visit(For &f, Range &range); ScopedExpr visit(For &f); ScopedExpr visit(Jump &jump); ScopedExpr visit(Probe &probe); ScopedExpr visit(Subprog &subprog); ScopedExpr visit(Program &program); ScopedExpr visit(BlockExpr &block); // compile is the primary entrypoint; it will return the generated LLVMModule. // Only one call to `compile` is permitted per instantiation. std::unique_ptr compile(); private: int getNextIndexForProbe(); ScopedExpr createLogicalAnd(Binop &binop); ScopedExpr createLogicalOr(Binop &binop); void createFormatStringCall(Call &call, int id, const std::vector &call_args, const std::string &call_name, async_action::AsyncAction async_action); void createPrintMapCall(Call &call); void createPrintNonMapCall(Call &call); void createJoinCall(Call &call, int id); void createMapDefinition(const std::string &name, bpf_map_type map_type, uint64_t max_entries, const SizedType &key_type, const SizedType &value_type); Value *createAnonStruct( const SizedType &stype, const std::vector> &vals, const std::string &name, const Location &loc); ScopedExpr createAnonStructAccess(const SizedType &stype, ScopedExpr &&expr_value, size_t field_idx); void createVariableStore(const SizedType &src_type, Value *src, const SizedType &dst_type, Value *dst, const Location &loc, bool recursing = false); void createMapBufferStore(const SizedType &src_type, Value *src, const SizedType &dst_type, Value *dst, const Location &loc, bool recursing = false); void generate_maps(const RequiredResources &required_resources); void generate_global_vars(const RequiredResources &resources, const ::bpftrace::Config &bpftrace_config); // Generate a probe for `current_attach_point_` // This is used to progress state (eg. asyncids) in this class instance for // invalid probes that still need to be visited. void generateProbe(Probe &probe, const std::string &name, FunctionType *func_type); // Generate a probe and register it to the BPFtrace class. void add_probe(AttachPoint &ap, Probe &probe, FunctionType *func_type); [[nodiscard]] ScopedExpr getMapKey(Map &map, Expression &key_expr); [[nodiscard]] ScopedExpr getMultiMapKey( Map &map, Expression &key_expr, const std::vector &extra_keys, const Location &loc); void compareStructure(const SizedType &our_type, llvm::Type *llvm_type); llvm::Function *createLog2Function(); llvm::Function *createLinearFunction(); MDNode *createLoopMetadata(); std::pair getString(Expression &expr); ScopedExpr binop_string(Binop &binop); ScopedExpr binop_integer_array(Binop &binop); ScopedExpr binop_buf(Binop &binop); ScopedExpr binop_int(Binop &binop); ScopedExpr binop_ptr(Binop &binop); ScopedExpr unop_int(Unop &unop); ScopedExpr unop_ptr(Unop &unop); ScopedExpr kstack(const SizedType &stype, const Location &loc); ScopedExpr ustack(const SizedType &stype, const Location &loc); ScopedExpr dw_ustack(const SizedType &stype, const Location &loc); int get_probe_id(); // Create return instruction // // If null, return value will depend on current attach point (void in subprog) void createRet(Value *value = nullptr); int getReturnValueForProbe(ProbeType probe_type); template ScopedExpr getIntegerLiteral(size_t size, T value); ScopedExpr readDatastructElemFromStack(ScopedExpr &&scoped_src, Value *index, const SizedType &data_type, const SizedType &elem_type); ScopedExpr readDatastructElemFromStack(ScopedExpr &&scoped_src, Value *index, llvm::Type *data_type, const SizedType &elem_type); ScopedExpr probereadDatastructElem(ScopedExpr &&scoped_src, Value *offset, const SizedType &data_type, const SizedType &elem_type, const Location &loc, const std::string &temp_name); ScopedExpr createIncDec(Unop &unop); llvm::Function *createMapLenCallback(); // This function creates the context type and value for callbacks. Extra // fields for this context may be passed as the `extra_fields` argument. // // The context created here is suitable for use in `createForCallback`. std::pair createForContext( For &f, std::vector &&extra_fields = {}); // This creates and invokes a callback function that captures all required // arguments in the context type. Note that all callbacks require some // argument for the context; this is found by finding a parameter named `ctx` // in the `debug_arg`. This must be provided by the caller. // // The provided `decl` function is invoked to construct the scoped value for // the local context. llvm::Function *createForCallback( For &f, const std::string &name, ArrayRef args, const Struct &debug_args, llvm::Type *ctx_t, std::function decl); llvm::Function *createForEachMapCallback(const For &f, const Map &map, llvm::Type *ctx_t); Value *createFmtString(int print_id); bool canAggPerCpuMapElems(bpf_map_type map_type, const SizedType &val_type); void maybeAllocVariable(const std::string &var_ident, const SizedType &var_type, const Location &loc); VariableLLVM *maybeGetVariable(const std::string &var_ident); VariableLLVM &getVariable(const std::string &var_ident); GlobalVariable *DeclareKernelVar(const std::string &name); ScopedExpr createExternFuncCall(const std::string &name, llvm::Type *return_type, llvm::ArrayRef arg_types, llvm::ArrayRef arg_values, const Location &loc); ASTContext &ast_; BPFtrace &bpftrace_; CDefinitions &c_definitions_; NamedParamInfo &named_param_info_; LLVMContext &llvm_ctx_; ExpansionResult &expansions_; const TypeMap &type_map_; std::unique_ptr module_; AsyncIds async_ids_; IRBuilderBPF b_; DIBuilderBPF debug_; const DataLayout &datalayout() const { return module_->getDataLayout(); } Value *ctx_; llvm::DILocalScope *scope_ = nullptr; AttachPoint *current_attach_point_ = nullptr; std::string probefull_; uint64_t probe_count_ = 0; int next_probe_index_ = 1; bool inside_subprog_ = false; bool in_session_return_branch_ = false; std::vector scope_stack_; std::unordered_map> variables_; std::unordered_map map_types_; llvm::Function *linear_func_ = nullptr; llvm::Function *log2_func_ = nullptr; MDNode *loop_metadata_ = nullptr; size_t getStructSize(StructType *s) { return module_->getDataLayout().getTypeAllocSize(s); } // The `loops_` vector holds the stack of loops, with a set of functions for // `continue` and `break` respectively. These are functions as they might // lazily initialize state and avoid creating basic blocks if they are not // used. std::vector< std::tuple, std::function>> loops_; std::unordered_map probe_names_; std::unordered_map extern_funcs_; }; } // namespace CodegenLLVM::CodegenLLVM(ASTContext &ast, BPFtrace &bpftrace, CDefinitions &c_definitions, NamedParamInfo &named_param_info, LLVMContext &llvm_ctx, ExpansionResult &expansions, const TypeMap &type_map) : ast_(ast), bpftrace_(bpftrace), c_definitions_(c_definitions), named_param_info_(named_param_info), llvm_ctx_(llvm_ctx), expansions_(expansions), type_map_(type_map), module_(std::make_unique("bpftrace", llvm_ctx)), b_(llvm_ctx, *module_, bpftrace, async_ids_), debug_(*module_) { #if LLVM_VERSION_MAJOR >= 21 module_->setTargetTriple(Triple(LLVMTargetTriple)); #else module_->setTargetTriple(LLVMTargetTriple); #endif module_->setDataLayout(getTargetMachine()->createDataLayout()); debug_.createCompileUnit(dwarf::DW_LANG_C, debug_.file, "bpftrace", false, "", 0, StringRef(), DICompileUnit::DebugEmissionKind::LineTablesOnly); module_->addModuleFlag(llvm::Module::Warning, "Debug Info Version", llvm::DEBUG_METADATA_VERSION); // The unwind table causes problems when linking via libbpf. module_->setUwtable(llvm::UWTableKind::None); // Set license of BPF programs. const std::string license = ::bpftrace::Config::get_license_str( bpftrace_.config_->license); auto license_size = license.size() + 1; auto *license_var = llvm::dyn_cast( module_->getOrInsertGlobal(LICENSE, ArrayType::get(b_.getInt8Ty(), license_size))); license_var->setInitializer( ConstantDataArray::getString(module_->getContext(), license)); license_var->setSection("license"); license_var->addDebugInfo( debug_.createGlobalVariable(LICENSE, CreateString(license_size))); } template ScopedExpr CodegenLLVM::getIntegerLiteral(size_t size, T value) { switch (size) { case 1: return ScopedExpr(b_.getInt8(value)); case 2: return ScopedExpr(b_.getInt16(value)); case 4: return ScopedExpr(b_.getInt32(value)); case 8: return ScopedExpr(b_.getInt64(value)); default: LOG(BUG) << "Unsupported integer size: " << size; } __builtin_unreachable(); } ScopedExpr CodegenLLVM::visit(Integer &integer) { return getIntegerLiteral(type_map_.type(&integer).GetSize(), integer.value); } ScopedExpr CodegenLLVM::visit(NegativeInteger &integer) { return getIntegerLiteral(type_map_.type(&integer).GetSize(), integer.value); } ScopedExpr CodegenLLVM::visit(Boolean &boolean) { return ScopedExpr(b_.getInt1(boolean.value)); } ScopedExpr CodegenLLVM::visit(String &string) { std::string s(string.value); auto *string_var = llvm::dyn_cast(module_->getOrInsertGlobal( s, ArrayType::get(b_.getInt8Ty(), type_map_.type(&string).GetSize()))); string_var->setInitializer( ConstantDataArray::getString(module_->getContext(), s)); return ScopedExpr(string_var); } // NB: we do not resolve identifiers that are structs. That is because in // bpftrace you cannot really instantiate a struct. ScopedExpr CodegenLLVM::visit(Identifier &identifier) { if (c_definitions_.enums.contains(identifier.ident)) { return ScopedExpr( b_.getInt64(std::get<0>(c_definitions_.enums[identifier.ident]))); } else { LOG(BUG) << "unknown identifier \"" << identifier.ident << "\""; __builtin_unreachable(); } } ScopedExpr CodegenLLVM::kstack(const SizedType &stype, const Location &loc) { StructType *stack_struct_type = b_.GetStackStructType(stype.stack_type); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *merge_block = BasicBlock::Create(module_->getContext(), "merge_block", parent); auto *stack = b_.CreateCallStackAllocation(stype, stype.stack_type.name(), loc); b_.CreateMemsetBPF(stack, b_.getInt8(0), datalayout().getTypeStoreSize(stack_struct_type)); BasicBlock *get_stack_success = BasicBlock::Create(module_->getContext(), "get_stack_success", parent); BasicBlock *get_stack_fail = BasicBlock::Create(module_->getContext(), "get_stack_fail", parent); Value *stack_size = b_.CreateGetStack(ctx_, b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(1) }), stype.stack_type, loc); Value *condition = b_.CreateICmpSGE(stack_size, b_.getInt64(0)); b_.CreateCondBr(condition, get_stack_success, get_stack_fail); b_.SetInsertPoint(get_stack_fail); b_.CreateRuntimeError(RuntimeErrorId::KSTACK, loc); b_.CreateBr(merge_block); b_.SetInsertPoint(get_stack_success); Value *num_frames = b_.CreateUDiv(stack_size, b_.getInt64(stype.stack_type.elem_size())); b_.CreateStore(num_frames, b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateBr(merge_block); b_.SetInsertPoint(merge_block); return ScopedExpr(stack); } ScopedExpr CodegenLLVM::ustack(const SizedType &stype, const Location &loc) { StructType *stack_struct_type = b_.GetStackStructType(stype.stack_type); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *merge_block = BasicBlock::Create(module_->getContext(), "merge_block", parent); auto *stack = b_.CreateCallStackAllocation(stype, stype.stack_type.name(), loc); b_.CreateMemsetBPF(stack, b_.getInt8(0), datalayout().getTypeStoreSize(stack_struct_type)); BasicBlock *get_stack_success = BasicBlock::Create(module_->getContext(), "get_stack_success", parent); BasicBlock *get_stack_fail = BasicBlock::Create(module_->getContext(), "get_stack_fail", parent); Value *stack_size = b_.CreateGetStack(ctx_, b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(3) }), stype.stack_type, loc); Value *condition = b_.CreateICmpSGE(stack_size, b_.getInt64(0)); b_.CreateCondBr(condition, get_stack_success, get_stack_fail); b_.SetInsertPoint(get_stack_fail); b_.CreateRuntimeError(RuntimeErrorId::USTACK, loc); b_.CreateBr(merge_block); b_.SetInsertPoint(get_stack_success); Value *num_frames = b_.CreateUDiv(stack_size, b_.getInt64(stype.stack_type.elem_size())); b_.CreateStore(num_frames, b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(2) })); // store pid b_.CreateStore(b_.CreateGetPid(loc, false), b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(0) })); // store probe id b_.CreateStore(b_.GetIntSameSize(get_probe_id(), stack_struct_type->getTypeAtIndex(1)), b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateBr(merge_block); b_.SetInsertPoint(merge_block); return ScopedExpr(stack); } ScopedExpr CodegenLLVM::dw_ustack(const SizedType &stype, const Location &loc) { StructType *stack_struct_type = b_.GetStackStructType(stype.stack_type); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *merge_block = BasicBlock::Create(module_->getContext(), "merge_block", parent); auto *stack = b_.CreateCallStackAllocation(stype, stype.stack_type.name(), loc); b_.CreateMemsetBPF(stack, b_.getInt8(0), datalayout().getTypeStoreSize(stack_struct_type)); BasicBlock *get_stack_success = BasicBlock::Create(module_->getContext(), "get_stack_success", parent); BasicBlock *get_stack_fail = BasicBlock::Create(module_->getContext(), "get_stack_fail", parent); Value *stack_trace = b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(3) }); Value *p_stack_size = b_.getInt32(stype.stack_type.limit * stype.stack_type.elem_size()); Value *tgid = b_.CreateGetPid(loc, false); std::array arg_types = { b_.getPtrTy(), b_.getPtrTy(), b_.getInt32Ty(), b_.getInt32Ty() }; std::array arg_values = { ctx_, stack_trace, p_stack_size, tgid }; Value *stack_size = createExternFuncCall("__ustack_dwunwind", b_.getInt64Ty(), arg_types, arg_values, loc) .value(); Value *condition = b_.CreateICmpSGE(stack_size, b_.getInt64(0)); b_.CreateCondBr(condition, get_stack_success, get_stack_fail); b_.SetInsertPoint(get_stack_fail); BasicBlock *no_dwarf_block = BasicBlock::Create(module_->getContext(), "no_dwarf_data", parent); BasicBlock *ustack_error_block = BasicBlock::Create(module_->getContext(), "ustack_error", parent); Value *is_no_dwarf = b_.CreateICmpEQ(stack_size, b_.getInt64(-2)); b_.CreateCondBr(is_no_dwarf, no_dwarf_block, ustack_error_block); b_.SetInsertPoint(no_dwarf_block); b_.CreateRuntimeError(RuntimeErrorId::DW_USTACK_NO_DWARF, loc); b_.CreateBr(merge_block); b_.SetInsertPoint(ustack_error_block); b_.CreateRuntimeError(RuntimeErrorId::USTACK, loc); b_.CreateBr(merge_block); b_.SetInsertPoint(get_stack_success); Value *num_frames = b_.CreateUDiv(stack_size, b_.getInt64(stype.stack_type.elem_size())); b_.CreateStore(num_frames, b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(2) })); // store pid b_.CreateStore(b_.CreateGetPid(loc, false), b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(0) })); // store probe id b_.CreateStore(b_.GetIntSameSize(get_probe_id(), stack_struct_type->getTypeAtIndex(1)), b_.CreateGEP(stack_struct_type, stack, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateBr(merge_block); b_.SetInsertPoint(merge_block); return ScopedExpr(stack); } int CodegenLLVM::get_probe_id() { auto begin = bpftrace_.resources.probe_ids.begin(); auto end = bpftrace_.resources.probe_ids.end(); auto found = std::find(begin, end, probefull_); if (found == end) { bpftrace_.resources.probe_ids.push_back(probefull_); } return std::distance(begin, found); } ScopedExpr CodegenLLVM::visit(Builtin &builtin) { if (builtin.ident == "nsecs") { return ScopedExpr(b_.CreateGetNs(TimestampMode::boot, builtin.loc)); } else if (builtin.ident == "__builtin_elapsed") { AllocaInst *key = b_.CreateAllocaBPF(b_.getInt64Ty(), "elapsed_key"); b_.CreateStore(b_.getInt64(0), key); auto type = CreateUInt64(); auto *start = b_.CreateMapLookupElem( to_string(MapType::Elapsed), key, type, builtin.loc); Value *ns_value = b_.CreateGetNs(TimestampMode::boot, builtin.loc); Value *ns_delta = b_.CreateSub(ns_value, start); // start won't be on stack, no need to LifeTimeEnd it b_.CreateLifetimeEnd(key); return ScopedExpr(ns_delta); } else if (builtin.ident == "kstack") { return kstack(type_map_.type(&builtin), builtin.loc); } else if (builtin.ident == "ustack") { return ustack(type_map_.type(&builtin), builtin.loc); } else if (builtin.ident == "__builtin_dw_ustack") { return dw_ustack(type_map_.type(&builtin), builtin.loc); } else if (builtin.ident == "pid") { return ScopedExpr(b_.CreateGetPid(builtin.loc, false)); } else if (builtin.ident == "tid") { return ScopedExpr(b_.CreateGetTid(builtin.loc, false)); } else if (builtin.ident == "__builtin_usermode") { if (arch::Host::Machine == arch::Machine::X86_64) { auto cs_offset = arch::Host::register_to_pt_regs_offset("cs"); if (!cs_offset) { builtin.addError() << "No CS register?"; return ScopedExpr(b_.getInt64(0)); } Value *cs = b_.CreateRegisterRead(ctx_, cs_offset.value(), "reg_cs"); Value *mask = b_.getInt64(0x3); Value *is_usermode = b_.CreateICmpEQ(b_.CreateAnd(cs, mask), b_.getInt64(3), "is_usermode"); Value *expr = b_.CreateZExt(is_usermode, b_.GetType(type_map_.type(&builtin)), "usermode_result"); return ScopedExpr(expr); } else { // We lack an implementation. builtin.addError() << "not supported on architecture " << arch::Host::Machine; return ScopedExpr(b_.getInt64(0)); } } else if (builtin.ident == "__builtin_cpu") { Value *cpu = b_.CreateGetCpuId(builtin.loc); return ScopedExpr(b_.CreateZExt(cpu, b_.getInt64Ty())); } else if (builtin.ident == "__builtin_ncpus") { return ScopedExpr(b_.CreateLoad(b_.getInt64Ty(), module_->getGlobalVariable(std::string( bpftrace::globalvars::NUM_CPUS)), "num_cpu.cmp")); } else if (builtin.ident == "__builtin_comm") { AllocaInst *buf = b_.CreateAllocaBPF(type_map_.type(&builtin), "__builtin_comm"); // initializing memory needed for older kernels: b_.CreateMemsetBPF(buf, b_.getInt8(0), type_map_.type(&builtin).GetSize()); b_.CreateGetCurrentComm(buf, type_map_.type(&builtin).GetSize(), builtin.loc); return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); } else if (builtin.ident == "__builtin_func") { // fentry/fexit probes do not have access to registers, so require use of // the get_func_ip helper to get the instruction pointer. // // For [ku]retprobes, the IP register will not be pointing to the function // we want to trace. It may point to a kernel trampoline, or it may point to // the caller of the traced function, as it fires after the "ret" // instruction has executed. // // The get_func_ip helper resolves these issues for us. // // But do not use the it for non-ret [ku]probes (which can be used with // offsets), as the helper will fail for probes placed within a function // (not at the entry). Value *value = nullptr; auto probe_type = probetype(current_attach_point_->provider); if (probe_type == ProbeType::fentry || probe_type == ProbeType::fexit || probe_type == ProbeType::kretprobe || probe_type == ProbeType::uretprobe || in_session_return_branch_) { value = b_.CreateGetFuncIp(ctx_, builtin.loc); } else { value = b_.CreateRegisterRead(ctx_, builtin.ident); } if (type_map_.type(&builtin).IsUsymTy()) { value = b_.CreateUSym(value, get_probe_id(), builtin.loc); return ScopedExpr(value, [this, value]() { b_.CreateLifetimeEnd(value); }); } return ScopedExpr(value); } else if (builtin.is_argx() || builtin.ident == "__builtin_retval") { auto probe_type = probetype(current_attach_point_->provider); if (type_map_.type(&builtin).is_funcarg) { return ScopedExpr( b_.CreateKFuncArg(ctx_, type_map_.type(&builtin), builtin.ident)); } Value *value = nullptr; if (builtin.is_argx() && probe_type == ProbeType::rawtracepoint) value = b_.CreateRawTracepointArg(ctx_, builtin.ident); else value = b_.CreateRegisterRead(ctx_, builtin.ident); if (type_map_.type(&builtin).IsUsymTy()) { value = b_.CreateUSym(value, get_probe_id(), builtin.loc); return ScopedExpr(value, [this, value]() { b_.CreateLifetimeEnd(value); }); } return ScopedExpr(value); } else if (builtin.ident == "args" && probetype(current_attach_point_->provider) == ProbeType::uprobe) { // uprobe args record is built on stack return ScopedExpr( b_.CreateUprobeArgsRecord(ctx_, type_map_.type(&builtin))); } else if (builtin.ident == "args" || builtin.ident == "ctx") { // ctx is undocumented builtin: for debugging. return ScopedExpr(ctx_); } else if (builtin.ident == "__builtin_cpid") { return ScopedExpr(b_.CreateLoad(b_.getInt64Ty(), module_->getGlobalVariable(std::string( bpftrace::globalvars::CHILD_PID)), "child_pid.cmp")); } else { LOG(BUG) << "unknown builtin \"" << builtin.ident << "\""; __builtin_unreachable(); } } ScopedExpr CodegenLLVM::visit(Call &call) { if (call.func == "count") { Map &map = *call.vargs.at(0).as(); auto scoped_key = getMapKey(map, call.vargs.at(1)); b_.CreatePerCpuMapElemAdd(map.ident, scoped_key.value(), b_.getInt64(1), type_map_.map_value_type(map.ident), call.loc); return ScopedExpr(); } else if (call.func == "sum") { Map &map = *call.vargs.at(0).as(); ScopedExpr scoped_key = getMapKey(map, call.vargs.at(1)); ScopedExpr scoped_expr = visit(call.vargs.at(2)); // promote int to 64-bit Value *cast = b_.CreateIntCast( scoped_expr.value(), b_.getInt64Ty(), type_map_.map_value_type(map.ident).IsSigned()); b_.CreatePerCpuMapElemAdd(map.ident, scoped_key.value(), cast, type_map_.map_value_type(map.ident), call.loc); return ScopedExpr(); } else if (call.func == "max" || call.func == "min") { bool is_max = call.func == "max"; Map &map = *call.vargs.at(0).as(); ScopedExpr scoped_key = getMapKey(map, call.vargs.at(1)); CallInst *lookup = b_.CreateMapLookup(map, scoped_key.value()); ScopedExpr scoped_expr = visit(call.vargs.at(2)); // promote int to 64-bit Value *expr = b_.CreateIntCast( scoped_expr.value(), b_.getInt64Ty(), type_map_.map_value_type(map.ident).IsSigned()); llvm::Type *mm_struct_ty = b_.GetMapValueType( type_map_.map_value_type(map.ident)); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_->getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_->getContext(), "lookup_failure", parent); BasicBlock *lookup_merge_block = BasicBlock::Create(module_->getContext(), "lookup_merge", parent); Value *lookup_condition = b_.CreateICmpNE( b_.CreateIntCast(lookup, b_.getPtrTy(), true), b_.GetNull(), "lookup_cond"); b_.CreateCondBr(lookup_condition, lookup_success_block, lookup_failure_block); b_.SetInsertPoint(lookup_success_block); b_.CreateMinMax( expr, b_.CreateGEP(mm_struct_ty, lookup, { b_.getInt64(0), b_.getInt32(0) }), b_.CreateGEP(mm_struct_ty, lookup, { b_.getInt64(0), b_.getInt32(1) }), is_max, type_map_.map_value_type(map.ident).IsSigned()); b_.CreateBr(lookup_merge_block); b_.SetInsertPoint(lookup_failure_block); AllocaInst *mm_struct = b_.CreateAllocaBPF(mm_struct_ty, "mm_struct"); b_.CreateStore(expr, b_.CreateGEP(mm_struct_ty, mm_struct, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateStore(b_.getInt64(1), b_.CreateGEP(mm_struct_ty, mm_struct, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateMapUpdateElem(map.ident, scoped_key.value(), mm_struct, call.loc); b_.CreateLifetimeEnd(mm_struct); b_.CreateBr(lookup_merge_block); b_.SetInsertPoint(lookup_merge_block); return ScopedExpr(); } else if (call.func == "avg" || call.func == "stats") { Map &map = *call.vargs.at(0).as(); ScopedExpr scoped_key = getMapKey(map, call.vargs.at(1)); CallInst *lookup = b_.CreateMapLookup(map, scoped_key.value()); ScopedExpr scoped_expr = visit(call.vargs.at(2)); // promote int to 64-bit Value *expr = b_.CreateIntCast( scoped_expr.value(), b_.getInt64Ty(), type_map_.map_value_type(map.ident).IsSigned()); llvm::Type *avg_struct_ty = b_.GetMapValueType( type_map_.map_value_type(map.ident)); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *lookup_success_block = BasicBlock::Create(module_->getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_->getContext(), "lookup_failure", parent); BasicBlock *lookup_merge_block = BasicBlock::Create(module_->getContext(), "lookup_merge", parent); Value *lookup_condition = b_.CreateICmpNE( b_.CreateIntCast(lookup, b_.getPtrTy(), true), b_.GetNull(), "lookup_cond"); b_.CreateCondBr(lookup_condition, lookup_success_block, lookup_failure_block); b_.SetInsertPoint(lookup_success_block); Value *total_val = b_.CreateLoad(b_.getInt64Ty(), b_.CreateGEP(avg_struct_ty, lookup, { b_.getInt64(0), b_.getInt32(0) })); Value *count_val = b_.CreateLoad(b_.getInt64Ty(), b_.CreateGEP(avg_struct_ty, lookup, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateStore(b_.CreateAdd(total_val, expr), b_.CreateGEP(avg_struct_ty, lookup, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateStore(b_.CreateAdd(b_.getInt64(1), count_val), b_.CreateGEP(avg_struct_ty, lookup, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateBr(lookup_merge_block); b_.SetInsertPoint(lookup_failure_block); AllocaInst *avg_struct = b_.CreateAllocaBPF(avg_struct_ty, "avg_struct"); b_.CreateStore(expr, b_.CreateGEP(avg_struct_ty, avg_struct, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateStore(b_.getInt64(1), b_.CreateGEP(avg_struct_ty, avg_struct, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateMapUpdateElem(map.ident, scoped_key.value(), avg_struct, call.loc); b_.CreateLifetimeEnd(avg_struct); b_.CreateBr(lookup_merge_block); b_.SetInsertPoint(lookup_merge_block); return ScopedExpr(); } else if (call.func == "hist") { if (!log2_func_) log2_func_ = createLog2Function(); Map &map = *call.vargs.at(0).as(); ScopedExpr scoped_arg = visit(call.vargs.at(2)); // There is only one log2_func_ so the second argument must be passed // as an argument even though it is a constant 0..5 // Possible optimization is create one function per different value // of the second argument. ScopedExpr scoped_arg2 = visit(call.vargs.at(3)); Value *k = b_.CreateIntCast(scoped_arg2.value(), b_.getInt64Ty(), false); // promote int to 64-bit Value *expr = b_.CreateIntCast(scoped_arg.value(), b_.getInt64Ty(), type_map_.type(call.vargs.at(2)).IsSigned()); Value *log2 = b_.CreateCall(log2_func_, { expr, k }, "log2"); ScopedExpr scoped_key = getMultiMapKey( map, call.vargs.at(1), { log2 }, call.loc); b_.CreatePerCpuMapElemAdd(map.ident, scoped_key.value(), b_.getInt64(1), type_map_.map_value_type(map.ident), call.loc); return ScopedExpr(); } else if (call.func == "lhist") { if (!linear_func_) linear_func_ = createLinearFunction(); Map &map = *call.vargs.at(0).as(); // prepare arguments auto &value_arg = call.vargs.at(2); auto &min_arg = call.vargs.at(3); auto &max_arg = call.vargs.at(4); auto &step_arg = call.vargs.at(5); auto scoped_value_arg = visit(value_arg); auto scoped_min_arg = visit(min_arg); auto scoped_max_arg = visit(max_arg); auto scoped_step_arg = visit(step_arg); // promote int to 64-bit Value *value = b_.CreateIntCast( scoped_value_arg.value(), b_.getInt64Ty(), type_map_.type(call.vargs.at(2)).IsSigned()); Value *min = b_.CreateIntCast(scoped_min_arg.value(), b_.getInt64Ty(), false); Value *max = b_.CreateIntCast(scoped_max_arg.value(), b_.getInt64Ty(), false); Value *step = b_.CreateIntCast(scoped_step_arg.value(), b_.getInt64Ty(), false); Value *linear = b_.CreateCall(linear_func_, { value, min, max, step }, "linear"); ScopedExpr scoped_key = getMultiMapKey( map, call.vargs.at(1), { linear }, call.loc); b_.CreatePerCpuMapElemAdd(map.ident, scoped_key.value(), b_.getInt64(1), type_map_.map_value_type(map.ident), call.loc); return ScopedExpr(); } else if (call.func == "tseries") { // tseries decides what the current bucket is based on the timestamp then // updates the bucket's value. // // void tseries(uint64_t n, uint64_t interval_ns, uint64_t num_intervals) { // uint64_t now = bpf_ktime_get_boot_ns(); // struct ts_struct ts_struct_alloc = {}; // uint64_t epoch = now / interval_ns; // uint64_t bucket = epoch % num_intervals; // struct ts_struct *bucket_value; // bool key_exists; // // bucket_value = bpf_map_lookup_elem(&tseries_map, &bucket); // if (!bucket_value) { // key_exists = false; // bucket_value = &ts_struct_alloc; // } else { // key_exists = true; // } // // #if defined(SUM) || defined(MIN) || defined(MAX) || defined(AVG) // if (epoch != bucket_value->epoch) { // bucket_value->value = 0; // bucket_value->meta = 0; // } // #endif // // #if defined(SUM) // bucket_value->value += n; // #elif defined(MIN) || defined(MAX) // if (!bucket_value->meta) { // bucket_value->value = n; // } else { // #if defined(MIN) // bucket_value->value = min(bucket_value->value, n); // #else // bucket_value->value = max(bucket_value->value, n); // #endif // } // bucket_value->meta = 1; // #elif defined(AVG) // bucket_value->value += n; // bucket_value->meta++; // #else // bucket_value->value = n; // bucket_value->meta = now; // #endif // // if (!key_exists) { // bpf_map_update_elem(&tseries_map, &bucket, bucket_value); // } // } Map &map = *call.vargs.at(0).as(); llvm::Function *parent = b_.GetInsertBlock()->getParent(); llvm::Type *ts_struct_ty = b_.GetMapValueType( type_map_.map_value_type(map.ident)); AllocaInst *ts_struct_ptr = b_.CreateAllocaBPF( PointerType::get(llvm_ctx_, 0), "ts_struct_ptr"); // Step 1) Figure out which bucket we're using. auto map_info = bpftrace_.resources.maps_info.find(map.ident); if (map_info == bpftrace_.resources.maps_info.end()) { LOG(BUG) << "map name: \"" << map.ident << "\" not found"; } auto &tseries_args = std::get(map_info->second.detail); Value *interval_ns = b_.getInt64(tseries_args.interval_ns); Value *num_intervals = b_.getInt64(tseries_args.num_intervals); Value *now = b_.CreateGetNs(TimestampMode::sw_tai, call.loc); Value *epoch = b_.CreateUDiv(now, interval_ns); Value *bucket = b_.CreateURem(epoch, num_intervals); auto scoped_key = getMultiMapKey( map, call.vargs.at(1), { bucket }, call.loc); AllocaInst *key_exists = b_.CreateAllocaBPF(b_.getInt8Ty(), "key_exists"); // Step 2) If the bucket already exists in the map, assign ts_struct_ptr to // the result of the map lookup. Otherwise, assign ts_struct_ptr to // a local AllocaInst. CallInst *lookup = b_.CreateMapLookup(map, scoped_key.value()); BasicBlock *lookup_success_block = BasicBlock::Create(module_->getContext(), "lookup_success", parent); BasicBlock *lookup_failure_block = BasicBlock::Create(module_->getContext(), "lookup_failure", parent); BasicBlock *maybe_clear_block = BasicBlock::Create(module_->getContext(), "maybe_clear", parent); BasicBlock *merge_block = BasicBlock::Create(module_->getContext(), "merge", parent); BasicBlock *update_block = BasicBlock::Create(module_->getContext(), "update", parent); BasicBlock *exit_block = BasicBlock::Create(module_->getContext(), "exit", parent); Value *lookup_condition = b_.CreateICmpNE( b_.CreateIntCast(lookup, b_.getPtrTy(), true), b_.GetNull(), "map_lookup_cond"); b_.CreateCondBr(lookup_condition, lookup_success_block, lookup_failure_block); b_.SetInsertPoint(lookup_success_block); // Success: ts_struct_ptr just points to what's in the map. b_.CreateStore( b_.CreatePointerCast(lookup, PointerType::get(llvm_ctx_, 0), "cast"), ts_struct_ptr); b_.CreateStore(b_.getInt8(1), key_exists); b_.CreateBr(maybe_clear_block); b_.SetInsertPoint(lookup_failure_block); // Failure: ts_struct_ptr points to a zero-initialized ts_struct_ty. AllocaInst *ts_struct = b_.CreateAllocaBPF(ts_struct_ty, "ts_struct"); b_.CreateStore(b_.getInt64(0), b_.CreateGEP(ts_struct_ty, ts_struct, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateStore(b_.getInt64(0), b_.CreateGEP(ts_struct_ty, ts_struct, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateStore(epoch, b_.CreateGEP(ts_struct_ty, ts_struct, { b_.getInt64(0), b_.getInt32(2) })); b_.CreateStore(ts_struct, ts_struct_ptr); b_.CreateStore(b_.getInt8(0), key_exists); b_.CreateBr(maybe_clear_block); // Step 3) If we do aggregation, check if we need to reset the bucket before // updating it. b_.SetInsertPoint(maybe_clear_block); Value *ptr = b_.CreateLoad(PointerType::get(llvm_ctx_, 0), ts_struct_ptr); Value *value_ptr = b_.CreateGEP(ts_struct_ty, ptr, { b_.getInt64(0), b_.getInt32(0) }); Value *meta_ptr = b_.CreateGEP(ts_struct_ty, ptr, { b_.getInt64(0), b_.getInt32(1) }); Value *epoch_ptr = b_.CreateGEP(ts_struct_ty, ptr, { b_.getInt64(0), b_.getInt32(2) }); if (tseries_args.agg != TSeriesAggFunc::none) { Value *old_epoch = b_.CreateLoad(b_.getInt64Ty(), epoch_ptr); BasicBlock *clear_block = BasicBlock::Create(module_->getContext(), "clear", parent); b_.CreateCondBr(b_.CreateICmpNE(old_epoch, epoch, "new_epoch"), clear_block, merge_block); b_.SetInsertPoint(clear_block); // Clear the current bucket's value and metadata if it's a new epoch. b_.CreateStore(b_.getInt64(0), value_ptr); b_.CreateStore(b_.getInt64(0), meta_ptr); } // Step 4) Update the current bucket b_.CreateBr(merge_block); b_.SetInsertPoint(merge_block); auto &value_arg = call.vargs.at(2); ScopedExpr scoped_expr = visit(value_arg); // promote int to 64-bit Value *cast = b_.CreateIntCast(scoped_expr.value(), b_.getInt64Ty(), type_map_.type(value_arg).IsSigned()); // Update the value and metadata. switch (tseries_args.agg) { case TSeriesAggFunc::avg: b_.CreateStore(b_.CreateAdd(b_.CreateLoad(b_.getInt64Ty(), meta_ptr), b_.getInt64(1)), meta_ptr); [[fallthrough]]; case TSeriesAggFunc::sum: b_.CreateStore(b_.CreateAdd(b_.CreateLoad(b_.getInt64Ty(), value_ptr), cast), value_ptr); break; case TSeriesAggFunc::max: case TSeriesAggFunc::min: b_.CreateMinMax(cast, value_ptr, meta_ptr, tseries_args.agg == TSeriesAggFunc::max, type_map_.type(value_arg).IsSigned()); break; case TSeriesAggFunc::none: b_.CreateStore(cast, value_ptr); b_.CreateStore(now, meta_ptr); break; default: LOG(BUG) << "disallowed type \"" << tseries_args.agg << "\""; } b_.CreateStore(epoch, epoch_ptr); b_.CreateCondBr(b_.CreateICmpNE(b_.CreateLoad(b_.getInt8Ty(), key_exists), b_.getInt8(1), "needs_update"), update_block, exit_block); b_.SetInsertPoint(update_block); b_.CreateMapUpdateElem(map.ident, scoped_key.value(), ptr, call.loc); b_.CreateBr(exit_block); b_.SetInsertPoint(exit_block); b_.CreateLifetimeEnd(ts_struct); b_.CreateLifetimeEnd(ts_struct_ptr); b_.CreateLifetimeEnd(key_exists); return ScopedExpr(); } else if (call.func == "str") { const auto max_strlen = bpftrace_.config_->pad_max_strlen(); // Largest read we'll allow = our global string buffer size Value *strlen = b_.getInt64(max_strlen); if (call.vargs.size() > 1) { auto scoped_arg = visit(call.vargs.at(1)); // Widen to i64 to match strlen (max_strlen) above, since the // ICmp and Select below require matching operand types. Value *proposed_strlen = b_.CreateIntCast(scoped_arg.value(), b_.getInt64Ty(), false); // integer comparison: unsigned less-than-or-equal-to CmpInst::Predicate P = CmpInst::ICMP_ULE; // check whether proposed_strlen is less-than-or-equal-to maximum Value *Cmp = b_.CreateICmp(P, proposed_strlen, strlen, "str.min.cmp"); // select proposed_strlen if it's sufficiently low, otherwise choose // maximum strlen = b_.CreateSelect(Cmp, proposed_strlen, strlen, "str.min.select"); } Value *buf = b_.CreateGetStrAllocation("str", call.loc); b_.CreateMemsetBPF(buf, b_.getInt8(0xff), max_strlen); auto &arg0 = call.vargs.front(); auto scoped_expr = visit(call.vargs.front()); b_.CreateProbeReadStr(buf, strlen, scoped_expr.value(), type_map_.type(arg0).GetAS(), call.loc); if (dyn_cast(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } else if (call.func == "buf") { const auto max_strlen = bpftrace_.config_->max_strlen; // Subtract out metadata headroom uint64_t fixed_buffer_length = max_strlen - sizeof(AsyncEvent::Buf); Value *max_length = b_.getInt64(fixed_buffer_length); Value *length; if (call.vargs.size() > 1) { auto &arg = call.vargs.at(1); auto scoped_expr = visit(&arg); Value *proposed_length = scoped_expr.value(); if (type_map_.type(arg).GetSize() != 8) proposed_length = b_.CreateZExt(proposed_length, max_length->getType()); Value *cmp = b_.CreateICmp( CmpInst::ICMP_ULE, proposed_length, max_length, "length.cmp"); length = b_.CreateSelect( cmp, proposed_length, max_length, "length.select"); auto *literal_length = arg.as(); if (literal_length) fixed_buffer_length = literal_length->value; } else { auto &arg = call.vargs.at(0); fixed_buffer_length = type_map_.type(arg).GetNumElements() * type_map_.type(arg).GetElementTy().GetSize(); length = b_.getInt32(fixed_buffer_length); } Value *buf = b_.CreateGetStrAllocation("buf", call.loc); auto elements = AsyncEvent::Buf().asLLVMType(b_, fixed_buffer_length); std::ostringstream dynamic_sized_struct_name; dynamic_sized_struct_name << "buffer_" << fixed_buffer_length << "_t"; StructType *buf_struct = b_.GetStructType(dynamic_sized_struct_name.str(), elements, true); Value *buf_len_offset = b_.CreateGEP(buf_struct, buf, { b_.getInt32(0), b_.getInt32(0) }); length = b_.CreateIntCast(length, buf_struct->getElementType(0), false); b_.CreateStore(length, buf_len_offset); Value *buf_data_offset = b_.CreateGEP(buf_struct, buf, { b_.getInt32(0), b_.getInt32(1) }); b_.CreateMemsetBPF(buf_data_offset, b_.getInt8(0), fixed_buffer_length); auto scoped_expr = visit(call.vargs.front()); const auto &arg0_type = type_map_.type(call.vargs.front()); b_.CreateProbeRead(buf_data_offset, length, scoped_expr.value(), arg0_type.IsInBpfMemory() ? AddrSpace::kernel : find_addrspace_stack(arg0_type), call.loc); if (dyn_cast(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } else if (call.func == "path") { Value *buf = b_.CreateGetStrAllocation("path", call.loc); const auto max_size = bpftrace_.config_->max_strlen; b_.CreateMemsetBPF(buf, b_.getInt8(0), max_size); Value *sz; if (call.vargs.size() > 1) { auto scoped_arg = visit(call.vargs.at(1)); Value *pr_sz = b_.CreateIntCast(scoped_arg.value(), b_.getInt32Ty(), false); Value *max_sz = b_.getInt32(max_size); Value *cmp = b_.CreateICmp( CmpInst::ICMP_ULE, pr_sz, max_sz, "path.size.cmp"); sz = b_.CreateSelect(cmp, pr_sz, max_sz, "path.size.select"); } else { sz = b_.getInt32(max_size); } auto scoped_arg = visit(call.vargs.front()); Value *value = scoped_arg.value(); b_.CreatePath(buf, b_.CreateCast(value->getType()->isPointerTy() ? Instruction::BitCast : Instruction::IntToPtr, value, b_.getPtrTy()), sz, call.loc); if (dyn_cast(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } else if (call.func == "kaddr") { uint64_t addr; auto name = call.vargs.at(0).as()->value; addr = bpftrace_.resolve_kname(name); if (!addr) call.addError() << "Failed to resolve kernel symbol: " << name; return ScopedExpr(b_.getInt64(addr)); } else if (call.func == "percpu_kaddr") { auto name = call.vargs.at(0).as()->value; auto *var = DeclareKernelVar(name); Value *percpu_ptr; if (call.vargs.size() == 1) { percpu_ptr = b_.CreateThisCpuPtr(var, call.loc); } else { auto scoped_cpu = visit(call.vargs.at(1)); percpu_ptr = b_.CreatePerCpuPtr(var, scoped_cpu.value(), call.loc); } return ScopedExpr(b_.CreatePtrToInt(percpu_ptr, b_.getInt64Ty())); } else if (call.func == "__builtin_uaddr") { auto name = call.vargs.at(0).as()->value; auto sym = bpftrace_.resolve_uname(name, current_attach_point_->target); if (!sym) { call.addError() << sym.takeError(); // Return null pointer on error Value *null_ptr = b_.CreateIntToPtr(b_.getInt64(0), b_.getPtrTy()); return ScopedExpr(null_ptr); } // Convert to pointer to match GetType() for pointer types // The pointee size info is preserved in type_map_ and used during deref Value *addr = b_.getInt64(sym->v_addr); Value *ptr = b_.CreateIntToPtr(addr, b_.getPtrTy()); return ScopedExpr(ptr); } else if (call.func == "cgroupid") { uint64_t cgroupid; auto path = call.vargs.at(0).as()->value; cgroupid = util::resolve_cgroupid(path); return ScopedExpr(b_.getInt64(cgroupid)); } else if (call.func == "join") { auto found_id = bpftrace_.resources.join_args_id_map.find(&call); if (found_id == bpftrace_.resources.join_args_id_map.end()) { LOG(BUG) << "No id found for join call"; } createJoinCall(call, found_id->second); return ScopedExpr(); } else if (call.func == "ksym") { // We want to just pass through from the child node. return visit(call.vargs.front()); } else if (call.func == "usym") { auto scoped_arg = visit(call.vargs.front()); return ScopedExpr( b_.CreateUSym(scoped_arg.value(), get_probe_id(), call.loc), std::move(scoped_arg)); } else if (call.func == "ntop") { // struct { // int af_type; // union { // char[4] inet4; // char[16] inet6; // } // } std::vector elements = { b_.getInt64Ty(), ArrayType::get(b_.getInt8Ty(), 16) }; StructType *inet_struct = b_.GetStructType("inet", elements, false); AllocaInst *buf = b_.CreateAllocaBPF(inet_struct, "inet"); Value *af_offset = b_.CreateGEP(inet_struct, buf, { b_.getInt64(0), b_.getInt32(0) }); Value *af_type; size_t inet_index = 0; if (call.vargs.size() == 1) { auto &inet = call.vargs.at(0); if (type_map_.type(inet).IsIntegerTy() || type_map_.type(inet).GetSize() == 4) { af_type = b_.getInt64(AF_INET); } else { af_type = b_.getInt64(AF_INET6); } } else { inet_index = 1; auto scoped_arg = visit(call.vargs.at(0)); af_type = b_.CreateIntCast(scoped_arg.value(), b_.getInt64Ty(), true); } b_.CreateStore(af_type, af_offset); Value *inet_offset = b_.CreateGEP(inet_struct, buf, { b_.getInt32(0), b_.getInt32(1) }); b_.CreateMemsetBPF(inet_offset, b_.getInt8(0), 16); auto &inet = call.vargs.at(inet_index); auto scoped_inet = visit(inet); if (type_map_.type(inet).IsArrayTy() || type_map_.type(inet).IsStringTy()) { b_.CreateProbeRead(static_cast(inet_offset), type_map_.type(inet), scoped_inet.value(), call.loc); } else { b_.CreateStore( b_.CreateIntCast(scoped_inet.value(), b_.getInt32Ty(), false), inet_offset); } return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "pton") { auto af_type = AF_INET; int addr_size = 4; std::string addr = call.vargs.at(0).as()->value; if (addr.find(":") != std::string::npos) { af_type = AF_INET6; addr_size = 16; } llvm::Type *array_t = ArrayType::get(b_.getInt8Ty(), addr_size); AllocaInst *buf; if (af_type == AF_INET6) { buf = b_.CreateAllocaBPF(array_t, "addr6"); } else { buf = b_.CreateAllocaBPF(array_t, "addr4"); } std::vector dst(addr_size); Value *octet; auto ret = inet_pton(af_type, addr.c_str(), dst.data()); if (ret != 1) { call.addError() << "inet_pton() call returns " << std::to_string(ret); } for (int i = 0; i < addr_size; i++) { octet = b_.getInt8(dst[i]); b_.CreateStore( octet, b_.CreateGEP(array_t, buf, { b_.getInt64(0), b_.getInt64(i) })); } return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "reg") { auto reg_name = call.vargs.at(0).as()->value; auto offset = arch::Host::register_to_pt_regs_offset(reg_name); if (!offset) { call.addError() << "register " << reg_name << " not available on architecture " << arch::Host::Machine; return ScopedExpr(b_.getInt64(0)); } return ScopedExpr(b_.CreateRegisterRead(ctx_, offset.value(), call.func + "_" + reg_name)); } else if (call.func == "printf") { // We overload printf call for iterator probe's seq_printf helper. if (!inside_subprog_ && probetype(current_attach_point_->provider) == ProbeType::iter) { auto nargs = call.vargs.size() - 1; int ptr_size = sizeof(unsigned long); int data_size = 0; // create buffer to store the argument expression values SizedType data_type = CreateArray(nargs, CreateUInt64()); AllocaInst *data = b_.CreateAllocaBPFInit(data_type, "data"); std::vector scoped_args; scoped_args.reserve(call.vargs.size()); for (size_t i = 1; i < call.vargs.size(); i++) { // process argument expression Expression &arg = call.vargs.at(i); auto scoped_arg = visit(&arg); Value *value = scoped_arg.value(); // and store it to data area Value *offset = b_.CreateGEP(b_.GetType(data_type), data, { b_.getInt64(0), b_.getInt32(i - 1) }); b_.CreateStore(value, offset); // keep the expression alive, so it's still there // for following seq_printf call scoped_args.emplace_back(std::move(scoped_arg)); data_size += ptr_size; } // pick the current format string auto found_id = bpftrace_.resources.bpf_print_fmts_id_map.find(&call); if (found_id == bpftrace_.resources.bpf_print_fmts_id_map.end()) { LOG(BUG) << "No id found for printf call"; } auto *fmt = createFmtString(found_id->second); const auto &s = bpftrace_.resources.bpf_print_fmts.at(found_id->second).str(); // and finally the seq_printf call b_.CreateSeqPrintf(ctx_, b_.CreateIntToPtr(fmt, b_.getPtrTy()), b_.getInt32(s.size() + 1), data, b_.getInt32(data_size), call.loc); return ScopedExpr(); } else { auto found_id = bpftrace_.resources.printf_args_id_map.find(&call); if (found_id == bpftrace_.resources.printf_args_id_map.end()) { LOG(BUG) << "No id found for printf call"; } createFormatStringCall( call, found_id->second, std::get<1>(bpftrace_.resources.printf_args[found_id->second]), "printf", async_action::AsyncAction::printf); return ScopedExpr(); } } else if (call.func == "errorf" || call.func == "warnf") { auto found_id = bpftrace_.resources.printf_args_id_map.find(&call); if (found_id == bpftrace_.resources.printf_args_id_map.end()) { LOG(BUG) << "No id found for errorf/warnf call"; } createFormatStringCall( call, found_id->second, std::get<1>(bpftrace_.resources.printf_args[found_id->second]), call.func, async_action::AsyncAction::printf); return ScopedExpr(); } else if (call.func == "debugf") { auto found_id = bpftrace_.resources.bpf_print_fmts_id_map.find(&call); if (found_id == bpftrace_.resources.bpf_print_fmts_id_map.end()) { LOG(BUG) << "No id found for printf call"; } auto *fmt = createFmtString(found_id->second); const auto &s = bpftrace_.resources.bpf_print_fmts.at(found_id->second).str(); std::vector values; std::vector exprs; for (size_t i = 1; i < call.vargs.size(); i++) { Expression &arg = call.vargs.at(i); auto scoped_expr = visit(arg); values.push_back(scoped_expr.value()); exprs.emplace_back(std::move(scoped_expr)); } b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getPtrTy()), b_.getInt32(s.size() + 1), values, call.loc); return ScopedExpr(); } else if (call.func == "system") { auto found_id = bpftrace_.resources.system_args_id_map.find(&call); if (found_id == bpftrace_.resources.system_args_id_map.end()) { LOG(BUG) << "No id found for system call"; } createFormatStringCall( call, found_id->second, std::get<1>(bpftrace_.resources.system_args[found_id->second]), "system", async_action::AsyncAction::syscall); return ScopedExpr(); } else if (call.func == "cat") { auto found_id = bpftrace_.resources.cat_args_id_map.find(&call); if (found_id == bpftrace_.resources.cat_args_id_map.end()) { LOG(BUG) << "No id found for cat call"; } createFormatStringCall(call, found_id->second, std::get<1>( bpftrace_.resources.cat_args[found_id->second]), "cat", async_action::AsyncAction::cat); return ScopedExpr(); } else if (call.func == "exit") { auto elements = AsyncEvent::Exit().asLLVMType(b_); StructType *exit_struct = b_.GetStructType("exit_t", elements, true); AllocaInst *buf = b_.CreateAllocaBPF(exit_struct, "exit"); size_t struct_size = datalayout().getTypeAllocSize(exit_struct); // Fill in exit struct. b_.CreateStore( b_.getInt64(static_cast(async_action::AsyncAction::exit)), b_.CreateGEP(exit_struct, buf, { b_.getInt64(0), b_.getInt32(0) })); Value *code = b_.getInt8(0); if (call.vargs.size() == 1) { auto scoped_expr = visit(call.vargs.at(0)); code = scoped_expr.value(); } b_.CreateStore( code, b_.CreateGEP(exit_struct, buf, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateOutput(buf, struct_size, call.loc); b_.CreateLifetimeEnd(buf); return ScopedExpr(); } else if (call.func == "print") { if (call.vargs.at(0).is()) { createPrintMapCall(call); } else { createPrintNonMapCall(call); } return ScopedExpr(); } else if (call.func == "cgroup_path") { auto elements = AsyncEvent::CgroupPath().asLLVMType(b_); StructType *cgroup_path_struct = b_.GetStructType(call.func + "_t", elements, true); AllocaInst *buf = b_.CreateAllocaBPF(cgroup_path_struct, call.func + "_args"); // Store cgroup path event id auto found_id = bpftrace_.resources.cgroup_path_args_id_map.find(&call); if (found_id == bpftrace_.resources.cgroup_path_args_id_map.end()) { LOG(BUG) << "No id found for cgroup_path call"; } b_.CreateStore(b_.GetIntSameSize(found_id->second, elements.at(0)), b_.CreateGEP(cgroup_path_struct, buf, { b_.getInt64(0), b_.getInt32(0) })); // Store cgroup id auto &arg = call.vargs.at(0); auto scoped_expr = visit(arg); b_.CreateStore(scoped_expr.value(), b_.CreateGEP(cgroup_path_struct, buf, { b_.getInt64(0), b_.getInt32(1) })); return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "clear" || call.func == "zero") { auto elements = AsyncEvent::MapEvent().asLLVMType(b_); StructType *event_struct = b_.GetStructType(call.func + "_t", elements, true); auto &arg = call.vargs.at(0); auto &map = *arg.as(); AllocaInst *buf = b_.CreateAllocaBPF(event_struct, call.func + "_" + map.ident); auto *aa_ptr = b_.CreateGEP(event_struct, buf, { b_.getInt64(0), b_.getInt32(0) }); if (call.func == "clear") b_.CreateStore(b_.GetIntSameSize(static_cast( async_action::AsyncAction::clear), elements.at(0)), aa_ptr); else b_.CreateStore(b_.GetIntSameSize(static_cast( async_action::AsyncAction::zero), elements.at(0)), aa_ptr); int id = bpftrace_.resources.maps_info.at(map.ident).id; if (id == -1) { LOG(BUG) << "map id for map \"" << map.ident << "\" not found"; } auto *ident_ptr = b_.CreateGEP(event_struct, buf, { b_.getInt64(0), b_.getInt32(1) }); b_.CreateStore(b_.GetIntSameSize(id, elements.at(1)), ident_ptr); b_.CreateOutput(buf, getStructSize(event_struct), call.loc); return ScopedExpr(buf, [this, buf] { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "stack_len") { auto &arg = call.vargs.at(0); auto scoped_arg = visit(arg); auto *stack_struct_type = b_.GetStackStructType( type_map_.type(arg).stack_type); // The nr_frames field is in a separate place depending on // if we're dealing with a ustack or kstack. See // IRBuilderBPF::GetStackStructType auto nr_frames_offset = type_map_.type(arg).stack_type.kernel ? 0 : 2; Value *nr_stack_frames = b_.CreateGEP(stack_struct_type, scoped_arg.value(), { b_.getInt64(0), b_.getInt32(nr_frames_offset) }); return ScopedExpr( b_.CreateIntCast(b_.CreateLoad(b_.getInt64Ty(), nr_stack_frames), b_.getInt64Ty(), false)); } else if (call.func == "time") { auto elements = AsyncEvent::Time().asLLVMType(b_); StructType *time_struct = b_.GetStructType(call.func + "_t", elements, true); AllocaInst *buf = b_.CreateAllocaBPF(time_struct, call.func + "_t"); b_.CreateStore( b_.GetIntSameSize(static_cast(async_action::AsyncAction::time), elements.at(0)), b_.CreateGEP(time_struct, buf, { b_.getInt64(0), b_.getInt32(0) })); auto found_id = bpftrace_.resources.time_args_id_map.find(&call); if (found_id == bpftrace_.resources.time_args_id_map.end()) { LOG(BUG) << "No id found for time call"; } b_.CreateStore( b_.GetIntSameSize(found_id->second, elements.at(1)), b_.CreateGEP(time_struct, buf, { b_.getInt64(0), b_.getInt32(1) })); b_.CreateOutput(buf, getStructSize(time_struct), call.loc); return ScopedExpr(buf, [this, buf] { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "strftime") { auto elements = AsyncEvent::Strftime().asLLVMType(b_); StructType *strftime_struct = b_.GetStructType(call.func + "_t", elements, true); AllocaInst *buf = b_.CreateAllocaBPF(strftime_struct, call.func + "_args"); auto found_id = bpftrace_.resources.strftime_args_id_map.find(&call); if (found_id == bpftrace_.resources.strftime_args_id_map.end()) { LOG(BUG) << "No id found for strftime call"; } b_.CreateStore( b_.GetIntSameSize(found_id->second, elements.at(0)), b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateStore( b_.GetIntSameSize(static_cast>( type_map_.type(&call).ts_mode), elements.at(1)), b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(1) })); auto &arg = call.vargs.at(1); auto scoped_expr = visit(arg); // Ensure the value is 64-bit to match the struct field type (uint64_t // nsecs) llvm::Value *nsecs_value = scoped_expr.value(); llvm::Type *value_type = nsecs_value->getType(); if (value_type->isIntegerTy() && value_type->getIntegerBitWidth() < 64) { // Zero-extend smaller integers to 64 bits nsecs_value = b_.CreateZExt(nsecs_value, b_.getInt64Ty()); } b_.CreateStore( nsecs_value, b_.CreateGEP(strftime_struct, buf, { b_.getInt64(0), b_.getInt32(2) })); return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "kstack") { return kstack(type_map_.type(&call), call.loc); } else if (call.func == "ustack") { return ustack(type_map_.type(&call), call.loc); } else if (call.func == "__builtin_dw_ustack") { return dw_ustack(type_map_.type(&call), call.loc); } else if (call.func == "strncmp") { auto &left_arg = call.vargs.at(0); auto &right_arg = call.vargs.at(1); auto size_opt = call.vargs.at(2).as()->value; uint64_t size = std::min( { size_opt, static_cast(type_map_.type(left_arg).GetSize()), static_cast(type_map_.type(right_arg).GetSize()) }); auto left_string = visit(&left_arg); auto right_string = visit(&right_arg); return ScopedExpr(b_.CreateStrncmp( left_string.value(), right_string.value(), size, false)); } else if (call.func == "kptr" || call.func == "uptr") { return visit(call.vargs.at(0)); } else if (call.func == "macaddr") { // MAC addresses are presented as char[6] AllocaInst *buf = b_.CreateAllocaBPFInit(type_map_.type(&call), "macaddr"); auto &macaddr = call.vargs.front(); auto scoped_arg = visit(macaddr); if (type_map_.type(macaddr).IsInBpfMemory()) b_.CreateMemcpyBPF(buf, scoped_arg.value(), type_map_.type(macaddr).GetSize()); else b_.CreateProbeRead( buf, type_map_.type(macaddr), scoped_arg.value(), call.loc); return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); } else if (call.func == "bswap") { auto &arg = call.vargs.at(0); auto scoped_arg = visit(arg); assert(type_map_.type(arg).IsIntegerTy()); if (type_map_.type(arg).GetSize() > 1) { llvm::Type *arg_type = b_.GetType(type_map_.type(arg)); #if LLVM_VERSION_MAJOR >= 20 llvm::Function *swap_fun = Intrinsic::getOrInsertDeclaration( module_.get(), Intrinsic::bswap, { arg_type }); #else llvm::Function *swap_fun = Intrinsic::getDeclaration(module_.get(), Intrinsic::bswap, { arg_type }); #endif return ScopedExpr(b_.CreateCall(swap_fun, { scoped_arg.value() }), std::move(scoped_arg)); } return scoped_arg; } else if (call.func == "skboutput") { auto elements = AsyncEvent::SkbOutput().asLLVMType(b_); StructType *hdr_t = b_.GetStructType("hdr_t", elements, false); AllocaInst *data = b_.CreateAllocaBPF(hdr_t, "hdr"); // The extra 0 here ensures the type of addr_offset will be int64 Value *aid_addr = b_.CreateGEP(hdr_t, data, { b_.getInt64(0), b_.getInt32(0) }); Value *id_addr = b_.CreateGEP(hdr_t, data, { b_.getInt64(0), b_.getInt32(1) }); Value *time_addr = b_.CreateGEP(hdr_t, data, { b_.getInt64(0), b_.getInt32(2) }); b_.CreateStore(b_.getInt64(static_cast( async_action::AsyncAction::skboutput)), aid_addr); auto found_id = bpftrace_.resources.skboutput_args_id_map.find(&call); if (found_id == bpftrace_.resources.skboutput_args_id_map.end()) { LOG(BUG) << "No id found for skboutput call"; } b_.CreateStore(b_.getInt64(found_id->second), id_addr); b_.CreateStore(b_.CreateGetNs(TimestampMode::boot, call.loc), time_addr); auto scoped_skb = visit(call.vargs.at(1)); auto scoped_arg_len = visit(call.vargs.at(2)); Value *len = b_.CreateIntCast(scoped_arg_len.value(), b_.getInt64Ty(), false); Value *ret = b_.CreateSkbOutput( scoped_skb.value(), len, data, getStructSize(hdr_t)); return ScopedExpr(ret); } else if (call.func == "nsecs") { return ScopedExpr(b_.CreateGetNs(type_map_.type(&call).ts_mode, call.loc)); } else if (call.func == "pid") { bool force_init = shouldForceInitPidNs(call.vargs); return ScopedExpr(b_.CreateGetPid(call.loc, force_init)); } else if (call.func == "tid") { bool force_init = shouldForceInitPidNs(call.vargs); return ScopedExpr(b_.CreateGetTid(call.loc, force_init)); } else if (call.func == "socket_cookie") { auto scoped_arg = visit(call.vargs.at(0)); return ScopedExpr(b_.CreateGetSocketCookie(scoped_arg.value(), call.loc)); } else { auto *func = extern_funcs_[call.func]; if (!func) { // If we don't know about this function for codegen, then it is very // likely something that will be linked in from the standard library. // Assume that type resolution has provided the types correctly, // and set everything up for success. llvm::Type *result_type = b_.GetType(type_map_.type(&call)); SmallVector arg_types; for (const auto &expr : call.vargs) { arg_types.push_back(b_.GetType(type_map_.type(expr))); } FunctionType *function_type = FunctionType::get(result_type, arg_types, false); func = llvm::Function::Create(function_type, llvm::Function::ExternalLinkage, call.func, module_.get()); func->addFnAttr(Attribute::AlwaysInline); func->addFnAttr(Attribute::NoUnwind); func->setDSOLocal(true); // Add noundef attribute to each argument. for (auto &arg : func->args()) { arg.addAttr(Attribute::NoUndef); } extern_funcs_[call.func] = func; } std::vector args; SmallVector arg_values; for (auto &expr : call.vargs) { args.emplace_back(visit(expr)); arg_values.push_back(args.back().value()); } auto *inst = b_.CreateCall(func, arg_values, call.func); inst->setDebugLoc(debug_.createDebugLocation(llvm_ctx_, scope_, call.loc)); return ScopedExpr(inst); } } ScopedExpr CodegenLLVM::visit([[maybe_unused]] Map &map) { // This is not currently used in code generation. Code is generated either // via `MapAccess` for reads or via `AssignMapStatement` for writes. return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(MapAddr &map_addr) { return ScopedExpr(b_.GetMapVar(map_addr.map->ident)); } ScopedExpr CodegenLLVM::visit(Variable &var) { if (needMemcpy(type_map_.type(&var))) { return ScopedExpr(getVariable(var.ident).value); } else { auto &var_llvm = getVariable(var.ident); return ScopedExpr(b_.CreateLoad(var_llvm.type, var_llvm.value)); } } ScopedExpr CodegenLLVM::visit(VariableAddr &var_addr) { return ScopedExpr(getVariable(var_addr.var->ident).value); } ScopedExpr CodegenLLVM::binop_string(Binop &binop) { if (binop.op != Operator::EQ && binop.op != Operator::NE) { LOG(BUG) << "missing codegen to string operator \"" << opstr(binop) << "\""; } // strcmp returns 0 when strings are equal bool inverse = binop.op == Operator::EQ; auto left_string = visit(binop.left); auto right_string = visit(binop.right); size_t len = std::min(type_map_.type(binop.left).GetSize(), type_map_.type(binop.right).GetSize()); return ScopedExpr(b_.CreateIntCast( b_.CreateStrncmp(left_string.value(), right_string.value(), len, inverse), b_.getInt1Ty(), false)); } ScopedExpr CodegenLLVM::binop_integer_array(Binop &binop) { assert(binop.op == Operator::EQ || binop.op == Operator::NE); // integer array compare returns 0 when arrays are equal bool inverse = binop.op == Operator::EQ; auto scoped_left = visit(binop.left); auto scoped_right = visit(binop.right); Value *left_array_val = scoped_left.value(); Value *right_array_val = scoped_right.value(); const auto &left_array_ty = type_map_.type(binop.left); const auto &right_array_ty = type_map_.type(binop.right); assert(left_array_ty.GetNumElements() == right_array_ty.GetNumElements()); assert(left_array_ty.GetElementTy().GetSize() == right_array_ty.GetElementTy().GetSize()); return ScopedExpr(b_.CreateIntegerArrayCmp(left_array_val, right_array_val, left_array_ty, right_array_ty, inverse, binop.loc, createLoopMetadata())); } ScopedExpr CodegenLLVM::binop_buf(Binop &binop) { if (binop.op != Operator::EQ && binop.op != Operator::NE) { LOG(BUG) << "missing codegen to buffer operator \"" << opstr(binop) << "\""; } // strcmp returns 0 when strings are equal bool inverse = binop.op == Operator::EQ; auto scoped_left = visit(binop.left); auto scoped_right = visit(binop.right); Value *left_string = scoped_left.value(); Value *right_string = scoped_right.value(); size_t len = std::min(type_map_.type(binop.left).GetSize(), type_map_.type(binop.right).GetSize()); return ScopedExpr(b_.CreateIntCast( b_.CreateStrncmp(left_string, right_string, len, inverse), b_.getInt1Ty(), false)); } ScopedExpr CodegenLLVM::binop_int(Binop &binop) { auto scoped_left = visit(binop.left); auto scoped_right = visit(binop.right); Value *lhs = scoped_left.value(); Value *rhs = scoped_right.value(); // If left or right is PositionalParameter, that means the syntax is: // str($1 + num) or str(num + $1) // The positional params returns a pointer to a buffer, and the buffer should // live until str() is accepted. Extend the lifetime of the buffer by moving // these into the deletion scoped, where they will run once the value is // consumed. auto del = [l = std::move(scoped_left), r = std::move(scoped_right)] {}; bool lsign = type_map_.type(binop.left).IsSigned(); bool rsign = type_map_.type(binop.right).IsSigned(); bool do_signed = lsign || rsign; // Promote operands if necessary auto size = std::max(type_map_.type(binop.left).GetSize(), type_map_.type(binop.right).GetSize()); lhs = b_.CreateIntCast(lhs, b_.getIntNTy(size * 8), lsign); rhs = b_.CreateIntCast(rhs, b_.getIntNTy(size * 8), rsign); switch (binop.op) { case Operator::EQ: return ScopedExpr(b_.CreateICmpEQ(lhs, rhs), std::move(del)); case Operator::NE: return ScopedExpr(b_.CreateICmpNE(lhs, rhs), std::move(del)); case Operator::LE: return ScopedExpr(do_signed ? b_.CreateICmpSLE(lhs, rhs) : b_.CreateICmpULE(lhs, rhs), std::move(del)); case Operator::GE: return ScopedExpr(do_signed ? b_.CreateICmpSGE(lhs, rhs) : b_.CreateICmpUGE(lhs, rhs), std::move(del)); case Operator::LT: return ScopedExpr(do_signed ? b_.CreateICmpSLT(lhs, rhs) : b_.CreateICmpULT(lhs, rhs), std::move(del)); case Operator::GT: return ScopedExpr(do_signed ? b_.CreateICmpSGT(lhs, rhs) : b_.CreateICmpUGT(lhs, rhs), std::move(del)); case Operator::LEFT: return ScopedExpr(b_.CreateShl(lhs, rhs), std::move(del)); case Operator::RIGHT: return ScopedExpr(b_.CreateLShr(lhs, rhs), std::move(del)); case Operator::PLUS: return ScopedExpr(b_.CreateAdd(lhs, rhs), std::move(del)); case Operator::MINUS: return ScopedExpr(b_.CreateSub(lhs, rhs), std::move(del)); case Operator::MUL: return ScopedExpr(b_.CreateMul(lhs, rhs), std::move(del)); case Operator::DIV: case Operator::MOD: { // Always do an unsigned modulo operation here even if `do_signed` // is true. bpf instruction set does not support signed division. // We already warn in an earlier pass that signed modulo can // lead to undefined behavior (because we will treat it as unsigned). return ScopedExpr(b_.CreateCheckedBinop(binop, lhs, rhs), std::move(del)); } case Operator::BAND: return ScopedExpr(b_.CreateAnd(lhs, rhs), std::move(del)); case Operator::BOR: return ScopedExpr(b_.CreateOr(lhs, rhs), std::move(del)); case Operator::BXOR: return ScopedExpr(b_.CreateXor(lhs, rhs), std::move(del)); default: LOG(BUG) << "\"" << opstr(binop) << "\" was handled earlier"; __builtin_unreachable(); } } ScopedExpr CodegenLLVM::binop_ptr(Binop &binop) { auto compare = false; auto arith = false; // Do what C does switch (binop.op) { case Operator::EQ: case Operator::NE: case Operator::LE: case Operator::GE: case Operator::LT: case Operator::GT: compare = true; break; case Operator::LEFT: case Operator::RIGHT: case Operator::MOD: case Operator::BAND: case Operator::BOR: case Operator::BXOR: case Operator::MUL: case Operator::DIV: LOG(BUG) << "binop_ptr: op not implemented for type\"" << opstr(binop) << "\""; break; case Operator::PLUS: case Operator::MINUS: arith = true; break; default: LOG(BUG) << "binop_ptr invalid op \"" << opstr(binop) << "\""; } auto scoped_left = visit(binop.left); auto scoped_right = visit(binop.right); Value *lhs = scoped_left.value(); Value *rhs = scoped_right.value(); // note: an earlier pass blocks invalid combinations if (compare) { // The only other type pointers can be compared to is ints if (!type_map_.type(binop.left).IsPtrTy()) { lhs = b_.CreateIntToPtr(lhs, rhs->getType()); } else if (!type_map_.type(binop.right).IsPtrTy()) { rhs = b_.CreateIntToPtr(rhs, lhs->getType()); } switch (binop.op) { case Operator::EQ: return ScopedExpr(b_.CreateICmpEQ(lhs, rhs)); case Operator::NE: return ScopedExpr(b_.CreateICmpNE(lhs, rhs)); case Operator::LE: { return ScopedExpr(b_.CreateICmpULE(lhs, rhs)); } case Operator::GE: { return ScopedExpr(b_.CreateICmpUGE(lhs, rhs)); } case Operator::LT: { return ScopedExpr(b_.CreateICmpULT(lhs, rhs)); } case Operator::GT: { return ScopedExpr(b_.CreateICmpUGT(lhs, rhs)); } default: LOG(BUG) << "invalid op \"" << opstr(binop) << "\""; __builtin_unreachable(); } } else if (arith) { bool leftptr = type_map_.type(binop.left).IsPtrTy(); const auto &ptr_ty = leftptr ? type_map_.type(binop.left) : type_map_.type(binop.right); Value *ptr_expr = leftptr ? lhs : rhs; Value *other_expr = leftptr ? rhs : lhs; return ScopedExpr(b_.CreateGEP(b_.GetType(ptr_ty.GetPointeeTy()), ptr_expr, binop.op == Operator::PLUS ? other_expr : b_.CreateNeg(other_expr))); } else { LOG(BUG) << "unknown op \"" << opstr(binop) << "\""; __builtin_unreachable(); } } ScopedExpr CodegenLLVM::visit(Binop &binop) { // Handle && and || separately so short circuiting works if (binop.op == Operator::LAND) { return createLogicalAnd(binop); } else if (binop.op == Operator::LOR) { return createLogicalOr(binop); } const SizedType &type = type_map_.type(binop.left); if (type_map_.type(binop.left).IsPtrTy() || type_map_.type(binop.right).IsPtrTy()) { return binop_ptr(binop); } else if (type.IsStringTy()) { return binop_string(binop); } else if (type.IsBufferTy()) { return binop_buf(binop); } else if (type.IsArrayTy() && type.GetElementTy().IsIntegerTy()) { return binop_integer_array(binop); } else { return binop_int(binop); } } ScopedExpr CodegenLLVM::unop_int(Unop &unop) { const SizedType &type = type_map_.type(unop.expr); switch (unop.op) { case Operator::LNOT: { ScopedExpr scoped_expr = visit(unop.expr); auto *ty = scoped_expr.value()->getType(); Value *zero_value = Constant::getNullValue(ty); Value *expr = b_.CreateICmpEQ(scoped_expr.value(), zero_value); return ScopedExpr(expr); } case Operator::BNOT: { ScopedExpr scoped_expr = visit(unop.expr); return ScopedExpr(b_.CreateNot(scoped_expr.value())); } case Operator::MINUS: { ScopedExpr scoped_expr = visit(unop.expr); return ScopedExpr(b_.CreateNeg(scoped_expr.value())); } case Operator::PRE_INCREMENT: case Operator::PRE_DECREMENT: case Operator::POST_INCREMENT: case Operator::POST_DECREMENT: { return createIncDec(unop); } case Operator::MUL: { // When dereferencing a 32-bit integer, only read in 32-bits, etc. ScopedExpr scoped_expr = visit(unop.expr); auto dst_type = SizedType(type.GetTy(), type.GetSize()); AllocaInst *dst = b_.CreateAllocaBPF(dst_type, "deref"); b_.CreateProbeRead(dst, type, scoped_expr.value(), unop.loc); Value *value = b_.CreateIntCast(b_.CreateLoad(b_.GetType(dst_type), dst), b_.getInt64Ty(), type.IsSigned()); b_.CreateLifetimeEnd(dst); return ScopedExpr(value); } default: LOG(BUG) << "unop_int: invalid op \"" << opstr(unop) << "\""; __builtin_unreachable(); } } ScopedExpr CodegenLLVM::unop_ptr(Unop &unop) { const SizedType &type = type_map_.type(unop.expr); switch (unop.op) { case Operator::MUL: { ScopedExpr scoped_expr = visit(unop.expr); // FIXME(jordalgo): This requires more investigating/fixing as there still // might be some internal types that don't deref properly after their // address is taken via the & operator, e.g., &$x if (type_map_.type(&unop).IsIntegerTy() || type_map_.type(&unop).IsPtrTy() || type_map_.type(&unop).IsUsernameTy() || type_map_.type(&unop).IsTimestampTy() || type_map_.type(&unop).IsKsymTy()) { const auto et = type.GetPointeeTy(); AllocaInst *dst = b_.CreateAllocaBPF(et, "deref"); if (type.GetAS() != AddrSpace::none) { b_.CreateProbeRead( dst, et, scoped_expr.value(), unop.loc, type.GetAS()); } else { b_.CreateStore(b_.CreateLoad(b_.GetType(et), scoped_expr.value()), dst); } Value *value = b_.CreateLoad(b_.GetType(et), dst); b_.CreateLifetimeEnd(dst); return ScopedExpr(value); } return scoped_expr; // Pass as is. } case Operator::PRE_INCREMENT: case Operator::PRE_DECREMENT: case Operator::POST_INCREMENT: case Operator::POST_DECREMENT: return createIncDec(unop); default: return visit(unop.expr); } } ScopedExpr CodegenLLVM::visit(Unop &unop) { const SizedType &type = type_map_.type(unop.expr); if (type.IsIntegerTy()) { return unop_int(unop); } else if (type.IsBoolTy()) { assert(unop.op == Operator::LNOT); ScopedExpr scoped_expr = visit(unop.expr); Value *zero_value = Constant::getNullValue(b_.getInt1Ty()); Value *expr = b_.CreateICmpEQ(scoped_expr.value(), zero_value); return ScopedExpr(expr); } else if (type.IsPtrTy() || type.IsCtxAccess()) // allow dereferencing args { return unop_ptr(unop); } else { LOG(BUG) << "invalid type (" << type << ") passed to unary operator \"" << opstr(unop) << "\""; __builtin_unreachable(); } } ScopedExpr CodegenLLVM::visit(IfExpr &if_expr) { llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *left_block = BasicBlock::Create(module_->getContext(), "left", parent); BasicBlock *right_block = BasicBlock::Create(module_->getContext(), "right", parent); // If both blocks already have a terminator, then we don't generate an // additional block. For this reason, the `done` block is initialized lazily. BasicBlock *done = nullptr; auto lazy_done = [&]() { if (done != nullptr) { return done; } auto saved_ip = b_.saveIP(); done = BasicBlock::Create(module_->getContext(), "done", parent); b_.restoreIP(saved_ip); return done; }; // ordering of all the following statements is important Value *buf = nullptr; if (type_map_.type(&if_expr).IsStringTy()) { buf = b_.CreateGetStrAllocation("buf", if_expr.loc); const auto max_strlen = bpftrace_.config_->max_strlen; b_.CreateMemsetBPF(buf, b_.getInt8(0), max_strlen); } else if (!type_map_.type(&if_expr).IsIntTy() && !type_map_.type(&if_expr).IsBoolTy() && !type_map_.type(&if_expr).IsNoneTy() && !type_map_.type(&if_expr).IsVoidTy()) { buf = b_.CreateAllocaBPF(type_map_.type(&if_expr)); b_.CreateMemsetBPF(buf, b_.getInt8(0), type_map_.type(&if_expr).GetSize()); } auto scoped_expr = visit(if_expr.cond); Value *cond = scoped_expr.value(); Value *zero_value = Constant::getNullValue(cond->getType()); b_.CreateCondBr(b_.CreateICmpNE(cond, zero_value, "true_cond"), left_block, right_block); if (type_map_.type(&if_expr).IsIntTy() || type_map_.type(&if_expr).IsBoolTy()) { // fetch selected integer via CreateStore auto *result_ty = b_.GetType(type_map_.type(&if_expr)); b_.SetInsertPoint(left_block); auto scoped_left = visit(if_expr.left); auto *left_expr = scoped_left.value(); b_.CreateBr(lazy_done()); BasicBlock *left_end_block = b_.GetInsertBlock(); b_.SetInsertPoint(right_block); auto scoped_right = visit(if_expr.right); auto *right_expr = scoped_right.value(); b_.CreateBr(lazy_done()); BasicBlock *right_end_block = b_.GetInsertBlock(); b_.SetInsertPoint(lazy_done()); auto *phi = b_.CreatePHI(result_ty, 2, "result"); phi->addIncoming(left_expr, left_end_block); phi->addIncoming(right_expr, right_end_block); return ScopedExpr(phi); } else if (type_map_.type(&if_expr).IsNoneTy() || type_map_.type(&if_expr).IsVoidTy()) { // Type::none b_.SetInsertPoint(left_block); bool prev_in_session_return = in_session_return_branch_; if (auto *call = if_expr.cond.as()) { if (call->func == "__session_is_return") { in_session_return_branch_ = true; } } visit(if_expr.left); in_session_return_branch_ = prev_in_session_return; if (!b_.HasTerminator()) { b_.CreateBr(lazy_done()); } b_.SetInsertPoint(right_block); visit(if_expr.right); if (!b_.HasTerminator()) { b_.CreateBr(lazy_done()); } // If we've instantiated done by this point, then we resume there. If we // haven't, then both blocks have a terminator (which is a return), so // therefore we have nothing left to generate. if (done != nullptr) { b_.SetInsertPoint(done); } return ScopedExpr(); } else { b_.SetInsertPoint(left_block); auto scoped_left = visit(if_expr.left); if (needMemcpy(type_map_.type(&if_expr))) { b_.CreateMemcpyBPF(buf, scoped_left.value(), type_map_.type(&if_expr).GetSize()); } else { b_.CreateStore(scoped_left.value(), buf); } b_.CreateBr(lazy_done()); b_.SetInsertPoint(right_block); auto scoped_right = visit(if_expr.right); if (needMemcpy(type_map_.type(&if_expr))) { b_.CreateMemcpyBPF(buf, scoped_right.value(), type_map_.type(&if_expr).GetSize()); } else { b_.CreateStore(scoped_right.value(), buf); } b_.CreateBr(lazy_done()); b_.SetInsertPoint(lazy_done()); if (dyn_cast(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } } ScopedExpr CodegenLLVM::visit(FieldAccess &acc) { const SizedType &type = type_map_.type(acc.expr); auto scoped_arg = visit(acc.expr); assert(type.IsRecordTy() || type.IsCTypeTy()); if (type.IsRecordTy()) { return createAnonStructAccess(type, std::move(scoped_arg), type.GetFieldIdx(acc.field)); } if (type.is_funcarg) { auto probe_type = probetype(current_attach_point_->provider); if (probe_type == ProbeType::fentry || probe_type == ProbeType::fexit || probe_type == ProbeType::rawtracepoint) { return ScopedExpr( b_.CreateKFuncArg(ctx_, type_map_.type(&acc), acc.field), std::move(scoped_arg)); } else if (probe_type == ProbeType::uprobe) { llvm::Type *args_type = b_.UprobeArgsType(type); return readDatastructElemFromStack(std::move(scoped_arg), b_.getInt32( type_map_.type(&acc).funcarg_idx), args_type, type_map_.type(&acc)); } } const auto &field = type.GetField(acc.field); // Structs may contain two kinds of fields that must be handled separately // (bitfields and _data_loc) if (field.type.IsIntTy() && field.bitfield.has_value()) { Value *raw; auto *field_type = b_.GetType(field.type); if (type.IsCtxAccess() && !type.IsInBpfMemory()) { // The offset is specified in absolute terms here; and the load // will implicitly convert to the intended field_type. Value *src = b_.CreateSafeGEP(b_.getPtrTy(), scoped_arg.value(), b_.getInt64(field.offset)); raw = b_.CreateLoad(field_type, src, true /*volatile*/); } else { // Since `src` is treated as a offset for a constructed probe read, // we are not constrained in the same way. Value *src = b_.CreateSafeGEP(b_.GetType(type), scoped_arg.value(), { b_.getInt64(0), b_.getInt64(field.offset) }); AllocaInst *dst = b_.CreateAllocaBPF(field.type, type.GetName() + "." + acc.field); // memset so verifier doesn't complain about reading uninitialized // stack b_.CreateMemsetBPF(dst, b_.getInt8(0), field.type.GetSize()); if (type.IsInBpfMemory()) { b_.CreateMemcpyBPF(dst, src, field.bitfield->read_bytes); } else { b_.CreateProbeRead(dst, b_.getInt32(field.bitfield->read_bytes), src, type.GetAS(), acc.loc); } raw = b_.CreateLoad(field_type, dst); b_.CreateLifetimeEnd(dst); } size_t rshiftbits; #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ rshiftbits = field.bitfield->access_rshift; #else rshiftbits = (field.type.GetSize() - field.bitfield->read_bytes) * 8; rshiftbits += field.bitfield->access_rshift; #endif Value *shifted = b_.CreateLShr(raw, rshiftbits); Value *masked = b_.CreateAnd(shifted, field.bitfield->mask); return ScopedExpr(masked); } if (field.type.IsIntTy() && field.is_data_loc) { // `is_data_loc` should only be set if field access is on `args` which // has to be a ctx access assert(type.IsCtxAccess()); // Parser needs to have rewritten field to be a u64 assert(field.type.GetIntBitWidth() == 64); // Top 2 bytes are length (which we'll ignore). Bottom two bytes are // offset which we add to the start of the tracepoint struct. We need // to wrap the context here in a special way to treat it as the // expected pointer type for all versions. Value *value = b_.CreateLoad( b_.getInt32Ty(), b_.CreateSafeGEP(b_.getInt32Ty(), ctx_, b_.getInt64(field.offset / 4))); value = b_.CreateIntCast(value, b_.getInt64Ty(), false); value = b_.CreateAnd(value, b_.getInt64(0xFFFF)); value = b_.CreateSafeGEP(b_.getInt8Ty(), ctx_, value); return ScopedExpr(value); } if (type.IsInBpfMemory()) { return readDatastructElemFromStack( std::move(scoped_arg), b_.getInt64(field.offset), type, field.type); } return probereadDatastructElem(std::move(scoped_arg), b_.getInt64(field.offset), type, field.type, acc.loc, type.GetName() + "." + acc.field); } ScopedExpr CodegenLLVM::visit(ArrayAccess &arr) { // Only allow direct reads if the element is also marked as a BTF type; this // is specifically because an earlier pass has marked these cases to // avoid copying through two pointers. const SizedType &type = type_map_.type(arr.expr); // We can allow the lifetime of the index to expire by the time the array // expression is complete, but we must preserve the lifetime of the // expression since the `readDatstructureElemFromStack` method might end up // returning a pointer to live memory produced by the expression. auto scoped_expr = visit(arr.expr); auto scoped_index = visit(arr.indexpr); if (type.IsArrayTy()) { llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *is_oob = BasicBlock::Create(module_->getContext(), "is_oob", parent); BasicBlock *merge = BasicBlock::Create(module_->getContext(), "oob_merge", parent); Value *cond = b_.CreateICmpUGT( b_.CreateIntCast(scoped_index.value(), b_.getInt64Ty(), false), b_.getInt64(type.GetNumElements() - 1), "oob_cond"); b_.CreateCondBr(cond, is_oob, merge); b_.SetInsertPoint(is_oob); b_.CreateRuntimeError(RuntimeErrorId::ARRAY_ACCESS_OOB, arr.loc); b_.CreateBr(merge); b_.SetInsertPoint(merge); } if (type.IsInBpfMemory()) { return readDatastructElemFromStack(std::move(scoped_expr), scoped_index.value(), type, type_map_.type(&arr)); } else { Value *array = scoped_expr.value(); if (array->getType()->isPointerTy()) { scoped_expr = ScopedExpr(b_.CreatePtrToInt(array, b_.getInt64Ty()), std::move(scoped_expr)); } Value *index = b_.CreateIntCast(scoped_index.value(), b_.getInt64Ty(), type.IsSigned()); Value *offset = b_.CreatePtrOffset(type_map_.type(&arr), index); return probereadDatastructElem(std::move(scoped_expr), offset, type, type_map_.type(&arr), arr.loc, "array_access"); } } ScopedExpr CodegenLLVM::createAnonStructAccess(const SizedType &stype, ScopedExpr &&expr_value, size_t field_idx) { assert(stype.IsTupleTy() || stype.IsRecordTy()); Value *src = b_.CreateGEP(b_.GetType(stype), expr_value.value(), { b_.getInt32(0), b_.getInt32(field_idx) }); SizedType &elem_type = stype.GetFields()[field_idx].type; if (elem_type.IsInBpfMemory()) { // Extend lifetime of source buffer return ScopedExpr(src, std::move(expr_value)); } else { // Lifetime is not extended, it is freed after the load return ScopedExpr(b_.CreateLoad(b_.GetType(elem_type), src)); } } ScopedExpr CodegenLLVM::visit(TupleAccess &acc) { const SizedType &type = type_map_.type(acc.expr); auto scoped_arg = visit(acc.expr); return createAnonStructAccess(type, std::move(scoped_arg), acc.index); } ScopedExpr CodegenLLVM::visit(MapAccess &acc) { if (named_param_info_.defaults.contains(acc.map->ident)) { const auto &val_type = type_map_.map_value_type(acc.map->ident); if (val_type.IsStringTy()) { const auto max_strlen = bpftrace_.config_->max_strlen; Value *np_alloc = b_.CreateGetStrAllocation(acc.map->ident, acc.loc); b_.CreateMemsetBPF(np_alloc, b_.getInt8(0), max_strlen); auto sized_type = bpftrace_.resources.global_vars.get_sized_type( acc.map->ident, bpftrace_.resources, *bpftrace_.config_); b_.CreateMemcpyBPF(np_alloc, module_->getGlobalVariable(acc.map->ident), sized_type.GetSize()); return ScopedExpr(np_alloc, [this, np_alloc]() { b_.CreateLifetimeEnd(np_alloc); }); } return ScopedExpr( b_.CreateLoad(val_type.IsBoolTy() ? b_.getInt1Ty() : b_.getInt64Ty(), module_->getGlobalVariable(acc.map->ident), acc.map->ident)); } auto scoped_key = getMapKey(*acc.map, acc.key); auto map_info = bpftrace_.resources.maps_info.find(acc.map->ident); if (map_info == bpftrace_.resources.maps_info.end()) { LOG(BUG) << "map name: \"" << acc.map->ident << "\" not found"; } const auto &val_type = map_info->second.value_type; Value *value; if (canAggPerCpuMapElems(map_info->second.bpf_type, val_type)) { value = b_.CreatePerCpuMapAggElems( *acc.map, scoped_key.value(), val_type, acc.loc); } else { value = b_.CreateMapLookupElem( acc.map->ident, scoped_key.value(), val_type, acc.loc); } return ScopedExpr(value, [this, value] { b_.CreateLifetimeEnd(value); }); } ScopedExpr CodegenLLVM::visit(Cast &cast) { const auto &ty = type_map_.type(&cast); auto scoped_expr = visit(cast.expr); if (ty.IsIntTy()) { auto *int_ty = b_.GetType(ty); if (type_map_.type(cast.expr).IsArrayTy()) { // we need to read the array into the integer Value *array = scoped_expr.value(); if (type_map_.type(cast.expr).IsInBpfMemory() || type_map_.type(cast.expr).IsCtxAccess()) { // array is on the stack - just cast the pointer if (array->getType()->isIntegerTy()) array = b_.CreateIntToPtr(array, b_.getPtrTy()); } else { // array is in memory - need to proberead auto *buf = b_.CreateAllocaBPF(ty); b_.CreateProbeRead( buf, ty, array, cast.loc, type_map_.type(cast.expr).GetAS()); array = buf; } return ScopedExpr(b_.CreateLoad(int_ty, array, true /*volatile*/)); } else if (type_map_.type(cast.expr).IsPtrTy()) { return ScopedExpr(b_.CreatePtrToInt(scoped_expr.value(), int_ty)); } else { return ScopedExpr(b_.CreateIntCast(scoped_expr.value(), b_.getIntNTy(ty.GetIntBitWidth()), type_map_.type(cast.expr).IsSigned(), "cast")); } } else if (ty.IsArrayTy() && type_map_.type(cast.expr).IsIntTy()) { // We need to store the cast integer on stack and reinterpret the pointer to // it to an array pointer. auto *v = b_.CreateAllocaBPF(scoped_expr.value()->getType()); b_.CreateStore(scoped_expr.value(), v); return ScopedExpr(v, [this, v] { b_.CreateLifetimeEnd(v); }); } else if (ty.IsBoolTy()) { if (type_map_.type(cast.expr).IsStringTy()) { auto *first_char = b_.CreateGEP(b_.getInt8Ty(), scoped_expr.value(), { b_.getInt32(0) }); Value *cond = b_.CreateICmpNE(b_.CreateLoad(b_.getInt8Ty(), first_char), b_.getInt8(0), "bool_cast"); return ScopedExpr(cond); } Value *zero_value = Constant::getNullValue(scoped_expr.value()->getType()); Value *cond = b_.CreateICmpNE(scoped_expr.value(), zero_value, "bool_cast"); return ScopedExpr(cond); } else if (ty.IsPtrTy()) { if (type_map_.type(cast.expr).IsIntTy()) { Value *val = b_.CreateIntToPtr(scoped_expr.value(), b_.getPtrTy()); return ScopedExpr(val); } return scoped_expr; } else if (ty.IsStringTy()) { auto *buf = b_.CreateGetStrAllocation("cast", cast.loc); const auto max_strlen = bpftrace_.config_->max_strlen; b_.CreateMemsetBPF(buf, b_.getInt8(0), max_strlen); b_.CreateMemcpyBPF(buf, scoped_expr.value(), type_map_.type(cast.expr).GetSize()); if (dyn_cast(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } else { // FIXME(amscanne): The existing behavior is to simply pass the existing // expression back up when it is neither an integer nor an array. return scoped_expr; } } void CodegenLLVM::compareStructure(const SizedType &our_type, llvm::Type *llvm_type) { // Validate that what we thought the struct looks like // and LLVM made of it are equal to avoid issues. // // As the size is used throughout type resolution for // sizing buffers and maps we have to abort if it doesn't // match. // But offset is only used for printing, so we can recover // from that by storing the correct offset. // size_t our_size = our_type.GetSize(); size_t llvm_size = datalayout().getTypeAllocSize(llvm_type); if (llvm_size != our_size) { LOG(BUG) << "Struct size mismatch: expected: " << our_size << ", real: " << llvm_size; } const auto *layout = datalayout().getStructLayout( reinterpret_cast(llvm_type)); for (ssize_t i = 0; i < our_type.GetFieldCount(); i++) { ssize_t llvm_offset = layout->getElementOffset(i); const auto &field = our_type.GetField(i); ssize_t our_offset = field.offset; if (llvm_offset != our_offset) { LOG(DEBUG) << "Struct offset mismatch for: " << field.type << "(" << i << ")" << ": (llvm) " << llvm_offset << " != " << our_offset; } } } // Constructs a tuple or record on the scratch buffer or stack from the provided // values. Value *CodegenLLVM::createAnonStruct( const SizedType &stype, const std::vector> &vals, const std::string &name, const Location &loc) { auto *llvm_ty = b_.GetType(stype); size_t alloc_size = datalayout().getTypeAllocSize(llvm_ty); auto *buf = b_.CreateAnonStructAllocation(stype, name, loc); b_.CreateMemsetBPF(buf, b_.getInt8(0), alloc_size); for (size_t i = 0; i < vals.size(); ++i) { const auto &[val, src_type, vloc] = vals[i]; SizedType &type = stype.GetField(i).type; Value *dst = b_.CreateGEP(llvm_ty, buf, { b_.getInt32(0), b_.getInt32(i) }); if ((type.IsArrayTy() || type.IsCTypeTy()) && !src_type.IsInBpfMemory()) b_.CreateProbeRead(dst, type, val, vloc, find_addrspace_stack(src_type)); else if (type.IsInBpfMemory()) b_.CreateMemcpyBPF(dst, val, type.GetSize()); else b_.CreateStore(val, dst); } return buf; } ScopedExpr CodegenLLVM::visit(Tuple &tuple) { llvm::Type *tuple_ty = b_.GetType(type_map_.type(&tuple)); compareStructure(type_map_.type(&tuple), tuple_ty); std::vector> vals; // This is used to extend the life of the element expressions // beyond the `for` loop body below std::vector scoped_exprs; vals.reserve(tuple.elems.size()); for (auto &elem : tuple.elems) { auto scoped_expr = visit(elem); vals.emplace_back(scoped_expr.value(), type_map_.type(elem), tuple.loc); scoped_exprs.emplace_back(std::move(scoped_expr)); } auto *buf = createAnonStruct( type_map_.type(&tuple), vals, "tuple", tuple.loc); if (isa(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } ScopedExpr CodegenLLVM::visit(Record &record) { llvm::Type *record_ty = b_.GetType(type_map_.type(&record)); compareStructure(type_map_.type(&record), record_ty); std::vector> vals; // This is used to extend the life of the element expressions // beyond the `for` loop body below std::vector scoped_exprs; vals.reserve(record.elems.size()); for (auto *elem : record.elems) { auto scoped_expr = visit(elem->expr); vals.emplace_back(scoped_expr.value(), type_map_.type(elem->expr), record.loc); scoped_exprs.emplace_back(std::move(scoped_expr)); } auto *buf = createAnonStruct( type_map_.type(&record), vals, "record", record.loc); if (dyn_cast(buf)) return ScopedExpr(buf, [this, buf]() { b_.CreateLifetimeEnd(buf); }); return ScopedExpr(buf); } ScopedExpr CodegenLLVM::visit(ExprStatement &expr) { return visit(expr.expr); } ScopedExpr CodegenLLVM::visit(AssignMapStatement &assignment) { auto scoped_expr = visit(assignment.expr); auto scoped_key = getMapKey(*assignment.map_access->map, assignment.map_access->key); Value *expr = scoped_expr.value(); const auto &map_type = type_map_.map_value_type( assignment.map_access->map->ident); const auto &expr_type = type_map_.type(assignment.expr); const auto alloca_created_here = needMapAllocation(map_type, expr_type); Value *value = alloca_created_here ? b_.CreateWriteMapValueAllocation( map_type, assignment.map_access->map->ident + "_val", assignment.loc) : expr; if (alloca_created_here) { createMapBufferStore(expr_type, expr, map_type, value, assignment.loc); } b_.CreateMapUpdateElem(assignment.map_access->map->ident, scoped_key.value(), value, assignment.loc); if (alloca_created_here && dyn_cast(value)) b_.CreateLifetimeEnd(value); return ScopedExpr(); } void CodegenLLVM::maybeAllocVariable(const std::string &var_ident, const SizedType &var_type, const Location &loc) { if (maybeGetVariable(var_ident) != nullptr) { // Already been allocated return; } auto *val = b_.CreateVariableAllocationInit(var_type, var_ident, loc); variables_[scope_stack_.back()][var_ident] = VariableLLVM{ .value = val, .type = b_.GetType(var_type) }; } VariableLLVM *CodegenLLVM::maybeGetVariable(const std::string &var_ident) { for (auto *scope : scope_stack_) { if (auto search_val = variables_[scope].find(var_ident); search_val != variables_[scope].end()) { return &search_val->second; } } return nullptr; } VariableLLVM &CodegenLLVM::getVariable(const std::string &var_ident) { auto *variable = maybeGetVariable(var_ident); if (!variable) { LOG(BUG) << "Can't find variable: " << var_ident << " in this or outer scope"; } return *variable; } void CodegenLLVM::createVariableStore(const SizedType &src_type, Value *src, const SizedType &dst_type, Value *dst, const Location &loc, bool recursing) { if (dst_type.IsTupleTy() || dst_type.IsRecordTy()) { if (src_type == dst_type) { // If the types exactly match we don't need to do field matching b_.CreateMemcpyBPF(dst, src, src_type.GetSize()); return; } llvm::Type *src_llvm_type = b_.GetType(src_type); llvm::Type *dst_llvm_type = b_.GetType(dst_type); for (size_t i = 0; i < dst_type.GetFields().size(); ++i) { const auto &dst_field = dst_type.GetField(i); auto src_field_index = dst_type.IsRecordTy() ? src_type.GetFieldIdx(dst_field.name) : i; const auto &src_field = src_type.GetField(src_field_index); Value *src_field_val = b_.CreateGEP( src_llvm_type, src, { b_.getInt64(0), b_.getInt32(src_field_index) }); Value *dst_field_val = b_.CreateGEP(dst_llvm_type, dst, { b_.getInt64(0), b_.getInt32(i) }); createVariableStore(src_field.type, src_field_val, dst_field.type, dst_field_val, loc, true); } return; } if (recursing) { // We're inside a tuple or record but we can just copy the fields b_.CreateMemcpyBPF(dst, src, src_type.GetSize()); return; } if ((dst_type.IsArrayTy() || dst_type.IsCTypeTy()) && !src_type.IsInBpfMemory()) { b_.CreateProbeRead(dst, dst_type, src, loc, find_addrspace_stack(src_type)); } else if (needMemcpy(dst_type)) { b_.CreateMemcpyBPF(dst, src, src_type.GetSize()); } else { b_.CreateStore(src, dst); } } ScopedExpr CodegenLLVM::visit(AssignVarStatement &assignment) { Variable &var = *assignment.var(); auto scoped_expr = visit(assignment.expr); // In order to assign a value to a variable, the expression has to actually // produce a value. Unfortunately, there are many expressions which currently // do not produce values (and are either valid only the context of a map // assignment, or are otherwise useful only in statements). Therefore, we try // to provide as much information as possible but generally consider this a // bug until it can be resolved. if (!scoped_expr.value()) { LOG(BUG) << "Expression produced no value for variable: " << var.ident; __builtin_unreachable(); } maybeAllocVariable(var.ident, type_map_.type(&var), var.loc); auto *val = getVariable(var.ident).value; const auto &expr_type = type_map_.type(assignment.expr); createVariableStore( expr_type, scoped_expr.value(), type_map_.type(&var), val, var.loc); return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(VarDeclStatement &decl) { Variable &var = *decl.var; if (type_map_.type(&var).IsNoneTy()) { // unused and has no type return ScopedExpr(); } maybeAllocVariable(var.ident, type_map_.type(&var), var.loc); b_.CreateAllocationInit(type_map_.type(&var), getVariable(var.ident).value); return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(Unroll &unroll) { auto n = unroll.expr.as()->value; for (uint64_t i = 0; i < n; i++) { // Make sure to save/restore async ID state b/c we could be processing // the same async calls multiple times. auto reset_ids = async_ids_.create_reset_ids(); auto scoped_del = visit(unroll.block); if (i != n - 1) reset_ids(); } return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(Jump &jump) { switch (jump.ident) { case JumpType::RETURN: // return can be used outside of loops. if (jump.return_value) { auto scoped_return = visit(jump.return_value); createRet(scoped_return.value()); } else { createRet(); } break; case JumpType::BREAK: b_.CreateBr(std::get<1>(loops_.back())()); break; case JumpType::CONTINUE: b_.CreateBr(std::get<0>(loops_.back())()); break; default: LOG(BUG) << "jump: invalid op \"" << opstr(jump) << "\""; __builtin_unreachable(); } return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(While &while_block) { if (!loop_metadata_) loop_metadata_ = createLoopMetadata(); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *while_cond = BasicBlock::Create(module_->getContext(), "while_cond", parent); BasicBlock *while_body = BasicBlock::Create(module_->getContext(), "while_body", parent); BasicBlock *while_end = BasicBlock::Create(module_->getContext(), "while_end", parent); // Both while blocks are guaranteed to have predescesors, because we evaluate // the condition for execution at least once. This simplifies the functions. loops_.emplace_back([&] { return while_cond; }, [&] { return while_end; }); b_.CreateBr(while_cond); b_.SetInsertPoint(while_cond); auto scoped_cond = visit(while_block.cond); auto *cond_expr = scoped_cond.value(); Value *zero_value = Constant::getNullValue(cond_expr->getType()); auto *cond = b_.CreateICmpNE(cond_expr, zero_value, "true_cond"); Instruction *loop_hdr = b_.CreateCondBr(cond, while_body, while_end); loop_hdr->setMetadata(LLVMContext::MD_loop, loop_metadata_); b_.SetInsertPoint(while_body); auto scoped_block = visit(*while_block.block); b_.SetInsertPoint(while_end); loops_.pop_back(); return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(For &f) { scope_stack_.push_back(&f); std::visit([&](auto *iter) { visit(f, *iter); }, f.iterable.value); scope_stack_.pop_back(); return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(BlockExpr &block_expr) { scope_stack_.push_back(&block_expr); visit(block_expr.stmts); ScopedExpr value = visit(block_expr.expr); scope_stack_.pop_back(); return value; } void CodegenLLVM::generateProbe(Probe &probe, const std::string &name, FunctionType *func_type) { auto probe_type = probetype(current_attach_point_->provider); int index = probe.index(); auto func_name = util::get_function_name_for_probe(name, index); auto *func = llvm::Function::Create( func_type, llvm::Function::ExternalLinkage, func_name, module_.get()); func->setSection(util::get_section_name(func_name)); func->addFnAttr(Attribute::NoUnwind); scope_ = debug_.createProbeDebugInfo(*func); BasicBlock *entry = BasicBlock::Create(module_->getContext(), "entry", func); b_.SetInsertPoint(entry); // check: do the following 8 lines need to be in the wildcard loop? ctx_ = func->arg_begin(); if (bpftrace_.need_recursion_check_) { b_.CreateCheckSetRecursion(current_attach_point_->loc, getReturnValueForProbe(probe_type)); } variables_.clear(); visit(*probe.block); } void CodegenLLVM::add_probe(AttachPoint &ap, Probe &probe, FunctionType *func_type) { current_attach_point_ = ≈ probefull_ = ap.name(); generateProbe(probe, probefull_, func_type); bpftrace_.add_probe(ap, probe, expansions_.get_expansion(ap), expansions_.get_expanded_funcs(ap)); current_attach_point_ = nullptr; } ScopedExpr CodegenLLVM::visit(Subprog &subprog) { scope_stack_.push_back(&subprog); std::vector arg_types; // First argument is for passing ctx pointer for output, rest are proper // arguments to the function arg_types.push_back(b_.getPtrTy()); std::ranges::transform(subprog.args, std::back_inserter(arg_types), [this](SubprogArg *arg) { return b_.GetType(type_map_.type(arg->typeof)); }); FunctionType *func_type = FunctionType::get( b_.GetType(type_map_.type(subprog.return_type)), arg_types, false); auto *func = llvm::Function::Create( func_type, llvm::Function::InternalLinkage, subprog.name, module_.get()); BasicBlock *entry = BasicBlock::Create(module_->getContext(), "entry", func); b_.SetInsertPoint(entry); variables_.clear(); ctx_ = func->arg_begin(); inside_subprog_ = true; int arg_index = 0; for (SubprogArg *arg : subprog.args) { auto *alloca = b_.CreateAllocaBPF(b_.GetType(type_map_.type(arg->typeof)), arg->var->ident); b_.CreateStore(func->getArg(arg_index + 1), alloca); variables_[scope_stack_.back()][arg->var->ident] = VariableLLVM{ .value = alloca, .type = alloca->getAllocatedType() }; ++arg_index; } visit(subprog.block); FunctionPassManager fpm; FunctionAnalysisManager fam; llvm::PassBuilder pb; pb.registerFunctionAnalyses(fam); fpm.addPass(UnreachableBlockElimPass()); fpm.run(*func, fam); scope_stack_.pop_back(); return ScopedExpr(); } void CodegenLLVM::createRet(Value *value) { if (bpftrace_.need_recursion_check_) { b_.CreateUnSetRecursion(current_attach_point_->loc); } // If value is explicitly provided, use it. if (value) { b_.CreateRet(value); } else { if (inside_subprog_) { b_.CreateRetVoid(); } else { int ret_val = getReturnValueForProbe( probetype(current_attach_point_->provider)); b_.CreateRet(b_.getInt64(ret_val)); } } } int CodegenLLVM::getReturnValueForProbe(ProbeType probe_type) { // Fall back to default return value switch (probe_type) { case ProbeType::invalid: LOG(BUG) << "Returning from invalid probetype"; return 0; case ProbeType::tracepoint: // Classic (ie. *not* raw) tracepoints have a kernel quirk stopping perf // subsystem from seeing a tracepoint event if BPF program returns 0. // This breaks perf in some situations and generally makes such BPF // programs bad citizens. Return 1 instead. return 1; case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::kprobe: case ProbeType::kretprobe: case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: case ProbeType::profile: case ProbeType::interval: case ProbeType::software: case ProbeType::hardware: case ProbeType::watchpoint: case ProbeType::fentry: case ProbeType::fexit: case ProbeType::iter: case ProbeType::rawtracepoint: return 0; } LOG(BUG) << "Unknown probetype"; return 0; } ScopedExpr CodegenLLVM::visit(Probe &probe) { FunctionType *func_type = FunctionType::get(b_.getInt64Ty(), { b_.getPtrTy() }, // ctx false); // We begin by saving state that gets changed by the codegen pass, so we // can restore it for the next pass (printf_id_, time_id_). async_ids_.create_reset_ids(); assert(probe.attach_points.size() == 1); current_attach_point_ = probe.attach_points.at(0); probe.set_index(getNextIndexForProbe()); add_probe(*current_attach_point_, probe, func_type); current_attach_point_ = nullptr; return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(Program &program) { for (Subprog *subprog : program.functions) visit(subprog); for (Probe *probe : program.probes) visit(probe); return ScopedExpr(); } int CodegenLLVM::getNextIndexForProbe() { return next_probe_index_++; } void CodegenLLVM::createMapBufferStore(const SizedType &src_type, Value *src, const SizedType &dst_type, Value *dst, const Location &loc, bool recursing) { if (dst_type.IsTupleTy() || dst_type.IsRecordTy()) { if (src_type == dst_type) { // If the types exactly match we don't need to do field matching b_.CreateMemcpyBPF(dst, src, src_type.GetSize()); return; } llvm::Type *src_llvm_type = b_.GetType(src_type); llvm::Type *dst_llvm_type = b_.GetType(dst_type); for (size_t i = 0; i < dst_type.GetFields().size(); ++i) { const auto &dst_field = dst_type.GetField(i); auto src_field_index = dst_type.IsRecordTy() ? src_type.GetFieldIdx(dst_field.name) : i; const auto &src_field = src_type.GetField(src_field_index); Value *src_field_val = b_.CreateGEP( src_llvm_type, src, { b_.getInt64(0), b_.getInt32(src_field_index) }); Value *dst_field_val = b_.CreateGEP(dst_llvm_type, dst, { b_.getInt64(0), b_.getInt32(i) }); createMapBufferStore(src_field.type, src_field_val, dst_field.type, dst_field_val, loc, true); } return; } if (recursing) { b_.CreateMemcpyBPF(dst, src, src_type.GetSize()); return; } if ((dst_type.IsArrayTy() || dst_type.IsCTypeTy()) && !src_type.IsInBpfMemory()) { // src currently contains a pointer to the struct or array // We now want to read the entire struct/array in so we can save it b_.CreateProbeRead(dst, dst_type, src, loc, find_addrspace_stack(src_type)); } else if (dst_type.IsInBpfMemory()) { b_.CreateMemcpyBPF(dst, src, src_type.GetSize()); } else { b_.CreateStore(src, dst); } } ScopedExpr CodegenLLVM::getMapKey(Map &map, Expression &key_expr) { const auto &expr_type = type_map_.type(key_expr); const auto alloca_created_here = needMapAllocation( type_map_.map_key_type(map.ident), expr_type); auto scoped_key_expr = visit(key_expr); const auto &key_type = type_map_.map_key_type(map.ident); Value *expr = scoped_key_expr.value(); // Allocation needs to be done after recursing via visit(key_expr) so that // we have the expression SSA value. Value *key = alloca_created_here ? b_.CreateMapKeyAllocation(key_type, map.ident + "_key", map.loc) : expr; if (alloca_created_here) { createMapBufferStore(expr_type, expr, key_type, key, map.loc); } // Either way we hold on to the original key, to ensure that its lifetime // lasts as long as it may be accessed. if (alloca_created_here && dyn_cast(key)) { return ScopedExpr(key, [this, key, k = std::move(scoped_key_expr)] { b_.CreateLifetimeEnd(key); }); } return ScopedExpr(key, std::move(scoped_key_expr)); } ScopedExpr CodegenLLVM::getMultiMapKey(Map &map, Expression &key_expr, const std::vector &extra_keys, const Location &loc) { auto scoped_expr = visit(key_expr); size_t size = type_map_.map_key_type(map.ident).GetSize(); for (auto *extra_key : extra_keys) { size += module_->getDataLayout().getTypeAllocSize(extra_key->getType()); } // If key ever changes to not be allocated here, be sure to update // getMapKey() as well to take the new lifetime semantics into account. auto *key = b_.CreateMapKeyAllocation(CreateArray(size, CreateInt8()), map.ident + "_key", loc); auto *key_type = ArrayType::get(b_.getInt8Ty(), size); int offset = 0; // Construct a map key in the stack Value *offset_val = b_.CreateGEP(key_type, key, { b_.getInt64(0), b_.getInt64(offset) }); size_t map_key_size = type_map_.map_key_type(map.ident).GetSize(); size_t expr_size = type_map_.type(key_expr).GetSize(); bool aligned = (map_key_size % 8) == 0; if (type_map_.type(key_expr).IsInBpfMemory()) { b_.CreateMemcpyBPF(offset_val, scoped_expr.value(), expr_size); } else { if (type_map_.type(key_expr).IsArrayTy() || type_map_.type(key_expr).IsCTypeTy()) { // Read the array/struct into the key b_.CreateProbeRead(offset_val, type_map_.type(key_expr), scoped_expr.value(), map.loc, find_addrspace_stack(type_map_.type(key_expr))); } else { if (aligned) b_.CreateStore(scoped_expr.value(), offset_val); else b_.createAlignedStore(scoped_expr.value(), offset_val, 1); } } offset += map_key_size; for (auto *extra_key : extra_keys) { Value *offset_val = b_.CreateGEP(key_type, key, { b_.getInt64(0), b_.getInt64(offset) }); if (aligned) b_.CreateStore(extra_key, offset_val); else b_.createAlignedStore(extra_key, offset_val, 1); offset += module_->getDataLayout().getTypeAllocSize(extra_key->getType()); } return ScopedExpr(key, [this, key] { b_.CreateLifetimeEnd(key); }); } ScopedExpr CodegenLLVM::createLogicalAnd(Binop &binop) { assert(type_map_.type(binop.left).IsIntTy() || type_map_.type(binop.left).IsPtrTy() || type_map_.type(binop.left).IsBoolTy()); assert(type_map_.type(binop.right).IsIntTy() || type_map_.type(binop.right).IsPtrTy() || type_map_.type(binop.right).IsBoolTy()); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *lhs_true_block = BasicBlock::Create(module_->getContext(), "&&_lhs_true", parent); BasicBlock *true_block = BasicBlock::Create(module_->getContext(), "&&_true", parent); BasicBlock *false_block = BasicBlock::Create(module_->getContext(), "&&_false", parent); BasicBlock *merge_block = BasicBlock::Create(module_->getContext(), "&&_merge", parent); Value *result = b_.CreateAllocaBPF(b_.getInt1Ty(), "&&_result"); ScopedExpr scoped_lhs = visit(binop.left); Value *lhs = scoped_lhs.value(); Value *lhs_zero_value = Constant::getNullValue(lhs->getType()); b_.CreateCondBr(b_.CreateICmpNE(lhs, lhs_zero_value, "lhs_true_cond"), lhs_true_block, false_block); b_.SetInsertPoint(lhs_true_block); ScopedExpr scoped_rhs = visit(binop.right); Value *rhs = scoped_rhs.value(); Value *rhs_zero_value = Constant::getNullValue(rhs->getType()); b_.CreateCondBr(b_.CreateICmpNE(rhs, rhs_zero_value, "rhs_true_cond"), true_block, false_block); b_.SetInsertPoint(true_block); b_.CreateStore(b_.getInt1(true), result); b_.CreateBr(merge_block); b_.SetInsertPoint(false_block); b_.CreateStore(b_.getInt1(false), result); b_.CreateBr(merge_block); b_.SetInsertPoint(merge_block); return ScopedExpr(b_.CreateLoad(b_.getInt1Ty(), result)); } ScopedExpr CodegenLLVM::createLogicalOr(Binop &binop) { assert(type_map_.type(binop.left).IsIntTy() || type_map_.type(binop.left).IsPtrTy() || type_map_.type(binop.left).IsBoolTy()); assert(type_map_.type(binop.right).IsIntTy() || type_map_.type(binop.right).IsPtrTy() || type_map_.type(binop.right).IsBoolTy()); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *lhs_false_block = BasicBlock::Create(module_->getContext(), "||_lhs_false", parent); BasicBlock *false_block = BasicBlock::Create(module_->getContext(), "||_false", parent); BasicBlock *true_block = BasicBlock::Create(module_->getContext(), "||_true", parent); BasicBlock *merge_block = BasicBlock::Create(module_->getContext(), "||_merge", parent); Value *result = b_.CreateAllocaBPF(b_.getInt1Ty(), "||_result"); ScopedExpr scoped_lhs = visit(binop.left); Value *lhs = scoped_lhs.value(); Value *lhs_zero_value = Constant::getNullValue(lhs->getType()); b_.CreateCondBr(b_.CreateICmpNE(lhs, lhs_zero_value, "lhs_true_cond"), true_block, lhs_false_block); b_.SetInsertPoint(lhs_false_block); ScopedExpr scoped_rhs = visit(binop.right); Value *rhs = scoped_rhs.value(); Value *rhs_zero_value = Constant::getNullValue(rhs->getType()); b_.CreateCondBr(b_.CreateICmpNE(rhs, rhs_zero_value, "rhs_true_cond"), true_block, false_block); b_.SetInsertPoint(false_block); b_.CreateStore(b_.getInt1(false), result); b_.CreateBr(merge_block); b_.SetInsertPoint(true_block); b_.CreateStore(b_.getInt1(true), result); b_.CreateBr(merge_block); b_.SetInsertPoint(merge_block); return ScopedExpr(b_.CreateLoad(b_.getInt1Ty(), result)); } llvm::Function *CodegenLLVM::createLog2Function() { auto ip = b_.saveIP(); // Arguments: VAL (int64), K (0..5) // Maps each power of 2 into N = 2^K buckets, so we can build fine-grained // histograms with low runtime cost. // // Returns: // 0 for VAL < 0 // 1 + VAL for 0 <= VAL < 2^K // 1 + concat(A,B) for VAL >= 2^K, // where // A is the position of the leftmost "1" in VAL, minus K // B are the K bits following the leftmost "1" in VAL // // As an example, if VAL = 225 (0b11100001) and K = 2: // - the leftmost "1" in VAL is at position 8, so A is 8-2=6 (0b110) // - the following bits are "11" so B is 0b11 // and the returned value is 1 + concat(0b110, 0b11) = 1 + 0b11011 = 28 // // log2(int n, int k) // { // if (n < 0) return 0; // mask = (1ul << k) - 1; // if (n <= mask) return n + 1; // n0 = n; // // find leftmost 1 // l = 0; // for (int i = 5; i >= 0; i--) { // threshold = 1ul << (1<= threshold) << i; // n >>= shift; // l += shift; // } // l -= k; // // mask K bits after leftmost 1 // x = (n0 >> l) & mask; // return ((l + 1) << k) + x + 1; // } FunctionType *log2_func_type = FunctionType::get( b_.getInt64Ty(), { b_.getInt64Ty(), b_.getInt64Ty() }, false); auto *log2_func = llvm::Function::Create( log2_func_type, llvm::Function::InternalLinkage, "log2", module_.get()); log2_func->addFnAttr(Attribute::AlwaysInline); log2_func->setSection("helpers"); log2_func->addFnAttr(Attribute::NoUnwind); BasicBlock *entry = BasicBlock::Create(module_->getContext(), "entry", log2_func); b_.SetInsertPoint(entry); // storage for arguments Value *n_alloc = b_.CreateAllocaBPF(CreateUInt64()); b_.CreateStore(log2_func->arg_begin(), n_alloc); Value *k_alloc = b_.CreateAllocaBPF(CreateUInt64()); b_.CreateStore(log2_func->arg_begin() + 1, k_alloc); // test for less than zero BasicBlock *is_less_than_zero = BasicBlock::Create(module_->getContext(), "hist.is_less_than_zero", log2_func); BasicBlock *is_not_less_than_zero = BasicBlock::Create( module_->getContext(), "hist.is_not_less_than_zero", log2_func); Value *n = b_.CreateLoad(b_.getInt64Ty(), n_alloc); Value *zero = b_.getInt64(0); b_.CreateCondBr(b_.CreateICmpSLT(n, zero), is_less_than_zero, is_not_less_than_zero); b_.SetInsertPoint(is_less_than_zero); createRet(zero); b_.SetInsertPoint(is_not_less_than_zero); // first set of buckets (<= mask) Value *one = b_.getInt64(1); Value *k = b_.CreateLoad(b_.getInt64Ty(), k_alloc); Value *mask = b_.CreateSub(b_.CreateShl(one, k), one); BasicBlock *is_zero = BasicBlock::Create(module_->getContext(), "hist.is_zero", log2_func); BasicBlock *is_not_zero = BasicBlock::Create(module_->getContext(), "hist.is_not_zero", log2_func); b_.CreateCondBr(b_.CreateICmpULE(n, mask), is_zero, is_not_zero); b_.SetInsertPoint(is_zero); createRet(b_.CreateAdd(n, one)); b_.SetInsertPoint(is_not_zero); // index of first bit set in n, 1 means bit 0, guaranteed to be >= k Value *l = zero; for (int i = 5; i >= 0; i--) { Value *threshold = b_.getInt64(1UL << (1UL << i)); Value *is_ge = b_.CreateICmpSGE(n, threshold); // cast is important. is_ge = b_.CreateIntCast(is_ge, b_.getInt64Ty(), false); Value *shift = b_.CreateShl(is_ge, i); n = b_.CreateLShr(n, shift); l = b_.CreateAdd(l, shift); } // see algorithm for next steps: // subtract k, so we can move the next k bits of N to position 0 l = b_.CreateSub(l, k); // now find the k bits in n after the first '1' Value *x = b_.CreateAnd( b_.CreateLShr(b_.CreateLoad(b_.getInt64Ty(), n_alloc), l), mask); Value *ret = b_.CreateAdd(l, one); ret = b_.CreateShl(ret, k); // make room for the extra slots ret = b_.CreateAdd(ret, x); ret = b_.CreateAdd(ret, one); createRet(ret); b_.restoreIP(ip); return module_->getFunction("log2"); } llvm::Function *CodegenLLVM::createLinearFunction() { auto ip = b_.saveIP(); // lhist() returns a bucket index for the given value. The first and last // bucket indexes are special: they are 0 for the less-than-range // bucket, and index max_bucket+2 for the greater-than-range bucket. // Indexes 1 to max_bucket+1 span the buckets in the range. // // int lhist(int value, int min, int max, int step) // { // int result; // // if (value < min) // return 0; // if (value > max) // return 1 + (max - min) / step; // result = 1 + (value - min) / step; // // return result; // } // inlined function initialization FunctionType *linear_func_type = FunctionType::get( b_.getInt64Ty(), { b_.getInt64Ty(), b_.getInt64Ty(), b_.getInt64Ty(), b_.getInt64Ty() }, false); auto *linear_func = llvm::Function::Create(linear_func_type, llvm::Function::InternalLinkage, "linear", module_.get()); linear_func->addFnAttr(Attribute::AlwaysInline); linear_func->setSection("helpers"); linear_func->addFnAttr(Attribute::NoUnwind); BasicBlock *entry = BasicBlock::Create(module_->getContext(), "entry", linear_func); b_.SetInsertPoint(entry); // pull in arguments Value *value_alloc = b_.CreateAllocaBPF(CreateUInt64()); Value *min_alloc = b_.CreateAllocaBPF(CreateUInt64()); Value *max_alloc = b_.CreateAllocaBPF(CreateUInt64()); Value *step_alloc = b_.CreateAllocaBPF(CreateUInt64()); Value *result_alloc = b_.CreateAllocaBPF(CreateUInt64()); b_.CreateStore(linear_func->arg_begin() + 0, value_alloc); b_.CreateStore(linear_func->arg_begin() + 1, min_alloc); b_.CreateStore(linear_func->arg_begin() + 2, max_alloc); b_.CreateStore(linear_func->arg_begin() + 3, step_alloc); Value *cmp = nullptr; // algorithm { Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc); Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc); cmp = b_.CreateICmpSLT(val, min); } BasicBlock *lt_min = BasicBlock::Create(module_->getContext(), "lhist.lt_min", linear_func); BasicBlock *ge_min = BasicBlock::Create(module_->getContext(), "lhist.ge_min", linear_func); b_.CreateCondBr(cmp, lt_min, ge_min); b_.SetInsertPoint(lt_min); createRet(b_.getInt64(0)); b_.SetInsertPoint(ge_min); { Value *max = b_.CreateLoad(b_.getInt64Ty(), max_alloc); Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc); cmp = b_.CreateICmpSGT(val, max); } BasicBlock *le_max = BasicBlock::Create(module_->getContext(), "lhist.le_max", linear_func); BasicBlock *gt_max = BasicBlock::Create(module_->getContext(), "lhist.gt_max", linear_func); b_.CreateCondBr(cmp, gt_max, le_max); b_.SetInsertPoint(gt_max); { Value *step = b_.CreateLoad(b_.getInt64Ty(), step_alloc); Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc); Value *max = b_.CreateLoad(b_.getInt64Ty(), max_alloc); Value *div = b_.CreateUDiv(b_.CreateSub(max, min), step); b_.CreateStore(b_.CreateAdd(div, b_.getInt64(1)), result_alloc); createRet(b_.CreateLoad(b_.getInt64Ty(), result_alloc)); } b_.SetInsertPoint(le_max); { Value *step = b_.CreateLoad(b_.getInt64Ty(), step_alloc); Value *min = b_.CreateLoad(b_.getInt64Ty(), min_alloc); Value *val = b_.CreateLoad(b_.getInt64Ty(), value_alloc); Value *div3 = b_.CreateUDiv(b_.CreateSub(val, min), step); b_.CreateStore(b_.CreateAdd(div3, b_.getInt64(1)), result_alloc); createRet(b_.CreateLoad(b_.getInt64Ty(), result_alloc)); } b_.restoreIP(ip); return module_->getFunction("linear"); } MDNode *CodegenLLVM::createLoopMetadata() { // Create metadata to disable loop unrolling // // For legacy reasons, the first item of a loop metadata node must be // a self-reference. See https://llvm.org/docs/LangRef.html#llvm-loop MDNode *unroll_disable = MDNode::get( llvm_ctx_, MDString::get(llvm_ctx_, "llvm.loop.unroll.disable")); MDNode *loopid = MDNode::getDistinct(llvm_ctx_, { unroll_disable, unroll_disable }); loopid->replaceOperandWith(0, loopid); return loopid; } void CodegenLLVM::createFormatStringCall(Call &call, int id, const std::vector &call_args, const std::string &call_name, async_action::AsyncAction async_action) { std::vector elements; for (const Field &arg : call_args) { llvm::Type *ty = b_.GetType(arg.type); elements.push_back(ty); } // perf event output has: uint64_t id, vargs // The id maps to bpftrace_.*_args_, and is a way to define the // types and offsets of each of the arguments, and share that between BPF // and user-space for printing. std::vector ringbuf_elems = { b_.getInt64Ty() }; StructType *fmt_struct = nullptr; if (!elements.empty()) { fmt_struct = StructType::create(elements, call_name + "_args_t", false); ringbuf_elems.push_back(fmt_struct); } StructType *ringbuf_struct = StructType::create(ringbuf_elems, call_name + "_t", false); int struct_size = datalayout().getTypeAllocSize(ringbuf_struct); Value *fmt_args = b_.CreateGetFmtStringArgsAllocation(ringbuf_struct, call_name + "_args", call.loc); // The struct is not packed so we need to memset it b_.CreateMemsetBPF(fmt_args, b_.getInt8(0), struct_size); Value *id_offset = b_.CreateGEP(ringbuf_struct, fmt_args, { b_.getInt32(0), b_.getInt32(0) }); b_.CreateStore(b_.getInt64(id + static_cast(async_action)), id_offset); Value *fmt_offset = nullptr; if (fmt_struct) { fmt_offset = b_.CreateGEP(ringbuf_struct, fmt_args, { b_.getInt32(0), b_.getInt32(1) }); } for (size_t i = 1; i < call.vargs.size(); i++) { Expression &arg = call.vargs.at(i); auto scoped_arg = visit(arg); Value *offset = b_.CreateGEP(fmt_struct, fmt_offset, { b_.getInt32(0), b_.getInt32(i - 1) }); if (needMemcpy(type_map_.type(arg))) b_.CreateMemcpyBPF(offset, scoped_arg.value(), type_map_.type(arg).GetSize()); else b_.CreateStore(scoped_arg.value(), offset); } b_.CreateOutput(fmt_args, struct_size, call.loc); if (dyn_cast(fmt_args)) b_.CreateLifetimeEnd(fmt_args); } void CodegenLLVM::createPrintMapCall(Call &call) { auto elements = AsyncEvent::Print().asLLVMType(b_); StructType *print_struct = b_.GetStructType(call.func + "_t", elements, true); auto &arg = call.vargs.at(0); auto &map = *arg.as(); AllocaInst *buf = b_.CreateAllocaBPF(print_struct, call.func + "_" + map.ident); // store asyncactionid: b_.CreateStore( b_.getInt64(static_cast(async_action::AsyncAction::print)), b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(0) })); int id = bpftrace_.resources.maps_info.at(map.ident).id; if (id == -1) { LOG(BUG) << "map id for map \"" << map.ident << "\" not found"; } auto *ident_ptr = b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(1) }); b_.CreateStore(b_.GetIntSameSize(id, elements.at(1)), ident_ptr); // top, div // first loops sets the arguments as passed by user. The second one zeros // the rest size_t arg_idx = 1; for (; arg_idx < call.vargs.size(); arg_idx++) { auto scoped_arg = visit(call.vargs.at(arg_idx)); b_.CreateStore( b_.CreateIntCast(scoped_arg.value(), elements.at(arg_idx), false), b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(arg_idx + 1) })); } for (; arg_idx < 3; arg_idx++) { b_.CreateStore(b_.GetIntSameSize(0, elements.at(arg_idx)), b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(arg_idx + 1) })); } b_.CreateOutput(buf, getStructSize(print_struct), call.loc); b_.CreateLifetimeEnd(buf); } void CodegenLLVM::createJoinCall(Call &call, int id) { auto &arg0 = call.vargs.front(); auto scoped_arg = visit(arg0); auto addrspace = type_map_.type(arg0).GetAS(); llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *failure_callback = BasicBlock::Create(module_->getContext(), "failure_callback", parent); Value *perfdata = b_.CreateJoinAllocation(call.loc); uint32_t content_size = bpftrace_.join_argnum_ * bpftrace_.join_argsize_; auto elements = AsyncEvent::Join().asLLVMType(b_, content_size); StructType *join_struct = b_.GetStructType("join_t", elements, true); Value *join_data = b_.CreateBitCast(perfdata, PointerType::get(llvm_ctx_, 0)); b_.CreateStore( b_.getInt64(static_cast(async_action::AsyncAction::join)), b_.CreateGEP(join_struct, join_data, { b_.getInt64(0), b_.getInt32(0) })); b_.CreateStore( b_.getInt64(id), b_.CreateGEP(join_struct, join_data, { b_.getInt64(0), b_.getInt32(1) })); Value *content_ptr = b_.CreateGEP(join_struct, join_data, { b_.getInt64(0), b_.getInt32(2) }); SizedType elem_type = CreatePointer(CreateInt8(), addrspace); Value *value = scoped_arg.value(); AllocaInst *arr = b_.CreateAllocaBPF(b_.getInt64Ty(), call.func + "_r0"); for (unsigned int i = 0; i < bpftrace_.join_argnum_; i++) { if (i > 0) { value = b_.CreateGEP(b_.GetType(elem_type), value, b_.getInt32(1)); } b_.CreateProbeRead(arr, elem_type, value, call.loc); Value *str_offset = b_.getInt64( static_cast(i) * static_cast(bpftrace_.join_argsize_)); Value *str_ptr = b_.CreateGEP(b_.getInt8Ty(), content_ptr, str_offset); b_.CreateProbeReadStr(str_ptr, bpftrace_.join_argsize_, b_.CreateLoad(b_.getInt64Ty(), arr), addrspace, call.loc); } size_t header_size = offsetof(AsyncEvent::Join, content); // action_id + // join_id size_t total_size = header_size + content_size; b_.CreateOutput(perfdata, total_size, call.loc); b_.CreateBr(failure_callback); b_.SetInsertPoint(failure_callback); } void CodegenLLVM::createPrintNonMapCall(Call &call) { auto &arg = call.vargs.at(0); auto scoped_arg = visit(arg); Value *value = scoped_arg.value(); auto elements = AsyncEvent::PrintNonMap().asLLVMType( b_, type_map_.type(arg).GetSize()); std::ostringstream struct_name; struct_name << call.func << "_" << type_map_.type(arg).GetTy() << "_" << type_map_.type(arg).GetSize() << "_t"; StructType *print_struct = b_.GetStructType(struct_name.str(), elements, true); Value *buf = b_.CreateGetFmtStringArgsAllocation(print_struct, struct_name.str(), call.loc); size_t struct_size = datalayout().getTypeAllocSize(print_struct); // Store asyncactionid: b_.CreateStore( b_.getInt64( static_cast(async_action::AsyncAction::print_non_map)), b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(0) })); // Store print id auto found_id = bpftrace_.resources.non_map_print_args_id_map.find(&call); if (found_id == bpftrace_.resources.non_map_print_args_id_map.end()) { LOG(BUG) << "No id found for non_map_print call"; } b_.CreateStore( b_.getInt64(found_id->second), b_.CreateGEP(print_struct, buf, { b_.getInt64(0), b_.getInt32(1) })); // Store content Value *content_offset = b_.CreateGEP(print_struct, buf, { b_.getInt32(0), b_.getInt32(2) }); b_.CreateMemsetBPF(content_offset, b_.getInt8(0), type_map_.type(arg).GetSize()); if (needMemcpy(type_map_.type(arg))) { if (type_map_.type(arg).IsInBpfMemory()) b_.CreateMemcpyBPF(content_offset, value, type_map_.type(arg).GetSize()); else b_.CreateProbeRead(content_offset, type_map_.type(arg), value, call.loc); } else { b_.CreateStore(value, content_offset); } b_.CreateOutput(buf, struct_size, call.loc); if (dyn_cast(buf)) b_.CreateLifetimeEnd(buf); } void CodegenLLVM::createMapDefinition(const std::string &name, bpf_map_type map_type, uint64_t max_entries, const SizedType &key_type, const SizedType &value_type) { DIType *di_key_type = debug_.GetMapKeyType(key_type, value_type, map_type); map_types_.emplace(name, map_type); auto var_name = bpf_map_name(name); auto *debuginfo = debug_.createMapEntry( var_name, map_type, max_entries, di_key_type, value_type); // It's sufficient that the global variable has the correct size (struct // with one pointer per field). The actual inner types are defined in debug // info. SmallVector elems = { b_.getPtrTy(), b_.getPtrTy() }; if (!value_type.IsNoneTy()) { elems.push_back(b_.getPtrTy()); elems.push_back(b_.getPtrTy()); } auto *type = StructType::create(elems, "struct map_internal_repr_t", false); auto *var = llvm::dyn_cast( module_->getOrInsertGlobal(var_name, type)); var->setInitializer(ConstantAggregateZero::get(type)); var->setSection(".maps"); var->setDSOLocal(true); var->addDebugInfo(debuginfo); } // Emit maps in libbpf format so that Clang can create BTF info for them which // can be read and used by libbpf. // // Each map should be defined by a global variable of a struct type with the // following fields: // - "type" map type (e.g. BPF_MAP_TYPE_HASH) // - "max_entries" maximum number of entries // - "key" key type // - "value" value type // // "type" and "max_entries" are integers but they must be represented as // pointers to an array of ints whose dimension defines the specified value. // // "key" and "value" are pointers to the corresponding types. Note that these // are not used for the BPF_MAP_TYPE_RINGBUF map type. // // The most important part is to generate BTF with the above information. This // is done by emitting DWARF which LLVM will convert into BTF. The LLVM type // of the global variable itself is not important, it can simply be a struct // with 4 pointers. // // Note that LLVM will generate BTF which misses some information. This is // normally set by libbpf's linker but since we load BTF directly, we must do // the fixing ourselves, until we start loading BPF programs via bpf_object. // See BpfBytecode::fixupBTF for details. void CodegenLLVM::generate_maps(const RequiredResources &required_resources) { // User-defined maps for (const auto &[name, info] : required_resources.maps_info) { const auto &val_type = info.value_type; const auto &key_type = info.key_type; createMapDefinition( name, info.bpf_type, info.max_entries, key_type, val_type); } // bpftrace internal maps if (required_resources.needs_elapsed_map) { createMapDefinition(to_string(MapType::Elapsed), BPF_MAP_TYPE_HASH, 1, CreateUInt64(), CreateUInt64()); } if (bpftrace_.need_recursion_check_) { createMapDefinition(to_string(MapType::RecursionPrevention), BPF_MAP_TYPE_PERCPU_ARRAY, 1, CreateUInt32(), CreateUInt64()); } if (required_resources.using_skboutput) { createMapDefinition(to_string(MapType::PerfEvent), BPF_MAP_TYPE_PERF_EVENT_ARRAY, util::get_online_cpus().size(), CreateInt32(), CreateInt32()); } auto num_pages = bpftrace_.get_buffer_pages(); // The default value exists just to prevent a segfault. // The program should terminate as we're adding an error to the ast root auto buffer_size = sysconf(_SC_PAGE_SIZE); if (!num_pages) { LOG(ERROR) << num_pages.takeError(); ast_.root->addError() << "Unable to get the number of ring buffer pages dynamically. " "You must set the `perf_rb_pages` config manually e.g. `config = " "{ " "perf_rb_pages=64 }`"; } else { buffer_size = *num_pages * sysconf(_SC_PAGE_SIZE); } createMapDefinition(to_string(MapType::Ringbuf), BPF_MAP_TYPE_RINGBUF, buffer_size, CreateNone(), CreateNone()); } void CodegenLLVM::generate_global_vars( const RequiredResources &resources, const ::bpftrace::Config &bpftrace_config) { for (const auto &[name, config] : resources.global_vars.global_var_map()) { auto sized_type = resources.global_vars.get_sized_type(name, resources, bpftrace_config); auto *var = llvm::dyn_cast( module_->getOrInsertGlobal(name, b_.GetType(sized_type))); var->setInitializer(Constant::getNullValue(b_.GetType(sized_type))); var->setConstant(config.section == globalvars::RO_SECTION_NAME); var->setSection(config.section); var->setExternallyInitialized(true); var->setDSOLocal(true); var->addDebugInfo(debug_.createGlobalVariable(name, sized_type)); } } // Read a single element from a compound data structure (i.e. an array or // a struct) that has been pulled onto BPF stack. // Params: // src_data pointer to the entire data structure // index index of the field to read // data_type type of the structure // elem_type type of the element // scoped_del scope deleter for the data structure ScopedExpr CodegenLLVM::readDatastructElemFromStack(ScopedExpr &&scoped_src, Value *index, llvm::Type *data_type, const SizedType &elem_type) { // src_data should contain a pointer to the data structure, but it may be // internally represented as an integer and then we need to cast it Value *src_data = scoped_src.value(); if (src_data->getType()->isIntegerTy()) src_data = b_.CreateIntToPtr(src_data, b_.getPtrTy()); Value *src = b_.CreateGEP(data_type, src_data, { b_.getInt32(0), index }); if (elem_type.IsIntegerTy() || elem_type.IsPtrTy() || elem_type.IsBoolTy()) { // Load the correct type from src return ScopedExpr(b_.CreateDatastructElemLoad(elem_type, src)); } else { // The inner type is an aggregate - instead of copying it, just pass // the pointer and extend lifetime of the source data. return ScopedExpr(src, std::move(scoped_src)); } } ScopedExpr CodegenLLVM::readDatastructElemFromStack(ScopedExpr &&scoped_src, Value *index, const SizedType &data_type, const SizedType &elem_type) { return readDatastructElemFromStack( std::move(scoped_src), index, b_.GetType(data_type), elem_type); } // Read a single element from a compound data structure (i.e. an array or // a struct) that has not been yet pulled into BPF memory. // Params: // scoped_src scoped expression pointing to the data structure // offset offset of the requested element from the structure beginning // data_type type of the data structure // elem_type type of the requested element // loc location of the element access (for proberead) // temp_name name of a temporary variable, if the function creates any ScopedExpr CodegenLLVM::probereadDatastructElem(ScopedExpr &&scoped_src, Value *offset, const SizedType &data_type, const SizedType &elem_type, const Location &loc, const std::string &temp_name) { // We treat this access as a raw byte offset, but may then subsequently need // to cast the pointer to the expected value. Value *src = b_.CreateSafeGEP(b_.getInt8Ty(), scoped_src.value(), offset); if (elem_type.IsCTypeTy() || elem_type.IsArrayTy()) { // For nested arrays, structs, unions, typedefs just pass the pointer along // and dereference it later when necessary. We just need to extend lifetime // of the source pointer. return ScopedExpr(src, std::move(scoped_src)); } else if (elem_type.IsStringTy() || elem_type.IsBufferTy()) { AllocaInst *dst = b_.CreateAllocaBPF(elem_type, temp_name); if (elem_type.IsStringTy() && data_type.IsInBpfMemory()) { if (src->getType()->isIntegerTy()) src = b_.CreateIntToPtr(src, dst->getType()); b_.CreateMemcpyBPF(dst, src, elem_type.GetSize()); } else { b_.CreateProbeRead(dst, elem_type, src, loc, data_type.GetAS()); } // dst is left as is, so we need to return and bound its lifetime to the // underlying expression. Since we've finished copying, we can end the // lifetime of the `scoped_src` argument. return ScopedExpr(dst, [this, dst]() { b_.CreateLifetimeEnd(dst); }); } else { // Read data onto stack if (data_type.IsCtxAccess()) { // Types have already been suitably casted; just do the access. Value *expr = b_.CreateDatastructElemLoad(elem_type, src); // check context access for iter probes (required by kernel) if (data_type.IsCtxAccess() && probetype(current_attach_point_->provider) == ProbeType::iter) { llvm::Function *parent = b_.GetInsertBlock()->getParent(); BasicBlock *pred_false_block = BasicBlock::Create(module_->getContext(), "pred_false", parent); BasicBlock *pred_true_block = BasicBlock::Create(module_->getContext(), "pred_true", parent); Value *cmp = b_.CreateICmpEQ( expr, Constant::getNullValue(b_.GetType(elem_type)), "predcond"); b_.CreateCondBr(cmp, pred_false_block, pred_true_block); b_.SetInsertPoint(pred_false_block); createRet(); b_.SetInsertPoint(pred_true_block); } // Everything should be loaded by this point, so we can drop the // lifetime of `scoped_src`. return ScopedExpr(expr); } else { AllocaInst *dst = b_.CreateAllocaBPF(elem_type, temp_name); b_.CreateProbeRead(dst, elem_type, src, loc, data_type.GetAS()); Value *expr = b_.CreateLoad(b_.GetType(elem_type), dst); // We have completely loaded from dst, and therefore can insert an end // to its lifetime directly. b_.CreateLifetimeEnd(dst); return ScopedExpr(expr); } } } ScopedExpr CodegenLLVM::createIncDec(Unop &unop) { bool is_increment = (unop.op == Operator::PRE_INCREMENT || unop.op == Operator::POST_INCREMENT); bool is_post = (unop.op == Operator::POST_INCREMENT || unop.op == Operator::POST_DECREMENT); const SizedType &type = type_map_.type(unop.expr); uint64_t step = type.IsPtrTy() ? type.GetPointeeTy().GetSize() : 1; if (auto *acc = unop.expr.as()) { auto &map = *acc->map; auto scoped_key = getMapKey(map, acc->key); Value *oldval = b_.CreateMapLookupElem(map.ident, scoped_key.value(), type_map_.map_value_type(map.ident), unop.loc); AllocaInst *newval = b_.CreateAllocaBPF(type_map_.map_value_type(map.ident), map.ident + "_newval"); if (type.IsPtrTy()) { b_.CreateStore( b_.CreateGEP(b_.GetType( type_map_.map_value_type(map.ident).GetPointeeTy()), oldval, is_increment ? b_.getInt32(1) : b_.getInt32(-1)), newval); } else { if (is_increment) b_.CreateStore(b_.CreateAdd(oldval, b_.GetIntSameSize(step, oldval)), newval); else b_.CreateStore(b_.CreateSub(oldval, b_.GetIntSameSize(step, oldval)), newval); } b_.CreateMapUpdateElem(map.ident, scoped_key.value(), newval, unop.loc); Value *value; if (is_post) { value = oldval; } else { value = b_.CreateLoad(b_.GetType(type_map_.map_value_type(map.ident)), newval); } b_.CreateLifetimeEnd(newval); return ScopedExpr(value); } else if (auto *var = unop.expr.as()) { const auto &variable = getVariable(var->ident); Value *oldval = b_.CreateLoad(variable.type, variable.value); Value *newval; if (type.IsPtrTy()) { newval = b_.CreateGEP(b_.GetType(type.GetPointeeTy()), oldval, is_increment ? b_.getInt32(1) : b_.getInt32(-1)); } else { if (is_increment) newval = b_.CreateAdd(oldval, b_.GetIntSameSize(step, oldval)); else newval = b_.CreateSub(oldval, b_.GetIntSameSize(step, oldval)); } b_.CreateStore(newval, variable.value); if (is_post) { return ScopedExpr(oldval); } else { return ScopedExpr(newval); } } else { LOG(BUG) << "invalid expression passed to " << opstr(unop); __builtin_unreachable(); } } std::pair CodegenLLVM::createForContext( For &f, std::vector &&extra_fields) { const auto &ctx_fields = type_map_.type(&f).GetFields(); std::vector ctx_field_types(ctx_fields.size(), b_.getPtrTy()); // Add all the extra fields. std::ranges::move(extra_fields, std::back_inserter(ctx_field_types)); // Pack pointers to variables into context struct for use in the callback. // If there are no fields, then the underlying codegen helper will simply // pass null as the context value. We should not allocate an empty struct. llvm::Type *ctx_t = nullptr; Value *ctx = nullptr; if (!ctx_field_types.empty()) { ctx_t = StructType::create(ctx_field_types, "ctx_t"); ctx = b_.CreateAllocaBPF(ctx_t, "ctx"); for (size_t i = 0; i < ctx_fields.size(); i++) { const auto &field = ctx_fields[i]; auto *field_expr = getVariable(field.name).value; auto *ctx_field_ptr = b_.CreateSafeGEP( ctx_t, ctx, { b_.getInt64(0), b_.getInt32(i) }, "ctx." + field.name); b_.CreateStore(field_expr, ctx_field_ptr); } } return { ctx_t, ctx }; } llvm::Function *CodegenLLVM::createForCallback( For &f, const std::string &name, ArrayRef args, const Struct &debug_args, llvm::Type *ctx_t, std::function decl) { auto saved_ip = b_.saveIP(); auto *saved_scope = scope_; // All callbacks in BPF will be generated with a standard integer return. FunctionType *callback_type = FunctionType::get(b_.getInt64Ty(), args, false); auto *callback = llvm::Function::Create( callback_type, llvm::Function::LinkageTypes::InternalLinkage, name, module_.get()); callback->setDSOLocal(true); callback->setVisibility(llvm::GlobalValue::DefaultVisibility); callback->setSection(".text"); callback->addFnAttr(Attribute::NoUnwind); // Add the debug information. scope_ = debug_.createFunctionDebugInfo(*callback, CreateInt64(), debug_args); // Start our basic function block. auto *for_body = BasicBlock::Create(module_->getContext(), "for_body", callback); BasicBlock *for_continue = nullptr; auto lazy_continue = [&] { if (for_continue) { return for_continue; } auto saved_ip = b_.saveIP(); for_continue = BasicBlock::Create(module_->getContext(), "for_continue", callback); b_.restoreIP(saved_ip); return for_continue; }; BasicBlock *for_break = nullptr; auto lazy_break = [&] { if (for_break) { return for_break; } auto saved_ip = b_.saveIP(); for_break = BasicBlock::Create(module_->getContext(), "for_break", callback); b_.restoreIP(saved_ip); return for_break; }; b_.SetInsertPoint(for_body); // Extract our context type and value. As noted, this requires that some // member of `debug_args` is named `ctx`. size_t ctx_index = 0; while (ctx_index < debug_args.fields.size()) { if (debug_args.fields[ctx_index].name == "ctx") { break; } ctx_index++; } assert(ctx_index < debug_args.fields.size()); llvm::Value *ctx = callback->getArg(ctx_index); // Generate the variable declaration. variables_[scope_stack_.back()][f.decl->ident] = VariableLLVM{ .value = decl(callback), .type = b_.GetType(type_map_.type(f.decl)) }; // 1. Save original locations of variables which will form part of the // callback context // 2. Replace variable expressions with those from the context const auto &ctx_fields = type_map_.type(&f).GetFields(); std::unordered_map orig_ctx_vars; for (size_t i = 0; i < ctx_fields.size(); i++) { const auto &field = ctx_fields[i]; orig_ctx_vars[field.name] = getVariable(field.name).value; auto *ctx_field_ptr = b_.CreateGEP( ctx_t, ctx, { b_.getInt64(0), b_.getInt32(i) }, "ctx." + field.name); getVariable(field.name).value = b_.CreateLoad(b_.getPtrTy(), ctx_field_ptr, field.name); } // Generate code for the loop body. loops_.emplace_back(lazy_continue, lazy_break); visit(f.block); loops_.pop_back(); if (for_continue != nullptr) { b_.SetInsertPoint(for_continue); b_.CreateRet(b_.getInt64(0)); } if (for_break != nullptr) { b_.SetInsertPoint(for_break); b_.CreateRet(b_.getInt64(1)); } // Restore original non-context variables. for (const auto &[ident, expr] : orig_ctx_vars) { getVariable(ident).value = expr; } // Decl variable is not valid beyond this for loop. variables_[scope_stack_.back()].erase(f.decl->ident); b_.restoreIP(saved_ip); scope_ = saved_scope; return callback; } ScopedExpr CodegenLLVM::visit(For &f, Range &range) { // Evaluate our starting and endpoint values. auto start = visit(range.start); auto end = visit(range.end); Value *iters = b_.CreateBinOp(Instruction::Sub, end.value(), start.value()); // Get the actual loop variable type from type checker const auto &decl_type = type_map_.type(f.decl); llvm::Type *loop_var_type = b_.GetType(decl_type); // Construct the context and callback with extra fields add to the context, // which track the starting value and the current value of the iteration. auto [ctx_t, ctx] = createForContext(f, { loop_var_type, loop_var_type }); const auto sz = type_map_.type(&f).GetFields().size(); b_.CreateStore(start.value(), b_.CreateSafeGEP(ctx_t, ctx, { b_.getInt64(0), b_.getInt32(sz) }, "ctx.start")); // Create a callback function suitable for passing to bpf_loop, for the // form: // // static int cb(uint64_t index, void *ctx) // { // $x = index+prefix; // [stmts...] // } std::array args = { b_.getInt64Ty(), b_.getPtrTy() }; Struct debug_args; debug_args.AddField("index", CreateInt64()); debug_args.AddField("ctx", CreatePointer(CreateInt8())); auto *cb = createForCallback( f, "loop_cb", args, debug_args, ctx_t, [&](llvm::Function *callback) { // See above. Prior to the callback, we push the starting value into // the context as an extra field, and reserve space for the current // value there. This must be set on each iteration, and provides a // declaration that points there. auto *ctx = callback->getArg(1); auto *start_field_ptr = b_.CreateSafeGEP( // NOLINTNEXTLINE(modernize-type-traits): false positive on var ctx_t, ctx, { b_.getInt64(0), b_.getInt32(sz) }, "start"); auto *current_field_ptr = b_.CreateSafeGEP( ctx_t, ctx, { b_.getInt64(0), b_.getInt32(sz + 1) }, "current"); // Add the current iteration count to our starting count, reseting the // value of the current variable in the context. The starting value is // not available to the user, simply the value of the current // iteration. b_.CreateStore(b_.CreateAdd(b_.CreateLoad(loop_var_type, start_field_ptr), b_.CreateIntCast(callback->getArg(0), loop_var_type, true)), current_field_ptr); return current_field_ptr; }); // Execute the loop. b_.CreateForRange(iters, cb, ctx, f.loc); return ScopedExpr(); } ScopedExpr CodegenLLVM::visit(For &f, Map &map) { // Construct our context types. auto [ctx_t, ctx] = createForContext(f); // Create a callback function suitable for passing to bpf_for_each_map_elem, // of the form: // // static int cb(struct map *map, void *key, void *value, void *ctx) // { // $decl = (key, value); // [stmts...] // } std::array args = { b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy() }; Struct debug_args; debug_args.AddField("map", CreatePointer(CreateInt8())); debug_args.AddField("key", CreatePointer(CreateInt8())); debug_args.AddField("value", CreatePointer(CreateInt8())); debug_args.AddField("ctx", CreatePointer(CreateInt8())); const std::string name = "map_for_each_cb"; auto *cb = createForCallback( f, name, args, debug_args, ctx_t, [&](llvm::Function *callback) { auto &key_type = type_map_.type(f.decl).GetField(0).type; Value *key = callback->getArg(1); if (!key_type.IsInBpfMemory()) { key = b_.CreateLoad(b_.GetType(key_type), key, "key"); } auto map_info = bpftrace_.resources.maps_info.find(map.ident); if (map_info == bpftrace_.resources.maps_info.end()) { LOG(BUG) << "map name: \"" << map.ident << "\" not found"; } auto &val_type = type_map_.type(f.decl).GetField(1).type; Value *val = callback->getArg(2); const auto &map_val_type = map_info->second.value_type; if (canAggPerCpuMapElems(map_info->second.bpf_type, map_val_type)) { val = b_.CreatePerCpuMapAggElems( map, callback->getArg(1), map_val_type, f.loc); } else if (!val_type.IsInBpfMemory()) { val = b_.CreateLoad(b_.GetType(val_type), val, "val"); } return createAnonStruct(type_map_.type(f.decl), { { key, key_type, f.decl->loc }, { val, val_type, f.decl->loc } }, f.decl->ident, f.decl->loc); }); // Invoke via the helper. b_.CreateForEachMapElem(map, cb, ctx, f.loc); return ScopedExpr(); } bool CodegenLLVM::canAggPerCpuMapElems(const bpf_map_type map_type, const SizedType &val_type) { return val_type.IsCastableMapTy() && map_type == BPF_MAP_TYPE_PERCPU_HASH; } // BPF helpers that use fmt strings (bpf_trace_printk, bpf_seq_printf) expect // the string passed in a data map. libbpf is able to create the map // internally if an internal global constant string is used. This function // creates the constant. Uses bpf_print_id_ to pick the correct format string // from RequiredResources. Value *CodegenLLVM::createFmtString(int print_id) { const auto &s = bpftrace_.resources.bpf_print_fmts.at(print_id).str(); auto *res = llvm::dyn_cast( module_->getOrInsertGlobal("__fmt_" + std::to_string(print_id), ArrayType::get(b_.getInt8Ty(), s.size() + 1))); res->setConstant(true); res->setInitializer(ConstantDataArray::getString(module_->getContext(), s)); res->setAlignment(MaybeAlign(1)); res->setLinkage(llvm::GlobalValue::InternalLinkage); return res; } ScopedExpr CodegenLLVM::createExternFuncCall( const std::string &name, llvm::Type *return_type, llvm::ArrayRef arg_types, llvm::ArrayRef arg_values, const Location &loc) { auto *func = extern_funcs_[name]; if (!func) { FunctionType *function_type = FunctionType::get(return_type, arg_types, false); func = llvm::Function::Create( function_type, llvm::Function::ExternalLinkage, name, module_.get()); func->addFnAttr(Attribute::AlwaysInline); func->addFnAttr(Attribute::NoUnwind); func->setDSOLocal(true); // Add noundef attribute to each argument. for (auto &arg : func->args()) { arg.addAttr(Attribute::NoUndef); } extern_funcs_[name] = func; } auto *inst = b_.CreateCall(func, arg_values, name); inst->setDebugLoc(debug_.createDebugLocation(llvm_ctx_, scope_, loc)); return ScopedExpr(inst); } /// This should emit /// /// declare !dbg !... extern ... @var_name(...) section ".ksyms" /// /// with proper debug info entry. /// /// The function type is retrieved from kernel BTF. /// /// If the function declaration is already in the module, just return it. /// GlobalVariable *CodegenLLVM::DeclareKernelVar(const std::string &var_name) { if (auto *sym = module_->getGlobalVariable(var_name)) return sym; std::string err; auto type = bpftrace_.btf_->get_var_type(var_name); assert(!type.IsNoneTy()); // already checked in an earlier pass auto *var = llvm::dyn_cast( module_->getOrInsertGlobal(var_name, b_.GetType(type))); var->setSection(".ksyms"); var->setLinkage(llvm::GlobalValue::ExternalLinkage); auto *var_debug = debug_.createGlobalVariable(var_name, type); var->addDebugInfo(var_debug); return var; } std::unique_ptr CodegenLLVM::compile() { generate_maps(bpftrace_.resources); generate_global_vars(bpftrace_.resources, *bpftrace_.config_); { visit(ast_.root); } debug_.finalize(); return std::move(module_); } Pass CreateLLVMInitPass() { LLVMInitializeBPFTargetInfo(); LLVMInitializeBPFTarget(); LLVMInitializeBPFTargetMC(); LLVMInitializeBPFAsmPrinter(); return Pass::create("llvm-init", [] { return CompileContext(); }); } Pass CreateCompilePass() { return Pass::create("compile", [](ASTContext &ast, [[maybe_unused]] ControlFlowChecked &control_flow, BPFtrace &bpftrace, CDefinitions &c_definitions, NamedParamInfo &named_param_info, CompileContext &ctx, ExpansionResult &expansions, TypeMap &type_map) mutable { CodegenLLVM llvm(ast, bpftrace, c_definitions, named_param_info, *ctx.context, expansions, type_map); return CompiledModule(llvm.compile()); }); } Pass CreateLinkBitcodePass() { return Pass::create( "LinkBitcode", [](BitcodeModules &bm, CompiledModule &cm) -> Result<> { for (auto &result : bm.modules) { if (!result.module) { continue; } // Make a copy of the module, to ensure this is not modifying the // original. The link step must consume the module below. auto copy = llvm::CloneModule(*result.module); // Modify to ensure everything is inlined. Note that this is also // marking all these functions for below, which will adjust their // linkage. // // We also want to ensure that we remove any attributes that prevent // any subsequent inline (such as "OptimizeNone"), and suitably tag // these functions are "NoUnwind", like the rest. There is no // unwinding in BPF, and these attributes are just ensuring that. for (auto &fn : copy->functions()) { if (fn.isDSOLocal() && !fn.isIntrinsic()) { fn.removeFnAttr(Attribute::NoInline); fn.removeFnAttr(Attribute::OptimizeNone); fn.addFnAttr(Attribute::AlwaysInline); fn.addFnAttr(Attribute::NoUnwind); } } // Link into the original source module, consume the new one. This // function returns `false` on success. Hopefully this path is // unlikely to cause errors, since it seems the information // available is sparse. auto err = Linker::linkModules(*cm.module, std::move(copy), Linker::LinkOnlyNeeded); if (err) { return make_error("error during LLVM linking", EINVAL); } } return OK(); }); } Pass CreateVerifyPass() { return Pass::create("verify", [](CompiledModule &cm) -> Result<> { std::stringstream ss; raw_os_ostream OS(ss); bool ret = llvm::verifyModule(*cm.module, &OS); OS.flush(); if (ret) { return make_error( "LLVM verification failed (--verify-llvm-ir)\n" + ss.str(), 0); } return OK(); }); } Pass CreateOptimizePass() { return Pass::create("optimize", [](CompiledModule &cm) { PipelineTuningOptions pto; pto.LoopUnrolling = false; pto.LoopInterleaving = false; pto.LoopVectorization = false; pto.SLPVectorization = false; llvm::PassBuilder pb(getTargetMachine(), pto); // ModuleAnalysisManager must be destroyed first. llvm::LoopAnalysisManager lam; llvm::FunctionAnalysisManager fam; llvm::CGSCCAnalysisManager cgam; llvm::ModuleAnalysisManager mam; // Register all the basic analyses with the managers. pb.registerModuleAnalyses(mam); pb.registerCGSCCAnalyses(cgam); pb.registerFunctionAnalyses(fam); pb.registerLoopAnalyses(lam); pb.crossRegisterProxies(lam, fam, cgam, mam); ModulePassManager mpm = pb.buildPerModuleDefaultPipeline( llvm::OptimizationLevel::O3); mpm.addPass(llvm::StripDeadDebugInfoPass()); mpm.run(*cm.module, mam); }); } Pass CreateDumpIRPass(std::ostream &out) { return Pass::create("dump-ir", [&out](CompiledModule &cm) { raw_os_ostream os(out); cm.module->print(os, nullptr, false, true); os.flush(); out.flush(); }); } Pass CreateObjectPass() { return Pass::create("object", [](CompiledModule &cm) { SmallVector output; raw_svector_ostream os(output); legacy::PassManager PM; auto type = CodeGenFileType::ObjectFile; if (getTargetMachine()->addPassesToEmitFile(PM, os, nullptr, type)) LOG(BUG) << "Cannot emit a file of this type"; PM.run(*cm.module); return BpfObject(output); }); } Pass CreateDumpASMPass([[maybe_unused]] std::ostream &out) { return Pass::create("dump-asm", [](BpfObject &bpf) { // Technically we could use LLVM APIs to do a proper disassemble on // the in-memory ELF file. But that is quite complex, as LLVM only // provides fairly low level APIs to do this. // // Since disassembly is a debugging tool, just shell out to llvm-objdump // to keep things simple. std::cout << "\nDisassembled bytecode\n"; std::cout << "---------------------------\n"; FILE *objdump = ::popen("llvm-objdump -d -", "w"); if (!objdump) { LOG(ERROR) << "Failed to spawn llvm-objdump: " << strerror(errno); return; } if (::fwrite(bpf.data.data(), sizeof(char), bpf.data.size(), objdump) != bpf.data.size()) { LOG(ERROR) << "Failed to write ELF to llvm-objdump"; return; } if (auto rc = ::pclose(objdump)) { LOG(WARNING) << "llvm-objdump did not exit cleanly: status " << rc; } }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/codegen_llvm.h000066400000000000000000000045361526721631600210730ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include "ast/pass_manager.h" #include "ast/passes/link.h" namespace bpftrace::ast { class CompileContext : public ast::State<"compile-context"> { public: CompileContext() : context(std::make_unique()) {}; std::unique_ptr context; }; // LLVMInit will create the required LLVM context which can be subsequently // shared by other passes. This should always be added, unless an external // `LLVMContext` is injected into the pass ahead of time. Pass CreateLLVMInitPass(); class CompiledModule : public ast::State<"compiled-module"> { public: CompiledModule(std::unique_ptr module) : module(std::move(module)) {}; std::unique_ptr module; }; // Compiles the primary AST, and emits `CompiledModule`. Pass CreateCompilePass(); // Links any external bitcode into the module. This must follow the compile // pass, and should proceed any verification, optimization or external linking. Pass CreateLinkBitcodePass(); // Dumps `CompiledModule` to the given stream. Pass CreateDumpIRPass(std::ostream &out); // Validates `CompiledModule`, and attaches an error diagnostic to the program // itself if verification fails. Pass CreateVerifyPass(); // In-place optimizes the `CompiledModule` emitted by the compile pass. Pass CreateOptimizePass(); class BpfObject : public ast::State<"bpf-object"> { public: BpfObject(std::span data) : data(data.begin(), data.end()) {}; std::vector data; }; // Produces the ELF data for the BPF bytecode as a `BpfObject`. This is // required by the Link pass below. Pass CreateObjectPass(); // Dumps `BpfObject` as disassembled bytecode. Pass CreateDumpASMPass(std::ostream &out); // AllCompilePasses returns a vector of passes representing all compile passes, // in the expected order. inline std::vector AllCompilePasses() { std::vector passes; passes.emplace_back(CreateCompilePass()); passes.emplace_back(CreateLinkBitcodePass()); passes.emplace_back(CreateVerifyPass()); passes.emplace_back(CreateOptimizePass()); passes.emplace_back(CreateObjectPass()); passes.emplace_back(CreateExternObjectPass()); passes.emplace_back(CreateLinkPass()); return passes; } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/collect_nodes.h000066400000000000000000000017121526721631600212430ustar00rootroot00000000000000#pragma once #include #include #include "ast/visitor.h" namespace bpftrace::ast { // CollectNodes // // Recurses into the provided node and builds a list of all descendants of the // requested type which match a predicate. template class CollectNodes : public Visitor> { public: explicit CollectNodes() : pred_([](const auto &) { return true; }) { } const std::vector> &nodes() const { return nodes_; } using Visitor>::visit; void visit(NodeT &node) { if (pred_(node)) { nodes_.push_back(node); } Visitor>::visit(node); } template void visit(T &node, std::function pred) { pred_ = pred; visit(node); } private: std::vector> nodes_; std::function pred_; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/config_analyser.cpp000066400000000000000000000037401526721631600221270ustar00rootroot00000000000000#include #include #include "ast/ast.h" #include "ast/passes/config_analyser.h" #include "ast/visitor.h" #include "bpftrace.h" #include "config.h" namespace bpftrace::ast { namespace { class ConfigAnalyser : public Visitor { public: explicit ConfigAnalyser(BPFtrace &bpftrace) : bpftrace_(bpftrace) {}; using Visitor::visit; void visit(AssignConfigVarStatement &assignment); private: BPFtrace &bpftrace_; }; } // namespace void ConfigAnalyser::visit(AssignConfigVarStatement &assignment) { // If this is deprecated, just emit a warning and move on. This is done here // because they are no longer understood by the actual config type. if (DEPRECATED_CONFIGS.contains(assignment.var)) { assignment.addWarning() << assignment.var << " is deprecated and has no effect"; return; } std::string var(assignment.var); while (true) { // Set the variable. auto ok = std::visit( [&](const auto &v) { return bpftrace_.config_->set(var, v); }, assignment.value); // Attempt to handle a rename error, and find the new name. This is done // here rather than the config so that we can emit a suitable error. if (!ok) { ok = handleErrors(std::move(ok), [&](const RenameError &e) { var = e.new_name(); }); if (!ok) { assignment.addError() << ok.takeError(); return; } continue; } break; // All set. } if (var != assignment.var) { assignment.addWarning() << assignment.var << " has been renamed, please use " << var; } } Pass CreateConfigPass() { auto fn = [](ASTContext &ast, BPFtrace &b) -> Result { auto configs = ConfigAnalyser(b); configs.visit(ast.root); // Reload any environment changes. auto ok = b.config_->load_environment(); if (!ok) { return ok.takeError(); } return OK(); }; return Pass::create("ConfigAnalyser", fn); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/config_analyser.h000066400000000000000000000001771526721631600215750ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateConfigPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/control_flow_analyser.cpp000066400000000000000000000274061526721631600233760ustar00rootroot00000000000000#include "ast/passes/control_flow_analyser.h" #include "ast/ast.h" #include "ast/context.h" #include "ast/visitor.h" #include "util/type_name.h" namespace bpftrace::ast { namespace { class ExitReturn : public Visitor { public: ExitReturn(ASTContext &ast) : ast_(ast) {}; using Visitor::visit; void visit(Expression &expr); private: ASTContext &ast_; }; template class JumpDisallowed : public Visitor> { public: using Visitor::visit; void visit([[maybe_unused]] Subprog &subprog) { JumpDisallowed<"function", JumpType::BREAK, JumpType::CONTINUE>().visit( subprog.block); } void visit([[maybe_unused]] For &f) { JumpDisallowed<"for-loop", JumpType::RETURN>().visit(f.block); } void visit([[maybe_unused]] While &w) { // If the while is inside a control flow where return is disallowed (e.g. // for) then it continues to be disallowed and vice versa. if constexpr ((... || (Ts == JumpType::RETURN))) { JumpDisallowed<"while-loop", JumpType::RETURN>().visit(w.block); } else { JumpDisallowed<"while-loop">().visit(w.block); } } void visit(Macro ¯o) { JumpDisallowed<"macro", JumpType::BREAK, JumpType::CONTINUE, JumpType::RETURN>() .visit(macro.block); } void visit(Probe &p) { JumpDisallowed<"probe", JumpType::BREAK, JumpType::CONTINUE>().visit( p.block); } void visit(Jump &jump) { if (((jump.ident == Ts) || ...)) jump.addError() << "'" << opstr(jump) << "' " << "statement is not allowed in a " << name.str(); } }; template class ControlFlowAnalyser : public Visitor, bool> { public: ControlFlowAnalyser(ASTContext &ast) : ast_(ast) {}; // Returns true if the visited node terminates in a jump of type Ts..., that // applies to the scope of the first visit. using Visitor::visit; bool visit(Jump &jump) { return ((jump.ident == Ts) || ...); } bool visit(IfExpr &if_expr) { return visit(if_expr.cond) || (visit(if_expr.left) && visit(if_expr.right)); } bool visit(Binop &binop) { return visit(binop.left) || visit(binop.right); } bool visit(ArrayAccess &acc) { return visit(acc.expr) || visit(acc.indexpr); } bool visit(MapAccess &acc) { return visit(acc.key); } bool visit(AssignMapStatement &map_assign) { return visit(map_assign.map_access) || visit(map_assign.expr); } bool visit(BlockExpr &block) { for (size_t i = 0; i < block.stmts.size(); i++) { if (visit(block.stmts[i])) { StatementList dead_code; if (i + 1 < block.stmts.size()) { // Leave a warning on the first unreachable statement. All unreachable // statements are moved into a dead code block so that they can be // used for type inference, but this block will likely be folded away. block.stmts[i + 1].node().addWarning() << "Unreachable statement."; for (size_t j = i + 1; j < block.stmts.size(); j++) { dead_code.emplace_back(block.stmts[j]); } block.stmts.resize(i + 1); } if (!block.expr.is()) { // If there is a non-none expression, then it is not possible // to evaluate this expression. This is also an error. block.expr.node().addWarning() << "Unreachable expression; block type is implicitly none."; // Since the expression is unreachable it just becomes another // statement in the dead code list, and not the block value. dead_code.emplace_back( ast_.make_node(block.expr.node().loc, block.expr)); block.expr = ast_.make_node(block.stmts[i].node().loc); } if (!dead_code.empty()) { // We rewrite the terminating statement to include the dead code in // an empty branch. This is because we need to put it somewhere so // that it can still be used for type inference, but it can't appear // after a block terminator. So we stuff it into a if that contains // the statements and isn't marked comptime. // // For example, the following block: // { // return; // foo() // } // // Becomes: // { // if (true) { // return; // } else { // foo(); // } // } auto original_ret = block.stmts[i]; auto original_loc = original_ret.node().loc; block.stmts.resize(i); auto *cond = ast_.make_node(original_loc, true); auto *ret_block = ast_.make_node( original_loc, StatementList({ original_ret }), ast_.make_node(original_loc)); auto *dead_block = ast_.make_node(original_loc, std::move(dead_code), ast_.make_node( original_loc)); auto *if_expr = ast_.make_node( original_loc, cond, ret_block, dead_block); auto *if_stmt = ast_.make_node(original_loc, if_expr); block.stmts.emplace_back(if_stmt); // The deadcode still needs to have both branches covered. return visit(if_stmt); } return true; } } return visit(block.expr); } bool visit([[maybe_unused]] Subprog &subprog) { // In case we ever allow nested subprograms, these are explicitly // scope-limited, so neither jump affects overall control flow. return false; } bool visit(Unroll &unroll) { return visit(unroll.expr) || visit(unroll.block); } bool viist(Range &range) { return visit(range.start) || visit(range.end); } bool visit([[maybe_unused]] For &f) { // For loops will always terminate, all control flow statements within // the context of the loop apply only to the loop.... except the iterable // itself, which may be a block-expression range. return visit(f.iterable); } bool visit([[maybe_unused]] While &w) { // While loops will *not* always terminate, it is possible to construct // something that looks like this: // // while (true) { // if (true) { // return; // } // } if constexpr ((... || (Ts == JumpType::RETURN))) { return visit(w.cond) || ControlFlowAnalyser(ast_).visit(w.block); } else { return visit(w.cond); } } private: ASTContext &ast_; }; class ControlFlowInjector : public Visitor { public: explicit ControlFlowInjector(ASTContext &ast) : ast_(ast) {}; using Visitor::visit; void visit(Subprog &subprog); void visit(Probe &probe); void visit(Macro ¯o); void visit(For &f); void visit(While &w); private: ASTContext &ast_; }; } // namespace template void inject_jump(ASTContext &ast, Expression &expr) { if (auto *blockexpr = expr.as()) { inject_jump(ast, *blockexpr); } else if (auto *if_expr = expr.as()) { // Because ifs may be folded in the future, we need to inject into both in // the case that one of the branches has the terminator. It is also // possible that one of the branches also has it, so we don't inject there. ControlFlowAnalyser checker(ast); if (!checker.visit(if_expr->left)) { inject_jump(ast, if_expr->left); } if (!checker.visit(if_expr->right)) { inject_jump(ast, if_expr->right); } } else { // If we don't need to inject into an existing block, or a partial branch, // then we can inject a jump simply by converting to a block expression. auto *stmt = ast.make_node(expr.node().loc, expr); auto *ret = ast.make_node(expr.node().loc, T); auto *none = ast.make_node(expr.node().loc); auto *block = ast.make_node(expr.node().loc, StatementList({ stmt, ret }), none); expr.value = block; } } template void inject_jump(ASTContext &ast, BlockExpr &block) { if (block.expr.is()) { // Check the final statement. If this statement is itself a block or if // expression, then we recursively inject a jump into that block. This is // done before those branches may be pruned so we might end up with a // `return; return;` in that case. if (!block.stmts.empty() && block.stmts.back().is()) { inject_jump(ast, block.stmts.back().as()->expr); } else { auto *jump = ast.make_node(block.loc, T); block.stmts.emplace_back(jump); } } else { inject_jump(ast, block.expr); } } void ExitReturn::visit(Expression &expr) { Visitor::visit(expr); // The `exit` call is special and always carries an implicit return following // the call. We inject it automatically. Anything following this will be // labelled as unreachable as per the regular error paths below. // // This also prevents `exit` from appearing anywhere that a naked return is // not allowed (e.g. a macro, etc.) which is a useful feature. if (auto *call = expr.as()) { if (call->func == "exit" && call->vargs.size() <= 1) { inject_jump(ast_, expr); } } } void ControlFlowInjector::visit(Subprog &subprog) { bool has_return = ControlFlowAnalyser(ast_).visit( subprog.block); if (!has_return) { // Always inject a return regardless of the subprog's return type. For // non-void subprogs, a future pass will catch the implicit void return and // report a type mismatch error. inject_jump(ast_, *subprog.block); } // Recurse to check loops, etc. visit(subprog.block); } void ControlFlowInjector::visit(Probe &probe) { // Ensure that we have an implicit return for the probe. if (!ControlFlowAnalyser(ast_).visit(probe.block)) { inject_jump(ast_, *probe.block); } // Check all loops, etc. visit(probe.block); } void ControlFlowInjector::visit(Macro ¯o) { // Macros are already verified not to contain any control flow directly, but // may contain embedded loops, etc. These need to be fixed up to ensure that // every block ends with a control flow statement. visit(macro.block); } void ControlFlowInjector::visit(For &f) { // Visit the loop and record any errors wherein we have // unreachable statements due to a unilateral break/continue. if (!ControlFlowAnalyser(ast_).visit( f.block)) { inject_jump(ast_, *f.block); } // Recurse to check nested loops, etc. visit(f.block); } void ControlFlowInjector::visit(While &w) { // Same as for loops. if (!ControlFlowAnalyser(ast_) .visit(w.block)) { inject_jump( ast_, *w.block); } visit(w.block); } Pass CreateControlFlowPass() { auto fn = [](ASTContext &ast) { ExitReturn(ast).visit(ast.root); JumpDisallowed<"program">().visit(ast.root); ControlFlowInjector r(ast); r.visit(ast.root); return ControlFlowChecked(); }; return Pass::create("ControlFlow", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/control_flow_analyser.h000066400000000000000000000006111526721631600230300ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { // Sentinel value guaranteeing all paths have returns injected. // // All modifications are made directly in the AST, this state may // be used to check that the pass has been completed successfully. class ControlFlowChecked : public State<"control-flow"> {}; Pass CreateControlFlowPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/deprecated.cpp000066400000000000000000000053721526721631600210670ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/passes/deprecated.h" #include "ast/visitor.h" namespace bpftrace::ast { namespace { class DeprecatedAnalyser : public Visitor { public: using Visitor::visit; void visit(Builtin &builtin); void visit(Call &call); void visit(While &while_loop); }; struct DeprecatedName { std::string old_name; std::string new_name; std::string version_deprecated; std::string version_last_available; // True if this name no longer exists - there is no `new_name`. bool deleted; bool matches(const std::string &name) const { // We allow a prefix match to match against builtins with number (argX) if (old_name.back() == '*') { std::string_view old_name_view{ old_name.c_str(), old_name.size() - 1 }; return name.rfind(old_name_view) == 0; } return name == old_name; } }; } // namespace static void check(const std::vector &list, const std::string &ident, Node &node) { for (const auto &item : list) { if (!item.matches(ident)) { continue; } if (item.deleted) { auto &err = node.addError(); err << item.old_name << " is deleted. " << "This was deprecated in " << item.version_deprecated << " and was last available in " << item.version_last_available << "."; err.addHint() << "Use " << item.new_name << " instead."; } else { auto &warn = node.addWarning(); warn << item.old_name << " is deprecated and will be removed in the future."; warn.addHint() << "Use " << item.new_name << " instead."; } } } static std::vector DEPRECATED_BUILTINS = { { .old_name = "sarg*", .new_name = "*(reg(\"sp\") + )", .version_deprecated = "v0.21", .version_last_available = "v0.24", .deleted = true, }, }; void DeprecatedAnalyser::visit(Builtin &builtin) { check(DEPRECATED_BUILTINS, builtin.ident, builtin); } static std::vector DEPRECATED_CALLS = {}; void DeprecatedAnalyser::visit(Call &call) { check(DEPRECATED_CALLS, call.func, call); } void DeprecatedAnalyser::visit(While &while_loop) { auto &warn = while_loop.addWarning(); warn << "While loops are deprecated and may be removed in the future."; auto &hint = warn.addHint(); hint << "For loops support ranges (e.g. `for ($x : $start..$end) { ... }`), " "and can be used in place of while. These are more easily proven to " "be bounded by the verifier."; } Pass CreateDeprecatedPass() { auto fn = [](ASTContext &ast) { DeprecatedAnalyser deprecated; deprecated.visit(ast.root); }; return Pass::create("Deprecated", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/deprecated.h000066400000000000000000000002031526721631600205200ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateDeprecatedPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/field_analyser.cpp000066400000000000000000000161201526721631600217410ustar00rootroot00000000000000#include #include #include "arch/arch.h" #include "ast/passes/ap_probe_expansion.h" #include "ast/passes/field_analyser.h" #include "ast/visitor.h" #include "bpftrace.h" #include "dwarf_parser.h" #include "probe_matcher.h" #include "util/strings.h" namespace bpftrace::ast { namespace { class FieldAnalyser : public Visitor { public: explicit FieldAnalyser(BPFtrace &bpftrace) : bpftrace_(bpftrace) { } using Visitor::visit; void visit(Identifier &identifier); void visit(Builtin &builtin); void visit(Map &map); void visit(Variable &var); void visit(FieldAccess &acc); void visit(ArrayAccess &arr); void visit(MapAccess &acc); void visit(Sizeof &szof); void visit(Offsetof &offof); void visit(Typeof &typeof); void visit(AssignMapStatement &assignment); void visit(AssignVarStatement &assignment); void visit(Unop &unop); void visit(Probe &probe); void visit(Subprog &subprog); void visit(Cast &cast); private: void resolve_fields(SizedType &type); void resolve_type(const ParsedType &type); ProbeType probe_type_; std::string attach_func_; SizedType sized_type_; BPFtrace &bpftrace_; bpf_prog_type prog_type_{ BPF_PROG_TYPE_UNSPEC }; bool has_builtin_args_; Probe *probe_ = nullptr; std::map var_types_; }; } // namespace void FieldAnalyser::visit(Identifier &identifier) { bpftrace_.btf_set_.insert(identifier.ident); } void FieldAnalyser::visit(Builtin &builtin) { std::string builtin_type; sized_type_ = CreateNone(); if (builtin.ident == "ctx") { if (!probe_) return; switch (prog_type_) { case BPF_PROG_TYPE_KPROBE: builtin_type = "struct pt_regs"; break; case BPF_PROG_TYPE_PERF_EVENT: builtin_type = "struct bpf_perf_event_data"; break; default: break; } // For each iterator probe, the context is pointing to specific struct, // make them resolved and available if (probe_type_ == ProbeType::iter) builtin_type = "struct bpf_iter__" + attach_func_; } else if (builtin.ident == "args") { if (!probe_) return; has_builtin_args_ = true; return; } else if (builtin.ident == "__builtin_retval") { if (!probe_) return; const auto *arg = bpftrace_.structs.GetProbeArg(*probe_, RETVAL_FIELD_NAME); if (arg) sized_type_ = arg->type; return; } if (bpftrace_.has_btf_data()) sized_type_ = bpftrace_.btf_->get_stype(builtin_type); } void FieldAnalyser::visit(Map &map) { auto it = var_types_.find(map.ident); if (it != var_types_.end()) sized_type_ = it->second; } void FieldAnalyser::visit(Variable &var) { auto it = var_types_.find(var.ident); if (it != var_types_.end()) sized_type_ = it->second; } void FieldAnalyser::visit(FieldAccess &acc) { has_builtin_args_ = false; visit(acc.expr); // Automatically resolve through pointers. while (sized_type_.IsPtrTy()) { sized_type_ = sized_type_.GetPointeeTy(); resolve_fields(sized_type_); } if (has_builtin_args_) { const auto *arg = bpftrace_.structs.GetProbeArg(*probe_, acc.field); if (arg) sized_type_ = arg->type; has_builtin_args_ = false; } else if (sized_type_.IsCTypeTy()) { SizedType field_type = CreateNone(); if (sized_type_.HasField(acc.field)) field_type = sized_type_.GetField(acc.field).type; if (!field_type.IsNoneTy()) { sized_type_ = field_type; } else if (bpftrace_.has_btf_data()) { // If the struct type or the field type has not been resolved, add the // type to the BTF set to let ClangParser resolve it bpftrace_.btf_set_.insert(sized_type_.GetName()); auto field_type_name = bpftrace_.btf_->type_of(sized_type_.GetName(), acc.field); bpftrace_.btf_set_.insert(field_type_name); } } } void FieldAnalyser::visit(ArrayAccess &arr) { visit(arr.indexpr); visit(arr.expr); if (sized_type_.IsPtrTy()) { sized_type_ = sized_type_.GetPointeeTy(); resolve_fields(sized_type_); } else if (sized_type_.IsArrayTy()) { sized_type_ = sized_type_.GetElementTy(); resolve_fields(sized_type_); } } void FieldAnalyser::visit(MapAccess &acc) { visit(acc.key); visit(acc.map); // Leaves sized_type_ as value type. } void FieldAnalyser::visit(Sizeof &szof) { visit(*szof.type_of); } void FieldAnalyser::visit(Offsetof &offof) { visit(*offof.type_of); } void FieldAnalyser::visit(Typeof &typeof) { if (auto *const *type = std::get_if(&typeof.record)) { resolve_type(**type); } else { visit(typeof.record); } } void FieldAnalyser::visit(AssignMapStatement &assignment) { visit(assignment.map_access); visit(assignment.expr); var_types_.emplace(assignment.map_access->map->ident, sized_type_); } void FieldAnalyser::visit(AssignVarStatement &assignment) { visit(assignment.expr); var_types_.emplace(assignment.var()->ident, sized_type_); } void FieldAnalyser::visit(Unop &unop) { visit(unop.expr); if (unop.op == Operator::MUL && sized_type_.IsPtrTy()) { sized_type_ = sized_type_.GetPointeeTy(); resolve_fields(sized_type_); } } void FieldAnalyser::resolve_fields(SizedType &type) { if (!type.IsCTypeTy()) return; if (probe_) { for (auto &ap : probe_->attach_points) if (Dwarf *dwarf = bpftrace_.get_dwarf(*ap)) dwarf->resolve_fields(type); } if (type.GetFieldCount() == 0 && bpftrace_.has_btf_data()) bpftrace_.btf_->resolve_fields(type); } void FieldAnalyser::resolve_type(const ParsedType &type) { sized_type_ = CreateNone(); const auto &base = type.base_type(); if (base.kind == ParsedType::Kind::Identifier && ident_to_builtin_type(base.name)) return; if (base.kind != ParsedType::Kind::Struct && base.kind != ParsedType::Kind::Union && base.kind != ParsedType::Kind::Identifier) return; const auto name = base.type_name(); if (probe_) { for (auto &ap : probe_->attach_points) if (Dwarf *dwarf = bpftrace_.get_dwarf(*ap)) sized_type_ = dwarf->get_stype(name); } if (sized_type_.IsNoneTy() && bpftrace_.has_btf_data()) sized_type_ = bpftrace_.btf_->get_stype(name); // Could not resolve destination type - let ClangParser do it if (sized_type_.IsNoneTy()) bpftrace_.btf_set_.insert(name); } void FieldAnalyser::visit(Probe &probe) { probe_ = &probe; for (AttachPoint *ap : probe.attach_points) { probe_type_ = probetype(ap->provider); prog_type_ = progtype(probe_type_); attach_func_ = ap->func; } visit(probe.block); } void FieldAnalyser::visit(Subprog &subprog) { probe_ = nullptr; visit(subprog.block); } void FieldAnalyser::visit(Cast &cast) { // N.B. Visit the expression first, so that fields can be resolved, but then // visit the type so that the returned sized_type_ is always the type. visit(cast.expr); visit(cast.typeof); } Pass CreateFieldAnalyserPass() { auto fn = [](ASTContext &ast, BPFtrace &b) { FieldAnalyser analyser(b); analyser.visit(ast.root); }; return Pass::create("FieldAnalyser", fn); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/field_analyser.h000066400000000000000000000002061526721631600214040ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateFieldAnalyserPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/fold_literals.cpp000066400000000000000000000673121526721631600216140ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/passes/fold_literals.h" #include "ast/visitor.h" #include "bpftrace.h" #include "log.h" #include "util/int_parser.h" namespace bpftrace::ast { namespace { const auto FLOW_ERROR = "unable to fold literals due to overflow or underflow"; class LiteralFolder : public Visitor> { public: LiteralFolder(ASTContext &ast) : ast_(ast) {}; LiteralFolder(ASTContext &ast, BPFtrace &bpftrace) : ast_(ast), bpftrace_(std::ref(bpftrace)) {}; using Visitor>::visit; std::optional visit(Unop &op); std::optional visit(Binop &op); std::optional visit(IfExpr &if_expr); std::optional visit(PositionalParameterCount ¶m); std::optional visit(PositionalParameter ¶m); std::optional visit(Call &call); std::optional visit(Expression &expr); std::optional visit(ExprStatement &expr); std::optional visit(Probe &probe); std::optional visit(Builtin &builtin); std::optional visit(BlockExpr &block_expr); std::optional visit(ArrayAccess &acc); std::optional visit(TupleAccess &acc); std::optional visit(FieldAccess &acc); std::optional visit(Comptime &comptime); private: // Return nullopt if we can't compare the expressions now // e.g. they contain variables, which are resolved at runtime std::optional compare_literal_exprs(Expression &l_expr, Expression &r_expr); std::optional compare_tuples(Tuple *left_tuple, Tuple *right_tuple); std::optional compare_records(Record *left_record, Record *right_record); ASTContext &ast_; std::optional> bpftrace_; Node *top_level_node_ = nullptr; }; } // namespace template static Expression make_boolean(ASTContext &ast, T left, T right, Binop &op) { bool value = true; switch (op.op) { case Operator::EQ: value = left == right; break; case Operator::NE: value = left != right; break; case Operator::LE: value = left <= right; break; case Operator::GE: value = left >= right; break; case Operator::LT: value = left < right; break; case Operator::GT: value = left > right; break; case Operator::LAND: value = left && right; break; case Operator::LOR: value = left || right; break; case Operator::PLUS: value = left + right; break; case Operator::MINUS: value = left - right; break; case Operator::MUL: value = left && right; break; case Operator::DIV: { if (!right) { op.addError() << FLOW_ERROR; } value = static_cast(left && right); break; } case Operator::MOD: if (!right) { op.addError() << FLOW_ERROR; } value = false; break; case Operator::BAND: value = left & right; break; case Operator::BOR: value = left | right; break; case Operator::BXOR: value = left ^ right; break; case Operator::LEFT: value = left < right; break; case Operator::RIGHT: value = left > right; break; case Operator::LNOT: case Operator::BNOT: case Operator::ASSIGN: case Operator::PRE_INCREMENT: case Operator::PRE_DECREMENT: case Operator::POST_INCREMENT: case Operator::POST_DECREMENT: LOG(BUG) << "binary operator is not valid: " << static_cast(op.op); } return ast.make_node(op.loc, value); } std::optional LiteralFolder::compare_literal_exprs(Expression &l_expr, Expression &r_expr) { visit(l_expr); visit(r_expr); if (!l_expr.is_literal() || !r_expr.is_literal()) { return std::nullopt; } if (auto *l_int = l_expr.as()) { if (auto *r_int = r_expr.as()) { return l_int->value == r_int->value; } return false; } if (auto *l_nint = l_expr.as()) { if (auto *r_nint = r_expr.as()) { return l_nint->value == r_nint->value; } return false; } if (auto *l_str = l_expr.as()) { if (auto *r_str = r_expr.as()) { return l_str->value == r_str->value; } return false; } if (auto *l_bool = l_expr.as()) { if (auto *r_bool = r_expr.as()) { return l_bool->value == r_bool->value; } return false; } if (auto *l_tuple = l_expr.as()) { if (auto *r_tuple = r_expr.as()) { return compare_tuples(l_tuple, r_tuple); } return false; } if (auto *l_record = l_expr.as()) { if (auto *r_record = r_expr.as()) { return compare_records(l_record, r_record); } return false; } return std::nullopt; } std::optional LiteralFolder::compare_tuples(Tuple *left_tuple, Tuple *right_tuple) { if (left_tuple->elems.size() != right_tuple->elems.size()) { return false; } for (size_t i = 0; i < left_tuple->elems.size(); ++i) { auto l_expr = left_tuple->elems[i]; auto r_expr = right_tuple->elems[i]; auto result = compare_literal_exprs(l_expr, r_expr); if (!result.has_value()) { return std::nullopt; } if (!*result) { return false; } } return true; } std::optional LiteralFolder::compare_records(Record *left_record, Record *right_record) { if (left_record->elems.size() != right_record->elems.size()) { return false; } for (auto *left_elm : left_record->elems) { NamedArgument *right_elem = nullptr; for (auto *elem : right_record->elems) { if (elem->name == left_elm->name) { right_elem = elem; break; } } if (!right_elem) { return std::nullopt; } auto l_expr = left_elm->expr; auto r_expr = right_elem->expr; auto result = compare_literal_exprs(l_expr, r_expr); if (!result.has_value()) { return std::nullopt; } if (!*result) { return false; } } return true; } template static std::optional> eval_binop(T left, T right, Operator op) { auto clamp = [](auto v) -> std::variant { if constexpr (std::is_same_v) { if (v >= 0) { return static_cast(v); } } return v; }; switch (op) { case Operator::PLUS: if (left == 0 || right == 0) { return clamp(left + right); } if (left > 0 && right > 0) { auto res = static_cast(left) + static_cast(right); if (res > static_cast(left) && res > static_cast(right)) { return res; } return std::nullopt; } if constexpr (std::is_same_v) { if ((left > 0 && right < 0) || (left < 0 && right > 0)) { return clamp(left + right); } if (left < 0 && right < 0) { if (std::numeric_limits::min() - left > right) return std::nullopt; return left + right; } } return std::nullopt; case Operator::MINUS: if constexpr (std::is_same_v) { if (left >= right) { return left - right; } else { // Ensure that this is representable during conversion. We know that // right > left, therefore the delta here is guaranteed to be greater // than zero. uint64_t delta = right - left - 1; auto max = static_cast(std::numeric_limits::max()); if (delta > max) { return std::nullopt; } else { return -static_cast(delta) - 1; } } } else { if (right == 0) { return clamp(left); } else { if (left > 0 && right < 0 && std::numeric_limits::max() - left < -right) { return std::nullopt; } else if (left < 0 && right > 0 && std::numeric_limits::min() - left > -right) { return std::nullopt; } return clamp(left - right); } } case Operator::MUL: if (left == 0 || right == 0) { return static_cast(0); } else { if constexpr (std::is_same_v) { // Spill into unsigned. if (left < 0 && right < 0) { return eval_binop(static_cast(-(left + 1)) + 1, static_cast(-(right + 1)) + 1, op); } } auto result = left * right; if (result / left != right) { return std::nullopt; // Overflow. } return clamp(result); } case Operator::DIV: if (right == 0) { return std::nullopt; } return clamp(left / right); case Operator::MOD: if (right == 0) { return std::nullopt; } return clamp(left % right); case Operator::BAND: return clamp(left & right); case Operator::BOR: return clamp(left | right); case Operator::BXOR: return clamp(left ^ right); case Operator::LEFT: // Shifting negative amount of bits or more bits than the width of `left` // (which is always 64 in our case) is undefined behavior in C++ if (right < 0 || right >= 64) return std::nullopt; return clamp(left << right); case Operator::RIGHT: // Same as above if (right < 0 || right >= 64) return std::nullopt; return clamp(left >> right); // Comparison operators are handled in `make_boolean` and checked in // `is_comparison_op`. case Operator::EQ: case Operator::NE: case Operator::LE: case Operator::GE: case Operator::LT: case Operator::GT: case Operator::LAND: case Operator::LOR: case Operator::ASSIGN: case Operator::PRE_INCREMENT: case Operator::PRE_DECREMENT: case Operator::POST_INCREMENT: case Operator::POST_DECREMENT: case Operator::LNOT: case Operator::BNOT: break; } LOG(BUG) << "Unexpected binary operator: " << static_cast(op); __builtin_unreachable(); } std::optional LiteralFolder::visit(Unop &op) { visit(op.expr); if (auto *integer = op.expr.as()) { if (op.op == Operator::BNOT) { // Still positive. return ast_.make_node(op.loc, ~integer->value); } else if (op.op == Operator::LNOT) { return ast_.make_node(op.loc, !integer->value); } else if (op.op == Operator::MINUS) { // Ensure that it is representable as a negative value. if (integer->value > static_cast(std::numeric_limits::max()) + 1) { op.addError() << "negative value will underflow"; return std::nullopt; } // Carefully make the conversion. We need to ensure that this does not // overflow/underflow while doing the math. if (integer->value == 0) { return integer; // Drop the operation. } else if (integer->value <= 1) { return ast_.make_node( op.loc, -static_cast(integer->value)); } else { int64_t value = -1; value -= static_cast(integer->value - 1); return ast_.make_node(op.loc, value); } } } else if (auto *integer = op.expr.as()) { if (op.op == Operator::BNOT) { // Always positive. return ast_.make_node(op.loc, static_cast(~integer->value)); } else if (op.op == Operator::LNOT) { return ast_.make_node(op.loc, !integer->value); } else if (op.op == Operator::MINUS) { // Ensure that it doesn't overflow. We do this by ensuring that is // representable as a positive number, casting, and then adding 1 to // the unsigned form. int64_t value = integer->value + 1; value = -value; return ast_.make_node(op.loc, static_cast(value) + 1); } } else if (auto *boolean = op.expr.as()) { // Just supporting logical not for now but we could support other // operations like BNOT (e.g. ~false == -1) in the future. if (op.op == Operator::LNOT) { return ast_.make_node(op.loc, !boolean->value); } } return std::nullopt; } std::optional LiteralFolder::visit(Binop &op) { visit(op.left); visit(op.right); // Check for string cases. auto *str = op.left.as(); auto other = op.right; if (str == nullptr) { str = op.right.as(); other = op.left; } if (str) { // For whatever reason you are allowed to fold "foo"+3. auto *integer = other.as(); if (op.op == Operator::PLUS && integer) { if (integer->value >= static_cast(str->value.size())) { op.addWarning() << "literal string will always be empty"; return ast_.make_node(op.loc, ""); } return ast_.make_node(op.loc, str->value.substr(integer->value)); } auto *rb = other.as(); if (rb) { if (op.op == Operator::LAND || op.op == Operator::LOR) { return make_boolean(ast_, !str->value.empty(), rb->value, op); } } // Check for another string. auto *rs = other.as(); if (!rs) { // This is a mix of a string and something else. This may be a runtime // type, and we need to leave it up to later type checking. return std::nullopt; } switch (op.op) { case Operator::EQ: return ast_.make_node(op.loc, str->value == rs->value); case Operator::NE: return ast_.make_node(op.loc, str->value != rs->value); case Operator::LE: return ast_.make_node(op.loc, str->value <= rs->value); case Operator::GE: return ast_.make_node(op.loc, str->value >= rs->value); case Operator::LT: return ast_.make_node(op.loc, str->value < rs->value); case Operator::GT: return ast_.make_node(op.loc, str->value > rs->value); case Operator::LAND: return ast_.make_node(op.loc, !str->value.empty() && rs->value.empty()); case Operator::LOR: return ast_.make_node(op.loc, !str->value.empty() || rs->value.empty()); case Operator::PLUS: return ast_.make_node(op.loc, str->value + rs->value); default: // What are they tring to do? op.addError() << "illegal literal operation with strings"; return std::nullopt; } } // Handle boolean cases. auto *boolean = op.left.as(); other = op.right; if (boolean == nullptr) { boolean = op.right.as(); other = op.left; } if (boolean) { auto *other_boolean = other.as(); if (other_boolean) { return make_boolean(ast_, boolean->value, other_boolean->value, op); } auto *ru = other.as(); if (ru) { if (op.op == Operator::LAND || op.op == Operator::LOR) { return make_boolean(ast_, boolean->value, ru->value != 0, op); } } auto *rs = other.as(); if (rs) { if (op.op == Operator::LAND || op.op == Operator::LOR) { // Negatives are always true. return make_boolean(ast_, boolean->value, true, op); } } } if (op.left.is() && op.right.is() && (op.op == Operator::EQ || op.op == Operator::NE)) { auto *left_tuple = op.left.as(); auto *right_tuple = op.right.as(); auto same = compare_tuples(left_tuple, right_tuple); if (same) { return ast_.make_node(op.loc, *same ? op.op == Operator::EQ : op.op == Operator::NE); } else { // Can't compare here return std::nullopt; } } if (op.left.is() && op.right.is() && (op.op == Operator::EQ || op.op == Operator::NE)) { auto *left_record = op.left.as(); auto *right_record = op.right.as(); auto same = compare_records(left_record, right_record); if (same) { return ast_.make_node(op.loc, *same ? op.op == Operator::EQ : op.op == Operator::NE); } else { // Can't compare here return std::nullopt; } } // Handle all integer cases. std::optional> result; auto *lu = op.left.as(); auto *ls = op.left.as(); auto *ru = op.right.as(); auto *rs = op.right.as(); // Only allow operations when we can safely marshall to two of the same type. // Then `eval_binop` effectively handles all overflow/underflow calculations. if (lu && ru) { if (is_comparison_op(op.op)) { return make_boolean(ast_, lu->value, ru->value, op); } result = eval_binop(lu->value, ru->value, op.op); } else if (ls && rs) { if (is_comparison_op(op.op)) { return make_boolean(ast_, ls->value, rs->value, op); } result = eval_binop(ls->value, rs->value, op.op); } else if (lu && rs) { if (lu->value <= std::numeric_limits::max()) { if (is_comparison_op(op.op)) { return make_boolean( ast_, static_cast(lu->value), rs->value, op); } result = eval_binop(static_cast(lu->value), rs->value, op.op); } } else if (ls && ru) { if (ru->value <= std::numeric_limits::max()) { if (is_comparison_op(op.op)) { return make_boolean( ast_, ls->value, static_cast(ru->value), op); } result = eval_binop(ls->value, static_cast(ru->value), op.op); } } else { // This is not an integer expression at all. return std::nullopt; } if (!result) { // This is not a valid expression. op.addError() << FLOW_ERROR; return std::nullopt; } return std::visit( [&](const auto &v) -> Expression { if constexpr (std::is_same_v, uint64_t>) { return ast_.make_node(op.loc, v); } else { return ast_.make_node(op.loc, v); } }, result.value()); } std::optional LiteralFolder::visit(IfExpr &if_expr) { visit(if_expr.left); visit(if_expr.right); if (auto *comptime = if_expr.cond.as()) { visit(comptime->expr); if (comptime->expr.is_literal()) { if (eval_bool(comptime->expr)) { return if_expr.left; } else { return if_expr.right; } } } else { visit(if_expr.cond); if (if_expr.cond.is_literal()) { // If everything is a literal, we can still fold. if (if_expr.left.is_literal() && if_expr.right.is_literal()) { if (eval_bool(if_expr.cond)) { return if_expr.left; } else { return if_expr.right; } } else { // At least simplify the conditional expression. if_expr.cond = ast_.make_node(if_expr.cond.loc(), eval_bool(if_expr.cond)); } } } return std::nullopt; } std::optional LiteralFolder::visit(PositionalParameterCount ¶m) { if (!bpftrace_) { return std::nullopt; } // This is always an unsigned integer value. return ast_.make_node(param.loc, bpftrace_->get().num_params()); } std::optional LiteralFolder::visit(PositionalParameter ¶m) { if (!bpftrace_) { return std::nullopt; } // By default, we treat parameters as integer literals if we can, and // rely on the user to have an explicit `str` cast. const std::string &val = bpftrace_->get().get_param(param.n); // If empty, treat as zero. This is the documented behavior. if (val.empty()) { param.addWarning() << "Positional parameter $" << param.n << " is empty or not provided. "; return ast_.make_node(param.loc, static_cast(0)); } if (val[0] == '-') { auto v = util::to_int(val); if (!v) { // Not parsed, treat it as a string. return ast_.make_node(param.loc, val); } return ast_.make_node(param.loc, *v); } else { auto v = util::to_uint(val); if (!v) { // Not parsed, treat it as a string. return ast_.make_node(param.loc, val); } return ast_.make_node(param.loc, *v); } } std::optional LiteralFolder::visit(Call &call) { // If this is the string function, then we can evaluate the given literal // as a string (e.g. this covers str(0) and str($3)). if (call.func == "str" && !call.vargs.empty()) { std::string s; // First, we need to check if this directly wraps a positional parameter. // If yes, then we prevent it from expanding to zero as is the default. if (auto *param = call.vargs.at(0).as()) { if (!bpftrace_) { return std::nullopt; // Can't fold yet. } call.vargs[0] = ast_.make_node( param->loc, bpftrace_->get().get_param(param->n)); } else if (auto *binop = call.vargs.at(0).as()) { auto *param = binop->left.as(); if (param && binop->op == Operator::PLUS) { if (!bpftrace_) { return std::nullopt; // Can't fold yet. } binop->left = ast_.make_node( param->loc, bpftrace_->get().get_param(param->n)); } } // Now we can expand normally. Visitor>::visit(call); // If this is an integer of some kind, then fold it into a string. if (auto *n = call.vargs.at(0).as()) { std::stringstream ss; ss << n->value; s = ss.str(); } else if (auto *n = call.vargs.at(0).as()) { std::stringstream ss; ss << n->value; s = ss.str(); } else if (auto *str = call.vargs.at(0).as()) { s = str->value; } else { return std::nullopt; } // Handle optional truncation. if (call.vargs.size() >= 2) { if (auto *n = call.vargs.at(1).as()) { // Truncate the string. if (s.size() >= n->value) { s = s.substr(0, n->value); } } else { return std::nullopt; } } return ast_.make_node(call.loc, s); } else { Visitor>::visit(call); } return std::nullopt; } std::optional LiteralFolder::visit(Expression &expr) { auto r = Visitor>::visit(expr.value); if (r) { expr.value = r->value; } return std::nullopt; } std::optional LiteralFolder::visit(ExprStatement &expr) { visit(expr.expr); // Removes excess nesting caused by comptime folding/pruning if (auto *block_expr = expr.expr.as()) { if (block_expr->stmts.size() == 1 && block_expr->stmts.back().is() && block_expr->expr.is()) { expr.expr = block_expr->stmts.back().as()->expr; } } return std::nullopt; } std::optional LiteralFolder::visit(Probe &probe) { top_level_node_ = &probe; return Visitor>::visit(probe); } std::optional LiteralFolder::visit(Builtin &builtin) { if (builtin.ident == "__builtin_usermode") { if (auto *probe = dynamic_cast(top_level_node_)) { for (auto *ap : probe->attach_points) { if (!ap->check_available(builtin.ident)) { auto probe_type = probetype(ap->provider); if (probe_type == ProbeType::special) { return ast_.make_node(builtin.loc, 1); } return ast_.make_node(builtin.loc, 0); } } } } return std::nullopt; } std::optional LiteralFolder::visit(BlockExpr &expr) { Visitor>::visit(expr); StatementList stmt_list; for (auto &stmt : expr.stmts) { if (auto *expr_stmt = stmt.as()) { if (expr_stmt->expr.is()) { continue; } } stmt_list.emplace_back(std::move(stmt)); } expr.stmts = std::move(stmt_list); // We fold this only if the statement list is empty, and we find a literal // as the expression value. We should have recorded an error if there was an // attempt to access variables, calls, or generally do anything non-hermetic. if (expr.stmts.empty() && (expr.expr.is_literal() || expr.expr.is() || expr.expr.is())) { return expr.expr; } return std::nullopt; } std::optional LiteralFolder::visit(ArrayAccess &acc) { visit(acc.expr); visit(acc.indexpr); if (auto *str = acc.expr.as()) { if (auto *index = acc.indexpr.as()) { if (index->value > str->value.size()) { // This error happens later on. return std::nullopt; } const char *s = str->value.c_str(); return ast_.make_node(acc.loc, static_cast(s[index->value])); } } return std::nullopt; } std::optional LiteralFolder::visit(TupleAccess &acc) { visit(acc.expr); if (acc.expr.is() && acc.expr.is_literal()) { auto *tuple = acc.expr.as(); if (acc.index >= tuple->elems.size()) { // This access error happens in a later pass. return std::nullopt; } return tuple->elems[acc.index]; } return std::nullopt; } std::optional LiteralFolder::visit(FieldAccess &acc) { visit(acc.expr); if (acc.expr.is() && acc.expr.is_literal()) { auto *record = acc.expr.as(); for (auto *elem : record->elems) { if (elem->name == acc.field) { return elem->expr; } } } return std::nullopt; } std::optional LiteralFolder::visit(Comptime &comptime) { // This will fold into an expression directly. If this should not be used for // cases where folding needs to happen above the comptime, e.g. `IfExpr`, // which handles this in a special way. visit(comptime.expr); if (comptime.expr.is_literal()) { return comptime.expr; } if (auto *nested = comptime.expr.as()) { return nested->expr; // Prune redundant comptime. } return std::nullopt; } bool eval_bool(Expression expr) { if (auto *integer = expr.as()) { return integer->value != 0; } if (expr.is()) { return true; } if (auto *str = expr.as()) { return !str->value.empty(); } if (auto *boolean = expr.as()) { return boolean->value; } LOG(BUG) << "Expression is not a literal"; return false; } void fold(ASTContext &ast, Expression &expr) { LiteralFolder folder(ast); folder.visit(expr); } void fold(ASTContext &ast) { LiteralFolder folder(ast); folder.visit(ast.root); } Pass CreateFoldLiteralsPass() { auto fn = [](ASTContext &ast, BPFtrace &b) { LiteralFolder folder(ast, b); folder.visit(ast.root); }; return Pass::create("FoldLiterals", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/fold_literals.h000066400000000000000000000010421526721631600212450ustar00rootroot00000000000000#pragma once #include "ast/ast.h" #include "ast/pass_manager.h" namespace bpftrace::ast { // Folds only a single expression. // // This may be used by subsequent passes when expressions are replaced by // literals. Note however, that it is up to the pass to ensure that the full // expression is recursively folded. void fold(ASTContext &ast, Expression &expr); // Re-visit the whole ast and re-fold void fold(ASTContext &ast); bool eval_bool(Expression expr); // Fold all nodes. Pass CreateFoldLiteralsPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/import_scripts.cpp000066400000000000000000000047251526721631600220510ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/passes/import_scripts.h" #include "ast/passes/resolve_imports.h" namespace bpftrace::ast { static void import_ast(ASTContext &ast, Node &node, const ASTContext &other) { // The ordering of all probes is reversed before and after appending, // in order to provide a partial ordering over imports. Consider the // left node import -- this will wind up being the first thing initialized. std::ranges::reverse(ast.root->probes); // Clone all map declarations, subfunctions, etc. into the primary AST. // Note that we may choose not to inline all definitions in the future, and // define that namespace-based resolution is used for e.g. macro expansion, // function matching, etc. But for now, we just support a trivial // expansion. ast.diagnostics().add(std::move(other.diagnostics())); if (other.root) { for (const auto &stmt : other.root->c_statements) { ast.root->c_statements.push_back(clone(ast, node.loc, stmt)); } for (const auto &decl : other.root->map_decls) { ast.root->map_decls.push_back(clone(ast, node.loc, decl)); } for (const auto &fn : other.root->functions) { ast.root->functions.push_back(clone(ast, node.loc, fn)); } for (const auto ¯o : other.root->macros) { ast.root->macros.push_back(clone(ast, node.loc, macro)); } for (const auto &probe : other.root->probes) { ast.root->probes.push_back(clone(ast, node.loc, probe)); } } // See above. We re-reverse the set of probes available to provide the // intended partial ordering. std::ranges::reverse(ast.root->probes); } Pass CreateImportExternalScriptsPass() { return Pass::create("ImportExternalScripts", [](ASTContext &ast, Imports &imports) { for (const auto &[name, obj] : imports.scripts) { if (!obj.internal) { import_ast(ast, obj.node, obj.ast); } } }); } Pass CreateImportInternalScriptsPass() { return Pass::create("ImportInternalScripts", [](ASTContext &ast, Imports &imports) { for (const auto &[name, obj] : imports.scripts) { if (obj.internal) { import_ast(ast, obj.node, obj.ast); } } }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/import_scripts.h000066400000000000000000000003721526721631600215100ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { // Requires the `Imports` from the `CreateResolveRootImports` pass. Pass CreateImportInternalScriptsPass(); Pass CreateImportExternalScriptsPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/link.cpp000066400000000000000000000067531526721631600177300ustar00rootroot00000000000000#include #include #include "ast/passes/codegen_llvm.h" #include "ast/passes/link.h" #include "ast/passes/resolve_imports.h" #include "bpfbytecode.h" #include "scopeguard.h" #include "util/temp.h" namespace bpftrace::ast { char LinkError::ID; void LinkError::log(llvm::raw_ostream &OS) const { OS << "linking " << origin_ << ": " << strerror(err_); } Pass CreateExternObjectPass() { return Pass::create("extern", [](Imports &imports) { BpfExternObjects result; for (const auto &[name, obj] : imports.objects) { result.objects.emplace_back(obj.path); } return result; }); } Pass CreateLinkPass() { return Pass::create( "link", [](BpfObject &obj, BpfExternObjects &ext) -> Result { // If there are no other objects to link, then just return our own. if (ext.objects.empty()) { return BpfBytecode{ obj.data }; } // Create a working directory. auto dir = util::TempDir::create(); if (!dir) { return dir.takeError(); } // Otherwise, dump the intermediate object. auto object = dir->create_file(); if (!object) { return object.takeError(); } auto ok = object->write_all(obj.data); if (!ok) { return ok.takeError(); } // Create an output file on disk. In the future, we may want to accept // some flags that allow this file to persist. auto output = dir->create_file(); if (!output) { return output.takeError(); } // In order to craft the final output, since we may have external maps // and probes, we delegate the heavy lifting to libbpf. First, we open a // new memfd as output, and add our top-level output to the linker. struct bpf_linker *linker = bpf_linker__new(output->path().c_str(), nullptr); if (linker == nullptr) { // Hopefully an empty 'origin' here is sufficient to distinguish the // case where this failed. I believe that it's likely to be ENOMEM or // something equally obvious to the user? return make_error("", errno); } SCOPE_EXIT { bpf_linker__free(linker); }; // Link in our own program. int rc = bpf_linker__add_file(linker, object->path().c_str(), nullptr); if (rc != 0) { return make_error(output->path().string(), errno); } // Next, we iterate through the list of link targets that we collected // from import statements. These are added to the link target one at a // time. for (auto &path : ext.objects) { int rc = bpf_linker__add_file(linker, path.c_str(), nullptr); if (rc != 0) { return make_error(path.string(), errno); } } // Finalize the linking, and free our underlying library handle. rc = bpf_linker__finalize(linker); if (rc != 0) { return make_error(output->path().string(), errno); } // Reload the final output and return it. std::ifstream file(output->path(), std::ios::binary); if (!file.is_open()) { return make_error(output->path().string(), errno); } std::vector data(std::istreambuf_iterator(file), {}); return BpfBytecode{ data }; }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/link.h000066400000000000000000000013601526721631600173620ustar00rootroot00000000000000#pragma once #include #include "ast/pass_manager.h" #include "util/result.h" namespace bpftrace::ast { class BpfExternObjects : public ast::State<"bpf-extern"> { public: std::vector objects; }; // Produces a set of external objects, `BpfExternObjects`. Pass CreateExternObjectPass(); class LinkError : public ErrorInfo { public: LinkError(std::string origin, int err) : origin_(std::move(origin)), err_(err) {}; static char ID; void log(llvm::raw_ostream &OS) const override; private: std::string origin_; int err_; }; // Produces the final output `BpfBytecode` object from `BpfObject` and the // `BpfExternObjects` provided. Pass CreateLinkPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/loop_return.cpp000066400000000000000000000214771526721631600213430ustar00rootroot00000000000000#include "ast/passes/loop_return.h" #include "ast/ast.h" #include "ast/visitor.h" namespace bpftrace::ast { namespace { class LoopReturn : public Visitor { public: LoopReturn(ASTContext &ast) : ast_(ast) {}; using Visitor::visit; template void inject(T &node); void visit(Subprog &subprog); void visit(Probe &probe); void visit(For &for_loop); void visit(While &while_loop); void visit(Statement &stmt); private: Variable *get_return_var(const Node &node) { return ast_.make_node(node.loc, "__return_value"); } Variable *get_return_set_var(const Node &node) { return ast_.make_node(node.loc, "__return_value_set"); } ASTContext &ast_; int loop_depth_ = 0; std::optional loop_return_; }; } // namespace void LoopReturn::visit(For &for_loop) { loop_depth_++; Visitor::visit(for_loop); loop_depth_--; } void LoopReturn::visit(While &while_loop) { loop_depth_++; Visitor::visit(while_loop); loop_depth_--; } void LoopReturn::visit(Statement &stmt) { // Recursively visit the block statements. Visitor::visit(stmt); // First see if we have any loop statements, because we will inject an // additional return into those statements if needed. This may be rewritten // below, but only if this is within an inner loop. // // Consider that this takes: // // for (...) { } // // And turns it into: // // { for (...) { } if (__return_value_set) { return __return_value; } } // // The return may be subsequently rewritten below, if inside a loop. bool is_loop = stmt.is() || stmt.is(); if (is_loop && loop_return_.has_value()) { std::vector ret_stmts; if (loop_depth_ > 0) { // We're still in a loop, so just break. ret_stmts.emplace_back( ast_.make_node(stmt.node().loc, JumpType::BREAK)); } else if (loop_return_.value()) { // The value was set within the loop, so return it. ret_stmts.emplace_back(ast_.make_node(stmt.node().loc, JumpType::RETURN, get_return_var(stmt.node()))); } else { // The value was not set within the loop, so skip it. ret_stmts.emplace_back( ast_.make_node(stmt.node().loc, JumpType::RETURN)); } // Make an if contingent on the return value being set, and break // from this local loop if that is the case. auto *ret_block = ast_.make_node(stmt.node().loc, std::move(ret_stmts), ast_.make_node( stmt.node().loc)); auto *ret_if = ast_.make_node(stmt.node().loc, get_return_set_var(stmt.node()), ret_block, ast_.make_node( stmt.node().loc)); auto *ret_stmt = ast_.make_node(stmt.node().loc, ret_if); auto *block = ast_.make_node( stmt.node().loc, std::vector({ stmt, ret_stmt }), ast_.make_node(stmt.node().loc)); auto *block_stmt = ast_.make_node(stmt.node().loc, block); stmt = block_stmt; // Replace with the compound block. } else if (auto *jmp = stmt.as()) { // This rewrites any return statements in a loop as something that will // set the return value and then break the loop. Combined with the above, // which checks this *outside* the loop and injects a return (possibly // rewritten here if inside an inner loop), we have control flow logic // that will be captured by the automatic context. if (loop_depth_ > 0 && jmp->ident == JumpType::RETURN) { if (!loop_return_.has_value()) { loop_return_ = jmp->return_value.has_value(); } else if (loop_return_.value() != jmp->return_value.has_value()) { // We cannot handle this case, but it's a more general error. jmp->addError() << "Return value used in loop is inconsistent"; return; } std::vector ret_stmts; if (jmp->return_value.has_value()) { ret_stmts.emplace_back(ast_.make_node( jmp->loc, get_return_var(stmt.node()), jmp->return_value.value())); } // This (and the below declaration, *should* be a boolean. Unfortunately, // the clang optimization passes are able to outsmart the by verifier by // short-circuiting the return value. The compiler knows that this value // contains either zero or one, and it is also the intended return value. // // if ($x == 1) { return 1; } else { return 0; } // // gets transformed into: // // return $x; // // Unfortunately the verifier is *not* sure that this value is either // zero or one, and bails out: // // 190: (73) *(u8 *)(r8 +0) = r7 ; frame2: R7_w=1 R8=fp[0]-49 cb // 191: (bf) r0 = r7 ; frame2: R0_w=1 R7_w=1 cb // 192: (95) exit // returning from callee: // frame2: R0_w=1 R1_w=3 R2=scalar() R6=fp[1]-48 R7_w=1 R8=fp[0]-49 // R9=scalar(smin=smin32=0,smax=umax=smax32=umax32=1320,var_off=(0x0; // 0x7f8)) R10=fp0 fp-8=???????m fp-16=mmmmmmmm fp-24=mmmmmmmm cb // to caller at 124: // frame1: // R0=scalar(smin=smin32=0,smax=umax=smax32=umax32=165,var_off=(0x0; // 0xff)) // R1=scalar(smin=umin=smin32=umin32=1,smax=umax=smax32=umax32=127,var_off=(0x0; // 0x7f)) R2=func() R3=fp-48 R4=0 R6=0 R7=fp[0]-49 // R8=scalar(smin=smin32=0,smax=umax=smax32=umax32=1320,var_off=(0x0; // 0x7f8)) R10=fp0 fp-32=scalar(id=8) fp-40=mmmmmmm1 fp-48=fp[0]-49 cb // 124: (85) call bpf_loop#181 ; frame1: R0_w=scalar() R6=0 // R7=fp[0]-49 // R8=scalar(smin=smin32=0,smax=umax=smax32=umax32=1320,var_off=(0x0; // 0x7f8)) R10=fp0 fp-32=scalar(id=8) fp-40=mmmmmmm1 fp-48=fp[0]-49 cb // 125: (bf) r1 = r0 ; frame1: R0_w=scalar(id=9) // R1_w=scalar(id=9) cb 126: (67) r1 <<= 32 ; frame1: // R1_w=scalar(smax=0x7fffffff00000000,umax=0xffffffff00000000,smin32=0,smax32=umax32=0,var_off=(0x0; // 0xffffffff00000000)) cb 127: (c7) r1 s>>= 32 ; frame1: // R1_w=scalar(smin=0xffffffff80000000,smax=0x7fffffff) cb 128: (6d) if r6 // s> r1 goto pc+2 ; frame1: // R1_w=scalar(smin=smin32=0,smax=umax=umax32=0x7fffffff,var_off=(0x0; // 0x7fffffff)) R6=0 cb 129: (71) r0 = *(u8 *)(r7 +0) ; frame1: // R0_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=255,var_off=(0x0; // 0xff)) R7=fp[0]-49 cb 130: (95) exit At callback return the register R0 // has smin=0 smax=255 should have been in [0, 1] // // We fix this by simply having a wider integer for this case, so we // check if the value is set to anything, and a cast is forced. ret_stmts.emplace_back(ast_.make_node( jmp->loc, get_return_set_var(stmt.node()), ast_.make_node(jmp->loc, 1))); ret_stmts.emplace_back(ast_.make_node(jmp->loc, JumpType::BREAK)); auto *block = ast_.make_node(jmp->loc, std::move(ret_stmts), ast_.make_node(jmp->loc)); auto *block_stmt = ast_.make_node(jmp->loc, block); stmt = block_stmt; // As above, replace with the compound block. } } } template void LoopReturn::inject(T &node) { loop_return_.reset(); Visitor::visit(node); if (loop_return_.has_value()) { // Declare the return variables at the top of the probe. These actually // need to supercede all the other statements in the block. if (loop_return_.value()) { auto *ret_var_decl = ast_.make_node( node.loc, get_return_var(node)); node.block->stmts.insert(node.block->stmts.begin(), Statement(ret_var_decl)); } auto *ret_set_var_decl = ast_.make_node( node.loc, get_return_set_var(node), ast_.make_node(node.loc, 0)); node.block->stmts.insert(node.block->stmts.begin(), Statement(ret_set_var_decl)); } } void LoopReturn::visit(Subprog &subprog) { inject(subprog); } void LoopReturn::visit(Probe &probe) { inject(probe); } Pass CreateLoopReturnPass() { auto fn = [](ASTContext &ast) { LoopReturn lr(ast); lr.visit(ast.root); }; return Pass::create("LoopReturn", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/loop_return.h000066400000000000000000000002031526721631600207700ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateLoopReturnPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/macro_expansion.cpp000066400000000000000000000543441526721631600221570ustar00rootroot00000000000000#include #include #include #include #include "ast/ast.h" #include "ast/context.h" #include "ast/passes/macro_expansion.h" #include "ast/visitor.h" #include "log.h" namespace bpftrace::ast { char MacroLookupError::ID; void MacroLookupError::log(llvm::raw_ostream &OS) const { // This is the default message, but most calls will handle this error and // apply to the relevant nodes directly. OS << "Unable to find macro " << name_; } static bool validate(Macro *macro) { std::unordered_set seen_mvars; std::unordered_set seen_mmaps; std::unordered_set seen_idents; for (const auto &arg : macro->vargs) { if (auto *mvar = arg.as()) { auto inserted = seen_mvars.insert(mvar->ident); if (!inserted.second) { mvar->addError() << "Variable for macro argument has already been used: " << mvar->ident; return false; } } else if (auto *mmap = arg.as()) { auto inserted = seen_mmaps.insert(mmap->ident); if (!inserted.second) { mmap->addError() << "Map for macro argument has already been used: " << mmap->ident; return false; } } else if (auto *ident = arg.as()) { auto inserted = seen_idents.insert(ident->ident); if (!inserted.second) { ident->addError() << "Ident for macro argument has already been used: " << ident->ident; return false; } } } return true; } MacroRegistry MacroRegistry::create(ASTContext &ast) { MacroRegistry registry; for (Macro *macro : ast.root->macros) { // Note that it is possible to define conflicting macros in this way. For // example, we could have: // // macro foo($x, $y) {} // macro foo(x, y) {} // // However we explicitly allow this, as long as they are added in such a way // that they will match with the most precise macros first. The newest macro // definition must not match with any existing macro definition. auto exists = registry.lookup(macro->name, macro->vargs, macro->is_stdlib); if (exists) { auto &err = macro->addError(); err << "Redefinition of macro: " << macro->name; err.addContext((*exists)->loc) << "This is the original definition."; continue; // Skip this macro. } consumeError(std::move(exists)); if (!validate(macro)) { continue; } // Add to the list matching this name. registry.macros_[macro->name].emplace_back(macro); } return registry; } static size_t distance(const Macro *macro, const std::vector &args) { // Any missing arguments either way are wrong; these dominate the other // differences by far, so we ensure that these are the least close macros. // This is why 1024 is used: we should never have a macro with this many // arguments, and we score 1 badness per incorrect argument. size_t d = 1024 * static_cast( std::abs(static_cast(macro->vargs.size()) - static_cast(args.size()))); for (size_t i = 0; i < macro->vargs.size() && i < args.size(); i++) { if ((macro->vargs[i].is() && !args[i].is()) || (macro->vargs[i].is() && !args[i].is())) { d++; // Incompatible arguments. } } return d; } Result MacroRegistry::lookup(const std::string &name, const std::vector &args, std::optional is_stdlib) const { const auto it = macros_.find(name); if (it == macros_.end()) { return make_error( name, std::vector()); // Nothing // with // this // name. } size_t min_distance = std::numeric_limits::max(); std::vector closest; const Macro *exact_stdlib_match = nullptr; const Macro *exact_user_match = nullptr; for (const auto *m : it->second) { // When a lookup explicitly targets stdlib or user-defined macros, treat // the other class as invisible. This avoids turning unrelated builtin or // function calls into macro mismatch errors. if (is_stdlib && m->is_stdlib != *is_stdlib) { continue; } size_t d = distance(m, args); if (d == 0) { if (m->is_stdlib && !exact_stdlib_match) { exact_stdlib_match = m; } else if (!m->is_stdlib && !exact_user_match) { exact_user_match = m; } } if (d < min_distance) { min_distance = d; closest.clear(); } if (d == min_distance) { closest.push_back(m); } } // When both user and stdlib definitions match, prefer the user-defined // macro. Filtered lookups only populate one of these pointers. if (exact_user_match) { return exact_user_match; } if (exact_stdlib_match) { return exact_stdlib_match; } return make_error(name, std::move(closest)); } class MacroExpander : public Visitor { public: MacroExpander(ASTContext &ast, const MacroRegistry ®istry, std::vector &stack, bool should_rename = true) : ast_(ast), registry_(registry), stack_(stack), should_rename_(should_rename) {}; using Visitor::visit; void visit(AssignVarStatement &assignment); void visit(Variable &var); void visit(VarDeclStatement &decl); void visit(Map &map); void visit(Expression &expr); void visit(Sizeof &sizeof_node); void visit(Offsetof &offsetof_node); void visit(Typeof &typeof_node); void visit(TypeArg &type_arg); void visit_expr_or_type(ExprOrType &record); std::optional expand(const Macro ¯o, Call &call); std::optional expand(const Macro ¯o, Identifier &ident); private: ASTContext &ast_; const MacroRegistry ®istry_; std::vector stack_; bool should_rename_; bool rename_ok(); std::string get_new_var_ident(std::string original_ident); // Maps of macro map/var names -> callsite map/var names std::unordered_map maps_; std::unordered_map vars_; std::unordered_set renamed_vars_; std::unordered_map passed_exprs_; }; void MacroExpander::visit(AssignVarStatement &assignment) { if (!rename_ok()) { visit(assignment.expr); return; } auto *var = assignment.var(); // Don't rename any variable passed by reference. if (!vars_.contains(var->ident)) { renamed_vars_.insert(var->ident); } if (std::holds_alternative(assignment.var_decl)) { visit(std::get(assignment.var_decl)); } else { visit(std::get(assignment.var_decl)); } visit(assignment.expr); } void MacroExpander::visit(VarDeclStatement &decl) { if (!rename_ok()) { return; } auto *var = decl.var; if (vars_.contains(var->ident)) { decl.addError() << "Variable declaration shadows macro arg " << var->ident; return; } renamed_vars_.insert(var->ident); visit(decl.typeof); visit(decl.var); } void MacroExpander::visit(Variable &var) { if (!rename_ok()) { return; } if (auto it = vars_.find(var.ident); it != vars_.end()) { var.ident = it->second; } else if (renamed_vars_.contains(var.ident)) { var.ident = get_new_var_ident(var.ident); } } void MacroExpander::visit(Map &map) { if (!rename_ok()) { return; } if (auto it = maps_.find(map.ident); it != maps_.end()) { map.ident = it->second; } else { map.addError() << "Unhygienic access to map: " << map.ident << ". Maps must be passed into the macro as arguments."; } } // We are in a possible type context so Macro expansion and type param // replacement has special behavior. If `record` is an expression then we only // care if it's a bare identifier, which we treat either as a type name or as a // target for replacement by a TypeArg (not a possible candidate for macro // expansion). If the user wants to expand a macro that has no params in this // context then we require the macro calling convention (e.g. // `sizeof(mymacro())`). If `record` is a ParsedType and not an expression then // we need to see if it's a candidate for replacement by a TypeArg. There are // some TypeArg replacements that are not valid (e.g. `macro a(t) { // sizeof(struct t) } begin { a(typeof(struct b)) }`, which would yield // `sizeof(struct struct b)`). void MacroExpander::visit_expr_or_type(ExprOrType &record) { if (auto *expr = std::get_if(&record)) { auto *ident = expr->as(); if (ident) { if (auto it = passed_exprs_.find(ident->ident); it != passed_exprs_.end()) { auto *type_arg = it->second.as(); if (type_arg) { record = clone(ast_, ident->loc, type_arg->type_of->record); return; } } else { // Bare identifier that isn't a macro expression argument — treat it as // a type name rather than expanding it as a macro. return; } } visit(*expr); } else { auto *parsed_type = std::get(record); assert(parsed_type != nullptr); ParsedType *parent = nullptr; while (parsed_type->inner) { parent = parsed_type; parsed_type = parsed_type->inner; } if (auto it = passed_exprs_.find(parsed_type->name); it != passed_exprs_.end()) { auto *type_arg = it->second.as(); auto *ident = it->second.as(); switch (parsed_type->kind) { case ParsedType::Kind::Struct: case ParsedType::Kind::Union: case ParsedType::Kind::Enum: { // struct enum or struct struct is not supported syntax so unless the // expression is a Identifier or a ParsedType Identifier this is an // error if (ident) { parsed_type->name = ident->ident; return; } if (type_arg) { if (auto *pt = std::get_if( &type_arg->type_of->record)) { if ((*pt)->kind == ParsedType::Kind::Identifier) { parsed_type->name = (*pt)->name; return; } } else { auto typeof_expr = std::get( type_arg->type_of->record); ident = typeof_expr.as(); if (ident) { parsed_type->name = ident->ident; return; } } // Fall through to error below } break; } case ParsedType::Kind::Identifier: { if (ident) { parsed_type->name = ident->ident; return; } if (type_arg) { if (!parent) { record = clone(ast_, parsed_type->loc, type_arg->type_of->record); return; } if (auto *pt = std::get_if( &type_arg->type_of->record)) { parent->inner = clone(ast_, parsed_type->loc, *pt); return; } auto typeof_expr = std::get(type_arg->type_of->record); auto *typeof_ident = typeof_expr.as(); if (typeof_ident) { parent->inner = ast_.make_node( parsed_type->loc, ParsedType::Kind::Identifier, typeof_ident->ident); return; } } break; } case ParsedType::Kind::Pointer: case ParsedType::Kind::Array: { LOG(BUG) << "ParsedType bottom can't be a pointer or array"; break; } } it->second.node().addError() << "Invalid replacement for macro '" << stack_.back()->name << "' type parameter '" << parsed_type->name << "' which makes up the type '" << std::get(record)->type_name() << "'"; } } } void MacroExpander::visit(Sizeof &sizeof_node) { visit(*sizeof_node.type_of); } void MacroExpander::visit(Offsetof &offsetof_node) { visit(*offsetof_node.type_of); if (offsetof_node.field.size() == 1) { if (auto it = passed_exprs_.find(offsetof_node.field.back()); it != passed_exprs_.end()) { if (auto *ident = it->second.as()) { offsetof_node.field[0] = ident->ident; } else if (it->second.as()) { // A FieldAccess made up entirely of identifiers (e.g. a.b.c) can // replace the single field parameter. std::vector fields; Expression expr = it->second; while (auto *field_access = expr.as()) { fields.push_back(field_access->field); expr = field_access->expr; } auto *base = expr.as(); if (!base) { it->second.node().addError() << "FieldAccess expressions must be made up entirely of idents " "(e.g. a.b.c) to replace the second argument in `offsetof`"; return; } fields.push_back(base->ident); std::ranges::reverse(fields); offsetof_node.field = std::move(fields); } } } } void MacroExpander::visit(Typeof &typeof_node) { visit_expr_or_type(typeof_node.record); } void MacroExpander::visit(TypeArg &type_arg) { visit_expr_or_type(type_arg.type_of->record); } void MacroExpander::visit(Expression &expr) { auto *ident = expr.as(); auto *call = expr.as(); if (!ident && !call) { Visitor::visit(expr); return; } if (ident) { if (auto it = passed_exprs_.find(ident->ident); it != passed_exprs_.end()) { expr = clone(ast_, ident->loc, it->second); // Create a new expander because we're visiting an expression passed into // the macro so it's not part of the surounding macro code and therefore // variables, maps, and idents in this expression shouldn't be modified // and this expression *is* permitted to be un-hygienic. MacroExpander expander(ast_, registry_, stack_, false); expander.visit(expr); return; } } if (call) { visit(call->vargs); } std::vector empty; const std::string &name = ident ? ident->ident : call->func; const std::vector &args = ident ? empty : call->vargs; // If we're being called from a stdlib macro then only expand other stdlib // macros not user-defined macros that also happen to match std::optional restrict_to_stdlib = std::nullopt; if (!stack_.empty() && stack_.back()->is_stdlib) { restrict_to_stdlib = true; } auto result = registry_.lookup(name, args, restrict_to_stdlib); if (!result) { auto done = handleErrors( std::move(result), [&](const MacroLookupError &lookupErr) { const auto &closest = lookupErr.closest(); if (closest.empty()) { // It does not match any macros. This is not really an error, and // just means that we don't process or expand this instance. return; } const auto *macro = closest[0]; auto &err = ident ? ident->addError() : call->addError(); err << "Call to " << name << "() " << "has arguments that do not match any definition."; // We can't say exactly what they intended here, so we break this into // a suitable hint, pointing to the closest macro we could find. if (macro->vargs.size() != args.size()) { err.addContext(macro->loc) << "The closest definition of " << macro->name << "() has a different number of arguments. " << "Expected: " << macro->vargs.size() << " but got " << args.size(); return; } // Break down the mismatched arguments. for (size_t i = 0; i < macro->vargs.size() && i < args.size(); i++) { if (auto *mmap = macro->vargs.at(i).as()) { if (args.at(i).is()) { auto &arg_err = args[i].node().addError(); arg_err << "Mismatched arg. " << macro->name << "() expects a map for arg " << mmap->ident << " but got a variable."; arg_err.addContext(mmap->loc) << "This is the argument in the closest definition."; } else { auto &arg_err = args[i].node().addError(); arg_err << "Mismatched arg. " << macro->name << "() expects a map for arg " << mmap->ident << " but got an expression."; arg_err.addContext(mmap->loc) << "This is the argument in the closest definition."; } } else if (auto *mvar = macro->vargs.at(i).as()) { if (args.at(i).is()) { auto &arg_err = args[i].node().addError(); arg_err << "Mismatched arg. " << macro->name << "() expects a variable for arg " << mvar->ident << " but got a map."; arg_err.addContext(mvar->loc) << "This is the argument in the closest definition."; } else { auto &arg_err = args[i].node().addError(); arg_err << "Mismatched arg. " << macro->name << "() expects a variable for arg " << mvar->ident << " but got an expression."; arg_err.addContext(mvar->loc) << "This is the argument in the closest definition."; } } } }); if (!done) { // This should not happen; add the error. LOG(BUG) << done.takeError(); } return; } const auto *macro = *result; for (size_t i = 0; i < stack_.size(); ++i) { // We cannot expand recursively at this time, however this may happen // later using apply. We provide this helpful error. if (stack_.at(i) == macro) { auto &err = expr.node().addError(); err << "Recursive macro call detected. Call chain: "; for (size_t j = i; j < stack_.size(); ++j) { err << stack_.at(j)->name << " > "; } err << macro->name; return; } } // Expand this macro. stack_.push_back(macro); auto r = ident ? MacroExpander(ast_, registry_, stack_).expand(*macro, *ident) : MacroExpander(ast_, registry_, stack_).expand(*macro, *call); stack_.pop_back(); if (r) { expr.value = *r; } } bool MacroExpander::rename_ok() { return !stack_.empty() && should_rename_; } std::string MacroExpander::get_new_var_ident(std::string original_ident) { // This is a name like $$foo_0_x, where `x` is the original name, // `foo` is the macro name, and `0` is the depth of the call. assert(rename_ok()); const auto *macro = stack_.back(); std::string base = "$$" + macro->name; if (stack_.size() != 1) { base += "_" + std::to_string(stack_.size()); } return base + "_" + original_ident; } std::optional MacroExpander::expand(const Macro ¯o, Call &call) { if (macro.vargs.size() != call.vargs.size()) { return std::nullopt; } StatementList stmt_list; for (size_t i = 0; i < macro.vargs.size(); i++) { if (auto *mident = macro.vargs.at(i).as()) { if (call.vargs.at(i).is() || call.vargs.at(i).is()) { // Wrap variables and maps in a block to avoid mutation. passed_exprs_[mident->ident] = ast_.make_node( call.loc, StatementList({}), call.vargs.at(i)); } else { passed_exprs_[mident->ident] = call.vargs.at(i); } } else if (auto *mvar = macro.vargs.at(i).as()) { auto *cvar = call.vargs.at(i).as(); assert(cvar != nullptr); // Required by lookup. vars_[mvar->ident] = cvar->ident; } else if (auto *mmap = macro.vargs.at(i).as()) { auto *cmap = call.vargs.at(i).as(); assert(cmap != nullptr); // Required by lookup. maps_[mmap->ident] = cmap->ident; } } auto *cloned_block = clone(ast_, call.loc, macro.block); visit(cloned_block); return cloned_block; } std::optional MacroExpander::expand(const Macro ¯o, Identifier &ident) { if (!macro.vargs.empty()) { ident.addError() << "Call to " << macro.name << "() has the wrong number of arguments. Expected: " << macro.vargs.size() << " but got 0."; return std::nullopt; } auto *cloned_block = clone(ast_, ident.loc, macro.block); visit(cloned_block); return cloned_block; } class TypeArgCheck : public Visitor { public: explicit TypeArgCheck(ASTContext &ast) : ast_(ast) {}; using Visitor::visit; void visit(TypeArg &type_arg); private: ASTContext &ast_; }; void TypeArgCheck::visit(TypeArg &type_arg) { type_arg.addError() << "When used as a call argument, `typeof` builtin only valid for macro " "calls that are expecting a type parameter"; } void expand_macro(ASTContext &ast, Expression &expr, const MacroRegistry ®istry) { std::vector stack; MacroExpander expander(ast, registry, stack); expander.visit(expr); } Pass CreateMacroExpansionPass() { auto fn = [](ASTContext &ast) -> MacroRegistry { auto macros = MacroRegistry::create(ast); std::vector stack; MacroExpander expander(ast, macros, stack); expander.visit(ast.root); TypeArgCheck type_arg_check(ast); type_arg_check.visit(ast.root); // Macros have now been expanded into their call sites, so remove the // definitions from the AST. The registry retains its own pointers to the // (arena-owned) macro nodes, so this only affects later AST traversals and // debug dumps, which should no longer see the consumed definitions. ast.root->macros.clear(); return macros; }; return Pass::create("MacroExpansion", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/macro_expansion.h000066400000000000000000000031631526721631600216150ustar00rootroot00000000000000#pragma once #include #include #include "ast/ast.h" #include "ast/context.h" #include "ast/pass_manager.h" namespace bpftrace::ast { class MacroLookupError : public ErrorInfo { public: MacroLookupError(std::string name, std::vector closest) : name_(std::move(name)), closest_(std::move(closest)) {}; static char ID; void log(llvm::raw_ostream &OS) const override; const std::vector &closest() const { return closest_; } private: std::string name_; std::vector closest_; }; class MacroRegistry : public State<"macro-registry"> { public: // Creates a new registry based on an AST. // // This may add errors to conflicting macros. static MacroRegistry create(ASTContext &ast); // Lookup a macro based on a name, set of arguments, and if it's stdlib // // If no matching macro is found, `nullptr` is returned. Result lookup( const std::string &name, const std::vector &args, std::optional is_stdlib = std::nullopt) const; private: // This holds the definitions for all discovered macros. std::map> macros_; }; void expand_macro(ASTContext &ast, Expression &expr, const MacroRegistry ®istry); // Expand all possible macros. Macros can be defined recursively, and in these // cases they are not expanded recursively. Instead, it is the responsibility // of the caller to reject these late calls or call `expand` above (to a limit). Pass CreateMacroExpansionPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/map_sugar.cpp000066400000000000000000000257341526721631600207510ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/passes/macro_expansion.h" #include "ast/passes/map_sugar.h" #include "ast/visitor.h" namespace bpftrace::ast { const std::unordered_set &getAssignRewriteFuncs() { // Similarly these are syntactic sugar over operating on a map. This list // could also be dynamically generated based on some underlying annotation. static std::unordered_set ASSIGN_REWRITE = { "hist", "lhist", "count", "sum", "min", "max", "avg", "stats", "tseries", }; return ASSIGN_REWRITE; } // These are special functions which are part of the map API, and operate // independently of any key. We allow the first argument to be a pure map, and // therefore don't expand a default key in these cases. // // In the future, this could be generalized by extracting information about the // specific function being called, and potentially respecting annotations on // these arguments. const std::unordered_set &getRawMapArgFuncs() { static std::unordered_set RAW_MAP_ARG = { "print", "clear", "zero", "len", "is_scalar", }; return RAW_MAP_ARG; } namespace { class MapDefaultKey : public Visitor { public: explicit MapDefaultKey(ASTContext &ast) : ast_(ast) {}; using Visitor::visit; void visit(Call &call); void visit(For &for_loop); void visit(Map &map); void visit(MapAccess &acc); void visit(MapAddr &map_addr); void visit(Program &program); void visit(Typeof &typeof); void visit(AssignScalarMapStatement &assign); void visit(AssignMapStatement &assign); void visit(Expression &expr); void visit(Statement &stmt); [[nodiscard]] bool check(Map &map, bool indexed); void checkAccess(Map &map, bool indexed); void checkCall(Map &map, bool indexed); MapMetadata metadata; private: ASTContext &ast_; bool first_pass_ = true; std::vector typeofs_; }; class MapFunctionAliases : public Visitor { public: explicit MapFunctionAliases(ASTContext &ast, MacroRegistry ¯o_registry) : ast_(ast), macro_registry_(macro_registry) {}; using Visitor::visit; void visit(Expression &expr); private: ASTContext &ast_; const MacroRegistry ¯o_registry_; }; class MapAssignmentCall : public Visitor { public: explicit MapAssignmentCall(ASTContext &ast) : ast_(ast) {}; using Visitor::visit; void visit(Statement &stmt); private: ASTContext &ast_; }; class MapAssignmentCheck : public Visitor { public: using Visitor::visit; void visit(Call &call); }; class MapScalarCheck : public Visitor { public: explicit MapScalarCheck(ASTContext &ast, MapMetadata &metadata) : ast_(ast), metadata_(metadata) {}; using Visitor::visit; void visit(Expression &expr); private: ASTContext &ast_; MapMetadata &metadata_; }; } // namespace void MapDefaultKey::visit(Map &map) { checkAccess(map, false); } void MapDefaultKey::visit(MapAccess &acc) { checkAccess(*acc.map, true); visit(acc.key); } void MapDefaultKey::visit([[maybe_unused]] MapAddr &map_addr) { // Don't desugar this into a map access, we want the map pointer } void MapDefaultKey::visit(Typeof &typeof) { if (first_pass_) { // Save these off and don't evaluate them until we've walked the rest of the // AST to determine if a map is a scalar or not. typeofs_.emplace_back(&typeof); return; } if (std::holds_alternative(typeof.record)) { const auto &expr = std::get(typeof.record); if (auto *map = expr.as()) { // Don't de-sugar if it's a non-scalar map auto val = metadata.scalar.find(map->ident); if (val != metadata.scalar.end() && !val->second) { return; } } } Visitor::visit(typeof); } void MapDefaultKey::visit(AssignScalarMapStatement &assign) { checkAccess(*assign.map, false); visit(assign.expr); } void MapDefaultKey::visit(AssignMapStatement &assign) { checkAccess(*assign.map_access->map, true); visit(assign.map_access); visit(assign.expr); } void MapDefaultKey::visit(Expression &expr) { Visitor::visit(expr); // Replace with an indexed map. Note that we don't visit for calls that // are exempt from this. This applies to all expressions in the tree, // including `lhist` and `hist`, which are treated in a special way // subsequently. if (auto *map = expr.as()) { auto *index = ast_.make_node(map->loc, 0); expr.value = ast_.make_node(map->loc, map, index); } } void MapDefaultKey::visit(Statement &stmt) { Visitor::visit(stmt); // Replace with a statement that has the default index, in the same way as // above. This will be type-checked in a later pass. if (auto *map = stmt.as()) { auto *index = ast_.make_node(map->loc, 0); auto *acc = ast_.make_node(map->loc, map->map, index); stmt.value = ast_.make_node(map->loc, acc, map->expr); } } void MapDefaultKey::visit(Program &program) { for (Subprog *subprog : program.functions) visit(subprog); for (Probe *probe : program.probes) visit(probe); first_pass_ = false; for (auto *typeof : typeofs_) { visit(*typeof); } } bool MapDefaultKey::check(Map &map, bool indexed) { bool scalar = !indexed; auto val = metadata.scalar.find(map.ident); if (val == metadata.scalar.end()) { metadata.scalar.emplace(map.ident, scalar); return true; } else { return val->second == scalar; } } void MapDefaultKey::checkAccess(Map &map, bool indexed) { if (!check(map, indexed)) { if (indexed) { metadata.bad_scalar_access.insert(&map); } else { metadata.bad_indexed_access.insert(&map); } } } void MapDefaultKey::checkCall(Map &map, bool indexed) { if (!check(map, indexed)) { if (indexed) { metadata.bad_scalar_call.insert(&map); } else { metadata.bad_indexed_call.insert(&map); } } } void MapDefaultKey::visit(Call &call) { // Skip the first argument in these cases. This allows the argument to be // *either* a pure map, or a map access. Later passes will figure out what to // do with this, as they may have parametric behavior (as with print). if (getRawMapArgFuncs().contains(call.func) && !call.vargs.empty()) { if (auto *map = call.vargs.at(0).as()) { // Check our functions for consistency. These are effectively builtins // that require that map to have keys (conditionally for delete). if (call.func == "len") { checkCall(*map, true); } else if (call.func == "is_scalar") { if (call.vargs.size() != 1) { call.addError() << "is_scalar() requires 1 argument (" << call.vargs.size() << " provided)"; } } } else { visit(call.vargs.at(0)); } for (size_t i = 1; i < call.vargs.size(); i++) { visit(call.vargs.at(i)); } } else { Visitor::visit(call); } } void MapDefaultKey::visit(For &for_loop) { if (auto *map = for_loop.iterable.as()) { if (!check(*map, true)) { metadata.bad_iterator.insert(map); } } else { // If the map is used for the range in any way, it needs // to be desugared properly. visit(for_loop.iterable); } visit(for_loop.block); } void MapFunctionAliases::visit(Expression &expr) { // We expect semantics for delete that are `delete(@, key)`. We support an // old `delete(@[key])` syntax but rewrite this under the hood. // This is expanded to the `__deprecated_delete` in macro stdlib. Visitor::visit(expr); if (auto *call = expr.as()) { if (call->func == "__deprecated_delete") { if (auto *access = call->vargs.at(0).as()) { call->vargs.clear(); call->vargs.emplace_back(access->map); call->vargs.emplace_back(access->key); call->func = "delete"; expand_macro(ast_, expr, macro_registry_); } } } } static std::optional injectMap(Expression expr, Map *map, Expression key) { if (auto *call = expr.as()) { if (getAssignRewriteFuncs().contains(call->func)) { auto args = std::move(call->vargs); call->vargs.emplace_back(map); call->vargs.emplace_back(key); call->injected_args += 2; call->vargs.insert(call->vargs.end(), args.begin(), args.end()); return call; } } else if (auto *block = expr.as()) { auto injected_expr = injectMap(block->expr, map, key); if (injected_expr) { return block; } } return std::nullopt; } void MapAssignmentCall::visit(Statement &stmt) { // Any assignments that are direct calls to special functions may // be rewritten to simply be the function expression. if (auto *assign = stmt.as()) { auto expr = injectMap(assign->expr, assign->map_access->map, assign->map_access->key); if (expr) { // We injected a call, and can flatten the statement. This discards // the return value, because it is not otherwise useful. We originally // visited as a statement, so this does not affect the semantics. stmt.value = ast_.make_node(assign->loc, expr.value()); } } Visitor::visit(stmt); } void MapAssignmentCheck::visit(Call &call) { if (getAssignRewriteFuncs().contains(call.func) && call.injected_args == 0) { call.addError() << call.func << "() must be assigned directly to a map"; } Visitor::visit(call); } void MapScalarCheck::visit(Expression &expr) { Visitor::visit(expr); if (auto *call = expr.as()) { if (call->func == "is_scalar") { if (auto *map = call->vargs.at(0).as()) { auto val = metadata_.scalar.find(map->ident); if (val == metadata_.scalar.end()) { expr.node().addError() << "Unknown map: " << map->ident; return; } expr.value = ast_.make_node(call->loc, val->second); } else { expr.node().addError() << call->func << "() expects a map for the first argument"; } } } } Pass CreateMapSugarPass() { auto fn = [](ASTContext &ast, MacroRegistry ¯o_registry) -> MapMetadata { MapFunctionAliases aliases(ast, macro_registry); aliases.visit(ast.root); MapDefaultKey defaults(ast); defaults.visit(ast.root); if (!ast.diagnostics().ok()) { // No consistent defaults. return std::move(defaults.metadata); } MapAssignmentCall sugar(ast); sugar.visit(ast.root); MapAssignmentCheck check; check.visit(ast.root); MapScalarCheck scalar(ast, defaults.metadata); scalar.visit(ast.root); return std::move(defaults.metadata); }; return Pass::create("MapSugar", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/map_sugar.h000066400000000000000000000021741526721631600204070ustar00rootroot00000000000000#pragma once #include #include "ast/ast.h" #include "ast/pass_manager.h" namespace bpftrace::ast { // MapMetadata contains metadata related to the sugared maps. // // For now, this is whether they are used as scalars. In the future, this may // be used as the basis for `MapInfo`, which can be propagated and used by // passes, rather than being mutated within the BPFtrace object. // // Additionally we track scalar/non-scalar map errors here but defer actually // issuing the errors on the nodes until a later pass as they may removed if // they are inside branch that is pruned at compile time class MapMetadata : public ast::State<"map-metadata"> { public: std::unordered_map scalar; std::unordered_set bad_scalar_access; std::unordered_set bad_indexed_access; std::unordered_set bad_scalar_call; std::unordered_set bad_indexed_call; std::unordered_set bad_iterator; }; const std::unordered_set &getAssignRewriteFuncs(); const std::unordered_set &getRawMapArgFuncs(); Pass CreateMapSugarPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/named_param.cpp000066400000000000000000000127061526721631600212320ustar00rootroot00000000000000#include "ast/passes/named_param.h" #include "ast/ast.h" #include "ast/context.h" #include "ast/visitor.h" #include "bpftrace.h" namespace bpftrace::ast { class NamedParamPass : public Visitor { public: NamedParamPass(ASTContext &ast, BPFtrace &bpftrace) : ast_(ast), bpftrace_(bpftrace) {}; using Visitor::visit; void visit(Expression &expr); std::unordered_map used_args; NamedParamInfo defaults; private: ASTContext &ast_; BPFtrace &bpftrace_; }; void NamedParamPass::visit(Expression &expr) { auto *call = expr.as(); if (!call || call->func != "getopt") { Visitor::visit(expr); return; } auto *arg_name = call->vargs.at(0).as(); if (!arg_name) { call->vargs.at(0).node().addError() << "First argument to 'getopt' must be a string literal."; return; } if (call->vargs.empty() || call->vargs.size() > 3) { call->addError() << "The 'getopt' function can take a maximum of " << "three arguments and a minimum of one argument."; return; } // The description field can only appear as the third parameter of getopt, // example: `getopt("name", true, "description")`. std::string description; if (call->vargs.size() == 3) { if (auto *description_str = call->vargs.at(2).as()) { description = description_str->value; } else { call->vargs.at(2).node().addWarning() << "Function 'getopt' requires the third parameter to be a string" << " literal."; return; } } if (call->vargs.size() >= 2) { if (!call->vargs.at(1).as() && !call->vargs.at(1).as() && !call->vargs.at(1).as() && !call->vargs.at(1).as()) { call->vargs.at(1).node().addError() << "Second argument to 'getopt' must be a string literal, integer " "literal, or a boolean literal."; return; } } globalvars::GlobalVarValue np_default; auto *map_node = ast_.make_node(call->loc, arg_name->value); SizedType val_type; if (call->vargs.size() == 1) { // boolean val_type = CreateBool(); np_default = false; } else if (auto *default_value = call->vargs.at(1).as()) { // boolean val_type = CreateBool(); np_default = default_value->value; } else if (auto *default_value = call->vargs.at(1).as()) { // string val_type = CreateString(bpftrace_.config_->max_strlen); np_default = default_value->value; } else if (auto *default_value = call->vargs.at(1).as()) { // unsigned integer val_type = CreateUInt64(); np_default = default_value->value; } else if (auto *default_value = call->vargs.at(1).as()) { // signed integer val_type = CreateInt64(); np_default = default_value->value; } defaults.map_val_types[arg_name->value] = std::move(val_type); if (used_args.contains(arg_name->value)) { if (used_args.at(arg_name->value).value != np_default) { std::string pre_value; if (std::holds_alternative( used_args.at(arg_name->value).value)) { pre_value = std::get(used_args.at(arg_name->value).value); } else if (std::holds_alternative( used_args.at(arg_name->value).value)) { pre_value = std::to_string( std::get(used_args.at(arg_name->value).value)); } else if (std::holds_alternative( used_args.at(arg_name->value).value)) { pre_value = std::to_string( std::get(used_args.at(arg_name->value).value)); } else { pre_value = std::get(used_args.at(arg_name->value).value) ? "true" : "false"; } call->addError() << "Command line option '" << arg_name->value << "' needs to have the same default value in all places " "it is used. Previous default value: " << pre_value; return; } if (!description.empty() && !used_args.at(arg_name->value).description.empty() && used_args.at(arg_name->value).description != description) { call->addError() << "Command line option '" << arg_name->value << "' must have the same description in all places " << "it's used. Hint: You can wrap it in a macro"; return; } // A parameter may be specified multiple times by `getopt`, and some // may not include a description field, so a description field should // be added for those that are not specified. if (description.empty()) { description = used_args.at(arg_name->value).description; } } auto *index = ast_.make_node(map_node->loc, 0); expr.value = ast_.make_node(map_node->loc, map_node, index); used_args[arg_name->value] = bpftrace::globalvars::GlobalVarInfo({ .value = np_default, .description = description, }); defaults.defaults[arg_name->value] = bpftrace::globalvars::GlobalVarInfo({ .value = std::move(np_default), .description = description, }); } Pass CreateNamedParamsPass() { auto fn = [](ASTContext &ast, BPFtrace &b) -> Result { NamedParamPass np_pass(ast, b); np_pass.visit(ast.root); return std::move(np_pass.defaults); }; return Pass::create("NamedParam", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/named_param.h000066400000000000000000000005521526721631600206730ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" #include "globalvars.h" namespace bpftrace::ast { class NamedParamInfo : public ast::State<"named_param_info"> { public: std::unordered_map defaults; std::unordered_map map_val_types; }; Pass CreateNamedParamsPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/parse_passes.h000066400000000000000000000061571526721631600211260ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" #include "ast/passes/ap_probe_expansion.h" #include "ast/passes/args_resolver.h" #include "ast/passes/attachpoint_passes.h" #include "ast/passes/builtins.h" #include "ast/passes/c_macro_expansion.h" #include "ast/passes/clang_parser.h" #include "ast/passes/config_analyser.h" #include "ast/passes/control_flow_analyser.h" #include "ast/passes/deprecated.h" #include "ast/passes/field_analyser.h" #include "ast/passes/fold_literals.h" #include "ast/passes/import_scripts.h" #include "ast/passes/loop_return.h" #include "ast/passes/macro_expansion.h" #include "ast/passes/map_sugar.h" #include "ast/passes/named_param.h" #include "ast/passes/pid_filter_pass.h" #include "ast/passes/probe_prune.h" #include "ast/passes/resolve_imports.h" #include "ast/passes/unstable_feature.h" #include "ast/passes/usdt_arguments.h" #include "btf.h" #include "parser.h" namespace bpftrace::ast { // AllParsePasses returns a vector of passes representing all parser passes, in // the expected order. This should be used unless there's a reason not to. inline std::vector AllParsePasses( std::vector &&extra_flags = {}, std::vector &&import_paths = {}, bool debug = false) { std::vector passes; passes.emplace_back(CreateParsePass(debug)); passes.emplace_back(CreateConfigPass()); passes.emplace_back(CreateResolveRootImportsPass(std::move(import_paths))); // N.B. We expand the AST with all externally imported scripts, then check // against unstable features, *then* import all internal scripts. This means // that internal scripts are except from the unstable feature warning. passes.emplace_back(CreateImportExternalScriptsPass()); passes.emplace_back(CreateUnstableFeaturePass()); passes.emplace_back(CreateDeprecatedPass()); passes.emplace_back(CreateParseAttachpointsPass()); passes.emplace_back(CreateCheckAttachpointsPass()); passes.emplace_back(CreateUSDTImportPass()); passes.emplace_back(CreateImportInternalScriptsPass()); passes.emplace_back(CreateLoopReturnPass()); passes.emplace_back(CreateControlFlowPass()); passes.emplace_back(CreateMacroExpansionPass()); passes.emplace_back(CreateParseBTFPass()); passes.emplace_back(CreatePreExpansionBuiltinsPass()); passes.emplace_back(CreateProbeAndApExpansionPass()); passes.emplace_back(CreateProbePrunePass()); passes.emplace_back(CreateArgsResolverPass()); passes.emplace_back(CreateFieldAnalyserPass()); passes.emplace_back(CreateClangParsePass(std::move(extra_flags))); // separate pass so we can fold accesses to configs e.g. `config.max_strlen` passes.emplace_back(CreateConfigBuiltinsPass()); passes.emplace_back(CreateFoldLiteralsPass()); passes.emplace_back(CreateBuiltinsPass()); passes.emplace_back(CreateCMacroExpansionPass()); passes.emplace_back(CreateMapSugarPass()); passes.emplace_back(CreateNamedParamsPass()); passes.emplace_back(CreatePidFilterPass()); // This comes after the MacroExpansion pass to conditionally // import standard library C files passes.emplace_back(CreateResolveStatementImportsPass()); return passes; } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/pid_filter_pass.cpp000066400000000000000000000054011526721631600221270ustar00rootroot00000000000000#include "ast/passes/pid_filter_pass.h" #include "ast/ast.h" #include "ast/visitor.h" #include "bpftrace.h" namespace bpftrace::ast { namespace { class PidFilterPass : public Visitor { public: explicit PidFilterPass(ASTContext &ast, BPFtrace &bpftrace) : ast_(ast), bpftrace_(bpftrace) { } using Visitor::visit; void visit(Probe &probe); private: ASTContext &ast_; BPFtrace &bpftrace_; }; // If the probe can't filter by pid when attaching // then we inject custom AST to filter by pid. // Note: this doesn't work for AOT as the code has already // been generated bool probe_needs_pid_filter(AttachPoint *ap) { ProbeType type = probetype(ap->provider); switch (type) { case ProbeType::kprobe: case ProbeType::kretprobe: case ProbeType::fentry: case ProbeType::fexit: case ProbeType::tracepoint: case ProbeType::rawtracepoint: return true; // These probe types support passing the pid during attachment case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: case ProbeType::watchpoint: case ProbeType::invalid: case ProbeType::iter: case ProbeType::profile: case ProbeType::software: case ProbeType::hardware: // We don't filter by pid at all for these special probes case ProbeType::interval: case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: return false; } return false; } } // namespace static BlockExpr *create_pid_filter(ASTContext &ast, int pid, BlockExpr *orig_block) { auto *ret_block = ast.make_node( orig_block->loc, StatementList( { ast.make_node(orig_block->loc, ast::JumpType::RETURN) }), ast.make_node(orig_block->loc)); return ast.make_node( orig_block->loc, StatementList({}), ast.make_node( orig_block->loc, ast.make_node(orig_block->loc, ast.make_node(orig_block->loc, "pid"), Operator::NE, ast.make_node(orig_block->loc, pid)), ret_block, orig_block)); } void PidFilterPass::visit(Probe &probe) { const auto pid = bpftrace_.pid(); if (!pid.has_value()) { return; } for (AttachPoint *ap : probe.attach_points) { if (probe_needs_pid_filter(ap)) { probe.block = create_pid_filter(ast_, *pid, probe.block); return; } } } Pass CreatePidFilterPass() { return Pass::create("PidFilter", [](ASTContext &ast, BPFtrace &b) { auto pid_filter = PidFilterPass(ast, b); pid_filter.visit(ast.root); }); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/pid_filter_pass.h000066400000000000000000000002021526721631600215660ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreatePidFilterPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/portability_analyser.cpp000066400000000000000000000065261526721631600232310ustar00rootroot00000000000000#include #include "ast/passes/portability_analyser.h" #include "ast/visitor.h" #include "types.h" namespace bpftrace::ast { namespace { // Checks if a script uses any non-portable bpftrace features that AOT // cannot handle. // // Over time, we expect to relax these restrictions as AOT supports more // features. class PortabilityAnalyser : public Visitor { public: using Visitor::visit; void visit(PositionalParameter ¶m); void visit(Call &call); void visit(Cast &cast); }; void PortabilityAnalyser::visit(PositionalParameter ¶m) { // Positional params are only known at runtime. Currently, codegen directly // embeds positional params into the bytecode but that does not work for AOT. // // In theory we could allow positional params for AOT and just embed the // values into the bytecode but there's really no point to that as: // // * that would mislead the user into thinking there's positional param // support // * the user can just hard code the values into their script param.addError() << "AOT does not yet support positional parameters"; } void PortabilityAnalyser::visit(Call &call) { for (auto &expr : call.vargs) visit(expr); // kaddr() and __builtin_uaddr() both resolve symbols -> address during // codegen and embeds the values into the bytecode. For AOT to support // kaddr()/__builtin_uaddr(), the addresses must be resolved at runtime // and fixed up during load time. // // cgroupid can vary across systems just like how a process does not // necessarily share the same PID across multiple systems. cgroupid() is also // resolved during codegen and the value embedded into the bytecode. For AOT // to support cgroupid(), the cgroupid must be resolved at runtime and fixed // up during load time. if (call.func == "kaddr" || call.func == "__builtin_uaddr" || call.func == "cgroupid") { call.addError() << "AOT does not yet support " << call.func << "()"; } // `curtask` is implemented via the `bpf_get_current_task` helper, which // returns a `struct task_struct *`. This struct is unstable across kernel // versions and configurations. This makes it inherently unportable. We must // block it until we support field access relocations. if (call.func == "__get_current_task") { call.addError() << "AOT does not yet support accessing `curtask`"; } } void PortabilityAnalyser::visit(Cast &cast) { visit(cast.expr); // The goal here is to block arbitrary field accesses but still allow `args` // access. `args` for tracepoint is fairly stable and should be considered // portable. `args` for k[ret]funcs are type checked by the kernel and may // also be considered stable. For AOT to fully support field accesses, we // need to relocate field access at runtime. cast.addError() << "AOT does not yet support struct casts"; } } // namespace Pass CreatePortabilityPass() { auto fn = [](ASTContext &ast) { PortabilityAnalyser analyser; analyser.visit(ast.root); if (!ast.diagnostics().ok()) { // Used by runtime test framework to know when to skip an AOT test if (std::getenv("__BPFTRACE_NOTIFY_AOT_PORTABILITY_DISABLED")) std::cout << "__BPFTRACE_NOTIFY_AOT_PORTABILITY_DISABLED" << std::endl; } }; return Pass::create("PortabilityAnalyser", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/portability_analyser.h000066400000000000000000000002041526721631600226610ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreatePortabilityPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/printer.cpp000066400000000000000000001277721526721631600204630ustar00rootroot00000000000000#include #include #include #include #include #include "ast/ast.h" #include "ast/passes/printer.h" #include "ast/passes/types/type_map.h" #include "types.h" #include "util/strings.h" namespace bpftrace::ast { constexpr size_t kIndentWidth = 2; static bool is_whitespace(const std::string& s) { return std::ranges::all_of(s, [](char c) { return std::isspace(c); }); } namespace { struct Text { Text(std::string data) : data(std::move(data)) {}; std::string data; }; struct Comment { Comment(std::string data) : data(std::move(data)) {}; std::string data; }; struct Line { Line() = default; size_t columns() const { // Compute the number of columns in this line. For now, // we just reify the line and return the character count. return reify().size(); } std::string reify() const { bool all_whitespace = true; std::stringstream ss; for (size_t i = 0; i < segments.size(); i++) { const auto& seg = segments[i]; if (std::holds_alternative(seg)) { const auto& s = std::get(seg).data; ss << s; all_whitespace = all_whitespace && is_whitespace(s); } else if (std::holds_alternative(seg)) { if (!all_whitespace) { ss << " "; } if (i == segments.size() - 1) { const auto& comment = std::get(seg).data; if (comment.empty()) { ss << "//"; } else { ss << "// " << comment; } } else { ss << "/* " << std::get(seg).data << " */"; } } } return ss.str(); } std::vector> segments; }; } // namespace struct BufferState { std::vector lines; size_t current_depth = 0; }; Buffer::Buffer() : state(std::make_unique()) { state->lines.emplace_back(); }; Buffer::~Buffer() = default; Buffer&& Buffer::append(Buffer&& other, size_t indent, bool align) { if (other.lines() == 0) { return std::move(*this); } else { // Record the current column, and extend from there. For example, // consider the following existing line: // // some_kind_of_call( // // Appending multiple lines would result in the following: // // some_kind_of_call(line1, // line2, // line3); // // Otherwise, the caller can manually inject a newline and use ident=2, // e.g.: // // some_kind_of_call( // line1, // line2, // line3 // ); // // When align is false, continuation lines are preserved verbatim (keeping // their own base-relative indentation) rather than aligned to the current // column. This is appropriate for block bodies following assignments, but // wrong for call arguments, e.g. // let $a = { // let $b = 1; // $b // }; size_t col = state->lines.back().columns(); if (indent > 0) { state->lines.emplace_back(); col = indent; } for (size_t i = 0; i < other.state->lines.size(); i++) { auto& line = other.state->lines[i]; if (align && col != 0 && state->lines.back().segments.empty()) { state->lines.back().segments.emplace_back(Text(std::string(col, ' '))); } state->lines.back().segments.insert( state->lines.back().segments.end(), std::make_move_iterator(line.segments.begin()), std::make_move_iterator(line.segments.end())); // Only add a new line if there are more lines or we are in indenting // mode, which carries an implicit newline at the end of the block. if (indent > 0 || i < other.state->lines.size() - 1) { state->lines.emplace_back(); } } } // We extend from our current final line. return std::move(*this); } Buffer&& Buffer::text(std::string str) { state->lines.back().segments.emplace_back(Text(std::move(str))); return std::move(*this); } Buffer&& Buffer::comment(std::string str) { state->lines.back().segments.emplace_back(Comment(std::move(str))); return std::move(*this); } Buffer&& Buffer::metadata(MetadataIndex metadata, std::optional min_vspace) { bool inline_style = !min_vspace.has_value(); if (!inline_style) { size_t total_vspace = 0; if (min_vspace) { for (size_t i = 0; i < *min_vspace; i++) { state->lines.emplace_back(); } } for (const auto& part : metadata.all()) { // Each element of metadata is either a string (comment), or a // size_t (vertical space). We extract these and emit them. See // MetadataIndex for more information. if (std::holds_alternative(part)) { for (size_t i = 0; i < std::get(part); i++) { if (min_vspace && total_vspace < *min_vspace) { // Already done above. } else { state->lines.emplace_back(); } total_vspace++; } } else { // This is a full-line comment. state->lines.back().segments.emplace_back( Comment(std::get(part))); state->lines.emplace_back(); } } } else { // In the style is inline, then we drop any vertical space. // This is basically condensing comments that are inline for // an expression into an inline comment. If they should be // multiple lines, then they can associated with a top-level // node, like the statement itself. for (const auto& part : metadata.all()) { if (std::holds_alternative(part)) { state->lines.back().segments.emplace_back( Comment(std::get(part))); } } } return std::move(*this); } Buffer&& Buffer::line_break() { state->lines.emplace_back(); return std::move(*this); } size_t Buffer::width() const { size_t max_width = 0; for (const auto& line : state->lines) { max_width = std::max(max_width, line.columns()); } return max_width; } size_t Buffer::lines() const { if (state->lines.back().segments.empty()) { return state->lines.size() - 1; } else { return state->lines.size(); } } std::ostream& operator<<(std::ostream& out, const Buffer& buffer) { for (size_t i = 0; i < buffer.lines(); i++) { const auto& line = buffer.state->lines[i]; auto s = line.reify(); out << util::rtrim(s) << std::endl; } return out; } static bool is_primitive(const Expression& expr) { if (expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is() || expr.is()) { return true; } if (auto* comptime = expr.as()) { return is_primitive(comptime->expr); } return false; } Buffer Formatter::visit(CStatement& cstmt) { return Buffer().text(cstmt.data); } Buffer Formatter::visit(Integer& integer) { if (integer.original) { // This typically means that it has special characters such as separately, // suffixes, etc. We preserve these as an esthetic choice. return Buffer().text(*integer.original); } else { return Buffer().text(std::to_string(integer.value)); } } Buffer Formatter::visit(NegativeInteger& integer) { return Buffer().text(std::to_string(integer.value)); } Buffer Formatter::visit(Boolean& boolean) { return boolean.value ? Buffer().text("true") : Buffer().text("false"); } Buffer Formatter::visit(PositionalParameter& param) { return Buffer().text("$" + std::to_string(param.n)); } Buffer Formatter::visit([[maybe_unused]] PositionalParameterCount& param) { return Buffer().text("$#"); } static std::string escape(const std::string& s) { std::stringstream ss; for (char c : s) { int code = static_cast(c); if (std::isprint(code)) { if (c == '\\') ss << "\\\\"; else if (c == '"') ss << "\\\""; else ss << c; } else { if (c == '\n') ss << "\\n"; else if (c == '\t') ss << "\\t"; else if (c == '\r') ss << "\\r"; else ss << "\\x" << std::setfill('0') << std::setw(2) << std::hex << code; } } return ss.str(); } Buffer Formatter::visit(String& string) { return Buffer().text("\"" + escape(string.value) + "\""); } Buffer Formatter::visit([[maybe_unused]] None& none) { // Does not have a syntactic representation. We should never get // here during a normal traversal, but we can just emit "none". return Buffer().text("none"); } Buffer Formatter::visit(Builtin& builtin) { return Buffer().text(builtin.ident); } Buffer Formatter::visit(Identifier& identifier) { return Buffer().text(identifier.ident); } template bool is_comparison(const T& expr) { if constexpr (std::is_same_v) { auto* binop = expr.template as(); if (!binop) { return false; } switch (binop->op) { case Operator::EQ: case Operator::NE: case Operator::LE: case Operator::GE: case Operator::LT: case Operator::GT: return true; default: return false; } } return false; } template Buffer Formatter::format_list(std::vector& exprs, const std::string& sep, MetadataIndex& metadata, size_t max_width, bool bare) { // We need to carefully extract the metadata for all the arguments, and // position them correctly. Depending on the width, we will do either // multiline in inline. std::vector args; size_t total_width = 0; for (size_t i = 0; i < exprs.size(); i++) { auto arg = format(exprs[i], metadata, (i < exprs.size() - 1) ? max_width - 1 : max_width, bare || is_comparison(exprs[i])); if (i < exprs.size() - 1) { arg = arg.text(sep); } total_width += arg.width(); args.emplace_back(std::move(arg)); } if (total_width < max_width) { // Join into a single line. auto single_line_args = Buffer(); for (size_t i = 0; i < exprs.size(); i++) { single_line_args = single_line_args.append(std::move(args[i])); } return single_line_args; } else { // Find the most aesthetically pleasing arrangement by minimizing // the relative gap between the widest and narrowest lines. std::vector widths; for (const auto& arg : args) { widths.push_back(arg.width()); } // Try all possible ways to partition arguments. double best_ratio = std::numeric_limits::max(); size_t best_mask = 0; size_t n = widths.size(); for (size_t mask = 0; mask < (1U << (n - 1)); mask++) { std::vector line_widths; size_t current_width = widths[0]; for (size_t i = 1; i < n; i++) { if (mask & (1U << (i - 1))) { line_widths.push_back(current_width); current_width = widths[i]; } else { current_width += widths[i]; } } line_widths.push_back(current_width); size_t min_w = *std::ranges::min_element(line_widths); size_t max_w = *std::ranges::max_element(line_widths); if (max_w > max_width) { continue; // Too wide, don't consider. } double relative_range = max_w > 0 ? (max_w - min_w) / max_w : 0; if (relative_range < best_ratio) { best_ratio = relative_range; best_mask = mask; } } // Build the result using the best mask. auto multi_line_args = Buffer(); for (size_t i = 0; i < args.size(); i++) { if (i > 0 && (best_mask & (1U << (i - 1)))) { multi_line_args = multi_line_args.line_break(); } multi_line_args = multi_line_args.append(std::move(args[i])); } return multi_line_args; } } Buffer Formatter::visit(Call& call) { auto args = format_list( call.vargs, ", ", metadata, max_width - (call.func.size() + 2), true); if (args.width() > max_width) { // Return with the newline break style. // // foo( // a, // b // ); return Buffer() .text(call.func + "(") .append(std::move(args), kIndentWidth) .text(")"); } else { // Return as is, with the inline or multi-line style. // // foo(a, b, c) // // foo(a, // b, // c); // return Buffer().text(call.func + "(").append(std::move(args)).text(")"); } } static bool is_array_access_ident(const Expression& expr) { const auto* arr = expr.as(); if (arr == nullptr) { return false; } const Expression* base = &arr->expr; while (const auto* inner = base->as()) { base = &inner->expr; } return base->is(); } // Check if the expression used as a type-context argument (e.g. to `typeinfo`, // `typeof`, `sizeof`, `offsetof`) is an array access on a bare identifier. If // so, we need to make sure to wrap this expression in parens to ensure that it // re-parses as an expression instead of as a ParsedType (Kind::Array). For // example these two parse differently: `typeof(ident[0])` and // `typeof((ident[0]))`. The first is a parsed as a type (an array of type // `ident` with 0 elements) while the second is parsed as an ArrayAccess // expression of the ident `ident`. This is important because in the second case // `ident` could be a macro (with no arguments) that gets expanded, while the // former cannot. Buffer Formatter::format_expr_as_type(Expression& expr, size_t max_width) { auto buffer = format(expr, metadata, max_width, true); if (is_array_access_ident(expr)) { return Buffer().text("(").append(std::move(buffer)).text(")"); } return buffer; } Buffer Formatter::format_type_arg(ExprOrType& record, size_t max_width) { return std::visit( [&](auto& v) -> Buffer { using T = std::decay_t; if constexpr (std::is_same_v) { return format_expr_as_type(v, max_width); } else { return format(v, metadata, max_width, true); } }, record); } Buffer Formatter::visit(Sizeof& szof) { // N.B. Does not support splitting. return Buffer() .text("sizeof(") .append(format_type_arg(szof.type_of->record, max_width - 8)) .text(")"); } Buffer Formatter::visit(Offsetof& ofof) { // N.B. Does not support splitting. auto fields = Buffer(); for (size_t i = 0; i < ofof.field.size(); i++) { if (i > 0) { fields = fields.text("."); } fields = fields.text(ofof.field[i]); } return Buffer() .text("offsetof(") .append(format_type_arg(ofof.type_of->record, max_width)) .text(", ") .append(std::move(fields)) .text(")"); } Buffer Formatter::visit(Typeof& typeof) { if (std::holds_alternative(typeof.record)) { return Buffer().text("typeof(").append( format_expr_as_type(std::get(typeof.record), max_width - 8) .text(")")); } else { // Prefer the simpler form for direct types. return format( *std::get(typeof.record), metadata, max_width, bare); } } Buffer Formatter::visit(ParsedType& type) { return visit(static_cast(type)); } Buffer Formatter::visit(TypeArg& type_arg) { auto& type_of = *type_arg.type_of; if (std::holds_alternative(type_of.record)) { // The expression form already prints as `typeof(expr)`. return visit(type_of); } // A direct type must be wrapped in `typeof(...)` so that it parses back as a // type argument rather than being interpreted as an expression. return Buffer() .text("typeof(") .append(format(*std::get(type_of.record), metadata, max_width - 8, true)) .text(")"); } Buffer Formatter::visit(Typeinfo& typeinfo) { return Buffer() .text("typeinfo(") .append(format_type_arg(typeinfo.typeof->record, max_width - 10)) .text(")"); } Buffer Formatter::visit(MapDeclStatement& decl) { std::stringstream bpf_type; bpf_type << decl.bpf_type; return Buffer() .text("let ") .text(decl.ident) .text(" = ") .text(bpf_type.str()) .text("(") .text(std::to_string(decl.max_entries)) .text(");"); } Buffer Formatter::visit(Map& map) { return Buffer().text(map.ident); } Buffer Formatter::visit(MapAddr& map_addr) { return Buffer().text("&").text(map_addr.map->ident); } Buffer Formatter::visit(Variable& var) { return Buffer().text(var.ident); } Buffer Formatter::visit(VariableAddr& var_addr) { return Buffer().text("&").text(var_addr.var->ident); } Buffer Formatter::visit(Binop& binop) { auto ops = opstr(binop); // Special case: allow chaining of comparisons. We don't strictly // require the use of nested brackets as long as the comparison // is ambiguious, but we will add brackets if either side involves // other comparison operators. std::vector chained_entries; bool is_logical = binop.op == Operator::LAND || binop.op == Operator::LOR; std::function expand; expand = [&](Expression& expr) { if (is_logical && expr.is() && expr.as()->op == binop.op) { auto* other_binop = expr.as(); expand(other_binop->left); expand(other_binop->right); } else { chained_entries.push_back(expr); } }; expand(binop.left); expand(binop.right); return format_list(chained_entries, " " + ops + " ", metadata, max_width); } Buffer Formatter::visit(Unop& unop) { auto ops = opstr(unop); auto expr = format(unop.expr, metadata, max_width - ops.size()); if (unop.op == Operator::POST_INCREMENT || unop.op == Operator::POST_DECREMENT) { return Buffer().append(std::move(expr)).text(ops); } return Buffer().text(ops).append(std::move(expr)); } Buffer Formatter::visit(IfExpr& if_expr) { // Figure out the full set of branches. std::vector> if_pairs; std::optional final_else; size_t total_width = 0; // Check if this is a ternary expression. You could technically // technically have a ternary expression using blocks, but we prefer // to convert that to a full if expression. if (!if_expr.left.is() && !if_expr.right.is() && !if_expr.right.is()) { auto cond = format(if_expr.cond, metadata, max_width); auto left = format(if_expr.left, metadata, max_width - 2); auto right = format(if_expr.right, metadata, max_width - 2); if (cond.width() + left.width() + right.width() + 8 > max_width) { return Buffer() .append(std::move(cond)) .line_break() .text("? ") .append(std::move(left)) .line_break() .text(": ") .append(std::move(right)); } else { return Buffer() .append(std::move(cond)) .text(" ? ") .append(std::move(left)) .text(" : ") .append(std::move(right)); } } // Since we will manually inject the braces anyways, ensure // that we format the block expression without them. auto as_raw_block = [&](Expression& expr) { if (expr.is()) { return format( *expr.as(), metadata, max_width - kIndentWidth, true); } else { return format(expr, metadata, max_width - kIndentWidth, true); } }; auto comments = metadata.before(if_expr.loc->current.begin); auto* it = &if_expr; while (it != nullptr) { // Special case: comptime is bare for if expressions. We also pull // any metadata between the start of the block and the conditional // so that it appears immediately following the condition itself. auto cond_metadata = metadata.before( if_expr.left.node().loc->current.begin); auto cond = format( it->cond, cond_metadata, max_width - 5, it->cond.is()); cond = cond.metadata(cond_metadata); auto expr = as_raw_block(it->left); total_width += cond.width() + 5; total_width += expr.width() + 3; if_pairs.emplace_back(std::move(cond), std::move(expr)); if (it->right.is()) { it = it->right.as(); continue; } else { if (!it->right.is()) { final_else.emplace(as_raw_block(it->right)); } break; } } // Is this a non-expression statement? auto buffer = Buffer().metadata(comments, 0); bool non_expr = (if_expr.left.is() && if_expr.left.as()->expr.is()) || if_expr.right.is(); bool any_multiline = std::ranges::any_of(if_pairs, [&](auto& v) { return v.first.lines() > 1 || v.second.lines() > 1; }); if (non_expr || total_width > max_width || if_pairs.size() > 1 || any_multiline || (final_else && final_else->lines() > 1)) { // Use the multi-line syntax for this. for (size_t i = 0; i < if_pairs.size(); i++) { buffer = buffer.text(i > 0 ? " else if " : "if ") .append(std::move(if_pairs[i].first)) .text(" {") .append(std::move(if_pairs[i].second), kIndentWidth) .text("}"); } if (final_else) { buffer = buffer.text(" else {") .append(std::move(*final_else), kIndentWidth) .text("}"); } return buffer; } // Everything fits on a single line. for (size_t i = 0; i < if_pairs.size(); i++) { buffer = buffer.text(i > 0 ? " else if " : "if ") .append(std::move(if_pairs[i].first)) .text(" { ") .append(std::move(if_pairs[i].second)) .text(" }"); } if (final_else) { buffer = buffer.text(" else { ").append(std::move(*final_else)).text(" }"); } return buffer; } Buffer Formatter::visit(FieldAccess& acc) { auto expr = format(acc.expr, metadata, max_width - (acc.field.size() + 1), is_primitive(acc.expr)); return expr.text(".").text(acc.field); } Buffer Formatter::visit(ArrayAccess& arr) { auto expr = format(arr.expr, metadata, max_width - 1); auto indexpr = format(arr.indexpr, metadata, max_width - kIndentWidth); if (expr.width() + indexpr.width() + 2 > max_width) { return Buffer() .append(std::move(expr)) .text("[") .append(std::move(indexpr), kIndentWidth) .text("]"); } else { return Buffer() .append(std::move(expr)) .text("[") .append(std::move(indexpr)) .text("]"); } } Buffer Formatter::visit(TupleAccess& acc) { auto n = std::to_string(acc.index); auto elems = format(acc.expr, metadata, max_width - (n.size() + 1)); return Buffer().append(std::move(elems)).text(".").text(n); } Buffer Formatter::visit(MapAccess& acc) { Buffer key; auto* tuple = acc.key.as(); if (tuple && tuple->elems.size() >= 2) { // We need to explicitly override the bare behavior for tuples, // because they will never be bare by default. key = format(*tuple, metadata, max_width - kIndentWidth, true); } else { // Use the default bare behavior, most will still be bare. key = format(acc.key, metadata, max_width - kIndentWidth, true); } if (acc.map->ident.size() + key.width() + 2 > max_width) { return Buffer() .text(acc.map->ident) .text("[") .append(std::move(key), kIndentWidth) .text("]"); } else { return Buffer() .text(acc.map->ident) .text("[") .append(std::move(key)) .text("]"); } } Buffer Formatter::visit(Cast& cast) { // Casts are never split; too confusing. auto buffer = Buffer() .text("(") .append(format(cast.typeof, metadata, max_width)) .text(")"); size_t expr_width = max_width - buffer.width(); return Buffer() .append(std::move(buffer)) .append(format(cast.expr, metadata, expr_width, is_primitive(cast.expr))); } Buffer Formatter::visit(Tuple& tuple) { Buffer elems; if (tuple.elems.size() == 1) { elems = format(tuple.elems[0], metadata, max_width - 3, true).text(","); } else { elems = format_list( tuple.elems, ", ", metadata, max_width - kIndentWidth, true); } if (bare) { return elems; } if (elems.lines() > 1) { return Buffer().text("(").append(std::move(elems), kIndentWidth).text(")"); } else { return Buffer().text("(").append(std::move(elems)).text(")"); } } Buffer Formatter::visit(Record& record) { Buffer elems; if (record.elems.size() == 1) { elems = format(record.elems[0], metadata, max_width - 2); } else { elems = format_list(record.elems, ", ", metadata, max_width - kIndentWidth); } if (elems.lines() > 1) { return Buffer().text("(").append(std::move(elems), kIndentWidth).text(")"); } else { return Buffer().text("(").append(std::move(elems)).text(")"); } } Buffer Formatter::visit(AssignScalarMapStatement& assignment) { std::string ops; auto map = format(assignment.map, metadata, max_width); Buffer expr; // Is this a compound operator? Expression* rhs = &assignment.expr; auto* binop = assignment.expr.as(); if (binop && binop->left.is() && *binop->left.as() == *assignment.map) { ops = opstr(*binop) + "="; rhs = &binop->right; expr = format(binop->right, metadata, max_width - (map.width() + 2 + ops.size()), true); } else { ops = "="; expr = format(assignment.expr, metadata, max_width - (map.width() + 2 + ops.size()), true); } auto buffer = Buffer().append(std::move(map)).text(" ").text(ops).text(" "); bool align = !(rhs->is() || rhs->is()); return buffer.append(std::move(expr), 0, align).text(";"); } Buffer Formatter::visit(AssignMapStatement& assignment) { std::string ops; auto map = format(assignment.map_access, metadata, max_width); Buffer expr; // Is this a compound operator? Expression* rhs = &assignment.expr; auto* binop = assignment.expr.as(); if (binop && binop->left.is() && *binop->left.as() == *assignment.map_access) { ops = opstr(*binop) + "="; rhs = &binop->right; expr = format(binop->right, metadata, max_width - (map.width() + 2 + ops.size()), true); } else { ops = "="; expr = format(assignment.expr, metadata, max_width - (map.width() + 2 + ops.size()), true); } auto buffer = Buffer().append(std::move(map)).text(" ").text(ops).text(" "); bool align = !(rhs->is() || rhs->is()); return buffer.append(std::move(expr), 0, align).text(";"); } Buffer Formatter::visit(AssignVarStatement& assignment) { // N.B. if bare is set, then VarDeclStatement does not include ';'. auto var = format(assignment.var_decl, metadata, max_width, true); Buffer expr; // Is this a compound operator? std::string ops; Expression* rhs = &assignment.expr; auto* binop = assignment.expr.as(); if (binop && binop->left.is() && *binop->left.as() == *assignment.var()) { ops = opstr(*binop) + "="; rhs = &binop->right; expr = format(binop->right, metadata, max_width - (var.width() + 2 + ops.size()), true); } else { ops = "="; expr = format(assignment.expr, metadata, max_width - (var.width() + 2 + ops.size()), true); } auto buffer = Buffer().append(std::move(var)).text(" ").text(ops).text(" "); bool align = !(rhs->is() || rhs->is()); return buffer.append(std::move(expr), 0, align).text(";"); } Buffer Formatter::visit(AssignConfigVarStatement& assignment) { return Buffer() .text(assignment.var) .text(" = ") .append(std::visit( [&](auto& v) { using T = std::decay_t; if constexpr (std::is_same_v) { if (v) { return Buffer().text("true"); } else { return Buffer().text("false"); } } else if constexpr (std::is_same_v) { return Buffer().text(std::to_string(v)); } else if constexpr (std::is_same_v) { // Prefer to use a naked identifier for the configuration, // it is rare that we need actual string paths. auto escaped = escape(v); if (escaped == v) { return Buffer().text(v); } else { return Buffer().text("\"" + escaped + "\""); } } }, assignment.value)) .text(";"); } Buffer Formatter::visit(VarDeclStatement& decl) { auto buffer = Buffer().text("let ").append( format(decl.var, metadata, max_width)); if (decl.typeof) { buffer = buffer.text(" : ").append( format(decl.typeof, metadata, max_width)); } if (bare) { return buffer; } return buffer.text(";"); } Buffer Formatter::visit(Unroll& unroll) { auto block = format(*unroll.block, metadata, max_width - 2); return Buffer() .text("unroll (") .append(format(unroll.expr, metadata, max_width - 11)) .text(") {") .append(std::move(block), kIndentWidth) .text("}"); } Buffer Formatter::visit(DiscardExpr& discard) { return Buffer() .text("_ = ") .append(format(discard.expr, metadata, max_width, true)) .text(";"); } Buffer Formatter::visit(Range& range) { Buffer start; if (range.start.is_literal() && mode != FormatMode::Debug) { start = format(range.start, metadata, max_width, true); } else { start = Buffer() .text("(") .append(format(range.start, metadata, max_width - 4, true)) .text(")"); } Buffer end; if (range.end.is_literal() && mode != FormatMode::Debug) { end = format(range.end, metadata, max_width, true); } else { end = Buffer() .text("(") .append(format(range.end, metadata, max_width - 4, true)) .text(")"); } // For simplicity, never split the range. return Buffer().append(std::move(start)).text("..").append(std::move(end)); } Buffer Formatter::visit(For& for_loop) { return Buffer() .text("for ") .append(format(for_loop.decl, metadata, max_width)) .text(" : ") .append(format(for_loop.iterable, metadata, max_width)) .text(" {") .append(format(*for_loop.block, metadata, max_width - kIndentWidth), kIndentWidth) .text("}"); } Buffer Formatter::visit(Config& config) { if (config.stmts.empty()) { return Buffer().text("config = {}"); } else { auto block = Buffer(); for (auto& stmt : config.stmts) { if (block.lines() > 0) { block = block.line_break(); } block = block.append(format(stmt, metadata, max_width - kIndentWidth)); } return Buffer() .text("config = {") .append(std::move(block), kIndentWidth) .text("}"); } } Buffer Formatter::visit(Jump& jump) { switch (jump.ident) { case JumpType::RETURN: if (jump.return_value) { return Buffer() .text("return ") .append(format(*jump.return_value, metadata, true)) .text(";"); } else { return Buffer().text("return").text(";"); } case JumpType::BREAK: return Buffer().text("break;"); case JumpType::CONTINUE: return Buffer().text("continue;"); } __builtin_unreachable(); } Buffer Formatter::visit(AttachPoint& ap) { // The attachpoints can unfortunately contain all kinds of weirdness, and // have a specialized lexer that is separate from the normal parser process. // This lexer is applied *after* expanding the provider, so we at least // normalize that. However, the best thing to do here is just emit the // original raw string, which should contain quotes and everything needed. return Buffer().text(ap.raw_input); } Buffer Formatter::visit(Probe& probe) { // Emit all attachpoints with their respective comments. These are both // top-level statements and require a separator. If the user has them // specified inline, they will be preserved in that way. std::vector aps; for (size_t i = 0; i < probe.attach_points.size(); i++) { auto buffer = format(probe.attach_points[i], metadata, (i < probe.attach_points.size() - 1) ? max_width - 1 : max_width); if (i < probe.attach_points.size() - 1) { buffer = buffer.text(","); } aps.emplace_back(std::move(buffer)); } // Match the parsed predicate pattern, and format appropriately. MetadataIndex pred_metadata; MetadataIndex block_metadata; std::optional pred; Buffer block; auto* if_expr = probe.block->expr.as(); if (if_expr && probe.block->stmts.empty() && if_expr->left.is() && if_expr->right.is()) { auto* block_expr = if_expr->left.as(); pred_metadata = metadata.before(if_expr->cond.node().loc->current.begin); pred.emplace(format(if_expr->cond, metadata, max_width, true)); block_metadata = metadata.before(block_expr->loc->current.begin); block = format(*block_expr, metadata, max_width - 2); } else { block_metadata = metadata.before(probe.block->loc->current.begin); block = format(*probe.block, metadata, max_width - 2); } auto buffer = Buffer(); for (auto& buf : aps) { buffer = buffer.append(std::move(buf)).line_break(); } if (pred) { buffer = buffer.metadata(pred_metadata) .text("/") .append(std::move(*pred)) .text("/") .line_break(); } buffer = buffer.metadata(block_metadata) .text("{") .append(std::move(block), kIndentWidth) .text("}"); return buffer; } Buffer Formatter::visit(SubprogArg& arg) { return Buffer() .text(arg.var->ident) .text(" : ") .append(format(arg.typeof, metadata, max_width - (arg.var->ident.size() + 3))); } Buffer Formatter::visit(Subprog& subprog) { auto block_metadata = metadata.before(subprog.block->loc->current.begin); auto return_buffer = format(subprog.return_type, metadata, max_width - (subprog.name.size() + 7)); auto args_buffer = format_list( subprog.args, ", ", metadata, max_width - (subprog.name.size() + 5)); auto block_buffer = format(subprog.block, metadata, max_width - kIndentWidth); Buffer decl; if (args_buffer.lines() > 1 || (args_buffer.width() + return_buffer.width() + 12) > max_width) { // Does not fit on a single line, use the multi-line format. decl = Buffer() .text("fn ") .text(subprog.name) .text("(") .append(std::move(args_buffer), kIndentWidth) .text(") : ") .append(std::move(return_buffer)); } else { // Fit the function declaration on a single line. decl = Buffer() .text("fn ") .text(subprog.name) .text("(") .append(std::move(args_buffer)) .text(") : ") .append(std::move(return_buffer)); } return decl.metadata(block_metadata) .line_break() .text("{") .append(std::move(block_buffer), kIndentWidth) .text("}"); } Buffer Formatter::visit(RootImport& imp) { return Buffer().text("import \"").text(imp.name).text("\";"); } Buffer Formatter::visit(StatementImport& imp) { return Buffer().text("import \"").text(imp.name).text("\";"); } Buffer Formatter::visit(BlockExpr& block) { // Blocks must be handled special, either when they are known // (e.g. there is a direct BlockExpr pointer), or when they are // generic expressions (see handling in Expression& formatter). auto buffer = Buffer(); for (size_t i = 0; i < block.stmts.size(); i++) { auto stmt_buffer = format(block.stmts[i], metadata, max_width); if (stmt_buffer.width() > 0 && i > 0) { buffer = buffer.line_break(); } buffer = buffer.append(std::move(stmt_buffer)); } // If there is an expression, we tack it on. auto extra_metadata = metadata.before(block.loc->current.end); if (!block.expr.is()) { // Since this expression appears in a block, we can pull any expression // related comments forward and print them as multiline comments. auto expr_metadata = extra_metadata.before( block.expr.node().loc->current.begin); auto expr = format(block.expr, extra_metadata, max_width, true); // Join the rest of remaining metadata. buffer = buffer.metadata(expr_metadata, buffer.lines() > 0 ? 1 : 0); buffer = buffer.append(std::move(expr)); // There's already vspace built-in to the expression, so we just print // any trailing comment without additional vspace. return buffer.metadata(extra_metadata); } else { // If there's anything left in the metadata, we need to add it. These are // effectively trailing comments in the block, potentially with vspace. return buffer.metadata(extra_metadata); } } Buffer Formatter::visit(Comptime& comptime) { auto expr = format(comptime.expr, metadata, max_width - 9); return Buffer().text("comptime ").append(std::move(expr)); } Buffer Formatter::visit(RootStatement& root) { // Pull out all comments ahead of the block itself. auto comments = metadata.before(root.node().loc->current.begin); auto buffer = format(root.value, metadata, max_width); return Buffer().metadata(comments, 0).append(std::move(buffer)).line_break(); } Buffer Formatter::visit(Program& program) { auto buffer = Buffer(); if (program.header && !program.header->empty()) { buffer = buffer.text(*program.header).line_break(); } // We preserve the order of all the top-level statements. By using // this map, we will iterate through them in order. The parser can // support strict ordering if it likes, but for printing we want to // ensure that we are respecting the original source order. std::map top_level; if (program.config != nullptr) { top_level.emplace(program.config->loc->current, program.config); } for (auto* import : program.imports) { top_level.emplace(import->loc->current, import); } for (auto* cstmt : program.c_statements) { top_level.emplace(cstmt->loc->current, cstmt); } for (auto* map_decl : program.map_decls) { top_level.emplace(map_decl->loc->current, map_decl); } for (auto* function : program.functions) { top_level.emplace(function->loc->current, function); } for (auto* probe : program.probes) { top_level.emplace(probe->loc->current, probe); } for (auto* macro : program.macros) { top_level.emplace(macro->loc->current, macro); } for (auto& [_, entry] : top_level) { // Extract the full metadata, and then format the buffer with that // metadata. Anything left is the preceeding comment, and will be // printed first to the buffer. auto pre_metadata = metadata.before(entry.node().loc->current.begin); auto local_buffer = format(entry, metadata, max_width); buffer = buffer.metadata(std::move(pre_metadata), 0) .append(std::move(local_buffer)); } // It's possible that there are trailing comments, not associated with any // macros, probes or functions. Include these at the end, where they were. buffer = buffer.metadata(std::move(metadata), 0); return buffer; } Buffer Formatter::visit(Macro& macro) { auto args = format_list(macro.vargs, ", ", metadata, max_width - 10, true); auto block_metadata = metadata.before(macro.block->loc->current.begin); auto block = format(*macro.block, metadata, max_width - kIndentWidth); return Buffer() .text("macro ") .text(macro.name) .text("(") .append(std::move(args)) .text(")") .metadata(block_metadata, 1) .text("{") .append(std::move(block), kIndentWidth) .text("}"); } Buffer Formatter::visit(Statement& stmt) { // Special case: do nothing for no-op statements. This is because the // none expression will print nothing, and we always end the statement // with a line break, which we don't want to happen in that case. if (stmt.is() && stmt.as()->expr.is()) { return {}; } // Pull out any leading comments for the statement and make them block // comments. Otherwise they will end up as inline comments. auto comments = metadata.before(stmt.loc()->current.begin); auto buffer = format(stmt.value, metadata, max_width); return Buffer().metadata(comments, 0).append(std::move(buffer)); } Buffer Formatter::visit(While& while_block) { auto cond = format(while_block.cond, metadata, max_width - 8); auto block = format(*while_block.block, metadata, max_width - 2); return Buffer() .text("while ") .append(std::move(cond)) .text(" {") .append(std::move(block), kIndentWidth) .text("}"); } Buffer Formatter::visit(ExprStatement& expr) { auto buffer = format(expr.expr, metadata, max_width, true); if (!expr.expr.is() && !expr.expr.is()) { return buffer.text(";"); } else { return buffer; } } Buffer Formatter::visit(Expression& expr) { auto local_metadata = metadata.before(expr.node().loc->current.end); // Note that tuples may only be bare in map access keys. bool bare_okay = (bare && !expr.is()) || (is_primitive(expr) && mode != FormatMode::Debug); size_t local_width = max_width - (bare_okay ? 0 : 2); Buffer buffer; if (!bare_okay) { buffer = buffer.text("("); } if (expr.is()) { // For a block expression, we determine whether this can be // suitable represented as a single line or whether this needs // to be split into its own scope with multiple lines. auto block = format( *expr.as(), local_metadata, max_width - 2, true); if (block.lines() > 1 || block.width() > local_width) { buffer = buffer.text("{").append(std::move(block), kIndentWidth).text("}"); } else { buffer = buffer.text("{ ").append(std::move(block)).text(" }"); } } else { // For other expressions, we determine if we can represent these // unambiguously without parentheses, otherwise they are added. buffer = buffer.append( format(expr.value, local_metadata, local_width, true)); } if (mode == FormatMode::Debug) { assert(type_map != nullptr); // Don't count this in the width; it's debug mode. buffer = buffer.comment(typestr(type_map->type(expr))); } if (bare_okay) { return buffer; } return buffer.text(")"); } Buffer Formatter::visit(NamedArgument& named_arg) { Buffer elem; // -1 for the equals size_t width = max_width - named_arg.name.size() - 1; auto elem_buf = format(named_arg.expr, metadata, width); elem = Buffer().text(named_arg.name).text("=").append(std::move(elem_buf)); return elem; } Buffer Formatter::visit(const ParsedType& type) { switch (type.kind) { case ParsedType::Kind::Identifier: case ParsedType::Kind::Struct: case ParsedType::Kind::Union: case ParsedType::Kind::Enum: return Buffer().text(type.type_name()); case ParsedType::Kind::Pointer: if (!type.inner) { return {}; } return format(*type.inner, metadata, max_width, bare).text("*"); case ParsedType::Kind::Array: { if (!type.inner) { return {}; } auto buffer = format(*type.inner, metadata, max_width, bare).text("["); if (type.array_size != 0) { buffer = std::move(buffer).text(std::to_string(type.array_size)); } return std::move(buffer).text("]"); } } return {}; } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/printer.h000066400000000000000000000125641526721631600201200ustar00rootroot00000000000000#pragma once #include #include #include "ast/visitor.h" namespace bpftrace::ast { class TypeMap; // BufferState is an internal type. struct BufferState; // Buffer is an internal type for output construction. class Buffer { public: Buffer(); ~Buffer(); Buffer(Buffer &&) = default; Buffer &operator=(Buffer &&) = default; Buffer(const Buffer &) = delete; Buffer &operator=(const Buffer &) = delete; [[nodiscard]] Buffer &&append(Buffer &&other, size_t indent = 0, bool align = true); [[nodiscard]] Buffer &&text(std::string str); [[nodiscard]] Buffer &&metadata( MetadataIndex metadata, std::optional min_vspace = std::nullopt); [[nodiscard]] Buffer &&comment(std::string str); [[nodiscard]] Buffer &&line_break(); size_t width() const; size_t lines() const; private: std::unique_ptr state; friend std::ostream &operator<<(std::ostream &out, const Buffer &buffer); }; // Buffer is directly printable, used below. std::ostream &operator<<(std::ostream &out, const Buffer &buffer); // Control how types should be formatted. enum FormatMode { Minimal, // Only probes, no comments or spacing. Full, // Print with full comments and spacing. Debug, // Print with no comments, spacing but full types. }; // Generic class for printing AST nodes. class Formatter : public Visitor { public: Formatter(FormatMode mode, MetadataIndex &metadata, size_t max_width, bool bare = false, const TypeMap *type_map = nullptr) : mode(mode), metadata(metadata), max_width(max_width), bare(bare), type_map(type_map) {}; using Visitor::visit; Buffer visit(Integer &integer); Buffer visit(NegativeInteger &integer); Buffer visit(Boolean &boolean); Buffer visit(PositionalParameter ¶m); Buffer visit(PositionalParameterCount ¶m); Buffer visit(String &string); Buffer visit(None &none); Buffer visit(Builtin &builtin); Buffer visit(Identifier &identifier); Buffer visit(ParsedType &type); Buffer visit(Variable &var); Buffer visit(VariableAddr &var_addr); Buffer visit(SubprogArg &subprog_arg); Buffer visit(AttachPoint &ap); Buffer visit(Call &call); Buffer visit(Sizeof &szof); Buffer visit(Offsetof &ofof); Buffer visit(TypeArg &type_arg); Buffer visit(Typeof &typeof); Buffer visit(Typeinfo &typeinfo); Buffer visit(Comptime &comptime); Buffer visit(MapDeclStatement &decl); Buffer visit(Map &map); Buffer visit(MapAddr &map_addr); Buffer visit(Binop &binop); Buffer visit(Unop &unop); Buffer visit(IfExpr &if_expr); Buffer visit(FieldAccess &acc); Buffer visit(ArrayAccess &arr); Buffer visit(TupleAccess &acc); Buffer visit(MapAccess &acc); Buffer visit(Cast &cast); Buffer visit(Tuple &tuple); Buffer visit(Record &record); Buffer visit(ExprStatement &expr); Buffer visit(AssignScalarMapStatement &assignment); Buffer visit(AssignMapStatement &assignment); Buffer visit(AssignVarStatement &assignment); Buffer visit(AssignConfigVarStatement &assignment); Buffer visit(VarDeclStatement &decl); Buffer visit(Jump &jump); Buffer visit(Unroll &unroll); Buffer visit(DiscardExpr &discard); Buffer visit(While &while_block); Buffer visit(Range &range); Buffer visit(For &for_loop); Buffer visit(Probe &probe); Buffer visit(Config &config); Buffer visit(BlockExpr &block); Buffer visit(Macro ¯o); Buffer visit(Subprog &subprog); Buffer visit(RootImport &imp); Buffer visit(StatementImport &imp); Buffer visit(Program &program); Buffer visit(Expression &expr); Buffer visit(Statement &stmt); Buffer visit(RootStatement &root); Buffer visit(CStatement &cstmt); Buffer visit(NamedArgument &named_arg); Buffer visit(const ParsedType &type); private: template Buffer format(U &value, MetadataIndex &metadata, size_t max_width, bool bare = false) { return Formatter(mode, metadata, max_width, bare, type_map).visit(value); } Buffer format_expr_as_type(Expression &expr, size_t max_width); Buffer format_type_arg(ExprOrType &record, size_t max_width); template Buffer format_list(std::vector &exprs, const std::string &sep, MetadataIndex &metadata, size_t max_width, bool bare = false); FormatMode mode; MetadataIndex &metadata; size_t max_width; bool bare; const TypeMap *type_map; }; // Printer is a class to format AST nodes of type T. class Printer : Visitor { public: constexpr static size_t kDefaultWidth = 90; Printer(const ASTContext &ast, std::ostream &out, FormatMode mode = FormatMode::Minimal, size_t max_width = kDefaultWidth, const TypeMap *type_map = nullptr) : ast_(ast), out_(out), mode_(mode), max_width_(max_width), type_map_(type_map) {}; template void visit(T &value) { MetadataIndex metadata = ast_.metadata(); out_ << Formatter(mode_, metadata, max_width_, true, type_map_).visit(value); } private: const ASTContext &ast_; std::ostream &out_; FormatMode mode_; size_t max_width_; const TypeMap *type_map_; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/probe_prune.cpp000066400000000000000000000020651526721631600213030ustar00rootroot00000000000000#include "ast/passes/probe_prune.h" #include "ast/ast.h" #include "bpftrace.h" namespace bpftrace::ast { Pass CreateProbePrunePass() { static std::string missing_msg = " has no valid attach points."; return Pass::create("ProbePrune", [](ASTContext &ast, BPFtrace &b) { auto missing_config = b.config_->missing_probes; for (Probe *probe : ast.root->probes) { if (probe->attach_points.empty()) { if (missing_config == ConfigMissingProbes::error) { probe->addError() << "Probe" << missing_msg << " If this is expected, set the 'missing_probes' " "config variable to 'warn'."; } else if (missing_config == ConfigMissingProbes::warn) { probe->addWarning() << "Probe" << missing_msg << " It is being removed which may cause issues with " "program behavior."; } } }; if (missing_config != ConfigMissingProbes::error) { ast.root->clear_empty_probes(); } }); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/probe_prune.h000066400000000000000000000002031526721631600207400ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateProbePrunePass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/recursion_check.cpp000066400000000000000000000060001526721631600221220ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/passes/attachpoint_passes.h" #include "ast/passes/recursion_check.h" #include "ast/visitor.h" #include "bpftrace.h" #include "log.h" #include "probe_matcher.h" namespace bpftrace::ast { namespace { const std::unordered_set RECURSIVE_KERNEL_FUNCS = { "vmlinux:_raw_spin_lock", "vmlinux:_raw_spin_lock_irqsave", "vmlinux:_raw_spin_unlock_irqrestore", "vmlinux:queued_spin_lock_slowpath", }; // Attaching to these kernel functions with fentry/fexit (kfunc/kretfunc) // could lead to a recursive loop and kernel crash so we need additional // generated BPF code to protect against this if one of these are being // attached to. bool is_recursive_func(const std::string &func_name) { return RECURSIVE_KERNEL_FUNCS.contains(func_name); } class RecursionCheck : public Visitor { public: explicit RecursionCheck(BPFtrace &bpftrace, FunctionInfo &func_info) : bpftrace_(bpftrace), func_info_(func_info) { } using Visitor::visit; void visit(Program &program); private: BPFtrace &bpftrace_; FunctionInfo &func_info_; }; } // namespace // This prevents an ABBA deadlock when attaching to spin lock internal // functions e.g. "fentry:queued_spin_lock_slowpath". // // Specifically, if there are two hash maps (non percpu) being accessed by // two different CPUs by two bpf progs then we can get in a situation where, // because there are progs attached to spin lock internals, a lock is taken for // one map while a different lock is trying to be acquired for the other map. // This is specific to fentry/fexit (kfunc/kretfunc) as kprobes have kernel // protections against this type of deadlock. // // Note: it would be better if this was in resource analyzer but we need // probe_matcher to get the list of functions for the attach point. void RecursionCheck::visit(Program &program) { ProbeMatcher probe_matcher(&bpftrace_, func_info_.kernel_info(), func_info_.user_info()); for (auto *probe : program.probes) { for (auto *ap : probe->attach_points) { auto probe_type = probetype(ap->provider); if (probe_type == ProbeType::fentry || probe_type == ProbeType::fexit) { auto matches = probe_matcher.get_matches_for_ap(*ap); for (const auto &match : matches) { if (is_recursive_func(match)) { LOG(WARNING) << "Attaching to dangerous function: " << match << ". bpftrace has added mitigations to prevent a kernel " "deadlock but they may result in some lost events."; bpftrace_.need_recursion_check_ = true; return; } } } } } } Pass CreateRecursionCheckPass() { return Pass::create( "RecursionCheck", [](ASTContext &ast, BPFtrace &b, FunctionInfo &func_info) { auto recursion_check = RecursionCheck(b, func_info); recursion_check.visit(ast.root); }); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/recursion_check.h000066400000000000000000000002071526721631600215720ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateRecursionCheckPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/resolve_imports.cpp000066400000000000000000000461361526721631600222260ustar00rootroot00000000000000#include #include #include #include #include "ast/passes/resolve_imports.h" #include "ast/visitor.h" #include "log.h" #include "parser.h" #include "stdlib/stdlib.h" #include "util/result.h" #include "util/similar.h" #include "util/strings.h" namespace bpftrace::ast { using bpftrace::stdlib::Stdlib; static constexpr auto INTERNAL_BT = "stdlib/internal.bt"; class ResolveRootImports : public Visitor { public: ResolveRootImports(Imports &imports, const std::vector &paths = {}) : imports_(imports), paths_(paths) {}; using Visitor::visit; void visit(RootImport &imp); private: Imports &imports_; const std::vector &paths_; }; class ResolveStdlibMacroImports : public Visitor { public: ResolveStdlibMacroImports( Imports &imports, std::optional source_macro_name, const std::vector &paths = {}) : imports_(imports), source_macro_name_(std::move(source_macro_name)), paths_(paths) {}; using Visitor::visit; void visit(Expression &expr); void visit(Macro ¯o); private: Imports &imports_; std::optional source_macro_name_; const std::vector &paths_; }; class ResolveStatementImports : public Visitor { public: ResolveStatementImports(Imports &imports, const std::vector &paths = {}) : imports_(imports), paths_(paths) {}; using Visitor::visit; void visit(StatementImport &imp); private: Imports &imports_; const std::vector &paths_; }; static bool check_permissions(const std::filesystem::path &path) { auto check_one = [](const std::filesystem::path &path) { auto status = std::filesystem::status(path); auto permissions = status.permissions(); return (permissions & std::filesystem::perms::others_write) == std::filesystem::perms::none; }; if (!check_one(path)) { return false; } if (path.parent_path().empty()) { return check_one("."); } else { return check_one(path.parent_path()); } } // Parses a script into the scripts map and returns a pointer to its // ASTContext, or nullptr if already imported. static Result import_bt_file( Node &node, const std::string &name, std::string data, bool internal, std::map &scripts) { if (scripts.contains(name)) { return nullptr; } auto [it, added] = scripts.emplace( name, ScriptObject(node, ASTContext(name, std::move(data)), internal)); assert(added); auto &ast = it->second.ast; PassManager pm; pm.put(ast); pm.add(CreateParsePass()); auto ok = pm.run(); if (!ok) { return ok.takeError(); } return * } static Result import_script(Node &node, Imports &imports, const std::string &name, const std::string &&data, const std::vector &paths, std::map &contents, bool internal) { auto result = import_bt_file(node, name, data, internal, contents); if (!result) { return result.takeError(); } if (*result == nullptr) { return OK(); } auto &ast = **result; // Disallow `config` blocks as they cannot be merged. if (ast.root != nullptr && ast.root->config != nullptr && !ast.root->config->stmts.empty()) { ast.root->config->addError() << "invalid `config` within import"; } // Recursively visit the parsed tree. ResolveRootImports resolver(imports, paths); resolver.visit(ast.root); // Check for stdlib macro references in the imported script. ResolveStdlibMacroImports macro_resolver(imports, std::nullopt, paths); macro_resolver.visit(ast.root); return OK(); } static Result import_script(Node &node, Imports &imports, const std::string &name, const std::filesystem::path &path, const std::vector &paths, std::map &contents) { if (contents.contains(name)) { return OK(); // Already added. } // Load the file. std::ifstream file(path); if (file.fail()) { node.addError() << "error reading import '" << path << "': " << std::strerror(errno); return OK(); } std::stringstream buf; buf << file.rdbuf(); return import_script(node, imports, name, buf.str(), paths, contents, false); } static Result import_object(Node &node, const std::string &name, const std::filesystem::path &path, std::map &contents) { if (contents.contains(name)) { return OK(); // Already added. } auto added = contents.emplace(name, ExternalObject(node, path)).second; assert(added); return OK(); } static Result import_c(Node &node, const std::string &name, const std::filesystem::path &path, std::map &contents) { if (contents.contains(name)) { return OK(); // Already added. } // Load the file. std::ifstream file(path); if (file.fail()) { node.addError() << "error reading import '" << path << "': " << std::strerror(errno); return OK(); } std::stringstream buf; buf << file.rdbuf(); auto [_, added] = contents.emplace(name, LoadedObject(node, buf.str())); assert(added); return OK(); } static Result import_c(Node &node, const std::string &name, const std::string_view &data, std::map &contents) { if (contents.contains(name)) { return OK(); // Already added. } auto [_, added] = contents.emplace(name, LoadedObject(node, data)); assert(added); return OK(); } Result Imports::import_any(Node &node, const std::string &name, const std::filesystem::path &path, const std::vector &paths, bool ignore_unknown, bool allow_directories) { if (!check_permissions(path)) { node.addError() << "cowardly refusing to import from a directory with " "global write permissions: " << path; return OK(); } if (std::filesystem::is_directory(path)) { // If `recurse` is not set, just ignore this directory. if (!allow_directories) { return OK(); } // Recursively import all entries in the directory. Note that the directory // iterator will never include '.' or '..' entries. for (const auto &entry : std::filesystem::directory_iterator(path)) { auto ok = import_any(node, name + "/" + entry.path().filename().string(), entry.path(), paths, true, false); if (!ok) { return ok.takeError(); } } return OK(); } else { // Import any support file-based extensions. if (path.extension() == ".bt") { return import_script(node, *this, name, path, paths, scripts); } else if (path.extension() == ".c" && path.stem().extension() == ".bpf") { return import_c(node, name, path, c_sources); } else if (path.extension() == ".h") { return import_c(node, name, path, c_headers); } else if (path.extension() == ".o" && path.stem().extension() == ".bpf") { return import_object(node, name, path, objects); } else if (!ignore_unknown) { node.addError() << "unknown import type: " << path.filename(); } return OK(); } } Result Imports::import_any(Node &node, const std::string &name, const std::string_view &data, const std::vector &paths, bool ignore_unknown) { // Import supported extensions. std::filesystem::path path(name); if (path.extension() == ".bt") { return import_script( node, *this, name, std::string(data), paths, scripts, true); } else if (path.extension() == ".c" && path.stem().extension() == ".bpf") { return import_c(node, name, data, c_sources); } else if (path.extension() == ".h") { return import_c(node, name, data, c_headers); } else if (!ignore_unknown) { node.addError() << "unknown import type: " << path; } return OK(); } static void mark_stdlib_macros(ASTContext &ast) { if (!ast.root) { return; } for (auto *macro : ast.root->macros) { macro->is_stdlib = true; } } Result Imports::import_stdlib( Node &node, const std::string &name, const std::string_view &data, const std::string ¯o_name, const std::vector &paths) { if (has_external_stdlib_override_ && name != INTERNAL_BT) { return OK(); } if (seen_stdlib_macros_.contains(macro_name)) { return OK(); } seen_stdlib_macros_.insert(macro_name); auto result = import_bt_file(node, name, std::string(data), true, scripts); if (!result) { return result.takeError(); } if (*result == nullptr) { // Even though we imported and parsed the stdlib file, we may still need to // resolve other nested macros auto found = scripts.find(name); if (found != scripts.end()) { ResolveStdlibMacroImports resolver(*this, macro_name, paths); auto &ast = found->second.ast; resolver.visit(ast.root); } return OK(); } auto &ast = **result; mark_stdlib_macros(ast); ResolveStdlibMacroImports resolver(*this, macro_name, paths); resolver.visit(ast.root); return OK(); } Result Imports::import_any(Node &node, const std::string &name, const std::vector &paths) { // Prevent direct re-importation of the same top-level name. This is used // because the name may match against directories or internal packages which // contain different files. if (packages_.contains(name)) { return OK(); } packages_.emplace(name); std::vector checked; for (const auto &import_path : paths) { // Check to see if this specific file exists. auto path = import_path / name; checked.emplace_back(path.string()); std::error_code ec; if (!std::filesystem::exists(path, ec)) { continue; // No file found. } // For loading anything from the filesystem, ensure that the name import // is not inside a globally writable directory. Note that we log this as // a warning for a search, which is different than the case where the // path is imported explicitly. if (!check_permissions(path)) { node.addWarning() << "skipping due to global write permissions: " << path; continue; } // Attempt the import. return import_any(node, name, path, paths, false, true); } // See if this matches a set of builtins. Note that we do the "directory" // expansion here, importing anything that is matching as a path. bool found = false; std::vector similar; // This automatically imports c files from the stdlib but not bpftrace (bt) // files so we don't have to always re-parse the entire stdlib library for // every script invocation for (const auto &[internal_path, s] : Stdlib::c_files) { auto path = std::filesystem::path(internal_path); if (path.string() == name) { return import_any(node, name, s, paths, false); } else if (path.parent_path().string() == name) { auto ok = import_any(node, path.string(), s, paths, true); if (!ok) { return ok.takeError(); } // As long as we found at least one import that matched the standard // library paths, then we call it a victory. found = true; } if (util::is_similar(name, internal_path)) { similar.push_back(internal_path); } } if (found) { return OK(); } // Unable to find a suitable import. auto &err = node.addError(); err << "Unable to find suitable path for import"; if (!checked.empty()) { err.addHint() << "checked: " << util::str_join(checked, ","); } if (!similar.empty()) { err.addHint() << "similar to builtins: " << util::str_join(similar, ","); } return OK(); } void ResolveStatementImports::visit(StatementImport &imp) { static std::string import_error = "Import statements that are not at the root are limited to specific " "object (.o), header (.h), or C source (.c or bpf.c) files"; std::filesystem::path path(imp.name); if (std::filesystem::is_directory(path)) { imp.addError() << import_error; } else if (path.extension() == ".bt") { imp.addError() << import_error; } auto ok = imports_.import_any(imp, imp.name, paths_); if (!ok) { imp.addError() << "import error: " << ok.takeError(); } } void ResolveRootImports::visit(RootImport &imp) { if (imp.name == "stdlib") { // If an explicit root import resolves to a filesystem stdlib package, // treat it as an override before importing its files so later // conditional stdlib bt imports do not mix in embedded stdlib scripts. for (const auto &import_path : paths_) { auto path = import_path / imp.name; std::error_code ec; if (!std::filesystem::exists(path, ec)) { continue; } if (!check_permissions(path)) { continue; } if (std::filesystem::is_directory(path)) { imports_.mark_external_stdlib_override(); } break; } } auto ok = imports_.import_any(imp, imp.name, paths_); if (!ok) { imp.addError() << "import error: " << ok.takeError(); } } void ResolveStdlibMacroImports::visit(Macro ¯o) { if (!source_macro_name_ || macro.name == *source_macro_name_) { visit(macro.block); } } void ResolveStdlibMacroImports::visit(Expression &expr) { auto *ident = expr.as(); auto *call = expr.as(); if (!ident && !call) { Visitor::visit(expr); return; } if (call) { visit(call->vargs); } const std::string &possible_macro_name = ident ? ident->ident : call->func; auto found = Stdlib::macro_to_file.find(possible_macro_name); if (found == Stdlib::macro_to_file.end()) { return; } auto found_files_entry = Stdlib::bt_files.find(found->second); if (found_files_entry == Stdlib::bt_files.end()) { LOG(BUG) << found->second << " should be also in Stdlib::bt_files"; return; } auto ok = imports_.import_stdlib(expr.node(), found->second, found_files_entry->second, possible_macro_name, paths_); if (!ok) { LOG(BUG) << "import error: " << ok.takeError(); } } Pass CreateResolveRootImportsPass(std::vector &&import_paths) { return Pass::create("ResolveRootImports", [import_paths](ASTContext &ast) -> Result { Imports imports; // Add the source location as a primary path. const auto &filename = ast.source()->filename; std::vector updated_paths; updated_paths.emplace_back( std::filesystem::path(filename).parent_path()); // Add all additional paths. for (const auto &path : import_paths) { updated_paths.emplace_back(path); } ResolveRootImports analyser(imports, updated_paths); analyser.visit(ast.root); // Let's pull in stdlib bt files as needed by the script // itself ResolveStdlibMacroImports macro_analyser(imports, std::nullopt, updated_paths); macro_analyser.visit(ast.root); // Ensure that the essential part of the standard // library is imported. All other parts of the standard // library are conditionally imported based on inlined // import statements. The implicit import is only // permitted from the embedded standard library. // Overriding this is possible, but it must be // explicitly imported. auto ok = imports.import_any(*ast.root, "stdlib"); if (!ok) { return ok.takeError(); } // This is the only stdlib bt script we import // unconditionally because it contains macro calls that // are created in future passes auto internal = Stdlib::bt_files.find(INTERNAL_BT); if (internal != Stdlib::bt_files.end()) { ok = imports.import_stdlib(*ast.root, INTERNAL_BT, internal->second, INTERNAL_BT, updated_paths); if (!ok) { return ok.takeError(); } } return imports; }); } // This is primarily for the standard library so we can conditionally // import specific bpf.c files instead of importing, compiling, and type // processing all of the stdlib bpf.c files which increase start up latency // and also possibly create/allocate unused maps Pass CreateResolveStatementImportsPass() { return Pass::create("ResolveStatementImports", [](ASTContext &ast, Imports &imports) { // Add the source location as a primary path. const auto &filename = ast.source()->filename; std::vector updated_paths; updated_paths.emplace_back( std::filesystem::path(filename).parent_path()); ResolveStatementImports analyser(imports, updated_paths); analyser.visit(ast.root); }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/resolve_imports.h000066400000000000000000000100551526721631600216620ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include "ast/context.h" #include "ast/pass_manager.h" namespace bpftrace::ast { // LoadedObject is a generic wrapper around some data that was either embedded, // or has been loaded off the filesystem. We no longer depend on any files. class LoadedObject { public: LoadedObject(Node &node, const std::string_view &data) : node(node), data_(data) {}; LoadedObject(Node &node, std::string &&data) : node(node), data_(std::move(data)) {}; std::string_view data() { return std::visit([](const auto &v) -> std::string_view { return v; }, data_); } // Original node, for errors. Node &node; private: // The reason for this extra indirection: the data is either owned, // or it will be a reference to something immutable in the binary. const std::variant data_; }; class ExternalObject { public: ExternalObject(Node &node, std::filesystem::path path) : node(node), path(std::move(path)) {}; // Per above, the original node. Node &node; // Objects are left on the filesystem, since these paths are passed directly // to the linker. const std::filesystem::path path; }; class ScriptObject { public: ScriptObject(Node &node, ASTContext &&ast, bool internal) : node(node), ast(std::move(ast)), internal(internal) {}; // Per above, the original node. Node &node; // The parsed source context. ASTContext ast; // Indicates whether or not this came from an internal source (e.g. the // standard library). This may be used by subsequent passes to import/resolve // in different orders or at different times. const bool internal; }; // Imports holds the set of imported modules. This includes the parsed ASTs for // any source files, the loaded module for serialized modules, any dlhandles // for loaded dynamic plugins, and the BPF objects for any binary blobs. class Imports : public ast::State<"imports"> { public: std::map c_sources; std::map c_headers; std::map objects; std::map scripts; // Public import calls. Result import_any(Node &node, const std::string &name, const std::vector &paths = {}); Result import_stdlib(Node &node, const std::string &name, const std::string_view &data, const std::string ¯o_name, const std::vector &paths); void mark_external_stdlib_override() { has_external_stdlib_override_ = true; } private: Result import_any(Node &node, const std::string &name, const std::filesystem::path &path, const std::vector &paths, bool ignore_unknown, bool allow_directories); Result import_any(Node &node, const std::string &name, const std::string_view &data, const std::vector &paths, bool ignore_unknown); // Record full packages/directories that have been imported separately from // the specific modules, in order to avoid re-importing these paths. std::unordered_set packages_; std::unordered_set seen_stdlib_macros_; // An explicit `import "stdlib"` should suppress conditional // imports from the embedded stdlib bt files. // This is a way for users or developers to override the internal stdlib // entirely bool has_external_stdlib_override_ = false; }; // This pass resolves imports from the AST itself. Pass CreateResolveRootImportsPass(std::vector &&import_paths = {}); Pass CreateResolveStatementImportsPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/resource_analyser.cpp000066400000000000000000000610531526721631600225120ustar00rootroot00000000000000#include #include #include "ast/async_event_types.h" #include "ast/codegen_helper.h" #include "ast/passes/map_sugar.h" #include "ast/passes/named_param.h" #include "ast/passes/resource_analyser.h" #include "ast/passes/types/type_map.h" #include "ast/visitor.h" #include "bpftrace.h" #include "log.h" #include "required_resources.h" #include "struct.h" #include "types.h" namespace bpftrace::ast { namespace { // Resource analysis pass on AST // // This pass collects information on what runtime resources a script needs. // For example, how many maps to create, what sizes the keys and values are, // all the async printf argument types, etc. // // TODO(danobi): Note that while complete resource collection in this pass is // the goal, there are still places where the goal is not yet realized. For // example the helper error metadata is still being collected during codegen. class ResourceAnalyser : public Visitor { public: ResourceAnalyser(BPFtrace &bpftrace, MapMetadata &mm, NamedParamInfo &named_param_info, const TypeMap &type_map); using Visitor::visit; void visit(Probe &probe); void visit(Subprog &subprog); void visit(Builtin &builtin); void visit(Call &call); void visit(Cast &cast); void visit(Map &map); void visit(MapAccess &acc); void visit(MapDeclStatement &decl); void visit(Tuple &tuple); void visit(Record &record); void visit(For &f); void visit(IfExpr &if_expr); void visit(AssignMapStatement &assignment); void visit(AssignVarStatement &assignment); void visit(VarDeclStatement &decl); // This will move the compute resources value, it should be called only // after the top-level visit. RequiredResources resources(); private: // Determines whether the given function uses userspace symbol resolution. // This is used later for loading the symbol table into memory. bool uses_usym_table(const std::string &fun); bool exceeds_stack_limit(size_t size); void maybe_allocate_map_key_buffer(const Map &map, const Expression &key_expr); void update_map_info(Map &map); void update_variable_info(Variable &var); RequiredResources resources_; BPFtrace &bpftrace_; MapMetadata map_metadata_; NamedParamInfo &named_param_info_; const TypeMap &type_map_; // Current probe we're analysing Probe *probe_{ nullptr }; std::unordered_map> map_decls_; int next_map_id_ = 0; }; } // namespace ResourceAnalyser::ResourceAnalyser(BPFtrace &bpftrace, MapMetadata &mm, NamedParamInfo &named_param_info, const TypeMap &type_map) : bpftrace_(bpftrace), map_metadata_(mm), named_param_info_(named_param_info), type_map_(type_map) { } RequiredResources ResourceAnalyser::resources() { if (resources_.max_fmtstring_args_size > 0) { resources_.global_vars.add_known(bpftrace::globalvars::FMT_STRINGS_BUFFER); } if (resources_.max_anon_struct_size > 0) { assert(resources_.anon_struct_buffers > 0); resources_.global_vars.add_known(bpftrace::globalvars::ANON_STRUCT_BUFFER); } if (resources_.max_call_stack_size > 0) { assert(resources_.call_stack_buffers > 0); resources_.global_vars.add_known(bpftrace::globalvars::CALL_STACK_BUFFER); } if (resources_.str_buffers > 0) { resources_.global_vars.add_known(bpftrace::globalvars::GET_STR_BUFFER); } if (resources_.max_read_map_value_size > 0) { assert(resources_.read_map_value_buffers > 0); resources_.global_vars.add_known( bpftrace::globalvars::READ_MAP_VALUE_BUFFER); } if (resources_.max_write_map_value_size > 0) { resources_.global_vars.add_known( bpftrace::globalvars::WRITE_MAP_VALUE_BUFFER); } if (resources_.max_variable_size > 0) { assert(resources_.variable_buffers > 0); resources_.global_vars.add_known(bpftrace::globalvars::VARIABLE_BUFFER); } if (resources_.max_map_key_size > 0) { assert(resources_.map_key_buffers > 0); resources_.global_vars.add_known(bpftrace::globalvars::MAP_KEY_BUFFER); } if (resources_.join_value_size > 0) { resources_.global_vars.add_known(bpftrace::globalvars::JOIN_BUFFER); } resources_.global_vars.add_known(bpftrace::globalvars::MAX_CPU_ID); resources_.global_vars.add_known(bpftrace::globalvars::EVENT_LOSS_COUNTER); return std::move(resources_); } void ResourceAnalyser::visit(Probe &probe) { probe_ = &probe; Visitor::visit(probe); } void ResourceAnalyser::visit(Subprog &subprog) { probe_ = nullptr; Visitor::visit(subprog); } void ResourceAnalyser::visit(Builtin &builtin) { if (uses_usym_table(builtin.ident)) { // mark probe as using usym, so that the symbol table can be pre-loaded // and symbols resolved even when unavailable at resolution time resources_.probes_using_usym.insert(probe_); } if (builtin.ident == "__builtin_ncpus") { resources_.global_vars.add_known(bpftrace::globalvars::NUM_CPUS); } else if (builtin.ident == "__builtin_cpid") { resources_.global_vars.add_known(bpftrace::globalvars::CHILD_PID); } else if (builtin.ident == "ustack" || builtin.ident == "kstack" || builtin.ident == "__builtin_dw_ustack") { const auto &ty = type_map_.type(&builtin); if (exceeds_stack_limit(ty.GetSize())) { resources_.call_stack_buffers++; resources_.max_call_stack_size = std::max(resources_.max_call_stack_size, ty.GetSize()); } } else if (builtin.ident == "__builtin_elapsed") { resources_.needs_elapsed_map = true; } } void ResourceAnalyser::visit(Call &call) { Visitor::visit(call); if (call.func == "printf" || call.func == "errorf" || call.func == "warnf" || call.func == "system" || call.func == "cat" || call.func == "debugf") { std::vector args; for (auto it = call.vargs.begin() + 1; it != call.vargs.end(); it++) { args.push_back(type_map_.type(*it)); } // It may seem odd that we're creating a tuple as part of format // string analysis, but it kinda makes sense. When we transmit // the format string from kernelspace to userspace, we are basically // creating a tuple. Namely: a bunch of values without names, back to // back, and with struct alignment rules. // // Thus, we are good to reuse the padding logic present in tuple // creation to generate offsets for each argument in the args "tuple". auto tuple = Struct::CreateTuple(args); // Keep track of max "tuple" size needed for fmt string args. Codegen // will use this information to create a percpu array map of large // enough size for all fmt string calls to use. Note that since this // will end up being aligned differently than the arguments themselves, // we need to ensure that it is aligned to the size of the largest type. uint64_t args_size = sizeof(uint64_t) + static_cast(tuple->size); if (args_size % sizeof(uint64_t) != 0) { args_size += sizeof(uint64_t) - (args_size % sizeof(uint64_t)); } if (exceeds_stack_limit(args_size)) { resources_.max_fmtstring_args_size = std::max( resources_.max_fmtstring_args_size, args_size); } auto fmtstr = call.vargs.at(0).as()->value; if (call.func == "printf") { if (probe_ != nullptr && probe_->get_probetype() == ProbeType::iter) { resources_.bpf_print_fmts_id_map[&call] = resources_.bpf_print_fmts.size(); resources_.bpf_print_fmts.emplace_back(fmtstr); } else { resources_.printf_args_id_map[&call] = resources_.printf_args.size(); resources_.printf_args.emplace_back( fmtstr, tuple->fields, PrintfSeverity::NONE, SourceInfo(call.loc)); } } else if (call.func == "errorf") { resources_.printf_args_id_map[&call] = resources_.printf_args.size(); resources_.printf_args.emplace_back( fmtstr, tuple->fields, PrintfSeverity::ERROR, SourceInfo(call.loc)); } else if (call.func == "warnf") { resources_.printf_args_id_map[&call] = resources_.printf_args.size(); resources_.printf_args.emplace_back( fmtstr, tuple->fields, PrintfSeverity::WARNING, SourceInfo(call.loc)); } else if (call.func == "debugf") { resources_.bpf_print_fmts_id_map[&call] = resources_.bpf_print_fmts.size(); resources_.bpf_print_fmts.emplace_back(fmtstr); } else if (call.func == "system") { resources_.system_args_id_map[&call] = resources_.system_args.size(); resources_.system_args.emplace_back(fmtstr, tuple->fields); } else { resources_.cat_args_id_map[&call] = resources_.cat_args.size(); resources_.cat_args.emplace_back(fmtstr, tuple->fields); } } else if (call.func == "join") { auto delim = call.vargs.size() > 1 ? call.vargs.at(1).as()->value : " "; resources_.join_args_id_map[&call] = resources_.join_args.size(); resources_.join_args.push_back(delim); } else if (call.func == "count" || call.func == "sum" || call.func == "min" || call.func == "max" || call.func == "avg") { resources_.global_vars.add_known(bpftrace::globalvars::NUM_CPUS); } else if (call.func == "hist") { Map *map = call.vargs.at(0).as(); uint64_t bits = call.vargs.at(3).as()->value; auto args = HistogramArgs{ .bits = static_cast(bits), }; auto &map_info = resources_.maps_info[map->ident]; if (std::holds_alternative(map_info.detail)) { map_info.detail.emplace(args); } else if (std::holds_alternative(map_info.detail) && std::get(map_info.detail) == args) { // Same arguments. } else { call.addError() << "Different bits in a single hist unsupported"; } } else if (call.func == "lhist") { Map *map = call.vargs.at(0).as(); Expression &min_arg = call.vargs.at(3); Expression &max_arg = call.vargs.at(4); Expression &step_arg = call.vargs.at(5); auto &min = *min_arg.as(); auto &max = *max_arg.as(); auto &step = *step_arg.as(); auto args = LinearHistogramArgs{ .min = static_cast(min.value), .max = static_cast(max.value), .step = static_cast(step.value), }; auto &map_info = resources_.maps_info[map->ident]; if (std::holds_alternative(map_info.detail)) { map_info.detail.emplace(args); } else if (std::holds_alternative(map_info.detail) && std::get(map_info.detail) == args) { // Same arguments. } else { call.addError() << "Different lhist bounds in a single map unsupported"; } } else if (call.func == "tseries") { Map *map = call.vargs.at(0).as(); Expression &n_arg = call.vargs.at(2); Expression &interval_ns_arg = call.vargs.at(3); Expression &num_intervals_arg = call.vargs.at(4); auto &interval_ns = *interval_ns_arg.as(); auto &num_intervals = *num_intervals_arg.as(); auto args = TSeriesArgs{ .interval_ns = static_cast(interval_ns.value), .num_intervals = static_cast(num_intervals.value), .value_type = type_map_.type(n_arg), .agg = TSeriesAggFunc::none, }; if (call.vargs.size() == 6) { auto &agg_func = *call.vargs.at(5).as(); if (agg_func.value == "avg") { args.agg = TSeriesAggFunc::avg; } else if (agg_func.value == "max") { args.agg = TSeriesAggFunc::max; } else if (agg_func.value == "min") { args.agg = TSeriesAggFunc::min; } else if (agg_func.value == "sum") { args.agg = TSeriesAggFunc::sum; } } auto &map_info = resources_.maps_info[map->ident]; if (std::holds_alternative(map_info.detail)) { map_info.detail.emplace(args); } else if (std::holds_alternative(map_info.detail) && std::get(map_info.detail) == args) { // Same arguments. } else { call.addError() << "Different tseries bounds in a single map unsupported"; } } else if (call.func == "ustack" || call.func == "kstack" || call.func == "__builtin_dw_ustack") { const auto &ty = type_map_.type(&call); if (exceeds_stack_limit(ty.GetSize())) { resources_.call_stack_buffers++; resources_.max_call_stack_size = std::max(resources_.max_call_stack_size, ty.GetSize()); } } else if (call.func == "time") { resources_.time_args_id_map[&call] = resources_.time_args.size(); if (!call.vargs.empty()) resources_.time_args.push_back(call.vargs.at(0).as()->value); else resources_.time_args.emplace_back("%H:%M:%S\n"); } else if (call.func == "strftime") { resources_.strftime_args_id_map[&call] = resources_.strftime_args.size(); resources_.strftime_args.push_back(call.vargs.at(0).as()->value); } else if (call.func == "print") { constexpr auto nonmap_headroom = sizeof(AsyncEvent::PrintNonMap); auto &arg = call.vargs.at(0); if (!arg.is()) { const auto &arg_type = type_map_.type(arg); resources_.non_map_print_args_id_map[&call] = resources_.non_map_print_args.size(); resources_.non_map_print_args.push_back(arg_type); const size_t fmtstring_args_size = nonmap_headroom + arg_type.GetSize(); if (exceeds_stack_limit(fmtstring_args_size)) { resources_.max_fmtstring_args_size = std::max( resources_.max_fmtstring_args_size, fmtstring_args_size); } } } else if (call.func == "cgroup_path") { resources_.cgroup_path_args_id_map[&call] = resources_.cgroup_path_args.size(); if (call.vargs.size() > 1) resources_.cgroup_path_args.push_back( call.vargs.at(1).as()->value); else resources_.cgroup_path_args.emplace_back("*"); } else if (call.func == "skboutput") { resources_.skboutput_args_id_map[&call] = resources_.skboutput_args_.size(); const auto &file = call.vargs.at(0).as()->value; const auto &offset = call.vargs.at(3).as()->value; resources_.skboutput_args_.emplace_back(file, offset); resources_.using_skboutput = true; } if (call.func == "print" || call.func == "clear" || call.func == "zero") { if (auto *map = call.vargs.at(0).as()) { auto &name = map->ident; auto &map_info = resources_.maps_info[name]; if (map_info.id == -1) map_info.id = next_map_id_++; } } if (call.func == "str" || call.func == "buf" || call.func == "path") { const auto max_strlen = bpftrace_.config_->pad_max_strlen(); if (exceeds_stack_limit(max_strlen)) resources_.str_buffers++; } if (call.func == "join") { resources_.join_value_size = offsetof(AsyncEvent::Join, content) + (bpftrace_.join_argnum_ * bpftrace_.join_argsize_); } // These functions, some of which are desugared AssignMapStatements (e.g., // `@a[1, 2, 3] = count(); -> count(@a, (1, 2, 3));`) might require // additional map key scratch buffers because the map key type might be // a slightly different type due to type promotion in an earlier pass. // This requires us to allocate a new map key (or create a scratch buffer) // and copy individual elements of the tuple instead of the whole thing. if (getAssignRewriteFuncs().contains(call.func)) { if (call.func == "lhist" || call.func == "hist" || call.func == "tseries") { auto &map = *call.vargs.at(0).as(); // Allocation is always needed for lhist/hist/tseries but we need to // allocate space for both map key and the bucket ID from a call to // linear/log2/tseries functions. const auto map_key_size = type_map_.map_key_type(map.ident).GetSize() + CreateUInt64().GetSize(); if (exceeds_stack_limit(map_key_size)) { resources_.map_key_buffers++; resources_.max_map_key_size = std::max(resources_.max_map_key_size, map_key_size); } } else { maybe_allocate_map_key_buffer(*call.vargs.at(0).as(), call.vargs.at(1)); } } if (uses_usym_table(call.func)) { // mark probe as using usym, so that the symbol table can be pre-loaded // and symbols resolved even when unavailable at resolution time resources_.probes_using_usym.insert(probe_); } } void ResourceAnalyser::visit(Cast &cast) { Visitor::visit(cast); const auto &ty = type_map_.type(&cast); if (ty.IsStringTy()) { const auto max_strlen = bpftrace_.config_->pad_max_strlen(); if (exceeds_stack_limit(max_strlen)) resources_.str_buffers++; } } void ResourceAnalyser::visit(MapDeclStatement &decl) { Visitor::visit(decl); auto bpf_type = get_bpf_map_type(decl.bpf_type); if (!bpf_type) { LOG(BUG) << "No bpf type from string: " << decl.bpf_type; return; } map_decls_.insert({ decl.ident, { *bpf_type, decl.max_entries } }); } void ResourceAnalyser::visit(Map &map) { Visitor::visit(map); auto it = named_param_info_.defaults.find(map.ident); if (it != named_param_info_.defaults.end()) { resources_.global_vars.add_named_param(map.ident, it->second.value, it->second.description); if (std::holds_alternative(it->second.value)) { const auto max_strlen = bpftrace_.config_->pad_max_strlen(); if (exceeds_stack_limit(max_strlen)) resources_.str_buffers++; } return; } update_map_info(map); } void ResourceAnalyser::visit(MapAccess &acc) { visit(acc.map); visit(acc.key); const auto &val_type = type_map_.map_value_type(acc.map->ident); if (exceeds_stack_limit(val_type.GetSize())) { resources_.read_map_value_buffers++; resources_.max_read_map_value_size = std::max( resources_.max_read_map_value_size, val_type.GetSize()); } maybe_allocate_map_key_buffer(*acc.map, acc.key); } void ResourceAnalyser::visit(Tuple &tuple) { Visitor::visit(tuple); const auto &ty = type_map_.type(&tuple); if (exceeds_stack_limit(ty.GetSize())) { resources_.anon_struct_buffers++; resources_.max_anon_struct_size = std::max(resources_.max_anon_struct_size, ty.GetSize()); } } void ResourceAnalyser::visit(Record &record) { Visitor::visit(record); const auto &ty = type_map_.type(&record); if (exceeds_stack_limit(ty.GetSize())) { resources_.anon_struct_buffers++; resources_.max_anon_struct_size = std::max(resources_.max_anon_struct_size, ty.GetSize()); } } void ResourceAnalyser::visit(For &f) { Visitor::visit(f); // Need tuple per for loop to store key and value const auto &ty = type_map_.type(f.decl); if (exceeds_stack_limit(ty.GetSize())) { resources_.anon_struct_buffers++; resources_.max_anon_struct_size = std::max(resources_.max_anon_struct_size, ty.GetSize()); } } void ResourceAnalyser::visit(AssignMapStatement &assignment) { // CodegenLLVM traverses the AST like: // AssignmentMapStatement a // | | // visit(a.expr) visit(a.map.key_expr) // // CodegenLLVM avoid traversing into the map node via visit(a.map) // to avoid triggering a map lookup. // // However, ResourceAnalyser traverses the AST differently: // AssignmentMapStatement a // | | // visit(a.expr) visit(a.map) // | // visit(a.map.key_expr) // // Unfortunately, calling ResourceAnalser::visit(a.map) will trigger // an additional read map buffer. Thus to mimic CodegenLLVM, we // skip calling ResourceAnalser::visit(a.map) and do the AST traversal // ourselves. visit(assignment.map_access->map); visit(assignment.map_access->key); visit(assignment.expr); const auto &map_type = type_map_.map_value_type( assignment.map_access->map->ident); // The `MapAccess` validated the read limit, we know this to be // a write, so we validate the write limit. if (needMapAllocation(map_type, type_map_.type(assignment.expr))) { if (exceeds_stack_limit(map_type.GetSize())) { resources_.max_write_map_value_size = std::max( resources_.max_write_map_value_size, map_type.GetSize()); } } maybe_allocate_map_key_buffer(*assignment.map_access->map, assignment.map_access->key); } void ResourceAnalyser::visit(IfExpr &if_expr) { Visitor::visit(if_expr); // Codegen cannot use a phi node for ternary string b/c strings can be of // differing lengths and phi node wants identical types. So we have to // allocate a result temporary, but not on the stack b/c a big string would // blow it up. So we need a scratch buffer for it. if (type_map_.type(&if_expr).IsStringTy()) { const auto max_strlen = bpftrace_.config_->pad_max_strlen(); if (exceeds_stack_limit(max_strlen)) resources_.str_buffers++; } } void ResourceAnalyser::update_variable_info(Variable &var) { // Note we don't check if a variable has been declared/assigned before. // We do this to simplify the code and make it more robust to changes // in other modules at the expense of memory over-allocation. Otherwise, // we would need to track scopes like TypeChecker and CodegenLLVM // and duplicate scope tracking in a third module. const auto &ty = type_map_.type(&var); if (exceeds_stack_limit(ty.GetSize())) { resources_.variable_buffers++; resources_.max_variable_size = std::max(resources_.max_variable_size, ty.GetSize()); } } void ResourceAnalyser::visit(AssignVarStatement &assignment) { Visitor::visit(assignment); update_variable_info(*assignment.var()); } void ResourceAnalyser::visit(VarDeclStatement &decl) { Visitor::visit(decl); update_variable_info(*decl.var); } bool ResourceAnalyser::exceeds_stack_limit(size_t size) { return size > bpftrace_.config_->on_stack_limit; } bool ResourceAnalyser::uses_usym_table(const std::string &fun) { return fun == "usym" || fun == "__builtin_func" || fun == "ustack" || fun == "__builtin_dw_ustack"; } void ResourceAnalyser::update_map_info(Map &map) { const auto &value_type = type_map_.map_value_type(map.ident); const auto &key_type = type_map_.map_key_type(map.ident); auto &map_info = resources_.maps_info[map.ident]; map_info.value_type = value_type; map_info.key_type = key_type; map_info.is_scalar = map_metadata_.scalar[map.ident]; auto decl = map_decls_.find(map.ident); if (decl != map_decls_.end()) { map_info.bpf_type = decl->second.first; map_info.max_entries = decl->second.second; } else { map_info.bpf_type = get_bpf_map_type(map_info.value_type); // hist() and lhist() transparently create additional elements in whatever // map they are assigned to. So even if the map looks like it has no keys, // multiple keys are necessary. if (!value_type.IsMultiKeyMapTy() && map_info.is_scalar) { map_info.max_entries = 1; } else { map_info.max_entries = bpftrace_.config_->max_map_keys; } } } void ResourceAnalyser::maybe_allocate_map_key_buffer(const Map &map, const Expression &key_expr) { const auto &key_type = type_map_.map_key_type(map.ident); const auto map_key_size = key_type.GetSize(); if (needMapAllocation(key_type, type_map_.type(key_expr)) && exceeds_stack_limit(map_key_size)) { resources_.map_key_buffers++; resources_.max_map_key_size = std::max(resources_.max_map_key_size, map_key_size); } } Pass CreateResourcePass() { auto fn = [](ASTContext &ast, BPFtrace &b, MapMetadata &mm, NamedParamInfo &named_param_info, TypeMap &type_map) { ResourceAnalyser analyser(b, mm, named_param_info, type_map); analyser.visit(ast.root); b.resources = analyser.resources(); }; return Pass::create("ResourceAnalyser", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/resource_analyser.h000066400000000000000000000002011526721631600221430ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateResourcePass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/tracepoint_format_parser.cpp000066400000000000000000000150701526721631600240570ustar00rootroot00000000000000#include #include #include #include #include "ast/ast.h" #include "ast/passes/args_resolver.h" #include "ast/visitor.h" #include "bpftrace.h" #include "config.h" #include "log.h" #include "tracefs/tracefs.h" #include "tracepoint_format_parser.h" namespace bpftrace::ast { char TracepointFormatFileError::ID; void TracepointFormatFileError::log(llvm::raw_ostream &OS) const { OS << err(); } std::string TracepointFormatFileError::err() const { std::stringstream msg; msg << "Tracepoint not found: " << category_ << ":" << event_; if (bt_verbose) { msg << "(" << strerror(errno) << ": " << file_path_ << ")"; } return msg.str(); } std::string TracepointFormatFileError::hint() const { if (category_ == "syscall") return "Did you mean syscalls:" + event_ + "?"; return ""; } Result<> TracepointFormatParser::parse_format_file() { std::string format_file_path = tracefs::event_format_file(category_, event_); std::ifstream format_file(format_file_path.c_str()); if (format_file.fail()) { return make_error(category_, event_, format_file_path); } format_file_ = std::move(format_file); return OK(); } std::string adjust_integer_types(const std::string &field_type, int size) { std::string new_type = field_type; // Adjust integer fields to correctly sized types if (size == 8) { if (field_type == "int") new_type = "s64"; if (field_type == "unsigned int" || field_type == "unsigned" || field_type == "u32" || field_type == "pid_t" || field_type == "uid_t" || field_type == "gid_t") new_type = "u64"; } return new_type; } Result parse_section(const std::string &line, const std::string &title, const std::string &tracepoint, const std::string &field_name) { auto start = line.find(title); if (start == std::string::npos) { return make_error(tracepoint, field_name, "could not parse \"" + title + "\""); } auto end = line.find(';', start); if (end == std::string::npos) { return make_error(tracepoint, field_name, "could not parse \"" + title + "\""); } return line.substr(start + title.length(), end - start - title.length()); } // Parse one line from the tracepoint format file which has the format: // field:unsigned short common_type; offset:0; size:2; signed:0; Result TracepointFormatParser::parse_field(const std::string &line, const std::string &tracepoint) { auto field_str = parse_section(line, "field:", tracepoint, ""); if (!field_str) return field_str.takeError(); // Split field type from the name auto field_type_end_pos = field_str->find_last_of("\t "); if (field_type_end_pos == std::string::npos) { return make_error(*field_str, "could not parse type"); } std::string field_type = field_str->substr(0, field_type_end_pos); std::string field_name = field_str->substr(field_type_end_pos + 1); // Check if the field is an array auto arr_size_pos = field_name.find('['); bool is_array = arr_size_pos != std::string::npos; std::optional array_size = std::nullopt; if (is_array) { auto arr_size_end_pos = field_name.find(']'); auto array_size_str = field_name.substr(arr_size_pos + 1, arr_size_end_pos - arr_size_pos - 1); if (array_size_str.empty()) { array_size = 0; } else { try { array_size = std::stoi(array_size_str); } catch (std::exception &) { return make_error(tracepoint, field_name, "could not parse array size"); } } field_name = field_name.substr(0, arr_size_pos); } auto offset_str = parse_section(line, "offset:", tracepoint, field_name); if (!offset_str) return offset_str.takeError(); auto size_str = parse_section(line, "size:", tracepoint, field_name); if (!size_str) return size_str.takeError(); auto signed_str = parse_section(line, "signed:", tracepoint, field_name); if (!signed_str) return signed_str.takeError(); bool is_signed = *signed_str == "1"; Field field; field.name = field_name; field.offset = std::stoi(*offset_str); field.is_data_loc = field_type.find("__data_loc") != std::string::npos; if (field.is_data_loc) { field.type = CreateInt64(); field.type.SetAS(AddrSpace::kernel); } else { auto type = bpftrace_.btf_->get_stype(field_type); // There may be fields that are parsed that have the __user type // tag, which indicates an user address space. Otherwise, no explicit // type is attached. However, we know that tracepoint fields generally // refer to kernel space, so we attach this explicitly if it present. if (type.GetAS() == AddrSpace::none) { type.SetAS(AddrSpace::kernel); } if (is_array) { if (field_type == "char") { // See src/btf.cpp for why this is converted to a string field.type = CreateString(*array_size); } else { field.type = CreateArray(*array_size, type); } } else { field.type = type; field.type.SetSize(std::stoi(*size_str)); field.type.SetSign(is_signed); } } return field; } Result> TracepointFormatParser::get_tracepoint_struct( std::istream &format_file) { if (!bpftrace_.has_btf_data()) { return make_error( category_ + ":" + event_, "BTF is required for parsing tracepoint arguments"); } auto result = std::make_shared(0, false); for (std::string line; getline(format_file, line);) { if (line.find("field:") == std::string::npos) continue; auto field = parse_field(line, category_ + ":" + event_); if (!field) return field.takeError(); result->fields.push_back(std::move(*field)); } result->is_tracepoint_args = true; result->size = result->fields.back().offset + result->fields.back().type.GetSize(); return result; } Result> TracepointFormatParser::get_tracepoint_struct() { return get_tracepoint_struct(format_file_); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/tracepoint_format_parser.h000066400000000000000000000026421526721631600235250ustar00rootroot00000000000000#pragma once #include #include #include "ast/pass_manager.h" #include "bpftrace.h" namespace bpftrace::ast { class TracepointFormatFileError : public ErrorInfo { public: static char ID; TracepointFormatFileError(std::string category, std::string event, std::string file_path) : category_(std::move(category)), event_(std::move(event)), file_path_(std::move(file_path)) {}; void log(llvm::raw_ostream &OS) const override; std::string err() const; std::string hint() const; private: std::string category_; std::string event_; std::string file_path_; }; class TracepointFormatParser { public: TracepointFormatParser(std::string category, std::string event, BPFtrace &bpftrace) : category_(std::move(category)), event_(std::move(event)), bpftrace_(bpftrace) {}; Result<> parse_format_file(); Result> get_tracepoint_struct(); protected: Result> get_tracepoint_struct( std::istream &format_file); private: Result parse_field(const std::string &line, const std::string &tracepoint); const std::string category_; const std::string event_; std::ifstream format_file_; BPFtrace &bpftrace_; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/000077500000000000000000000000001526721631600174205ustar00rootroot00000000000000bpftrace-0.27.1/src/ast/passes/types/ast_transformer.cpp000066400000000000000000000172341526721631600233440ustar00rootroot00000000000000#include "ast/passes/types/ast_transformer.h" #include "ast/ast.h" #include "ast/passes/fold_literals.h" #include "ast/passes/macro_expansion.h" #include "ast/passes/types/cast_creator.h" #include "ast/visitor.h" #include "struct.h" #include "types.h" #include namespace bpftrace::ast { namespace { class AstTransformer : public Visitor> { public: AstTransformer(ASTContext &ast, const MacroRegistry ¯o_registry, const ResolvedTypes &resolved_types) : ast_(ast), macro_registry_(macro_registry), resolved_types_(resolved_types) {}; using Visitor>::visit; std::optional visit(ArrayAccess &acc); std::optional visit(Cast &cast); std::optional visit(Expression &expr); std::optional visit(Binop &binop); std::optional visit(Offsetof &offof); std::optional visit(Sizeof &szof); std::optional visit(Typeinfo &typeinfo); std::optional visit(FieldAccess &acc); bool had_transforms() const { return had_transforms_; } private: ASTContext &ast_; const MacroRegistry ¯o_registry_; const ResolvedTypes &resolved_types_; bool had_transforms_ = false; const SizedType &get_type(const TypeVariable &node) const { auto it = resolved_types_.find(node); if (it != resolved_types_.end()) { return it->second; } static SizedType none = CreateNone(); return none; } }; std::optional AstTransformer::visit(ArrayAccess &acc) { visit(acc.expr); visit(acc.indexpr); if (get_type(&acc.expr.node()).IsTupleTy()) { if (auto *index = acc.indexpr.as()) { return ast_.make_node(acc.loc, acc.expr, static_cast(index->value)); } else { acc.addError() << "Array-style access for tuples only valid for integer literals"; } } return std::nullopt; } std::optional AstTransformer::visit(Binop &binop) { visit(binop.left); visit(binop.right); const auto &lht = get_type(&binop.left.node()); const auto &rht = get_type(&binop.right.node()); if (binop.op != Operator::EQ && binop.op != Operator::NE) return std::nullopt; if (!lht.IsTupleTy() && !lht.IsRecordTy()) return std::nullopt; if (!lht.IsCompatible(rht)) return std::nullopt; if (binop.left.is_literal() && binop.right.is_literal()) { // This will get folded. return std::nullopt; } bool is_tuple = lht.IsTupleTy(); auto updatedTy = is_tuple ? get_promoted_tuple(lht, rht) : get_promoted_record(lht, rht); if (!updatedTy) { binop.addError() << "Type mismatch for '" << opstr(binop) << "': comparing " << lht << " with " << rht; return std::nullopt; } auto updated_lht = lht; if (*updatedTy != lht) { auto updated = is_tuple ? try_tuple_cast(ast_, binop.left, lht, *updatedTy) : try_record_cast(ast_, binop.left, lht, *updatedTy); if (updated) { updated_lht = *updated; } } auto updated_rht = rht; if (*updatedTy != rht) { auto updated = is_tuple ? try_tuple_cast(ast_, binop.right, rht, *updatedTy) : try_record_cast(ast_, binop.right, rht, *updatedTy); if (updated) { updated_rht = *updated; } } auto *size = ast_.make_node(binop.loc, updatedTy->GetSize()); // N.B. if the types aren't equal at this point it means that // we're dealing with record types that are same except for // their fields are in a different order so we need to use a // different memcmp that saves off both the left and right to // variables but sets the type of the right variable to the left // before assignment (e.g. `let $right: typeof($left) = right;`) // as this ensures the temporary `$right` variable has the same // field ordering as the `$left`. auto *call = ast_.make_node( binop.loc, updated_rht == updated_lht ? "memcmp" : "memcmp_record", ExpressionList{ binop.left, binop.right, size }); auto *parsed_type = ast_.make_node(binop.loc, ParsedType::Kind::Identifier, "bool"); auto *typeof_node = ast_.make_node(binop.loc, parsed_type); auto *cast = ast_.make_node(binop.loc, typeof_node, call); if (binop.op == Operator::NE) { return cast; } else { return ast_.make_node(binop.loc, cast, Operator::LNOT); } } std::optional AstTransformer::visit(Cast &cast) { visit(cast.expr); if (get_type(&cast).IsBoolTy() && cast.expr.is_literal()) { return ast_.make_node(cast.expr.loc(), eval_bool(cast.expr)); } return std::nullopt; } std::optional AstTransformer::visit(Expression &expr) { auto r = Visitor>::visit( expr.value); if (r) { had_transforms_ = true; expr.value = r->value; expand_macro(ast_, expr, macro_registry_); } return std::nullopt; } std::optional AstTransformer::visit(FieldAccess &acc) { visit(acc.expr); // FieldAccesses will automatically resolve through any number of pointer // dereferences. For now, we inject the `Unop` operator directly, as codegen // stores the underlying structs as pointers anyways. In the future, we will // likely want to do this in a different way if we are tracking l-values. auto type = get_type(&acc.expr.node()); while (type.IsPtrTy()) { auto *unop = ast_.make_node(acc.expr.node().loc, acc.expr, Operator::MUL); acc.expr.value = unop; had_transforms_ = true; type = type.GetPointeeTy(); } return std::nullopt; } std::optional AstTransformer::visit(Offsetof &offof) { SizedType c_type = get_type(offof.type_of); if (c_type.IsNoneTy()) { return std::nullopt; } size_t offset = 0; for (const auto &field : offof.field) { if (!c_type.IsCTypeTy() || !c_type.HasField(field)) { return std::nullopt; } const auto &f = c_type.GetField(field); offset += f.offset; c_type = f.type; } return ast_.make_node(Location(offof.loc), offset); } std::optional AstTransformer::visit(Sizeof &szof) { const auto &ty = get_type(szof.type_of); if (ty.IsNoneTy()) { return std::nullopt; } return ast_.make_node(Location(szof.loc), ty.GetSize()); } std::optional AstTransformer::visit(Typeinfo &typeinfo) { const auto &type = get_type(typeinfo.typeof); if (type.IsNoneTy()) { return std::nullopt; } // We currently lack a globally-unique enumeration of types. For // simplicity, just use the type string with a placeholder identifier. auto *id = ast_.make_node(typeinfo.loc, 0); auto *base_ty = ast_.make_node(typeinfo.loc, to_string(type.GetTy())); auto *full_ty = ast_.make_node(typeinfo.loc, typestr(type)); auto *record = make_record( ast_, typeinfo.loc, { { "btf_id", id }, { "base_type", base_ty }, { "full_type", full_ty } }); return record; } } // namespace bool RunAstTransformer(ASTContext &ast, const MacroRegistry ¯o_registry, const ResolvedTypes &resolved_types) { AstTransformer transformer(ast, macro_registry, resolved_types); transformer.visit(ast.root); return transformer.had_transforms(); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/ast_transformer.h000066400000000000000000000005621526721631600230050ustar00rootroot00000000000000#pragma once #include "ast/passes/types/type_resolver.h" namespace bpftrace::ast { class MacroRegistry; // Runs the AST transformer, returns true if any transforms were made. bool RunAstTransformer(ASTContext &ast, const MacroRegistry ¯o_registry, const ResolvedTypes &resolved_types); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/cast_creator.cpp000066400000000000000000000473731526721631600226130ustar00rootroot00000000000000#include "ast/passes/types/cast_creator.h" #include "ast/ast.h" #include "ast/integer_types.h" #include "ast/passes/map_sugar.h" #include "ast/passes/types/parsed_type_bridge.h" #include "ast/passes/types/type_map.h" #include "ast/passes/types/type_system.h" #include "ast/visitor.h" #include "bpftrace.h" #include "btf/compat.h" #include "log.h" #include "types.h" #include #include #include #include #include #include namespace bpftrace::ast { static bool integer_fits_in_type(uint64_t val, const SizedType &type) { assert(type.IsIntegerTy()); auto size = type.GetSize(); if (type.IsSigned()) { switch (size) { case 1: return val <= std::numeric_limits::max(); case 2: return val <= std::numeric_limits::max(); case 4: return val <= std::numeric_limits::max(); case 8: return val <= std::numeric_limits::max(); default: return false; } } else { switch (size) { case 1: return val <= std::numeric_limits::max(); case 2: return val <= std::numeric_limits::max(); case 4: return val <= std::numeric_limits::max(); case 8: return true; default: return false; } } } static bool integer_fits_in_type(int64_t val, const SizedType &type) { assert(type.IsIntegerTy()); if (!type.IsSigned()) { return false; } auto size = type.GetSize(); switch (size) { case 1: return val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); case 2: return val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); case 4: return val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); case 8: return true; default: return false; } } static std::optional try_expression_cast( ASTContext &ctx, Expression &expr, const SizedType &expr_type, const SizedType &target_type); std::optional try_tuple_cast(ASTContext &ctx, Expression &exp, const SizedType &expr_type, const SizedType &target_type) { if (auto *block_expr = exp.as()) { return try_tuple_cast(ctx, block_expr->expr, expr_type, target_type); } if (!exp.is() && !exp.is() && !exp.is() && !exp.is() && !exp.is() && !exp.is()) { LOG(BUG) << "Unexpected expression kind: try_tuple_cast"; } ExpressionList expr_list = {}; std::vector element_types; for (size_t i = 0; i < target_type.GetFields().size(); ++i) { auto &expr_field_ty = expr_type.GetField(i).type; auto &target_field_ty = target_type.GetField(i).type; Expression elem; if (auto *tuple_literal = exp.as()) { elem = clone(ctx, tuple_literal->elems.at(i).loc(), tuple_literal->elems.at(i)); } else { elem = ctx.make_node(Location(exp.loc()), clone(ctx, exp.loc(), exp), i); } auto cast_type = try_expression_cast( ctx, elem, expr_field_ty, target_field_ty); if (!cast_type) { return std::nullopt; } element_types.emplace_back(*cast_type); expr_list.emplace_back(std::move(elem)); } auto tuple_type = CreateTuple(Struct::CreateTuple(element_types)); exp = ctx.make_node(Location(exp.loc()), std::move(expr_list)); return tuple_type; } std::optional try_record_cast(ASTContext &ctx, Expression &exp, const SizedType &expr_type, const SizedType &target_type) { if (auto *block_expr = exp.as()) { return try_record_cast(ctx, block_expr->expr, expr_type, target_type); } if (!exp.is() && !exp.is() && !exp.is() && !exp.is() && !exp.is() && !exp.is()) { LOG(BUG) << "Unexpected expression kind: try_record_cast"; } std::unordered_map> named_arg_map; for (size_t i = 0; i < expr_type.GetFields().size(); ++i) { const auto &target_field = target_type.GetField(i); const auto &expr_field_ty = expr_type.GetField(target_field.name).type; const auto &target_field_ty = target_field.type; Expression elem; if (auto *record_literal = exp.as()) { auto field_idx = expr_type.GetFieldIdx(target_field.name); elem = clone(ctx, record_literal->elems.at(field_idx)->expr.loc(), record_literal->elems.at(field_idx)->expr); } else { elem = ctx.make_node(Location(exp.loc()), clone(ctx, exp.loc(), exp), target_field.name); } auto cast_type = try_expression_cast( ctx, elem, expr_field_ty, target_field_ty); if (!cast_type) { return std::nullopt; } auto *named_arg = ctx.make_node(Location(exp.loc()), target_field.name, std::move(elem)); named_arg_map[expr_type.GetFieldIdx(target_field.name)] = { named_arg, *cast_type }; } // Keep the ordering for the current type to maintain evaluation order NamedArgumentList named_args = {}; std::vector elements; std::vector names; for (size_t i = 0; i < expr_type.GetFields().size(); ++i) { named_args.emplace_back(named_arg_map[i].first); names.emplace_back(named_arg_map[i].first->name); elements.emplace_back(named_arg_map[i].second); } auto record_type = CreateRecord(Struct::CreateRecord(elements, names)); exp = ctx.make_node(Location(exp.loc()), std::move(named_args)); return record_type; } static std::optional try_int_cast(ASTContext &ctx, Expression &exp, const SizedType &expr_type, const SizedType &target_type) { if (auto *integer = exp.as()) { if (!integer_fits_in_type(integer->value, target_type)) { return std::nullopt; } } else if (auto *negative_integer = exp.as()) { if (!integer_fits_in_type(negative_integer->value, target_type)) { return std::nullopt; } } if (!expr_type.FitsInto(target_type) && !expr_type.IsCastableMapTy() && !exp.is() && !exp.is()) { auto &warning = exp.node().addWarning(); warning << "Expression of type: " << expr_type << " being cast to type: " << target_type << ". This may cause unexpected results. Use an explicit cast to " "suppress this warning."; } auto *typeof_r = ctx.make_node( Location(exp.loc()), sized_type_to_parsed_type(ctx, Location(exp.loc()), target_type)); exp = ctx.make_node(Location(exp.loc()), typeof_r, clone(ctx, exp.loc(), exp)); return target_type; } static std::optional try_string_cast(ASTContext &ctx, Expression &exp, const SizedType &expr_type, const SizedType &target_type) { if (expr_type.GetSize() == target_type.GetSize()) { return target_type; } if (!expr_type.FitsInto(target_type)) { return std::nullopt; } auto *typeof_r = ctx.make_node( Location(exp.loc()), sized_type_to_parsed_type(ctx, Location(exp.loc()), target_type)); exp = ctx.make_node(Location(exp.loc()), typeof_r, clone(ctx, exp.loc(), exp)); return target_type; } static std::optional try_expression_cast( ASTContext &ctx, Expression &expr, const SizedType &expr_type, const SizedType &target_type) { if (expr_type == target_type) { return target_type; } // No when both are castable map types if (expr_type.GetTy() == target_type.GetTy() && expr_type.IsCastableMapTy()) { return target_type; } if ((expr_type.IsIntegerTy() || expr_type.IsCastableMapTy()) && (target_type.IsIntegerTy() || target_type.IsCastableMapTy())) { return try_int_cast(ctx, expr, expr_type, target_type); } if (expr_type.GetTy() != target_type.GetTy()) { return std::nullopt; } if (target_type.IsStringTy()) { return try_string_cast(ctx, expr, expr_type, target_type); } else if (target_type.IsTupleTy()) { return try_tuple_cast(ctx, expr, expr_type, target_type); } else if (target_type.IsRecordTy()) { return try_record_cast(ctx, expr, expr_type, target_type); } else if (target_type.IsPtrTy()) { auto *typeof_r = ctx.make_node( Location(expr.loc()), sized_type_to_parsed_type(ctx, Location(expr.loc()), target_type)); expr = ctx.make_node(Location(expr.loc()), typeof_r, clone(ctx, expr.loc(), expr)); return target_type; } else if (target_type.IsBufferTy()) { // TODO: make it ok to cast buffer types to larger buffer types return target_type; } return std::nullopt; } namespace { class CastCreator : public Visitor { public: explicit CastCreator(ASTContext &ast, BPFtrace &bpftrace, TypeMetadata &type_metadata, const TypeMap &type_map); using Visitor::visit; void visit(AssignMapStatement &assignment); void visit(AssignVarStatement &assignment); void visit(Binop &binop); void visit(BlockExpr &block); void visit(Call &call); void visit(Cast &cast); void visit(For &f); void visit(IfExpr &if_expr); void visit(Jump &jump); void visit(MapAccess &acc); void visit(Probe &probe); void visit(Subprog &subprog); private: std::optional cast_expression(Expression &expr, const SizedType &expr_type, const SizedType &target_type); ASTContext &ctx_; BPFtrace &bpftrace_; TypeMetadata &type_metadata_; const TypeMap &type_map_; std::variant top_level_node_; }; CastCreator::CastCreator(ASTContext &ast, BPFtrace &bpftrace, TypeMetadata &type_metadata, const TypeMap &type_map) : ctx_(ast), bpftrace_(bpftrace), type_metadata_(type_metadata), type_map_(type_map) { } std::optional CastCreator::cast_expression( Expression &expr, const SizedType &expr_type, const SizedType &target_type) { return try_expression_cast(ctx_, expr, expr_type, target_type); } void CastCreator::visit(AssignMapStatement &assignment) { visit(assignment.map_access); visit(assignment.expr); const auto &expr_type = type_map_.type(assignment.expr); const auto &value_type = type_map_.map_value_type( assignment.map_access->map->ident); if (value_type == expr_type) { return; } if (!cast_expression(assignment.expr, expr_type, value_type)) { assignment.addError() << "Type mismatch for " << assignment.map_access->map->ident << ": " << "trying to assign value of type '" << expr_type << "' when map already has a value type '" << value_type << "'"; } } void CastCreator::visit(AssignVarStatement &assignment) { visit(assignment.expr); visit(assignment.var_decl); const auto &expr_type = type_map_.type(assignment.expr); const auto &var_type = type_map_.type(assignment.var()); if (var_type == expr_type) { return; } if (!cast_expression(assignment.expr, expr_type, var_type)) { assignment.addError() << "Type mismatch for " << assignment.var()->ident << ": " << "trying to assign value of type '" << expr_type << "' when variable already has a type '" << var_type << "'"; } } void CastCreator::visit(Binop &binop) { visit(binop.left); visit(binop.right); const auto &left_type = type_map_.type(binop.left); const auto &right_type = type_map_.type(binop.right); // N.B. don't upcast strings as there are cases when one size is the max // string size and we don't want to create a cast like (string[1024])"hi" if (left_type.IsStringTy() || right_type.IsStringTy()) { return; } if (is_comparison_op(binop.op)) { auto promoted = get_promoted_type(left_type, right_type); if (promoted) { cast_expression(binop.left, left_type, *promoted); cast_expression(binop.right, right_type, *promoted); } } else { const auto &result_type = type_map_.type(&binop); cast_expression(binop.left, left_type, result_type); cast_expression(binop.right, right_type, result_type); } } void CastCreator::visit(BlockExpr &block) { visit(block.stmts); visit(block.expr); } void CastCreator::visit(Call &call) { for (auto &varg : call.vargs) { visit(varg); } if (getAssignRewriteFuncs().contains(call.func)) { if (auto *map = call.vargs.at(0).as()) { cast_expression(call.vargs.at(1), type_map_.type(call.vargs.at(1)), type_map_.map_key_type(map->ident)); } } else if (call.func == "percpu_kaddr") { if (call.vargs.size() == 2) { auto arg_type = type_map_.type(call.vargs.at(1)); if (arg_type != CreateUInt32() && arg_type.IsIntegerTy()) { auto *typeof_c = ctx_.make_node( Location(call.vargs.at(1).loc()), sized_type_to_parsed_type(ctx_, Location(call.vargs.at(1).loc()), CreateUInt32())); call.vargs.at(1) = ctx_.make_node( Location(call.vargs.at(1).loc()), typeof_c, clone(ctx_, call.vargs.at(1).loc(), call.vargs.at(1))); } } } else if (call.func == "usym") { auto arg_type = type_map_.type(call.vargs.at(0)); if (arg_type.IsIntegerTy() && arg_type.GetSize() != 8) { cast_expression(call.vargs.at(0), type_map_.type(call.vargs.at(0)), CreateUInt64()); } } else { // All these errors below will be surfaced in type_checker auto maybe_func = type_metadata_.global.lookup(call.func); if (!maybe_func) { consumeError(std::move(maybe_func)); return; } const auto &func = *maybe_func; auto proto = func.type(); if (!proto) { consumeError(std::move(proto)); return; } auto argument_types = proto->argument_types(); if (!argument_types) { consumeError(argument_types.takeError()); return; } if (argument_types->size() != call.vargs.size()) { return; } for (size_t i = 0; i < argument_types->size(); i++) { auto compat_arg_type = getCompatType(argument_types->at(i).second, bpftrace_.structs); if (!compat_arg_type) { consumeError(compat_arg_type.takeError()); continue; } auto &arg = call.vargs.at(i); const auto &arg_type = type_map_.type(arg); if (!arg_type.IsIntegerTy() || !compat_arg_type->IsIntegerTy()) { continue; } // Cast integers and issue warnings if neccessary cast_expression(arg, arg_type, *compat_arg_type); } } } void CastCreator::visit(Cast &cast) { visit(cast.expr); visit(cast.typeof); } void CastCreator::visit(For &f) { visit(f.decl); visit(f.block); if (auto *map = f.iterable.as()) { visit(map); } else if (auto *range = f.iterable.as()) { visit(range->start); visit(range->end); const auto &start_type = type_map_.type(range->start); const auto &end_type = type_map_.type(range->end); if (start_type == end_type) { return; } auto larger = start_type.GetSize() > end_type.GetSize() ? start_type : end_type; cast_expression(range->start, start_type, larger); cast_expression(range->end, end_type, larger); } } void CastCreator::visit(IfExpr &if_expr) { visit(if_expr.cond); visit(if_expr.left); visit(if_expr.right); const auto &result_type = type_map_.type(&if_expr); const auto &left_type = type_map_.type(if_expr.left); const auto &right_type = type_map_.type(if_expr.right); if (!left_type.IsNoneTy() && result_type != left_type) { if (!cast_expression(if_expr.left, left_type, result_type)) { LOG(BUG) << "IfExpr left should be castable"; } } if (!right_type.IsNoneTy() && result_type != right_type) { if (!cast_expression(if_expr.right, right_type, result_type)) { LOG(BUG) << "IfExpr right should be castable"; } } } void CastCreator::visit(Jump &jump) { if (jump.ident == JumpType::RETURN) { visit(jump.return_value); if (std::holds_alternative(top_level_node_)) { if (jump.return_value.has_value()) { const auto &ty = type_map_.type(*jump.return_value); if (ty.IsIntegerTy() && ty.GetSize() != 8) { // Probes always return 64 bit ints cast_expression(*jump.return_value, ty, CreateInt64()); } } } else if (auto **subprog_ptr = std::get_if(&top_level_node_)) { auto *subprog = *subprog_ptr; const auto &return_type = type_map_.type(subprog->return_type); if (!jump.return_value.has_value()) { if (!return_type.IsVoidTy()) { jump.addError() << "Function " << subprog->name << " is of type " << return_type << ", cannot return " << CreateVoid(); return; } return; } if (!cast_expression(*jump.return_value, type_map_.type(*jump.return_value), return_type)) { jump.addError() << "Function " << subprog->name << " is of type " << return_type << ", cannot return " << type_map_.type(*jump.return_value); return; } } } } void CastCreator::visit(MapAccess &acc) { visit(acc.key); visit(acc.map); const auto &expr_type = type_map_.type(acc.key); const auto &key_type = type_map_.map_key_type(acc.map->ident); if (key_type.IsNoneTy() || expr_type.IsNoneTy()) { return; } if (!cast_expression(acc.key, expr_type, key_type)) { acc.addError() << "Type mismatch for " << acc.map->ident << ": " << "trying to assign key of type '" << expr_type << "' when map already has a key type '" << key_type << "'"; } } void CastCreator::visit(Probe &probe) { top_level_node_ = &probe; visit(probe.attach_points); visit(probe.block); } void CastCreator::visit(Subprog &subprog) { top_level_node_ = &subprog; for (SubprogArg *arg : subprog.args) { visit(arg->var); } visit(subprog.block); visit(subprog.return_type); } } // namespace void RunCastCreator(ASTContext &ast, BPFtrace &bpftrace, TypeMetadata &type_metadata, const TypeMap &type_map) { CastCreator(ast, bpftrace, type_metadata, type_map).visit(ast.root); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/cast_creator.h000066400000000000000000000016621526721631600222470ustar00rootroot00000000000000#pragma once #include #include "types.h" namespace bpftrace { class BPFtrace; } // namespace bpftrace namespace bpftrace::ast { class ASTContext; class Expression; class TypeMap; class TypeMetadata; struct Program; std::optional try_tuple_cast(ASTContext &ctx, Expression &exp, const SizedType &expr_type, const SizedType &target_type); std::optional try_record_cast(ASTContext &ctx, Expression &exp, const SizedType &expr_type, const SizedType &target_type); void RunCastCreator(ASTContext &ast, BPFtrace &bpftrace, TypeMetadata &type_metadata, const TypeMap &type_map); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/parsed_type_bridge.cpp000066400000000000000000000055051526721631600237640ustar00rootroot00000000000000#include "ast/passes/types/parsed_type_bridge.h" #include #include "ast/ast.h" namespace bpftrace { SizedType parsed_type_to_sized_type(const ast::ParsedType &type) { switch (type.kind) { case ast::ParsedType::Kind::Identifier: if (auto bt = ident_to_builtin_type(type.name)) { return *bt; } return CreateCStruct(type.name); case ast::ParsedType::Kind::Struct: case ast::ParsedType::Kind::Union: return CreateCStruct(type.type_name()); case ast::ParsedType::Kind::Enum: return CreateEnum(64, type.name); case ast::ParsedType::Kind::Pointer: assert(type.inner); return CreatePointer(parsed_type_to_sized_type(*type.inner)); case ast::ParsedType::Kind::Array: assert(type.inner); return normalize_array_to_sized_type( CreateArray(type.array_size, parsed_type_to_sized_type(*type.inner))); } return CreateNone(); } ast::ParsedType *sized_type_to_parsed_type(ast::ASTContext &ctx, const ast::Location &loc, const SizedType &type) { if (type.IsPtrTy()) { auto *pointee = sized_type_to_parsed_type(ctx, loc, type.GetPointeeTy()); return ctx.make_node(loc, pointee); } if (type.IsArrayTy()) { auto *element = sized_type_to_parsed_type(ctx, loc, type.GetElementTy()); return ctx.make_node(loc, type.GetNumElements(), element); } if (type.IsStringTy() || type.IsBufferTy() || type.IsInetTy()) { auto *base = ctx.make_node( loc, ast::ParsedType::Kind::Identifier, typestr(type.GetTy())); if (type.GetSize() == 0) { return base; } return ctx.make_node(loc, type.GetSize(), base); } if (type.IsEnumTy()) { return ctx.make_node(loc, ast::ParsedType::Kind::Enum, type.GetName()); } if (type.IsCUnionTy()) { return ctx.make_node(loc, ast::ParsedType::Kind::Union, std::string(type.GetBaseName())); } if (type.IsCStructTy()) { return ctx.make_node(loc, ast::ParsedType::Kind::Struct, std::string(type.GetBaseName())); } if (type.IsCTypedefTy()) { return ctx.make_node(loc, ast::ParsedType::Kind::Identifier, type.GetName()); } return ctx.make_node(loc, ast::ParsedType::Kind::Identifier, typestr(type)); } } // namespace bpftrace bpftrace-0.27.1/src/ast/passes/types/parsed_type_bridge.h000066400000000000000000000007761526721631600234360ustar00rootroot00000000000000#pragma once #include "types.h" namespace bpftrace::ast { class ASTContext; class ParsedType; class LocationChain; using Location = std::shared_ptr; } // namespace bpftrace::ast namespace bpftrace { SizedType parsed_type_to_sized_type(const ast::ParsedType &type); ast::ParsedType *sized_type_to_parsed_type(ast::ASTContext &ctx, const ast::Location &loc, const SizedType &type); } // namespace bpftrace bpftrace-0.27.1/src/ast/passes/types/pre_type_check.cpp000066400000000000000000000566551526721631600231310ustar00rootroot00000000000000#include "ast/passes/types/pre_type_check.h" #include #include #include #include #include #include "arch/arch.h" #include "ast/ast.h" #include "ast/helpers.h" #include "ast/passes/map_sugar.h" #include "ast/visitor.h" #include "bpfmap.h" #include "bpftrace.h" #include "format_string.h" #include "log.h" #include "output/output.h" #include "probe_types.h" namespace bpftrace::ast { namespace { using VarOrigin = std:: variant; struct VarInfo { VarOrigin origin; bool was_assigned; }; using Scope = Node *; void add_origin_context(Diagnostic &d, const VarOrigin &origin) { std::visit( [&d](auto &&arg) { using T = std::decay_t; if constexpr (std::is_same_v) { d.addContext(arg->loc) << "This is the initial declaration."; } else if constexpr (std::is_same_v) { d.addContext(arg->loc) << "This is the initial assignment."; } else if constexpr (std::is_same_v) { d.addContext(arg->loc) << "This is the function parameter."; } else if constexpr (std::is_same_v) { d.addContext(arg->loc) << "This is the loop variable."; } }, origin); } class VariablePreCheck : public Visitor { public: using Visitor::visit; void visit(AssignVarStatement &assignment); void visit(BlockExpr &block); void visit(For &f); void visit(Offsetof &offof); void visit(Probe &probe); void visit(Sizeof &szof); void visit(Subprog &subprog); void visit(SubprogArg &arg); void visit(Typeof &typeof_); void visit(Typeinfo &typeinfo); void visit(VarDeclStatement &decl); void visit(Variable &var); void visit(VariableAddr &var_addr); private: VarInfo *find_variable(const std::string &name); void check_variable_decls(); std::vector scope_stack_; std::map> variables_; uint32_t meta_depth_ = 0; // sizeof, offsetof, typeof, typeinfo }; VarInfo *VariablePreCheck::find_variable(const std::string &name) { for (auto *scope : scope_stack_) { if (auto scope_it = variables_.find(scope); scope_it != variables_.end()) { if (auto var_it = scope_it->second.find(name); var_it != scope_it->second.end()) { return &var_it->second; } } } return nullptr; } void VariablePreCheck::check_variable_decls() { for (const auto &[scope, var_map] : variables_) { for (const auto &[ident, info] : var_map) { if (info.was_assigned) { continue; } if (const auto *decl = std::get_if(&info.origin)) { (*decl)->addWarning() << "Variable " << ident << " was never assigned to."; } } } } void VariablePreCheck::visit(AssignVarStatement &assignment) { visit(assignment.expr); if (std::holds_alternative(assignment.var_decl)) { visit(assignment.var_decl); } const std::string &var_ident = assignment.var()->ident; if (auto *info = find_variable(var_ident)) { info->was_assigned = true; } else if (!scope_stack_.empty()) { variables_[scope_stack_.back()][var_ident] = VarInfo{ .origin = &assignment, .was_assigned = true }; } } void VariablePreCheck::visit(BlockExpr &block) { scope_stack_.push_back(&block); Visitor::visit(block); scope_stack_.pop_back(); } void VariablePreCheck::visit(For &f) { const auto &decl_name = f.decl->ident; if (const auto *info = find_variable(decl_name)) { auto &err = f.decl->addError(); err << "Loop declaration shadows existing variable: " + decl_name; add_origin_context(err, info->origin); } visit(f.iterable); scope_stack_.push_back(&f); // Loop variable is always assigned variables_[&f][decl_name] = VarInfo{ .origin = f.decl, .was_assigned = true }; visit(f.block); scope_stack_.pop_back(); } void VariablePreCheck::visit(Offsetof &offof) { meta_depth_++; Visitor::visit(offof); meta_depth_--; } void VariablePreCheck::visit(Probe &probe) { scope_stack_.push_back(&probe); Visitor::visit(probe); check_variable_decls(); scope_stack_.pop_back(); } void VariablePreCheck::visit(Sizeof &szof) { meta_depth_++; Visitor::visit(szof); meta_depth_--; } void VariablePreCheck::visit(Subprog &subprog) { scope_stack_.push_back(&subprog); // Function parameters are always assigned for (auto *arg : subprog.args) { variables_[&subprog][arg->var->ident] = VarInfo{ .origin = arg, .was_assigned = true }; } visit(subprog.args); visit(subprog.block); visit(subprog.return_type); check_variable_decls(); scope_stack_.pop_back(); } void VariablePreCheck::visit(SubprogArg &arg) { // Only visit typeof, not the variable being defined as a parameter visit(arg.typeof); } void VariablePreCheck::visit(Typeof &typeof_) { meta_depth_++; Visitor::visit(typeof_); meta_depth_--; } void VariablePreCheck::visit(Typeinfo &typeinfo) { meta_depth_++; Visitor::visit(typeinfo); meta_depth_--; } void VariablePreCheck::visit(VarDeclStatement &decl) { // Only visit typeof, not the variable being declared visit(decl.typeof); const std::string &var_ident = decl.var->ident; if (const auto *info = find_variable(var_ident)) { auto &err = decl.addError(); err << "Variable " << var_ident << " was already declared. Variable shadowing is not " "allowed."; add_origin_context(err, info->origin); return; } // Declaration without assignment - was_assigned = false if (!scope_stack_.empty()) { variables_[scope_stack_.back()][var_ident] = VarInfo{ .origin = &decl, .was_assigned = false }; } } void VariablePreCheck::visit(Variable &var) { if (auto *info = find_variable(var.ident)) { if (!info->was_assigned && meta_depth_ == 0) { var.addWarning() << "Variable used before it was assigned: " << var.ident; } } else { var.addError() << "Undefined or undeclared variable: " << var.ident; } } void VariablePreCheck::visit(VariableAddr &var_addr) { if (auto *found = find_variable(var_addr.var->ident)) { // We can't know if the pointer to a scratch variable was passed // to an external function for assignment so just mark it as assigned. found->was_assigned = true; } else { var_addr.var->addError() << "Undefined or undeclared variable: " << var_addr.var->ident; } } bool check_symbol(const Call &call) { auto *arg = call.vargs.at(0).as(); if (!arg) { call.addError() << call.func << "() expects a string literal as the first argument"; return false; } std::string re = "^[a-zA-Z0-9./_-]+$"; bool is_valid = std::regex_match(arg->value, std::regex(re)); if (!is_valid) { call.addError() << call.func << "() expects a string that is a valid symbol (" << re << ") as input (\"" << arg << "\" provided)"; return false; } return true; } struct nargs_spec { size_t min_args = 0; size_t max_args = 0; }; // clang-format off const std::map CALL_NARGS = { { "__builtin_dw_ustack", { .min_args=0, .max_args=2 } }, { "__builtin_uaddr", { .min_args=1, .max_args=1 } }, { "avg", { .min_args=3, .max_args=3 } }, { "bswap", { .min_args=1, .max_args=1 } }, { "buf", { .min_args=1, .max_args=2 } }, { "cat", { .min_args=1, .max_args=128 } }, { "cgroup_path", { .min_args=1, .max_args=2 } }, { "cgroupid", { .min_args=1, .max_args=1 } }, { "clear", { .min_args=1, .max_args=1 } }, { "count", { .min_args=2, .max_args=2 } }, { "debugf", { .min_args=1, .max_args=128 } }, { "errorf", { .min_args=1, .max_args=128 } }, { "exit", { .min_args=0, .max_args=1 } }, { "fail", { .min_args=1, .max_args=128 } }, { "hist", { .min_args=3, .max_args=4 } }, { "join", { .min_args=1, .max_args=2 } }, { "kaddr", { .min_args=1, .max_args=1 } }, { "kptr", { .min_args=1, .max_args=1 } }, { "kstack", { .min_args=0, .max_args=2 } }, { "ksym", { .min_args=1, .max_args=1 } }, { "lhist", { .min_args=6, .max_args=6 } }, { "macaddr", { .min_args=1, .max_args=1 } }, { "max", { .min_args=3, .max_args=3 } }, { "min", { .min_args=3, .max_args=3 } }, { "nsecs", { .min_args=0, .max_args=1 } }, { "ntop", { .min_args=1, .max_args=2 } }, { "offsetof", { .min_args=2, .max_args=2 } }, { "path", { .min_args=1, .max_args=2 } }, { "percpu_kaddr", { .min_args=1, .max_args=2 } }, { "pid", { .min_args=0, .max_args=1 } }, { "print", { .min_args=1, .max_args=3 } }, { "printf", { .min_args=1, .max_args=128 } }, { "pton", { .min_args=1, .max_args=1 } }, { "reg", { .min_args=1, .max_args=1 } }, { "sizeof", { .min_args=1, .max_args=1 } }, { "skboutput", { .min_args=4, .max_args=4 } }, { "socket_cookie", { .min_args=1, .max_args=1 } }, { "stack_len", { .min_args=1, .max_args=1 } }, { "stats", { .min_args=3, .max_args=3 } }, { "str", { .min_args=1, .max_args=2 } }, { "strftime", { .min_args=2, .max_args=2 } }, { "strncmp", { .min_args=3, .max_args=3 } }, { "sum", { .min_args=3, .max_args=3 } }, { "system", { .min_args=1, .max_args=128 } }, { "tid", { .min_args=0, .max_args=1 } }, { "time", { .min_args=0, .max_args=1 } }, { "tseries", { .min_args=5, .max_args=6 } }, { "unwatch", { .min_args=1, .max_args=1 } }, { "uptr", { .min_args=1, .max_args=1 } }, { "ustack", { .min_args=0, .max_args=2 } }, { "usym", { .min_args=1, .max_args=1 } }, { "warnf", { .min_args=1, .max_args=128 } }, { "zero", { .min_args=1, .max_args=1 } }, }; // clang-format on template class AssignMapDisallowed : public Visitor> { public: explicit AssignMapDisallowed() = default; using Visitor::visit; void visit(AssignMapStatement &assignment) { assignment.addError() << "Map assignments not allowed inside of " << name.str(); } }; class MapCheck : public Visitor { public: explicit MapCheck() = default; using Visitor::visit; void visit(Offsetof &offof); void visit(Sizeof &szof); void visit(Typeof &typeof); }; void MapCheck::visit(Offsetof &offof) { AssignMapDisallowed<"offsetof">().visit(offof.type_of->record); } void MapCheck::visit(Sizeof &szof) { AssignMapDisallowed<"sizeof">().visit(szof.type_of->record); } void MapCheck::visit(Typeof &typeof) { AssignMapDisallowed<"typeof or typeinfo">().visit(typeof.record); } class CallPreCheck : public Visitor { public: explicit CallPreCheck(ASTContext &ctx, BPFtrace &bpftrace) : ctx_(ctx), bpftrace_(bpftrace) { } using Visitor::visit; void visit(Call &call); void visit(Identifier &identifier); void visit(Probe &probe); void visit(String &string); void visit(Subprog &subprog); void visit(Unroll &unroll); private: bool check_nargs(const Call &call, size_t expected_nargs); bool check_varargs(const Call &call, size_t min_nargs, size_t max_nargs); ASTContext &ctx_; BPFtrace &bpftrace_; std::string func_; int func_arg_idx_ = -1; Node *top_level_node_ = nullptr; }; bool CallPreCheck::check_nargs(const Call &call, size_t expected_nargs) { std::stringstream err; auto nargs = call.vargs.size(); assert(nargs >= call.injected_args); assert(expected_nargs >= call.injected_args); nargs -= call.injected_args; expected_nargs -= call.injected_args; if (nargs != expected_nargs) { if (expected_nargs == 0) err << call.func << "() requires no arguments"; else if (expected_nargs == 1) err << call.func << "() requires one argument"; else err << call.func << "() requires " << expected_nargs << " arguments"; err << " (" << nargs << " provided)"; call.addError() << err.str(); return false; } return true; } bool CallPreCheck::check_varargs(const Call &call, size_t min_nargs, size_t max_nargs) { std::stringstream err; auto nargs = call.vargs.size(); assert(nargs >= call.injected_args); assert(min_nargs >= call.injected_args); assert(max_nargs >= call.injected_args); nargs -= call.injected_args; min_nargs -= call.injected_args; max_nargs -= call.injected_args; if (nargs < min_nargs) { if (min_nargs == 1) err << call.func << "() requires at least one argument"; else err << call.func << "() requires at least " << min_nargs << " arguments"; err << " (" << nargs << " provided)"; call.addError() << err.str(); return false; } else if (nargs > max_nargs) { if (max_nargs == 0) err << call.func << "() requires no arguments"; else if (max_nargs == 1) err << call.func << "() takes up to one argument"; else err << call.func << "() takes up to " << max_nargs << " arguments"; err << " (" << nargs << " provided)"; call.addError() << err.str(); return false; } return true; } void CallPreCheck::visit(Call &call) { // Check for unsafe-ness first. if (bpftrace_.safe_mode_ && is_unsafe_func(call.func)) { call.addError() << call.func << "() is an unsafe function being used in safe mode"; } struct func_setter { func_setter(CallPreCheck &checker, const std::string &s) : checker_(checker), old_func_(checker_.func_) { checker_.func_ = s; } ~func_setter() { checker_.func_ = old_func_; checker_.func_arg_idx_ = -1; } private: CallPreCheck &checker_; std::string old_func_; }; // Check probe availability if (auto *probe = dynamic_cast(top_level_node_)) { for (auto *ap : probe->attach_points) { if (!ap->check_available(call.func)) { call.addError() << call.func << " can not be used with \"" << ap->provider << "\" probes"; } } } // Check argument count before visiting args to avoid cascading errors. auto spec = CALL_NARGS.find(call.func); if (spec != CALL_NARGS.end()) { bool nargs_ok; if (spec->second.min_args != spec->second.max_args) { nargs_ok = check_varargs(call, spec->second.min_args, spec->second.max_args); } else { nargs_ok = check_nargs(call, spec->second.min_args); } if (!nargs_ok) { return; } } func_setter scope_bound_func_setter{ *this, call.func }; for (size_t i = 0; i < call.vargs.size(); ++i) { func_arg_idx_ = i; visit(call.vargs.at(i)); } if (getRawMapArgFuncs().contains(call.func) && !call.vargs.empty()) { if (call.func != "print" && !call.vargs.at(0).is()) { call.vargs.at(0).node().addError() << call.func << "() expects a map argument"; } } // Per-function literal/structural checks if (call.func == "hist") { // Inject default bits argument (0) if not provided, so that downstream // passes always see 4 arguments. if (call.vargs.size() == 3) { call.vargs.emplace_back(ctx_.make_node(call.loc, 0)); } if (call.vargs.size() == 4) { const auto *bits = call.vargs.at(3).as(); if (!bits) { LOG(BUG) << call.func << ": invalid bits value, need integer literal"; } else if (bits->value > 5) { call.addError() << call.func << ": bits " << bits->value << " must be 0..5"; } } } else if (call.func == "lhist") { Expression &min_arg = call.vargs.at(3); Expression &max_arg = call.vargs.at(4); Expression &step_arg = call.vargs.at(5); auto *min = min_arg.as(); auto *max = max_arg.as(); auto *step = step_arg.as(); if (!min) { call.addError() << call.func << ": invalid min value (must be non-negative literal)"; return; } if (!max) { call.addError() << call.func << ": invalid max value (must be non-negative literal)"; return; } if (!step) { call.addError() << call.func << ": invalid step value"; return; } if (step->value <= 0) { call.addError() << "lhist() step must be >= 1 (" << step->value << " provided)"; } else { int buckets = (max->value - min->value) / step->value; if (buckets > 1000) { call.addError() << "lhist() too many buckets, must be <= 1000 (would need " << buckets << ")"; } } if (min->value > max->value) { call.addError() << "lhist() min must be less than max (provided min " << min->value << " and max " << max->value << ")"; } if ((max->value - min->value) < step->value) { call.addError() << "lhist() step is too large for the given range (provided step " << step->value << " for range " << (max->value - min->value) << ")"; } } else if (call.func == "tseries") { const static std::set ALLOWED_AGG_FUNCS = { "avg", "sum", "max", "min", }; Expression &interval_ns_arg = call.vargs.at(3); Expression &num_intervals_arg = call.vargs.at(4); auto *interval_ns = interval_ns_arg.as(); auto *num_intervals = num_intervals_arg.as(); if (!interval_ns) { call.addError() << call.func << ": invalid interval_ns value (must be non-negative literal)"; return; } if (!num_intervals) { call.addError() << call.func << ": invalid num_intervals value (must be non-negative literal)"; return; } if (interval_ns->value <= 0) { call.addError() << "tseries() interval_ns must be >= 1 (" << interval_ns->value << " provided)"; return; } if (num_intervals->value <= 0) { call.addError() << "tseries() num_intervals must be >= 1 (" << num_intervals->value << " provided)"; return; } else if (num_intervals->value > 1000000) { call.addError() << "tseries() num_intervals must be < 1000000 (" << num_intervals->value << " provided)"; } if (call.vargs.size() == 6) { auto &aggregator = *call.vargs.at(5).as(); if (!ALLOWED_AGG_FUNCS.contains(aggregator.value)) { auto &err = call.addError(); err << "tseries() expects one of the following aggregation " "functions: "; size_t i = 0; for (const std::string &agg : ALLOWED_AGG_FUNCS) { err << agg; if (i++ != ALLOWED_AGG_FUNCS.size() - 1) { err << ", "; } } err << " (\"" << aggregator.value << "\" provided)"; } } } else if (call.func == "reg") { auto reg_name = call.vargs.at(0).as()->value; auto offset = arch::Host::register_to_pt_regs_offset(reg_name); if (!offset) { call.addError() << "'" << reg_name << "' is not a valid register on this architecture" << " (" << arch::Host::Machine << ")"; } } else if (call.func == "debugf") { call.addWarning() << "The debugf() builtin is not recommended for production use. " "For more information see bpf_trace_printk in bpf-helpers(7)."; // bpf_trace_printk cannot use more than three arguments, see // bpf-helpers(7). constexpr int PRINTK_MAX_ARGS = 3; // args are all vargs after the format string auto num_args = call.vargs.size() - 1; if (num_args > static_cast(PRINTK_MAX_ARGS)) { call.addError() << "cannot use more than " << PRINTK_MAX_ARGS << " conversion specifiers"; } } else if (call.func == "path") { if (call.vargs.size() == 2) { auto *size = call.vargs.at(1).as(); if (!size) { call.addError() << call.func << ": invalid size value, need non-negative literal"; } else { const auto max_strlen = bpftrace_.config_->max_strlen; if (size->value > max_strlen) { auto &err = call.addError(); err << call.func << ": size is too long (over " << max_strlen << " bytes): " << size->value; err.addHint() << "Increase BPFTRACE_MAX_STRLEN."; } } } if (auto *probe = dynamic_cast(top_level_node_)) { ProbeType type = probe->get_probetype(); if (type != ProbeType::fentry && type != ProbeType::fexit && type != ProbeType::iter) { call.addError() << "The path function can only be used with " << "'fentry', 'fexit', 'iter' probes"; } } } else if (call.func == "strncmp") { if (!call.vargs.at(2).is()) { call.addError() << "Builtin strncmp requires a non-negative literal"; } } else if (call.func == "pid" || call.func == "tid") { if (call.vargs.size() == 1) { auto &arg = call.vargs.at(0); if (!arg.as()) { call.addError() << call.func << "() only supports curr_ns and init as the argument"; } } } else if (call.func == "__builtin_uaddr") { check_symbol(call); } } void CallPreCheck::visit(Identifier &identifier) { if (func_ == "pid" || func_ == "tid") { if (identifier.ident != "curr_ns" && identifier.ident != "init") { identifier.addError() << "Invalid PID namespace mode: " << identifier.ident << " (expects: curr_ns or init)"; } } } void CallPreCheck::visit(Probe &probe) { top_level_node_ = &probe; Visitor::visit(probe); } void CallPreCheck::visit(String &string) { if ((func_ == "printf" || func_ == "errorf" || func_ == "warnf") && func_arg_idx_ == 0) return; const auto str_len = bpftrace_.config_->max_strlen; if (!is_compile_time_func(func_) && string.value.size() > str_len - 1) { string.addError() << "String is too long (over " << str_len << " bytes): " << string.value; } } void CallPreCheck::visit(Subprog &subprog) { top_level_node_ = &subprog; Visitor::visit(subprog); } void CallPreCheck::visit(Unroll &unroll) { visit(unroll.expr); auto *integer = unroll.expr.as(); if (!integer) { unroll.addError() << "invalid unroll value"; return; } if (integer->value > static_cast(100)) { unroll.addError() << "unroll maximum value is 100"; } else if (integer->value < static_cast(1)) { unroll.addError() << "unroll minimum value is 1"; } visit(unroll.block); } } // namespace Pass CreatePreTypeCheckPass() { return Pass::create("PreTypeCheck", [](ASTContext &ast, BPFtrace &bpftrace) { // Variable state is effectively reset for each probe and subprog for (auto &subprog : ast.root->functions) { VariablePreCheck().visit(subprog); } for (auto &probe : ast.root->probes) { VariablePreCheck().visit(probe); } MapCheck().visit(ast.root); CallPreCheck call_checker(ast, bpftrace); call_checker.visit(ast.root); }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/pre_type_check.h000066400000000000000000000012451526721631600225570ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { // This pass runs early validation checks that do not depend on type // information. It is composed of three separate visitors: // // VariablePreCheck: // - variable was never assigned to // - variable was used before assignment // - variable declaration shadows another variable // - variable is not defined // // CallPreCheck: // - function call argument count validation // - literal/structural validation per function // - safe mode checks // - probe availability checks // - string length checks // - unroll validation Pass CreatePreTypeCheckPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_checker.cpp000066400000000000000000001223621526721631600225770ustar00rootroot00000000000000#include #include #include #include #include "ast/ast.h" #include "ast/async_event_types.h" #include "ast/context.h" #include "ast/integer_types.h" #include "ast/passes/collect_nodes.h" #include "ast/passes/types/type_checker.h" #include "ast/passes/types/type_map.h" #include "ast/passes/types/type_system.h" #include "bpftrace.h" #include "btf/compat.h" #include "config.h" #include "log.h" #include "types.h" #include "util/strings.h" namespace bpftrace::ast { namespace { struct arg_type_spec { Type type = Type::integer; bool literal = false; // This indicates that this is just a placeholder as we use the index in the // vector of arg_type_spec as the number argument to check. bool skip_check = false; }; class TypeChecker : public Visitor { public: explicit TypeChecker(ASTContext &ctx, BPFtrace &bpftrace, CDefinitions &c_definitions, TypeMetadata &type_metadata, const TypeMap &type_map) : ctx_(ctx), bpftrace_(bpftrace), c_definitions_(c_definitions), type_metadata_(type_metadata), type_map_(type_map) { } using Visitor::visit; void visit(Identifier &identifier); void visit(Call &call); void visit(Map &map); void visit(MapDeclStatement &decl); void visit(Variable &var); void visit(VariableAddr &var_addr); void visit(Binop &binop); void visit(While &while_block); void visit(For &f); void visit(Jump &jump); void visit(IfExpr &if_expr); void visit(FieldAccess &acc); void visit(ArrayAccess &arr); void visit(TupleAccess &acc); void visit(MapAccess &acc); void visit(Cast &cast); void visit(Tuple &tuple); void visit(Record &record); void visit(ExprStatement &expr); void visit(AssignVarStatement &assignment); void visit(VarDeclStatement &decl); void visit(Probe &probe); void visit(Subprog &subprog); void visit(Program &program); private: ASTContext &ctx_; BPFtrace &bpftrace_; const CDefinitions &c_definitions_; const TypeMetadata &type_metadata_; const TypeMap &type_map_; [[nodiscard]] bool check_arg(Call &call, size_t index, const arg_type_spec &spec); [[nodiscard]] bool check_call(Call &call); bool check_string_size(Node &node, const SizedType &ty); bool check_arg(Call &call, Type type, size_t index, bool want_literal = false); bool in_loop() { return loop_depth_ > 0; }; Node *top_level_node_ = nullptr; std::map bpf_map_type_; uint32_t loop_depth_ = 0; // Track map declarations for "unused map" warnings std::map map_decls_; std::set used_maps_; }; } // namespace static const std::map> CALL_ARG_TYPE_SPEC = { { "buf", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer } } }, { "cat", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "cgroupid", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "cgroup_path", { arg_type_spec{ .type = Type::integer }, arg_type_spec{ .type = Type::string } } }, { "debugf", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "errorf", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "exit", { arg_type_spec{ .type = Type::integer } } }, { "hist", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer }, arg_type_spec{ .type = Type::integer, .literal = true } } }, { "join", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::string, .literal = true } } }, { "kaddr", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "lhist", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer }, arg_type_spec{ .type = Type::integer, .literal = true }, arg_type_spec{ .type = Type::integer, .literal = true }, arg_type_spec{ .type = Type::integer, .literal = true } } }, { "tseries", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer }, arg_type_spec{ .type = Type::integer, .literal = true }, arg_type_spec{ .type = Type::integer, .literal = true }, arg_type_spec{ .type = Type::string, .literal = true } } }, { "nsecs", { arg_type_spec{ .type = Type::timestamp_mode } } }, { "path", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer, .literal = true } } }, { "percpu_kaddr", { arg_type_spec{ .type = Type::string, .literal = true }, arg_type_spec{ .type = Type::integer } } }, { "print", { // This may be a pure map or not. arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer, .literal = true }, arg_type_spec{ .type = Type::integer, .literal = true } } }, { "printf", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "reg", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "skboutput", { arg_type_spec{ .type = Type::string, .literal = true }, // pcap file // name arg_type_spec{ .type = Type::pointer }, // *skb arg_type_spec{ .type = Type::integer }, // cap length // cap offset, default is 0 // some tracepoints like // dev_queue_xmit will output // ethernet header, set offset // to 14 bytes can exclude // this header arg_type_spec{ .type = Type::integer } } }, { "str", { arg_type_spec{ .skip_check = true }, arg_type_spec{ .type = Type::integer } } }, { "strftime", { arg_type_spec{ .type = Type::string, .literal = true }, arg_type_spec{ .type = Type::integer } } }, { "strncmp", { arg_type_spec{ .type = Type::string }, arg_type_spec{ .type = Type::string }, arg_type_spec{ .type = Type::integer, .literal = true } } }, { "system", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "time", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "__builtin_uaddr", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "unwatch", { arg_type_spec{ .type = Type::integer } } }, { "warnf", { arg_type_spec{ .type = Type::string, .literal = true } } }, { "socket_cookie", { arg_type_spec{ .type = Type::pointer } } }, // struct // sock * { "fail", { arg_type_spec{ .type = Type::string, .literal = true } } }, }; // clang-format on // These are types which aren't valid for scratch variables // e.g. this is not valid `let $x: sum_t;` static bool IsValidVarDeclType(const SizedType &ty) { switch (ty.GetTy()) { case Type::avg_t: case Type::count_t: case Type::hist_t: case Type::lhist_t: case Type::tseries_t: case Type::max_t: case Type::min_t: case Type::stats_t: case Type::sum_t: case Type::voidtype: return false; case Type::integer: case Type::kstack_t: case Type::ustack_t: case Type::timestamp: case Type::ksym_t: case Type::usym_t: case Type::inet: case Type::username_t: case Type::string: case Type::buffer: case Type::pointer: case Type::array: case Type::mac_address: case Type::c_type: case Type::tuple: case Type::record: case Type::cgroup_path_t: case Type::none: case Type::timestamp_mode: case Type::boolean: return true; } return false; // unreachable } void TypeChecker::visit(Identifier &identifier) { // These are used in function arguments and don't have types if (identifier.ident == "curr_ns" || identifier.ident == "init" || identifier.ident == "current_pid" || identifier.ident == "current_tid") { return; } if (type_map_.type(&identifier).IsNoneTy()) { identifier.addError() << "Unknown identifier: '" + identifier.ident + "'"; } } void TypeChecker::visit(Call &call) { for (auto &varg : call.vargs) { visit(varg); } if (!check_call(call)) { return; } if (call.func == "str") { auto &arg = call.vargs.at(0); const auto &t = type_map_.type(arg); if (!t.IsStringTy() && !t.IsIntegerTy() && !t.IsPtrTy()) { call.addError() << call.func << "() expects a string, integer or a pointer type as first " << "argument (" << t << " provided)"; } } else if (call.func == "buf") { const uint64_t max_strlen = bpftrace_.config_->max_strlen; if (max_strlen > std::numeric_limits::max()) { call.addError() << "BPFTRACE_MAX_STRLEN too large to use on buffer (" << max_strlen << " > " << std::numeric_limits::max() << ")"; } auto &arg = call.vargs.at(0); const auto &arg_type = type_map_.type(arg); if (!(arg_type.IsIntTy() || arg_type.IsStringTy() || arg_type.IsPtrTy() || arg_type.IsArrayTy())) { call.addError() << call.func << "() expects an integer, string, or array argument but saw " << typestr(arg_type.GetTy()); } if (call.vargs.size() == 1) { if (!arg_type.IsArrayTy()) { call.addError() << call.func << "() expects a length argument for non-array type " << typestr(arg_type.GetTy()); } } else { if (auto *integer = call.vargs.at(1).as()) { call.addError() << call.func << "cannot use negative length (" << integer->value << ")"; } } } else if (call.func == "ksym" || call.func == "usym") { // allow symbol lookups on casts (eg, function pointers) auto &arg = call.vargs.at(0); const auto &type = type_map_.type(arg); if (!type.IsIntegerTy() && !type.IsPtrTy()) { call.addError() << call.func << "() expects an integer or pointer argument"; } } else if (call.func == "ntop") { int index = 0; if (call.vargs.size() == 2) { check_arg(call, Type::integer, 0); index = 1; } auto &arg = call.vargs.at(index); const auto &arg_type = type_map_.type(arg); if (!arg_type.IsIntTy() && !arg_type.IsStringTy() && !arg_type.IsArrayTy()) call.addError() << call.func << "() expects an integer or array argument, got " << arg_type.GetTy(); // Kind of: // // struct { // int af_type; // union { // char[4] inet4; // char[16] inet6; // } // } auto type = arg_type; if ((arg_type.IsArrayTy() || arg_type.IsStringTy()) && type.GetSize() != 4 && type.GetSize() != 16) call.addError() << call.func << "() argument must be 4 or 16 bytes in size"; } else if (call.func == "join") { auto &arg = call.vargs.at(0); const auto &arg_type = type_map_.type(arg); if (!(arg_type.IsIntTy() || arg_type.IsPtrTy())) { call.addError() << "() only supports int or pointer arguments" << " (" << arg_type.GetTy() << " provided)"; } } else if (call.func == "percpu_kaddr") { const auto &symbol = call.vargs.at(0).as()->value; if (bpftrace_.btf_->get_var_type(symbol).IsNoneTy()) { call.addError() << "Could not resolve variable \"" << symbol << "\" from BTF"; } } else if (call.func == "printf" || call.func == "errorf" || call.func == "warnf" || call.func == "system" || call.func == "cat" || call.func == "debugf") { const auto &fmt = call.vargs.at(0).as()->value; std::vector args; for (size_t i = 1; i < call.vargs.size(); i++) { args.push_back(type_map_.type(call.vargs[i])); } FormatString fs(fmt); auto ok = fs.check(args); if (!ok) { call.addError() << ok.takeError(); } // The `debugf` call is a builtin, and is subject to more much rigorous // checks. We've already validate the basic counts, etc. but we need to // apply these additional constraints which includes a limited surface. if (call.func == "debugf") { for (size_t i = 0; i < args.size(); i++) { // bpf_trace_printk_format_types is a subset of printf_format_types // that contains valid types for bpf_trace_printk() see iovisor/bcc // BTypeVisitor::checkFormatSpecifiers. static const std::unordered_map bpf_trace_printk_format_types = { { "d", Type::integer }, { "u", Type::integer }, { "x", Type::integer }, { "p", Type::integer }, { "s", Type::string } }; auto it = bpf_trace_printk_format_types.find(fs.specs[i].specifier); if (it == bpf_trace_printk_format_types.end()) { call.vargs.at(0).node().addError() << "Invalid format specifier for `debugf`: " << fs.specs[i].specifier; continue; } if (args[i].GetTy() != it->second) { call.vargs.at(i + 1).node().addError() << "Type does not match format specifier: " << fs.specs[i].specifier; continue; } } } } if (call.func == "print") { if (auto *map = call.vargs.at(0).as()) { // N.B. that print is parameteric in the type, so this is not checked // by `check_arg` as there is no spec for the first argument. if (in_loop()) { call.addWarning() << "Due to it's asynchronous nature using " "'print()' in a loop can " "lead to unexpected behavior. The map will " "likely be updated " "before the runtime can 'print' it."; } if (type_map_.map_value_type(map->ident).IsStatsTy() && call.vargs.size() > 1) { call.addWarning() << "print()'s top and div arguments are ignored when used on " "stats() maps."; } } // Note that IsPrintableTy() is somewhat disingenuous here. Printing a // non-map value requires being able to serialize the entire value, so // map-backed types like count(), min(), max(), etc. cannot be printed // through the non-map printing mechanism. // // We rely on the fact that type checking enforces types like count(), // min(), max(), etc. to be assigned directly to a map. else { const auto &varg_type = type_map_.type(call.vargs.at(0)); if (varg_type.IsMultiKeyMapTy()) { call.addError() << "Map type " << varg_type << " cannot print the value of individual keys. You must print " "the whole map."; } else if (varg_type.IsPrintableTy()) { if (call.vargs.size() != 1) call.addError() << "Non-map print() only takes 1 argument, " << call.vargs.size() << " found"; } else { call.addError() << varg_type << " type passed to " << call.func << "() is not printable"; } } } else if (call.func == "stack_len") { if (!type_map_.type(call.vargs.at(0)).IsStack()) { call.addError() << "len() expects a map or stack to be provided"; } } else if (call.func == "strftime") { if (type_map_.type(&call).ts_mode == TimestampMode::monotonic) { call.addError() << "strftime() can not take a monotonic timestamp"; } // Check if timestamp argument is a negative literal auto ×tamp_arg = call.vargs.at(1); if (timestamp_arg.is()) { call.addError() << "strftime() does not accept negative timestamps"; } } else if (call.func == "path") { if (!bpftrace_.feature_->has_d_path()) { call.addError() << "BPF_FUNC_d_path not available for your kernel version"; } // Argument for path can be both record and pointer. // It's pointer when it's passed directly from the probe // argument, like: path(args.path)) // It's record when it's referenced as object pointer // member, like: path(args.filp->f_path)) auto &arg = call.vargs.at(0); const auto &arg_type = type_map_.type(arg); if (!arg_type.IsCTypeTy() && !arg_type.IsPtrTy()) { call.addError() << "path() only supports pointer or C type argument (" << arg_type.GetTy() << " provided)"; } } else if (call.func == "kptr" || call.func == "uptr") { // kptr should accept both integer or pointer. Consider case: kptr($1) auto &arg = call.vargs.at(0); const auto &arg_type = type_map_.type(arg); if (!arg_type.IsIntTy() && !arg_type.IsPtrTy()) { call.addError() << call.func << "() only supports " << "integer or pointer arguments (" << arg_type.GetTy() << " provided)"; return; } } else if (call.func == "macaddr") { auto &arg = call.vargs.at(0); const auto &arg_type = type_map_.type(arg); if (!arg_type.IsIntTy() && !arg_type.IsArrayTy() && !arg_type.IsByteArray() && !arg_type.IsPtrTy()) call.addError() << call.func << "() only supports array or pointer arguments" << " (" << arg_type.GetTy() << " provided)"; if (arg.is()) call.addError() << call.func << "() does not support literal string arguments"; // N.B. When converting from BTF, we can treat string types as 7 bytes in // order to signal to userspace that they are well-formed. However, we can // convert from anything as long as there are at least 6 bytes to read. if ((arg_type.IsArrayTy() || arg_type.IsByteArray()) && arg_type.GetSize() < 6) { call.addError() << call.func << "() argument must be at least 6 bytes in size"; } } else if (call.func == "nsecs") { const auto &nsecs_type = type_map_.type(&call); if (nsecs_type.ts_mode == TimestampMode::tai && !bpftrace_.feature_->has_helper_ktime_get_tai_ns()) { call.addError() << "Kernel does not support tai timestamp, please try sw_tai"; } if (nsecs_type.ts_mode == TimestampMode::sw_tai && !bpftrace_.delta_taitime_.has_value()) { call.addError() << "Failed to initialize sw_tai in " "userspace. This is very unexpected."; } } else if (call.func == "socket_cookie") { auto logError = [&](T name) { call.addError() << call.func << "() only supports 'struct sock *' as the argument (" << name << " provided)"; }; const auto &type = type_map_.type(call.vargs.at(0)); if (!type.IsPtrTy() || !type.GetPointeeTy().IsCTypeTy()) { logError(type.GetTy()); return; } if (!type.GetPointeeTy().IsCompatible(CreateCStruct("struct sock"))) { logError("'" + type.GetPointeeTy().GetName() + " *'"); return; } } else if (call.func == "exit") { // OK } else if (call.func == "fail") { bool fail_valid = true; std::vector args; for (size_t i = 0; i < call.vargs.size(); ++i) { if (!call.vargs[i].is_literal()) { fail_valid = false; call.addError() << "fail() arguments need to be literals"; } else { if (i != 0) { if (auto *val = call.vargs[i].as()) { args.emplace_back(val->value); } else if (auto *val = call.vargs[i].as()) { args.emplace_back(val->value); } else if (auto *val = call.vargs[i].as()) { args.emplace_back(val->value); } else if (auto *val = call.vargs[i].as()) { args.emplace_back(val->value); } } else { if (!call.vargs[0].is()) { call.addError() << "first argument to fail() must be a string literal"; } } } } if (fail_valid) { FormatString fs(call.vargs[0].as()->value); call.addError() << fs.format(args); } } else { // Check here if this corresponds to an external function. We convert the // external type metadata into the internal `SizedType` representation and // check that they are exactly equal. auto maybe_func = type_metadata_.global.lookup(call.func); if (!maybe_func) { consumeError(std::move(maybe_func)); if (type_map_.type(&call).IsNoneTy()) { LOG(BUG) << "Unknown builtin function " << call.func; } return; } const auto &func = *maybe_func; auto proto = func.type(); if (!proto) { consumeError(std::move(proto)); return; } // Convert all arguments. auto argument_types = proto->argument_types(); if (!argument_types) { call.addError() << "Unable to read argument types: " << argument_types.takeError(); return; } // Check the argument count. if (argument_types->size() != call.vargs.size()) { call.addError() << "Function `" << call.func << "` requires " << argument_types->size() << " arguments, got only " << call.vargs.size(); return; } std::vector> args; for (size_t i = 0; i < argument_types->size(); i++) { const auto &[name, type] = argument_types->at(i); const auto &varg_type = type_map_.type(call.vargs[i]); auto compat_arg_type = getCompatType(type, bpftrace_.structs); if (!compat_arg_type) { // If the required type is a **pointer**, and the provided type is // a **pointer**, then we let it slide. Just assume the user knows // what they are doing. The verifier will catch them out otherwise. if (type.is() && varg_type.IsPtrTy()) { args.emplace_back(name, varg_type); continue; } call.addError() << "Unable to convert argument type, " << "function requires '" << type << "', " << "found '" << typestr(varg_type) << "': " << compat_arg_type.takeError(); continue; } args.emplace_back(name, std::move(*compat_arg_type)); } if (args.size() != argument_types->size()) { return; // Already emitted errors. } // Check all the individual arguments. bool ok = true; for (size_t i = 0; i < args.size(); i++) { const auto &[name, type] = args[i]; const auto &varg_type = type_map_.type(call.vargs[i]); if (type != varg_type) { if (!name.empty()) { call.vargs[i].node().addError() << "Expected " << typestr(type) << " for argument `" << name << "` got " << typestr(varg_type); } else { call.vargs[i].node().addError() << "Expected " << typestr(type) << " got " << typestr(varg_type); } ok = false; } } // Build our full proto as an error message. std::stringstream fullmsg; fullmsg << "Function `" << call.func << "` requires arguments ("; bool first = true; for (const auto &[name, type] : args) { if (!first) { fullmsg << ", "; } fullmsg << typestr(type); first = false; } fullmsg << ")"; if (!ok) { call.addError() << fullmsg.str(); return; } } } void TypeChecker::visit(MapDeclStatement &decl) { const auto bpf_type = get_bpf_map_type(decl.bpf_type); if (!bpf_type) { auto &err = decl.addError(); err << "Invalid bpf map type: " << decl.bpf_type; auto &hint = err.addHint(); add_bpf_map_types_hint(hint); } else { bpf_map_type_.insert({ decl.ident, *bpf_type }); } map_decls_.insert({ decl.ident, &decl }); } void TypeChecker::visit(Map &map) { used_maps_.insert(map.ident); const auto &value_type = type_map_.map_value_type(map.ident); const auto &key_type = type_map_.map_key_type(map.ident); if (value_type.IsNoneTy() || key_type.IsNoneTy()) { map.addError() << "Undefined map: " + map.ident; } // Note that the naked `Map` node actually gets no type, the type // is applied to the node at the `MapAccess` level. auto found_kind = bpf_map_type_.find(map.ident); if (found_kind != bpf_map_type_.end()) { if (!bpf_map_types_compatible(value_type, found_kind->second)) { auto map_type = get_bpf_map_type(value_type); map.addError() << "Incompatible map types. Type from declaration: " << get_bpf_map_type_str(found_kind->second) << ". Type from value/key type: " << get_bpf_map_type_str(map_type); } } } void TypeChecker::visit(Variable &var) { if (type_map_.type(&var).IsNoneTy()) { var.addError() << "Could not resolve the type of this variable"; } } void TypeChecker::visit(VariableAddr &var_addr) { if (type_map_.type(&var_addr).IsNoneTy()) { var_addr.addError() << "No type available for variable " << var_addr.var->ident; } } void TypeChecker::visit(ArrayAccess &arr) { visit(arr.expr); visit(arr.indexpr); const SizedType &type = type_map_.type(arr.expr); if (type.IsPtrTy() && type.GetPointeeTy().GetSize() == 0) { arr.addError() << "The array index operator [] cannot be used " "on a pointer to an unsized type (void *)."; } if (auto *integer = arr.indexpr.as()) { auto num = [&]() -> size_t { if (type.IsArrayTy()) { return type.GetNumElements(); } else if (type.IsStringTy()) { return type.GetSize(); } else { return 0; } }(); if (num != 0 && static_cast(integer->value) >= num) { arr.addError() << "the index " << integer->value << " is out of bounds for array of size " << num; } } else { const auto &idx_type = type_map_.type(arr.indexpr); if (!idx_type.IsIntTy() || (idx_type.IsSigned() && !idx_type.IsSignFlexible())) { arr.addError() << "The array index operator [] only " "accepts non-negative integer indices. Got: " << idx_type; } } } void TypeChecker::visit(TupleAccess &acc) { visit(acc.expr); const SizedType &type = type_map_.type(acc.expr); if (!type.IsTupleTy()) { acc.addError() << "Can not access index '" << acc.index << "' on expression of type '" << type << "'"; return; } if (acc.index >= type.GetFields().size()) { acc.addError() << "Invalid tuple index: " << acc.index << ". Found " << type.GetFields().size() << " elements in tuple."; } } void TypeChecker::visit(Binop &binop) { visit(binop.left); visit(binop.right); const auto &lht = type_map_.type(binop.left); const auto &rht = type_map_.type(binop.right); bool is_int_binop = (lht.IsCastableMapTy() || lht.IsIntTy() || lht.IsBoolTy()) && (rht.IsCastableMapTy() || rht.IsIntTy() || rht.IsBoolTy()); bool is_ptr_binop = lht.IsPtrTy() || rht.IsPtrTy(); bool is_array_binop = lht.IsArrayTy() && rht.IsArrayTy(); if (is_int_binop || is_ptr_binop) { // Already handled in a previous pass } else if (is_array_binop) { if (binop.op != Operator::EQ && binop.op != Operator::NE) { binop.addError() << "The " << opstr(binop) << " operator cannot be used on arrays."; } if (lht.GetNumElements() != rht.GetNumElements()) { binop.addError() << "Only arrays of same size support comparison operators."; } if (!lht.GetElementTy().IsIntegerTy() || lht != rht) { binop.addError() << "Only arrays of same sized integer support comparison operators."; } } else if (!lht.IsCompatible(rht)) { auto &err = binop.addError(); err << "Type mismatch for '" << opstr(binop) << "': comparing " << lht << " with " << rht; err.addContext(binop.left.loc()) << "left (" << lht << ")"; err.addContext(binop.right.loc()) << "right (" << rht << ")"; } // Also allow combination like reg("sp") + 8 else if (binop.op != Operator::EQ && binop.op != Operator::NE) { binop.addError() << "The " << opstr(binop) << " operator can not be used on expressions of types " << lht << ", " << rht; } } void TypeChecker::visit(IfExpr &if_expr) { visit(if_expr.cond); visit(if_expr.left); visit(if_expr.right); const Type &cond = type_map_.type(if_expr.cond).GetTy(); if (cond != Type::integer && cond != Type::pointer && cond != Type::boolean) { if_expr.addError() << "Invalid condition: " << cond; return; } } void TypeChecker::visit(Jump &jump) { if (jump.ident == JumpType::RETURN) { visit(jump.return_value); if (dynamic_cast(top_level_node_)) { if (jump.return_value.has_value()) { const auto &ty = type_map_.type(*jump.return_value); if (!ty.IsIntegerTy()) { jump.addError() << "Probe return values can only be integers. Found " << ty; } } } } } void TypeChecker::visit(While &while_block) { visit(while_block.cond); loop_depth_++; visit(while_block.block); loop_depth_--; } void TypeChecker::visit(For &f) { if (f.iterable.is() && !bpftrace_.feature_->has_helper_loop()) { f.addError() << "Missing required kernel feature: loop"; } visit(f.iterable); loop_depth_++; visit(f.block); loop_depth_--; // Currently, we do not pass BPF context to the callback so disable builtins // which require ctx access. CollectNodes builtins; builtins.visit(f.block); for (Builtin &builtin : builtins.nodes()) { if (type_map_.type(&builtin).IsCtxAccess()) { builtin.addError() << "'" << builtin.ident << "' builtin is not allowed in a for-loop"; } } } void TypeChecker::visit(FieldAccess &acc) { visit(acc.expr); SizedType type = type_map_.type(acc.expr); while (type.IsPtrTy()) { type = type.GetPointeeTy(); } if (!type.IsCTypeTy() && !type.IsTupleTy() && !type.IsRecordTy()) { return; } const auto &record = type.GetStruct(); if (!record) { return; } if (!record->HasField(acc.field)) { return; } const auto &field = record->GetField(acc.field); if (record->is_tracepoint_args && field.offset < 8) acc.addError() << "BPF does not support accessing common tracepoint fields"; } void TypeChecker::visit(MapAccess &acc) { visit(acc.map); visit(acc.key); if (type_map_.map_value_type(acc.map->ident).IsCastableMapTy() && !bpftrace_.feature_->has_helper_map_lookup_percpu_elem()) { acc.addError() << "Missing required kernel feature: map_lookup_percpu_elem"; } // Validate map key type const auto &key_type = type_map_.type(acc.key); if (key_type.IsPtrTy() && key_type.IsCtxAccess()) { // map functions only accepts a pointer to a element in the stack acc.key.node().addError() << "context cannot be part of a map key"; } if (key_type.IsHistTy() || key_type.IsLhistTy() || key_type.IsStatsTy() || key_type.IsTSeriesTy()) { acc.key.node().addError() << key_type << " cannot be part of a map key"; } if (key_type.IsNoneTy() || key_type.IsVoidTy()) { acc.key.node().addError() << "Invalid map key type: " << key_type; } // For tuple keys, validate each element if (key_type.IsTupleTy()) { for (const auto &field : key_type.GetFields()) { if (field.type.IsPtrTy() && field.type.IsCtxAccess()) { acc.key.node().addError() << "context cannot be part of a map key"; } if (field.type.IsHistTy() || field.type.IsLhistTy() || field.type.IsStatsTy() || field.type.IsTSeriesTy()) { acc.key.node().addError() << field.type << " cannot be part of a map key"; } } } } void TypeChecker::visit(Cast &cast) { visit(cast.expr); visit(cast.typeof); const auto &ty = type_map_.type(&cast); if (ty.IsNoneTy()) { cast.addError() << "Incomplete cast, unknown type"; return; } auto rhs = type_map_.type(cast.expr); if (rhs.IsCTypeTy()) { cast.addError() << "Cannot cast from C type \"" << rhs << "\""; return; } else if (rhs.IsNoneTy()) { cast.addError() << "Cannot cast from \"" << rhs << "\" type"; return; } if (!check_string_size(cast, ty)) { return; } if (ty == rhs) { cast.addWarning() << "Unnecessary cast: expression is already of type " << rhs; return; } auto logError = [&]() { cast.addError() << "Cannot cast from \"" << rhs << "\" to \"" << ty << "\""; }; if (ty.IsStringTy() && rhs.IsStringTy()) { if (ty.GetSize() < rhs.GetSize()) { logError(); } return; } if (ty.IsUsernameTy() && rhs.IsIntegerTy()) { return; } if (!ty.IsIntTy() && !ty.IsPtrTy() && !ty.IsBoolTy() && (!ty.IsPtrTy() || ty.GetElementTy().IsIntTy() || ty.GetElementTy().IsCTypeTy()) && // we support casting integers to int arrays !(ty.IsArrayTy() && ty.GetElementTy().IsBoolTy()) && !(ty.IsArrayTy() && ty.GetElementTy().IsIntTy())) { logError(); } if (ty.IsArrayTy()) { if (ty.GetNumElements() == 0) { if (ty.GetElementTy().GetSize() == 0) { cast.addError() << "Could not determine size of the array"; } else { if (rhs.GetSize() % ty.GetElementTy().GetSize() != 0) { cast.addError() << "Cannot determine array size: the element size is " "incompatible with the cast integer size"; } } } if (rhs.IsIntTy()) { if ((ty.GetElementTy().IsIntegerTy() || ty.GetElementTy().IsBoolTy())) { if ((ty.GetSize() <= 8) && (ty.GetSize() > rhs.GetSize())) { // ok } else if (ty.GetSize() != rhs.GetSize()) { logError(); } } } else { if ((!rhs.IsBoolTy() && !rhs.IsStringTy()) || ty.GetSize() != rhs.GetSize()) { logError(); } } } if (ty.IsEnumTy()) { if (!c_definitions_.enum_defs.contains(ty.GetName())) { cast.addError() << "Unknown enum: " << ty.GetName(); } else { if (auto *integer = cast.expr.as()) { const auto &enums = c_definitions_.enum_defs.at(ty.GetName()); if (!enums.contains(integer->value)) { cast.addError() << "Enum: " << ty.GetName() << " doesn't contain a variant value of " << integer->value; } } } } if (!rhs.IsPtrTy() && !rhs.IsCastableMapTy() && !rhs.IsIntTy()) { if (ty.IsBoolTy() && !rhs.IsStringTy()) { logError(); } if (ty.IsIntTy() && !rhs.IsBoolTy() && !rhs.IsCtxAccess() && !rhs.IsArrayTy()) { logError(); } } if ((rhs.IsArrayTy() && (!ty.IsIntTy() || ty.GetSize() != rhs.GetSize()))) { logError(); } } void TypeChecker::visit(Tuple &tuple) { for (auto &elem : tuple.elems) { visit(elem); // If elem type is none that means that the tuple is not yet resolved. const auto &elem_type = type_map_.type(elem); if (elem_type.IsMultiKeyMapTy()) { elem.node().addError() << "Map type " << elem_type << " cannot exist inside a tuple."; } } } void TypeChecker::visit(Record &record) { for (auto *named_arg : record.elems) { auto &elem = named_arg->expr; visit(elem); const auto &elem_type = type_map_.type(elem); if (elem_type.IsMultiKeyMapTy()) { elem.node().addError() << "Map type " << elem_type << " cannot exist inside a record."; } } } void TypeChecker::visit(ExprStatement &expr) { visit(expr.expr); bool warn_discarded = true; if (auto *unop = expr.expr.as()) { if (unop->op == Operator::PRE_INCREMENT || unop->op == Operator::PRE_DECREMENT || unop->op == Operator::POST_INCREMENT || unop->op == Operator::POST_DECREMENT) { warn_discarded = false; } } const auto &expr_type = type_map_.type(expr.expr); if (expr_type.IsNoneTy() || expr_type.IsVoidTy()) { warn_discarded = false; } if (warn_discarded) { expr.addWarning() << "Return value discarded."; } } void TypeChecker::visit(AssignVarStatement &assignment) { visit(assignment.expr); // Only visit the declaration if it is a `let` declaration, // otherwise skip as it is not a variable access. if (std::holds_alternative(assignment.var_decl)) { visit(assignment.var_decl); } if (type_map_.type(assignment.var()).IsNoneTy()) { assignment.addError() << "Invalid expression for assignment"; } } void TypeChecker::visit(VarDeclStatement &decl) { visit(decl.typeof); if (decl.typeof) { const auto &ty = type_map_.type(decl.typeof); if (!ty.IsNoneTy()) { if (!IsValidVarDeclType(ty)) { decl.typeof->addError() << "Invalid variable declaration type: " << ty; } else { check_string_size(*decl.typeof, ty); } } else { // We couldn't resolve that specific type by now. decl.typeof->addError() << "Type cannot be resolved: still none"; } } } void TypeChecker::visit(Probe &probe) { top_level_node_ = &probe; visit(probe.attach_points); visit(probe.block); } void TypeChecker::visit(Subprog &subprog) { top_level_node_ = &subprog; // Validate that arguments are set. visit(subprog.args); for (SubprogArg *arg : subprog.args) { if (type_map_.type(arg->typeof).IsNoneTy()) { arg->addError() << "Unable to resolve argument type."; } else { check_string_size(*arg->typeof, type_map_.type(arg->typeof)); } } // Visit all statements. visit(subprog.block); // Validate that the return type is valid. visit(subprog.return_type); if (type_map_.type(subprog.return_type).IsNoneTy()) { subprog.return_type->addError() << "Unable to resolve suitable return type."; } else { check_string_size(*subprog.return_type, type_map_.type(subprog.return_type)); } } bool TypeChecker::check_string_size(Node &node, const SizedType &ty) { const auto max_strlen = bpftrace_.config_->max_strlen; if (!ty.IsStringTy() || ty.GetSize() <= max_strlen) { return true; } auto &err = node.addError(); err << "String type is too long (over " << max_strlen << " bytes): " << ty; err.addHint() << "Increase BPFTRACE_MAX_STRLEN."; return false; } void TypeChecker::visit(Program &program) { Visitor::visit(program); for (const auto &[ident, decl] : map_decls_) { if (!used_maps_.contains(ident)) { decl->addWarning() << "Unused map: " << ident; } } } bool TypeChecker::check_arg(Call &call, size_t index, const arg_type_spec &spec) { if (spec.skip_check) { return true; } return check_arg(call, spec.type, index, spec.literal); } bool TypeChecker::check_call(Call &call) { auto spec = CALL_ARG_TYPE_SPEC.find(call.func); if (spec == CALL_ARG_TYPE_SPEC.end()) { return true; } auto ret = true; for (size_t i = 0; i < spec->second.size() && i < call.vargs.size(); ++i) { ret = check_arg(call, i, spec->second.at(i)); } return ret; } // Checks an argument passed to a function is of the correct type. // // This function does not check that the function has the correct number of // arguments. Either check_nargs() or check_varargs() should be called first // to validate this. bool TypeChecker::check_arg(Call &call, Type type, size_t index, bool want_literal) { const auto &arg = call.vargs.at(index); const auto &arg_type = type_map_.type(arg); if (want_literal && (!arg.is_literal() || arg_type.GetTy() != type)) { call.addError() << call.func << "() expects a " << type << " literal (" << arg_type.GetTy() << " provided)"; if (type == Type::string) { // If the call requires a string literal and a positional parameter is // given, tell user to use str() auto *pos_param = arg.as(); if (pos_param) pos_param->addError() << "Use str($" << pos_param->n << ") to treat $" << pos_param->n << " as a string"; } return false; } else if (arg_type.GetTy() != type) { call.addError() << call.func << "() only supports " << type << " arguments (" << arg_type.GetTy() << " provided)"; return false; } return true; } void RunTypeChecker(ASTContext &ast, BPFtrace &b, CDefinitions &c_definitions, TypeMetadata &types, const TypeMap &type_map) { TypeChecker checker(ast, b, c_definitions, types, type_map); checker.visit(ast.root); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_checker.h000066400000000000000000000006111526721631600222340ustar00rootroot00000000000000#pragma once namespace bpftrace { class BPFtrace; } namespace bpftrace::ast { class ASTContext; class TypeMap; struct CDefinitions; struct TypeMetadata; void RunTypeChecker(ASTContext &ast, BPFtrace &b, CDefinitions &c_definitions, TypeMetadata &types, const TypeMap &type_map); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_map.h000066400000000000000000000033161526721631600214120ustar00rootroot00000000000000#pragma once #include "ast/ast.h" #include "ast/pass_manager.h" #include "ast/passes/types/type_resolver.h" #include "log.h" namespace bpftrace::ast { class TypeMap : public State<"resolved-types"> { public: explicit TypeMap(ResolvedTypes resolved_types) : resolved_types_(std::move(resolved_types)) { } TypeMap(TypeMap &&) = default; TypeMap &operator=(TypeMap &&) = default; const SizedType &type(Node *node) const { auto it = resolved_types_.find(node); if (it != resolved_types_.end()) { return it->second; } return none_type(); } const SizedType &type(const Expression &expr) const { return type(&expr.node()); } const SizedType &map_key_type(const std::string &ident) const { auto it = resolved_types_.find(get_map_key_name(ident)); if (it != resolved_types_.end()) { return it->second; } return none_type(); } const SizedType &map_value_type(const std::string &ident) const { auto it = resolved_types_.find(get_map_value_name(ident)); if (it != resolved_types_.end()) { return it->second; } return none_type(); } const SizedType *find_map_key_type(const std::string &ident) const { auto it = resolved_types_.find(get_map_key_name(ident)); return it != resolved_types_.end() ? &it->second : nullptr; } const SizedType *find_map_value_type(const std::string &ident) const { auto it = resolved_types_.find(get_map_value_name(ident)); return it != resolved_types_.end() ? &it->second : nullptr; } private: static const SizedType &none_type() { static const SizedType none_ty = CreateNone(); return none_ty; } ResolvedTypes resolved_types_; }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_resolver.cpp000066400000000000000000002636231526721631600230420ustar00rootroot00000000000000#include "ast/passes/types/type_resolver.h" #include "ast/ast.h" #include "ast/async_event_types.h" #include "ast/integer_types.h" #include "ast/passes/clang_parser.h" #include "ast/passes/collect_nodes.h" #include "ast/passes/fold_literals.h" #include "ast/passes/macro_expansion.h" #include "ast/passes/map_sugar.h" #include "ast/passes/named_param.h" #include "ast/passes/types/ast_transformer.h" #include "ast/passes/types/cast_creator.h" #include "ast/passes/types/parsed_type_bridge.h" #include "ast/passes/types/type_checker.h" #include "ast/passes/types/type_map.h" #include "ast/passes/types/type_system.h" #include "ast/visitor.h" #include "bpftrace.h" #include "btf/compat.h" #include "config.h" #include "config_parser.h" #include "log.h" #include "probe_types.h" #include "struct.h" #include "types.h" #include #include #include #include namespace bpftrace::ast { namespace { std::unordered_set VOID_RETURNING_FUNCS = { "join", "printf", "errorf", "warnf", "system", "cat", "debugf", "exit", "print", "clear", "zero", "time", "unwatch", "fail" }; std::unordered_map SIMPLE_BUILTIN_TYPES = { { "pid", CreateUInt32 }, { "tid", CreateUInt32 }, { "nsecs", CreateUInt64 }, { "__builtin_elapsed", CreateUInt64 }, { "__builtin_cpu", CreateUInt64 }, { "__builtin_ncpus", CreateUInt64 }, { "__builtin_usermode", CreateUInt8 }, { "__builtin_cpid", CreateUInt64 }, }; std::unordered_map SIMPLE_CALL_TYPES = { { "ksym", CreateKSym }, { "usym", CreateUSym }, { "cgroupid", CreateUInt64 }, { "cgroup_path", CreateCgroupPath }, { "stack_len", CreateInt64 }, { "macaddr", CreateMacAddress }, { "skboutput", CreateUInt32 }, { "strncmp", CreateUInt64 }, { "socket_cookie", CreateUInt64 }, }; const std::unordered_map AGGREGATE_HINTS{ { Type::count_t, "count()" }, { Type::sum_t, "sum(retval)" }, { Type::min_t, "min(retval)" }, { Type::max_t, "max(retval)" }, { Type::avg_t, "avg(retval)" }, { Type::hist_t, "hist(retval)" }, { Type::lhist_t, "lhist(rand %10, 0, 10, 1)" }, { Type::tseries_t, "tseries(rand %10, 10s, 1)" }, { Type::stats_t, "stats(arg2)" }, }; AddrSpace find_addrspace(ProbeType pt) { switch (pt) { case ProbeType::kprobe: case ProbeType::kretprobe: case ProbeType::fentry: case ProbeType::fexit: case ProbeType::tracepoint: case ProbeType::iter: case ProbeType::rawtracepoint: return AddrSpace::kernel; case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: return AddrSpace::user; case ProbeType::invalid: case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::profile: case ProbeType::interval: case ProbeType::software: case ProbeType::hardware: case ProbeType::watchpoint: return AddrSpace::none; } return {}; // unreached } struct TypeRule { TypeVariable output; std::vector inputs; std::function &)> resolve; }; class TypeResolver { public: void set_type(const TypeVariable &node, const SizedType &type) { if (type.IsNoneTy()) { return; } types_[node] = type; seeded_nodes_.push_back(node); } const SizedType &get_type(const TypeVariable &node) const { static const SizedType none_type = CreateNone(); auto it = types_.find(node); return it != types_.end() ? it->second : none_type; } void add_type_rule(TypeRule type_rule) { size_t idx = type_rules_.size(); for (const auto &input : type_rule.inputs) { dependents_[input].push_back(idx); } type_rules_.push_back(std::move(type_rule)); } void add_pass_through(const TypeVariable &source, const TypeVariable &target) { add_type_rule({ .output = target, .inputs = { source }, .resolve = [](const std::vector &inputs) -> SizedType { return inputs[0]; }, }); } void resolve(const std::unordered_set &map_value_names) { // Seed worklist from nodes that were set during the visit phase, // in the order they were set (preserves AST visitation order). for (const auto &node : seeded_nodes_) { enqueue_dependents(node); } while (!worklist_.empty()) { auto idx = worklist_.front(); worklist_.pop(); in_worklist_.erase(idx); auto &type_rule = type_rules_[idx]; // Check all inputs are resolved std::vector input_types; input_types.reserve(type_rule.inputs.size()); bool all_resolved = true; for (const auto &input : type_rule.inputs) { const auto &t = get_type(input); if (t.IsNoneTy()) { all_resolved = false; break; } input_types.push_back(t); } if (!all_resolved) { continue; } auto result_type = type_rule.resolve(input_types); if (result_type.IsNoneTy()) { continue; } // N.B. this is ok because nothing lists AST Map nodes as a dependent. AST // Map nodes have two types (key type and value type) so storing and // referencing a single type for an AST Map node is not correct const auto ¤t_type = types_[type_rule.output]; // Types can become not sign flexible but not the other way around bool ignore_sign_flexible = (current_type.IsSignFlexible() == result_type.IsSignFlexible()) || (!current_type.IsSignFlexible() && result_type.IsSignFlexible()); // TODO: further investigate and fix this weirdness with address space and // ctx access bool ignore_address_space = (current_type.GetAS() == result_type.GetAS() || current_type.GetAS() != AddrSpace::none); if (current_type == result_type && ignore_sign_flexible && ignore_address_space && current_type.IsCtxAccess() == result_type.IsCtxAccess()) { continue; } types_[type_rule.output] = result_type; enqueue_dependents(type_rule.output); } // There are some map expressions that self initialize, e.g. `@a++` or `@a // +=1` and there are no other assignments to them. Treat these as holding // an int8 value type, as this is equivalent to a default 0 assignment, and // then try again to resolve bool had_unresolved_map_values = false; for (const auto &name : map_value_names) { const auto ¤t_type = get_type(name); if (current_type.IsNoneTy()) { had_unresolved_map_values = true; set_type(name, CreateInt8()); } } if (had_unresolved_map_values) { // Re-run the solve resolve(map_value_names); } } const ResolvedTypes &get_resolved_types() const { return types_; } private: ResolvedTypes types_; std::vector seeded_nodes_; std::vector type_rules_; std::unordered_map, TypeVariableHash> dependents_; std::queue worklist_; std::unordered_set in_worklist_; void enqueue_dependents(const TypeVariable &node) { auto it = dependents_.find(node); if (it == dependents_.end()) return; for (auto idx : it->second) { if (in_worklist_.insert(idx).second) { worklist_.push(idx); } } } }; using LockedNodes = std::unordered_map; class TypeRuleCollector : public Visitor { public: explicit TypeRuleCollector(ASTContext &ast, BPFtrace &bpftrace, MapMetadata &map_metadata, CDefinitions &c_definitions, NamedParamInfo &named_param_info, TypeMetadata &type_metadata, const MacroRegistry ¯o_registry, TypeResolver &resolver, LockedNodes locked_nodes = {}) : ast_(ast), bpftrace_(bpftrace), map_metadata_(map_metadata), c_definitions_(c_definitions), named_param_info_(named_param_info), type_metadata_(type_metadata), macro_registry_(macro_registry), resolver_(resolver), locked_nodes_(std::move(locked_nodes)) { } using Visitor::visit; void visit(ArrayAccess &arr); void visit(AssignMapStatement &assignment); void visit(AssignVarStatement &assignment); void visit(Binop &binop); void visit(BlockExpr &block); void visit(Boolean &boolean); void visit(Builtin &builtin); void visit(Call &call); void visit(Cast &cast); void visit(Comptime &comptime); void visit(ExprStatement &expr); void visit(FieldAccess &acc); void visit(For &f); void visit(Identifier &identifier); void visit(IfExpr &if_expr); void visit(Integer &integer); void visit(Jump &jump); void visit(Map &map); void visit(MapAccess &acc); void visit(MapAddr &map_addr); void visit(NegativeInteger &integer); void visit(Offsetof &offof); void visit(PositionalParameter ¶m); void visit(PositionalParameterCount ¶m); void visit(Probe &probe); void visit(Record &record); void visit(Sizeof &szof); void visit(String &str); void visit(Subprog &subprog); void visit(Tuple &tuple); void visit(TupleAccess &acc); void visit(Typeof &typeof); void visit(Typeinfo &typeinfo); void visit(Unop &unop); void visit(VarDeclStatement &decl); void visit(Variable &var); void visit(VariableAddr &var_addr); LockedNodes get_locked_nodes(); const std::vector &get_unresolved_comptimes() const { return unresolved_comptimes_; } const std::unordered_set &get_map_value_names() const { return map_value_names_; } private: ASTContext &ast_; BPFtrace &bpftrace_; MapMetadata &map_metadata_; CDefinitions &c_definitions_; NamedParamInfo &named_param_info_; TypeMetadata &type_metadata_; const MacroRegistry ¯o_registry_; TypeResolver &resolver_; const LockedNodes locked_nodes_; std::unordered_map> variables_; std::unordered_set map_value_names_; std::map> for_vars_referenced_; // These are variables that have a declaration with a type with a SIZE // let $a: uint16; // type with a size // let $a; // no type no size // let $a: string // type but no size std::unordered_set sized_decl_vars_; std::vector scope_stack_; Probe *probe_ = nullptr; std::string func_; // tracks Call context for Identifier resolution int introspection_level_ = 0; // Only includes ScopedVariables and map keys/value strings std::unordered_set introspected_nodes_; std::vector unresolved_comptimes_; // This is for tracking type compatibilty for the arguments passed to map // aggregate functions, e.g. `sum`, `avg`, etc. // `sum((uint64)1)` is not compatible with `sum((int64)-1)` std::unordered_map agg_map_args_; // Cached map name strings to avoid repeated allocations std::unordered_map map_key_name_cache_; std::unordered_map map_value_name_cache_; const std::string &map_key_name(const std::string &ident) { auto [it, inserted] = map_key_name_cache_.try_emplace(ident); if (inserted) { it->second = get_map_key_name(ident); } return it->second; } const std::string &map_value_name(const std::string &ident) { auto [it, inserted] = map_value_name_cache_.try_emplace(ident); if (inserted) { it->second = get_map_value_name(ident); } return it->second; } std::optional resolve_parsed_type(ParsedType *type, Node &node); bool resolve_external_type(SizedType &type, Node &node); bool check_offsetof_type(Offsetof &offof, SizedType c_type); SizedType get_var_type(const ScopedVariable &scoped_var, const SizedType &type, Node &error_node); SizedType get_map_value_type(const std::string &map_name, const SizedType &type, Node &error_node); SizedType get_agg_map_type(const std::string &map_name, const SizedType &type, Call &call); SizedType get_map_key_type(const std::string &map_name, const SizedType &type, Node &error_node); Node *find_variable_scope(const std::string &var_ident, bool safe = true); SizedType get_locked_node(const TypeVariable &node, const SizedType &type, Node &error_node, const std::string &name); Probe *get_probe(); Probe *get_probe(Node &node, std::string name = ""); SizedType get_stack_type(Call &call, bool kernel); }; SizedType get_binop_ptr(Binop &binop, const SizedType &lht, const SizedType &rht) { bool left_is_ptr = lht.IsPtrTy(); const auto &ptr = left_is_ptr ? lht : rht; const auto &other = left_is_ptr ? rht : lht; bool compare = is_comparison_op(binop.op); bool logical = binop.op == Operator::LAND || binop.op == Operator::LOR; auto invalid_op = [&binop, &lht, &rht]() -> SizedType { binop.addError() << "The " << opstr(binop) << " operator can not be used on expressions of types " << lht << ", " << rht; return CreateNone(); }; // Binop on two pointers if (other.IsPtrTy()) { if (compare) { const auto le = lht.GetPointeeTy(); const auto re = rht.GetPointeeTy(); if (le != re) { auto &warn = binop.addWarning(); warn << "comparison of distinct pointer types: " << le << ", " << re; warn.addContext(binop.left.loc()) << "left (" << le << ")"; warn.addContext(binop.right.loc()) << "right (" << re << ")"; } return CreateBool(); } else if (!logical) { return invalid_op(); } else { return CreateBool(); } } // Binop on a pointer and (int or bool) else if (other.IsIntTy() || other.IsBoolTy()) { // sum is associative but minus only works with pointer on the left hand // side if (binop.op == Operator::MINUS && !left_is_ptr) return invalid_op(); else if (binop.op == Operator::PLUS || binop.op == Operator::MINUS) return CreatePointer(ptr.GetPointeeTy(), ptr.GetAS()); else if (!compare && !logical) return invalid_op(); if (compare) { return CreateBool(); } else { return invalid_op(); } } // Binop on a pointer and something else else { return invalid_op(); } } SizedType get_binop_int(Binop &binop, const SizedType &lht, const SizedType &rht) { auto left_type = lht; auto right_type = rht; if (left_type.IsSignFlexible() && !right_type.IsSignFlexible()) { left_type.SetSign(right_type.IsSigned()); left_type.SetSignFlexible(false); } else if (right_type.IsSignFlexible() && !left_type.IsSignFlexible()) { right_type.SetSign(left_type.IsSigned()); right_type.SetSignFlexible(false); } auto is_comparison = is_comparison_op(binop.op); if (left_type == right_type) { if (is_comparison) { return CreateBool(); } else { if (left_type.IsSigned() || binop.op == Operator::MINUS) { return CreateInt64(); } return CreateUInt64(); } } if (is_comparison) { return CreateBool(); } // Next, warn on any operations that require signed division. // // SDIV is not implemented for bpf. See Documentation/bpf/bpf_design_QA // in kernel sources if (binop.op == Operator::DIV || binop.op == Operator::MOD) { // If they're still signed, we have to warn if (left_type.IsSigned() || right_type.IsSigned()) { binop.addWarning() << "signed operands for '" << opstr(binop) << "' can lead to undefined behavior " << "(cast to unsigned to silence warning)"; } } if (left_type.IsSigned() || right_type.IsSigned() || binop.op == Operator::MINUS) { return CreateInt64(); } return CreateUInt64(); } SizedType get_binop_type(Binop &binop, const SizedType &lht, const SizedType &rht) { bool is_comparison = is_comparison_op(binop.op); if (lht.IsBoolTy() && rht.IsBoolTy()) { return CreateBool(); } bool lsign = lht.IsSigned(); bool rsign = rht.IsSigned(); bool is_int_binop = (lht.IsCastableMapTy() || lht.IsIntTy() || lht.IsBoolTy()) && (rht.IsCastableMapTy() || rht.IsIntTy() || rht.IsBoolTy()); bool is_signed = lsign || rsign; switch (binop.op) { case Operator::LEFT: case Operator::RIGHT: is_signed = lsign; break; default: break; } if (lht.IsPtrTy() || rht.IsPtrTy()) { return get_binop_ptr(binop, lht, rht); } auto result_type = is_comparison ? CreateBool() : CreateInteger(64, is_signed); auto addr_lhs = lht.GetAS(); auto addr_rhs = rht.GetAS(); // if lhs or rhs has different addrspace (not none), then set the // addrspace to none. This preserves the behaviour for x86. if (addr_lhs != addr_rhs && addr_lhs != AddrSpace::none && addr_rhs != AddrSpace::none) { binop.addWarning() << "Addrspace mismatch"; result_type.SetAS(AddrSpace::none); } // Associativity from left to right for binary operator else if (addr_lhs != AddrSpace::none) { result_type.SetAS(addr_lhs); } else { // In case rhs is none, then this triggers warning in // selectProbeReadHelper. result_type.SetAS(addr_rhs); } if (is_int_binop) { auto int_type = get_binop_int(binop, lht, rht); int_type.SetAS(result_type.GetAS()); return int_type; } return result_type; } bool TypeRuleCollector::check_offsetof_type(Offsetof &offof, SizedType c_type) { // Check if all sub-fields are present. for (const auto &field : offof.field) { if (!c_type.IsCTypeTy()) { offof.addError() << "'" << c_type << "' " << "is not a C type."; return false; } else if (!bpftrace_.structs.Has(c_type.GetName())) { offof.addError() << "'" << c_type.GetName() << "' does not exist."; return false; } else if (!c_type.HasField(field)) { offof.addError() << "'" << c_type.GetName() << "' " << "has no field named " << "'" << field << "'"; return false; } else { // Get next sub-field const auto &f = c_type.GetField(field); c_type = f.type; } } return true; } // These are special map aggregation types that cannot be assigned // to scratch variables and map values/keys: // @a = count(); // OK // @a = 1; @b = count(); @a = @b; // OK // @a = 1; @b = hist(); @a = @b; // NOK // @b = count(); @a = @b; // NOK // @a = 1; @a = count(); // NOK // @a = count(); @a = 1; // NOK // @a = count(); @a = sum(5); // NOK bool is_valid_assignment(const SizedType &type, const SizedType ¤t_type, bool is_map_assignment = false) { if (type.IsVoidTy()) { return false; } else if (type.NeedsPercpuMap() && !type.IsCastableMapTy()) { return false; } else if (!current_type.IsIntegerTy() && type.IsCastableMapTy()) { // Assigning to maps with no value type yet is not allowed (mostly to // prevent user confusion) // @b = count(); @a = @b; // But assigning to scratch variables or map keys is OK if (is_map_assignment) { return false; } else if (!current_type.IsNoneTy()) { return false; } } return true; } } // namespace void TypeRuleCollector::visit(ArrayAccess &arr) { visit(arr.expr); visit(arr.indexpr); resolver_.add_type_rule({ .output = &arr, .inputs = { &arr.expr.node() }, .resolve = [&arr](const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; SizedType elem; if (type.IsArrayTy()) { elem = type.GetElementTy(); } else if (type.IsPtrTy()) { elem = type.GetPointeeTy(); } else if (type.IsStringTy()) { elem = CreateInt8(); } else if (type.IsTupleTy()) { if (auto *integer = arr.indexpr.as()) { if (static_cast(integer->value) >= type.GetFieldCount()) { arr.addError() << "Invalid tuple index: " << integer->value << ". Found " << type.GetFields().size() << " elements in tuple."; } else { elem = type.GetField(integer->value).type; } } } else { arr.addError() << "The array index operator [] can only be " "used on arrays, pointers, and tuples, found " << type << "."; } elem.SetAS(type.GetAS()); // Indexing a pointer as an array can't be verified, so in_bpf_memory is // only propagated from arrays. if (elem.IsCTypeTy() || elem.IsArrayTy()) { elem.SetInBpfMemory(type.IsInBpfMemory()); } return elem; }, }); } void TypeRuleCollector::visit(AssignMapStatement &assignment) { visit(assignment.map_access); visit(assignment.expr); auto map_name = assignment.map_access->map->ident; const auto &value_name = map_value_name(map_name); resolver_.add_type_rule({ .output = value_name, .inputs = { &assignment.expr.node() }, .resolve = [this, &assignment, map_name]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; const auto &value_name = map_value_name(map_name); const auto ¤t_type = resolver_.get_type(value_name); if (!is_valid_assignment(type, current_type, true)) { auto &err = assignment.addError(); auto hint = AGGREGATE_HINTS.find(type.GetTy()); if (hint != AGGREGATE_HINTS.end()) { err << "Map value '" << type << "' cannot be assigned from one map to another. " "The function that returns this type must be called " "directly " "e.g. " "`" << assignment.map_access->map->ident << " = " << hint->second << ";`."; if (const auto *acc = assignment.expr.as()) { if (type.IsCastableMapTy()) { err.addHint() << "Add a cast to integer if you want the value of the " "aggregate, " << "e.g. `" << assignment.map_access->map->ident << " = (int64)" << acc->map->ident << ";`."; } } } else { err << "Value '" << type << "' cannot be assigned to a map."; } return CreateNone(); } return get_map_value_type(map_name, type, assignment); }, }); } void TypeRuleCollector::visit(AssignVarStatement &assignment) { visit(assignment.expr); visit(assignment.var_decl); Node *var_scope = find_variable_scope(assignment.var()->ident); ScopedVariable scoped_var = std::make_pair(var_scope, assignment.var()->ident); // Ignore the RHS to determine the type of this variable and issue errors // later if the RHS type is not compatible or doesn't fit into this sized // declaration type. For sized declarations, propagate addrspace from RHS if // LHS has none. if (sized_decl_vars_.contains(scoped_var)) { resolver_.add_type_rule({ .output = scoped_var, .inputs = { &assignment.expr.node(), scoped_var }, .resolve = [this](const std::vector &inputs) -> SizedType { auto var_type = inputs[1]; // $x's declared type const auto &expr_type = inputs[0]; // rhs type if (var_type.GetAS() == AddrSpace::none && expr_type.GetAS() != AddrSpace::none) { var_type.SetAS(expr_type.GetAS()); } return var_type; }, }); return; } // For unsized declarations (e.g., begin { let $x; $x = ...; }), infer type // from RHS resolver_.add_type_rule({ .output = scoped_var, .inputs = { &assignment.expr.node() }, .resolve = [this, &assignment, scoped_var]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; if (!is_valid_assignment(type, resolver_.get_type(scoped_var))) { assignment.addError() << "Value '" << type << "' cannot be assigned to a scratch variable."; return CreateNone(); } return get_var_type(scoped_var, type, assignment); }, }); } void TypeRuleCollector::visit(Builtin &builtin) { SizedType builtin_type = CreateNone(); auto simple_it = SIMPLE_BUILTIN_TYPES.find(builtin.ident); if (simple_it != SIMPLE_BUILTIN_TYPES.end()) { builtin_type = simple_it->second(); } else if (builtin.ident == "ctx") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return; ProbeType pt = probetype(probe->attach_points[0]->provider); bpf_prog_type bt = progtype(pt); std::string func = probe->attach_points[0]->func; builtin_type = CreatePointer(CreateNone()); switch (bt) { case BPF_PROG_TYPE_KPROBE: { auto record = bpftrace_.structs.Lookup("struct pt_regs"); if (!record.expired()) { builtin_type = CreatePointer(CreateCStruct("struct pt_regs", record), AddrSpace::kernel); builtin_type.MarkCtxAccess(); } break; } case BPF_PROG_TYPE_PERF_EVENT: builtin_type = CreatePointer( CreateCStruct("struct bpf_perf_event_data", bpftrace_.structs.Lookup( "struct bpf_perf_event_data")), AddrSpace::kernel); builtin_type.MarkCtxAccess(); break; case BPF_PROG_TYPE_TRACING: if (pt == ProbeType::iter) { std::string type = "struct bpf_iter__" + func; builtin_type = CreatePointer( CreateCStruct(type, bpftrace_.structs.Lookup(type)), AddrSpace::kernel); builtin_type.MarkCtxAccess(); } break; default: break; } } else if (builtin.ident == "__builtin_retval") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return; ProbeType type = probe->get_probetype(); if (type == ProbeType::fentry || type == ProbeType::fexit) { const auto *arg = bpftrace_.structs.GetProbeArg(*probe, RETVAL_FIELD_NAME); if (arg) { builtin_type = arg->type; } else { builtin.addError() << "Can't find a field " << RETVAL_FIELD_NAME; } } else { builtin_type = CreateUInt64(); } builtin_type.SetAS(find_addrspace(type)); } else if (builtin.ident == "kstack") { if (bpftrace_.config_->stack_mode == StackMode::build_id) { builtin.addWarning() << "'build_id' stack mode can only be used for " "ustack. Falling back to 'raw' mode."; builtin_type = CreateStack(true, StackType{ .mode = StackMode::raw }); } else { builtin_type = CreateStack( true, StackType{ .mode = bpftrace_.config_->stack_mode }); } } else if (builtin.ident == "ustack" || builtin.ident == "__builtin_dw_ustack") { builtin_type = CreateStack( false, StackType{ .mode = bpftrace_.config_->stack_mode }); } else if (builtin.ident == "__builtin_comm") { constexpr int COMM_SIZE = 16; builtin_type = CreateString(COMM_SIZE); builtin_type.SetAS(AddrSpace::kernel); } else if (builtin.ident == "__builtin_func") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return; ProbeType type = probe->get_probetype(); if (type == ProbeType::uprobe || type == ProbeType::uretprobe) { builtin_type = CreateUSym(); } else { builtin_type = CreateKSym(); } } else if (builtin.is_argx()) { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return; builtin_type = CreateUInt64(); builtin_type.SetAS( find_addrspace(probetype(probe->attach_points[0]->provider))); } else if (builtin.ident == "args") { auto *probe = get_probe(builtin, builtin.ident); if (probe == nullptr) return; ProbeType type = probe->get_probetype(); auto type_name = probe->args_typename(); if (!type_name) { builtin.addError() << "Unable to resolve unique type name."; return; } if (type == ProbeType::fentry || type == ProbeType::fexit || type == ProbeType::uprobe || type == ProbeType::rawtracepoint) { builtin_type = CreateCStruct(*type_name, bpftrace_.structs.Lookup(*type_name)); if (builtin_type.GetFieldCount() == 0) builtin.addError() << "Cannot read function parameters"; builtin_type.MarkCtxAccess(); builtin_type.is_funcarg = true; builtin_type.SetAS(type == ProbeType::uprobe ? AddrSpace::user : AddrSpace::kernel); if (type == ProbeType::uprobe) builtin_type.SetInBpfMemory(true); } else if (type == ProbeType::tracepoint) { builtin_type = CreateCStruct(*type_name, bpftrace_.structs.Lookup(*type_name)); builtin_type.SetAS(probe->attach_points.front()->target == "syscalls" ? AddrSpace::user : AddrSpace::kernel); builtin_type.MarkCtxAccess(); } } else { LOG(BUG) << "Unknown builtin variable: '" << builtin.ident << "'"; } resolver_.set_type(&builtin, builtin_type); } void TypeRuleCollector::visit(Call &call) { // RAII setter for func_ context (used by Identifier resolution) struct func_setter { func_setter(TypeRuleCollector &pass, const std::string &s) : pass_(pass), old_func_(pass_.func_) { pass_.func_ = s; } ~func_setter() { pass_.func_ = old_func_; } private: TypeRuleCollector &pass_; std::string old_func_; }; func_setter scope_bound_func_setter{ *this, call.func }; for (auto &varg : call.vargs) { visit(varg); } // These map aggregate functions are the only ones that can set the map value // types to the corresponding aggregate types. For example `@a = count();` // gets desuggared to `count(@a, 0)` However some of these aggregation types // are castable to ints so this is ok: // `@a = count(); @b = 1; @b = @a;` but the value type of `@b` remains an // integer not `count_t`. if (getAssignRewriteFuncs().contains(call.func)) { if (auto *map = call.vargs.at(0).as()) { auto map_name = map->ident; if (call.func == "count" || call.func == "hist" || call.func == "lhist" || call.func == "tseries") { resolver_.add_type_rule({ .output = map_value_name(map_name), .inputs = { &call }, .resolve = [this, &call, map_name]( const std::vector &) -> SizedType { SizedType agg_type; if (call.func == "count") { agg_type = CreateCount(); } else if (call.func == "hist") { agg_type = CreateHist(); } else if (call.func == "lhist") { agg_type = CreateLhist(); } else if (call.func == "tseries") { agg_type = CreateTSeries(); } return get_agg_map_type(map_name, agg_type, call); }, }); } else { // N.B. @a = sum(5); gets desugared to _ = sum(@x, 0, 5); so we have to // set the consumer of this map aggregate function to be the map value // name directly and also add the resolved call type in the callback resolver_.add_type_rule({ .output = map_value_name(map_name), .inputs = { &call.vargs.at(2).node() }, .resolve = [this, &call, map_name]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; if (!type.IsIntegerTy()) { call.addError() << call.func << "() only supports integer arguments (" << type << " provided)"; return CreateNone(); } SizedType agg_type; if (call.func == "avg") { agg_type = CreateAvg(type.IsSigned()); } else if (call.func == "max") { agg_type = CreateMax(type.IsSigned()); } else if (call.func == "min") { agg_type = CreateMin(type.IsSigned()); } else if (call.func == "stats") { agg_type = CreateStats(type.IsSigned()); } else if (call.func == "sum") { agg_type = CreateSum(type.IsSigned()); } // Check if the arguments passed are compatible with each other auto found = agg_map_args_.find(map_name); if (found == agg_map_args_.end()) { agg_map_args_[map_name] = type; } else { auto promoted = get_promoted_type(found->second, type); if (!promoted) { call.addError() << "Type mismatch for " << call.func << ": " << "trying to call function with type '" << type << "' when it already has a type '" << found->second << "'"; return CreateNone(); } else { found->second = *promoted; } } return get_agg_map_type(map_name, agg_type, call); }, }); } // 2nd arg is the key resolver_.add_type_rule({ .output = map_key_name(map_name), .inputs = { &call.vargs.at(1).node() }, .resolve = [this, &call, map_name]( const std::vector &inputs) -> SizedType { return get_map_key_type(map_name, inputs[0], call); }, }); resolver_.set_type(&call, CreateVoid()); } else { call.vargs.at(0).node().addError() << call.func << "() expects a map argument"; } } else { SizedType return_type = CreateNone(); if (VOID_RETURNING_FUNCS.contains(call.func)) { return_type = CreateVoid(); } else if (auto it = SIMPLE_CALL_TYPES.find(call.func); it != SIMPLE_CALL_TYPES.end()) { return_type = it->second(); } else if (call.func == "str") { auto strlen = bpftrace_.config_->max_strlen; if (call.vargs.size() == 2) { if (auto *integer = call.vargs.at(1).as()) { if (integer->value + 1 > strlen) { call.addWarning() << "length param (" << integer->value << ") is too long and will be shortened to " << strlen << " bytes (see BPFTRACE_MAX_STRLEN)"; } else { strlen = integer->value + 1; } } if (auto *integer = dynamic_cast( call.vargs.at(1).as())) { call.addError() << call.func << "cannot use negative length (" << integer->value << ")"; } } return_type = CreateString(strlen); return_type.SetAS(AddrSpace::kernel); } else if (call.func == "buf") { const uint64_t max_strlen = bpftrace_.config_->max_strlen; uint32_t max_buffer_size = max_strlen - sizeof(AsyncEvent::Buf); uint32_t buffer_size = max_buffer_size; if (call.vargs.size() == 1) { resolver_.add_type_rule({ .output = &call, .inputs = { &call.vargs.at(0).node() }, .resolve = [this, &call, max_buffer_size]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; uint32_t buffer_size = max_buffer_size; if (type.IsArrayTy()) { buffer_size = type.GetNumElements() * type.GetElementTy().GetSize(); } buffer_size = std::min(buffer_size, max_buffer_size); auto return_type = CreateBuffer(buffer_size); return_type.SetAS(AddrSpace::kernel); return return_type; }, }); return; } else if (call.vargs.size() == 2) { if (auto *integer = call.vargs.at(1).as()) { buffer_size = integer->value; } } buffer_size = std::min(buffer_size, max_buffer_size); return_type = CreateBuffer(buffer_size); return_type.SetAS(AddrSpace::kernel); } else if (call.func == "ntop") { int buffer_size = 24; return_type = CreateInet(buffer_size); } else if (call.func == "pton") { int af_type = 0, addr_size = 0; std::string addr; if (call.vargs.size() == 1) { if (auto *str = call.vargs.at(0).as()) { addr = str->value; if (addr.find(".") != std::string::npos) { af_type = AF_INET; addr_size = 4; } else if (addr.find(":") != std::string::npos) { af_type = AF_INET6; addr_size = 16; } else { call.addError() << call.func << "() expects an string argument of an IPv4/IPv6 address, got " << addr; return; } } else { call.addError() << call.func << "() expects an string literal at the first argument"; return; } } std::vector dst(addr_size); auto ret = inet_pton(af_type, addr.c_str(), dst.data()); if (ret != 1) { call.addError() << call.func << "() expects a valid IPv4/IPv6 address, got " << addr; return; } return_type = CreateArray(addr_size, CreateUInt8()); return_type.SetAS(AddrSpace::kernel); return_type.SetInBpfMemory(true); } else if (call.func == "reg") { return_type = CreateUInt64(); if (probe_) { ProbeType pt = probe_->get_probetype(); return_type.SetAS(find_addrspace(pt)); } else { return_type.SetAS(AddrSpace::kernel); } } else if (call.func == "kaddr" || call.func == "percpu_kaddr") { return_type = CreateUInt64(); return_type.SetAS(AddrSpace::kernel); } else if (call.func == "__builtin_uaddr") { auto *probe = get_probe(call, call.func); if (probe == nullptr) return; size_t pointee_size = 64; if (!call.vargs.empty() && call.vargs.at(0).is()) { auto name = call.vargs.at(0).as()->value; const auto &target = probe->attach_points[0]->target; auto sym = bpftrace_.resolve_uname(name, target); if (sym) { switch (sym->size) { case 1: case 2: case 4: pointee_size = sym->size * 8; break; } } else { call.addError() << sym.takeError(); } } return_type = CreatePointer(CreateInt(pointee_size), AddrSpace::user); } else if (call.func == "kstack") { return_type = get_stack_type(call, true); } else if (call.func == "ustack" || call.func == "__builtin_dw_ustack") { return_type = get_stack_type(call, false); } else if (call.func == "path") { auto call_type_size = bpftrace_.config_->max_strlen; if (call.vargs.size() == 2) { if (auto *size = call.vargs.at(1).as()) { call_type_size = size->value; } } return_type = CreateString(call_type_size); } else if (call.func == "kptr" || call.func == "uptr") { resolver_.add_type_rule({ .output = &call, .inputs = { &call.vargs.at(0).node() }, .resolve = [this, &call](const std::vector &inputs) -> SizedType { auto result = inputs[0]; result.SetAS(call.func == "kptr" ? AddrSpace::kernel : AddrSpace::user); return result; }, }); return; } else if (call.func == "bswap") { resolver_.add_type_rule({ .output = &call, .inputs = { &call.vargs.at(0).node() }, .resolve = [this, &call](const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; auto int_bit_width = 1; if (!type.IsIntTy()) { call.addError() << call.func << "() only supports integer arguments (" << type.GetTy() << " provided)"; return CreateNone(); } int_bit_width = type.GetIntBitWidth(); return CreateUInt(int_bit_width); }, }); return; } else if (call.func == "nsecs") { if (call.vargs.size() == 1) { resolver_.add_type_rule({ .output = &call, .inputs = { &call.vargs.at(0).node() }, .resolve = [this, &call]( const std::vector &inputs) -> SizedType { auto ret_type = CreateUInt64(); ret_type.ts_mode = inputs[0].ts_mode; return ret_type; }, }); return; } else { return_type = CreateUInt64(); return_type.ts_mode = TimestampMode::boot; } } else if (call.func == "strftime") { resolver_.add_type_rule({ .output = &call, .inputs = { &call.vargs.at(1).node() }, .resolve = [this, &call](const std::vector &inputs) -> SizedType { auto ret_type = CreateTimestamp(); ret_type.ts_mode = inputs[0].ts_mode; return ret_type; }, }); return; } else if (auto bit = SIMPLE_BUILTIN_TYPES.find(call.func); bit != SIMPLE_BUILTIN_TYPES.end()) { return_type = bit->second(); } if (!return_type.IsNoneTy()) { resolver_.set_type(&call, return_type); } else { // BTF function lookup auto maybe_func = type_metadata_.global.lookup(call.func); if (!maybe_func) { call.addError() << "Unknown function: '" << call.func << "'"; return; } const auto &func = *maybe_func; if (func.linkage() != btf::Function::Linkage::Global && func.linkage() != btf::Function::Linkage::Extern) { call.addError() << "Unsupported function linkage: '" << call.func << "'"; return; } auto proto = func.type(); if (!proto) { call.addError() << "Unable to find function proto: " << proto.takeError(); return; } // Extract our return type. auto btf_return_type = proto->return_type(); if (!btf_return_type) { call.addError() << "Unable to read return type: " << btf_return_type.takeError(); return; } auto compat_return_type = getCompatType(*btf_return_type, bpftrace_.structs); if (!compat_return_type) { call.addError() << "Unable to convert return type: " << compat_return_type.takeError(); return; } resolver_.set_type(&call, *compat_return_type); } } } void TypeRuleCollector::visit(Binop &op) { visit(op.left); visit(op.right); resolver_.add_type_rule({ .output = &op, .inputs = { &op.left.node(), &op.right.node() }, .resolve = [&op](const std::vector &inputs) -> SizedType { return get_binop_type(op, inputs[0], inputs[1]); }, }); } void TypeRuleCollector::visit(BlockExpr &block) { scope_stack_.push_back(&block); visit(block.stmts); visit(block.expr); resolver_.add_pass_through(&block.expr.node(), &block); scope_stack_.pop_back(); } void TypeRuleCollector::visit(Boolean &boolean) { resolver_.set_type(&boolean, CreateBool()); } SizedType update_cast_expr(const SizedType &cast_ty, const SizedType &expr_ty, Probe *probe) { auto updated_ty = cast_ty; if (updated_ty.IsArrayTy()) { if (updated_ty.GetNumElements() == 0) { if (updated_ty.GetElementTy().GetSize() != 0) { if (expr_ty.GetSize() % updated_ty.GetElementTy().GetSize() == 0) { // casts to unsized arrays (e.g. int8[]) need to determine size from // RHS auto num_elems = expr_ty.GetSize() / updated_ty.GetElementTy().GetSize(); updated_ty = CreateArray(num_elems, updated_ty.GetElementTy()); } } } if (expr_ty.IsIntTy() || expr_ty.IsBoolTy()) updated_ty.SetInBpfMemory(true); } if (expr_ty.IsCtxAccess() && !updated_ty.IsIntTy()) { updated_ty.MarkCtxAccess(); } updated_ty.SetAS(expr_ty.GetAS()); // case : begin { @foo = (struct Foo)0; } // case : profile:hz:99 $task = (struct task_struct *)curtask. if (updated_ty.GetAS() == AddrSpace::none) { if (probe) { ProbeType type = probe->get_probetype(); updated_ty.SetAS(find_addrspace(type)); } else { // Assume kernel space for data in subprogs. updated_ty.SetAS(AddrSpace::kernel); } } return updated_ty; } void TypeRuleCollector::visit(Cast &cast) { visit(cast.expr); auto *probe = get_probe(); // Account for the race condition whereby the expression type may resolve // before the cast type even though they both need resolution to determine the // final cast type, e.g. `@ = (int8[])"hello"` resolver_.add_type_rule({ .output = &cast, .inputs = { &cast.expr.node() }, .resolve = [this, &cast, probe]( const std::vector &inputs) -> SizedType { const auto &expr_ty = inputs[0]; const auto &cast_ty = resolver_.get_type(&cast); return update_cast_expr(cast_ty, expr_ty, probe); }, }); if (std::holds_alternative(cast.typeof->record)) { auto ty = resolve_parsed_type(std::get(cast.typeof->record), *cast.typeof); if (!ty) { return; } const auto &expr_ty = resolver_.get_type(&cast.expr.node()); if (!expr_ty.IsNoneTy()) { *ty = update_cast_expr(*ty, expr_ty, probe); } resolver_.set_type(&cast, *ty); } else { visit(cast.typeof); resolver_.add_type_rule({ .output = &cast, .inputs = { cast.typeof }, .resolve = [this, &cast, probe]( const std::vector &inputs) -> SizedType { const auto &cast_ty = inputs[0]; const auto &expr_ty = resolver_.get_type(&cast.expr.node()); if (!expr_ty.IsNoneTy()) { return update_cast_expr(cast_ty, expr_ty, probe); } return cast_ty; }, }); } } void TypeRuleCollector::visit(Comptime &comptime) { visit(comptime.expr); unresolved_comptimes_.emplace_back(&comptime); } void TypeRuleCollector::visit(ExprStatement &expr) { visit(expr.expr); } void TypeRuleCollector::visit(FieldAccess &acc) { visit(acc.expr); auto *probe = get_probe(); resolver_.add_type_rule({ .output = &acc, .inputs = { &acc.expr.node() }, .resolve = [this, &acc, probe]( const std::vector &inputs) -> SizedType { const auto &expr_type_in = inputs[0]; // FieldAccesses will automatically resolve through any number of // pointer dereferences. For now, we inject the `Unop` operator // in AstTransformer, as codegen stores the underlying structs as // pointers anyways. In the future, we will likely want to do this in a // different way if we are tracking l-values. bool is_ctx = expr_type_in.IsCtxAccess(); bool in_bpf_memory = expr_type_in.IsInBpfMemory(); auto expr_type = expr_type_in; while (expr_type.IsPtrTy()) { expr_type = expr_type.GetPointeeTy(); } SizedType result_type = CreateNone(); if (!expr_type.IsCTypeTy() && !expr_type.IsRecordTy()) { acc.addError() << "Can not access field '" << acc.field << "' on expression of type '" << expr_type << "'"; return CreateNone(); } if (expr_type.is_funcarg) { if (probe == nullptr) { return CreateNone(); } const auto *arg = bpftrace_.structs.GetProbeArg(*probe, acc.field); if (arg) { result_type = arg->type; result_type.SetAS(expr_type.GetAS()); if (result_type.IsNoneTy()) { acc.addError() << acc.field << " has unsupported type"; } } else { acc.addError() << "Can't find function parameter " << acc.field; } return result_type; } if (!expr_type.IsRecordTy() && !bpftrace_.structs.Has(expr_type.GetName())) { acc.addError() << "Unknown struct/union: '" << expr_type.GetName() << "'"; return CreateNone(); } const auto &record = expr_type.GetStruct(); if (!record->HasField(acc.field)) { if (expr_type.IsRecordTy()) { acc.addError() << "Record does not contain " << "a field named '" << acc.field << "'"; } else { acc.addError() << "Struct/union of type '" << expr_type.GetName() << "' does not contain " << "a field named '" << acc.field << "'"; } return CreateNone(); } else { const auto &field = record->GetField(acc.field); if (field.type.IsPtrTy()) { const auto &tags = field.type.GetBtfTypeTags(); // Currently only "rcu" is safe. "percpu", for example, requires // special unwrapping with `bpf_per_cpu_ptr` which is not yet // supported. static const std::string_view allowed_tag = "rcu"; for (const auto &tag : tags) { if (tag != allowed_tag) { acc.addError() << "Attempting to access pointer field '" << acc.field << "' with unsupported tag attribute: " << tag; } } } result_type = field.type; if (is_ctx && (result_type.IsArrayTy() || result_type.IsCTypeTy())) { // e.g., ((struct bpf_perf_event_data*)ctx)->regs.ax result_type.MarkCtxAccess(); } if (result_type.IsCTypeTy() || result_type.IsArrayTy()) { result_type.SetInBpfMemory(in_bpf_memory); } result_type.SetAS(expr_type.GetAS()); return result_type; } }, }); } SizedType get_range_type(const SizedType &start_type, const SizedType &end_type, Range *range) { if (!start_type.IsIntTy()) { range->addError() << "Loop range requires an integer for the start value"; } if (!end_type.IsIntTy()) { range->addError() << "Loop range requires an integer for the end value"; } auto range_type = start_type; if (start_type.IsIntTy() && end_type.IsIntTy()) { if (start_type.GetSize() > end_type.GetSize() || start_type.GetSize() < end_type.GetSize()) { auto promoted = get_promoted_type(start_type, end_type); if (promoted) { range_type = *promoted; } } } return range_type; } void TypeRuleCollector::visit(For &f) { if (auto *map = f.iterable.as()) { if (map_metadata_.bad_iterator.contains(map)) { map->addError() << map->ident << " has no explicit keys (scalar map), and " "cannot be used for iteration"; } } const auto &decl_name = f.decl->ident; // Collect a list of unique variables which are referenced in the loop's // body and declared before the loop. These will be passed into the loop // callback function as the context parameter. std::unordered_set found_vars; auto [iter, _] = for_vars_referenced_.try_emplace(&f); auto &collector = iter->second; collector.visit(f.block, [this, &found_vars, &decl_name](const auto &var) { if (found_vars.contains(var.ident) || var.ident == decl_name) return false; Node *scope = find_variable_scope(var.ident, false); if (scope && variables_[scope].contains(var.ident)) { found_vars.insert(var.ident); return true; } return false; }); scope_stack_.push_back(&f); visit(f.decl); ScopedVariable scoped_var = std::make_pair(scope_stack_.back(), decl_name); if (auto *map = f.iterable.as()) { visit(map); const auto &key_name = map_key_name(map->ident); const auto &value_name = map_value_name(map->ident); resolver_.add_type_rule({ .output = scoped_var, .inputs = { key_name, value_name }, .resolve = [map](const std::vector &inputs) -> SizedType { const auto &key_type = inputs[0]; const auto &value_type = inputs[1]; if (!value_type.IsMapIterableTy()) { map->addError() << "Loop expression does not support type: " << value_type; } return CreateTuple(Struct::CreateTuple({ key_type, value_type })); }, }); } else if (auto *range = f.iterable.as()) { visit(range->start); visit(range->end); resolver_.add_type_rule({ .output = scoped_var, .inputs = { &range->start.node(), &range->end.node() }, .resolve = [range](const std::vector &inputs) -> SizedType { return get_range_type(inputs[0], inputs[1], range); }, }); } visit(f.block); scope_stack_.pop_back(); { std::vector ctx_inputs; for (Variable &var : collector.nodes()) { ctx_inputs.emplace_back(&var); } if (!ctx_inputs.empty()) { resolver_.add_type_rule({ .output = &f, .inputs = std::move(ctx_inputs), .resolve = [this, &f](const std::vector &) -> SizedType { // Finally, create the context tuple now that all variables // inside the loop have been resolved. std::vector ctx_types; std::vector ctx_idents; auto [iter, _] = for_vars_referenced_.try_emplace(&f); auto &collector = iter->second; for (const Variable &var : collector.nodes()) { const auto &var_type = resolver_.get_type( const_cast(static_cast(&var))); ctx_types.push_back(CreatePointer(var_type, AddrSpace::none)); ctx_idents.push_back(var.ident); } return CreateCStruct("", Struct::CreateRecord(ctx_types, ctx_idents)); }, }); } } // Create an empty ctx struct in case there are no referenced vars in the loop // body std::vector ctx_types; std::vector ctx_idents; resolver_.set_type( &f, CreateCStruct("", Struct::CreateRecord(ctx_types, ctx_idents))); } void TypeRuleCollector::visit(Identifier &identifier) { SizedType ident_type = CreateNone(); if (c_definitions_.enums.contains(identifier.ident)) { const auto &enum_name = std::get<1>(c_definitions_.enums[identifier.ident]); ident_type = CreateEnum(64, enum_name); } else if (bpftrace_.structs.Has(identifier.ident)) { ident_type = CreateCStruct(identifier.ident, bpftrace_.structs.Lookup(identifier.ident)); } else if (func_ == "nsecs") { ident_type = CreateTimestampMode(); if (identifier.ident == "monotonic") { ident_type.ts_mode = TimestampMode::monotonic; } else if (identifier.ident == "boot") { ident_type.ts_mode = TimestampMode::boot; } else if (identifier.ident == "tai") { ident_type.ts_mode = TimestampMode::tai; } else if (identifier.ident == "sw_tai") { ident_type.ts_mode = TimestampMode::sw_tai; } else { identifier.addError() << "Invalid timestamp mode: " << identifier.ident; } } else { ConfigParser parser; StackMode mode; auto ok = parser.parse(func_, &mode, identifier.ident); if (ok) { ident_type = CreateStack(true, StackType{ .mode = mode }); } } if (ident_type.IsNoneTy() && introspection_level_ > 0) { ident_type = bpftrace_.btf_->get_stype(identifier.ident); } resolver_.set_type(&identifier, ident_type); } void TypeRuleCollector::visit(IfExpr &if_expr) { if (auto *comptime = if_expr.cond.as()) { visit(comptime->expr); unresolved_comptimes_.emplace_back(comptime); return; // Skip visiting this `if` for now. } visit(if_expr.cond); visit(if_expr.left); visit(if_expr.right); resolver_.add_type_rule({ .output = &if_expr, .inputs = { &if_expr.left.node() }, .resolve = [&if_expr, this](const std::vector &inputs) -> SizedType { const auto &left_type = inputs[0]; const auto ¤t = resolver_.get_type(&if_expr); auto promoted = get_promoted_type(current, left_type); if (!promoted) { if_expr.addError() << "Branches must return the same type or compatible types: " << "have '" << left_type << "' and '" << current << "'"; return CreateNone(); } return *promoted; }, }); resolver_.add_type_rule({ .output = &if_expr, .inputs = { &if_expr.right.node() }, .resolve = [&if_expr, this](const std::vector &inputs) -> SizedType { const auto &right_type = inputs[0]; const auto ¤t = resolver_.get_type(&if_expr); auto promoted = get_promoted_type(current, right_type); if (!promoted) { if_expr.addError() << "Branches must return the same type or compatible types: " << "have '" << current << "' and '" << right_type << "'"; return CreateNone(); } return *promoted; }, }); } void TypeRuleCollector::visit(Integer &integer) { resolver_.set_type(&integer, get_integer_type(integer.value)); } void TypeRuleCollector::visit(Jump &jump) { if (jump.ident == JumpType::RETURN) { visit(jump.return_value); } } void TypeRuleCollector::visit(Map &map) { if (map_metadata_.bad_indexed_access.contains(&map)) { map.addError() << map.ident << " used as a map without an explicit key (scalar map), previously " "used with an explicit key (non-scalar map)"; return; } const auto &key_name = map_key_name(map.ident); const auto &value_name = map_value_name(map.ident); // N.B. No pass throughs or TypeRules are added for AST map nodes. This is // because consumers should only ever depend on the map key name or the map // value name. Functions like `print` and `clear` that use AST Map nodes // (instead of map access) don't actually require the value or key types. map_value_names_.insert(value_name); // Named param maps (from getopt()) are read-only and have their types pre-set // by the NamedParamsPass. auto it = named_param_info_.map_val_types.find(map.ident); if (it != named_param_info_.map_val_types.end()) { resolver_.set_type(value_name, it->second); resolver_.set_type(key_name, CreateInt64()); } if (introspection_level_ > 0) { introspected_nodes_.insert(map.ident); } } void TypeRuleCollector::visit(MapAccess &acc) { visit(acc.map); visit(acc.key); if (map_metadata_.bad_scalar_access.contains(acc.map)) { acc.addError() << acc.map->ident << " used as a map with an explicit key (non-scalar map), " "previously used without an explicit key (scalar map)"; return; } const auto &key_name = map_key_name(acc.map->ident); resolver_.add_type_rule({ .output = key_name, .inputs = { &acc.key.node() }, .resolve = [this, &acc, key_name]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; if (!is_valid_assignment(type, resolver_.get_type(key_name))) { acc.addError() << "Value '" << type << "' cannot be used as a map key."; return CreateNone(); } return get_map_key_type(acc.map->ident, type, acc); }, }); resolver_.add_pass_through(map_value_name(acc.map->ident), &acc); } void TypeRuleCollector::visit(MapAddr &map_addr) { visit(map_addr.map); // This needs to be fixed as neither the map value or map key are the actual // map's type resolver_.add_type_rule({ .output = &map_addr, .inputs = { map_value_name(map_addr.map->ident) }, .resolve = [](const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; return CreatePointer(type, AddrSpace::kernel); }, }); } void TypeRuleCollector::visit(NegativeInteger &integer) { resolver_.set_type(&integer, get_signed_integer_type(integer.value)); } void TypeRuleCollector::visit(PositionalParameter ¶m) { resolver_.set_type(¶m, CreateInt64()); } void TypeRuleCollector::visit(PositionalParameterCount ¶m) { resolver_.set_type(¶m, CreateUInt64()); } void TypeRuleCollector::visit(Offsetof &offof) { visit(*offof.type_of); // This type will change later depending on what integer literal it resolves // to in AstTransformer but for now set it to the smallest uint resolver_.add_type_rule({ .output = &offof, .inputs = { offof.type_of }, .resolve = [this, &offof](const std::vector &inputs) -> SizedType { auto local_type = inputs[0]; resolve_external_type(local_type, offof); if (!check_offsetof_type(offof, local_type)) { return CreateNone(); } return CreateUInt8(); }, }); } void TypeRuleCollector::visit(Probe &probe) { probe_ = &probe; visit(probe.attach_points); visit(probe.block); } void TypeRuleCollector::visit(Record &record) { std::vector inputs; for (auto *named_arg : record.elems) { visit(named_arg->expr); inputs.emplace_back(&named_arg->expr.node()); } resolver_.add_type_rule({ .output = &record, .inputs = std::move(inputs), .resolve = [&record](const std::vector &inputs) -> SizedType { std::vector elements; std::vector names; for (size_t i = 0; i < record.elems.size(); ++i) { auto &elem = elements.emplace_back(inputs[i]); if (elem.IsCTypeTy() || elem.IsArrayTy()) { elem.SetInBpfMemory(true); } names.emplace_back(record.elems[i]->name); } return CreateRecord(Struct::CreateRecord(elements, names)); }, }); } void TypeRuleCollector::visit(Sizeof &szof) { visit(*szof.type_of); // This type will change later depending on what integer literal it resolves // to for now set it to the smallest uint resolver_.add_type_rule({ .output = &szof, .inputs = { szof.type_of }, .resolve = [](const std::vector &) -> SizedType { return CreateUInt8(); }, }); } void TypeRuleCollector::visit(String &str) { auto type = CreateString(str.value.size() + 1); type.SetAS(AddrSpace::kernel); resolver_.set_type(&str, type); } void TypeRuleCollector::visit(Subprog &subprog) { // Note that we visit the subprogram and process arguments *after* // constructing the stack with the variable states. This is because the // arguments, etc. may have types defined in terms of the arguments // themselves. We already handle detecting circular dependencies. scope_stack_.push_back(&subprog); probe_ = nullptr; for (SubprogArg *arg : subprog.args) { ScopedVariable scoped_var = std::make_pair(&subprog, arg->var->ident); if (std::holds_alternative(arg->typeof->record)) { auto ty = resolve_parsed_type(std::get(arg->typeof->record), *arg->typeof); if (ty) { resolver_.set_type(scoped_var, *ty); resolver_.set_type(arg->typeof, *ty); if (ty->GetSize() != 0) { sized_decl_vars_.insert(scoped_var); } } } else { sized_decl_vars_.insert(scoped_var); visit(arg->typeof); resolver_.add_pass_through(arg->typeof, scoped_var); } visit(arg->var); } visit(subprog.block); visit(subprog.return_type); scope_stack_.pop_back(); } void TypeRuleCollector::visit(Typeof &typeof) { if (std::holds_alternative(typeof.record)) { auto ty = resolve_parsed_type(std::get(typeof.record), typeof); if (ty) { resolver_.set_type(&typeof, *ty); } } else { auto &expr = std::get(typeof.record); ++introspection_level_; visit(expr); --introspection_level_; if (auto *map = expr.as()) { // Typeof for a raw (scalar) map returns the key type. // Subscribe directly to the map's key name to avoid getting the // value type (both propagate through the Map node). resolver_.add_pass_through(map_key_name(map->ident), &typeof); } else { resolver_.add_pass_through(&expr.node(), &typeof); } } } void TypeRuleCollector::visit(Tuple &tuple) { std::vector inputs; for (auto &elem : tuple.elems) { visit(elem); inputs.emplace_back(&elem.node()); } resolver_.add_type_rule({ .output = &tuple, .inputs = std::move(inputs), .resolve = [](const std::vector &inputs) -> SizedType { std::vector elements(inputs.begin(), inputs.end()); for (auto &elem : elements) { if (elem.IsCTypeTy() || elem.IsArrayTy()) { elem.SetInBpfMemory(true); } } return CreateTuple(Struct::CreateTuple(elements)); }, }); } void TypeRuleCollector::visit(TupleAccess &acc) { visit(acc.expr); resolver_.add_type_rule({ .output = &acc, .inputs = { &acc.expr.node() }, .resolve = [&acc](const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; if (!type.IsTupleTy()) { return CreateNone(); } if (acc.index >= type.GetFields().size()) { return CreateNone(); } return type.GetField(acc.index).type; }, }); } void TypeRuleCollector::visit(Typeinfo &typeinfo) { ++introspection_level_; visit(typeinfo.typeof); --introspection_level_; resolver_.add_type_rule({ .output = &typeinfo, .inputs = { typeinfo.typeof }, .resolve = [](const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; auto base_ty_str = to_string(type.GetTy()); auto full_ty_str = typestr(type); std::vector elements = { CreateUInt64(), CreateString(base_ty_str.size() + 1), CreateString(full_ty_str.size() + 1) }; std::vector names = { "btf_id", "base_type", "full_type" }; return CreateRecord(Struct::CreateRecord(elements, names)); }, }); } void TypeRuleCollector::visit(Unop &unop) { visit(unop.expr); bool is_inc_op = false; bool is_dec_op = false; switch (unop.op) { case Operator::PRE_INCREMENT: case Operator::POST_INCREMENT: is_inc_op = true; break; case Operator::PRE_DECREMENT: case Operator::POST_DECREMENT: is_dec_op = true; break; default:; } // Unops are special in that they can be both assignments and expressions. If // we're dealing with a map access or variable then treat these like // assignments whereby we set the type of the unop expression and create a // chain that attemps to assign this integer type to the stored map value or // variable. This enables us to get error messages on the correct node if we // attempt to increment a string or some other invalid type. if (is_inc_op || is_dec_op) { if (auto *acc = unop.expr.as()) { auto map_name = acc->map->ident; resolver_.add_type_rule({ .output = map_value_name(map_name), .inputs = { &unop }, .resolve = [this, &unop, map_name]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; const auto ¤t_type = resolver_.get_type( map_value_name(map_name)); if (current_type.IsPtrTy()) { return current_type; } return get_map_value_type(map_name, type, unop); }, }); resolver_.add_type_rule({ .output = &unop, .inputs = { &unop.expr.node() }, .resolve = [&unop, is_dec_op]( const std::vector &inputs) -> SizedType { return (inputs[0].IsSigned() || is_dec_op) ? CreateInt64() : CreateUInt64(); }, }); return; } else if (auto *var = unop.expr.as()) { Node *scope = find_variable_scope(var->ident); ScopedVariable scoped_var = std::make_pair(scope, var->ident); resolver_.add_type_rule({ .output = scoped_var, .inputs = { &unop }, .resolve = [this, &unop, scoped_var]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; if (sized_decl_vars_.contains(scoped_var)) { return CreateNone(); } const auto ¤t_type = resolver_.get_type(scoped_var); if (current_type.IsPtrTy()) { return current_type; } return get_var_type(scoped_var, type, unop); }, }); resolver_.add_type_rule({ .output = &unop, .inputs = { &unop.expr.node() }, .resolve = [this, &unop, scoped_var, is_dec_op]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; const auto ¤t_type = resolver_.get_type(scoped_var); if (sized_decl_vars_.contains(scoped_var) || current_type.IsPtrTy()) { return current_type; } return (type.IsSigned() || is_dec_op) ? CreateInt64() : CreateUInt64(); }, }); return; } else { unop.addError() << "The " << opstr(unop) << " operator must be applied to a map or variable"; } } auto valid_ptr_op = unop.op == Operator::MUL; resolver_.add_type_rule({ .output = &unop, .inputs = { &unop.expr.node() }, .resolve = [&unop, valid_ptr_op]( const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; bool invalid = false; // Unops are only allowed on ints (e.g. ~$x), dereference only on // pointers and context (we allow args->field for backwards // compatibility) if (type.IsBoolTy()) { invalid = unop.op != Operator::LNOT; } else if (!type.IsIntegerTy() && !((type.IsPtrTy() || type.IsCtxAccess()) && valid_ptr_op)) { invalid = true; } if (invalid) { unop.addError() << "The " << opstr(unop) << " operator can not be used on expressions of type '" << type << "'"; return CreateNone(); } SizedType result = CreateNone(); if (unop.op == Operator::MUL) { if (type.IsPtrTy()) { result = type.GetPointeeTy(); if (type.IsCtxAccess()) result.MarkCtxAccess(); if (result.IsCTypeTy() || result.IsArrayTy()) { result.SetInBpfMemory(type.IsInBpfMemory()); } result.SetAS(type.GetAS()); } else if (type.IsCTypeTy()) { // We allow dereferencing "args" with no effect (for backwards // compat) if (type.IsCtxAccess()) { result = type; } else { unop.addError() << "Can not dereference struct/union of type '" << type.GetName() << "'. It is not a pointer."; } } else if (type.IsIntTy()) { result = CreateUInt64(); } else { unop.addError() << "Can not dereference type '" << type << "'. It is not a pointer."; } } else if (unop.op == Operator::LNOT) { result = CreateBool(); } else if (type.IsPtrTy() && valid_ptr_op) { result = type; } else { result = type.IsSigned() ? CreateInt64() : CreateUInt64(); } return result; }, }); } void TypeRuleCollector::visit(VarDeclStatement &decl) { if (find_variable_scope(decl.var->ident, false) != nullptr) { LOG(BUG) << "Variable shadowing should have been caught by now"; } if (!decl.typeof) { // If the declaration has no type then we can rely on the assignments to // this variable to determine the type. visit(decl.var); return; } auto *scope = scope_stack_.back(); ScopedVariable scoped_var = std::make_pair(scope, decl.var->ident); if (std::holds_alternative(decl.typeof->record)) { auto ty = resolve_parsed_type(std::get(decl.typeof->record), *decl.typeof); if (!ty) { return; } resolver_.set_type(scoped_var, *ty); resolver_.set_type(decl.typeof, *ty); // Some declared types like 'string' have no size so we can factor in the // size of the assignment if (ty->GetSize() != 0) { sized_decl_vars_.insert(scoped_var); } } else { sized_decl_vars_.insert(scoped_var); visit(decl.typeof); resolver_.add_pass_through(decl.typeof, scoped_var); } visit(decl.var); } void TypeRuleCollector::visit(Variable &var) { Node *scope = find_variable_scope(var.ident, false); if (scope == nullptr) { scope = scope_stack_.back(); } variables_[scope].insert({ var.ident, CreateNone() }); ScopedVariable scoped_var = std::make_pair(scope, var.ident); resolver_.add_type_rule({ .output = &var, .inputs = { scoped_var }, .resolve = [](const std::vector &inputs) -> SizedType { auto type = inputs[0]; if (type.IsCTypeTy() || type.IsArrayTy()) { type.SetInBpfMemory(true); } return type; }, }); if (introspection_level_ > 0) { introspected_nodes_.insert(scoped_var); } } void TypeRuleCollector::visit(VariableAddr &var_addr) { visit(var_addr.var); resolver_.add_type_rule({ .output = &var_addr, .inputs = { var_addr.var }, .resolve = [](const std::vector &inputs) -> SizedType { const auto &type = inputs[0]; // Stack variables need kernel address space when their address is taken return CreatePointer(type, AddrSpace::kernel); }, }); } std::optional TypeRuleCollector::resolve_parsed_type( ParsedType *type, Node &node) { if (!type) { return std::nullopt; } auto sized_type = parsed_type_to_sized_type(*type); // N.B. Only certain SizedTypes might need additional external resolution, // e.g. structs, typedefs, etc. if (!resolve_external_type(sized_type, node)) { return std::nullopt; } resolver_.set_type(type, sized_type); return sized_type; } bool TypeRuleCollector::resolve_external_type(SizedType &type, Node &node) { if (type.IsPtrTy()) { auto inner = type.GetPointeeTy(); if (!resolve_external_type(inner, node)) { return false; } type = CreatePointer(inner); return true; } if (type.IsArrayTy()) { auto num_elements = type.GetNumElements(); auto inner = type.GetElementTy(); if (!resolve_external_type(inner, node)) { return false; } type = CreateArray(num_elements, inner); return true; } if (type.IsCTypeTy() && !type.GetStruct()) { auto struct_type = bpftrace_.structs.Lookup(type.GetName()).lock(); if (struct_type) { type = CreateCStruct(type.GetName(), struct_type); return true; } // Try to find the type as something other than a struct, e.g. 'char' or // 'uint64_t' auto stype = bpftrace_.btf_->get_stype(type.GetName()); if (stype.IsNoneTy()) { node.addError() << "Cannot resolve unknown type \"" << type.GetName() << "\"\n"; return false; } type = stype; } return true; } SizedType TypeRuleCollector::get_var_type(const ScopedVariable &scoped_var, const SizedType &type, Node &error_node) { const auto &var = scoped_var.second; auto locked_type = get_locked_node(scoped_var, type, error_node, var); if (!locked_type.IsNoneTy()) { return locked_type; } const auto ¤t_type = resolver_.get_type(scoped_var); auto promoted = get_promoted_type(current_type, type); if (promoted) { return *promoted; } error_node.addError() << "Type mismatch for " << var << ": " << "trying to assign value of type '" << type << "' when variable already has a type '" << current_type << "'"; return CreateNone(); } SizedType TypeRuleCollector::get_map_value_type(const std::string &map_name, const SizedType &type, Node &error_node) { const auto &value_name = map_value_name(map_name); auto locked_type = get_locked_node(value_name, type, error_node, map_name); if (!locked_type.IsNoneTy()) { return locked_type; } const auto ¤t_type = resolver_.get_type(value_name); auto add_error = [&]() { error_node.addError() << "Type mismatch for " << map_name << ": " << "trying to assign value of type '" << type << "' when map already has a type '" << current_type << "'"; }; if (current_type.IsCastableMapTy()) { add_error(); return CreateNone(); } auto promoted = get_promoted_type(current_type, type); if (promoted) { // Data stored in a BPF map is internal (managed by BPF runtime), so // structs and arrays should be marked as such. if (promoted->IsCTypeTy() || promoted->IsArrayTy()) { promoted->SetInBpfMemory(true); } return *promoted; } add_error(); return CreateNone(); } SizedType TypeRuleCollector::get_agg_map_type(const std::string &map_name, const SizedType &type, Call &call) { const auto &value_name = map_value_name(map_name); auto locked_type = get_locked_node(value_name, type, call, map_name); if (!locked_type.IsNoneTy()) { return locked_type; } const auto ¤t_type = resolver_.get_type(value_name); if (current_type.IsNoneTy()) { return type; } if (current_type.GetTy() == type.GetTy()) { auto promoted = get_promoted_type(current_type, type); if (promoted) { return *promoted; } } call.addError() << "Type mismatch for " << map_name << ": " << "trying to assign value of type '" << type << "' when map already has a type '" << current_type << "'"; return CreateNone(); } SizedType TypeRuleCollector::get_map_key_type(const std::string &map_name, const SizedType &type, Node &error_node) { auto val = map_metadata_.scalar.find(map_name); if (val != map_metadata_.scalar.end() && val->second) { // N.B. all scalar map keys are int64 return CreateInt64(); } const auto &key_name = map_key_name(map_name); auto locked_type = get_locked_node(key_name, type, error_node, map_name); if (!locked_type.IsNoneTy()) { return locked_type; } const auto ¤t_type = resolver_.get_type(key_name); auto promoted = get_promoted_type(current_type, type); if (promoted) { if (promoted->IsCTypeTy() || promoted->IsArrayTy()) { promoted->SetInBpfMemory(true); } return *promoted; } error_node.addError() << "Argument mismatch for " << map_name << ": " << "trying to access with arguments: '" << type << "' when map expects arguments: '" << current_type << "'"; return CreateNone(); } SizedType TypeRuleCollector::get_locked_node(const TypeVariable &node, const SizedType &type, Node &error_node, const std::string &name) { if (auto found_locked = locked_nodes_.find(node); found_locked != locked_nodes_.end()) { auto promoted = get_promoted_type(found_locked->second, type); if (!promoted || *promoted != found_locked->second) { error_node.addError() << "Type mismatch for " << name << ": " << "this type has been locked because it was used " "in another part of the type graph that was already " "resolved (e.g. `sizeof`, `typeinfo`, etc.). The new type '" << type << "' doesn't fit into the locked type '" << found_locked->second << "'"; } return found_locked->second; } return CreateNone(); } Probe *TypeRuleCollector::get_probe() { return probe_; } Probe *TypeRuleCollector::get_probe(Node &node, std::string name) { if (probe_ == nullptr) { if (name.empty()) { node.addError() << "Feature not supported outside probe"; } else { node.addError() << "Builtin " << name << " not supported outside probe"; } } return probe_; } SizedType TypeRuleCollector::get_stack_type(Call &call, bool kernel) { auto return_type = CreateStack(kernel); StackType stack_type; stack_type.mode = bpftrace_.config_->stack_mode; auto nargs = call.vargs.size(); if (nargs > 2) { call.addError() << "Invalid number of arguments"; } else { // First arg can be a stack mode identifier or an integer limit size_t limit_arg = 0; if (nargs >= 1) { if (auto *ident = call.vargs.at(0).as()) { ConfigParser parser; auto ok = parser.parse(call.func, &stack_type.mode, ident->ident); if (!ok) { ident->addError() << "Error parsing stack mode: " << ok.takeError(); } limit_arg = 1; } else if (nargs == 2) { call.addError() << "Expected stack mode as first argument"; limit_arg = 1; } } // Parse the limit from whichever arg position it's at if (limit_arg < nargs) { if (auto *limit = call.vargs.at(limit_arg).as()) { stack_type.limit = limit->value; } else { call.addError() << call.func << ": invalid limit value"; } } } constexpr int MAX_STACK_SIZE = 1024; if (stack_type.limit > MAX_STACK_SIZE) { call.addError() << call.func << "([int limit]): limit shouldn't exceed " << MAX_STACK_SIZE << ", " << stack_type.limit << " given"; } if (stack_type.mode == StackMode::build_id && kernel) { call.addError() << "'build_id' stack mode can only be used for ustack"; } return CreateStack(kernel, stack_type); } LockedNodes TypeRuleCollector::get_locked_nodes() { LockedNodes locked_nodes = locked_nodes_; for (const auto &node : introspected_nodes_) { if (const auto *scoped_var = std::get_if(&node)) { const auto &type = resolver_.get_type(*scoped_var); if (!type.IsNoneTy()) { locked_nodes.insert({ *scoped_var, type }); } } else if (const auto *map_ident = std::get_if(&node)) { const auto &key_type = resolver_.get_type(map_key_name(*map_ident)); if (!key_type.IsNoneTy()) { locked_nodes.insert({ map_key_name(*map_ident), key_type }); } const auto &value_type = resolver_.get_type(map_value_name(*map_ident)); if (!value_type.IsNoneTy()) { locked_nodes.insert({ map_value_name(*map_ident), value_type }); } } } return locked_nodes; } Node *TypeRuleCollector::find_variable_scope(const std::string &var_ident, bool safe) { for (auto *scope : scope_stack_) { if (auto search_val = variables_[scope].find(var_ident); search_val != variables_[scope].end()) { return scope; } } if (safe) { LOG(BUG) << "No scope found for variable: " << var_ident; } return nullptr; } // This pass consists of 5 visitors: // - TypeRuleCollector // - AstTransformer // - TypeApplicator // - CastCreator // - TypeChecker // Read more about how all this works in type_resolution.md Pass CreateTypeResolverPass() { return Pass::create( "TypeResolver", [](ASTContext &ast, BPFtrace &b, MapMetadata &mm, CDefinitions &c_definitions, NamedParamInfo &named_param_info, TypeMetadata &types, MacroRegistry ¯o_registry) -> TypeMap { // Fold up front fold(ast); ResolvedTypes resolved_types; std::vector prev_comptimes; LockedNodes locked_nodes; bool should_rerun = true; // First run // This is just a safety mechanism so we don't spin forever constexpr int MAX_ITERATIONS = 50; int iteration = 0; while (should_rerun) { if (++iteration > MAX_ITERATIONS) { ast.diagnostics().addError(ast.root->loc) << "Type resolution exceeded maximum iterations (" << MAX_ITERATIONS << "); possible infinite loop in comptime expressions"; return TypeMap(ResolvedTypes{}); } TypeResolver resolver; auto tr_collector = TypeRuleCollector(ast, b, mm, c_definitions, named_param_info, types, macro_registry, resolver, locked_nodes); // Collect the TypeRules (TypeVariable → TypeRules) tr_collector.visit(ast.root); // Resolve the TypeRules collected by the TypeRuleCollector // and generate a set of types for our TypeVariables resolver.resolve(tr_collector.get_map_value_names()); if (!ast.diagnostics().ok()) { return TypeMap(ResolvedTypes{}); } resolved_types = resolver.get_resolved_types(); // Create literals from expressions like `typeinfo`, `offsetof`, etc. // Also handles AST transformations like tuple/record comparisons. bool had_transforms = RunAstTransformer(ast, macro_registry, resolved_types); // Fold literals like `comptime (typeof($a).base_ty == "int")` that // relied on type information to resolve fold(ast); if (!ast.diagnostics().ok()) { return TypeMap(ResolvedTypes{}); } // Check if we haven't made progress resolving comptime expressions auto next_comptimes = tr_collector.get_unresolved_comptimes(); if (!next_comptimes.empty() && prev_comptimes == next_comptimes && !had_transforms) { for (auto *comptime : next_comptimes) { comptime->addError() << "Unable to resolve comptime expression"; } return TypeMap(ResolvedTypes{}); } prev_comptimes = next_comptimes; locked_nodes = tr_collector.get_locked_nodes(); // Check if there are unresolved comptime expressions or there were // AST transformations, if so we need to re-run everything above should_rerun = !prev_comptimes.empty() || had_transforms; } TypeMap type_map(std::move(resolved_types)); // Apply casts in parts of the AST where we want the left and right // sides to have the same type. RunCastCreator(ast, b, types, type_map); // Re-resolve types for nodes created by CastCreator. This is just // easier than having CastCreator update resolved_types TypeResolver resolver; auto collector = TypeRuleCollector(ast, b, mm, c_definitions, named_param_info, types, macro_registry, resolver, locked_nodes); collector.visit(ast.root); resolver.resolve(collector.get_map_value_names()); resolved_types = resolver.get_resolved_types(); type_map = TypeMap(std::move(resolved_types)); // Run type checking as the final step RunTypeChecker(ast, b, c_definitions, types, type_map); return type_map; }); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_resolver.h000066400000000000000000000033541526721631600225000ustar00rootroot00000000000000#pragma once #include "ast/ast.h" #include "ast/pass_manager.h" #include "types.h" #include #include #include #include namespace bpftrace::ast { using ScopedVariable = std::pair; // Node * is a pointer to an AST node // ScopedVariable is for tracking the type of a scratch variable referenced in // many AST nodes std::string is for map key and value names as these are often // resolved separately by different statements/expressions using TypeVariable = std::variant; struct ScopedVariableHash { std::size_t operator()(const ScopedVariable &sv) const { auto h1 = std::hash{}(sv.first); auto h2 = std::hash{}(sv.second); // Boost-style hash combine for better distribution h1 ^= h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2); return h1; } }; struct TypeVariableHash { std::size_t operator()(const TypeVariable &gn) const { return std::visit( [](const auto &val) -> std::size_t { using T = std::decay_t; if constexpr (std::is_same_v) { return std::hash{}(val); } else if constexpr (std::is_same_v) { return std::hash{}(val); } else { return ScopedVariableHash{}(val); } }, gn); } }; using ResolvedTypes = std::unordered_map; inline std::string get_map_value_name(const std::string &ident) { return ident + "__val"; } inline std::string get_map_key_name(const std::string &ident) { return ident + "__key"; } class TypeMap; Pass CreateTypeResolverPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_system.cpp000066400000000000000000000061621526721631600225160ustar00rootroot00000000000000#include "ast/passes/types/type_system.h" #include "ast/context.h" #include "ast/passes/attachpoint_passes.h" #include "ast/passes/clang_build.h" #include "ast/passes/printer.h" #include "ast/passes/types/type_map.h" namespace bpftrace::ast { Pass CreateTypeSystemPass() { auto fn = [](ASTContext &ast, FunctionInfo &func_info, BitcodeModules &bm) -> Result { TypeMetadata result; // For now, we simply build a single type system that covers all the // external imports and standard library. // Eventually we want to load in a base type system // that is different for each of the probes. std::optional aggregate; auto kernel_types = func_info.kernel_info().load_btf("vmlinux"); if (kernel_types) { result.kernel = std::move(*kernel_types); } else { consumeError(kernel_types.takeError()); } for (const auto &module : bm.modules) { auto btf = btf::Types::parse(static_cast( module.object.data()), module.object.size()); if (!btf) { // If we encounter some error parsing BTF, add it to the specific // import directly. If there is no BTF (e.g. an empty C file), then // we can just suppress the warning. auto err = handleErrors(std::move(btf), [&](const btf::ParseError &parse_err) { if (parse_err.error_code() != ENODATA) { auto &diag = ast.diagnostics().addWarning( module.loc); diag << "Failed to parse BTF data: " << strerror(parse_err.error_code()); } }); if (!err) { return err.takeError(); } continue; // Skip this file. } if (!aggregate) { aggregate.emplace(std::move(*btf)); } else { auto ok = aggregate->append(*btf); if (!ok) { return ok.takeError(); } } } if (aggregate) { result.global = std::move(*aggregate); } return result; }; return Pass::create("TypeSystem", fn); } Pass CreateDumpTypesPass(std::ostream &out) { auto fn = [&out](ASTContext &ast, TypeMetadata &tm, TypeMap &type_map) { out << "// Functions\n"; for (const auto &type : tm.global) { if (!type.is()) { continue; } out << "// " << type.as() << "\n"; } out << "// Variables\n"; for (const auto &type : tm.global) { if (!type.is()) { continue; } out << "// " << type.as() << "\n"; } out << "// Program\n"; ast::Printer printer(ast, out, ast::FormatMode::Debug, ast::Printer::kDefaultWidth, &type_map); printer.visit(ast.root); }; return Pass::create("DumpTypes", fn); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/types/type_system.h000066400000000000000000000015001526721631600221520ustar00rootroot00000000000000#pragma once #include #include "ast/ast.h" #include "ast/pass_manager.h" #include "btf/btf.h" namespace bpftrace::ast { // TypeMetadata holds the external BTF types: `global` is built from the // standard library and imported C modules, and `kernel` is loaded from // vmlinux. It does not cover any of the existing `SizedType` implementations. // // Currently this is only consulted to resolve calls to external functions, // which are looked up in `global`. In the future this may be extended to // "per-probe" types, e.g. the types loaded per kernel module or associated // with user binaries. class TypeMetadata : public ast::State<"type-metadata"> { public: btf::Types global; btf::Types kernel; }; Pass CreateTypeSystemPass(); Pass CreateDumpTypesPass(std::ostream &out); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/unstable_feature.cpp000066400000000000000000000110411526721631600223050ustar00rootroot00000000000000#include #include #include #include "ast/ast.h" #include "ast/passes/unstable_feature.h" #include "ast/visitor.h" #include "bpftrace.h" #include "config.h" #include "log.h" namespace bpftrace::ast { namespace { const auto MAP_DECL = "map declarations"; const auto IMPORTS = "imports"; const auto IMPORT_STATEMENTS = "import statements"; const auto TSERIES = "tseries"; const auto ADDR = "address-of operator (&)"; const auto TYPEINFO = "typeinfo"; const auto DW_USTACK = "dw_ustack (DWARF stack unwinding)"; std::string get_warning(const std::string &feature, const std::string &config) { return std::string("Script is using an unstable feature: " + feature + ". To prevent this warning you must explicitly enable it " "in the config e.g. ") + config + std::string("=enable"); } std::string get_error(const std::string &feature, const std::string &config) { return std::string(feature + " feature is not enabled by default. To enable " "this unstable feature, set the config flag to enable. ") + config + std::string("=enable"); } class UnstableFeature : public Visitor { public: explicit UnstableFeature(BPFtrace &bpftrace) : bpftrace_(bpftrace) {}; using Visitor::visit; void visit(StatementImport &imp); void visit(Call &call); void visit(Typeinfo &typeinfo); private: BPFtrace &bpftrace_; // This set is so we don't warn multiple times for the same feature. std::unordered_set warned_features; void check_unstable_tseries(Node &node); void check_unstable_dw_ustack(Node &node); }; } // namespace // Note: for logged warnings we don't want to use the AST node's `addWarning()` // as this also prints the code location which is overly noisy. We just // want to notify users they're using an unstable feature. For errors it's ok to // print the location because the script is going to fail anyway. void UnstableFeature::visit(StatementImport &imp) { if (bpftrace_.config_->unstable_import_statement == ConfigUnstable::error) { imp.addError() << "Import statements that are not at the top level are primarily for " "the standard library. If this is functionality you need, please " "file an issue to explain why."; return; } if (bpftrace_.config_->unstable_import_statement == ConfigUnstable::warn && !warned_features.contains(UNSTABLE_IMPORT_STATEMENT)) { LOG(WARNING) << get_warning(IMPORT_STATEMENTS, UNSTABLE_IMPORT_STATEMENT); warned_features.insert(UNSTABLE_IMPORT_STATEMENT); } } void UnstableFeature::visit(Call &call) { if (call.func == "tseries") { check_unstable_tseries(call); } else if (call.func == "dw_ustack") { check_unstable_dw_ustack(call); } Visitor::visit(call.vargs); } void UnstableFeature::visit(Typeinfo &typeinfo) { if (bpftrace_.config_->unstable_typeinfo == ConfigUnstable::error) { typeinfo.addError() << get_error(TYPEINFO, UNSTABLE_TYPEINFO); } else if (bpftrace_.config_->unstable_typeinfo == ConfigUnstable::warn && !warned_features.contains(UNSTABLE_TYPEINFO)) { LOG(WARNING) << get_warning(TYPEINFO, UNSTABLE_TYPEINFO); warned_features.insert(UNSTABLE_TYPEINFO); } } void UnstableFeature::check_unstable_tseries(Node &node) { if (bpftrace_.config_->unstable_tseries == ConfigUnstable::error) { node.addError() << get_error(TSERIES, UNSTABLE_TSERIES); return; } if (bpftrace_.config_->unstable_tseries == ConfigUnstable::warn && !warned_features.contains(UNSTABLE_TSERIES)) { LOG(WARNING) << get_warning(TSERIES, UNSTABLE_TSERIES); warned_features.insert(UNSTABLE_TSERIES); } } void UnstableFeature::check_unstable_dw_ustack(Node &node) { #ifndef HAVE_DW_UNWIND node.addError() << "dw_ustack is not available in this build " "(requires x86_64 and LLVM >= 21)"; #else if (bpftrace_.config_->unstable_dw_ustack == ConfigUnstable::error) { node.addError() << get_error(DW_USTACK, UNSTABLE_DW_USTACK); return; } if (bpftrace_.config_->unstable_dw_ustack == ConfigUnstable::warn && !warned_features.contains(UNSTABLE_DW_USTACK)) { LOG(WARNING) << get_warning(DW_USTACK, UNSTABLE_DW_USTACK); warned_features.insert(UNSTABLE_DW_USTACK); } #endif // HAVE_DW_UNWIND } Pass CreateUnstableFeaturePass() { return Pass::create("UnstableFeature", [](ASTContext &ast, BPFtrace &b) { auto configs = UnstableFeature(b); configs.visit(ast.root); }); }; } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/unstable_feature.h000066400000000000000000000002101526721631600217460ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateUnstableFeaturePass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/usdt_arguments.cpp000066400000000000000000000064741526721631600220370ustar00rootroot00000000000000#include #include "ast/ast.h" #include "ast/passes/resolve_imports.h" #include "ast/passes/usdt_arguments.h" #include "ast/visitor.h" namespace bpftrace::ast { namespace { class USDTArgumentLift : public Visitor { public: explicit USDTArgumentLift(ASTContext &ast) : ast_(ast) { } using Visitor::visit; void visit(Probe &probe); void visit(Expression &expr); ast::Variable *var(size_t arg, Node &node) { std::string ident = "__usdt_arg_" + std::to_string(arg); return ast_.make_node(node.loc, ident); } ast::AssignVarStatement *var_decl(size_t arg, Node &node) { // The USDT arg function expects an long int type auto *int_arg = ast_.make_node(node.loc, static_cast(arg)); std::vector args = { int_arg }; Expression expr = ast_.make_node(node.loc, "usdt_arg", std::move(args)); return ast_.make_node(node.loc, var(arg, node), expr); } private: ASTContext &ast_; std::set args_; }; } // namespace void USDTArgumentLift::visit(Probe &probe) { bool is_usdt = false; for (const auto &ap : probe.attach_points) { if (probetype(ap->provider) == ProbeType::usdt) { is_usdt = true; break; } } if (!is_usdt) { return; } // Process this probe. Visitor::visit(probe); if (args_.empty()) { return; } // Rewrite the block to include declarations. StatementList stmt_list; for (const auto arg_num : args_) { stmt_list.emplace_back(var_decl(arg_num, probe)); } auto existing_stmts = std::move(probe.block->stmts); stmt_list.insert(stmt_list.end(), existing_stmts.begin(), existing_stmts.end()); probe.block->stmts = std::move(stmt_list); args_.clear(); } void USDTArgumentLift::visit(Expression &expr) { Visitor::visit(expr); if (auto *builtin = expr.as()) { // Check if this matches `argXX` and replace with the variable. if (builtin->is_argx()) { size_t arg_num = std::stoul(builtin->ident.substr(3)); args_.insert(arg_num); expr = var(arg_num, *builtin); } } } Pass CreateUSDTImportPass() { return Pass::create("USDTImport", [](ASTContext &ast, Imports &imports) -> Result<> { bool has_usdt = false; for (auto *probe : ast.root->probes) { for (auto *ap : probe->attach_points) { if (probetype(ap->provider) == ProbeType::usdt) { has_usdt = true; break; } } if (has_usdt) break; } if (has_usdt) { auto usdt_arguments = USDTArgumentLift(ast); usdt_arguments.visit(ast.root); return imports.import_any(*ast.root, "stdlib/usdt"); } return OK(); }); } } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/passes/usdt_arguments.h000066400000000000000000000002031526721631600214640ustar00rootroot00000000000000#pragma once #include "ast/pass_manager.h" namespace bpftrace::ast { Pass CreateUSDTImportPass(); } // namespace bpftrace::ast bpftrace-0.27.1/src/ast/signal.cpp000066400000000000000000000023271526721631600167430ustar00rootroot00000000000000#include "ast/signal_bt.h" #include #include namespace bpftrace { static std::map signals = { { "SIGABRT", SIGABRT }, { "SIGALRM", SIGALRM }, { "SIGBUS", SIGBUS }, { "SIGCHLD", SIGCHLD }, { "SIGCONT", SIGCONT }, { "SIGFPE", SIGFPE }, { "SIGHUP", SIGHUP }, { "SIGILL", SIGILL }, { "SIGINT", SIGINT }, { "SIGKILL", SIGKILL }, { "SIGPIPE", SIGPIPE }, { "SIGPOLL", SIGPOLL }, { "SIGQUIT", SIGQUIT }, { "SIGSEGV", SIGSEGV }, { "SIGSTOP", SIGSTOP }, { "SIGSYS", SIGSYS }, { "SIGTERM", SIGTERM }, { "SIGTRAP", SIGTRAP }, { "SIGTSTP", SIGTSTP }, { "SIGTTIN", SIGTTIN }, { "SIGTTOU", SIGTTOU }, { "SIGURG", SIGURG }, { "SIGUSR1", SIGUSR1 }, { "SIGUSR2", SIGUSR2 }, { "SIGVTALRM", SIGVTALRM }, { "SIGWINCH", SIGWINCH }, { "SIGXCPU", SIGXCPU }, { "SIGXFSZ", SIGXFSZ }, }; int signal_name_to_num(const std::string &signal) { if (signal.empty()) { return -1; } std::string sig(signal); std::ranges::for_each(sig, [](char &c) { c = ::toupper(c); }); if (sig[0] != 'S') { sig.insert(0, "SIG"); } auto s = signals.find(sig); if (s != signals.end()) return s->second; return -1; } } // namespace bpftrace bpftrace-0.27.1/src/ast/signal_bt.h000066400000000000000000000003341526721631600170710ustar00rootroot00000000000000// This file is name "signal_bt.h" so it doesn't shadow "" #pragma once #include #include namespace bpftrace { int signal_name_to_num(const std::string &signal); } // namespace bpftrace bpftrace-0.27.1/src/ast/visitor.h000066400000000000000000000176221526721631600166360ustar00rootroot00000000000000#pragma once #include #include #include "ast/ast.h" #include "ast/context.h" namespace bpftrace::ast { // Visitor for fully-static visitation. // // This uses CRTP to make all calls static, while still allowing the entrypoint // for a single visitor to be dispatched dynamically. The implementation may // optionally provide individual `visit` methods. To replace specific types, // a `visit` method must be provided on the suitable dynamic type (e.g. you // may want `Expression` or `Statement`). template class Visitor { public: // visit methods are used to traverse the graph, and are provided a reference // to the underlying node. The visit is invoked *before* the replace call, // and can directly consume and modify the results of the visit. R visit([[maybe_unused]] Integer &integer) { return default_value(); } R visit([[maybe_unused]] NegativeInteger &integer) { return default_value(); } R visit([[maybe_unused]] Boolean &boolean) { return default_value(); } R visit([[maybe_unused]] PositionalParameter ¶m) { return default_value(); } R visit([[maybe_unused]] PositionalParameterCount ¶m) { return default_value(); } R visit([[maybe_unused]] String &string) { return default_value(); } R visit([[maybe_unused]] None &none) { return default_value(); } R visit([[maybe_unused]] Builtin &builtin) { return default_value(); } R visit([[maybe_unused]] Identifier &identifier) { return default_value(); } R visit([[maybe_unused]] ParsedType &type) { return default_value(); } R visit([[maybe_unused]] Variable &var) { return default_value(); } R visit([[maybe_unused]] VariableAddr &var_addr) { return visitImpl(var_addr.var); } R visit(SubprogArg &subprog_arg) { visitImpl(subprog_arg.var); visitImpl(subprog_arg.typeof); return default_value(); } R visit([[maybe_unused]] AttachPoint &ap) { return default_value(); } R visit(Call &call) { return visitImpl(call.vargs); } R visit(Sizeof &szof) { return visitImpl(szof.type_of); } R visit(Offsetof &ofof) { return visitImpl(ofof.type_of); } R visit([[maybe_unused]] TypeArg &type_arg) { return default_value(); } R visit(Typeof &typeof) { return visitImpl(typeof.record); } R visit(Typeinfo &typeinfo) { return visitImpl(typeinfo.typeof); } R visit(Comptime &comptime) { return visitImpl(comptime.expr); } R visit([[maybe_unused]] MapDeclStatement &decl) { return default_value(); } R visit([[maybe_unused]] Map &map) { return default_value(); } R visit([[maybe_unused]] MapAddr &map_addr) { return visitImpl(map_addr.map); } R visit(Binop &binop) { visitImpl(binop.left); visitImpl(binop.right); return default_value(); } R visit(Unop &unop) { return visitImpl(unop.expr); } R visit(IfExpr &if_expr) { visitImpl(if_expr.cond); visitImpl(if_expr.left); visitImpl(if_expr.right); return default_value(); } R visit(FieldAccess &acc) { return visitImpl(acc.expr); } R visit(ArrayAccess &arr) { visitImpl(arr.indexpr); return visitImpl(arr.expr); } R visit(TupleAccess &acc) { return visitImpl(acc.expr); } R visit(MapAccess &acc) { visitImpl(acc.map); return visitImpl(acc.key); } R visit(Cast &cast) { visitImpl(cast.typeof); return visitImpl(cast.expr); } R visit(Tuple &tuple) { return visitImpl(tuple.elems); } R visit(NamedArgument &named_arg) { return visitImpl(named_arg.expr); } R visit(Record &record) { return visitImpl(record.elems); } R visit(ExprStatement &expr) { return visitImpl(expr.expr); } R visit(AssignScalarMapStatement &assignment) { visitImpl(assignment.map); return visitImpl(assignment.expr); } R visit(AssignMapStatement &assignment) { visitImpl(assignment.map_access); return visitImpl(assignment.expr); } R visit(AssignVarStatement &assignment) { visitImpl(assignment.var_decl); return visitImpl(assignment.expr); } R visit([[maybe_unused]] AssignConfigVarStatement &assignment) { return default_value(); } R visit(VarDeclStatement &decl) { visitImpl(decl.var); visitImpl(decl.typeof); return default_value(); } R visit(DiscardExpr &discard_expr) { return visitImpl(discard_expr.expr); } R visit(Jump &jump) { return visitImpl(jump.return_value); } R visit(Unroll &unroll) { visitImpl(unroll.expr); visitImpl(unroll.block); return default_value(); } R visit(While &while_block) { visitImpl(while_block.cond); visitImpl(while_block.block); return default_value(); } R visit(Range &range) { visitImpl(range.start); visitImpl(range.end); return default_value(); } R visit(For &for_loop) { visitImpl(for_loop.decl); visitImpl(for_loop.iterable); visitImpl(for_loop.block); return default_value(); } R visit(Probe &probe) { visitImpl(probe.attach_points); return visitImpl(probe.block); } R visit(Config &config) { visitImpl(config.stmts); return default_value(); } R visit(BlockExpr &block) { visitImpl(block.stmts); return visitImpl(block.expr); } R visit([[maybe_unused]] Macro ¯o) { // In general because macros are expanded in an early pass (macro_expansion) // later passes shouldn't visit any macros; visitation should be specially // handled by the macro_expansion pass. return default_value(); } R visit(Subprog &subprog) { visitImpl(subprog.args); visitImpl(subprog.return_type); return visitImpl(subprog.block); } R visit([[maybe_unused]] RootImport &imp) { return default_value(); } R visit([[maybe_unused]] StatementImport &imp) { return default_value(); } R visit(Program &program) { // This order is important. visitImpl(program.c_statements); visitImpl(program.config); visitImpl(program.imports); visitImpl(program.macros); visitImpl(program.functions); visitImpl(program.map_decls); visitImpl(program.probes); return default_value(); } R visit(Iterable &iterable) { return visitImpl(iterable.value); } R visit(Expression &expr) { return visitImpl(expr.value); } R visit(Statement &stmt) { return visitImpl(stmt.value); } R visit(RootStatement &root) { return visitImpl(root.value); } R visit([[maybe_unused]] CStatement &cstmt) { return default_value(); } R visit([[maybe_unused]] const SizedType &type) { return default_value(); } // Automatically unpack and dispatch all variant and vector types into the // suitable visitor method. // // In order to automatically replace a variant, e.g. change from type A to // type B, it is necessary to provide a replace method that accepts that // variant type directly. This could still dispatch via the standard visit // function, which could e.g. return the replacement pointer, but this would // be a single specialized pass for this case. template R visit(std::variant &var) { return std::visit([&](auto &v) -> R { return visitImpl(v); }, var); } template R visit(std::vector &var) { for (auto &value : var) { visitImpl(value); } return default_value(); } template R visit(std::optional &var) { if (var.has_value()) { return visitImpl(var.value()); } return default_value(); } template R visit(T *ptr) { if (ptr) return visitImpl(*ptr); return default_value(); } private: template R visitImpl(T &t) { Impl *impl = static_cast(this); return impl->visit(t); } R default_value() { if constexpr (!std::is_void_v) { return R(); } } }; } // namespace bpftrace::ast bpftrace-0.27.1/src/async_action.cpp000066400000000000000000000175561526721631600173630ustar00rootroot00000000000000#include #include #include #include #include "ast/async_event_types.h" #include "async_action.h" #include "bpftrace.h" #include "log.h" #include "types_format.h" #include "util/exceptions.h" #include "util/system.h" namespace bpftrace::async_action { static Result> prepare_args( BPFtrace &bpftrace, const ast::CDefinitions &c_definitions, const std::vector &fields, const OpaqueValue &value) { std::vector res; for (const auto &field : fields) { auto v = format(bpftrace, c_definitions, field.type, value.slice(field.offset, field.type.GetSize())); if (!v) { return v.takeError(); } res.emplace_back(std::move(*v)); } return res; } Result<> AsyncHandlers::exit(const OpaqueValue &data) { auto exit = data.bitcast(); bpftrace.exit_code = exit.exit_code; bpftrace.request_finalize(); return OK(); } Result<> AsyncHandlers::join(const OpaqueValue &data) { auto join = data.bitcast(); uint64_t join_id = join.join_id; const auto *delim = bpftrace.resources.join_args[join_id].c_str(); auto arg = data.slice(sizeof(AsyncEvent::Join)); size_t arg_count = arg.count() / bpftrace.join_argsize_; std::stringstream joined; for (unsigned int i = 0; i < arg_count; i++) { const char *current_str = arg.data() + (i * bpftrace.join_argsize_); if (current_str == nullptr || current_str[0] == '\0') { break; } if (i) joined << delim; joined << current_str; } out->join(joined.str()); return OK(); } Result<> AsyncHandlers::time(const OpaqueValue &data) { // not respecting config_->get(ConfigKeyInt::max_strlen) char timestr[AsyncHandlers::MAX_TIME_STR_LEN]; time_t t; struct tm tmp; t = ::time(nullptr); if (!localtime_r(&t, &tmp)) { return make_error("unable to get localtime"); } auto time = data.bitcast(); const auto *fmt = bpftrace.resources.time_args[time.time_id].c_str(); if (strftime(timestr, sizeof(timestr), fmt, &tmp) == 0) { return make_error("strftime returned zero"); } out->time(timestr); return OK(); } Result<> AsyncHandlers::runtime_error(const OpaqueValue &data) { auto runtime_error = data.bitcast(); auto error_id = runtime_error.error_id; const auto return_value = runtime_error.return_value; const auto &info = bpftrace.resources.runtime_error_info[error_id]; out->runtime_error(return_value, info); return OK(); } Result<> AsyncHandlers::print_non_map(const OpaqueValue &data) { auto print = data.bitcast(); const SizedType &ty = bpftrace.resources.non_map_print_args.at( print.print_id); auto v = format( bpftrace, c_definitions, ty, data.slice(sizeof(AsyncEvent::PrintNonMap))); if (!v) { return v.takeError(); } out->value(*v); return OK(); } Result<> AsyncHandlers::print_map(const OpaqueValue &data) { auto print = data.bitcast(); const auto &map = bpftrace.bytecode_.getMap(print.mapid); const auto &map_info = bpftrace.resources.maps_info.at(map.name()); auto res = format(bpftrace, c_definitions, map, print.top, print.div); if (!res) { return res.takeError(); } if (!map_info.is_scalar || map_info.value_type.IsHistTy() || map_info.value_type.IsLhistTy() || map_info.value_type.IsTSeriesTy()) { out->map(map.name(), *res); return OK(); } auto emit_empty_scalar = [&](bool stats) -> Result<> { auto scalar = format(bpftrace, c_definitions, map_info.value_type, OpaqueValue::alloc(map_info.value_type.GetSize())); if (!scalar) { return scalar.takeError(); } if (stats) { out->map(map.name(), output::Value(output::Value::Stats(std::move(*scalar)))); } else { out->map(map.name(), output::Value(std::move(*scalar))); } return OK(); }; if (auto *m = std::get_if(&res->variant); m && m->values.empty()) { return emit_empty_scalar(false); } if (auto *stats = std::get_if(&res->variant)) { if (auto *m = std::get_if(&stats->value); m && m->values.empty()) { return emit_empty_scalar(true); } } out->map(map.name(), *res); return OK(); } Result<> AsyncHandlers::zero_map(const OpaqueValue &data) { auto mapevent = data.bitcast(); const auto &map = bpftrace.bytecode_.getMap(mapevent.mapid); uint64_t nvalues = map.is_per_cpu_type() ? bpftrace.ncpus_ : 1; return map.zero_out(nvalues); } Result<> AsyncHandlers::clear_map(const OpaqueValue &data) { auto mapevent = data.bitcast(); const auto &map = bpftrace.bytecode_.getMap(mapevent.mapid); return map.clear(); } Result<> AsyncHandlers::skboutput(const OpaqueValue &data) { auto hdr = data.bitcast(); int offset = std::get<1>( bpftrace.resources.skboutput_args_.at(hdr.skb_output_id)); auto pkt = data.slice(sizeof(hdr)); if (static_cast(offset) >= pkt.size()) { return OK(); // Nothing to dump. } bpftrace.write_pcaps(hdr.skb_output_id, hdr.nsecs_since_boot, pkt.slice(offset)); return OK(); } Result<> AsyncHandlers::syscall(const OpaqueValue &data) { if (bpftrace.safe_mode_) { return make_error( "syscall() not allowed in safe mode. Use '--unsafe'.", EPERM); } auto id = data.bitcast() - static_cast(AsyncAction::syscall); auto &fmt = std::get<0>(bpftrace.resources.system_args[id]); auto &args = std::get<1>(bpftrace.resources.system_args[id]); auto vals = prepare_args( bpftrace, c_definitions, args, data.slice(sizeof(uint64_t))); if (!vals) { return vals.takeError(); } // Always execute via a shell, if available. std::vector system_args; system_args.emplace_back("sh"); system_args.emplace_back("-c"); system_args.emplace_back(fmt.format(*vals)); auto result = util::exec_system(system_args); if (!result) { return result.takeError(); } out->syscall(*result); return OK(); } Result<> AsyncHandlers::cat(const OpaqueValue &data) { auto id = data.bitcast() - static_cast(AsyncAction::cat); auto &fmt = std::get<0>(bpftrace.resources.cat_args[id]); auto &args = std::get<1>(bpftrace.resources.cat_args[id]); auto vals = prepare_args( bpftrace, c_definitions, args, data.slice(sizeof(uint64_t))); if (!vals) { return vals.takeError(); } auto filename = fmt.format(*vals); auto file = std::ifstream(filename, std::ios::binary); if (file.fail()) { return make_error("failed to open file '" + filename + "'"); } // Read up to the maximum bytes specified. std::string str; str.resize(bpftrace.config_->max_cat_bytes); file.read(str.data(), bpftrace.config_->max_cat_bytes); str.resize(file.gcount()); out->cat(str); return OK(); } Result<> AsyncHandlers::printf(const OpaqueValue &data) { auto id = data.bitcast() - static_cast(AsyncAction::printf); auto &fmt = std::get<0>(bpftrace.resources.printf_args[id]); auto &args = std::get<1>(bpftrace.resources.printf_args[id]); auto severity = std::get<2>(bpftrace.resources.printf_args[id]); auto &source_info = std::get<3>(bpftrace.resources.printf_args[id]); auto vals = prepare_args( bpftrace, c_definitions, args, data.slice(sizeof(uint64_t))); if (!vals) { return vals.takeError(); } if (severity == PrintfSeverity::WARNING && bpftrace.warning_level_ == 0) { return OK(); } out->printf(fmt.format(*vals), source_info, severity); return OK(); } } // namespace bpftrace::async_action bpftrace-0.27.1/src/async_action.h000066400000000000000000000031471526721631600170170ustar00rootroot00000000000000#pragma once #include "ast/async_event_types.h" #include "bpftrace.h" #include "output/output.h" namespace bpftrace::async_action { enum class AsyncAction { // clang-format off printf = 0, // printf reserves 0-9999 for printf_ids printf_end = 9999, syscall = 10000, // system reserves 10000-19999 for printf_ids syscall_end = 19999, cat = 20000, // cat reserves 20000-29999 for printf_ids cat_end = 29999, exit = 30000, print, clear, zero, time, join, runtime_error, print_non_map, strftime, skboutput, // clang-format on }; class AsyncHandlers { public: const static size_t MAX_TIME_STR_LEN = 64; AsyncHandlers(BPFtrace &bpftrace, const ast::CDefinitions &c_definitions, output::Output &output) : bpftrace(bpftrace), c_definitions(c_definitions), out(&output) {}; Result<> exit(const OpaqueValue &data); Result<> join(const OpaqueValue &data); Result<> time(const OpaqueValue &data); Result<> runtime_error(const OpaqueValue &data); Result<> print_non_map(const OpaqueValue &data); Result<> print_map(const OpaqueValue &data); Result<> zero_map(const OpaqueValue &data); Result<> clear_map(const OpaqueValue &data); Result<> skboutput(const OpaqueValue &data); Result<> syscall(const OpaqueValue &data); Result<> cat(const OpaqueValue &data); Result<> printf(const OpaqueValue &data); void change_output(output::Output &out) { this->out = &out; } private: BPFtrace &bpftrace; const ast::CDefinitions &c_definitions; output::Output *out; }; } // namespace bpftrace::async_action bpftrace-0.27.1/src/attached_probe.cpp000066400000000000000000001211521526721631600176410ustar00rootroot00000000000000#ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "attached_probe.h" #include "bpftrace.h" #include "disasm.h" #include "log.h" #include "symbols/kernel.h" #include "util/bpf_names.h" #include "util/cpus.h" #include "util/exceptions.h" #include "util/paths.h" #include "util/symbols.h" #include "util/system.h" namespace bpftrace { char AttachError::ID; void AttachError::log(llvm::raw_ostream &OS) const { OS << msg_; } bool is_return_type(ProbeType t) { // clang-format off switch (t) { case ProbeType::kprobe: return false; break; case ProbeType::kretprobe: return true; break; case ProbeType::special: return false; break; case ProbeType::test: return false; break; case ProbeType::benchmark: return false; break; case ProbeType::uprobe: return false; break; case ProbeType::uretprobe: return true; break; case ProbeType::usdt: return false; break; default: LOG(BUG) << "invalid probe type \"" << t << "\""; } // clang-format on } bpf_prog_type progtype(ProbeType t) { switch (t) { // clang-format off case ProbeType::special: return BPF_PROG_TYPE_RAW_TRACEPOINT; break; case ProbeType::test: return BPF_PROG_TYPE_XDP; break; case ProbeType::benchmark: return BPF_PROG_TYPE_XDP; break; case ProbeType::kprobe: return BPF_PROG_TYPE_KPROBE; break; case ProbeType::kretprobe: return BPF_PROG_TYPE_KPROBE; break; case ProbeType::uprobe: return BPF_PROG_TYPE_KPROBE; break; case ProbeType::uretprobe: return BPF_PROG_TYPE_KPROBE; break; case ProbeType::usdt: return BPF_PROG_TYPE_KPROBE; break; case ProbeType::tracepoint: return BPF_PROG_TYPE_TRACEPOINT; break; case ProbeType::profile: return BPF_PROG_TYPE_PERF_EVENT; break; case ProbeType::interval: return BPF_PROG_TYPE_PERF_EVENT; break; case ProbeType::software: return BPF_PROG_TYPE_PERF_EVENT; break; case ProbeType::watchpoint: return BPF_PROG_TYPE_PERF_EVENT; break; case ProbeType::hardware: return BPF_PROG_TYPE_PERF_EVENT; break; case ProbeType::fentry: return BPF_PROG_TYPE_TRACING; break; case ProbeType::fexit: return BPF_PROG_TYPE_TRACING; break; case ProbeType::iter: return BPF_PROG_TYPE_TRACING; break; case ProbeType::rawtracepoint: return BPF_PROG_TYPE_TRACING; break; // clang-format on case ProbeType::invalid: LOG(BUG) << "program type invalid"; } return {}; // unreached } // eventprefix is always used as std::string // NOLINTNEXTLINE(modernize-use-string-view) std::string eventprefix(ProbeType t) { return is_return_type(t) ? "r_" : "p_"; } std::string eventname(const Probe &probe, uint64_t offset) { std::ostringstream offset_str; std::string index_str = "_" + std::to_string(probe.index); switch (probe.type) { case ProbeType::kprobe: case ProbeType::kretprobe: case ProbeType::rawtracepoint: offset_str << std::hex << offset; return eventprefix(probe.type) + util::sanitise_bpf_program_name(probe.attach_point) + "_" + offset_str.str() + index_str; case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: offset_str << std::hex << offset; return eventprefix(probe.type) + util::sanitise_bpf_program_name(probe.path) + "_" + offset_str.str() + index_str; case ProbeType::tracepoint: return probe.attach_point; default: LOG(BUG) << "invalid eventname probe \"" << probe.type << "\""; } } Result resolve_offset_kprobe(Probe &probe) { uint64_t offset = probe.func_offset; // If we are using only the symbol, we don't need to check the offset. bool is_symbol_kprobe = !probe.attach_point.empty(); if (is_symbol_kprobe && probe.func_offset == 0) return offset; // To validate an arbitrary address, we'd need to check symtabs of vmlinux // and all modules, as well as know their load addresses. Since we support // address probes only in unsafe mode anyway, validation is deferred to the // kernel. This function is only called for sym+offset kprobes. assert(is_symbol_kprobe); Symbol sym = {}; sym.name = probe.attach_point; auto path = symbols::find_vmlinux(&sym); if (!path.has_value()) { LOG(V1) << "Could not resolve symbol " << probe.attach_point << ". Skipping usermode offset checking."; LOG(V1) << "The kernel will verify the safety of the location but " "will also allow the offset to be in a different symbol."; return offset; } if (probe.func_offset >= sym.size) { return make_error("Offset outside the function bounds ('" + probe.attach_point + "' size is " + std::to_string(sym.size) + ")"); } return offset; } static constexpr std::string_view hint_unsafe = "\nUse --unsafe to force attachment. WARNING: This option could lead to " "data corruption in the target process."; Result<> check_alignment(Probe &probe, std::string &symbol, uint64_t sym_offset, uint64_t func_offset, bool safe_mode) { Disasm dasm(probe.path); AlignState aligned = dasm.is_aligned(sym_offset, func_offset); std::string tmp = probe.path + ":" + symbol + "+" + std::to_string(func_offset); switch (aligned) { case AlignState::Ok: return OK(); case AlignState::NotAlign: if (safe_mode) { return make_error( "Could not add " + probetypeName(probe.type) + " into middle of instruction: " + tmp + std::string{ hint_unsafe }); } else { std::string_view hint; LOG(WARNING) << "Unsafe " << probe.type << " in the middle of the instruction: " << tmp << hint; return OK(); } case AlignState::Fail: if (safe_mode) { return make_error( "Failed to check if " + probetypeName(probe.type) + " is in proper place: " + tmp + std::string{ hint_unsafe }); } else { LOG(WARNING) << "Unchecked " << probe.type << ": " << tmp; return OK(); } case AlignState::NotSupp: if (safe_mode) { return make_error("Can't check if " + probetypeName(probe.type) + " is in proper place (compiled without " "(k|u)probe offset support): " + tmp + std::string{ hint_unsafe }); } else { LOG(WARNING) << "Unchecked " << probe.type << ": " << tmp; return OK(); } } return OK(); } Result resolve_offset_uprobe(Probe &probe, bool safe_mode) { std::string &symbol = probe.attach_point; uint64_t func_offset = probe.func_offset; if (symbol.empty()) { auto sym = util::resolve_symbol(probe.path, probe.address); if (!sym) { if (safe_mode) { consumeError(sym.takeError()); return make_error( "Could not determine instruction boundary for " + probe.name + " (binary appears stripped)." + std::string{ hint_unsafe }); } else { consumeError(sym.takeError()); LOG(WARNING) << "Could not determine instruction boundary for " << probe.name << " (binary appears stripped). Misaligned probes " "can lead to tracee crashes!"; return probe.address; } } symbol = sym->name; func_offset = probe.address - sym->v_addr; } auto symbols = util::resolve_symbols(probe.path, { symbol }); if (!symbols) { return make_error(llvm::toString(symbols.takeError())); } if (symbols->empty()) { return make_error("Could not resolve symbol: " + probe.path + ":" + symbol); } auto &sym = symbols->front(); if (probe.type == ProbeType::uretprobe && func_offset != 0) { return make_error("uretprobes cannot be attached at function " "offset. (address resolved to: " + symbol + "+" + std::to_string(func_offset) + ")"); } if (sym.size == 0 && func_offset == 0) { if (safe_mode) { return make_error("Could not determine boundary for " + sym.name + " (symbol has size 0)." + std::string{ hint_unsafe }); } } else if (func_offset >= sym.size) { return make_error("Offset outside the function bounds ('" + symbol + "' size is " + std::to_string(sym.size) + ")"); } uint64_t offset = sym.file_offset + func_offset; if (func_offset == 0) return offset; auto align_ok = check_alignment( probe, symbol, sym.file_offset, func_offset, safe_mode); if (!align_ok) { return align_ok.takeError(); } return offset; } Result> resolve_offsets_uprobe_multi(Probe &probe) { std::set names; for (const std::string &func : probe.funcs) { auto pos = func.find(':'); if (pos == std::string::npos) { return make_error("Error resolving probe: " + probe.name); } names.insert(func.substr(pos + 1)); } auto symbols = util::resolve_symbols(probe.path, names); if (!symbols) { return make_error(llvm::toString(symbols.takeError())); } return symbols; } class AttachedKprobeProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog); ~AttachedKprobeProbe() override; int link_fd() override; private: AttachedKprobeProbe(const Probe &probe, struct bpf_link *link); struct bpf_link *link_; }; AttachedKprobeProbe::AttachedKprobeProbe(const Probe &probe, struct bpf_link *link) : AttachedProbe(probe), link_(link) { } AttachedKprobeProbe::~AttachedKprobeProbe() { if (bpf_link__destroy(link_)) { LOG(WARNING) << "failed to destroy link for kprobe probe: " << strerror(errno); } } int AttachedKprobeProbe::link_fd() { return bpf_link__fd(link_); } Result> AttachedKprobeProbe::make( Probe &probe, const BpfProgram &prog) { // Construct a string containing "module:function". We don't do any // additional checking here because this has already been verified during // attachpoint verification. We will automatically propagate any failures // to attach form the libbpf layer in the future. std::string funcname; if (!probe.path.empty() && probe.path != "vmlinux") { funcname = probe.path + ":" + probe.attach_point; } else { funcname = probe.attach_point; } const char *kprobe_func; uint64_t offset; // The kprobe can either be defined by a symbol+offset or an address: // For symbol+offset kprobe, we need to check the validity of the offset. // Address kprobes are only allowed in unsafe mode so no validation is // performed -- the kernel will reject invalid probes. bool is_symbol_kprobe = !probe.attach_point.empty(); if (is_symbol_kprobe) { auto offset_res = resolve_offset_kprobe(probe); if (!offset_res) { return offset_res.takeError(); } kprobe_func = funcname.c_str(); offset = *offset_res; } else { if (probe.address == 0) { return make_error("Probe address not set"); } // The kernel interprets the offset as the absolute address if the symbol // name is null; see alloc_trace_kprobe() in kernel/trace/trace_kprobe.c kprobe_func = nullptr; offset = probe.address; } DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts); opts.offset = offset; opts.retprobe = probe.type == ProbeType::kretprobe; auto *link = bpf_program__attach_kprobe_opts(prog.bpf_prog(), kprobe_func, &opts); if (!link) { if (errno == EILSEQ) return make_error( "Possible attachment attempt in the middle of an instruction, " "try a different offset."); return make_error(); } return std::unique_ptr( new AttachedKprobeProbe(probe, link)); } class AttachedMultiKprobeProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog); ~AttachedMultiKprobeProbe() override; int link_fd() override; size_t probe_count() const override; private: AttachedMultiKprobeProbe(const Probe &probe, int link_fd); int link_fd_; }; AttachedMultiKprobeProbe::AttachedMultiKprobeProbe(const Probe &probe, int link_fd) : AttachedProbe(probe), link_fd_(link_fd) { } AttachedMultiKprobeProbe::~AttachedMultiKprobeProbe() { close(link_fd_); } int AttachedMultiKprobeProbe::link_fd() { return link_fd_; } size_t AttachedMultiKprobeProbe::probe_count() const { return probe_.funcs.size(); } Result> AttachedMultiKprobeProbe:: make(Probe &probe, const BpfProgram &prog) { DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts); std::vector syms; unsigned int i = 0; for (const auto &func : probe.funcs) syms.push_back(func.c_str()); opts.kprobe_multi.syms = syms.data(); opts.kprobe_multi.cnt = syms.size(); opts.kprobe_multi.flags = probe.type == ProbeType::kretprobe ? BPF_F_KPROBE_MULTI_RETURN : 0; if (bt_verbose) { LOG(V1) << "Attaching to " << probe.funcs.size() << " functions"; for (i = 0; i < opts.kprobe_multi.cnt; i++) { LOG(V1) << " " << syms[i]; } } auto attach_type = probe.is_session ? BPF_TRACE_KPROBE_SESSION : BPF_TRACE_KPROBE_MULTI; int link_fd = bpf_link_create(prog.fd(), 0, attach_type, &opts); if (link_fd < 0) { return make_error(); } return std::unique_ptr( new AttachedMultiKprobeProbe(probe, link_fd)); } class AttachedUprobeProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid, bool safe_mode); ~AttachedUprobeProbe() override; int link_fd() override; private: AttachedUprobeProbe(const Probe &probe, struct bpf_link *link); struct bpf_link *link_; }; AttachedUprobeProbe::AttachedUprobeProbe(const Probe &probe, struct bpf_link *link) : AttachedProbe(probe), link_(link) { } AttachedUprobeProbe::~AttachedUprobeProbe() { if (bpf_link__destroy(link_)) LOG(WARNING) << "failed to destroy link for uprobe probe: " << strerror(errno); } int AttachedUprobeProbe::link_fd() { return bpf_link__fd(link_); } Result> AttachedUprobeProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid, bool safe_mode) { auto offset_res = resolve_offset_uprobe(probe, safe_mode); if (!offset_res) { return offset_res.takeError(); } uint64_t offset = *offset_res; DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, opts); opts.retprobe = probe.type == ProbeType::uretprobe; if (!probe.attach_point.empty() && util::is_archive_path(probe.path)) { // When probing libraries mapped directly from zip archives, libbpf needs // the function name to determine its offset within the archive. The offset // argument in this case is relative to the start of the function. See // https://github.com/libbpf/libbpf/blob/3b4f0ef5/src/libbpf.c#L12289 opts.func_name = probe.attach_point.c_str(); offset = probe.func_offset; } auto *link = bpf_program__attach_uprobe_opts(prog.bpf_prog(), pid.has_value() ? *pid : -1, probe.path.c_str(), offset, &opts); if (!link) { return make_error(); } return std::unique_ptr( new AttachedUprobeProbe(probe, link)); } class AttachedMultiUprobeProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid); ~AttachedMultiUprobeProbe() override; size_t probe_count() const override; private: AttachedMultiUprobeProbe(const Probe &probe, int link_fd); int link_fd_; }; AttachedMultiUprobeProbe::AttachedMultiUprobeProbe(const Probe &probe, int link_fd) : AttachedProbe(probe), link_fd_(link_fd) { } AttachedMultiUprobeProbe::~AttachedMultiUprobeProbe() { close(link_fd_); } size_t AttachedMultiUprobeProbe::probe_count() const { return probe_.funcs.size(); } Result> AttachedMultiUprobeProbe:: make(Probe &probe, const BpfProgram &prog, std::optional pid) { auto symbols = resolve_offsets_uprobe_multi(probe); if (!symbols) { return symbols.takeError(); } std::vector offsets; for (const auto &sym : *symbols) { offsets.push_back(sym.file_offset); } // Attach uprobe through uprobe_multi link DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts); opts.uprobe_multi.path = probe.path.c_str(); opts.uprobe_multi.offsets = offsets.data(); opts.uprobe_multi.cnt = offsets.size(); opts.uprobe_multi.flags = probe.type == ProbeType::uretprobe ? BPF_F_UPROBE_MULTI_RETURN : 0; if (pid.has_value()) { opts.uprobe_multi.pid = *pid; } if (bt_verbose) { LOG(V1) << "Attaching to " << probe.funcs.size() << " functions"; for (const auto &sym : *symbols) { LOG(V1) << probe.path << ":" << sym.name; } } int link_fd = bpf_link_create(prog.fd(), 0, BPF_TRACE_UPROBE_MULTI, &opts); if (link_fd < 0) { return make_error(); } return std::unique_ptr( new AttachedMultiUprobeProbe(probe, link_fd)); } class AttachedUSDTProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid); ~AttachedUSDTProbe() override; int link_fd() override; private: AttachedUSDTProbe(const Probe &probe, struct bpf_link *link); struct bpf_link *link_; }; AttachedUSDTProbe::AttachedUSDTProbe(const Probe &probe, struct bpf_link *link) : AttachedProbe(probe), link_(link) { } int AttachedUSDTProbe::link_fd() { return bpf_link__fd(link_); } AttachedUSDTProbe::~AttachedUSDTProbe() { if (bpf_link__destroy(link_)) LOG(WARNING) << "failed to destroy link for usdt probe: " << strerror(errno); } Result> AttachedUSDTProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid) { auto *link = bpf_program__attach_usdt(prog.bpf_prog(), pid.has_value() ? *pid : -1, probe.path.c_str(), probe.ns.c_str(), probe.attach_point.c_str(), nullptr); if (!link) { char bpf_error_msg[128]; int res = libbpf_strerror(errno, bpf_error_msg, sizeof(bpf_error_msg)); if (res) { return make_error("Failed to attach usdt probe: " + std::string(std::strerror(errno))); } else { return make_error("Failed to attach usdt probe: " + std::string(bpf_error_msg)); } } return std::unique_ptr(new AttachedUSDTProbe(probe, link)); } class AttachedTracepointProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog); ~AttachedTracepointProbe() override; private: AttachedTracepointProbe(const Probe &probe, struct bpf_link *link); struct bpf_link *link_; }; AttachedTracepointProbe::AttachedTracepointProbe(const Probe &probe, struct bpf_link *link) : AttachedProbe(probe), link_(link) { } AttachedTracepointProbe::~AttachedTracepointProbe() { if (bpf_link__destroy(link_)) { LOG(WARNING) << "failed to destroy link for tracepiont probe: " << strerror(errno); } } Result> AttachedTracepointProbe::make( Probe &probe, const BpfProgram &prog) { auto *link = bpf_program__attach_tracepoint(prog.bpf_prog(), probe.path.c_str(), eventname(probe, 0).c_str()); if (!link) { return make_error(); } return std::unique_ptr( new AttachedTracepointProbe(probe, link)); } int open_perf_event(uint32_t ev_type, uint32_t ev_config, uint64_t sample_period, uint64_t sample_freq, pid_t pid, int cpu, int group_fd) { if (sample_period > 0 && sample_freq > 0) { LOG(BUG) << "Exactly one of sample_period / sample_freq should be set"; return -1; } struct perf_event_attr attr = {}; attr.type = ev_type; attr.size = sizeof(struct perf_event_attr); attr.config = ev_config; if (sample_freq > 0) { attr.freq = 1; attr.sample_freq = sample_freq; } else { attr.sample_period = sample_period; } if (pid > 0) attr.inherit = 1; return syscall( __NR_perf_event_open, &attr, pid, cpu, group_fd, PERF_FLAG_FD_CLOEXEC); } class AttachedProfileProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid); ~AttachedProfileProbe() override; private: AttachedProfileProbe(const Probe &probe, std::vector links); std::vector links_; }; AttachedProfileProbe::AttachedProfileProbe(const Probe &probe, std::vector links) : AttachedProbe(probe), links_(std::move(links)) { } AttachedProfileProbe::~AttachedProfileProbe() { for (struct bpf_link *link : links_) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for profile probe: " << strerror(errno); } } Result> AttachedProfileProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid) { int group_fd = -1; uint64_t period, freq; if (probe.path == "hz") { period = 0; freq = probe.freq; } else if (probe.path == "s") { period = probe.freq * 1e9; freq = 0; } else if (probe.path == "ms") { period = probe.freq * 1e6; freq = 0; } else if (probe.path == "us") { period = probe.freq * 1e3; freq = 0; } else { return make_error("invalid profile path \"" + probe.path + "\""); } bool has_error = false; std::vector links; std::vector cpus = util::get_online_cpus(); for (int cpu : cpus) { int perf_event_fd = open_perf_event(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, period, freq, pid.has_value() ? *pid : -1, cpu, group_fd); if (perf_event_fd < 0) { has_error = true; break; } auto *link = bpf_program__attach_perf_event(prog.bpf_prog(), perf_event_fd); if (!link) { close(perf_event_fd); has_error = true; break; } links.push_back(link); } if (has_error) { for (struct bpf_link *link : links) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for profile probe: " << strerror(errno); } return make_error(); } return std::unique_ptr( new AttachedProfileProbe(probe, links)); } class AttachedIntervalProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog); ~AttachedIntervalProbe() override; int link_fd() override; private: AttachedIntervalProbe(const Probe &probe, struct bpf_link *link); struct bpf_link *link_; }; AttachedIntervalProbe::AttachedIntervalProbe(const Probe &probe, struct bpf_link *link) : AttachedProbe(probe), link_(link) { } AttachedIntervalProbe::~AttachedIntervalProbe() { if (bpf_link__destroy(link_)) LOG(WARNING) << "failed to destroy link for interval probe: " << strerror(errno); } int AttachedIntervalProbe::link_fd() { return bpf_link__fd(link_); } Result> AttachedIntervalProbe::make( Probe &probe, const BpfProgram &prog) { int group_fd = -1; int cpu = 0; std::vector cpus = util::get_online_cpus(); if (!cpus.empty()) cpu = cpus[0]; uint64_t period = 0, freq = 0; if (probe.path == "s") { period = probe.freq * 1e9; } else if (probe.path == "ms") { period = probe.freq * 1e6; } else if (probe.path == "us") { period = probe.freq * 1e3; } else if (probe.path == "hz") { freq = probe.freq; } else { return make_error("invalid interval path \"" + probe.path + "\""); } int perf_event_fd = open_perf_event(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, period, freq, -1, cpu, group_fd); if (perf_event_fd < 0) { return make_error(); } auto *link = bpf_program__attach_perf_event(prog.bpf_prog(), perf_event_fd); if (!link) { close(perf_event_fd); return make_error(); } return std::unique_ptr( new AttachedIntervalProbe(probe, link)); } class AttachedSoftwareProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid); ~AttachedSoftwareProbe() override; private: AttachedSoftwareProbe(const Probe &probe, std::vector links); std::vector links_; }; AttachedSoftwareProbe::AttachedSoftwareProbe( const Probe &probe, std::vector links) : AttachedProbe(probe), links_(std::move(links)) { } AttachedSoftwareProbe::~AttachedSoftwareProbe() { for (struct bpf_link *link : links_) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for software probe: " << strerror(errno); } } Result> AttachedSoftwareProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid) { int group_fd = -1; uint64_t period = probe.freq; uint64_t defaultp = 1; uint32_t type = 0; // from linux/perf_event.h, with aliases from perf: for (const auto &probeListItem : SW_PROBE_LIST) { if (probe.path == probeListItem.path || probe.path == probeListItem.alias) { type = probeListItem.type; defaultp = probeListItem.defaultp; } } if (period == 0) period = defaultp; bool has_error = false; std::vector links; std::vector cpus = util::get_online_cpus(); for (int cpu : cpus) { int perf_event_fd = open_perf_event(PERF_TYPE_SOFTWARE, type, period, 0, pid.has_value() ? *pid : -1, cpu, group_fd); if (perf_event_fd < 0) { has_error = true; break; } auto *link = bpf_program__attach_perf_event(prog.bpf_prog(), perf_event_fd); if (!link) { close(perf_event_fd); has_error = true; break; } links.push_back(link); } if (has_error) { for (struct bpf_link *link : links) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for software probe: " << strerror(errno); } return make_error(); } return std::unique_ptr( new AttachedSoftwareProbe(probe, links)); } class AttachedHardwareProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid); ~AttachedHardwareProbe() override; private: AttachedHardwareProbe(const Probe &probe, std::vector links); std::vector links_; }; AttachedHardwareProbe::AttachedHardwareProbe( const Probe &probe, std::vector links) : AttachedProbe(probe), links_(std::move(links)) { } AttachedHardwareProbe::~AttachedHardwareProbe() { for (struct bpf_link *link : links_) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for hardware probe: " << strerror(errno); } } Result> AttachedHardwareProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid) { int group_fd = -1; uint64_t period = probe.freq; uint64_t defaultp = 1000000; uint32_t type = 0; // from linux/perf_event.h, with aliases from perf: for (const auto &probeListItem : HW_PROBE_LIST) { if (probe.path == probeListItem.path || probe.path == probeListItem.alias) { type = probeListItem.type; defaultp = probeListItem.defaultp; } } if (period == 0) period = defaultp; bool has_error = false; std::vector links; std::vector cpus = util::get_online_cpus(); for (int cpu : cpus) { int perf_event_fd = open_perf_event(PERF_TYPE_HARDWARE, type, period, 0, pid.has_value() ? *pid : -1, cpu, group_fd); if (perf_event_fd < 0) { has_error = true; break; } auto *link = bpf_program__attach_perf_event(prog.bpf_prog(), perf_event_fd); if (!link) { close(perf_event_fd); has_error = true; break; } links.push_back(link); } if (has_error) { for (struct bpf_link *link : links) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for hardware probe: " << strerror(errno); } return make_error(); } return std::unique_ptr( new AttachedHardwareProbe(probe, links)); } class AttachedFentryProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog); ~AttachedFentryProbe() override; private: AttachedFentryProbe(const Probe &probe, int tracing_fd); int tracing_fd_; }; AttachedFentryProbe::AttachedFentryProbe(const Probe &probe, int tracing_fd) : AttachedProbe(probe), tracing_fd_(tracing_fd) { } AttachedFentryProbe::~AttachedFentryProbe() { close(tracing_fd_); } Result> AttachedFentryProbe::make( Probe &probe, const BpfProgram &prog) { int tracing_fd = bpf_raw_tracepoint_open(nullptr, prog.fd()); if (tracing_fd < 0) { return make_error(); } return std::unique_ptr( new AttachedFentryProbe(probe, tracing_fd)); } class AttachedRawtracepointProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog); ~AttachedRawtracepointProbe() override; private: AttachedRawtracepointProbe(const Probe &probe, int tracing_fd); int tracing_fd_; }; AttachedRawtracepointProbe::AttachedRawtracepointProbe(const Probe &probe, int tracing_fd) : AttachedProbe(probe), tracing_fd_(tracing_fd) { } AttachedRawtracepointProbe::~AttachedRawtracepointProbe() { close(tracing_fd_); } Result> AttachedRawtracepointProbe:: make(Probe &probe, const BpfProgram &prog) { int tracing_fd = bpf_raw_tracepoint_open(nullptr, prog.fd()); if (tracing_fd < 0) { if (tracing_fd == -ENOENT) { return make_error("Probe does not exist: " + probe.name); } else if (tracing_fd == -EINVAL) { return make_error( "Maybe trying to access arguments beyond what's available in " "this tracepoint"); } return make_error(); } return std::unique_ptr( new AttachedRawtracepointProbe(probe, tracing_fd)); } class AttachedIterProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid); ~AttachedIterProbe() override; int link_fd() override; private: AttachedIterProbe(const Probe &probe, int iter_link_fd); const int iter_link_fd_; }; AttachedIterProbe::AttachedIterProbe(const Probe &probe, int iter_link_fd) : AttachedProbe(probe), iter_link_fd_(iter_link_fd) { } AttachedIterProbe::~AttachedIterProbe() { close(iter_link_fd_); } Result> AttachedIterProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid) { int iter_fd = -1; if (!pid.has_value()) { iter_fd = bpf_link_create(prog.fd(), 0, BPF_TRACE_ITER, nullptr); } else { DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts); union bpf_iter_link_info linfo; memset(&linfo, 0, sizeof(linfo)); linfo.task.pid = *pid; opts.iter_info = &linfo; opts.iter_info_len = sizeof(linfo); iter_fd = bpf_link_create(prog.fd(), 0, BPF_TRACE_ITER, &opts); } if (iter_fd < 0) { return make_error(); } return std::unique_ptr( new AttachedIterProbe(probe, iter_fd)); } int AttachedIterProbe::link_fd() { return iter_link_fd_; } class AttachedWatchpointProbe : public AttachedProbe { public: static Result> make( Probe &probe, const BpfProgram &prog, std::optional pid, const std::string &mode); ~AttachedWatchpointProbe() override; private: AttachedWatchpointProbe(const Probe &probe, std::vector links); std::vector links_; }; AttachedWatchpointProbe::AttachedWatchpointProbe( const Probe &probe, std::vector links) : AttachedProbe(probe), links_(std::move(links)) { } AttachedWatchpointProbe::~AttachedWatchpointProbe() { for (struct bpf_link *link : links_) { if (bpf_link__destroy(link)) LOG(WARNING) << "failed to destroy link for watchpoint probe: " << strerror(errno); } } Result> AttachedWatchpointProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid, const std::string &mode) { struct perf_event_attr attr = {}; attr.type = PERF_TYPE_BREAKPOINT; attr.size = sizeof(struct perf_event_attr); attr.config = 0; attr.bp_type = HW_BREAKPOINT_EMPTY; for (const char c : mode) { if (c == 'r') attr.bp_type |= HW_BREAKPOINT_R; else if (c == 'w') attr.bp_type |= HW_BREAKPOINT_W; else if (c == 'x') attr.bp_type |= HW_BREAKPOINT_X; } attr.bp_addr = probe.address; // https://man7.org/linux/man-pages/man2/perf_event_open.2.html attr.bp_len = (attr.bp_type & HW_BREAKPOINT_X) ? sizeof(long) : probe.len; // Generate a notification every 1 event; we care about every event attr.sample_period = 1; // Attach to threads created after attachment. attr.inherit = 1; std::vector cpus, tids; if (pid.has_value()) { // when tracing a specific process, we need to create a separate perf event // for each of its existing threads auto res = util::get_process_tids(*pid); if (!res) { return res.takeError(); } tids = *res; cpus = { -1 }; } else { cpus = util::get_online_cpus(); tids = { -1 }; } std::string err_msg; std::vector links; for (int cpu : cpus) { for (int tid : tids) { // We copy paste the code from bcc's bpf_attach_perf_event_raw here // because we need to know the exact error codes (and also we don't // want bcc's noisy error messages). int perf_event_fd = syscall( __NR_perf_event_open, &attr, tid, cpu, -1, PERF_FLAG_FD_CLOEXEC); if (perf_event_fd < 0) { if (errno == ENOSPC) err_msg = "No more HW registers left"; LOG(WARNING) << "Failed to create a perf event for cpu " << cpu << " tid " << tid << ": " << strerror(errno); continue; } auto *link = bpf_program__attach_perf_event(prog.bpf_prog(), perf_event_fd); if (!link) { close(perf_event_fd); continue; } links.push_back(link); } } if (links.empty()) { // Not all perf_event_open() calls will necessarily succeed -- threads may // exit and CPUs may be offlined. Only return an error if we were unable to // create any event. return make_error(std::move(err_msg)); } return std::unique_ptr( new AttachedWatchpointProbe(probe, links)); } AttachedProbe::AttachedProbe(const Probe &probe) : probe_(probe) { } Result> AttachedProbe::make( Probe &probe, const BpfProgram &prog, std::optional pid, bool safe_mode) { LOG(V1) << "Trying to attach probe: " << probe.name; switch (probe.type) { case ProbeType::kprobe: case ProbeType::kretprobe: if (!probe.funcs.empty()) { return AttachedMultiKprobeProbe::make(probe, prog); } return AttachedKprobeProbe::make(probe, prog); case ProbeType::tracepoint: return AttachedTracepointProbe::make(probe, prog); case ProbeType::profile: return AttachedProfileProbe::make(probe, prog, pid); case ProbeType::interval: return AttachedIntervalProbe::make(probe, prog); case ProbeType::software: return AttachedSoftwareProbe::make(probe, prog, pid); case ProbeType::hardware: return AttachedHardwareProbe::make(probe, prog, pid); case ProbeType::fentry: case ProbeType::fexit: return AttachedFentryProbe::make(probe, prog); case ProbeType::iter: return AttachedIterProbe::make(probe, prog, pid); case ProbeType::rawtracepoint: return AttachedRawtracepointProbe::make(probe, prog); case ProbeType::usdt: return AttachedUSDTProbe::make(probe, prog, pid); case ProbeType::watchpoint: return AttachedWatchpointProbe::make(probe, prog, pid, probe.mode); case ProbeType::uprobe: case ProbeType::uretprobe: if (!probe.funcs.empty()) { return AttachedMultiUprobeProbe::make(probe, prog, pid); } return AttachedUprobeProbe::make(probe, prog, pid, safe_mode); case ProbeType::invalid: case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: { LOG(BUG) << "invalid attached probe type \"" << probe.type << "\""; } } return make_error(); } } // namespace bpftrace bpftrace-0.27.1/src/attached_probe.h000066400000000000000000000025421526721631600173070ustar00rootroot00000000000000#pragma once #include #include #include #include "bpffeature.h" #include "bpfprogram.h" #include "btf.h" #include "probe_types.h" #include "util/result.h" namespace bpftrace { bool is_return_type(ProbeType t); bpf_prog_type progtype(ProbeType t); std::string_view progtypeName(bpf_prog_type t); class AttachError : public ErrorInfo { public: AttachError(std::string &&msg) : msg_(std::move(msg)) {}; AttachError() = default; static char ID; void log(llvm::raw_ostream &OS) const override; const std::string &msg() const { return msg_; } private: std::string msg_; }; class AttachedProbe { public: static Result> make(Probe &probe, const BpfProgram &prog, std::optional pid, bool safe_mode = true); virtual ~AttachedProbe() = default; AttachedProbe(const AttachedProbe &) = delete; AttachedProbe &operator=(const AttachedProbe &) = delete; virtual int link_fd() { return -1; } virtual size_t probe_count() const { return 1; } const Probe &probe() const { return probe_; } protected: AttachedProbe(const Probe &probe); const Probe &probe_; }; } // namespace bpftrace bpftrace-0.27.1/src/benchmark.cpp000066400000000000000000000106361526721631600166330ustar00rootroot00000000000000#include #include #include #include #include #include "ast/ast.h" #include "ast/context.h" #include "benchmark.h" #include "util/time.h" namespace bpftrace { char TimerError::ID; void TimerError::log(llvm::raw_ostream &OS) const { OS << "timer error: " << strerror(err_); } using time_point = std::chrono::time_point; static Result processor_time() { struct timespec ts = {}; int rc = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); if (rc < 0) { return make_error(errno); } return time_point(std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)); } static int64_t delta(time_point start, time_point end) { return std::chrono::duration_cast(end - start) .count(); } Result<> benchmark(std::ostream &out, ast::PassManager &mgr) { ast::PassContext ctx; // See below; we aggregate at the end. int64_t full_mean = 0; double full_variance = 0; size_t full_count = 0; // We print out the confidence interval at p95, which corresponds to a // z-score of 1.96 (see the `err` value below). auto emit = [&](const std::string &name, int64_t total, int64_t count, double variance) { size_t mean = total / count; auto stddev = std::sqrt(variance); auto err = static_cast(1.96 * stddev / std::sqrt(static_cast(count))); auto [unit, scale] = util::duration_str(std::chrono::nanoseconds(mean)); out << std::left << std::setw(30) << name; out << std::left << std::setw(8) << count; out << std::left << std::setw(14) << total; out << mean / scale << " ± " << err / scale << " " << unit << std::endl; }; auto ok = mgr.foreach([&](auto &pass) -> Result<> { // Copy out the AST. We allow passes to mutate the AST, and therefore we // copy this out and reset it each time. ast::ASTContext saved; if (ctx.has()) { auto &ast = ctx.get(); saved.root = saved.clone_node(ast::Location(), ast.root); } // We run the function until we are able to accumulate at least three // iterations, and 100 milliseconds (but we never bother doing more than // 10,000). This should provide reasonable data for the below. The times // are all recorded in process CPU time, only while the pass itself is // running. We may accumulate additional time rebuilding the AST, etc. int64_t goal = std::chrono::duration_cast( std::chrono::milliseconds(100)) .count(); std::vector samples; int64_t total = 0; while (true) { auto start = processor_time(); if (!start) { return start.takeError(); } auto ok = pass.run(ctx); if (!ok) { return ok.takeError(); } auto end = processor_time(); if (!end) { return end.takeError(); } int64_t current = delta(*start, *end); samples.push_back(current); total += current; // Do we have enough (or too much)? if (samples.size() >= 10000 || (samples.size() > 3 && total >= goal)) { break; } // Restore the original tree. auto &ast = ctx.get(); ast.clear(); ast.root = clone(ast, ast::Location(), saved.root); } // Compute the variance of the samples. int64_t mean = total / samples.size(); double variance = 0; for (const auto &sample : samples) { variance += std::pow(static_cast(sample - mean), 2); } emit(pass.name(), total, samples.size(), variance); // Aggregate for printing the final stats. Note that we treat each pass as // independent, therefore the final variance is the sum of the variances. full_mean += mean; full_variance += variance; full_count++; return OK(); }); if (!ok) { out << "FAIL\n"; // See below. return ok.takeError(); } // The final `PASS` is emitted when all passes have finished correctly. This // makes the output format compatible with `gobench` or other aggregation // tools that can compare benchmarks. emit("total", full_mean * full_count, full_count, full_variance); out << "PASS\n"; return OK(); } } // namespace bpftrace bpftrace-0.27.1/src/benchmark.h000066400000000000000000000006101526721631600162670ustar00rootroot00000000000000#pragma once #include #include "ast/pass_manager.h" #include "util/result.h" namespace bpftrace { class TimerError : public ErrorInfo { public: TimerError(int err) : err_(err) {}; static char ID; void log(llvm::raw_ostream &OS) const override; private: int err_; }; Result benchmark(std::ostream &out, ast::PassManager &mgr); } // namespace bpftrace bpftrace-0.27.1/src/bfd-disasm.cpp000066400000000000000000000060711526721631600167100ustar00rootroot00000000000000#include #include #include #include #include // bfd.h assumes everyone is using autotools and will error out unless // PACKAGE is defined. Some distros patch this check out. #define PACKAGE "bpftrace" #include #include #include #include "bfd-disasm.h" #include "util/system.h" namespace bpftrace { BfdDisasm::BfdDisasm(std::string &path) { fd_ = open(path.c_str(), O_RDONLY); if (fd_ >= 0) { std::error_code ec; std::filesystem::path fs_path{ path }; std::uintmax_t file_size = std::filesystem::file_size(fs_path, ec); if (!ec) { size_ = file_size; } } } BfdDisasm::~BfdDisasm() { if (fd_ >= 0) close(fd_); } // NOLINTNEXTLINE(modernize-avoid-variadic-functions): required by libbfd API static int fprintf_nop(void *out __attribute__((unused)), const char *fmt __attribute__((unused)), ...) { return 0; } #ifdef LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE // NOLINTNEXTLINE(modernize-avoid-variadic-functions): required by libbfd API static int fprintf_styled_nop(void *out __attribute__((unused)), enum disassembler_style s __attribute__((unused)), const char *fmt __attribute__((unused)), ...) { return 0; } #endif static AlignState is_aligned_buf(void *buf, uint64_t size, uint64_t offset) { disassembler_ftype disassemble; struct disassemble_info info; auto tpath = util::get_pid_exe("self"); if (!tpath) { return AlignState::Fail; } bfd *bfdf; bfdf = bfd_openr(tpath->c_str(), nullptr); if (bfdf == nullptr) return AlignState::Fail; if (!bfd_check_format(bfdf, bfd_object)) { bfd_close(bfdf); return AlignState::Fail; } #ifdef LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE init_disassemble_info(&info, stdout, fprintf_nop, fprintf_styled_nop); #else init_disassemble_info(&info, stdout, fprintf_nop); #endif info.arch = bfd_get_arch(bfdf); info.mach = bfd_get_mach(bfdf); info.buffer = static_cast(buf); info.buffer_length = size; disassemble_init_for_target(&info); disassemble = disassembler(info.arch, bfd_big_endian(bfdf), info.mach, bfdf); uint64_t pc = 0; int count; do { count = disassemble(pc, &info); pc += static_cast(count); if (pc == offset) { bfd_close(bfdf); return AlignState::Ok; } } while (static_cast(count) > 0 && pc < size && pc < offset); bfd_close(bfdf); return AlignState::NotAlign; } AlignState BfdDisasm::is_aligned(uint64_t offset, uint64_t pc) { AlignState aligned = AlignState::Fail; // 100 bytes should be enough to cover next instruction behind pc uint64_t size = std::min(pc + 100, size_); auto buf = std::make_unique(size); if (fd_ < 0) return aligned; uint64_t sz = pread(fd_, buf.get(), size, offset); if (sz == size) aligned = is_aligned_buf(buf.get(), size, pc); else perror("pread failed"); return aligned; } } // namespace bpftrace bpftrace-0.27.1/src/bfd-disasm.h000066400000000000000000000004641526721631600163550ustar00rootroot00000000000000#pragma once #include "disasm.h" namespace bpftrace { class BfdDisasm : public IDisasm { public: explicit BfdDisasm(std::string &path); ~BfdDisasm() override; AlignState is_aligned(uint64_t offset, uint64_t pc) override; private: int fd_ = -1; uint64_t size_{ 0 }; }; } // namespace bpftrace bpftrace-0.27.1/src/bpf_assembler.h000066400000000000000000000106361526721631600171520ustar00rootroot00000000000000// BPF macro assembler copied from bcc/libbpf.h #include // clang-format off /* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ #define BPF_ALU64_REG(OP, DST, SRC) \ ((struct bpf_insn) { \ .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = 0, \ .imm = 0 }) #define BPF_ALU32_REG(OP, DST, SRC) \ ((struct bpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = 0, \ .imm = 0 }) /* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ #define BPF_ALU64_IMM(OP, DST, IMM) \ ((struct bpf_insn) { \ .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \ .off = 0, \ .imm = IMM }) #define BPF_ALU32_IMM(OP, DST, IMM) \ ((struct bpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \ .off = 0, \ .imm = IMM }) /* Short form of mov, dst_reg = src_reg */ #define BPF_MOV64_REG(DST, SRC) \ ((struct bpf_insn) { \ .code = BPF_ALU64 | BPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = 0, \ .imm = 0 }) /* Short form of mov, dst_reg = imm32 */ #define BPF_MOV64_IMM(DST, IMM) \ ((struct bpf_insn) { \ .code = BPF_ALU64 | BPF_MOV | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \ .off = 0, \ .imm = IMM }) /* BPF_LD_IMM64 macro encodes single 'load 64-bit immediate' insn */ #define BPF_LD_IMM64(DST, IMM) \ BPF_LD_IMM64_RAW(DST, 0, IMM) #define BPF_LD_IMM64_RAW(DST, SRC, IMM) \ ((struct bpf_insn) { \ .code = BPF_LD | BPF_DW | BPF_IMM, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = 0, \ .imm = (__s32) (IMM) }), \ ((struct bpf_insn) { \ .code = 0, /* zero is reserved opcode */ \ .dst_reg = 0, \ .src_reg = 0, \ .off = 0, \ .imm = (__s32)(((__u64) (IMM)) >> 32) }) #define BPF_PSEUDO_MAP_FD 1 /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ #define BPF_LD_MAP_FD(DST, MAP_FD) \ BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD) /* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ #define BPF_LD_ABS(SIZE, IMM) \ ((struct bpf_insn) { \ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ .dst_reg = 0, \ .src_reg = 0, \ .off = 0, \ .imm = IMM }) /* Memory load, dst_reg = *(uint *) (src_reg + off16) */ #define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \ ((struct bpf_insn) { \ .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = OFF, \ .imm = 0 }) /* Memory store, *(uint *) (dst_reg + off16) = src_reg */ #define BPF_STX_MEM(SIZE, DST, SRC, OFF) \ ((struct bpf_insn) { \ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = OFF, \ .imm = 0 }) /* Memory store, *(uint *) (dst_reg + off16) = imm32 */ #define BPF_ST_MEM(SIZE, DST, OFF, IMM) \ ((struct bpf_insn) { \ .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = 0, \ .off = OFF, \ .imm = IMM }) /* Conditional jumps against registers, if (dst_reg 'op' src_reg) goto pc + off16 */ #define BPF_JMP_REG(OP, DST, SRC, OFF) \ ((struct bpf_insn) { \ .code = BPF_JMP | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = OFF, \ .imm = 0 }) /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ #define BPF_JMP_IMM(OP, DST, IMM, OFF) \ ((struct bpf_insn) { \ .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \ .off = OFF, \ .imm = IMM }) /* Kfunc call */ #define BPF_CALL_KFUNC(OFF, IMM) \ ((struct bpf_insn) { \ .code = BPF_JMP | BPF_CALL, \ .dst_reg = 0, \ .src_reg = BPF_PSEUDO_KFUNC_CALL, \ .off = OFF, \ .imm = IMM }) /* Raw code statement block */ #define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \ ((struct bpf_insn) { \ .code = CODE, \ .dst_reg = DST, \ .src_reg = SRC, \ .off = OFF, \ .imm = IMM }) /* Program exit */ #define BPF_EXIT_INSN() \ ((struct bpf_insn) { \ .code = BPF_JMP | BPF_EXIT, \ .dst_reg = 0, \ .src_reg = 0, \ .off = 0, \ .imm = 0 }) // clang-format on bpftrace-0.27.1/src/bpfbytecode.cpp000066400000000000000000000316241526721631600171670ustar00rootroot00000000000000#include "bpfbytecode.h" #include #include #include #include "ast/passes/named_param.h" #include "bpftrace.h" #include "globalvars.h" #include "log.h" #include "util/bpf_names.h" #include "util/exceptions.h" #include "util/wildcard.h" #include #include #include namespace bpftrace { char BpfLoadError::ID; void BpfLoadError::log(llvm::raw_ostream &OS) const { OS << msg_; } char HelperVerifierError::ID; void HelperVerifierError::log(llvm::raw_ostream &OS) const { OS << msg_; } BpfBytecode::BpfBytecode(std::span elf) : BpfBytecode(std::as_bytes(elf)) { } BpfBytecode::BpfBytecode(std::span elf) : BpfBytecode(std::as_bytes(elf)) { } static std::optional get_global_var_section_name( std::string_view map_name, const std::unordered_set §ion_names) { for (const auto §ion_name : section_names) { // there are some random chars in the beginning of the map name if (std::string_view::npos != map_name.find(section_name)) return section_name; } return std::nullopt; } BpfBytecode::BpfBytecode(std::span elf) { int log_level = 0; // In debug mode, show full verifier log. // In verbose mode, only show verifier log for failures. if (bt_debug.contains(DebugStage::Verifier)) log_level = 15; else if (bt_verbose) log_level = 1; DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts); opts.kernel_log_level = static_cast<__u32>(log_level); bpf_object_ = std::unique_ptr( bpf_object__open_mem(elf.data(), elf.size(), &opts)); if (!bpf_object_) LOG(BUG) << "The produced ELF is not a valid BPF object: " << std::strerror(errno); const auto section_names = globalvars::get_section_names(); // Discover maps struct bpf_map *m; bpf_map__for_each (m, bpf_object_.get()) { std::string_view name = bpf_map__name(m); if (auto global_var_section_name_opt = get_global_var_section_name( name, section_names)) { section_names_to_global_vars_map_[std::move( *global_var_section_name_opt)] = m; continue; } maps_.emplace(bpftrace_map_name(bpf_map__name(m)), m); } // Discover programs struct bpf_program *p; bpf_object__for_each_program (p, bpf_object_.get()) { programs_.emplace(bpf_program__name(p), BpfProgram(p)); } } const BpfProgram &BpfBytecode::getProgramForProbe(const Probe &probe) const { auto prog = programs_.find( util::get_function_name_for_probe(probe.name, probe.index)); if (prog == programs_.end()) { throw std::runtime_error("Code not generated for probe: " + probe.name); } return prog->second; } BpfProgram &BpfBytecode::getProgramForProbe(const Probe &probe) { return const_cast( const_cast(this)->getProgramForProbe(probe)); } void BpfBytecode::update_global_vars(BPFtrace &bpftrace, globalvars::GlobalVarMap &&global_var_vals) { bpftrace.resources.global_vars.update_global_vars( bpf_object_.get(), section_names_to_global_vars_map_, std::move(global_var_vals), bpftrace.ncpus_, bpftrace.max_cpu_id_, bpftrace.child_ ? std::make_optional(bpftrace.child_->pid()) : std::nullopt); } uint64_t BpfBytecode::get_event_loss_counter(BPFtrace &bpftrace, int max_cpu_id) { auto *current_values = bpftrace.resources.global_vars.get_global_var( bpf_object_.get(), globalvars::EVENT_LOSS_COUNTER_SECTION_NAME, section_names_to_global_vars_map_); uint64_t current_value = 0; for (int i = 0; i < max_cpu_id; ++i) { current_value += *current_values; current_values++; } return current_value; } // Searches the verifier's log for err_pattern. If a match is found, extracts // the name and ID of the problematic helper and throws a HelperVerifierError. // // Example verfier log extract: // [...] // 36: (b7) r3 = 64 ; R3_w=64 // 37: (85) call bpf_d_path#147 // helper call is not allowed in probe // [...] // // In the above log, "bpf_d_path" is the helper's name and "147" is the ID. static Result<> check_helper_verifier_error( const std::string &log, const std::string &err_pattern, const std::string &exception_msg_suffix) { auto err_pos = log.find(err_pattern); if (err_pos == std::string_view::npos) return OK(); std::string_view call_pattern = " call "; auto call_pos = log.rfind(call_pattern, err_pos); if (call_pos == std::string_view::npos) return OK(); auto helper_begin = call_pos + call_pattern.size(); auto hash_pos = log.find("#", helper_begin); if (hash_pos == std::string_view::npos) return OK(); auto eol = log.find("\n", hash_pos + 1); if (eol == std::string_view::npos) return OK(); auto helper_name = std::string{ log.substr(helper_begin, hash_pos - helper_begin) }; auto func_id = std::stoi( std::string{ log.substr(hash_pos + 1, eol - hash_pos - 1) }); std::string msg = std::string{ "helper " } + helper_name + exception_msg_suffix; return make_error(msg, static_cast(func_id)); } // The log should end with line: // processed N insns (limit 1000000) ... // so we try to find it. If it's not there, it's very likely that the log has // been trimmed due to insufficient log limit. This function checks if that // happened. static bool is_log_trimmed(std::string_view log) { static const std::vector tokens = { "processed", "insns" }; return !util::wildcard_match(log, tokens, true, true); } static bool is_stack_size_error(std::string_view log) { static const std::vector tokens = { "stack size", "Too large" }; return util::wildcard_match(log, tokens, true, true); } Result<> BpfBytecode::load_progs(const RequiredResources &resources, const BTF &btf, BPFfeature &feature, const Config &config) { std::unordered_map> log_bufs; for (auto &[name, prog] : programs_) { log_bufs[name] = std::vector(config.log_size, '\0'); auto &log_buf = log_bufs[name]; bpf_program__set_log_buf(prog.bpf_prog(), log_buf.data(), log_buf.size()); } prepare_progs(resources.begin_probes, btf, feature, config); prepare_progs(resources.end_probes, btf, feature, config); prepare_progs(resources.test_probes, btf, feature, config); prepare_progs(resources.benchmark_probes, btf, feature, config); prepare_progs(resources.signal_probes, btf, feature, config); prepare_progs(resources.probes, btf, feature, config); prepare_progs(resources.watchpoint_probes, btf, feature, config); int res = bpf_object__load(bpf_object_.get()); // If requested, print the entire verifier logs, even if loading succeeded. for (const auto &[name, prog] : programs_) { if (bt_debug.contains(DebugStage::Verifier)) { std::cout << "BPF verifier log for " << name << ":\n"; std::cout << "--------------------------------------\n"; std::cout << log_bufs[name].data() << std::endl; } } if (res == 0) return OK(); // If loading of bpf_object failed, we try to give user some hints of what // could've gone wrong. std::string last_error_msg; // libbpf stops loading at the first failed program, so the last attempted // program is the first one with a verifier log when walking in reverse. auto *bpf_prog = bpf_object__prev_program(bpf_object_.get(), nullptr); while (bpf_prog != nullptr) { auto *previous_prog = bpf_object__prev_program(bpf_object_.get(), bpf_prog); auto program = programs_.find(bpf_program__name(bpf_prog)); if (program == programs_.end() || program->second.fd() >= 0) { bpf_prog = previous_prog; continue; } const auto &name = program->first; // Unfortunately, a negative fd does not mean that this specific program // caused the failure. It can mean that libbpf didn't even try to load it // b/c some other program failed to load. So, we only log program load // failures when the verifier log is non-empty. std::string log(log_bufs[name].data()); if (!log.empty()) { // These should be the only errors that may occur here which do not // imply a bpftrace bug so throw immediately with a proper error // message. auto ok = check_helper_verifier_error( log, "helper call is not allowed in probe", " not allowed in probe"); if (!ok) { return ok.takeError(); } ok = check_helper_verifier_error(log, "program of this type cannot use helper", " not allowed in probe"); if (!ok) { return ok.takeError(); } ok = check_helper_verifier_error( log, "pointer arithmetic on ptr_or_null_ prohibited, null-check it " "first", ": result needs to be null-checked before accessing fields"); if (!ok) { return ok.takeError(); } if (is_stack_size_error(log)) { return make_error( "Stack size is too large. Trying moving some scratch variables " "into maps or try setting a lower on_stack_limit (e.g. `config = " "{ on_stack_limit=16 }`)"); } std::stringstream errmsg; errmsg << "Error loading BPF program for " << name << ". Error code: " << res << " (" << strerror(res < 0 ? -res : res) << ")."; if (bt_verbose) { errmsg << std::endl << "Kernel error log: " << std::endl << log << std::endl; if (res == -ENOSPC || is_log_trimmed(log)) { LOG(WARNING, errmsg) << "Kernel log seems to be trimmed. This may be due to buffer " "not being big enough, try increasing the BPFTRACE_LOG_SIZE " "environment variable beyond the current value of " << log_bufs[name].size() << " bytes. Or, add the configuration " "`config = { log_size = N; }` to the script."; } } else { errmsg << " Use -v for full kernel error log."; } last_error_msg = errmsg.str(); break; } bpf_prog = previous_prog; } if (!last_error_msg.empty()) { return make_error(last_error_msg); } // The problem does not seem to be in program loading. It may be something // else (e.g. maps failing to load) but we're not able to figure out what // it is so advise user to check libbf output which should contain more // information. return make_error( "Unknown BPF object load failure. Try using the \"-d libbpf\" " "option to see the full loading log."); } void BpfBytecode::prepare_progs(const std::vector &probes, const BTF &btf, BPFfeature &feature, const Config &config) { for (const auto &probe : probes) { auto &program = getProgramForProbe(probe); program.set_prog_type(probe); program.set_expected_attach_type(probe, feature); program.set_attach_target(probe, btf, config); program.set_no_autoattach(); } } void BpfBytecode::attach_external() { for (const auto &prog : programs_) { auto *p = prog.second.bpf_prog(); if (bpf_program__autoattach(p)) { bpf_program__attach(p); } } } bool BpfBytecode::all_progs_loaded() { return std::ranges::all_of(programs_, [](const auto &prog) { return prog.second.fd() >= 0; }); } bool BpfBytecode::hasMap(const std::string &name) const { return maps_.contains(name); } bool BpfBytecode::hasMap(MapType internal_type) const { return maps_.contains(to_string(internal_type)); } const BpfMap &BpfBytecode::getMap(const std::string &name) const { auto map = maps_.find(name); if (map == maps_.end()) { LOG(BUG) << "Unknown map: " << name; } return map->second; } const BpfMap &BpfBytecode::getMap(MapType internal_type) const { return getMap(to_string(internal_type)); } const BpfMap &BpfBytecode::getMap(int map_id) const { auto map = maps_by_id_.find(map_id); if (map == maps_by_id_.end()) { LOG(BUG) << "Unknown map id: " << std::to_string(map_id); } return *map->second; } const std::map &BpfBytecode::maps() const { return maps_; } int BpfBytecode::countStackMaps() const { int n = 0; for (const auto &map : maps_) { if (map.second.is_stack_map()) n++; } return n; } void BpfBytecode::set_map_ids(RequiredResources &resources) { for (auto &map : maps_) { auto map_info = resources.maps_info.find(map.first); if (map_info != resources.maps_info.end() && map_info->second.id != -1) maps_by_id_.emplace(map_info->second.id, &map.second); } } } // namespace bpftrace bpftrace-0.27.1/src/bpfbytecode.h000066400000000000000000000065131526721631600166330ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include "bpffeature.h" #include "bpfmap.h" #include "bpfprogram.h" #include "config.h" #include "globalvars.h" #include "probe_types.h" #include "required_resources.h" #include "util/result.h" namespace bpftrace { // General load error with a specific message. class BpfLoadError : public ErrorInfo { public: BpfLoadError(std::string msg) : msg_(std::move(msg)) {}; static char ID; void log(llvm::raw_ostream &OS) const override; private: std::string msg_; }; // Error related to a specific helper. class HelperVerifierError : public ErrorInfo { public: HelperVerifierError(std::string msg, bpf_func_id func_id_) : msg_(std::move(msg)), func_id_(func_id_) {}; static char ID; void log(llvm::raw_ostream &OS) const override; bpf_func_id func_id() const { return func_id_; } private: std::string msg_; bpf_func_id func_id_; }; // Representation of the entire BPF bytecode generated by bpftrace. // Created from ELF emitted by CodegenLLVM. // Encapsulates libbpf's 'struct bpf_object' and contains BPF maps and programs. class BpfBytecode : public ast::State<"bytecode"> { public: BpfBytecode() = default; BpfBytecode(std::span elf); BpfBytecode(std::span elf); BpfBytecode(std::span elf); BpfBytecode(const BpfBytecode &) = delete; BpfBytecode &operator=(const BpfBytecode &) = delete; BpfBytecode(BpfBytecode &&) = default; BpfBytecode &operator=(BpfBytecode &&) = default; void update_global_vars(BPFtrace &bpftrace, globalvars::GlobalVarMap &&global_var_vals); uint64_t get_event_loss_counter(BPFtrace &bpftrace, int max_cpu_id); Result<> load_progs(const RequiredResources &resources, const BTF &btf, BPFfeature &feature, const Config &config); void attach_external(); const BpfProgram &getProgramForProbe(const Probe &probe) const; BpfProgram &getProgramForProbe(const Probe &probe); bool hasMap(const std::string &name) const; bool hasMap(MapType internal_type) const; const BpfMap &getMap(const std::string &name) const; const BpfMap &getMap(MapType internal_type) const; const BpfMap &getMap(int map_id) const; void set_map_ids(RequiredResources &resources); const std::map &maps() const; int countStackMaps() const; private: void prepare_progs(const std::vector &probes, const BTF &btf, BPFfeature &feature, const Config &config); bool all_progs_loaded(); // We need a custom deleter for bpf_object which will call bpf_object__close. // Note that it is not possible to run bpf_object__close in ~BpfBytecode // as the desctuctor may be called upon move assignment. struct bpf_object_deleter { void operator()(struct bpf_object *object) { bpf_object__close(object); } }; std::unique_ptr bpf_object_; std::map maps_; std::map maps_by_id_; std::map programs_; std::unordered_map section_names_to_global_vars_map_; }; } // namespace bpftrace bpftrace-0.27.1/src/bpffeature.cpp000066400000000000000000000342201526721631600170170ustar00rootroot00000000000000#include "bpffeature.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "bpf_assembler.h" #include "btf.h" #include "dwarf_parser.h" #include "symbols/kernel.h" #include "tracefs/tracefs.h" #include "util/strings.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) namespace bpftrace { using symbols::KernelVersionMethod; int BPFnofeature::parse(const char* str) { for (auto feat : util::split_string(str, ',')) { // Remember to update bpftrace.adoc! if (feat == "kprobe_multi") { kprobe_multi_ = true; } else if (feat == "kprobe_session") { kprobe_session_ = true; } else if (feat == "uprobe_multi") { uprobe_multi_ = true; } else { return -1; } } return 0; } static bool try_load_(const char* name, enum bpf_prog_type prog_type, std::optional attach_type, std::optional attach_btf_id, struct bpf_insn* insns, size_t insns_cnt, int loglevel, char* logbuf, size_t logbuf_size, int* outfd = nullptr) { const KernelVersionMethod methods[] = { KernelVersionMethod::vDSO, KernelVersionMethod::UTS, KernelVersionMethod::File }; for (KernelVersionMethod method : methods) { auto version = kernel_version(method); if (method != KernelVersionMethod::vDSO && !version) { // Recent kernels don't check the version so we should try to call // bpf_prog_load during first iteration even if we failed to determine // the version. We should not do that in subsequent iterations to avoid // zeroing of log_buf on systems with older kernels. continue; } DECLARE_LIBBPF_OPTS(bpf_prog_load_opts, opts); opts.log_buf = logbuf; opts.log_size = logbuf_size; opts.log_level = loglevel; opts.kern_version = version; if (attach_type.has_value()) { opts.expected_attach_type = attach_type.value(); } if (attach_btf_id.has_value()) opts.attach_btf_id = attach_btf_id.value(); int ret = bpf_prog_load(prog_type, name, "GPL", insns, insns_cnt, &opts); if (ret >= 0) { if (outfd) *outfd = ret; else close(ret); return true; } } return false; } bool BPFfeature::try_load(enum bpf_prog_type prog_type, struct bpf_insn* insns, size_t len, const char* name, std::optional attach_type, int* outfd) { constexpr int log_size = 4096; char logbuf[log_size] = {}; std::optional btf_id; if (prog_type == BPF_PROG_TYPE_TRACING && has_btf()) { btf_id = btf_.get_btf_id(name, "vmlinux"); } if (prog_type == BPF_PROG_TYPE_TRACING) { // List of available functions must be readable std::ifstream traceable_funcs(tracefs::available_filter_functions()); if (!traceable_funcs.good()) return false; } return try_load_(name, prog_type, attach_type, btf_id, insns, len, 0, logbuf, log_size, outfd); } bool BPFfeature::try_load_btf(const void* btf_data, size_t btf_size) { constexpr int log_size = 4096; char log_buf[log_size] = {}; DECLARE_LIBBPF_OPTS(bpf_btf_load_opts, btf_opts); btf_opts.log_buf = log_buf; btf_opts.log_level = 0; btf_opts.log_size = log_size; int fd = bpf_btf_load(btf_data, btf_size, &btf_opts); if (fd >= 0) { close(fd); return true; } return false; } bool BPFfeature::detect_helper(enum bpf_func_id func_id, enum bpf_prog_type prog_type) { // Stolen from libbpf's bpf_probe_helper char logbuf[4096] = {}; char* buf = logbuf; struct bpf_insn insns[] = { BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, func_id), BPF_EXIT_INSN(), }; if (try_load_(nullptr, prog_type, std::nullopt, std::nullopt, insns, ARRAY_SIZE(insns), 1, logbuf, 4096)) return true; if (errno == EPERM) return false; // On older kernels the first byte can be zero, skip leading 0 bytes // $2 = "\000: (85) call 4\nR1 type=ctx expected=fp\n", '\000' // ^^ for (int i = 0; i < 8 && *buf == 0; i++, buf++) ; if (*buf == 0) return false; return (strstr(buf, "invalid func ") == nullptr) && (strstr(buf, "unknown func ") == nullptr) && (strstr(buf, "program of this type cannot use helper ") == nullptr); } // Used to test whether kfuncs are supported in a certain type of BPF program. // // The kernel function check_kfunc_call() will check metadata before the BPF // Verifier. If the check fails, it will populate the log_buf with the // corresponding error log. We can determine the support status of the kfunc // in a BPF_PROG by matching specific logs. bool BPFfeature::kfunc_allowed(const char* kfunc, enum bpf_prog_type prog_type) { char logbuf[4096] = {}; struct bpf_insn insn_buf[512]; struct bpf_insn* insn = insn_buf; if (has_btf()) { int kfunc_btf_id = btf_.get_btf_id(kfunc, "vmlinux"); size_t insn_cnt = 0; if (kfunc_btf_id <= 0) { return false; } *insn++ = BPF_CALL_KFUNC(0, kfunc_btf_id); *insn++ = BPF_EXIT_INSN(); insn_cnt = insn - insn_buf; if (try_load_(nullptr, prog_type, std::nullopt, std::nullopt, insn_buf, insn_cnt, 1, logbuf, 4096)) { return true; } else { std::string errmsg = std::string("calling kernel function ") + kfunc + " is not allowed"; return strstr(logbuf, errmsg.c_str()) == nullptr; } } return false; } bool BPFfeature::has_kfunc(std::string kfunc) { int btf_id = 0; if (has_btf()) { btf_id = btf_.get_btf_id(kfunc, "vmlinux"); } return btf_id > 0; } bool BPFfeature::detect_prog_type(enum bpf_prog_type prog_type, const char* name, std::optional attach_type, int* outfd) { struct bpf_insn insns[] = { BPF_MOV64_IMM(BPF_REG_0, 0), BPF_EXIT_INSN() }; return try_load( prog_type, insns, ARRAY_SIZE(insns), name, attach_type, outfd); } bool BPFfeature::has_btf() { return btf_.has_data(); } int BPFfeature::instruction_limit() { if (insns_limit_.has_value()) return *insns_limit_; struct bpf_insn insns[] = { BPF_LD_IMM64(BPF_REG_0, 0), BPF_EXIT_INSN(), }; constexpr int logsize = 4096; char logbuf[logsize] = {}; bool res = try_load_(nullptr, BPF_PROG_TYPE_KPROBE, std::nullopt, std::nullopt, insns, ARRAY_SIZE(insns), 1, logbuf, logsize); if (!res) insns_limit_ = std::make_optional(-1); // Extract limit from the verifier log: // processed 2 insns (limit 131072), stack depth 0 std::string log(logbuf, logsize); std::size_t line_start = log.find("processed 2 insns"); if (line_start == std::string::npos) { insns_limit_ = std::make_optional(-1); return *insns_limit_; } // Old kernels don't have the instruction limit in the verifier output auto begin = log.find("limit", line_start); if (begin == std::string::npos) { insns_limit_ = std::make_optional(-1); return *insns_limit_; } begin += 6; /* "limit " = 6*/ std::size_t end = log.find(")", begin); std::string cnt = log.substr(begin, end - begin); insns_limit_ = std::make_optional(std::stoi(cnt)); return *insns_limit_; } bool BPFfeature::has_d_path() { if (has_d_path_.has_value()) return *has_d_path_; struct bpf_insn insns[] = { BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, 0), BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), BPF_MOV64_IMM(BPF_REG_6, 0), BPF_STX_MEM(BPF_DW, BPF_REG_2, BPF_REG_6, 0), BPF_LD_IMM64(BPF_REG_3, 8), BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_d_path), BPF_MOV64_IMM(BPF_REG_0, 0), BPF_EXIT_INSN(), }; has_d_path_ = std::make_optional(try_load(BPF_PROG_TYPE_TRACING, insns, ARRAY_SIZE(insns), "dentry_open", BPF_TRACE_FENTRY)); return *has_d_path_; } bool try_create_link(bpf_prog_type prog_type, const std::string_view prog_name, bpf_attach_type expected_attach_type, const bpf_link_create_opts& link_opts, std::optional expected_err) { bool result = false; DECLARE_LIBBPF_OPTS(bpf_prog_load_opts, load_opts); load_opts.expected_attach_type = expected_attach_type; struct bpf_insn insns[] = { BPF_MOV64_IMM(BPF_REG_0, 0), BPF_EXIT_INSN(), }; int progfd = bpf_prog_load(prog_type, prog_name.data(), "GPL", reinterpret_cast(insns), ARRAY_SIZE(insns), &load_opts); if (progfd < 0) return false; int linkfd = bpf_link_create(progfd, 0, expected_attach_type, &link_opts); result = expected_err.has_value() ? linkfd < 0 && -errno == *expected_err : linkfd >= 0; if (linkfd >= 0) { close(linkfd); } close(progfd); return result; } bool BPFfeature::has_kprobe_multi() { if (has_kprobe_multi_.has_value()) return *has_kprobe_multi_; if (no_feature_.kprobe_multi_) { has_kprobe_multi_ = false; return *has_kprobe_multi_; } const char* sym = "ksys_read"; DECLARE_LIBBPF_OPTS(bpf_link_create_opts, link_opts); link_opts.kprobe_multi.syms = &sym; link_opts.kprobe_multi.cnt = 1; has_kprobe_multi_ = try_create_link(BPF_PROG_TYPE_KPROBE, sym, BPF_TRACE_KPROBE_MULTI, link_opts, std::nullopt); return *has_kprobe_multi_; } bool BPFfeature::has_kprobe_session() { if (has_kprobe_session_.has_value()) return *has_kprobe_session_; if (no_feature_.kprobe_session_) { has_kprobe_session_ = false; return *has_kprobe_session_; } const char* sym = "ksys_read"; DECLARE_LIBBPF_OPTS(bpf_link_create_opts, link_opts); link_opts.kprobe_multi.syms = &sym; link_opts.kprobe_multi.cnt = 1; has_kprobe_session_ = try_create_link(BPF_PROG_TYPE_KPROBE, sym, BPF_TRACE_KPROBE_SESSION, link_opts, std::nullopt); return *has_kprobe_session_; } bool BPFfeature::has_uprobe_multi() { if (has_uprobe_multi_.has_value()) return *has_uprobe_multi_; if (no_feature_.uprobe_multi_) { has_uprobe_multi_ = false; return *has_uprobe_multi_; } DECLARE_LIBBPF_OPTS(bpf_link_create_opts, link_opts); const unsigned long offset = 0; link_opts.uprobe_multi.path = "/"; link_opts.uprobe_multi.offsets = &offset; link_opts.uprobe_multi.cnt = 1; has_uprobe_multi_ = try_create_link(BPF_PROG_TYPE_KPROBE, "uprobe_multi", BPF_TRACE_UPROBE_MULTI, link_opts, -EBADF); return *has_uprobe_multi_; } static void tabulate(std::stringstream& buf, std::vector>& data) { size_t len = data.size(); constexpr int width = 35; for (size_t i = 0; i < len; i += 2) { buf << std::setw(width) << std::left << " " + data[i].first + ": " + data[i].second << std::setw(width); if (i + 1 < len) { buf << data[i + 1].first + ": " + data[i + 1].second << std::endl; } else { buf << std::endl; } } } std::string BPFfeature::report() { std::stringstream buf; auto to_str = [](bool f) -> std::string { return f ? "yes" : "no"; }; std::vector> helpers = { { "dpath", to_str(has_d_path()) }, { "get_tai_ns", to_str(has_helper_ktime_get_tai_ns()) }, { "get_func_ip", to_str(has_helper_get_func_ip()) }, { "lookup_percpu_elem", to_str(has_helper_map_lookup_percpu_elem()) }, { "loop", to_str(has_helper_loop()) } }; std::vector> features = { { "Instruction limit", std::to_string(instruction_limit()) }, { "btf", to_str(has_btf()) }, { "module btf", to_str(btf_.has_module_btf()) }, }; std::vector> probe_types = { { "kprobe_multi", to_str(has_kprobe_multi()) }, { "uprobe_multi", to_str(has_uprobe_multi()) }, { "kprobe_session", to_str(has_kprobe_session()) }, { "iter", to_str(has_iter("task")) } }; buf << "Kernel helpers" << std::endl; tabulate(buf, helpers); buf << std::endl; buf << "Kernel features" << std::endl; tabulate(buf, features); buf << std::endl; buf << "Probe types" << std::endl; tabulate(buf, probe_types); buf << std::endl; return buf.str(); } bool BPFfeature::has_iter(std::string name) { auto tracing_name = "bpf_iter_" + name; return detect_prog_type(BPF_PROG_TYPE_TRACING, tracing_name.c_str(), BPF_TRACE_ITER); } } // namespace bpftrace bpftrace-0.27.1/src/bpffeature.h000066400000000000000000000066531526721631600164750ustar00rootroot00000000000000#pragma once #include #include #include #include #include "btf.h" namespace bpftrace { #define DEFINE_HELPER_TEST(name, progtype) \ protected: \ std::optional has_##name##_; \ \ public: \ bool has_helper_##name() \ { \ if (!has_##name##_.has_value()) \ has_##name##_ = std::make_optional( \ detect_helper(BPF_FUNC_##name, (progtype))); \ return *(has_##name##_); \ } class BPFfeature; class BPFnofeature { public: BPFnofeature() = default; int parse(const char* str); protected: bool kprobe_multi_{ false }; bool kprobe_session_{ false }; bool uprobe_multi_{ false }; friend class BPFfeature; }; class BPFfeature { public: BPFfeature(BPFnofeature& no_feature, BTF& btf) : no_feature_(no_feature), btf_(btf) { } virtual ~BPFfeature() = default; // Due to the unique_ptr usage the generated copy constructor & assignment // don't work. Move works but doesn't make sense as the `has_*` functions // will just reassign the unique_ptr. // A single bpffeature should be constructed in main() and passed around, // marking these as deleted to avoid accidentally copying/moving it. BPFfeature(const BPFfeature&) = delete; BPFfeature& operator=(const BPFfeature&) = delete; BPFfeature(BPFfeature&&) = delete; BPFfeature& operator=(BPFfeature&&) = delete; int instruction_limit(); bool has_btf(); bool has_d_path(); bool has_kprobe_multi(); bool has_kprobe_session(); bool has_uprobe_multi(); virtual bool has_iter(std::string name); std::string report(); DEFINE_HELPER_TEST(ktime_get_tai_ns, BPF_PROG_TYPE_KPROBE); DEFINE_HELPER_TEST(get_func_ip, BPF_PROG_TYPE_KPROBE); DEFINE_HELPER_TEST(map_lookup_percpu_elem, BPF_PROG_TYPE_KPROBE); DEFINE_HELPER_TEST(loop, BPF_PROG_TYPE_KPROBE); // Added in 5.17. bool has_kfunc(std::string kfunc); bool kfunc_allowed(const char* kfunc, enum bpf_prog_type prog_type); protected: std::optional has_d_path_; std::optional insns_limit_; std::optional has_kprobe_multi_; std::optional has_kprobe_session_; std::optional has_uprobe_multi_; std::optional has_kernel_dwarf_; private: bool detect_helper(bpf_func_id func_id, bpf_prog_type prog_type); bool detect_prog_type(bpf_prog_type prog_type, const char* name, std::optional attach_type, int* outfd = nullptr); bool try_load(bpf_prog_type prog_type, struct bpf_insn* insns, size_t len, const char* name = nullptr, std::optional attach_type = std::nullopt, int* outfd = nullptr); bool try_load_btf(const void* btf_data, size_t btf_size); BPFnofeature no_feature_; BTF& btf_; }; #undef DEFINE_HELPER_TEST } // namespace bpftrace bpftrace-0.27.1/src/bpfmap.cpp000066400000000000000000000174531526721631600161520ustar00rootroot00000000000000#include #include #include "bpfmap.h" #include "util/stats.h" #include "util/tseries.h" namespace bpftrace { char BpfMapError::ID = 0; const std::unordered_map BPF_MAP_TYPES = { { "hash", BPF_MAP_TYPE_HASH }, { "lruhash", BPF_MAP_TYPE_LRU_HASH }, { "percpuhash", BPF_MAP_TYPE_PERCPU_HASH }, { "percpulruhash", BPF_MAP_TYPE_LRU_PERCPU_HASH } }; int BpfMap::fd() const { return bpf_map__fd(bpf_map_); } bpf_map_type BpfMap::type() const { return type_; } const std::string &BpfMap::bpf_name() const { return name_; } std::string BpfMap::name() const { return bpftrace_map_name(bpf_name()); } uint32_t BpfMap::max_entries() const { return max_entries_; } bool BpfMap::is_stack_map() const { return name().starts_with("stack_"); } bool BpfMap::is_per_cpu_type() const { return type() == BPF_MAP_TYPE_PERCPU_HASH || type() == BPF_MAP_TYPE_LRU_PERCPU_HASH; } bool BpfMap::is_printable() const { // Internal maps are not printable return bpf_name().starts_with("AT_"); } std::vector BpfMap::collect_keys() const { const void *last_key = nullptr; std::vector keys; while (true) { int rc = 0; auto key = OpaqueValue::alloc(key_size_, [&](void *data) { rc = bpf_map_get_next_key(fd(), last_key, data); }); if (rc != 0) { break; } last_key = keys.emplace_back(std::move(key)).data(); } return keys; } Result<> BpfMap::zero_out(int nvalues) const { auto keys = collect_keys(); auto value_size = static_cast(value_size_) * static_cast(nvalues); auto zero = OpaqueValue::alloc(value_size, [&](void *data) { memset(data, 0, value_size); }); for (auto &k : keys) { int err = bpf_map_update_elem(fd(), k.data(), zero.data(), BPF_EXIST); if (err && err != -ENOENT) { return make_error(name_, "zero", err); } } return OK(); } Result<> BpfMap::clear() const { auto keys = collect_keys(); for (auto &k : keys) { int err = bpf_map_delete_elem(fd(), k.data()); if (err && err != -ENOENT) { return make_error(name_, "clear", err); } } return OK(); } Result<> BpfMap::update_elem(const void *key, const void *value) const { auto err = bpf_map_update_elem(fd(), key, value, BPF_ANY); if (err != 0) { return make_error(name_, "update", err); } return OK(); } Result<> BpfMap::lookup_elem(const void *key, void *value) const { auto err = bpf_map_lookup_elem(fd(), key, value); if (err != 0) { return make_error(name_, "lookup", err); } return OK(); } Result<> BpfMap::resize(uint32_t new_size) const { auto err = bpf_map__set_max_entries(bpf_map_, new_size); if (err != 0) { return make_error(name_, "resize", err); } return OK(); } Result BpfMap::collect_elements(int nvalues) const { auto keys = collect_keys(); MapElements values_by_key; for (auto &key : keys) { int err = 0; auto value = OpaqueValue::alloc( static_cast(value_size_) * static_cast(nvalues), [&](void *data) { err = bpf_map_lookup_elem(fd(), key.data(), data); }); if (err == -ENOENT) { // key was removed by the eBPF program during bpf_map_get_next_key() and // bpf_map_lookup_elem(), let's skip this key. continue; } else if (err) { return make_error(name_, "lookup", err); } values_by_key.emplace_back(std::move(key), std::move(value)); } return values_by_key; } Result BpfMap::collect_histogram_data(const MapInfo &map_info, int nvalues) const { auto keys = collect_keys(); HistogramMap values_by_key; for (auto &key : keys) { int err = 0; auto value = OpaqueValue::alloc( static_cast(value_size_) * static_cast(nvalues), [&](void *data) { err = bpf_map_lookup_elem(fd(), key.data(), data); }); if (err == -ENOENT) { // key was removed by the eBPF program during bpf_map_get_next_key() and // bpf_map_lookup_elem(), let's skip this key continue; } else if (err) { return make_error(name_, "lookup", err); } auto prefix = key.slice(0, map_info.key_type.GetSize()); auto bucket = key.slice(map_info.key_type.GetSize(), sizeof(uint64_t)); if (!values_by_key.contains(prefix)) { // New key - create a list of buckets for it if (map_info.value_type.IsHistTy()) values_by_key[prefix].resize(65 * 32, 0); else values_by_key[prefix].resize(1002, 0); } auto idx = bucket.bitcast(); values_by_key[prefix].at(idx) = util::reduce_value(value); } return values_by_key; } Result BpfMap::collect_tseries_data(const MapInfo &map_info, int nvalues) const { auto keys = collect_keys(); TSeriesMap values_by_key; const auto &tseries_args = std::get(map_info.detail); for (auto &key : keys) { int err = 0; auto value = OpaqueValue::alloc( static_cast(value_size_) * static_cast(nvalues), [&](void *data) { err = bpf_map_lookup_elem(fd(), key.data(), data); }); if (err == -ENOENT) { // key was removed by the eBPF program during bpf_map_get_next_key() and // bpf_map_lookup_elem(), let's skip this key continue; } else if (err) { return make_error(name_, "lookup", err); } auto prefix = key.slice(0, map_info.key_type.GetSize()); auto bucket = key.slice(map_info.key_type.GetSize(), sizeof(uint64_t)); auto tseries = values_by_key.try_emplace(prefix).first; auto [epoch, v] = util::reduce_tseries_value(value, tseries_args.value_type, tseries_args.agg); tseries->second.emplace(epoch, std::move(v)); } return values_by_key; } std::string to_string(MapType t) { switch (t) { case MapType::PerfEvent: return "perf_event"; case MapType::Elapsed: return "elapsed"; case MapType::Ringbuf: return "ringbuf"; case MapType::EventLossCounter: return "event_loss_counter"; case MapType::RecursionPrevention: return "recursion_prevention"; } return {}; // unreached } bpf_map_type get_bpf_map_type(const SizedType &val_type) { if (val_type.NeedsPercpuMap()) { return BPF_MAP_TYPE_PERCPU_HASH; } else { return BPF_MAP_TYPE_HASH; } } std::optional get_bpf_map_type(const std::string &name) { auto found = BPF_MAP_TYPES.find(name); if (found == BPF_MAP_TYPES.end()) { return std::nullopt; } return found->second; } std::string get_bpf_map_type_str(bpf_map_type map_type) { for (const auto &pair : BPF_MAP_TYPES) { if (pair.second == map_type) { return pair.first; } } return "unknown"; } void add_bpf_map_types_hint(std::stringstream &hint) { hint << "Valid map types: "; int num_types = BPF_MAP_TYPES.size(); for (const auto &bpf_type : BPF_MAP_TYPES) { hint << bpf_type.first; num_types--; if (num_types != 0) { hint << ", "; } } } bool bpf_map_types_compatible(const SizedType &val_type, bpf_map_type kind) { auto kind_from_stype = get_bpf_map_type(val_type); if (kind_from_stype == kind) { return true; } if ((kind_from_stype == BPF_MAP_TYPE_HASH || kind_from_stype == BPF_MAP_TYPE_LRU_HASH) && (kind == BPF_MAP_TYPE_HASH || kind == BPF_MAP_TYPE_LRU_HASH)) { return true; } if ((kind_from_stype == BPF_MAP_TYPE_PERCPU_HASH || kind_from_stype == BPF_MAP_TYPE_LRU_PERCPU_HASH) && (kind == BPF_MAP_TYPE_PERCPU_HASH || kind == BPF_MAP_TYPE_LRU_PERCPU_HASH)) { return true; } return false; } } // namespace bpftrace bpftrace-0.27.1/src/bpfmap.h000066400000000000000000000070621526721631600156120ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include "map_info.h" #include "util/opaque.h" namespace bpftrace { class BpfMapError : public ErrorInfo { public: static char ID; std::string name_; std::string op_; int errno_; BpfMapError(std::string name_, std::string op_, int errno_) : name_(std::move(name_)), op_(std::move(op_)), errno_(errno_) { } void log(llvm::raw_ostream &OS) const override { OS << "BPF map operation " << op_ << " failed: " << std::strerror(-errno_) << " [map = " << name_ << "]"; } }; using util::OpaqueValue; using MapElements = std::vector>; using HistogramMap = std::map>; using TSeries = std::map; using TSeriesMap = std::map; class BpfMap { public: BpfMap(struct bpf_map *bpf_map) : bpf_map_(bpf_map), type_(bpf_map__type(bpf_map)), name_(bpf_map__name(bpf_map)), key_size_(bpf_map__key_size(bpf_map)), value_size_(bpf_map__value_size(bpf_map)), max_entries_(bpf_map__max_entries(bpf_map)) { } BpfMap(bpf_map_type type, std::string name, uint32_t key_size, uint32_t value_size, uint32_t max_entries) : type_(type), name_(std::move(name)), key_size_(key_size), value_size_(value_size), max_entries_(max_entries) { } virtual ~BpfMap() = default; int fd() const; bpf_map_type type() const; const std::string &bpf_name() const; std::string name() const; uint32_t max_entries() const; bool is_stack_map() const; bool is_per_cpu_type() const; bool is_printable() const; std::vector collect_keys() const; virtual Result collect_elements(int nvalues) const; virtual Result collect_histogram_data(const MapInfo &map_info, int nvalues) const; virtual Result collect_tseries_data(const MapInfo &map_info, int nvalues) const; Result<> zero_out(int nvalues) const; Result<> clear() const; Result<> update_elem(const void *key, const void *value) const; Result<> lookup_elem(const void *key, void *value) const; Result<> resize(uint32_t new_size) const; private: struct bpf_map *bpf_map_; bpf_map_type type_; std::string name_; uint32_t key_size_; uint32_t value_size_; uint32_t max_entries_; }; // Internal map types enum class MapType { // Also update to_string PerfEvent, Elapsed, Ringbuf, EventLossCounter, RecursionPrevention, }; std::string to_string(MapType t); // BPF maps do not accept "@" in name so we replace it by "AT_". // The below two functions do the translations. inline std::string bpf_map_name(std::string_view bpftrace_map_name) { auto name = std::string{ bpftrace_map_name }; if (name[0] == '@') name = "AT_" + name.substr(1); return name; } inline std::string bpftrace_map_name(std::string_view bpf_map_name) { auto name = std::string{ bpf_map_name }; if (name.starts_with("AT_")) name = "@" + name.substr(3); return name; } bpf_map_type get_bpf_map_type(const SizedType &val_type); std::optional get_bpf_map_type(const std::string &name); std::string get_bpf_map_type_str(bpf_map_type map_type); void add_bpf_map_types_hint(std::stringstream &hint); bool bpf_map_types_compatible(const SizedType &val_type, bpf_map_type kind); } // namespace bpftrace bpftrace-0.27.1/src/bpfprogram.cpp000066400000000000000000000076211526721631600170400ustar00rootroot00000000000000#include #include #include #include #include "attached_probe.h" #include "bpfprogram.h" #include "log.h" #include "util/exceptions.h" #include "util/fd.h" namespace bpftrace { BpfProgram::BpfProgram(struct bpf_program *bpf_prog) : bpf_prog_(bpf_prog) { } int BpfProgram::fd() const { return bpf_program__fd(bpf_prog_); } void BpfProgram::set_prog_type(const Probe &probe) { auto prog_type = progtype(probe.type); bpf_program__set_type(bpf_prog_, prog_type); } void BpfProgram::set_expected_attach_type(const Probe &probe, BPFfeature &feature) { auto attach_type = static_cast(0); if (probe.type == ProbeType::fentry) attach_type = BPF_TRACE_FENTRY; else if (probe.type == ProbeType::fexit) attach_type = BPF_TRACE_FEXIT; else if (probe.type == ProbeType::iter) attach_type = BPF_TRACE_ITER; else if (probe.type == ProbeType::rawtracepoint) attach_type = BPF_TRACE_RAW_TP; // We want to avoid kprobe_multi when a module is specified // because the BPF_TRACE_KPROBE_MULTI link type does not // currently support the `module:function` syntax. if ((probe.type == ProbeType::kprobe || probe.type == ProbeType::kretprobe) && !probe.funcs.empty() && probe.path.empty()) { if (probe.is_session && feature.has_kprobe_session()) attach_type = BPF_TRACE_KPROBE_SESSION; else if (feature.has_kprobe_multi()) attach_type = BPF_TRACE_KPROBE_MULTI; } if (feature.has_uprobe_multi() && (((probe.type == ProbeType::uprobe || probe.type == ProbeType::uretprobe) && !probe.funcs.empty()) || probe.type == ProbeType::usdt)) { attach_type = BPF_TRACE_UPROBE_MULTI; } bpf_program__set_expected_attach_type(bpf_prog_, attach_type); } void BpfProgram::set_attach_target(const Probe &probe, const BTF &btf, const Config &config) { if (probe.type != ProbeType::fentry && probe.type != ProbeType::fexit && probe.type != ProbeType::iter && probe.type != ProbeType::rawtracepoint) return; const std::string &mod = probe.path; const std::string &fun = probe.attach_point; std::string attach_target = !mod.empty() ? mod + ":" + fun : fun; std::string btf_fun; __u32 btf_kind = BTF_KIND_FUNC; if (probe.type == ProbeType::iter) { btf_fun = "bpf_iter_" + fun; } else if (probe.type == ProbeType::rawtracepoint) { btf_fun = "btf_trace_" + fun; btf_kind = BTF_KIND_TYPEDEF; } else { btf_fun = fun; } std::string err_msg; if ((probe.type == ProbeType::fentry || probe.type == ProbeType::fexit) && mod == "bpf") { int raw_fd = bpf_prog_get_fd_by_id(static_cast<__u32>(probe.bpf_prog_id)); if (raw_fd < 0) { err_msg = "No valid BPF program found with name: " + fun + " and id: " + std::to_string(probe.bpf_prog_id) + "."; } else { bpf_prog_fd_ = util::FD(raw_fd); attach_target = fun; } } else if (btf.get_btf_id(btf_fun, mod, btf_kind) < 0) { err_msg = "No BTF found for " + attach_target + "."; } if (!err_msg.empty()) { if (config.missing_probes == ConfigMissingProbes::error) { LOG(ERROR) << err_msg; } else if (config.missing_probes == ConfigMissingProbes::warn) { LOG(WARNING) << err_msg; } bpf_program__set_autoload(bpf_prog_, false); } bpf_program__set_attach_target(bpf_prog_, bpf_prog_fd_ ? *bpf_prog_fd_ : 0, attach_target.c_str()); } void BpfProgram::set_no_autoattach() { bpf_program__set_autoattach(bpf_prog_, false); } void BpfProgram::set_no_autoload() { bpf_program__set_autoload(bpf_prog_, false); } struct bpf_program *BpfProgram::bpf_prog() const { return bpf_prog_; } } // namespace bpftrace bpftrace-0.27.1/src/bpfprogram.h000066400000000000000000000020371526721631600165010ustar00rootroot00000000000000#pragma once #include #include "bpffeature.h" #include "btf.h" #include "config.h" #include "probe_types.h" #include "util/fd.h" namespace bpftrace { class BpfBytecode; class BPFtrace; // This class abstracts a single BPF program by encapsulating libbpf's // 'struct bpf_prog'. class BpfProgram { public: explicit BpfProgram(struct bpf_program *bpf_prog); void set_prog_type(const Probe &probe); void set_expected_attach_type(const Probe &probe, BPFfeature &feature); void set_attach_target(const Probe &probe, const BTF &btf, const Config &config); void set_no_autoattach(); void set_no_autoload(); int fd() const; struct bpf_program *bpf_prog() const; BpfProgram(const BpfProgram &) = delete; BpfProgram &operator=(const BpfProgram &) = delete; BpfProgram(BpfProgram &&) = default; BpfProgram &operator=(BpfProgram &&) = default; private: struct bpf_program *bpf_prog_; std::optional bpf_prog_fd_ = std::nullopt; }; } // namespace bpftrace bpftrace-0.27.1/src/bpftrace.cpp000066400000000000000000001360221526721631600164650ustar00rootroot00000000000000#include "bpfbytecode.h" #include "types_format.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIBSYSTEMD #include #endif #include "ast/context.h" #include "async_action.h" #include "attached_probe.h" #include "bpfmap.h" #include "bpfprogram.h" #include "bpftrace.h" #include "btf.h" #include "dwarf/dwunwind.h" #include "dwarf/dwunwind_loader.h" #include "log.h" #include "output/capture.h" #include "output/discard.h" #include "output/text.h" #include "scopeguard.h" #include "symbols/kernel.h" #include "util/bpf_names.h" #include "util/cgroup.h" #include "util/paths.h" #include "util/strings.h" #include "util/system.h" #include "util/wildcard.h" using namespace std::chrono_literals; namespace bpftrace { std::set bt_debug = {}; bool bt_quiet = false; bool bt_verbose = false; bool dry_run = false; volatile sig_atomic_t BPFtrace::exitsig_recv = false; volatile sig_atomic_t BPFtrace::sigusr1_recv = false; static void log_probe_attach_failure(const std::string &err_msg, const std::string &name, ConfigMissingProbes missing_probes) { if (missing_probes == ConfigMissingProbes::error) { if (!err_msg.empty()) { LOG(ERROR) << err_msg; } LOG(ERROR) << "Unable to attach probe: " << name << ". If this is expected, set the 'missing_probes' " "config variable to 'warn'."; } else if (missing_probes == ConfigMissingProbes::warn) { if (!err_msg.empty()) { LOG(WARNING) << err_msg; } LOG(WARNING) << "Unable to attach probe: " << name << ". Skipping."; } } static void set_rlimit_nofile(size_t num_probes, size_t num_maps) { // 3 fds per probe + maps + buffer for things like scratch maps size_t needed_fd_count = (num_probes * 3) + num_maps + 50; rlimit current_limit; if (getrlimit(RLIMIT_NOFILE, ¤t_limit) != 0) { LOG(V1) << "Could not get current RLIMIT_NOFILE"; return; } if (current_limit.rlim_cur >= needed_fd_count) { return; } struct rlimit rl = {}; int err; rl.rlim_max = needed_fd_count; rl.rlim_cur = needed_fd_count; err = setrlimit(RLIMIT_NOFILE, &rl); if (err) LOG(WARNING) << std::strerror(err) << ": couldn't set RLIMIT_NOFILE for " << "bpftrace. If your program is not loading, you can try increasing" << "\"ulimit -n\" to fix the problem"; } BPFtrace::~BPFtrace() { close_pcaps(); } Probe BPFtrace::generate_probe(const ast::AttachPoint &ap, const ast::Probe &p, ast::ExpansionType expansion, std::set expanded_funcs) { Probe probe; probe.path = ap.target; probe.attach_point = ap.func; probe.type = probetype(ap.provider); probe.log_size = config_->log_size; probe.ns = ap.ns; probe.name = ap.name(); probe.freq = ap.freq; probe.address = ap.address; probe.func_offset = ap.func_offset; probe.loc = 0; probe.index = p.index(); probe.len = ap.len; probe.mode = ap.mode; probe.pin = ap.pin; probe.is_session = expansion == ast::ExpansionType::SESSION; probe.funcs = std::move(expanded_funcs); probe.bpf_prog_id = ap.bpf_prog_id; return probe; } int BPFtrace::add_probe(const ast::AttachPoint &ap, const ast::Probe &p, ast::ExpansionType expansion, std::set expanded_funcs) { auto type = probetype(ap.provider); auto probe = generate_probe(ap, p, expansion, std::move(expanded_funcs)); if (ap.provider == "begin") { resources.begin_probes.emplace_back(std::move(probe)); } else if (ap.provider == "end") { resources.end_probes.emplace_back(std::move(probe)); } else if (ap.provider == "test") { resources.test_probes.emplace_back(std::move(probe)); } else if (ap.provider == "bench") { resources.benchmark_probes.emplace_back(std::move(probe)); } else if (ap.provider == "self") { if (ap.target == "signal") { resources.signal_probes.emplace_back(std::move(probe)); } } else { resources.probes.emplace_back(std::move(probe)); } if (type == ProbeType::iter) has_iter_ = true; // Preload symbol tables if necessary if (resources.probes_using_usym.contains(&p) && util::is_exe(ap.target)) { usyms_.cache(ap.target, this->pid()); } return 0; } int BPFtrace::num_probes() const { return resources.num_probes(); } void BPFtrace::request_finalize() { finalize_ = true; attached_probes_.clear(); if (child_) { auto result = child_->terminate(); if (!result) consumeError(result.takeError()); } } // PerfEventContext is our callback wrapper. struct PerfEventContext { PerfEventContext(BPFtrace &b, async_action::AsyncHandlers &handlers, output::Output &o) : bpftrace(b), handlers(handlers), output(o) {}; BPFtrace &bpftrace; async_action::AsyncHandlers &handlers; output::Output &output; }; static Result<> event_printer(void *cb_cookie, void *raw_data, int size) { auto *ctx = static_cast(cb_cookie); // N.B. This will copy the value into its own buffer, potentially allocating // and freeing a new chunk if it is larger than a single word. This is // guaranteed to be aligned. auto data = OpaqueValue::alloc(size, [&](char *data) { memcpy(data, raw_data, size); }); // Ignore the remaining events if event_printer is called during // finalization stage (exit() builtin has been called) if (ctx->bpftrace.finalize_) return OK(); if (bpftrace::BPFtrace::exitsig_recv) { ctx->bpftrace.request_finalize(); return OK(); } // async actions auto printf_id = async_action::AsyncAction(data.bitcast()); if (printf_id == async_action::AsyncAction::exit) { return ctx->handlers.exit(data); } else if (printf_id == async_action::AsyncAction::print) { return ctx->handlers.print_map(data); } else if (printf_id == async_action::AsyncAction::print_non_map) { return ctx->handlers.print_non_map(data); } else if (printf_id == async_action::AsyncAction::clear) { return ctx->handlers.clear_map(data); } else if (printf_id == async_action::AsyncAction::zero) { return ctx->handlers.zero_map(data); } else if (printf_id == async_action::AsyncAction::time) { return ctx->handlers.time(data); } else if (printf_id == async_action::AsyncAction::join) { return ctx->handlers.join(data); } else if (printf_id == async_action::AsyncAction::runtime_error) { return ctx->handlers.runtime_error(data); } else if (printf_id == async_action::AsyncAction::skboutput) { return ctx->handlers.skboutput(data); } else if (printf_id >= async_action::AsyncAction::syscall && printf_id <= async_action::AsyncAction::syscall_end) { return ctx->handlers.syscall(data); } else if (printf_id >= async_action::AsyncAction::cat && printf_id <= async_action::AsyncAction::cat_end) { return ctx->handlers.cat(data); } else if (printf_id >= async_action::AsyncAction::printf && printf_id <= async_action::AsyncAction::printf_end) { return ctx->handlers.printf(data); } else { LOG(BUG) << "Unknown printf_id: " << static_cast(printf_id); return OK(); // Unreachable. } } static int ringbuf_printer(void *cb_cookie, void *data, size_t size) { auto ok = event_printer(cb_cookie, data, size); if (!ok) { LOG(ERROR) << ok.takeError(); } return 0; } static void skb_output_printer(void *ctx, [[maybe_unused]] int cpu, void *data, __u32 size) { auto ok = event_printer(ctx, data, size); if (!ok) { LOG(ERROR) << ok.takeError(); } } void skb_output_lost(void *ctx, [[maybe_unused]] int cpu, __u64 cnt) { auto *perf_ctx = static_cast(ctx); perf_ctx->output.lost_events(cnt); } void BPFtrace::add_param(const std::string ¶m) { params_.emplace_back(param); } std::string BPFtrace::get_param(size_t i) const { if (params_.size() < i) { return ""; } return params_.at(i - 1); } size_t BPFtrace::num_params() const { return params_.size(); } Result> BPFtrace::attach_probe( Probe &probe, const BpfBytecode &bytecode) { const auto &program = bytecode.getProgramForProbe(probe); std::optional pid = child_ ? std::make_optional(child_->pid()) : this->pid(); auto ap = AttachedProbe::make(probe, program, pid, safe_mode_); if (!ap) { auto missing_probes = config_->missing_probes; auto ok = handleErrors(std::move(ap), [&](const AttachError &err) { log_probe_attach_failure(err.msg(), probe.name, missing_probes); }); return make_error(); } else { return std::move(*ap); } } bool attach_reverse(const Probe &p) { switch (p.type) { case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::kprobe: case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: case ProbeType::fentry: case ProbeType::fexit: case ProbeType::iter: return true; case ProbeType::kretprobe: case ProbeType::tracepoint: case ProbeType::profile: case ProbeType::interval: case ProbeType::watchpoint: case ProbeType::hardware: case ProbeType::rawtracepoint: case ProbeType::software: return false; case ProbeType::invalid: LOG(BUG) << "Unknown probe type"; } return {}; // unreached } int BPFtrace::run_iter() { auto probe = resources.probes.begin(); char buf[1024] = {}; ssize_t len; if (probe == resources.probes.end()) { LOG(ERROR) << "Failed to create iter probe"; return 1; } // If a script contains an iter probe, it must be the only probe assert(attached_probes_.size() == 1); if (attached_probes_.empty()) { LOG(ERROR) << "Failed to attach iter probe"; return 1; } auto &ap = *attached_probes_.begin(); int link_fd = ap->link_fd(); if (probe->pin.empty()) { int iter_fd = bpf_iter_create(link_fd); if (iter_fd < 0) { LOG(ERROR) << "Failed to open iter probe link"; return 1; } while ((len = read(iter_fd, buf, sizeof(buf))) > 0) { fwrite(buf, len, 1, stdout); } close(iter_fd); } else { auto pin = probe->pin; if (pin.at(0) != '/') pin = "/sys/fs/bpf/" + pin; if (bpf_obj_pin(link_fd, pin.c_str())) LOG(ERROR) << "Failed to pin iter probe link"; else std::cout << "Program pinned to " << pin << std::endl; } return 0; } int BPFtrace::prerun() const { uint64_t num_probes = this->num_probes(); const auto max_probes = config_->max_probes; if (num_probes == 0) { if (!bt_quiet) std::cout << "No probes to attach" << std::endl; return 1; } else if (num_probes > max_probes) { LOG(ERROR) << "Can't attach to " << num_probes << " probes because it " << "exceeds the current limit of " << max_probes << " probes.\n" << "You can increase the limit through the BPFTRACE_MAX_PROBES " << "environment variable, but BE CAREFUL since a high number of probes " << "attached can cause your system to crash."; return 1; } return 0; } int BPFtrace::run(output::Output &out, const ast::CDefinitions &c_definitions, BpfBytecode bytecode) { // temporary storage for DWARF unwind data, between parse and feed std::map>> unwind_data; std::map> unwind_mappings; bytecode_ = std::move(bytecode); bytecode_.set_map_ids(resources); if (!probe_filter_.empty()) { std::regex filter_re; try { filter_re = std::regex(probe_filter_); } catch (const std::regex_error &e) { LOG(ERROR) << "Invalid --probe-filter regex '" << probe_filter_ << "': " << e.what(); return -1; } auto filter = [&](std::vector &probes) { std::erase_if(probes, [&](const Probe &probe) { if (!std::regex_search(probe.name, filter_re)) { auto &prog = bytecode_.getProgramForProbe(probe); prog.set_no_autoload(); return true; } return false; }); }; filter(resources.probes); filter(resources.test_probes); filter(resources.benchmark_probes); filter(resources.watchpoint_probes); } int err = prerun(); if (err) return err; set_rlimit_nofile(resources.num_probes(), resources.maps_info.size()); // map DWUNWIND_MAPPINGS is only present if dw_unwind() is used. bool needs_dwarf_unwind = bytecode_.hasMap(DWUNWIND_MAPPINGS); if (needs_dwarf_unwind) { if (procmon_) dwarf_pids_.emplace_back(procmon_->pid()); if (child_) dwarf_pids_.emplace_back(child_->pid()); if (dwarf_pids_.empty()) { LOG(ERROR) << "dw_ustack requires a target process. " "Use -p, -c, or --dwarf-pid to specify one."; return -1; } } if (!(run_tests_ || run_benchmarks_) && child_ && (has_usdt_ || needs_dwarf_unwind)) { auto result = child_->run(true); if (!result) { LOG(ERROR) << "Failed to setup child: " << result.takeError(); return -1; } if (needs_dwarf_unwind) { // Run the program to its entry point, normally _start. This ensures // that the shared libraries are loaded. We need this to be able to // extract the unwind information from the libraries as well. // As we haven't attached any probes yet, we might miss events related // to the loader itself. // TODO: Currently we have to parse the unwind tables before loading the // bpf programs, as we need to resize the maps accordingly. // Once we have support for dynamic hash maps, we can change the order // to first load/attach the programs, then run_until_entry, and then // parse and feed the unwind tables directly. This eliminates the race // condition. // Mainline supports it from 6.1. auto ok = child_->run_until_entry(); if (!ok) { LOG(ERROR) << "Failed to run child to entry: " << ok.takeError(); return -1; } } } if (needs_dwarf_unwind) parse_dwarf_unwind(bytecode_, dwarf_pids_, unwind_data, unwind_mappings); auto ok = bytecode_.load_progs(resources, *btf_, *feature_, *config_); if (!ok) { auto errs = handleErrors(std::move(ok), [&](const HelperVerifierError &e) { // To provide the most useful diagnostics, provide the error for every // callsite. After all, they all must be fixed. for (const auto &info : helper_use_loc_[e.func_id()]) { bool first = true; for (const auto &loc : info.locations) { if (first) { LOG(ERROR, std::string(loc.source_location), std::vector(loc.source_context)) << e.message(); first = false; } else { LOG(ERROR, std::string(loc.source_location), std::vector(loc.source_context)) << "expanded from"; } } } }); if (!errs) { // An error occurred, but we don't have location for this helper. It may // be a C file or elsewhere, and we need to plumb this through somehow. // At least inform the user what has gone wrong in this case. LOG(ERROR) << errs.takeError(); } return -1; } if (needs_dwarf_unwind) { int ret = feed_dwarf_unwind(bytecode_, unwind_data, unwind_mappings); if (ret) return ret; } async_action::AsyncHandlers handlers(*this, c_definitions, out); PerfEventContext ctx(*this, handlers, out); err = setup_output(&ctx); if (err) return err; SCOPE_EXIT { teardown_output(); }; err = create_pcaps(); if (err) { LOG(ERROR) << "Failed to create pcap file(s)"; return err; } if (bytecode_.hasMap(MapType::Elapsed)) { struct timespec ts; clock_gettime(CLOCK_BOOTTIME, &ts); auto nsec = (1000000000ULL * ts.tv_sec) + ts.tv_nsec; uint64_t key = 0; auto map = bytecode_.getMap(MapType::Elapsed); auto ok = map.update_elem(&key, &nsec); if (!ok) { LOG(ERROR) << "Failed to write start time to elapsed map: " << ok.takeError(); return -1; } } int num_begin_attached = 0; int num_end_attached = 0; int num_signal_attached = 0; int num_test_attached = 0; int num_benchmark_attached = 0; for (const auto &begin_probe : resources.begin_probes) { auto &begin_prog = bytecode_.getProgramForProbe(begin_probe); if (::bpf_prog_test_run_opts(begin_prog.fd(), nullptr)) return -1; LOG(V1) << "Attaching 'begin' probe"; ++num_begin_attached; } num_end_attached += resources.end_probes.size(); int rval = 0; // Used for return below. if (run_tests_ || run_benchmarks_) { if (run_tests_) { std::vector all_tests; std::vector all_passed; for (auto &probe : resources.test_probes) { all_tests.emplace_back(probe.path); } for (size_t index = 0; index < resources.test_probes.size(); index++) { ++num_test_attached; auto &probe = resources.test_probes[index]; auto &test_prog = bytecode_.getProgramForProbe(probe); // We swap our output for something that will capture the // result of executing this single test. `poll_output` should // be called after each test, and `ss.str("")` to reset the // output (or used as required). std::stringstream ss; auto text_output = std::make_unique(ss, ss); auto capture = std::make_unique(*text_output); handlers.change_output(*capture); // See below; we must provide sufficient data. constexpr size_t ETH_HLEN = 14; char data_in[ETH_HLEN]; DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts); opts.data_in = data_in; opts.data_size_in = ETH_HLEN; opts.repeat = 1; if (auto ret = ::bpf_prog_test_run_opts(test_prog.fd(), &opts)) { LOG(ERROR) << "bpf_prog_test_run_opts failed: " << ret; return -1; } // See above; ensure the output is flushed. poll_output(*capture, true); bool passed = opts.retval == 0 && exit_code == 0 && capture->error_count == 0; all_passed.push_back(passed); out.test_result(all_tests, index, std::chrono::nanoseconds(opts.duration), all_passed, ss.str()); // Override the return value. if (rval == 0 && !passed) { rval = 1; } exit_code = 0; // Reset for all tests. } // Return the original output. handlers.change_output(out); } else if (run_benchmarks_) { std::vector all_benches; for (auto &probe : resources.benchmark_probes) { all_benches.emplace_back(probe.path); } for (size_t index = 0; index < resources.benchmark_probes.size(); index++) { ++num_benchmark_attached; auto &probe = resources.benchmark_probes[index]; auto &benchmark_prog = bytecode_.getProgramForProbe(probe); // Increase opts.repeat until we reach at least 1ms of run time. We // double the repeat time each instance, so each probe should take // a few milliseconds at most (plus loading time, etc). size_t iters = 1; while (true) { // Benchmarks have all output suppressed. auto discard = std::make_unique(); auto capture = std::make_unique(*discard); handlers.change_output(*capture); // Note: on newer kernels you must provide a data_in buffer at least // ETH_HLEN bytes long to make sure input validation works for // opts. Otherwise, bpf_prog_test_run_opts will return -EINVAL for // BPF_PROG_TYPE_XDP. // // https://github.com/torvalds/linux/commit/6b3d638ca897e099fa99bd6d02189d3176f80a47 constexpr size_t ETH_HLEN = 14; char data_in[ETH_HLEN]; DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts); opts.data_in = data_in; opts.data_size_in = ETH_HLEN; opts.repeat = iters; if (auto ret = ::bpf_prog_test_run_opts(benchmark_prog.fd(), &opts)) { LOG(ERROR) << "bpf_prog_test_run_opts failed: " << ret; return -1; } poll_output(*capture, true); // Allow skipping benchmarks by returning 1. if (exit_code == 0 && opts.retval != 0) { break; } // Did we run for enough time? auto total = std::chrono::nanoseconds(opts.duration) * iters; if (total < std::chrono::microseconds(1)) { iters *= 10'00; continue; } if (total < std::chrono::microseconds(10)) { iters *= 100; continue; } if (total < std::chrono::microseconds(100)) { iters *= 10; continue; } if (total < std::chrono::milliseconds(1)) { iters *= 2; continue; } // We don't include any benchmark results that have failed, but // they are allowed to skip by returning 1. If they explicitly // use errorf or something similar, then we fail the run. if (exit_code != 0 || capture->error_count != 0) { LOG(ERROR) << "Benchmark '" << probe.path << "' failed."; rval = 1; exit_code = 0; // Always reset for tests. break; } out.benchmark_result(all_benches, index, std::chrono::nanoseconds(opts.duration), iters); handlers.change_output(out); break; } } } } else { for (auto &probe : resources.signal_probes) { auto &sig_prog = bytecode_.getProgramForProbe(probe); sigusr1_prog_fds_.emplace_back(sig_prog.fd()); ++num_signal_attached; } bytecode_.attach_external(); // The kernel appears to fire some probes in the order that they were // attached and others in reverse order. In order to make sure that blocks // are executed in the same order they were declared, iterate over the // probes twice: in the first pass iterate forward and attach the probes // that will be fired in the same order they were attached, and in the // second pass iterate in reverse and attach the rest. for (auto &probe : resources.probes) { if (BPFtrace::exitsig_recv) { request_finalize(); return -1; } if (!attach_reverse(probe)) { auto ap = attach_probe(probe, bytecode_); if (!ap) { if (config_->missing_probes == ConfigMissingProbes::error) { return -1; } } else { attached_probes_.push_back(std::move(*ap)); } } } for (auto &probe : std::ranges::reverse_view(resources.probes)) { if (BPFtrace::exitsig_recv) { request_finalize(); return -1; } if (attach_reverse(probe)) { auto ap = attach_probe(probe, bytecode_); if (!ap) { if (config_->missing_probes == ConfigMissingProbes::error) { return -1; } } else { attached_probes_.push_back(std::move(*ap)); } } } if (dry_run) { request_finalize(); return rval; } // Kick the child to execute the command. if (child_) { if (has_usdt_ || needs_dwarf_unwind) { auto result = child_->resume(); if (!result) { LOG(ERROR) << "Failed to run child: " << result.takeError(); return -1; } } else { auto result = child_->run(); if (!result) { LOG(ERROR) << "Failed to run child: " << result.takeError(); return -1; } } } } size_t num_attached = 0; for (auto &ap : attached_probes_) { num_attached += ap->probe_count(); } auto total_attached = num_attached + num_begin_attached + num_end_attached + num_signal_attached + num_test_attached + num_benchmark_attached; if (total_attached == 0) { // Provide some helpful hints, there if there are test or benchmark probes // defined, they won't be attached unless the appropriate mode is set. if (!resources.test_probes.empty()) { LOG(ERROR) << "No probes attached; use --test to run test probes."; } else if (!resources.benchmark_probes.empty()) { LOG(ERROR) << "No probes attached; use --bench to run benchmark probes."; } else { LOG(ERROR) << "Attachment failed for all probes."; } return -1; } if (!bt_quiet && !run_tests_ && !run_benchmarks_) { out.attached_probes(total_attached); } // Used by runtime test framework to know when to run AFTER directive if (std::getenv("__BPFTRACE_NOTIFY_PROBES_ATTACHED")) std::cout << "__BPFTRACE_NOTIFY_PROBES_ATTACHED" << std::endl; #ifdef HAVE_LIBSYSTEMD err = sd_notify(false, "READY=1\nSTATUS=Processing events..."); if (err < 0) LOG(WARNING) << "Failed to send readiness notification, ignoring: " << strerror(-err); #endif if (has_iter_) { int err = run_iter(); if (err) return err; } else { bool should_drain = (num_begin_attached > 0 || num_end_attached > 0 || run_tests_ || run_benchmarks_) && num_signal_attached == 0 && num_attached == 0; poll_output(out, should_drain); } #ifdef HAVE_LIBSYSTEMD err = sd_notify(false, "STOPPING=1\nSTATUS=Shutting down..."); if (err < 0) LOG(WARNING) << "Failed to send shutdown notification, ignoring: " << strerror(-err); #endif attached_probes_.clear(); // finalize_ and exitsig_recv should be false from now on otherwise // event_printer() can ignore the `end` events. finalize_ = false; exitsig_recv = false; for (const auto &end_probe : resources.end_probes) { auto &end_prog = bytecode_.getProgramForProbe(end_probe); if (::bpf_prog_test_run_opts(end_prog.fd(), nullptr)) return -1; LOG(V1) << "Attaching 'end' probe"; } poll_output(out, /* drain */ true); uint64_t total_lost_events = bytecode_.get_event_loss_counter(*this, max_cpu_id_); if (total_lost_events > 0) { // We incrementally log lost event counts to stdout via `output` // so users can get a record of it in their txt/json output // but let's log to stderr here to make sure this message doesn't // get lost to users in scripts with high frequency output LOG(WARNING) << "Total lost event count: " << total_lost_events; } // Indicate that we are done the main loop. out.end(); // Print maps if needed (true by default). if (!err && !run_tests_ && !run_benchmarks_ && !dry_run && config_->print_maps_on_exit) { for (const auto &[_, map] : bytecode_.maps()) { if (!map.is_printable()) continue; auto res = format(*this, c_definitions, map); if (!res) { std::cerr << "Error printing map: " << res.takeError(); continue; } out.map(map.name(), *res); } } return rval; } int BPFtrace::setup_output(void *ctx) { setup_ringbuf(ctx); if (resources.using_skboutput) { return setup_skboutput_perf_buffer(ctx); } return 0; } int BPFtrace::setup_skboutput_perf_buffer(void *ctx) { auto map = bytecode_.getMap(MapType::PerfEvent); auto num_pages = get_buffer_pages_per_cpu(); if (!num_pages) { LOG(ERROR) << num_pages.takeError(); return -1; } skb_perfbuf_ = perf_buffer__new(map.fd(), *num_pages, &skb_output_printer, &skb_output_lost, ctx, nullptr); if (skb_perfbuf_ == nullptr) { LOG(ERROR) << "Failed to open perf buffer"; return -1; } return 0; } void BPFtrace::setup_ringbuf(void *ctx) { ringbuf_ = ring_buffer__new( bytecode_.getMap(MapType::Ringbuf).fd(), ringbuf_printer, ctx, nullptr); } void BPFtrace::teardown_output() { ring_buffer__free(ringbuf_); if (resources.using_skboutput) perf_buffer__free(skb_perfbuf_); } void BPFtrace::poll_output(output::Output &out, bool drain) { int ready; bool poll_skboutput = resources.using_skboutput; bool do_poll_ringbuf = true; auto should_retry = [](int ready) { // epoll_wait will set errno to EINTR if an interrupt received, it is // retryable if not caused by SIGINT. ring_buffer__poll does not set // errno, we will keep retrying till SIGINT. return ready < 0 && (errno == 0 || errno == EINTR) && !BPFtrace::exitsig_recv; }; auto should_stop = [this, drain](int ready) { // Stop if either // * an exit signal is received // * epoll_wait has encountered an error (eg signal delivery) // * there's no events left and we've been instructed to drain or // finalization has been requested through exit() builtin. return BPFtrace::exitsig_recv || ready < 0 || (ready == 0 && (drain || finalize_)); }; while (true) { if (poll_skboutput) { ready = perf_buffer__poll(skb_perfbuf_, timeout_ms); if (should_retry(ready)) { if (!do_poll_ringbuf) continue; } if (should_stop(ready)) { poll_skboutput = false; } } // Handle lost events, if any poll_event_loss(out); if (do_poll_ringbuf) { ready = ring_buffer__poll(ringbuf_, timeout_ms); if (should_retry(ready)) { continue; } if (should_stop(ready)) { do_poll_ringbuf = false; } } if (!poll_skboutput && !do_poll_ringbuf) { return; } // If we are tracing a specific pid and it has exited, we should exit // as well b/c otherwise we'd be tracing nothing. if ((procmon_ && !procmon_->is_alive()) || (child_ && !child_->is_alive())) { return; } if (BPFtrace::sigusr1_recv) { BPFtrace::sigusr1_recv = false; for (auto fd : sigusr1_prog_fds_) { if (::bpf_prog_test_run_opts(fd, nullptr)) { LOG(ERROR) << "Failed to run signal probe"; return; } LOG(V1) << "Attaching 'self:signal' probe"; } } } } void BPFtrace::poll_event_loss(output::Output &out) { uint64_t current_value = bytecode_.get_event_loss_counter(*this, max_cpu_id_); if (current_value > event_loss_count_) { out.lost_events(current_value - event_loss_count_); event_loss_count_ = current_value; } else if (current_value < event_loss_count_) { LOG(ERROR) << "Invalid event loss count value: " << current_value << ", last seen: " << event_loss_count_; } } std::optional BPFtrace::get_watchpoint_binary_path() const { if (child_) { // We can ignore all error checking here b/c child.cpp:validate_cmd() has // already done it auto args = util::split_string(cmd_, ' ', /* remove_empty */ true); assert(!args.empty()); return util::resolve_binary_path(args[0]).front(); } else if (pid().has_value()) { return "/proc/" + std::to_string(pid().value_or(0)) + "/exe"; } else { return std::nullopt; } } std::string BPFtrace::get_stack(uint64_t nr_stack_frames, const OpaqueValue &raw_stack, int32_t pid, int32_t probe_id, bool ustack, StackType stack_type, int indent) { std::ostringstream stack; std::string padding(indent, ' '); stack << "\n"; for (uint64_t i = 0; i < nr_stack_frames; ++i) { auto addr = raw_stack.bitcast(i); if (addr == static_cast(-1)) { stack << padding << "" << std::endl; break; } if (stack_type.mode == StackMode::raw) { stack << std::hex << addr << std::endl; continue; } std::vector syms; if (!ustack) syms = resolve_ksym_stack(addr, true, stack_type.mode == StackMode::perf, config_->show_debug_info); else syms = resolve_usym_stack(addr, pid, probe_id, true, stack_type.mode == StackMode::perf, config_->show_debug_info); for (auto const &sym : syms) { switch (stack_type.mode) { case StackMode::bpftrace: stack << padding << sym << std::endl; break; case StackMode::perf: stack << "\t" << std::hex << addr << std::dec << " " << sym << std::endl; break; case StackMode::raw: case StackMode::build_id: LOG(BUG) << "StackMode::raw or build_id should have been processed before " "symbolication."; break; } } } return stack.str(); } std::string BPFtrace::resolve_uid(uint64_t addr) const { std::string file_name = "/etc/passwd"; std::string uid = std::to_string(addr); std::string username; std::ifstream file(file_name); if (file.fail()) { LOG(ERROR) << strerror(errno) << ": " << file_name; return username; } std::string line; bool found = false; while (std::getline(file, line) && !found) { auto fields = util::split_string(line, ':'); if (fields.size() >= 3 && fields[2] == uid) { found = true; username = fields[0]; } } file.close(); return username; } std::chrono::time_point BPFtrace::resolve_timestamp( uint32_t mode, uint64_t nsecs) { std::chrono::time_point t; auto ts_mode = static_cast(mode); if (ts_mode == TimestampMode::boot) { if (!boottime_) { LOG(ERROR) << "Cannot resolve timestamp due to failed boot time calculation"; } else { t += std::chrono::seconds(boottime_->tv_sec); t += std::chrono::duration_cast( std::chrono::nanoseconds(boottime_->tv_nsec)); } } t += std::chrono::duration_cast( std::chrono::nanoseconds(nsecs)); return t; } std::string BPFtrace::format_timestamp( const std::chrono::time_point &time_point, uint32_t strftime_id) { return format_timestamp(time_point, resources.strftime_args[strftime_id], false); } std::string BPFtrace::format_timestamp( const std::chrono::time_point &time_point, const std::string &raw_fmt, bool utc) { static const auto nsec_regex = std::regex("%k"); static const auto usec_regex = std::regex("%f"); static const auto msec_regex = std::regex("%l"); time_t time = std::chrono::system_clock::to_time_t(time_point); auto ns = (time_point - std::chrono::floor(time_point)) .count(); if (!time) { return "(?)"; } // Calculate and localize timestamp struct tm tmp; if (utc) { if (!gmtime_r(&time, &tmp)) { LOG(ERROR) << "gmtime_r: " << strerror(errno); return "(?)"; } } else { if (!localtime_r(&time, &tmp)) { LOG(ERROR) << "localtime_r: " << strerror(errno); return "(?)"; } } // Process strftime() format string extensions std::chrono::nanoseconds ns_rem(ns); char nsecs_buf[10]; snprintf(nsecs_buf, sizeof(nsecs_buf), "%09" PRIu64, ns_rem.count()); char usecs_buf[7]; snprintf( usecs_buf, sizeof(usecs_buf), "%06" PRIu64, std::chrono::duration_cast(ns_rem).count()); char msecs_buf[4]; snprintf( msecs_buf, sizeof(msecs_buf), "%03" PRIu64, std::chrono::duration_cast(ns_rem).count()); auto fmt = std::regex_replace(raw_fmt, usec_regex, usecs_buf); fmt = std::regex_replace(fmt, nsec_regex, nsecs_buf); fmt = std::regex_replace(fmt, msec_regex, msecs_buf); const auto timestr_size = config_->max_strlen; std::string timestr(timestr_size, '\0'); size_t timestr_len = strftime( timestr.data(), timestr_size, fmt.c_str(), &tmp); if (timestr_len == 0) { LOG(ERROR) << "strftime returned 0"; return "(?)"; } // Fit return value to formatted length timestr.resize(timestr_len); return timestr; } std::string BPFtrace::resolve_ksym(uint64_t addr) { auto syms = resolve_ksym_stack(addr, false, false, false); assert(syms.size() == 1); return syms.front(); } std::vector BPFtrace::resolve_ksym_stack(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info) { return ksyms_.resolve(addr, show_offset, perf_mode, show_debug_info); } uint64_t BPFtrace::resolve_kname(const std::string &name) const { uint64_t addr = 0; std::string file_name = "/proc/kallsyms"; std::ifstream file(file_name); if (file.fail()) { LOG(ERROR) << strerror(errno) << ": " << file_name; return addr; } std::string line; while (std::getline(file, line) && addr == 0) { auto tokens = util::split_string(line, ' '); if (name == tokens[2]) { addr = read_address_from_output(line); break; } } file.close(); return addr; } Result BPFtrace::resolve_uname(const std::string &name, const std::string &path) const { auto symbols = util::resolve_symbols(path, { name }, false); if (!symbols) { return symbols.takeError(); } if (symbols->empty()) { return make_error("Could not resolve symbol: " + path + ":" + name); } return symbols->front(); } std::string BPFtrace::resolve_mac_address(const char *mac_addr) const { const size_t SIZE = 18; char addr[SIZE]; const auto *bytes = reinterpret_cast(mac_addr); snprintf(addr, SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", static_cast(bytes[0]), static_cast(bytes[1]), static_cast(bytes[2]), static_cast(bytes[3]), static_cast(bytes[4]), static_cast(bytes[5])); return addr; } std::string BPFtrace::resolve_cgroup_path(uint64_t cgroup_path_id, uint64_t cgroup_id) const { auto paths = util::get_cgroup_paths( cgroup_id, resources.cgroup_path_args[cgroup_path_id]); std::stringstream result; for (auto &pair : paths) { if (pair.second.empty()) continue; result << pair.first << ":" << pair.second << ","; } return result.str().substr(0, result.str().size() - 1); } uint64_t BPFtrace::read_address_from_output(std::string output) { std::string first_word = output.substr(0, output.find(" ")); return std::stoull(first_word, nullptr, 16); } static std::string resolve_inetv4(const char *inet) { char addr_cstr[INET_ADDRSTRLEN]; inet_ntop(AF_INET, inet, addr_cstr, INET_ADDRSTRLEN); return addr_cstr; } static std::string resolve_inetv6(const char *inet) { char addr_cstr[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, inet, addr_cstr, INET6_ADDRSTRLEN); return addr_cstr; } std::string BPFtrace::resolve_inet(int af, const char *inet) const { std::string addrstr; switch (af) { case AF_INET: addrstr = resolve_inetv4(inet); break; case AF_INET6: addrstr = resolve_inetv6(inet); break; } // TODO(mmarchini): handle inet_ntop errors return addrstr; } std::string BPFtrace::resolve_usym(uint64_t addr, int32_t pid, int32_t probe_id) { auto syms = resolve_usym_stack(addr, pid, probe_id, false, false, false); assert(syms.size() == 1); return syms.front(); } std::vector BPFtrace::resolve_usym_stack(uint64_t addr, int32_t pid, int32_t probe_id, bool show_offset, bool perf_mode, bool show_debug_info) { std::string pid_exe; auto res = util::get_pid_exe(pid); if (res) { pid_exe = *res; } else if (probe_id != -1) { // sometimes program cannot be determined from PID, typically when the // process does not exist anymore; in that case, try to get program name // from probe // note: this fails if the probe contains a wildcard, since the probe id // is not generated per match auto probe_full = resolve_probe(probe_id); if (probe_full.find(',') == std::string::npos && !util::has_wildcard(probe_full)) { // only find program name for probes that contain one program name, // to avoid incorrect symbol resolutions size_t start = probe_full.find(':') + 1; size_t end = probe_full.find(':', start); pid_exe = probe_full.substr(start, end - start); } } return usyms_.resolve( addr, pid, pid_exe, show_offset, perf_mode, show_debug_info); } std::string BPFtrace::resolve_probe(uint64_t probe_id) const { assert(probe_id < resources.probe_ids.size()); return resources.probe_ids[probe_id]; } int BPFtrace::resume_tracee(pid_t tracee_pid) { return ::kill(tracee_pid, SIGCONT); } const std::optional &BPFtrace::get_pidns_self_stat() const { static std::optional pidns = []() -> std::optional { struct stat s; if (::stat("/proc/self/ns/pid", &s)) { if (errno == ENOENT) return std::nullopt; throw std::runtime_error( std::string("Failed to stat /proc/self/ns/pid: ") + std::strerror(errno)); } return s; }(); return pidns; } uint64_t find_closest_power_of_2(uint64_t n) { double log_val = log2(n); auto low_end = static_cast(pow(2, floor(log_val))); auto high_end = static_cast(pow(2, ceil(log_val))); if (n - low_end <= high_end - n) { return low_end; } else { return high_end; } } Result BPFtrace::get_buffer_pages(bool per_cpu) const { if (config_->perf_rb_pages) { auto pages = config_->perf_rb_pages; if (!per_cpu) { // We want at least one page per cpu if (pages < static_cast(ncpus_)) { return ncpus_; } return pages; } double res = static_cast(pages) / ncpus_; pages = static_cast(std::ceil(res)); return find_closest_power_of_2(pages); } auto available_mem_kb = util::get_available_mem_kb(); if (!available_mem_kb) { return available_mem_kb; } static uint64_t ceiling = 16544; static uint64_t floor = 256; uint64_t max = std::min(*available_mem_kb, ceiling); uint64_t amount_bytes = std::max(max, floor) * 1024; if (per_cpu) { amount_bytes /= ncpus_; } return find_closest_power_of_2(amount_bytes / sysconf(_SC_PAGE_SIZE)); } Result BPFtrace::get_buffer_pages_per_cpu() const { return get_buffer_pages(true); } Dwarf *BPFtrace::get_dwarf(const std::string &filename) { auto dwarf = dwarves_.find(filename); if (dwarf == dwarves_.end()) { dwarf = dwarves_ .emplace(filename, Dwarf::GetFromBinary(this, filename, debuginfo_path_)) .first; } return dwarf->second.get(); } Dwarf *BPFtrace::get_dwarf(const ast::AttachPoint &attachpoint) { auto probe_type = probetype(attachpoint.provider); if (probe_type != ProbeType::uprobe && probe_type != ProbeType::uretprobe) return nullptr; return get_dwarf(attachpoint.target); } int BPFtrace::create_pcaps() { for (auto arg : resources.skboutput_args_) { auto file = std::get<0>(arg); if (pcap_writers_.contains(file)) { return 0; } auto writer = std::make_unique(); if (!writer->open(file)) return -1; pcap_writers_[file] = std::move(writer); } return 0; } void BPFtrace::close_pcaps() { for (auto &writer : pcap_writers_) { writer.second->close(); } } bool BPFtrace::write_pcaps(uint64_t id, uint64_t ns, const OpaqueValue &pkt) { if (boottime_) { ns = (boottime_->tv_sec * 1e9) + (boottime_->tv_nsec + ns); } auto file = std::get<0>(resources.skboutput_args_.at(id)); auto &writer = pcap_writers_.at(file); return writer->write(ns, pkt.data(), pkt.size()); } void BPFtrace::parse_module_btf(const std::set &modules) { btf_->load_module_btfs(modules); } bool BPFtrace::has_btf_data() const { return btf_->has_data(); } // Retrieves the list of kernel modules for all attachpoints. Will be used to // identify modules whose BTF we need to parse. // Currently, this is useful for fentry/fexit, k(ret)probes, tracepoints, // and raw tracepoints std::set BPFtrace::list_modules(const ast::ASTContext &ctx, ProbeMatcher &probe_matcher) { std::set modules; for (const auto &probe : ctx.root->probes) { for (const auto &ap : probe->attach_points) { auto probe_type = probetype(ap->provider); if (probe_type == ProbeType::fentry || probe_type == ProbeType::fexit || probe_type == ProbeType::rawtracepoint || probe_type == ProbeType::kprobe || probe_type == ProbeType::kretprobe) { // Force module name into listing bool clear_target; if (ap->target.empty()) { ap->target = "*"; clear_target = true; } else { clear_target = false; } if (util::has_wildcard(ap->target)) { for (std::string match : probe_matcher.get_matches_for_ap(*ap)) { auto module = util::erase_prefix(match); modules.insert(module); } } else { modules.insert(ap->target); } if (clear_target) ap->target.clear(); } else if (probe_type == ProbeType::tracepoint) { // For now, we support this for a single target only since tracepoints // need dumping of C definitions BTF and that is not available for // multiple modules at once. modules.insert(ap->target); } } } return modules; } } // namespace bpftrace bpftrace-0.27.1/src/bpftrace.h000066400000000000000000000211071526721631600161270ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include "ast/ast.h" #include "ast/pass_manager.h" #include "ast/passes/ap_probe_expansion.h" #include "ast/passes/clang_parser.h" #include "attached_probe.h" #include "bpfbytecode.h" #include "bpffeature.h" #include "bpfprogram.h" #include "btf.h" #include "config.h" #include "dwarf_parser.h" #include "functions.h" #include "ksyms.h" #include "output/output.h" #include "pcap_writer.h" #include "probe_matcher.h" #include "required_resources.h" #include "struct.h" #include "symbols/kernel.h" #include "types.h" #include "usyms.h" #include "util/cpus.h" #include "util/proc.h" #include "util/result.h" namespace bpftrace { using util::Symbol; const int timeout_ms = 100; enum class DebugStage; // globals extern std::set bt_debug; extern bool bt_quiet; extern bool bt_verbose; extern bool dry_run; enum class DebugStage { Parse, Ast, Codegen, CodegenOpt, Disassemble, Libbpf, Verifier, Types, }; const std::unordered_map debug_stages = { // clang-format off { "ast", DebugStage::Ast }, { "codegen", DebugStage::Codegen }, { "codegen-opt", DebugStage::CodegenOpt }, #ifndef NDEBUG { "dis", DebugStage::Disassemble }, { "parse", DebugStage::Parse }, #endif { "libbpf", DebugStage::Libbpf }, { "verifier", DebugStage::Verifier }, { "types", DebugStage::Types }, // clang-format on }; class WildcardException : public std::exception { public: WildcardException(std::string msg) : msg_(std::move(msg)) { } const char *what() const noexcept override { return msg_.c_str(); } private: std::string msg_; }; class BPFtrace : public ast::State<"bpftrace"> { public: BPFtrace(BPFnofeature no_feature = BPFnofeature(), std::unique_ptr config = std::make_unique()) : btf_(std::make_unique(this)), feature_(std::make_unique(no_feature, *btf_)), ncpus_(util::get_possible_cpus().size()), max_cpu_id_(util::get_max_cpu_id()), config_(std::move(config)), ksyms_(*config_), usyms_(*config_) { } ~BPFtrace() override; virtual int add_probe(const ast::AttachPoint &ap, const ast::Probe &p, ast::ExpansionType expansion, std::set expanded_funcs); Probe generateWatchpointSetupProbe(const ast::AttachPoint &ap, const ast::Probe &probe); int num_probes() const; int prerun() const; int run(output::Output &out, const ast::CDefinitions &c_definitions, BpfBytecode bytecode); virtual Result> attach_probe( Probe &probe, const BpfBytecode &bytecode); int run_iter(); std::string get_stack(uint64_t nr_stack_frames, const OpaqueValue &raw_stack, int32_t pid, int32_t probe_id, bool ustack, StackType stack_type, int indent = 0); std::string resolve_ksym(uint64_t addr); std::string resolve_usym(uint64_t addr, int32_t pid, int32_t probe_id); std::string resolve_inet(int af, const char *inet) const; std::string resolve_uid(uint64_t addr) const; std::chrono::time_point resolve_timestamp( uint32_t mode, uint64_t nsecs); std::string format_timestamp( const std::chrono::time_point &time_point, uint32_t strftime_id); std::string format_timestamp( const std::chrono::time_point &time_point, const std::string &raw_fmt, bool utc); time_t time_since_epoch(uint32_t mode, uint64_t timestamp_ns, uint64_t *nsecs); uint64_t resolve_kname(const std::string &name) const; virtual Result resolve_uname(const std::string &name, const std::string &path) const; std::string resolve_mac_address(const char *mac_addr) const; std::string resolve_cgroup_path(uint64_t cgroup_path_id, uint64_t cgroup_id) const; std::string resolve_probe(uint64_t probe_id) const; void add_param(const std::string ¶m); std::string get_param(size_t index) const; size_t num_params() const; void request_finalize(); std::optional get_watchpoint_binary_path() const; virtual int resume_tracee(pid_t tracee_pid); virtual const std::optional &get_pidns_self_stat() const; // This gets the number of perf or ring buffer pages in total across all cpus // by first checking if the user set this manually with a config value // (`perf_rb_pages`), then falling back to a dynamic default based on the // amount of available system memory virtual Result get_buffer_pages(bool per_cpu = false) const; Result get_buffer_pages_per_cpu() const; bool write_pcaps(uint64_t id, uint64_t ns, const OpaqueValue &pkt); void parse_module_btf(const std::set &modules); bool has_btf_data() const; Dwarf *get_dwarf(const std::string &filename); Dwarf *get_dwarf(const ast::AttachPoint &attachpoint); std::set list_modules(const ast::ASTContext &ctx, ProbeMatcher &probe_matcher); std::string cmd_; // Set by the async `exit` handler. bool finalize_ = false; int exit_code = 0; // Global variables checking if an exit/usr1 signal was received. static volatile sig_atomic_t exitsig_recv; static volatile sig_atomic_t sigusr1_recv; RequiredResources resources; BpfBytecode bytecode_; StructManager structs; FunctionRegistry functions; // For each helper, list of all generated call sites. std::map> helper_use_loc_; symbols::KConfig kconfig; std::vector> attached_probes_; std::vector sigusr1_prog_fds_; unsigned int join_argnum_ = 16; unsigned int join_argsize_ = 1024; std::unique_ptr btf_; std::unique_ptr feature_; bool safe_mode_ = true; bool has_usdt_ = false; bool usdt_file_activation_ = false; int warning_level_ = 1; std::optional boottime_; std::optional delta_taitime_; bool need_recursion_check_ = false; std::unordered_set btf_set_; std::unique_ptr child_; std::unique_ptr procmon_; std::vector dwarf_pids_; std::optional pid() const { if (procmon_) { return procmon_->pid(); } return std::nullopt; } int ncpus_; int max_cpu_id_; std::unique_ptr config_; bool run_tests_ = false; bool run_benchmarks_ = false; std::string probe_filter_; std::string debuginfo_path_; private: Ksyms ksyms_; Usyms usyms_; std::vector params_; std::map> pcap_writers_; int create_pcaps(); void close_pcaps(); int setup_output(void *ctx); int setup_skboutput_perf_buffer(void *ctx); void setup_ringbuf(void *ctx); std::vector resolve_ksym_stack(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info); std::vector resolve_usym_stack(uint64_t addr, int32_t pid, int32_t probe_id, bool show_offset, bool perf_mode, bool show_debug_info); void teardown_output(); void poll_output(output::Output &out, bool drain = false); void poll_event_loss(output::Output &out); static uint64_t read_address_from_output(std::string output); struct bcc_symbol_option &get_symbol_opts(); Probe generate_probe(const ast::AttachPoint &ap, const ast::Probe &p, ast::ExpansionType expansion, std::set expanded_funcs); bool has_iter_ = false; struct ring_buffer *ringbuf_ = nullptr; struct perf_buffer *skb_perfbuf_ = nullptr; uint64_t event_loss_count_ = 0; std::unordered_map> dwarves_; }; } // namespace bpftrace bpftrace-0.27.1/src/btf.cpp000066400000000000000000001163561526721631600154620ustar00rootroot00000000000000#include "scopeguard.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #include #pragma GCC diagnostic pop #include #include #include "arch/arch.h" #include "ast/context.h" #include "ast/pass_manager.h" #include "ast/passes/args_resolver.h" #include "ast/passes/attachpoint_passes.h" #include "bpftrace.h" #include "btf.h" #include "log.h" #include "probe_matcher.h" #include "symbols/kernel.h" #include "tracefs/tracefs.h" #include "types.h" #include "util/strings.h" using namespace std::literals::string_view_literals; namespace bpftrace { static __u32 type_cnt(const struct btf *btf) { const auto count = btf__type_cnt(btf); return count ? count - 1 : 0; } __u32 BTF::start_id(const struct btf *btf) const { return btf == vmlinux_btf ? 1 : vmlinux_btf_size + 1; } BTF::BTF() : BTF(nullptr) { } BTF::BTF(BPFtrace *bpftrace) : bpftrace_(bpftrace) { } BTF::~BTF() { for (auto &btf_obj : btf_objects) btf__free(btf_obj.btf); } void BTF::load_vmlinux_btf() { if (state != INIT) { // Don't attempt to reload vmlinux even if it fails below return; } state = ERROR; // Try to get BTF file from BPFTRACE_BTF env char *path = std::getenv("BPFTRACE_BTF"); if (path) { btf_objects.push_back(BTFObj{ .btf = btf__parse_raw(path), .name = "" }); vmlinux_btf = btf_objects.back().btf; if (!vmlinux_btf) { LOG(WARNING) << "BTF: failed to parse BTF from " << path; return; } } else { vmlinux_btf = btf__load_vmlinux_btf(); if (libbpf_get_error(vmlinux_btf)) { LOG(V1) << "BTF: failed to find BTF data for vmlinux: " << strerror(errno); return; } btf_objects.push_back(BTFObj{ .btf = vmlinux_btf, .name = "vmlinux" }); } if (btf_objects.empty()) { LOG(V1) << "BTF: failed to find BTF data"; return; } vmlinux_btf_size = type_cnt(vmlinux_btf); state = VMLINUX_LOADED; } bool BTF::has_module_btf() { if (has_module_btf_.has_value()) return *has_module_btf_; char name[64]; struct bpf_btf_info info = {}; info.name = reinterpret_cast(name); info.name_len = sizeof(name); // The vmlinux's BTF ID is always 1 __u32 id = 1, info_len = sizeof(info); int err = 0, fd = -1; err = bpf_btf_get_next_id(id, &id); if (err) goto not_support; fd = bpf_btf_get_fd_by_id(id); if (fd < 0) goto not_support; err = bpf_obj_get_info_by_fd(fd, &info, &info_len); close(fd); if (err) goto not_support; has_module_btf_ = true; return *has_module_btf_; not_support: has_module_btf_ = false; return *has_module_btf_; } void BTF::load_module_btfs(const std::set &modules) { load_vmlinux_btf(); if ((bpftrace_ && !has_module_btf()) || state != VMLINUX_LOADED) return; // Note that we cannot parse BTFs from /sys/kernel/btf/ as we need BTF object // IDs, so the only way is to iterate through all loaded BTF objects. The BTF // ID of vmlinux is always 1 so we skip it to traverse only modules BTF. __u32 id = 1; while (true) { if (bpf_btf_get_next_id(id, &id)) { if (errno != ENOENT) LOG(V1) << "BTF: failed to iterate modules BTF objects: " << strerror(errno); break; } // Get BTF object FD int fd = bpf_btf_get_fd_by_id(id); if (fd < 0) { LOG(V1) << "BTF: failed to get FD for object with id " << id; continue; } // Get BTF object info - needed to determine if this is a kernel module BTF char name[64] = {}; struct bpf_btf_info info = {}; info.name = reinterpret_cast(name); info.name_len = sizeof(name); uint32_t info_len = sizeof(info); auto err = bpf_obj_get_info_by_fd(fd, &info, &info_len); close(fd); // close the FD not to leave too many files open if (err) { LOG(V1) << "BTF: failed to get info for object with id " << id; continue; } if (!info.kernel_btf) continue; if (modules.contains(name)) { btf_objects.push_back( BTFObj{ .btf = btf__load_from_kernel_by_id_split(id, vmlinux_btf), .name = name }); } } state = VMLINUX_AND_MODULES_LOADED; } static void dump_printf(void *ctx, const char *fmt, va_list args) { auto *ret = static_cast(ctx); char *str; if (vasprintf(&str, fmt, args) < 0) return; *ret << str; free(str); } static struct btf_dump *dump_new(const struct btf *btf, btf_dump_printf_fn_t dump_printf, std::stringstream *ctx) { return btf_dump__new(btf, dump_printf, static_cast(ctx), nullptr); } static const char *btf_str(const struct btf *btf, __u32 off) { if (!off) return "(anon)"; return btf__name_by_offset(btf, off) ?: "(invalid)"; } static std::string full_type_str(const struct btf *btf, const struct btf_type *type) { const char *str = btf_str(btf, type->name_off); if (BTF_INFO_KIND(type->info) == BTF_KIND_STRUCT) return std::string(STRUCT_PREFIX) + str; if (BTF_INFO_KIND(type->info) == BTF_KIND_UNION) return std::string(UNION_PREFIX) + str; if (BTF_INFO_KIND(type->info) == BTF_KIND_ENUM) return std::string(ENUM_PREFIX) + str; return str; } static std::string_view btf_type_str(std::string_view type) { if (type.starts_with(STRUCT_PREFIX)) return type.substr(STRUCT_PREFIX.length()); if (type.starts_with(UNION_PREFIX)) return type.substr(UNION_PREFIX.length()); if (type.starts_with(ENUM_PREFIX)) return type.substr(ENUM_PREFIX.length()); return type; } std::string BTF::dump_defs_from_btf( const struct btf *btf, std::unordered_set &types) const { std::stringstream ret; auto *dump = dump_new(btf, dump_printf, &ret); if (auto err = libbpf_get_error(dump)) { char err_buf[256] = {}; libbpf_strerror(err, err_buf, sizeof(err_buf)); LOG(ERROR) << "BTF: failed to initialize dump (" << err_buf << ")"; return {}; } SCOPE_EXIT { btf_dump__free(dump); }; // note that we're always iterating from 1 here as we need to go through the // vmlinux BTF entries, too (even for kernel module BTFs) bool all = types.empty(); __u32 max = type_cnt(btf); for (__u32 id = 1; id <= max && (all || !types.empty()); id++) { const auto *t = btf__type_by_id(btf, id); if (!t) continue; // Allow users to reference enum values by name to pull in entire enum defs if (btf_is_enum(t)) { const auto *p = btf_enum(t); for (__u16 e = 0, vlen = btf_vlen(t); e < vlen; ++e, ++p) { if (all || types.erase(btf_str(btf, p->name_off))) { btf_dump__dump_type(dump, id); break; } } } if (all || types.erase(full_type_str(btf, t))) { btf_dump__dump_type(dump, id); } } return ret.str(); } std::string BTF::c_def(const std::unordered_set &set) { if (!has_data()) return {}; // Definition dumping from multiple modules would require to resolve type // conflicts, so we allow dumping from a single module or from vmlinux only. std::unordered_set to_dump(set); if (btf_objects.size() == 2) { auto *mod_btf = btf_objects[0].btf == vmlinux_btf ? btf_objects[1].btf : btf_objects[0].btf; return dump_defs_from_btf(mod_btf, to_dump); } return dump_defs_from_btf(vmlinux_btf, to_dump); } std::string BTF::type_of(std::string_view name, std::string_view field) { if (!has_data()) return {}; auto btf_name = btf_type_str(name); auto type_id = find_id(btf_name); if (!type_id.btf) return {}; return type_of(type_id, field); } std::string BTF::type_of(const BTFId &type_id, std::string_view field) { if (!has_data()) return {}; const struct btf_type *type = btf__type_by_id(type_id.btf, type_id.id); if (!type || (BTF_INFO_KIND(type->info) != BTF_KIND_STRUCT && BTF_INFO_KIND(type->info) != BTF_KIND_UNION)) return {}; // We need to walk through oaa the struct/union members // and try to find the requested field name. // // More info on struct/union members: // https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-kind-union const struct btf_member *m = btf_members(type); for (unsigned int i = 0; i < BTF_INFO_VLEN(type->info); i++) { std::string m_name = btf__name_by_offset(type_id.btf, m[i].name_off); // anonymous struct/union if (m_name.empty()) { std::string type_name = type_of( BTFId{ .btf = type_id.btf, .id = m[i].type }, field); if (!type_name.empty()) return type_name; } if (m_name != field) continue; const struct btf_type *f = btf__type_by_id(type_id.btf, m[i].type); if (!f) break; // Get rid of all the pointers and qualifiers on the way to the actual type. while (BTF_INFO_KIND(f->info) == BTF_KIND_PTR || BTF_INFO_KIND(f->info) == BTF_KIND_CONST || BTF_INFO_KIND(f->info) == BTF_KIND_VOLATILE || BTF_INFO_KIND(f->info) == BTF_KIND_RESTRICT) { f = btf__type_by_id(type_id.btf, f->type); if (!f) return {}; } return full_type_str(type_id.btf, f); } return {}; } static bool btf_type_is_modifier(const struct btf_type *t) { // Some of them is not strictly a C modifier // but they are grouped into the same bucket // for BTF concern: // A type (t) that refers to another // type through t->type AND its size cannot // be determined without following the t->type. // ptr does not fall into this bucket // because its size is always sizeof(void *). switch (BTF_INFO_KIND(t->info)) { case BTF_KIND_TYPEDEF: case BTF_KIND_VOLATILE: case BTF_KIND_CONST: case BTF_KIND_RESTRICT: return true; default: return false; } } __u32 BTF::get_type_tags(std::unordered_set &tags, const BTFId &btf_id) const { __u32 id = btf_id.id; const struct btf_type *t = btf__type_by_id(btf_id.btf, btf_id.id); while (t && btf_is_type_tag(t)) { tags.insert(btf_str(btf_id.btf, t->name_off)); id = t->type; t = btf__type_by_id(btf_id.btf, t->type); } return id; } static bool is_anon_btf_typename(const std::string &name) { return name.empty() || name == "(anon)"; } BTF::BTFId BTF::parse_anon_btf_name(const std::string &fullname) { unsigned int btf_id; // First, find BTF_ANON_STRUCT_PREFIX auto prefix_pos = fullname.find(BTF_ANON_STRUCT_PREFIX); if (prefix_pos == std::string::npos) return BTFId{ .btf = nullptr }; // After BTF_ANON_STRUCT_PREFIX, should have _ auto tail_pos = prefix_pos + BTF_ANON_STRUCT_PREFIX.length(); auto underscore_pos = fullname.find("_", tail_pos); if (underscore_pos == std::string::npos) return BTFId{ .btf = nullptr }; std::string idstr = fullname.substr(tail_pos, underscore_pos - tail_pos); std::string btf_obj_name = fullname.substr(underscore_pos + 1); try { btf_id = std::stoul(idstr); } catch (const std::invalid_argument &e) { return BTFId{ .btf = nullptr }; } for (const auto &btf_obj : btf_objects) { if (btf_obj.name == btf_obj_name) { struct btf *btf = btf__type_by_id(btf_obj.btf, btf_id) ? btf_obj.btf : nullptr; return BTFId{ .btf = btf, .id = btf_id }; } } return BTFId{ .btf = nullptr }; } std::string BTF::create_anon_btf_name(BTFId &btf_id) { for (const auto &btf_obj : btf_objects) { if (btf_obj.btf == btf_id.btf) { return std::string(BTF_ANON_STRUCT_PREFIX) + std::to_string(btf_id.id) + "_" + btf_obj.name; } } return ""; } SizedType BTF::get_stype(const BTFId &btf_id, bool resolve_structs) { const struct btf_type *t; BTFId id; id = btf_id; while ((t = btf__type_by_id(id.btf, id.id))) { if (!btf_type_is_modifier(t)) break; id.id = t->type; } if (!t) { // BTF type id 0 represents void if (id.id == 0) { return CreateVoid(); } return CreateNone(); } auto stype = CreateNone(); if (btf_is_int(t)) { auto encoding = btf_int_encoding(t); if (encoding & BTF_INT_BOOL) { return CreateBool(); } stype = CreateInteger(btf_int_bits(t), encoding & BTF_INT_SIGNED); } else if (btf_is_enum(t)) { std::string enum_name = btf_str(btf_id.btf, t->name_off); if (!enum_name.empty()) { stype = CreateEnum(t->size * 8, enum_name); // Extract enum values from BTF for symbolication auto [it, inserted] = enum_defs_.try_emplace(enum_name); if (inserted) { const auto *p = btf_enum(t); for (__u16 e = 0, vlen = btf_vlen(t); e < vlen; ++e, ++p) { it->second[p->val] = btf_str(btf_id.btf, p->name_off); } } } else { stype = CreateInteger(t->size * 8, false); } } else if (btf_is_composite(t)) { bool is_anon = false; std::string recprefix(btf_is_struct(t) ? STRUCT_PREFIX : UNION_PREFIX); std::string rname = btf_str(btf_id.btf, t->name_off); if (is_anon_btf_typename(rname)) { is_anon = true; rname = create_anon_btf_name(id); if (rname.empty()) return CreateNone(); } auto name = recprefix + rname; auto record = bpftrace_->structs.LookupOrAdd(name, t->size).lock(); stype = CreateCStruct(name, record); if (is_anon) stype.SetAnon(); if (resolve_structs) resolve_fields(id, std::move(record), 0); } else if (btf_is_ptr(t)) { const BTFId pointee_btf_id = { .btf = btf_id.btf, .id = t->type }; std::unordered_set tags; auto id = get_type_tags(tags, pointee_btf_id); stype = CreatePointer( get_stype(BTFId{ .btf = btf_id.btf, .id = id }, false)); stype.SetBtfTypeTags(std::move(tags)); } else if (btf_is_array(t)) { auto *array = btf_array(t); const auto &elem_type = get_stype( BTFId{ .btf = btf_id.btf, .id = array->type }); // Auto convert char arrays to strings. // This is the least worse option since users have come to expect // strings when they call `print`, `printf` or do string literal // comparison to this BTF type but note that we don't add 1 // to the length to ensure it's well formed because // string.GetSize() will return len + 1, which is a mismatch with the actual // type. So this is making the assumption that the string // IS well formed (NULL terminated), which is not guaranteed. // A string that is missing the NULL terminator at the end // will appear as a truncated string, e.g. `...` as a trailing suffix. // If this conversion is incorrect, because it's not an actual string, users // have the option to cast all strings to int8 arrays, e.g. // `(int8[])"mystring"`. if (elem_type.IsIntTy() && elem_type.GetSize() == 1) { stype = CreateString(array->nelems); } else { stype = CreateArray(array->nelems, elem_type); } } else if (btf_is_void(t) || btf_is_func_proto(t)) { // We treat func_proto as void because there are no callable functions in // bpftrace that can be assigned to scratch variables or maps, however // bpftrace does support pointers to functions. Builtins like `ksym` can be // used on these function pointers. return CreateVoid(); } return stype; } Result> BTF::resolve_args(std::string_view func, bool ret, bool skip_first_arg) { if (!has_data()) { return make_error(func, "BTF data not available"); } auto func_id = find_id(func, BTF_KIND_FUNC); if (!func_id.btf) { return make_error( func, "BTF data for the function not found"); } const struct btf_type *t = btf__type_by_id(func_id.btf, func_id.id); t = btf__type_by_id(func_id.btf, t->type); if (!t || !btf_is_func_proto(t)) { return make_error(func, "not a function"); } const struct btf_param *p = btf_params(t); __u16 vlen = btf_vlen(t); if (vlen > arch::Host::arguments().size()) { return make_error( func, "functions with more than " + std::to_string(arch::Host::arguments().size()) + " parameters are not supported."); } int arg_idx = 0; auto args = std::make_shared(0, false); for (__u16 j = 0; j < vlen; j++, p++) { if (j == 0 && skip_first_arg) { continue; } const char *str = btf_str(func_id.btf, p->name_off); if (!str) { return make_error(func, "failed to resolve arguments"); } SizedType stype = get_stype(BTFId{ .btf = func_id.btf, .id = p->type }); stype.funcarg_idx = arg_idx; stype.is_funcarg = true; args->AddField(str, stype, args->size); // fentry args are stored in a u64 array. // Note that it's ok to represent them by a struct as we will use GEP with // funcarg_idx to access them in codegen. auto type_size = btf__resolve_size(func_id.btf, p->type); args->size += type_size; arg_idx += std::ceil(static_cast(type_size) / static_cast(8)); } if (ret) { SizedType stype = get_stype(BTFId{ .btf = func_id.btf, .id = t->type }); stype.funcarg_idx = arg_idx; stype.is_funcarg = true; args->AddField(RETVAL_FIELD_NAME, stype, args->size); // fentry args (incl. retval) are stored in a u64 array args->size += btf__resolve_size(func_id.btf, t->type); } return args; } Result> BTF::resolve_raw_tracepoint_args( std::string_view func) { for (const auto &prefix : RT_BTF_PREFIXES) { auto args = resolve_args(std::string(prefix) + std::string(func), false, true); if (args) { return args; } } return make_error( func, "BTF data for the tracepoint not found"); } std::string BTF::get_all_traceable_funcs_from_btf( const symbols::KernelInfo &kernel_func_info, const BTFObj &btf_obj) const { std::string funcs; auto id = start_id(btf_obj.btf), max = type_cnt(btf_obj.btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf_obj.btf, id); if (!t) continue; if (!btf_is_func(t)) continue; std::string func_name = btf__name_by_offset(btf_obj.btf, t->name_off); t = btf__type_by_id(btf_obj.btf, t->type); if (!t || !btf_is_func_proto(t)) { /* bad.. */ LOG(ERROR) << func_name << " function does not have FUNC_PROTO record"; break; } // Make sure that the kernel considers this function traceable. if (!kernel_func_info.is_traceable(std::string(func_name), btf_obj.name)) { continue; } if (btf_vlen(t) > arch::Host::arguments().size()) continue; funcs += btf_obj.name + ":" + func_name + "\n"; } return funcs; } std::unique_ptr BTF::get_all_traceable_funcs( const symbols::KernelInfo &kernel_func_info) const { if (!all_funcs_.empty()) { return std::make_unique(all_funcs_); } for (const auto &btf_obj : btf_objects) all_funcs_ += get_all_traceable_funcs_from_btf(kernel_func_info, btf_obj); return std::make_unique(all_funcs_); } std::string BTF::get_all_raw_tracepoints_from_btf(const BTFObj &btf_obj) const { std::set func_set; auto id = start_id(btf_obj.btf), max = type_cnt(btf_obj.btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf_obj.btf, id); if (!t) continue; if (!btf_is_func(t)) continue; std::string_view func_name = btf__name_by_offset(btf_obj.btf, t->name_off); t = btf__type_by_id(btf_obj.btf, t->type); if (!t || !btf_is_func_proto(t)) { /* bad.. */ LOG(ERROR) << func_name << " function does not have FUNC_PROTO record"; break; } if (btf_vlen(t) > arch::Host::arguments().size()) continue; bool found = false; for (const auto &prefix : RT_BTF_PREFIXES) { if (func_name.starts_with(prefix)) { found = true; func_name.remove_prefix(prefix.length()); break; } } if (!found) continue; // TODO: remove the std::string on C++26 func_set.insert(btf_obj.name + ':' + std::string(func_name) + '\n'); } std::string funcs; for (const auto &func : func_set) { funcs += func; } return funcs; } std::unique_ptr BTF::get_all_raw_tracepoints() { if (!all_rawtracepoints_.empty()) { return std::make_unique(all_rawtracepoints_); } for (const auto &btf_obj : btf_objects) all_rawtracepoints_ += get_all_raw_tracepoints_from_btf(btf_obj); return std::make_unique(all_rawtracepoints_); } FuncParamLists BTF::get_params_from_btf( const BTFObj &btf_obj, const std::set &funcs) const { std::stringstream type; auto *dump = dump_new(btf_obj.btf, dump_printf, &type); if (auto err = libbpf_get_error(dump)) { char err_buf[256] = {}; libbpf_strerror(err, err_buf, sizeof(err_buf)); LOG(ERROR) << "BTF: failed to initialize dump (" << err_buf << ")"; return {}; } SCOPE_EXIT { btf_dump__free(dump); }; FuncParamLists params; auto id = start_id(btf_obj.btf), max = type_cnt(btf_obj.btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf_obj.btf, id); if (!t) continue; if (!btf_is_func(t)) continue; const auto func_name = btf_obj.name + ":" + btf__name_by_offset(btf_obj.btf, t->name_off); if (!funcs.contains(func_name)) continue; t = btf__type_by_id(btf_obj.btf, t->type); if (!t) continue; DECLARE_LIBBPF_OPTS(btf_dump_emit_type_decl_opts, decl_opts); decl_opts.field_name = ""; const auto *p = btf_params(t); for (__u16 j = 0, len = btf_vlen(t); j < len; j++, p++) { const char *arg_name = btf__name_by_offset(btf_obj.btf, p->name_off); // set by dump_printf callback type.str(""); if (btf_dump__emit_type_decl(dump, p->type, &decl_opts)) { LOG(ERROR) << "failed to dump argument: " << arg_name; break; } params[func_name].push_back(type.str() + " " + arg_name); } if (!t->type) continue; // set by dump_printf callback type.str(""); if (btf_dump__emit_type_decl(dump, t->type, &decl_opts)) { LOG(ERROR) << "failed to dump return type for: " << func_name; break; } params[func_name].push_back(type.str() + " retval"); } if (id != (max + 1)) LOG(ERROR) << "BTF data inconsistency " << id << "," << max; return params; } FuncParamLists BTF::get_kprobes_params_from_btf( const BTFObj &btf_obj, const std::set &funcs, bool is_kretprobe) const { std::stringstream type; auto *dump = dump_new(btf_obj.btf, dump_printf, &type); if (auto err = libbpf_get_error(dump)) { char err_buf[256] = {}; libbpf_strerror(err, err_buf, sizeof(err_buf)); LOG(V1) << "BTF: failed to initialize dump (" << err_buf << ")"; return {}; } SCOPE_EXIT { btf_dump__free(dump); }; FuncParamLists params; auto id = start_id(btf_obj.btf), max = type_cnt(btf_obj.btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf_obj.btf, id); if (!t) continue; if (!btf_is_func(t)) continue; std::string func_name; const std::string pure_func_name = btf__name_by_offset(btf_obj.btf, t->name_off); const std::string obj_func_name = btf_obj.name + ":" + pure_func_name; // First match the module prefix name, then match the pure function name. // For example, first match "kprobe:vmlinux:do_sys*", then "kprobe:do_sys*". // The same goes for other modules, such as "kvm". if (funcs.contains(obj_func_name)) func_name = obj_func_name; else if (funcs.contains(pure_func_name)) func_name = pure_func_name; else continue; t = btf__type_by_id(btf_obj.btf, t->type); if (!t) continue; DECLARE_LIBBPF_OPTS(btf_dump_emit_type_decl_opts, decl_opts); decl_opts.field_name = ""; if (!is_kretprobe) { const auto *p = btf_params(t); for (__u16 j = 0, argN = 0, len = btf_vlen(t); j < len; j++, p++) { const std::string arg_name = "arg" + std::to_string(argN); // set by dump_printf callback type.str(""); if (btf_dump__emit_type_decl(dump, p->type, &decl_opts)) { LOG(V1) << "failed to dump argument: " << arg_name; break; } // Note that floating point arguments are typically passed in special // registers which don’t count as argN arguments. e.g. on x86_64 the // first 6 non-floating point arguments are passed in registers and // all following arguments are passed on the stack const auto *pt = btf__type_by_id(btf_obj.btf, p->type); if (pt && BTF_INFO_KIND(pt->info) == BTF_KIND_FLOAT) continue; params[func_name].push_back(type.str() + " " + arg_name); argN++; } } else { if (!t->type) { params[func_name].emplace_back("void"); continue; } // set by dump_printf callback type.str(""); if (btf_dump__emit_type_decl(dump, t->type, &decl_opts)) { LOG(ERROR) << "failed to dump return type for: " << func_name; break; } params[func_name].push_back(type.str() + " retval"); } } if (id != (max + 1)) LOG(BUG) << "BTF data inconsistency " << id << "," << max; return params; } FuncParamLists BTF::get_raw_tracepoints_params_from_btf( const BTFObj &btf_obj, const std::set &rawtracepoints) const { std::stringstream type; auto *dump = dump_new(btf_obj.btf, dump_printf, &type); if (auto err = libbpf_get_error(dump)) { char err_buf[256] = {}; libbpf_strerror(err, err_buf, sizeof(err_buf)); LOG(ERROR) << "BTF: failed to initialize dump (" << err_buf << ")"; return {}; } SCOPE_EXIT { btf_dump__free(dump); }; FuncParamLists params; auto id = start_id(btf_obj.btf), max = type_cnt(btf_obj.btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf_obj.btf, id); if (!t) continue; if (!btf_is_func(t)) continue; std::string_view tp_name = btf__name_by_offset(btf_obj.btf, t->name_off); for (const auto &prefix : RT_BTF_PREFIXES) { if (tp_name.starts_with(prefix)) tp_name.remove_prefix(prefix.length()); } // Checking multiple prefixes so make sure we don't add duplicates // TODO: remove the std::string ctor on C++26 auto mod_tp_name = btf_obj.name + ":" + std::string(tp_name); if (!rawtracepoints.contains(mod_tp_name) || params.contains(mod_tp_name)) continue; t = btf__type_by_id(btf_obj.btf, t->type); if (!t) continue; DECLARE_LIBBPF_OPTS(btf_dump_emit_type_decl_opts, decl_opts); decl_opts.field_name = ""; const struct btf_param *p = btf_params(t); for (__u16 j = 0, len = btf_vlen(t); j < len; j++, p++) { if (j == 0) { // The first param is void *, which is not really part of the // rawtracepoint params continue; } const char *arg_name = btf__name_by_offset(btf_obj.btf, p->name_off); // set by dump_printf callback type.str(""); if (btf_dump__emit_type_decl(dump, p->type, &decl_opts)) { LOG(ERROR) << "failed to dump argument: " << arg_name; break; } params[mod_tp_name].push_back(type.str() + " " + arg_name); } } if (id != (max + 1)) LOG(ERROR) << "BTF data inconsistency " << id << "," << max; return params; } FuncParamLists BTF::get_params_impl( const std::set &funcs, std::function &funcs)> get_param_btf_cb) const { FuncParamLists params; auto all_resolved = [¶ms](const std::string &f) { return params.contains(f); }; for (const auto &btf_obj : btf_objects) { if (std::ranges::all_of(funcs, all_resolved)) break; auto mod_params = get_param_btf_cb(btf_obj, funcs); params.insert(mod_params.begin(), mod_params.end()); } return params; } FuncParamLists BTF::get_params(const std::set &funcs) const { return get_params_impl( funcs, [this](const BTFObj &btf_obj, const std::set &funcs) { return get_params_from_btf(btf_obj, funcs); }); } FuncParamLists BTF::get_kprobes_params(const std::set &funcs) const { return get_params_impl( funcs, [this](const BTFObj &btf_obj, const std::set &funcs) { return get_kprobes_params_from_btf(btf_obj, funcs, false); }); } FuncParamLists BTF::get_kretprobes_params( const std::set &funcs) const { return get_params_impl( funcs, [this](const BTFObj &btf_obj, const std::set &funcs) { return get_kprobes_params_from_btf(btf_obj, funcs, true); }); } FuncParamLists BTF::get_rawtracepoint_params( const std::set &rawtracepoints) const { return get_params_impl( rawtracepoints, [this](const BTFObj &btf_obj, const std::set &funcs) { return get_raw_tracepoints_params_from_btf(btf_obj, funcs); }); } std::set BTF::get_all_structs_from_btf(const struct btf *btf) const { std::set struct_set; std::stringstream types; auto *dump = dump_new(btf, dump_printf, &types); if (auto err = libbpf_get_error(dump)) { char err_buf[256] = { 0 }; libbpf_strerror(err, err_buf, sizeof(err_buf)); LOG(ERROR) << "BTF: failed to initialize dump (" << err_buf << ")"; return {}; } SCOPE_EXIT { btf_dump__free(dump); }; auto id = start_id(btf), max = type_cnt(btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf, id); if (!t || !(btf_is_struct(t) || btf_is_union(t) || btf_is_enum(t))) continue; const std::string name = full_type_str(btf, t); if (name.find("(anon)") != std::string::npos) continue; if (bt_verbose) btf_dump__dump_type(dump, id); else struct_set.insert(std::move(name)); } if (id != (max + 1)) LOG(ERROR) << " BTF data inconsistency " << id << "," << max; if (bt_verbose) { // BTF dump contains definitions of all types in a single string, here we // split it std::istringstream type_stream(types.str()); std::string line, type; bool in_def = false; while (std::getline(type_stream, line)) { if (in_def) { type += line + "\n"; if (line == "};") { // end of type definition struct_set.insert(type); type.clear(); in_def = false; } } else if ((line.starts_with(STRUCT_PREFIX) || line.starts_with(UNION_PREFIX) || line.starts_with(ENUM_PREFIX)) && line.back() == '{') { // start of type definition type += line + "\n"; in_def = true; } } } return struct_set; } std::map> BTF::get_all_structs() const { // Save the structure definition and module name list. // For example: { "struct task_struct", { "vmlinux", "kvm" } } std::map> structs_map; for (const auto &btf_obj : btf_objects) { for (const auto &s : get_all_structs_from_btf(btf_obj.btf)) { auto it = structs_map.find(s); // The same structure (name) can appear in different BTFs. if (it != structs_map.end()) { it->second.insert(btf_obj.name); } else { structs_map.insert({ s, { btf_obj.name } }); } } } return structs_map; } std::unordered_set BTF::get_all_iters_from_btf( const struct btf *btf) const { constexpr std::string_view prefix = "bpf_iter__"; // kernel commit 6fcd486b3a0a("bpf: Refactor RCU enforcement in the // verifier.") add 'struct bpf_iter__task__safe_trusted' constexpr std::string_view suffix___safe_trusted = "__safe_trusted"; std::unordered_set iter_set; auto id = start_id(btf), max = type_cnt(btf); for (; id <= max; id++) { const struct btf_type *t = btf__type_by_id(btf, id); if (!t || !btf_is_struct(t)) continue; std::string_view name = btf_str(btf, t->name_off); // skip __safe_trusted suffix struct if (name.ends_with(suffix___safe_trusted)) continue; if (name.starts_with(prefix)) { name.remove_prefix(prefix.length()); iter_set.insert(std::string(name)); } } return iter_set; } std::unordered_set BTF::get_all_iters() const { std::unordered_set iters; for (const auto &btf_obj : btf_objects) { auto mod_iters = get_all_iters_from_btf(btf_obj.btf); iters.insert(mod_iters.begin(), mod_iters.end()); } return iters; } int BTF::get_btf_id(std::string_view func, std::string_view mod, __u32 kind) const { for (const auto &btf_obj : btf_objects) { if (!mod.empty() && mod != btf_obj.name) continue; auto id = find_id_in_btf(btf_obj.btf, func, kind); if (id >= 0) return id; } return -1; } BTF::BTFId BTF::find_id(std::string_view name, std::optional<__u32> kind) const { for (const auto &btf_obj : btf_objects) { __s32 id = kind ? btf__find_by_name_kind(btf_obj.btf, name.data(), *kind) : btf__find_by_name(btf_obj.btf, name.data()); if (id >= 0) return { .btf = btf_obj.btf, .id = static_cast<__u32>(id) }; } return { .btf = nullptr, .id = 0 }; } __s32 BTF::find_id_in_btf(struct btf *btf, std::string_view name, std::optional<__u32> kind) const { for (auto id = start_id(btf), max = type_cnt(btf); id <= max; ++id) { const struct btf_type *t = btf__type_by_id(btf, id); if (!t) continue; if (kind && btf_kind(t) != *kind) continue; const auto *type_name = btf__name_by_offset(btf, t->name_off); if (name == type_name) return id; } return -1; } void BTF::resolve_fields(const SizedType &type) { BTFId type_id; if (!type.IsCTypeTy()) return; auto const &name = type.GetName(); auto record = bpftrace_->structs.Lookup(name).lock(); if (record->HasFields()) return; if (type.IsAnonTy()) { type_id = parse_anon_btf_name(name); } else { __u32 kind = type.IsCStructTy() ? BTF_KIND_STRUCT : BTF_KIND_UNION; auto type_name = btf_type_str(name); type_id = find_id(type_name, kind); if (!type_id.btf) return; } resolve_fields(type_id, std::move(record), 0); } static std::optional resolve_bitfield( const struct btf_type *record_type, __u32 member_idx) { __u32 bitfield_width = btf_member_bitfield_size(record_type, member_idx); if (bitfield_width <= 0) return std::nullopt; return Bitfield(btf_member_bit_offset(record_type, member_idx) % 8, bitfield_width); } void BTF::resolve_fields(const BTFId &type_id, std::shared_ptr record, __u32 start_offset) { const auto *btf_type = btf__type_by_id(type_id.btf, type_id.id); if (!btf_type) return; auto *members = btf_members(btf_type); for (__u32 i = 0; i < BTF_INFO_VLEN(btf_type->info); i++) { BTFId field_id{ .btf = type_id.btf, .id = members[i].type }; const auto *field_type = btf__type_by_id(field_id.btf, field_id.id); if (!field_type) { LOG(ERROR) << "Inconsistent BTF data (no type found for id " << members[i].type << ")"; record->ClearFields(); break; } std::string field_name = btf__name_by_offset(type_id.btf, members[i].name_off); __u32 field_offset = start_offset + (btf_member_bit_offset(btf_type, i) / 8); if (btf_is_composite(field_type) && is_anon_btf_typename(field_name)) { resolve_fields(field_id, record, field_offset); continue; } record->AddField(field_name, get_stype(field_id), field_offset, resolve_bitfield(btf_type, i)); } } static char user_pointer[] = R"(__attribute__((btf_type_tag("user"))) *)"; SizedType BTF::get_stype(std::string_view type_name) { auto btf_name = btf_type_str(type_name); auto type_id = find_id(btf_name); if (type_id.btf) return get_stype(type_id); if (type_name.starts_with("const ")) return get_stype(type_name.substr("const "sv.length())); if (type_name.ends_with(" const") || type_name.ends_with("*const")) { auto new_name = std::string(type_name.substr(0, type_name.rfind("const"))); util::rtrim(new_name); return get_stype(new_name); } if (type_name.ends_with(user_pointer)) { auto pointee = std::string( type_name.substr(0, type_name.length() - strlen(user_pointer))); util::rtrim(pointee); auto ty = get_stype(pointee); ty.SetAS(AddrSpace::user); return CreatePointer(ty, AddrSpace::user); } if (type_name.ends_with("*")) { auto pointee = std::string(type_name.substr(0, type_name.length() - 1)); util::rtrim(pointee); auto ty = get_stype(pointee); ty.SetAS(AddrSpace::kernel); return CreatePointer(ty, AddrSpace::kernel); } if (type_name == "unsigned") return get_stype("unsigned int"); if (type_name == "short") return get_stype("short int"); if (type_name == "unsigned short") return get_stype("short unsigned int"); if (type_name == "long") return get_stype("long int"); if (type_name == "unsigned long") return get_stype("long unsigned int"); if (type_name == "long long") return get_stype("long long int"); if (type_name == "unsigned long long") return get_stype("long long unsigned int"); if (type_name.ends_with(" short")) { auto pos = type_name.rfind(" short"); return get_stype("short " + std::string(type_name.substr(0, pos))); } if (type_name.ends_with(" long")) { auto pos = type_name.rfind(" long"); return get_stype("long " + std::string(type_name.substr(0, pos))); } if (type_name.ends_with(" unsigned")) { auto pos = type_name.rfind(" long"); return get_stype("long " + std::string(type_name.substr(0, pos))); } if (type_name == "void") return CreateVoid(); return CreateNone(); } SizedType BTF::get_var_type(std::string_view var_name) { auto var_id = find_id(var_name, BTF_KIND_VAR); if (!var_id.btf) return CreateNone(); const struct btf_type *t = btf__type_by_id(var_id.btf, var_id.id); if (!t) return CreateNone(); return get_stype(BTFId{ .btf = var_id.btf, .id = t->type }); } ast::Pass CreateParseBTFPass() { return ast::Pass::create( "btf", [](ast::ASTContext &ast, BPFtrace &b, ast::FunctionInfo &func_info) { ProbeMatcher probe_matcher(&b, func_info.kernel_info(), func_info.user_info()); b.parse_module_btf(b.list_modules(ast, probe_matcher)); }); } } // namespace bpftrace bpftrace-0.27.1/src/btf.h000066400000000000000000000170311526721631600151150ustar00rootroot00000000000000#pragma once #include "types.h" #include #include #include #include #include #include #include #include #include #include "ast/pass_manager.h" #include "symbols/kernel.h" #include "util/result.h" // Taken from libbpf #define BTF_INFO_ENC(kind, kind_flag, vlen) \ ((!!(kind_flag) << 31) | ((kind) << 24) | ((vlen) & BTF_MAX_VLEN)) #define BTF_TYPE_ENC(name, info, size_or_type) (name), (info), (size_or_type) #define BTF_INT_ENC(encoding, bits_offset, nr_bits) \ ((encoding) << 24 | (bits_offset) << 16 | (nr_bits)) #define BTF_TYPE_INT_ENC(name, encoding, bits_offset, bits, sz) \ BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_INT, 0, 0), sz), \ BTF_INT_ENC(encoding, bits_offset, bits) #define BTF_PARAM_ENC(name, type) (name), (type) struct btf; struct btf_type; namespace bpftrace { // Note: there are several prefixes for raw tracepoint BTF functions. // "__probestub_" seems to be the most accurate in terms of getting the params // but it wasn't added until May 2023 so older kernels might not have it, // which is why we also check "__traceiter_" (as needed). // "btf_trace_" prefix, which is what the kernel uses for raw tracepoints, we // use in bpfprogram.cpp to validate if we can attach to this raw tracepoint. // The BTF for "btf_trace_" is a typedef that eventually resolves to a // FUNC_PROTO but the params for this do not have names, which is what we need. // "__probestub_" was added here: // https://lore.kernel.org/all/168507471874.913472.17214624519622959593.stgit@mhiramat.roam.corp.google.com/ // "__traceiter_" was added here: // https://lore.kernel.org/all/20200908105743.GW2674@hirez.programming.kicks-ass.net/ static const std::vector RT_BTF_PREFIXES = { "__probestub_", "__traceiter_" }; class BPFtrace; // Prefix used to generate names for anonymous struct/unions. The // format is: BTF_ANON_STRUCT_PREFIX + + "_" + constexpr std::string_view BTF_ANON_STRUCT_PREFIX = "__bpftrace_btf_anon_"; using FuncParamLists = std::map>; class BTF { enum state { INIT, ERROR, VMLINUX_LOADED, VMLINUX_AND_MODULES_LOADED, }; // BTF object for vmlinux or a kernel module. // We're currently storing its name and BTF id. struct BTFObj { struct btf* btf; std::string name; }; // It is often necessary to store a BTF id along with the BTF data containing // its definition. struct BTFId { struct btf* btf; __u32 id; }; public: BTF(); BTF(BPFtrace* bpftrace); ~BTF(); bool has_data(); bool has_module_btf(); bool modules_loaded() const; size_t objects_cnt() const { return btf_objects.size(); } void load_module_btfs(const std::set& modules); std::string type_of(std::string_view name, std::string_view field); std::string type_of(const BTFId& type_id, std::string_view field); SizedType get_stype(std::string_view type_name); SizedType get_var_type(std::string_view var_name); // Returns a string containing the C definitions generated from the BTF data. // If `set` is provided (non-empty), then the generated types will be limited // to just those in the set. If `set` is not provided (empty), then all types // will be generated. std::string c_def(const std::unordered_set& set = {}); std::map> get_all_structs() const; std::unique_ptr get_all_traceable_funcs( const symbols::KernelInfo& kernel_func_info) const; std::unordered_set get_all_iters() const; std::unique_ptr get_all_raw_tracepoints(); FuncParamLists get_params(const std::set& funcs) const; FuncParamLists get_kprobes_params(const std::set& funcs) const; FuncParamLists get_kretprobes_params( const std::set& funcs) const; FuncParamLists get_rawtracepoint_params( const std::set& rawtracepoints) const; Result> resolve_args(std::string_view func, bool ret, bool skip_first_arg); Result> resolve_raw_tracepoint_args( std::string_view func); void resolve_fields(const SizedType& type); int get_btf_id(std::string_view func, std::string_view mod, __u32 kind = BTF_KIND_FUNC) const; private: void load_vmlinux_btf(); SizedType get_stype(const BTFId& btf_id, bool resolve_structs = true); void resolve_fields(const BTFId& type_id, std::shared_ptr record, __u32 start_offset); BTF::BTFId find_id(std::string_view name, std::optional<__u32> kind = std::nullopt) const; __s32 find_id_in_btf(struct btf* btf, std::string_view name, std::optional<__u32> kind = std::nullopt) const; std::string dump_defs_from_btf(const struct btf* btf, std::unordered_set& types) const; std::string get_all_traceable_funcs_from_btf( const symbols::KernelInfo& kernel_func_info, const BTFObj& btf_obj) const; std::string get_all_raw_tracepoints_from_btf(const BTFObj& btf_obj) const; FuncParamLists get_params_impl( const std::set& funcs, std::function& funcs)> get_param_btf_cb) const; FuncParamLists get_params_from_btf(const BTFObj& btf_obj, const std::set& funcs) const; FuncParamLists get_kprobes_params_from_btf(const BTFObj& btf_obj, const std::set& funcs, bool is_kretprobe) const; FuncParamLists get_raw_tracepoints_params_from_btf( const BTFObj& btf_obj, const std::set& rawtracepoints) const; std::set get_all_structs_from_btf(const struct btf* btf) const; std::unordered_set get_all_iters_from_btf( const struct btf* btf) const; // This returns the id of the first type that is not a BTF_KIND_TYPE_TAG // while also populating the tags set with the tag/attribute names // from the BTF_KIND_TYPE_TAG types it finds. __u32 get_type_tags(std::unordered_set& tags, const BTFId& btf_id) const; __u32 start_id(const struct btf* btf) const; BTFId parse_anon_btf_name(const std::string& name); std::string create_anon_btf_name(BTFId& btf_id); struct btf* vmlinux_btf = nullptr; __u32 vmlinux_btf_size; // BTF objects for vmlinux and modules std::vector btf_objects; enum state state = INIT; BPFtrace* bpftrace_ = nullptr; mutable std::string all_funcs_; std::string all_rawtracepoints_; std::optional has_module_btf_; public: // enum_name -> (value -> variant_name) std::map> enum_defs_; }; inline bool BTF::has_data() { // This can be called multiple times and won't reload vmlinux load_vmlinux_btf(); return state == VMLINUX_LOADED || state == VMLINUX_AND_MODULES_LOADED; } inline bool BTF::modules_loaded() const { return state == VMLINUX_AND_MODULES_LOADED; } ast::Pass CreateParseBTFPass(); } // namespace bpftrace bpftrace-0.27.1/src/btf/000077500000000000000000000000001526721631600147425ustar00rootroot00000000000000bpftrace-0.27.1/src/btf/CMakeLists.txt000066400000000000000000000002111526721631600174740ustar00rootroot00000000000000add_library(btf STATIC btf.cpp compat.cpp helpers.cpp irbuilder.cpp ) add_dependencies(btf util) target_link_libraries(btf util) bpftrace-0.27.1/src/btf/btf.cpp000066400000000000000000000616121526721631600162270ustar00rootroot00000000000000#include #include #include #include "btf/btf.h" #include "btf/helpers.h" #include "util/temp.h" namespace bpftrace::btf { using namespace bpftrace; namespace detail { Handle::Handle() : btf_(btf__new_empty()) { } Handle::Handle(std::shared_ptr base) : btf_(btf__new_empty_split(base->btf_)), base_(std::move(base)) { } Result Handle::parse(const void *data, size_t sz) { auto f = util::TempFile::create(); if (!f) { return f.takeError(); } auto ok = f->write_all(std::span(static_cast(data), sz)); if (!ok) { return ok.takeError(); } auto *btf = btf__parse(f->path().c_str(), nullptr); // No extensions. if (btf == nullptr) { return make_error(errno); } return std::make_shared(btf); } Result Handle::parse(HandleRef base, const void *data, size_t sz) { auto f = util::TempFile::create(); if (!f) { return f.takeError(); } auto ok = f->write_all(std::span(static_cast(data), sz)); if (!ok) { return ok.takeError(); } auto *btf = btf__parse_split(f->path().c_str(), base->btf_); if (btf == nullptr) { return make_error(errno); } return std::make_shared(btf, std::move(base)); } Handle::~Handle() { btf__free(btf_); } } // namespace detail char ParseError::ID; void ParseError::log(llvm::raw_ostream &OS) const { OS << "Parse error: " << std::strerror(err_); } char TypeError::ID; void TypeError::log(llvm::raw_ostream &OS) const { OS << "Type error: " << std::strerror(err_); } char UnknownType::ID; void UnknownType::log(llvm::raw_ostream &OS) const { std::visit([&](const auto &v) { OS << "Unknown type: " << v; }, name_); } char KindMismatch::ID; void KindMismatch::log(llvm::raw_ostream &OS) const { OS << "Kind mismatch: got " << got_ << ", expected " << expected_; } Result BaseType::size() const { auto v = btf__resolve_size(btf_library(), type_id_); if (v < 0) { return make_error(v); } return static_cast(v); } // Returns the required alignment for the type. Result BaseType::alignment() const { auto v = btf__align_of(btf_library(), type_id_); if (v < 0) { return make_error(v); } return static_cast(v); } const struct btf_type *BaseType::btf_type() const { return btf__type_by_id(handle_->btf_library(), type_id_); } Result Integer::add(HandleRef handle, const std::string &name, size_t bytes, int encoding) { auto v = btf__add_int(handle->btf_library(), name.c_str(), bytes, encoding); if (v < 0) { return make_error(v); } return Integer(std::move(handle), v); } size_t Integer::bytes() const { return btf_type()->size; } Result Pointer::add(HandleRef handle, const AnyType &type) { auto v = btf__add_ptr(handle->btf_library(), type.type_id()); if (v < 0) { return make_error(v); } return Pointer(std::move(handle), v); } Result Pointer::element_type() const { return AnyType::lookup(handle(), btf_type()->type); } Result Array::add(HandleRef handle, const Integer &index_type, const ValueType &element_type, size_t elements) { auto v = btf__add_array(handle->btf_library(), index_type.type_id(), element_type.type_id(), elements); if (v < 0) { return make_error(v); } return Array(std::move(handle), v); } Result Array::index_type() const { return ValueType::lookup(handle(), btf_array(btf_type())->index_type); } Result Array::element_type() const { return AnyType::lookup(handle(), btf_array(btf_type())->type); } size_t Array::element_count() const { return btf_array(btf_type())->nelems; } static Result forEachField( HandleRef handle, const struct btf_type *t, std::function fn, std::optional<__u16> start_index = std::nullopt, std::optional<__u16> end_index = std::nullopt) { if (!start_index) { start_index = 0; } if (!end_index) { end_index = btf_vlen(t); } auto *members = btf_members(t); for (int i = *start_index; i < *end_index; i++) { std::string name( btf__name_by_offset(handle->btf_library(), members[i].name_off)); auto ok = ValueType::lookup(handle, members[i].type); if (!ok) { // We found the field, but can't resolve the type. return ok.takeError(); } bool kflag = BTF_INFO_KFLAG(t->info); FieldInfo info = { .type = std::move(*ok), .bit_offset = kflag ? BTF_MEMBER_BIT_OFFSET(members[i].offset) : members[i].offset, .bit_size = kflag ? BTF_MEMBER_BITFIELD_SIZE(members[i].offset) : 0, }; if (!fn(std::move(name), std::move(info))) { break; } } return OK(); } Result Struct::add( HandleRef handle, const std::string &name, const std::vector> &fields) { size_t total_bytes = 0; std::vector offsets; for (const auto &[_, t] : fields) { auto align = t.alignment(); if (!align) { return align.takeError(); } auto left = total_bytes % (*align); if (left != 0) { total_bytes += (*align) - left; } offsets.push_back(total_bytes); auto size = t.size(); if (!size) { return size.takeError(); } total_bytes += (*size); } auto v = btf__add_struct(handle->btf_library(), name.c_str(), total_bytes); if (v < 0) { return make_error(v); } size_t index = 0; for (const auto &[field_name, t] : fields) { // We always provide bit_size=0, which indicates that this is not a // bitfield. We cannot construct bitfields via the `add` API. int rc = btf__add_field(handle->btf_library(), field_name.c_str(), t.type_id(), 8 * offsets[index], 0); if (rc < 0) { return make_error(rc); } index++; } return Struct(std::move(handle), v); } std::string Struct::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result Struct::field(const std::string &name) const { std::optional result; auto ok = forEachField(handle(), btf_type(), [&](std::string &&field_name, FieldInfo &&info) -> bool { if (name == field_name) { result.emplace(std::move(info)); return false; } return true; }); if (!ok) { return ok.takeError(); } if (!result) { return make_error(name); } return std::move(*result); } Result Struct::field(uint32_t index) const { std::optional result; auto ok = forEachField( handle(), btf_type(), [&]([[maybe_unused]] std::string &&field_name, FieldInfo &&info) -> bool { result.emplace(std::move(info)); return true; }, index, index + 1); if (!ok) { return ok.takeError(); } if (!result) { return make_error(index); } return std::move(*result); } Result>> Struct::fields() const { std::vector> result; auto ok = forEachField( handle(), btf_type(), [&](std::string &&field_name, FieldInfo &&info) -> bool { result.emplace_back(std::move(field_name), std::move(info)); return true; }); if (!ok) { return ok.takeError(); } return result; } Result Union::add( HandleRef handle, const std::string &name, const std::vector> &fields) { size_t total_bytes = 0; for (const auto &[_, t] : fields) { auto size = t.size(); if (!size) { return size.takeError(); } total_bytes = std::max(total_bytes, *size); } auto v = btf__add_union(handle->btf_library(), name.c_str(), total_bytes); if (v < 0) { return make_error(v); } for (const auto &[field_name, t] : fields) { // We always provide bit_offset 0, with a bit_size of 0 because bitfields // are not supported. We only rely on the total size above. auto r = btf__add_field( handle->btf_library(), field_name.c_str(), t.type_id(), 0, 0); if (r < 0) { return make_error(r); } } return Union(std::move(handle), v); } std::string Union::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result Union::field(const std::string &name) const { std::optional result; auto ok = forEachField(handle(), btf_type(), [&](std::string &&field_name, FieldInfo &&info) -> bool { if (name == field_name) { result.emplace(std::move(info)); return false; } return true; }); if (!ok) { return ok.takeError(); } if (!result) { return make_error(name); } return std::move(*result); } Result Union::field(uint32_t index) const { std::optional result; auto ok = forEachField( handle(), btf_type(), [&]([[maybe_unused]] std::string &&field_name, FieldInfo &&info) -> bool { result.emplace(std::move(info)); return true; }, index, index + 1); if (!ok) { return ok.takeError(); } if (!result) { return make_error(index); } return std::move(*result); } Result>> Union::fields() const { std::vector> result; auto ok = forEachField( handle(), btf_type(), [&](std::string &&field_name, FieldInfo &&info) -> bool { result.emplace_back(std::move(field_name), std::move(info)); return true; }); if (!ok) { return ok.takeError(); } return result; } std::string Enum::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } std::map Enum::values() const { std::map values; const auto *t = btf_type(); auto *v = btf_enum(t); auto vlen = btf_vlen(t); for (int i = 0; i < vlen; i++) { std::string s(btf__name_by_offset(btf_library(), v[i].name_off)); values.emplace(std::move(s), static_cast(v[i].val)); } return values; } Result Enum::add(HandleRef handle, const std::string &name, const std::map &values) { auto v = btf__add_enum(handle->btf_library(), name.c_str(), sizeof(int32_t)); if (v < 0) { return make_error(v); } for (const auto &[value_name, v] : values) { btf__add_enum_value(handle->btf_library(), value_name.c_str(), v); } return Enum(std::move(handle), v); } std::string Enum64::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } std::map Enum64::values() const { std::map values; const auto *t = btf_type(); auto *v = btf_enum64(t); auto vlen = btf_vlen(t); for (int i = 0; i < vlen; i++) { std::string s(btf__name_by_offset(btf_library(), v[i].name_off)); values.emplace(std::move(s), (static_cast(v[i].val_hi32) << 32) | static_cast(v[i].val_lo32)); } return values; } Result Enum64::add(HandleRef handle, const std::string &name, const std::map &values) { auto v = btf__add_enum64( handle->btf_library(), name.c_str(), sizeof(int64_t), true); if (v < 0) { return make_error(v); } for (const auto &[value_name, v] : values) { btf__add_enum64_value(handle->btf_library(), value_name.c_str(), v); } return Enum64(std::move(handle), v); } ForwardDecl::Kind ForwardDecl::kind() const { // Note that enums don't really exist in the encoded scheme, they are just // enums without any defined values. bool is_union = BTF_INFO_KFLAG(btf_type()->info); if (is_union) { return ForwardDecl::Kind::Union; } return ForwardDecl::Kind::Struct; } std::string ForwardDecl::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result Typedef::add(HandleRef handle, const std::string &name, const AnyType &t) { auto v = btf__add_typedef(handle->btf_library(), name.c_str(), t.type_id()); if (v < 0) { return make_error(v); } return Typedef(std::move(handle), v); } std::string Typedef::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result Typedef::type() const { return AnyType::lookup(handle(), btf_type()->type); } Result Volatile::add(HandleRef handle, const ValueType &value_type) { auto v = btf__add_volatile(handle->btf_library(), value_type.type_id()); if (v < 0) { return make_error(v); } return Volatile(std::move(handle), v); } Result Volatile::type() const { return AnyType::lookup(handle(), btf_type()->type); } Result Const::add(HandleRef handle, const ValueType &value_type) { auto v = btf__add_const(handle->btf_library(), value_type.type_id()); if (v < 0) { return make_error(v); } return Const(std::move(handle), v); } Result Const::type() const { return AnyType::lookup(handle(), btf_type()->type); } Result Restrict::add(HandleRef handle, const ValueType &value_type) { auto v = btf__add_restrict(handle->btf_library(), value_type.type_id()); if (v < 0) { return make_error(v); } return Restrict(std::move(handle), v); } Result Restrict::type() const { return AnyType::lookup(handle(), btf_type()->type); } Result FunctionProto::add( HandleRef handle, const ValueType &return_type, const std::vector> &args) { auto v = btf__add_func_proto(handle->btf_library(), return_type.type_id()); if (v < 0) { return make_error(v); } for (const auto &[param_name, t] : args) { btf__add_func_param(handle->btf_library(), param_name.c_str(), t.type_id()); } return FunctionProto(std::move(handle), v); } Result>> FunctionProto:: argument_types() const { std::vector> result; const auto *t = btf_type(); auto *params = btf_params(t); auto vlen = btf_vlen(t); for (int i = 0; i < vlen; i++) { auto v = ValueType::lookup(handle(), params[i].type); if (!v) { return v.takeError(); } result.emplace_back(std::string(btf__name_by_offset(btf_library(), params[i].name_off)), std::move(*v)); } return result; } Result FunctionProto::return_type() const { return ValueType::lookup(handle(), btf_type()->type); } Result Function::add(HandleRef handle, const std::string &name, Linkage linkage, const FunctionProto &proto) { auto v = btf__add_func(handle->btf_library(), name.c_str(), static_cast(linkage), proto.type_id()); if (v < 0) { return make_error(v); } return Function(std::move(handle), v); } Result Function::type() const { return FunctionProto::lookup(handle(), btf_type()->type); } Function::Linkage Function::linkage() const { return static_cast(btf_vlen(btf_type())); } std::string Function::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result Var::add(HandleRef handle, const std::string &name, Linkage linkage, const ValueType &type) { auto v = btf__add_var( handle->btf_library(), name.c_str(), linkage, type.type_id()); if (v < 0) { return make_error(v); } return Var(std::move(handle), v); } Result Var::type() const { return ValueType::lookup(handle(), btf_type()->type); } Var::Linkage Var::linkage() const { auto *var = btf_var(btf_type()); return static_cast(var->linkage); } std::string Var::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } std::string DataSection::name() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result DataSection::add(HandleRef handle, const std::string &name, const std::vector &vars) { size_t total_bytes = 0; std::vector sizes; std::vector offsets; for (const auto &var : vars) { auto align = var.alignment(); if (!align) { return align.takeError(); } auto left = total_bytes % (*align); if (left != 0) { total_bytes += (*align) - left; } offsets.push_back(total_bytes); auto size = var.size(); if (!size) { return size.takeError(); } sizes.push_back(*size); total_bytes += (*size); } auto v = btf__add_datasec(handle->btf_library(), name.c_str(), total_bytes); if (v < 0) { return make_error(v); } for (size_t i = 0; i < vars.size(); i++) { auto r = btf__add_datasec_var_info( handle->btf_library(), vars[i].type_id(), offsets[i], sizes[i]); if (r < 0) { return make_error(r); } } return DataSection(std::move(handle), v); } std::string DeclTag::value() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } std::string TypeTag::value() const { return btf__name_by_offset(btf_library(), btf_type()->name_off); } Result TypeTag::element_type() const { return AnyType::lookup(handle(), btf_type()->type); } Result Types::parse(const void *data, size_t sz) { auto handle = detail::Handle::parse(data, sz); if (!handle) { return handle.takeError(); } return Types(std::move(*handle)); } Result Types::parse(const Types &base, const void *data, size_t sz) { auto handle = detail::Handle::parse(base.handle_, data, sz); if (!handle) { return handle.takeError(); } return Types(std::move(*handle)); } size_t Types::size() const { return btf__type_cnt(handle_->btf_library()); } Result Types::distill() { struct btf *new_base_btf = nullptr; struct btf *new_split_btf = nullptr; int rc = btf__distill_base(handle_->btf_library(), &new_base_btf, &new_split_btf); if (rc < 0) { return make_error(rc); } // Replace the current one with the new base, and return // the new top-level target. handle_ = std::make_shared(new_base_btf); return Types(std::make_shared(new_split_btf, handle_)); } Result Types::relocate(const Types &other) { int rc = btf__relocate(handle_->btf_library(), other.handle_->btf_library()); if (rc < 0) { return make_error(rc); } handle_->rebase(other.handle_); return OK(); } Result Types::append(const Types &other) { int rc = btf__add_btf(handle_->btf_library(), other.handle_->btf_library()); if (rc < 0) { return make_error(rc); } return OK(); } static void dump_printf(void *ctx, const char *fmt, va_list args) { auto &out = *static_cast(ctx); char *str; if (vasprintf(&str, fmt, args) < 0) return; out << str; free(str); } Result<> Types::emit_decl(std::ostream &out) const { struct btf_dump *dump = btf_dump__new( handle_->btf_library(), dump_printf, static_cast(&out), nullptr); if (!dump) { return make_error(errno); } size_t sz = size(); for (size_t i = 1; i < sz; i++) { int rc = btf_dump__dump_type(dump, i); if (rc) { return make_error(rc); } } return OK(); } std::ostream &operator<<(std::ostream &out, const BaseType &type) { auto name_offset = type.btf_type()->name_off; if (name_offset != 0) { out << btf__name_by_offset(type.btf_library(), name_offset); } else { out << "(anon)"; } return out; } std::ostream &operator<<(std::ostream &out, [[maybe_unused]] const Void &type) { out << "void"; return out; } std::ostream &operator<<(std::ostream &out, const Integer &type) { out << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const Pointer &type) { auto t = type.element_type(); if (!t) { out << "(error: " << t.takeError() << ")"; } else { out << *t; } out << "*"; return out; } std::ostream &operator<<(std::ostream &out, const Array &type) { auto t = type.element_type(); if (!t) { llvm::Error err = t.takeError(); out << "(error: " << err << ")"; } else { out << *t; } out << "[" << type.element_count() << "]"; return out; } std::ostream &operator<<(std::ostream &out, const Struct &type) { auto info = getMapInfo(type); if (!info) { out << "struct " << static_cast(type); } else { // This is a map we can print it special. out << "map{type=" << static_cast(info->map_type) << ", key_type=" << info->key << ", value_type=" << info->value << ", nr_elements=" << info->nr_elements << "}"; } return out; } std::ostream &operator<<(std::ostream &out, const Union &type) { out << "union " << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const Enum &type) { out << "enum " << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const Enum64 &type) { out << "enum64 " << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const ForwardDecl &type) { out << "enum " << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const Typedef &type) { out << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const Volatile &type) { auto t = type.type(); out << "volatile "; if (!t) { out << "(error: " << t.takeError() << ")"; } else { out << *t; } return out; } std::ostream &operator<<(std::ostream &out, const Const &type) { auto t = type.type(); out << "const "; if (!t) { out << "(error: " << t.takeError() << ")"; } else { out << *t; } return out; } std::ostream &operator<<(std::ostream &out, const Restrict &type) { auto t = type.type(); out << "restrict "; if (!t) { out << "(error: " << t.takeError() << ")"; } else { out << *t; } return out; } static void formatFunction(std::ostream &out, const std::string &name, const FunctionProto &type) { auto rt = type.return_type(); if (!rt) { out << "(error: " << rt.takeError() << ") "; } else { out << *rt << " "; } out << name; auto args = type.argument_types(); if (!args) { out << "(error: " << args.takeError() << ")"; } else { out << "("; bool first = true; for (const auto &[name, t] : *args) { if (!first) { out << ", "; } out << t; if (!name.empty()) { out << " " << name; } first = false; } out << ")"; } } std::ostream &operator<<(std::ostream &out, const FunctionProto &type) { formatFunction(out, "(*)", type); return out; } std::ostream &operator<<(std::ostream &out, const Function &type) { std::string name = type.name(); auto t = type.type(); if (!t) { out << "void " << name << "(error: " << t.takeError() << ")"; } else { formatFunction(out, name, *t); } return out; } std::ostream &operator<<(std::ostream &out, const Var &type) { auto t = type.type(); if (!t) { out << "(error: " << t.takeError() << ") "; } else { out << *t << " "; } out << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const DataSection &type) { out << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const Float &type) { out << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const DeclTag &type) { out << static_cast(type); return out; } std::ostream &operator<<(std::ostream &out, const TypeTag &type) { out << static_cast(type); return out; } } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/btf.h000066400000000000000000000624641526721631600157020ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include #include #include #include "util/result.h" namespace bpftrace::btf { namespace detail { class Handle; using HandleRef = std::shared_ptr; // Handle is the internal library BTF handle. This is shared among all objects // that may be referencing the `struct btf*` pointer. It is held as a // `shared_ptr`, using the alias `HandleRef` (defined above). class Handle { public: Handle(); Handle(HandleRef base); Handle(struct btf *btf) : btf_(btf) {}; Handle(struct btf *btf, HandleRef base) : btf_(btf), base_(std::move(base)) {}; ~Handle(); Handle(Handle &&other) = delete; Handle &operator=(Handle &&other) = delete; Handle(const Handle &other) = delete; Handle &operator=(Handle &other) = delete; static Result parse(const void *data, size_t sz); static Result parse(HandleRef base, const void *data, size_t sz); struct btf *btf_library() const { return btf_; } void rebase(HandleRef base) { base_ = std::move(base); } private: struct btf *btf_; // N.B. base_ is not used directly, but holds a reference to the btf_library // handle if this is needed. This ensures it is not released while it is being // used. It is only used indirectly through our own handle above. HandleRef base_; }; } // namespace detail using detail::HandleRef; // Indicates an error occured while parsing BTF. class ParseError : public ErrorInfo { public: static char ID; ParseError(int err) : err_(err >= 0 ? err : -err) {}; void log(llvm::raw_ostream &OS) const override; int error_code() const { return err_; } private: int err_; }; // Indicates an error occurred within libbtf. class TypeError : public ErrorInfo { public: static char ID; TypeError(int err) : err_(err >= 0 ? err : -err) {}; void log(llvm::raw_ostream &OS) const override; int error_code() const { return err_; } private: int err_; }; // Indicates that no associated type was found, either when looking up by name // or by type_id. class UnknownType : public ErrorInfo { public: static char ID; UnknownType(const std::string &name) : name_(name) {}; UnknownType(uint32_t type_id) : name_(type_id) {}; void log(llvm::raw_ostream &OS) const override; private: std::variant name_; }; // Indicates that a type was found, but it did not match the expected type. class KindMismatch : public ErrorInfo { public: static char ID; KindMismatch(uint32_t got, uint32_t expected) : got_(got), expected_(expected) {}; void log(llvm::raw_ostream &OS) const override; private: uint32_t got_; uint32_t expected_; }; class Void; class Integer; class Pointer; class Array; class Struct; class Union; class Enum; class Enum64; class ForwardDecl; class Typedef; class Volatile; class Const; class Restrict; class FunctionProto; class Function; class Var; class DataSection; class Float; class DeclTag; class TypeTag; // Defined below for ordering. template class VariantType; // ValueType represents a value that may be passed to functions, returned, etc. // It excludes special types that may exist only within BTF (e.g. function, // variable, data section, tags, etc.). using ValueType = VariantType; // AnyType is the set of all possible BTF types. using AnyType = VariantType; // BaseType is the concrete implementation of the abstract `Type`. class BaseType { public: // Construct a new object with the handle and type_id. This is the universal // constructor for all types; it should not be overriden. BaseType(HandleRef handle, uint32_t type_id) : handle_(std::move(handle)), type_id_(type_id) {}; // Return the resolved size of the type. Result size() const; // Returns the required alignment for the type. Result alignment() const; // Return the handle for the type. const struct btf_type *btf_type() const; // Returns the library handle. HandleRef handle() const { return handle_; } // Returns the type_id. uint32_t type_id() const { return type_id_; } // Returns the btf library data, convenience wrapper. struct btf *btf_library() const { return handle_->btf_library(); } private: HandleRef handle_; uint32_t type_id_; }; // Type is the common implementation for all types; this class uses the CRTP // pattern to eliminate as much boilerplate as possible. // // Each subclass should define the following: // - An `add` method, which will lookup if the type already exists, and if not // add to the handle and return the result. // - Any custom methods related to extracting type-specfic information. template class Type : public BaseType { public: using BaseType::BaseType; // Used by the variant above, to determine if this accepts the given kind. static bool is(uint32_t kind) { return kind == Kind; } // Finds the type with the required kind and name, constructing a new object. static Result lookup(HandleRef handle, const std::string &name) { auto v = btf__find_by_name_kind(handle->btf_library(), name.c_str(), Kind); if (v >= 0) { return T(std::move(handle), v); } return make_error(name); } // Checks the given type_id against the passed one. static Result lookup(HandleRef handle, uint32_t type_id) { const auto *t = btf__type_by_id(handle->btf_library(), type_id); if (t == nullptr) { return make_error(type_id); } auto k = btf_kind(t); if (k != Kind) { return make_error(k, Kind); } return T(std::move(handle), type_id); } friend class Types; friend std::ostream &operator<<(std::ostream &, const BaseType &); }; class Void : public Type { public: Void(HandleRef handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; static Result lookup(HandleRef handle, const std::string &name) { if (name == "void") { return Void(std::move(handle), 0); } return make_error(name); } static Result lookup(HandleRef handle, uint32_t type_id) { if (type_id == 0) { return Void(std::move(handle), type_id); } return make_error(type_id); } private: // There is no `add` method for void types, it is always implicitly defined. // It is also used for types that we cannot currently interpret correctly. friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Void & /*type*/); }; class Integer : public Type { public: Integer(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; size_t bytes() const; bool is_bool() const { return btf_int_encoding(btf_type()) & BTF_INT_BOOL; } bool is_signed() const { return btf_int_encoding(btf_type()) & BTF_INT_SIGNED; } private: static Result add(HandleRef handle, const std::string &name, size_t bytes, int encoding); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Integer & /*type*/); }; class Pointer : public Type { public: Pointer(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; Result element_type() const; private: static Result add(HandleRef handle, const AnyType &type); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Pointer & /*type*/); }; class Array : public Type { public: Array(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; Result index_type() const; Result element_type() const; size_t element_count() const; private: static Result add(HandleRef handle, const Integer &index_type, const ValueType &element_type, size_t elements); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Array & /*type*/); }; // Defined below. struct FieldInfo; class Struct : public Type { public: Struct(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string name() const; Result field(const std::string &name) const; Result field(uint32_t index) const; Result>> fields() const; private: static Result add( HandleRef handle, const std::string &name, const std::vector> &fields); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Struct & /*type*/); }; class Union : public Type { public: Union(HandleRef handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string name() const; Result field(const std::string &name) const; Result field(uint32_t index) const; Result>> fields() const; private: static Result add( HandleRef handle, const std::string &name, const std::vector> &fields); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Union & /*type*/); }; class Enum : public Type { public: Enum(HandleRef handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string name() const; std::map values() const; private: static Result add(HandleRef handle, const std::string &name, const std::map &values); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Enum & /*type*/); }; class Enum64 : public Type { public: Enum64(HandleRef handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string name() const; std::map values() const; private: static Result add(HandleRef handle, const std::string &name, const std::map &values); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Enum64 & /*type*/); }; class ForwardDecl : public Type { public: ForwardDecl(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; enum Kind { Struct = BTF_FWD_STRUCT, Union = BTF_FWD_UNION, Enum = BTF_FWD_ENUM, }; Kind kind() const; std::string name() const; private: // We don't support `add` for forward declarations, this is really an // artifact used for constructing pointers without full type information in // all translation units. It should not be relevant in fully fleshed out // types, hence the only method is the resolution method. friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const ForwardDecl & /*type*/); }; class Typedef : public Type { public: Typedef(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string name() const; Result type() const; private: static Result add(HandleRef handle, const std::string &name, const AnyType &t); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Typedef & /*type*/); }; class Volatile : public Type { public: Volatile(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; Result type() const; private: static Result add(HandleRef handle, const ValueType &value_type); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Volatile & /*type*/); }; class Const : public Type { public: Const(HandleRef handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; Result type() const; private: static Result add(HandleRef handle, const ValueType &value_type); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Const & /*type*/); }; class Restrict : public Type { public: Restrict(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; Result type() const; private: static Result add(HandleRef handle, const ValueType &value_type); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Restrict & /*type*/); }; class FunctionProto : public Type { public: FunctionProto(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; Result>> argument_types() const; Result return_type() const; private: static Result add( HandleRef handle, const ValueType &return_type, const std::vector> &args); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const FunctionProto & /*type*/); }; class Function : public Type { public: Function(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; enum Linkage { Static = BTF_FUNC_STATIC, Global = BTF_FUNC_GLOBAL, Extern = BTF_FUNC_EXTERN, }; Result type() const; Linkage linkage() const; std::string name() const; private: static Result add(HandleRef handle, const std::string &name, Linkage linkage, const FunctionProto &proto); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Function & /*type*/); }; class Var : public Type { public: Var(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; enum Linkage { Static = BTF_VAR_STATIC, Global = BTF_VAR_GLOBAL_ALLOCATED, Extern = BTF_VAR_GLOBAL_EXTERN, }; Result type() const; Linkage linkage() const; std::string name() const; private: static Result add(HandleRef handle, const std::string &name, Linkage linkage, const ValueType &type); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Var & /*type*/); }; class DataSection : public Type { public: DataSection(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string name() const; private: static Result add(HandleRef handle, const std::string &name, const std::vector &vars); friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const DataSection & /*type*/); }; class Float : public Type { public: Float(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; private: // We don't presently support floating point operations, and hence do not // have the ability to add anything to this type system. friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const Float & /*type*/); }; class DeclTag : public Type { public: DeclTag(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string value() const; private: friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const DeclTag & /*type*/); }; class TypeTag : public Type { public: TypeTag(HandleRef &&handle, uint32_t type_id) : Type(std::move(handle), type_id) {}; std::string value() const; Result element_type() const; private: friend class Types; friend std::ostream &operator<<(std::ostream & /*out*/, const TypeTag & /*type*/); }; // VariantType represents a variant over some set of possible types. template class VariantType { public: VariantType(std::variant value) : value_(std::move(value)) {}; // Allow automatic construct from any supported type. template VariantType(const U &value) requires((std::is_same_v || ...)) : value_(value) {}; // Allow conversion between types as long as one is strictly a subset of the // other. In general, this allows `ValueType` to `AnyType` implicit // conversion. template VariantType(VariantType other) : VariantType( std::visit([](const auto &v) -> std::variant { return v; }, other.value())) {}; // Checks to see if this is the given kind. template bool is() const { return std::holds_alternative(value_); } // Interpret as the given kind; use `is` first. template const T &as() const { return std::get(value_); } // Return the size of the type. Result size() const { return std::visit([](const auto &v) { return v.size(); }, value_); } // Returns the alignment of the type. Result alignment() const { return std::visit([](const auto &v) { return v.alignment(); }, value_); } // Return the underlying type_id for the type. uint32_t type_id() const { return std::visit([](const auto &v) { return v.type_id(); }, value_); } static Result> lookup(HandleRef handle, uint32_t type_id) { const auto *t = btf__type_by_id(handle->btf_library(), type_id); assert(t != nullptr); auto k = btf_kind(t); return tryLookup(k, std::move(handle), type_id); } static Result> lookup(HandleRef handle, const std::string &name) { return tryLookup(std::move(handle), name); } const std::variant &value() const { return value_; } private: std::variant value_; template static Result> tryLookup(uint32_t kind, HandleRef handle, uint32_t type_id) { if (First::is(kind)) { // This matches the kind provided, so we delegate to this class. Note // that this may still return an error, and we propagate that explicitly. auto ok = First::lookup(std::move(handle), type_id); if (!ok) { return ok.takeError(); } return VariantType(std::move(*ok)); } if constexpr (sizeof...(Rest) != 0) { // Keep tring the rest of the underlying types. return tryLookup(kind, std::move(handle), type_id); } return make_error(type_id); } template static Result> tryLookup(HandleRef handle, const std::string &name) { auto ok = First::lookup(handle, name); if (ok) { return std::move(*ok); } if constexpr (sizeof...(Rest) != 0) { return tryLookup(std::move(handle), name); } return make_error(name); } friend class Types; template friend std::ostream &operator<<(std::ostream &, const VariantType &); }; template std::ostream &operator<<(std::ostream &out, const VariantType &type) { std::visit([&](const auto &v) { out << v; }, type.value_); return out; } // Information for fields. struct FieldInfo { ValueType type; size_t bit_offset; size_t bit_size; }; namespace detail { // Basic iterator over times, used to provide a view into the system. class TypeIterator { public: using value_type = AnyType; using difference_type = std::ptrdiff_t; class Sentinel { public: uint32_t limit; }; // Used for `end`. TypeIterator(HandleRef handle, uint32_t type_id) : handle_(std::move(handle)), type_id_(type_id) {}; AnyType operator*() const { auto ok = AnyType::lookup(handle_, type_id_); if (!ok) { // We expect this to happen only if the iterator is being used // incorrectly. If exceptions are disable in this case, then everything // will merely die. This seems like the best outcome. std::stringstream ss; ss << ok.takeError(); throw std::out_of_range(ss.str()); } return std::move(*ok); } TypeIterator &operator++() { type_id_++; return *this; } TypeIterator operator++(int) { TypeIterator temp(handle_, type_id_); ++(*this); return temp; } bool operator==(const TypeIterator &other) const { return handle_ == other.handle_ && type_id_ == other.type_id_; } bool operator==(const Sentinel &other) const { return type_id_ >= other.limit; } private: HandleRef handle_; uint32_t type_id_; }; } // namespace detail // Types represents a self-contained type system. It is typically constructed // from a serialized BTF dataset, but may be constructed dynamically. class Types { public: Types() : handle_(std::make_shared()) {}; Types(HandleRef &&handle) : handle_(std::move(handle)) {}; Types(const Types &base) : handle_(std::make_shared(base.handle_)) {}; Types(struct btf *btf) : handle_(std::make_shared(btf)) {}; Types(struct btf *btf, const Types &base) : handle_(std::make_shared(btf, base.handle_)) {}; Types(Types &&other) = default; Types &operator=(Types &&other) = default; static Result parse(const void *data, size_t sz); static Result parse(const Types &base, const void *data, size_t sz); // Iterators. detail::TypeIterator begin() { return { handle_, 0 }; } detail::TypeIterator::Sentinel end() { return { .limit = static_cast(size()) }; } // Returns the number of types. size_t size() const; // See `bpf__distill_base`. Result distill(); // Switches the base of this system to another. Result relocate(const Types &other); // Append another type system to this one. Result append(const Types &other); // Add adds the given type. template Result add(Args... args) { return T::add(handle_, args...); } // Lookup will lookup the given type by the type string. template Result lookup(const std::string &name) const { return T::lookup(handle_, name); } // ... or, we can lookup by the type_id. template Result lookup(uint32_t type_id) const { return T::lookup(handle_, type_id); } // Dumps a stream of C declarations. Result<> emit_decl(std::ostream &out) const; private: HandleRef handle_; }; } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/compat.cpp000066400000000000000000000221331526721631600167320ustar00rootroot00000000000000#include "btf/compat.h" #include "btf/btf.h" #include "log.h" #include "struct.h" #include "types.h" namespace bpftrace::btf { char CompatTypeError::ID; void CompatTypeError::log(llvm::raw_ostream &OS) const { OS << msg_; } Result getCompatType([[maybe_unused]] const Void &type, [[maybe_unused]] CompatTypeCache &type_cache) { return CreateVoid(); } Result getCompatType(const Integer &type, [[maybe_unused]] CompatTypeCache &type_cache) { if (type.is_bool()) { return CreateBool(); } return CreateInteger(8 * type.bytes(), type.is_signed()); } Result getCompatType(const Pointer &type, CompatTypeCache &type_cache) { auto t = type.element_type(); if (!t) { return t.takeError(); } auto ty = getCompatType(*t, type_cache); if (!ty) { return ty.takeError(); } return CreatePointer(*ty); } Result getCompatType(const Array &type, CompatTypeCache &type_cache) { auto t = type.element_type(); if (!t) { return t.takeError(); } auto ty = getCompatType(*t, type_cache); if (!ty) { return ty.takeError(); } // Special case; all int8 arrays are treated as strings. if (ty->IsIntegerTy() && ty->GetIntBitWidth() == 8) { return CreateString(type.element_count()); } return CreateArray(type.element_count(), *ty); } // We can only generate the fields based on the offsets. static Result resolveFields( std::vector> &&fields, CompatTypeCache &type_cache) { bpftrace::Fields resolved; for (const auto &[name, info] : fields) { auto ft = getCompatType(info.type, type_cache); if (!ft) { return ft.takeError(); } resolved.emplace_back(Field{ .name = name, .type = *ft, .offset = static_cast(info.bit_offset / 8), .bitfield = std::nullopt, }); } return resolved; } Result asRecord( uint32_t type_id, const std::string &name, size_t size, std::vector> &&fields, CompatTypeCache &type_cache) { // While this record's fields are being resolved, the cache holds a null // entry for it. Since this function recurses this null entry is used to // determine if we're also dealing with a recursive type. auto [it, first_visit] = type_cache.records.try_emplace(type_id, nullptr); if (!name.empty()) { auto record = type_cache.structs.LookupOrAdd(name, size).lock(); if (first_visit && !record->HasFields()) { auto resolved = resolveFields(std::move(fields), type_cache); if (!resolved) { type_cache.records.erase(it); return resolved.takeError(); } // Another BTF type with the same name may have filled in this record // while its fields were being resolved; don't clobber it. if (!record->HasFields()) { record->fields = std::move(*resolved); } } return CreateCStruct(name, std::weak_ptr(record)); } // Anonymous records have no name to share them under, so they are owned by // the type that refers to them. auto make_record = [size](bpftrace::Fields &&fields) { auto record = bpftrace::Struct::CreateRecord({}, {}); record->size = static_cast(size); record->fields = std::move(fields); return record; }; if (!first_visit) { if (it->second) { return CreateCStruct(name, std::shared_ptr(it->second)); } // This type is still being resolved. We need to break the recursion cycle // by returning an empty record of the right size. return CreateCStruct(name, make_record({})); } auto resolved = resolveFields(std::move(fields), type_cache); if (!resolved) { type_cache.records.erase(it); return resolved.takeError(); } it->second = make_record(std::move(*resolved)); return CreateCStruct(name, std::shared_ptr(it->second)); } Result getCompatType(const Struct &type, CompatTypeCache &type_cache) { auto f = type.fields(); if (!f) { return f.takeError(); } auto sz = type.size(); if (!sz) { return sz.takeError(); } auto name = type.name(); return asRecord(type.type_id(), name.empty() ? name : "struct " + name, *sz, std::move(*f), type_cache); } Result getCompatType(const Union &type, CompatTypeCache &type_cache) { auto f = type.fields(); if (!f) { return f.takeError(); } auto sz = type.size(); if (!sz) { return sz.takeError(); } auto name = type.name(); return asRecord(type.type_id(), name.empty() ? name : "union " + name, *sz, std::move(*f), type_cache); } Result getCompatType(const Enum &type, [[maybe_unused]] CompatTypeCache &type_cache) { auto size = type.size(); if (!size) { return size.takeError(); } return CreateEnum(8 * (*size), type.name()); } Result getCompatType(const Enum64 &type, [[maybe_unused]] CompatTypeCache &type_cache) { auto size = type.size(); if (!size) { return size.takeError(); } return CreateEnum(8 * (*size), type.name()); } Result getCompatType(const TypeTag &type, CompatTypeCache &type_cache) { // Values are: user, percpu, rcu. if (type.value() == "user") { auto t = type.element_type(); if (!t) { return t.takeError(); } auto ty = getCompatType(*t, type_cache); if (!ty) { return ty.takeError(); } ty->SetAS(AddrSpace::user); return *ty; } else if (type.value() == "percpu" || type.value() == "rcu") { auto t = type.element_type(); if (!t) { return t.takeError(); } auto ty = getCompatType(*t, type_cache); if (!ty) { return ty.takeError(); } return *ty; } else { return make_error(type); } } Result getCompatType(const DeclTag &type, [[maybe_unused]] CompatTypeCache &type_cache) { return make_error(type); } Result getCompatType(const Typedef &type, CompatTypeCache &type_cache) { auto t = type.type(); if (!t) { return t.takeError(); } return getCompatType(*t, type_cache); } Result getCompatType(const Const &type, CompatTypeCache &type_cache) { auto t = type.type(); if (!t) { return t.takeError(); } return getCompatType(*t, type_cache); } Result getCompatType(const Volatile &type, CompatTypeCache &type_cache) { auto t = type.type(); if (!t) { return t.takeError(); } return getCompatType(*t, type_cache); } Result getCompatType(const Restrict &type, CompatTypeCache &type_cache) { auto t = type.type(); if (!t) { return t.takeError(); } return getCompatType(*t, type_cache); } Result getCompatType([[maybe_unused]] const Function &type, [[maybe_unused]] CompatTypeCache &type_cache) { return CreatePointer(CreateVoid()); } Result getCompatType([[maybe_unused]] const FunctionProto &type, [[maybe_unused]] CompatTypeCache &type_cache) { return CreatePointer(CreateVoid()); } Result getCompatType([[maybe_unused]] const Float &type, [[maybe_unused]] CompatTypeCache &type_cache) { auto size = type.size(); if (!size) { return size.takeError(); } return CreateBuffer(*size); } Result getCompatType([[maybe_unused]] const Var &type, [[maybe_unused]] CompatTypeCache &type_cache) { return CreatePointer(CreateVoid()); } Result getCompatType([[maybe_unused]] const DataSection &type, [[maybe_unused]] CompatTypeCache &type_cache) { return CreatePointer(CreateVoid()); } Result getCompatType(const ForwardDecl &type, CompatTypeCache &type_cache) { // Attempt to resolve the forward declaration by looking up // the type name in the existing type system. auto kind = type.kind(); auto name = type.name(); auto types = Types(type.handle()); switch (kind) { case ForwardDecl::Struct: { auto struct_type = types.lookup(name); if (!struct_type) { return CreatePointer(CreateVoid()); } return getCompatType(*struct_type, type_cache); } case ForwardDecl::Union: { auto union_type = types.lookup(name); if (!union_type) { return CreatePointer(CreateVoid()); } return getCompatType(*union_type, type_cache); } case ForwardDecl::Enum: { auto enum_type = types.lookup(name); if (!enum_type) { return CreatePointer(CreateVoid()); } return getCompatType(*enum_type, type_cache); } default: return CreatePointer(CreateVoid()); } } } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/compat.h000066400000000000000000000075311526721631600164040ustar00rootroot00000000000000#pragma once #include "btf/btf.h" #include "types.h" #include "util/result.h" namespace bpftrace { class StructManager; } // namespace bpftrace namespace bpftrace::btf { class CompatTypeError : public ErrorInfo { public: template CompatTypeError(const T &type) { std::stringstream ss; ss << "no compatible type for " << type; msg_ = ss.str(); } static char ID; void log(llvm::raw_ostream &OS) const override; const std::string &msg() const { return msg_; } private: std::string msg_; }; using BtfTypeId = uint32_t; // The state for a single conversion. // // Named records are owned by the `StructManager` and referred to weakly, which // is how a type that refers back to itself is represented without forming a // reference cycle. Anonymous records have no name to share them under, so they // are owned by the type instead. struct CompatTypeCache { StructManager &structs; std::map> records; }; template struct compatTypeFor { Result operator()(const T &t, CompatTypeCache &type_cache); }; template struct compatTypeFor> { Result operator()(const VariantType &type, CompatTypeCache &type_cache) { return std::visit( [&](const auto &v) { return getCompatType(v, type_cache); }, type.value()); } }; Result getCompatType(const Void &type, CompatTypeCache &type_cache); Result getCompatType(const Integer &type, CompatTypeCache &type_cache); Result getCompatType(const Pointer &type, CompatTypeCache &type_cache); Result getCompatType(const Array &type, CompatTypeCache &type_cache); Result getCompatType(const Struct &type, CompatTypeCache &type_cache); Result getCompatType(const Union &type, CompatTypeCache &type_cache); Result getCompatType(const Enum &type, CompatTypeCache &type_cache); Result getCompatType(const Enum64 &type, CompatTypeCache &type_cache); Result getCompatType(const TypeTag &type, CompatTypeCache &type_cache); Result getCompatType(const DeclTag &type, CompatTypeCache &type_cache); Result getCompatType(const Typedef &type, CompatTypeCache &type_cache); Result getCompatType(const Const &type, CompatTypeCache &type_cache); Result getCompatType(const Volatile &type, CompatTypeCache &type_cache); Result getCompatType(const Restrict &type, CompatTypeCache &type_cache); Result getCompatType(const Function &type, CompatTypeCache &type_cache); Result getCompatType(const FunctionProto &type, CompatTypeCache &type_cache); Result getCompatType(const DataSection &type, CompatTypeCache &type_cache); Result getCompatType(const Float &type, CompatTypeCache &type_cache); Result getCompatType(const Var &type, CompatTypeCache &type_cache); Result getCompatType(const ForwardDecl &type, CompatTypeCache &type_cache); template Result getCompatType(const T &type, CompatTypeCache &type_cache) { compatTypeFor op; return op(type, type_cache); } template Result getCompatType(const T &type, StructManager &structs) { CompatTypeCache type_cache{ .structs = structs, .records = {} }; return getCompatType(type, type_cache); } } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/helpers.cpp000066400000000000000000000106751526721631600171210ustar00rootroot00000000000000#include "btf/helpers.h" namespace bpftrace::btf { char MapError::ID; void MapError::log(llvm::raw_ostream &OS) const { OS << msg_; } Result createTuple(Types &btf, const std::vector &types) { std::vector> fields; for (const auto &type : types) { fields.emplace_back("", type); } return btf.add("", fields); } Result createMap(Types &btf, const struct MapInfo &info) { std::vector> fields; // First, we need an "int" type. auto i = btf.lookup("int"); if (!i) { i = btf.add("int", sizeof(int), true); if (!i) { return i.takeError(); } } // Now we need an `__ARRAY_SIZE_TYPE__`. auto sz = btf.lookup("__ARRAY_SIZE_TYPE__"); if (!sz) { sz = btf.add("__ARRAY_SIZE_TYPE__", sizeof(int), true); if (!sz) { return sz.takeError(); } } // Now we need to encode the type and max_entries. auto enc_type_arr = btf.add(*sz, *i, static_cast(info.map_type)); if (!enc_type_arr) { return enc_type_arr.takeError(); } auto enc_type_ptr = btf.add(*enc_type_arr); if (!enc_type_ptr) { return enc_type_ptr.takeError(); } auto enc_max_entries_arr = btf.add(*sz, *i, info.nr_elements); if (!enc_max_entries_arr) { return enc_max_entries_arr.takeError(); } auto enc_max_entries_ptr = btf.add(*enc_max_entries_arr); if (!enc_max_entries_ptr) { return enc_max_entries_ptr.takeError(); } auto enc_key = btf.add(info.key); if (!enc_key) { return enc_key.takeError(); } auto enc_value = btf.add(info.value); if (!enc_value) { return enc_value.takeError(); } fields.emplace_back("type", *enc_type_ptr); fields.emplace_back("max_entries", *enc_max_entries_ptr); fields.emplace_back("key", *enc_key); fields.emplace_back("value", *enc_value); auto r = btf.add("", fields); if (!r) { return r.takeError(); } return std::move(*r); } Result getMapInfo(const AnyType &type) { if (!type.is()) { return make_error("not a struct"); } const auto &s = type.as(); auto fields = s.fields(); if (!fields) { return fields.takeError(); } // Validate that all fields are present and in order. if (fields->size() != 4) { return make_error("does not have four fields"); } static const std::vector expected = { "type", "max_entries", "key", "value" }; size_t elem = 0; for (const auto &[name, _] : *fields) { if (name != expected[elem]) { return make_error("field names do not match"); } elem++; } // Extract the type. auto &type_info = fields->at(0).second; ::bpf_map_type map_type = BPF_MAP_TYPE_ARRAY; if (!type_info.type.is()) { return make_error("type field is not a pointer"); } else { auto arr = type_info.type.as().element_type(); if (!arr || !arr->is()) { return make_error("type field is not a pointer to an array"); } map_type = static_cast(arr->as().element_count()); } // Extract the number of elements. auto &max_entries = fields->at(1).second; size_t nr_elements = 0; if (!max_entries.type.is()) { return make_error("max_entries field is not a pointer"); } else { auto arr = max_entries.type.as().element_type(); if (!arr || !arr->is()) { return make_error( "max_entries field is not a pointer to an array"); } nr_elements = arr->as().element_count(); } // Extract the key and value types. auto &key_ptr = fields->at(2).second.type; if (!key_ptr.is()) { return make_error("key field is not a pointer"); } auto key_type = key_ptr.as().element_type(); if (!key_type) { return key_type.takeError(); } auto &value_ptr = fields->at(3).second.type; if (!value_ptr.is()) { return make_error("value field is not a pointer"); } auto value_type = value_ptr.as().element_type(); if (!value_type) { return value_type.takeError(); } struct MapInfo info = { .map_type = map_type, .key = *key_type, .value = *value_type, .nr_elements = nr_elements, }; return info; } } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/helpers.h000066400000000000000000000015031526721631600165540ustar00rootroot00000000000000#pragma once #include #include "btf/btf.h" namespace bpftrace::btf { // Indicates an error occured while parsing BTF. class MapError : public ErrorInfo { public: static char ID; MapError(std::string msg) : msg_(std::move(msg)) {}; void log(llvm::raw_ostream &OS) const override; private: std::string msg_; }; // A tuple is an anonymous struct. Result createTuple(Types &btf, const std::vector &types); // Defines a map. struct MapInfo { ::bpf_map_type map_type; AnyType key; AnyType value; size_t nr_elements; }; // A map as the standard specialized Types definition. Result createMap(Types &btf, const struct MapInfo &info); // Returns the information for the map, if it is a map. Result getMapInfo(const AnyType &type); } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/irbuilder.cpp000066400000000000000000000100111526721631600174200ustar00rootroot00000000000000#include "btf/irbuilder.h" namespace bpftrace::btf { static Result intType(llvm::IRBuilderBase &base, size_t bits) { switch (bits) { case 1: return base.getInt1Ty(); case 8: return base.getInt8Ty(); case 16: return base.getInt16Ty(); case 32: return base.getInt32Ty(); case 64: return base.getInt64Ty(); default: return make_error(EINVAL); } } Result getType(llvm::IRBuilderBase &base, const Integer &type) { return intType(base, 8 * type.bytes()); } Result getType(llvm::IRBuilderBase &base, [[maybe_unused]] const Pointer &type) { return base.getPtrTy(); } Result getType(llvm::IRBuilderBase &base, const Array &type) { auto t = type.element_type(); if (!t) { return t.takeError(); } auto ty = getType(base, t); if (!ty) { return ty.takeError(); } return llvm::ArrayType::get(*ty, type.element_count()); } Result getType(llvm::IRBuilderBase &base, const Struct &type) { llvm::SmallVector fields; auto f = type.fields(); if (!f) { return f.takeError(); } size_t last_offset = 0; bool packed = true; for (const auto &[name, info] : *f) { if (info.bit_offset != last_offset) { packed = false; } if (info.bit_size != 0) { last_offset += info.bit_size; } else { auto size = info.type.size(); if (!size) { return size.takeError(); } last_offset += 8 * (*size); } auto ft = getType(base, info.type); if (!ft) { return ft.takeError(); } fields.push_back(*ft); } return llvm::StructType::create( base.getContext(), fields, type.name(), packed); } Result getType(llvm::IRBuilderBase &base, const Union &type) { // There are no unions in LLVM IR. Therefore, we need to construct a // struct with appropriate size. auto size = type.size(); if (!size) { return size.takeError(); } auto *bytes = llvm::ArrayType::get(base.getInt8Ty(), *size); return llvm::StructType::create( base.getContext(), { bytes }, type.name(), true); } Result getType(llvm::IRBuilderBase &base, const Enum &type) { auto size = type.size(); if (!size) { return size.takeError(); } return intType(base, 8 * (*size)); } Result getType(llvm::IRBuilderBase &base, const Enum64 &type) { auto size = type.size(); if (!size) { return size.takeError(); } return intType(base, 8 * (*size)); } Result getType(llvm::IRBuilderBase &base, const Typedef &type) { auto t = type.type(); if (!t) { return t.takeError(); } return getType(base, *t); } Result getType(llvm::IRBuilderBase &base, const Volatile &type) { auto t = type.type(); if (!t) { return t.takeError(); } return getType(base, *t); } Result getType(llvm::IRBuilderBase &base, const Const &type) { auto t = type.type(); if (!t) { return t.takeError(); } return getType(base, *t); } Result getType(llvm::IRBuilderBase &base, const Restrict &type) { auto t = type.type(); if (!t) { return t.takeError(); } return getType(base, *t); } Result getType(llvm::IRBuilderBase &base, const FunctionProto &type) { llvm::SmallVector params; auto rt = type.return_type(); if (!rt) { return rt.takeError(); } auto rtt = getType(base, rt); if (!rtt) { return rtt.takeError(); } auto args = type.argument_types(); if (!args) { return args.takeError(); } bool var_args = false; size_t count = 0; for (const auto &[_, arg] : *args) { if (count == args->size() - 1 && arg.is()) { // This is a vararg function. var_args = true; break; } auto t = getType(base, arg); if (!t) { return t.takeError(); } params.push_back(*t); count++; } return llvm::FunctionType::get(*rtt, params, var_args); } } // namespace bpftrace::btf bpftrace-0.27.1/src/btf/irbuilder.h000066400000000000000000000033501526721631600170750ustar00rootroot00000000000000#pragma once #include #include "btf/btf.h" namespace bpftrace::btf { template struct defaultIRTypeFor { Result operator()(llvm::IRBuilderBase &base, [[maybe_unused]] const T &t) { return base.getVoidTy(); } }; template struct defaultIRTypeFor> { Result operator()(llvm::IRBuilderBase &base, const VariantType &type) { return std::visit([&](const auto &v) { return getType(base, v); }, type.value()); } }; Result getType(llvm::IRBuilderBase &base, const Integer &type); Result getType(llvm::IRBuilderBase &base, const Pointer &type); Result getType(llvm::IRBuilderBase &base, const Array &type); Result getType(llvm::IRBuilderBase &base, const Struct &type); Result getType(llvm::IRBuilderBase &base, const Union &type); Result getType(llvm::IRBuilderBase &base, const Enum &type); Result getType(llvm::IRBuilderBase &base, const Enum64 &type); Result getType(llvm::IRBuilderBase &base, const Typedef &type); Result getType(llvm::IRBuilderBase &base, const Volatile &type); Result getType(llvm::IRBuilderBase &base, const Const &type); Result getType(llvm::IRBuilderBase &base, const Restrict &type); Result getType(llvm::IRBuilderBase &base, const FunctionProto &type); template Result getType(llvm::IRBuilderBase &base, const T &type) { defaultIRTypeFor op; return op(base, type); } } // namespace bpftrace::btf bpftrace-0.27.1/src/build_info.cpp000066400000000000000000000021141526721631600170030ustar00rootroot00000000000000#include #include #include "build_info.h" #include "version.h" namespace bpftrace { std::string BuildInfo::report() { std::stringstream buf; buf << "Build" << std::endl << " version: " << BPFTRACE_VERSION << std::endl << " LLVM: " << LLVM_VERSION_MAJOR << "." << LLVM_VERSION_MINOR << "." << LLVM_VERSION_PATCH << std::endl << " bfd: " #ifdef HAVE_BFD_DISASM << "yes" << std::endl; #else << "no" << std::endl; #endif buf << " libdw (DWARF support): " #ifdef HAVE_LIBDW << "yes" << std::endl; #else << "no" << std::endl; #endif buf << " libsystemd (systemd notify support): " #ifdef HAVE_LIBSYSTEMD << "yes" << std::endl; #else << "no" << std::endl; #endif buf << " blazesym (advanced symbolization): " #ifdef HAVE_BLAZESYM << "yes" << std::endl; #else << "no" << std::endl; #endif buf << " dwunwind (DWARF stack unwinding): " #ifdef HAVE_DW_UNWIND << "yes" << std::endl; #else << "no" << std::endl; #endif return buf.str(); } } // namespace bpftrace bpftrace-0.27.1/src/build_info.h000066400000000000000000000002141526721631600164470ustar00rootroot00000000000000#pragma once #include namespace bpftrace { class BuildInfo { public: static std::string report(); }; } // namespace bpftrace bpftrace-0.27.1/src/config.cpp000066400000000000000000000324331526721631600161450ustar00rootroot00000000000000#include #include #include #include #include #include "config.h" #include "log.h" #include "types.h" #include "util/int_parser.h" #include "util/strings.h" namespace bpftrace { char ParseError::ID; char RenameError::ID; char LicenseError::ID; void ParseError::log(llvm::raw_ostream &OS) const { OS << key_ << ": " << detail_; } void RenameError::log(llvm::raw_ostream &OS) const { OS << "key has been renamed to '" << name_ << "'"; } static const std::unordered_map BPF_LICENSE_STR = { { "GPL", GPL }, { "GPL v2", GPL_V2 }, { "GPL and additional rights", GPL_AR }, { "Dual BSD/GPL", DUAL_BSD_GPL }, { "Dual MIT/GPL", DUAL_MIT_GPL }, { "Dual MPL/GPL", DUAL_MPL_GPL } }; void LicenseError::log(llvm::raw_ostream &OS) const { OS << "Invalid value for license. Found: " << license() << ". Valid values: "; bool first = true; for (const auto &[k, v] : BPF_LICENSE_STR) { if (!first) { OS << ", "; } OS << k; first = false; } OS << ". Read more about BPF programs and licensing: " "https://docs.kernel.org/bpf/" "bpf_licensing.html#using-bpf-programs-in-the-linux-kernel"; } // /proc/sys/kernel/randomize_va_space >= 1 static bool is_aslr_enabled() { std::string randomize_va_space_file = "/proc/sys/kernel/randomize_va_space"; { std::ifstream file(randomize_va_space_file); if (file.fail()) { LOG(V1) << std::strerror(errno) << ": " << randomize_va_space_file; // conservatively return true return true; } std::string line; if (std::getline(file, line) && std::stoi(line) < 1) return false; } return true; } Config::Config(bool has_cmd) : user_symbol_cache_type((has_cmd || !is_aslr_enabled()) ? UserSymbolCacheType::per_program : UserSymbolCacheType::per_pid) {}; template <> struct ConfigParser { Result parse(const std::string &key, uint64_t *target, const std::string &s) { // If this can be parsed as a literal integer, then we take that. auto val = util::to_uint(s); if (!val) { return make_error(key, "expecting a number, got " + s); } *target = *val; return OK(); } Result parse([[maybe_unused]] const std::string &key, uint64_t *target, uint64_t v) { *target = v; return OK(); } }; template <> struct ConfigParser { Result parse(const std::string &key, bool *target, const std::string &original) { if (util::is_str_bool_truthy(original)) { *target = true; return OK(); } else if (util::is_str_bool_falsy(original)) { *target = false; return OK(); } else { return make_error( key, "Invalid bool value: valid values are true, false, 1 or 0."); } } Result parse([[maybe_unused]] const std::string &key, bool *target, uint64_t v) { if (v != 0) { *target = true; return OK(); } else { *target = false; return OK(); } } }; template <> struct ConfigParser { Result parse([[maybe_unused]] const std::string &key, std::string *target, const std::string &s) { *target = s; return OK(); } Result parse([[maybe_unused]] const std::string &key, std::string *target, uint64_t v) { std::stringstream ss; ss << v; *target = ss.str(); return OK(); } }; template <> struct ConfigParser { Result parse(const std::string &key, UserSymbolCacheType *target, const std::string &original) { std::string s = util::to_lower(original); if (s == "1") { return OK(); // Leave as the default. } else if (s == "per_pid") { *target = UserSymbolCacheType::per_pid; return OK(); } else if (s == "per_program") { *target = UserSymbolCacheType::per_program; return OK(); } else if (s == "none" || s == "0") { *target = UserSymbolCacheType::none; return OK(); } else { return make_error( key, "Invalid value for cache_user_symbols: valid values are PER_PID, " "PER_PROGRAM, and NONE."); } } Result parse([[maybe_unused]] const std::string &key, UserSymbolCacheType *target, uint64_t v) { if (v == 0) { *target = UserSymbolCacheType::none; return OK(); } else { // Leave as the default. return OK(); } } }; template <> struct ConfigParser { Result parse(const std::string &key, ConfigMissingProbes *target, const std::string &original) { std::string s = util::to_lower(original); if (s == "ignore") { *target = ConfigMissingProbes::ignore; return OK(); } else if (s == "warn") { *target = ConfigMissingProbes::warn; return OK(); } else if (s == "error") { *target = ConfigMissingProbes::error; return OK(); } else { return make_error(key, "Invalid value for missing_probes: valid " "values are ignore, warn, and error."); } } Result parse(const std::string &key, [[maybe_unused]] ConfigMissingProbes *target, [[maybe_unused]] uint64_t v) { return make_error(key, "Invalid value for missing_probes: valid " "values are ignore, warn, and error."); } }; template <> struct ConfigParser { Result parse([[maybe_unused]] const std::string &key, CompatibleBPFLicense *target, const std::string &original) { auto found = BPF_LICENSE_STR.find(original); if (found == BPF_LICENSE_STR.end()) { return make_error(original); } *target = found->second; return OK(); } Result parse([[maybe_unused]] const std::string &key, [[maybe_unused]] CompatibleBPFLicense *target, uint64_t v) { return make_error(std::to_string(v)); } }; template <> struct ConfigParser { Result parse(const std::string &key, ConfigUnstable *target, const std::string &original) { std::string s = util::to_lower(original); if (s == "enable" || util::is_str_bool_truthy(original)) { *target = ConfigUnstable::enable; return OK(); } else if (s == "warn") { *target = ConfigUnstable::warn; return OK(); } else if (s == "error" || util::is_str_bool_falsy(original)) { *target = ConfigUnstable::error; return OK(); } else { return make_error(key, "Invalid value for unstable config: valid " "values are enable, warn, and error."); } } Result parse([[maybe_unused]] const std::string &key, [[maybe_unused]] ConfigUnstable *target, [[maybe_unused]] uint64_t v) { if (v != 0) { *target = ConfigUnstable::enable; return OK(); } else { *target = ConfigUnstable::error; return OK(); } } }; struct AnyParser { using KeyType = const std::string &; std::function(KeyType, Config *, uint64_t)> integer; std::function(KeyType, Config *, const std::string &)> string; }; template AnyParser parser(T fn) { // The passed function should return a pointer to the field. We extract // the type of the returned field, and match against the parser. using R = std::remove_pointer_t(nullptr)))>; return AnyParser{ .integer = [fn](const std::string &k, Config *c, uint64_t value) { ConfigParser parser; return parser.parse(k, fn(c), value); }, .string = [fn](const std::string &k, Config *c, const std::string &s) { ConfigParser parser; return parser.parse(k, fn(c), s); }, }; } // This map construsts all the different parsers. #define CONFIG_FIELD_PARSER(x) parser([](Config *config) { return &config->x; }) const std::map CONFIG_KEY_MAP = { { "cache_user_symbols", CONFIG_FIELD_PARSER(user_symbol_cache_type) }, { "cpp_demangle", CONFIG_FIELD_PARSER(cpp_demangle) }, { "lazy_symbolication", CONFIG_FIELD_PARSER(lazy_symbolication) }, { "license", CONFIG_FIELD_PARSER(license) }, { "log_size", CONFIG_FIELD_PARSER(log_size) }, { "max_bpf_progs", CONFIG_FIELD_PARSER(max_bpf_progs) }, { "max_cat_bytes", CONFIG_FIELD_PARSER(max_cat_bytes) }, { "max_map_keys", CONFIG_FIELD_PARSER(max_map_keys) }, { "max_probes", CONFIG_FIELD_PARSER(max_probes) }, { "max_strlen", CONFIG_FIELD_PARSER(max_strlen) }, { "on_stack_limit", CONFIG_FIELD_PARSER(on_stack_limit) }, { "perf_rb_pages", CONFIG_FIELD_PARSER(perf_rb_pages) }, { "stack_mode", CONFIG_FIELD_PARSER(stack_mode) }, { "str_trunc_trailer", CONFIG_FIELD_PARSER(str_trunc_trailer) }, { "missing_probes", CONFIG_FIELD_PARSER(missing_probes) }, { "print_maps_on_exit", CONFIG_FIELD_PARSER(print_maps_on_exit) }, { "use_blazesym", CONFIG_FIELD_PARSER(use_blazesym) }, { "show_debug_info", CONFIG_FIELD_PARSER(show_debug_info) }, { UNSTABLE_IMPORT_STATEMENT, CONFIG_FIELD_PARSER(unstable_import_statement) }, { UNSTABLE_TSERIES, CONFIG_FIELD_PARSER(unstable_tseries) }, { UNSTABLE_TYPEINFO, CONFIG_FIELD_PARSER(unstable_typeinfo) }, { UNSTABLE_DW_USTACK, CONFIG_FIELD_PARSER(unstable_dw_ustack) }, }; // These symbols are deprecated, and have been remapped elsewhere. const std::map RENAMED = { { "strlen", "max_strlen" }, { "no_cpp_demangle", "cpp_demangle" }, { "cat_bytes_max", "max_cat_bytes" }, { "map_keys_max", "max_map_keys" }, }; // These are configuration names that are consumed elsewhere. We use this only // to check if we should produce a more helpful error for the user. const std::unordered_set ENV_ONLY = { "btf", "kernel_build", "kernel_source", "vmlinux", }; // This is applied for all environment variables, and will also be accepted // as part of the general configuration key (in lower case only). static const std::string ENV_PREFIX = "bpftrace_"; static std::string restore(const std::string &original_key) { std::string key = util::to_lower(original_key); if (key.starts_with(ENV_PREFIX)) { key = key.substr(ENV_PREFIX.length()); } return key; } static Result lookup(const std::string &original_key) { auto key = restore(original_key); auto it = CONFIG_KEY_MAP.find(key); if (it == CONFIG_KEY_MAP.end()) { auto dep = RENAMED.find(key); if (dep != RENAMED.end()) { return make_error(dep->second); } auto env = ENV_ONLY.find(key); if (env != ENV_ONLY.end()) { return make_error( original_key, "can only be set as an environment variable"); } return make_error(original_key, "not a known configuration option"); } return it->second; } Result Config::set(const std::string &original_key, const std::string &val) { auto parser = lookup(original_key); if (!parser) { return parser.takeError(); } return parser->string(original_key, this, val); } Result Config::set(const std::string &original_key, uint64_t val) { auto parser = lookup(original_key); if (!parser) { return parser.takeError(); } return parser->integer(original_key, this, val); } bool Config::is_unstable(const std::string &original_key) { const static std::string UNSTABLE_PREFIX = "unstable_"; auto key = restore(original_key); return key.starts_with(UNSTABLE_PREFIX); } Result Config::load_environment() { // Scan all known keys by their environment variable name, and if it is // present then set from the environment value. for (const auto &[key, _] : CONFIG_KEY_MAP) { std::string env = ENV_PREFIX + key; std::ranges::transform(env, env.begin(), [](unsigned char c) { return std::toupper(c); }); const auto *cenv = getenv(env.c_str()); if (cenv) { auto ok = set(key, std::string(cenv)); if (!ok) { return ok.takeError(); } } } return OK(); } std::string Config::get_license_str(CompatibleBPFLicense license) { for (const auto &[k, v] : BPF_LICENSE_STR) { if (v == license) { return k; } } LOG(BUG) << "License enum not in BPF_LICENSE_STR map"; return ""; } uint64_t Config::pad_max_strlen() const { // Note that the successful copying of a string will always include the // NULL byte, so we always add an extra byte to detect truncation. // Anything copied out of this will be copied as a str[N] type that may // omit the NUL byte (which indicates that it has been truncated). return max_strlen < 1024 ? max_strlen + 1 : max_strlen; } } // namespace bpftrace bpftrace-0.27.1/src/config.h000066400000000000000000000070131526721631600156060ustar00rootroot00000000000000#pragma once #include #include #include "types.h" #include "util/result.h" namespace bpftrace { enum class ConfigMissingProbes { ignore, warn, error, }; enum class ConfigUnstable { enable, warn, error, }; // Taken from here: // https://elixir.bootlin.com/linux/v5.16/source/include/linux/license.h enum CompatibleBPFLicense { GPL, GPL_V2, GPL_AR, DUAL_BSD_GPL, DUAL_MIT_GPL, DUAL_MPL_GPL }; static const auto UNSTABLE_IMPORT_STATEMENT = "unstable_import_statement"; static const auto UNSTABLE_TSERIES = "unstable_tseries"; static const auto UNSTABLE_TYPEINFO = "unstable_typeinfo"; static const auto UNSTABLE_DW_USTACK = "unstable_dw_ustack"; static std::unordered_set DEPRECATED_CONFIGS = { "symbol_source", "max_type_res_iterations", "unstable_addr", "unstable_import", "unstable_macro", "unstable_map_decl" }; class Config { public: Config(bool has_cmd = false); // Fields can be accessed directly via the callers, although care should be // taken not to mutate these fields unless the caller truly intends to change // them. The `set` method is provided for external users to set the values. Result set(const std::string &key, uint64_t val); Result set(const std::string &key, const std::string &val); // Helpers for analysis of variables. bool is_unstable(const std::string &key); Result load_environment(); static std::string get_license_str(CompatibleBPFLicense license); // All configuration options. bool cpp_demangle = true; bool lazy_symbolication = true; bool print_maps_on_exit = true; ConfigUnstable unstable_import_statement = ConfigUnstable::error; ConfigUnstable unstable_tseries = ConfigUnstable::warn; ConfigUnstable unstable_typeinfo = ConfigUnstable::error; ConfigUnstable unstable_dw_ustack = ConfigUnstable::warn; #ifdef HAVE_BLAZESYM bool use_blazesym = true; bool show_debug_info = true; #else bool use_blazesym = false; bool show_debug_info = false; #endif uint64_t log_size = 1000000; uint64_t max_bpf_progs = 1024; uint64_t max_cat_bytes = 10240; uint64_t max_map_keys = 4096; uint64_t max_probes = 1024; uint64_t max_strlen = 1024; uint64_t on_stack_limit = 32; uint64_t perf_rb_pages = 0; // See get_buffer_pages CompatibleBPFLicense license = CompatibleBPFLicense::GPL; std::string str_trunc_trailer = ".."; ConfigMissingProbes missing_probes = ConfigMissingProbes::error; StackMode stack_mode = StackMode::bpftrace; // Initialized in the constructor. UserSymbolCacheType user_symbol_cache_type; uint64_t pad_max_strlen() const; }; // Specific key has been renamed, must be handled by caller. This may be // returned by the `Config::set` method if a different key must be used to set // the value. This is explicitly propagated in order to ensure that the caller // can appropriately propagate this information to the user. class RenameError : public ErrorInfo { public: static char ID; RenameError(std::string &&name) : name_(std::move(name)) {}; void log(llvm::raw_ostream &OS) const override; // Returns the new key which must be used. const std::string &new_name() const { return name_; } private: std::string name_; }; class LicenseError : public ErrorInfo { public: static char ID; LicenseError(std::string license) : license_(std::move(license)) {}; void log(llvm::raw_ostream &OS) const override; const std::string &license() const { return license_; } private: std::string license_; }; } // namespace bpftrace bpftrace-0.27.1/src/config_parser.h000066400000000000000000000014351526721631600171640ustar00rootroot00000000000000#pragma once #include #include "util/result.h" namespace bpftrace { // If you want to be able to parse custom configuration, then simply // provide a specialization of the `ConfigParser` class that specifies // the implementation of the operators to parse any string and integers. template struct ConfigParser; // Generic parse error for a specific key. This should be returned by // the `ConfigParser` implementations if the value cannot be parsed. class ParseError : public ErrorInfo { public: static char ID; ParseError(std::string key, std::string &&detail) : key_(std::move(key)), detail_(std::move(detail)) {}; void log(llvm::raw_ostream &OS) const override; private: std::string key_; std::string detail_; }; } // namespace bpftrace bpftrace-0.27.1/src/cxxdemangler/000077500000000000000000000000001526721631600166505ustar00rootroot00000000000000bpftrace-0.27.1/src/cxxdemangler/CMakeLists.txt000066400000000000000000000001741526721631600214120ustar00rootroot00000000000000add_library(cxxdemangler_stdlib STATIC cxxdemangler_stdlib.cpp) add_library(cxxdemangler_llvm STATIC cxxdemangler_llvm.cpp) bpftrace-0.27.1/src/cxxdemangler/cxxdemangler.h000066400000000000000000000002511526721631600215000ustar00rootroot00000000000000#pragma once namespace bpftrace { // Demangle a mangled C++ symbol name // // Note: callee `free()`ed char* cxxdemangle(const char* mangled); } // namespace bpftrace bpftrace-0.27.1/src/cxxdemangler/cxxdemangler_llvm.cpp000066400000000000000000000003501526721631600230650ustar00rootroot00000000000000#include "cxxdemangler.h" #include #include namespace bpftrace { char* cxxdemangle(const char* mangled) { return llvm::itaniumDemangle(mangled); } } // namespace bpftrace bpftrace-0.27.1/src/cxxdemangler/cxxdemangler_stdlib.cpp000066400000000000000000000003141526721631600233740ustar00rootroot00000000000000#include "cxxdemangler.h" #include namespace bpftrace { char* cxxdemangle(const char* mangled) { return abi::__cxa_demangle(mangled, nullptr, nullptr, nullptr); } } // namespace bpftrace bpftrace-0.27.1/src/debugfs/000077500000000000000000000000001526721631600156065ustar00rootroot00000000000000bpftrace-0.27.1/src/debugfs/CMakeLists.txt000066400000000000000000000000561526721631600203470ustar00rootroot00000000000000add_library(debugfs STATIC debugfs.cpp ) bpftrace-0.27.1/src/debugfs/debugfs.cpp000066400000000000000000000004071526721631600177320ustar00rootroot00000000000000#include #include "debugfs.h" namespace bpftrace::debugfs { #define DEBUGFS "/sys/kernel/debug" std::string path() { return DEBUGFS; } std::string path(const std::string &file) { return path() + "/" + file; } } // namespace bpftrace::debugfs bpftrace-0.27.1/src/debugfs/debugfs.h000066400000000000000000000003621526721631600173770ustar00rootroot00000000000000#pragma once #include namespace bpftrace::debugfs { std::string path(); std::string path(const std::string &file); inline std::string kprobes_blacklist() { return path("kprobes/blacklist"); } } // namespace bpftrace::debugfs bpftrace-0.27.1/src/disasm.cpp000066400000000000000000000007561526721631600161630ustar00rootroot00000000000000#include "disasm.h" #include "bfd-disasm.h" namespace bpftrace { class DummyDisasm : public IDisasm { AlignState is_aligned(uint64_t offset __attribute__((unused)), uint64_t pc __attribute__((unused))) override { return AlignState::NotSupp; } }; Disasm::Disasm(std::string &path __attribute__((unused))) { #ifdef HAVE_BFD_DISASM dasm_ = std::make_unique(path); #else dasm_ = std::make_unique(); #endif } } // namespace bpftrace bpftrace-0.27.1/src/disasm.h000066400000000000000000000007701526721631600156240ustar00rootroot00000000000000#pragma once #include #include #include namespace bpftrace { enum class AlignState { Ok, Fail, NotAlign, NotSupp }; class IDisasm { public: virtual AlignState is_aligned(uint64_t offset, uint64_t pc) = 0; virtual ~IDisasm() = default; }; class Disasm { public: Disasm(std::string &path); AlignState is_aligned(uint64_t offset, uint64_t pc) { return dasm_->is_aligned(offset, pc); } private: std::unique_ptr dasm_; }; } // namespace bpftrace bpftrace-0.27.1/src/dwarf/000077500000000000000000000000001526721631600152725ustar00rootroot00000000000000bpftrace-0.27.1/src/dwarf/dwunwind.cpp000066400000000000000000000665241526721631600176520ustar00rootroot00000000000000#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overread" #include #pragma GCC diagnostic pop #include #include #include #include #include #include "dwarf/dwunwind.h" #include "dwarf/dwunwind_table.h" #include "log.h" #include "llvm/ADT/StringExtras.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" #include "llvm/Object/BuildID.h" #include "llvm/Object/ELFObjectFile.h" #include "llvm/Object/ObjectFile.h" #include #include "stdlib/stack/dwunwind_defs.h" const int CFT_ENTRY_SIZE = 228; const int CHUNK_SIZE = 256 * 1024; std::ostream &operator<<(std::ostream &os, const DWARFError &err) { switch (err) { case DWARFError::Success: os << "Success"; break; case DWARFError::FileNotFound: os << "FileNotFound"; break; case DWARFError::ParseError: os << "ParseError"; break; case DWARFError::UnsupportedFormat: os << "UnsupportedFormat"; break; case DWARFError::InternalError: os << "InternalError"; break; case DWARFError::TooManyObjects: os << "TooManyObjects"; break; default: os << "UnknownError"; break; } return os; } static void append_u8(std::vector &buf, uint8_t val) { if (buf.capacity() < buf.size() + 1) LOG(BUG) << "append_u8: buffer overflow"; buf.emplace_back(val); } static void append_u32(std::vector &buf, uint32_t val) { if (buf.capacity() < buf.size() + 4) LOG(BUG) << "append_u32: buffer overflow"; buf.emplace_back(static_cast(val & 0xff)); buf.emplace_back(static_cast((val >> 8) & 0xff)); buf.emplace_back(static_cast((val >> 16) & 0xff)); buf.emplace_back(static_cast((val >> 24) & 0xff)); } static void append_u64(std::vector &buf, uint64_t val) { if (buf.capacity() < buf.size() + 8) LOG(BUG) << "append_u64: buffer overflow"; buf.emplace_back(static_cast(val & 0xff)); buf.emplace_back(static_cast((val >> 8) & 0xff)); buf.emplace_back(static_cast((val >> 16) & 0xff)); buf.emplace_back(static_cast((val >> 24) & 0xff)); buf.emplace_back(static_cast((val >> 32) & 0xff)); buf.emplace_back(static_cast((val >> 40) & 0xff)); buf.emplace_back(static_cast((val >> 48) & 0xff)); buf.emplace_back(static_cast((val >> 56) & 0xff)); } static std::optional expr_get(const std::vector &expr_u8, size_t size, size_t &ix) { if (ix + size > expr_u8.size()) return std::nullopt; uint64_t v = 0; for (size_t j = 0; j < size; ++j) { v |= static_cast(expr_u8[ix + j]) << (j * 8); } return v; } static std::optional expr_get_leb(const std::vector &expr_u8, bool is_signed, size_t &ix) { uint64_t result = 0; unsigned shift = 0; uint8_t byte; while (true) { if (ix >= expr_u8.size()) return std::nullopt; byte = expr_u8[ix++]; result |= static_cast(byte & 0x7f) << shift; shift += 7; if ((byte & 0x80) == 0) break; } // sign extend if (is_signed && (shift < 64) && (byte & 0x40)) result |= -(1ULL << shift); return result; } // returns nullopt or error string static std::optional convert_expression( const std::vector &expr_u8, std::vector &eout) { eout.emplace_back(0); // placeholder for number of instructions uint64_t u; std::optional v; size_t i = 0; uint8_t nexpr = 0; while (i < expr_u8.size()) { if (nexpr == MAX_EXPR_INSTRUCTIONS) { return std::make_optional("DWARF expression too long"); } ++nexpr; uint8_t op = expr_u8[i++]; switch (op) { case llvm::dwarf::DW_OP_addr: // XXX handle 32 bit case v = expr_get(expr_u8, 8, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_deref: append_u8(eout, EXPR_OP_DEREF); break; case llvm::dwarf::DW_OP_const1u: v = expr_get(expr_u8, 1, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_const1s: v = expr_get(expr_u8, 1, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, static_cast(v.value())); break; case llvm::dwarf::DW_OP_const2u: v = expr_get(expr_u8, 2, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_const2s: v = expr_get(expr_u8, 2, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, static_cast(v.value())); break; case llvm::dwarf::DW_OP_const4u: v = expr_get(expr_u8, 4, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_const4s: v = expr_get(expr_u8, 4, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, static_cast(v.value())); break; case llvm::dwarf::DW_OP_const8u: case llvm::dwarf::DW_OP_const8s: v = expr_get(expr_u8, 8, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_constu: v = expr_get_leb(expr_u8, false, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_consts: v = expr_get_leb(expr_u8, true, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_lit0... llvm::dwarf::DW_OP_lit31: u = op - llvm::dwarf::DW_OP_lit0; append_u8(eout, EXPR_OP_CONST); append_u64(eout, u); break; case llvm::dwarf::DW_OP_reg0... llvm::dwarf::DW_OP_reg31: u = op - llvm::dwarf::DW_OP_reg0; append_u8(eout, EXPR_OP_BREG); append_u8(eout, u); append_u64(eout, 0); break; case llvm::dwarf::DW_OP_breg0... llvm::dwarf::DW_OP_breg31: u = op - llvm::dwarf::DW_OP_breg0; v = expr_get_leb(expr_u8, true, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_BREG); append_u8(eout, u); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_and: append_u8(eout, EXPR_OP_AND); break; case llvm::dwarf::DW_OP_ge: append_u8(eout, EXPR_OP_GE); break; case llvm::dwarf::DW_OP_shl: append_u8(eout, EXPR_OP_SHL); break; case llvm::dwarf::DW_OP_plus: append_u8(eout, EXPR_OP_PLUS); break; case llvm::dwarf::DW_OP_mul: append_u8(eout, EXPR_OP_MUL); break; case llvm::dwarf::DW_OP_plus_uconst: v = expr_get_leb(expr_u8, false, i); if (!v.has_value()) goto invalid_expression; append_u8(eout, EXPR_OP_PLUS_CONST); append_u64(eout, v.value()); break; case llvm::dwarf::DW_OP_addrx: case llvm::dwarf::DW_OP_call2: case llvm::dwarf::DW_OP_call4: case llvm::dwarf::DW_OP_call_ref: case llvm::dwarf::DW_OP_const_type: case llvm::dwarf::DW_OP_constx: case llvm::dwarf::DW_OP_convert: case llvm::dwarf::DW_OP_deref_type: case llvm::dwarf::DW_OP_regval_type: case llvm::dwarf::DW_OP_reinterpret: case llvm::dwarf::DW_OP_push_object_address: case llvm::dwarf::DW_OP_call_frame_cfa: return std::make_optional("DWARF expression op 0x" + llvm::utohexstr(op, true) + " not allowed"); default: return std::make_optional("DWARF expression op 0x" + llvm::utohexstr(op, true) + " not implemented"); } } eout[0] = nexpr; return std::nullopt; invalid_expression: return std::make_optional("invalid expression"); } std::optional DWARFUnwind::add_expression(llvm::DWARFExpression &expr) { auto expr_bytes = expr.getData(); auto expr_u8 = std::vector(expr_bytes.begin(), expr_bytes.end()); auto it = expressions_.find(expr_u8); if (it != expressions_.end()) return it->second; uint32_t id = expressions_.size(); expressions_[expr_u8] = id; // // preprocess expression to simplify bpf code // mainly we expand all arguments to 64 bits (registers to 8 bits) // std::vector expr_out; expr_out.reserve(256); auto error = convert_expression(expr_u8, expr_out); if (error.has_value()) { LOG(ERROR) << "Failed to convert DWARF expression: " << error.value(); return std::nullopt; } expr_out.resize(256, 0); if (table_feed_cb_(TableType::Expressions, id, expr_out)) return std::nullopt; return id; } DWARFError DWARFUnwind::add_object_file(const std::string &filename) { uint32_t out_oid; auto ret = add_file_nopush(filename, -1, out_oid); if (ret != DWARFError::Success) return ret; return push_current_table(); } std::string DWARFUnwind::resolve_path(const std::string &filename, int pid) { if (pid >= 0) return "/proc/" + std::to_string(pid) + "/root/" + filename; return filename; } std::string DWARFUnwind::file_cache_key(const std::string &filename, int pid) { auto resolved = resolve_path(filename, pid); auto expectedBinary = llvm::object::createBinary(resolved); if (expectedBinary) { auto *bin = expectedBinary.get().getBinary(); auto *obj = llvm::dyn_cast(bin); if (obj) { auto build_id = llvm::object::getBuildID(obj); if (!build_id.empty()) { return "buildid:" + llvm::toHex(build_id); } } } else { llvm::consumeError(expectedBinary.takeError()); } // Fallback: original pathname + size + mtime struct stat st; if (stat(resolved.c_str(), &st) == 0) { return filename + ":" + std::to_string(st.st_size) + ":" + std::to_string(st.st_mtim.tv_sec); } return filename; } DWARFError DWARFUnwind::add_file_nopush(const std::string &filename, int pid, uint32_t &out_oid) { auto key = file_cache_key(filename, pid); auto f = files_seen_.find(key); if (f != files_seen_.end()) { if (!f->second.has_value()) return DWARFError::ParseError; out_oid = *f->second; return DWARFError::Success; } DWARFError err = add_new_file(filename, pid, out_oid); if (err != DWARFError::Success) { files_seen_[key] = std::nullopt; } else { files_seen_[key] = out_oid; } return err; } // Template function to handle specific ELF bit-widths and endianness template void build_map_offsets(const llvm::object::ELFObjectFile *Obj, std::map &map_offsets) { for (const auto &Section : Obj->sections()) { const typename ELFT::Shdr *header = Obj->getSection( Section.getRawDataRefImpl()); if ((header->sh_flags & llvm::ELF::SHF_ALLOC) == 0) continue; // Skip non-allocated sections if (header->sh_addr == header->sh_offset) continue; map_offsets[header->sh_addr] = header->sh_addr - header->sh_offset; } } DWARFError DWARFUnwind::add_new_file(const std::string &filename, int pid, uint32_t &out_oid) { auto oid = next_oid_; if (oid == UINT16_MAX) { LOG(ERROR) << "Maximum number of object IDs reached."; return DWARFError::TooManyObjects; } if (oid == 0) { std::vector empty; empty.resize(CFT_ENTRY_SIZE, 0); if (table_feed_cb_(TableType::UnwindEntries, 0, empty)) return DWARFError::InternalError; } ++next_oid_; out_oid = oid; auto fn = resolve_path(filename, pid); LOG(V1) << "Adding file " << fn << " with OID " << oid; auto ExpectedBinary = llvm::object::createBinary(fn); if (!ExpectedBinary) { LOG(ERROR) << "Cannot open " << fn << " to extract stack walk information"; return DWARFError::FileNotFound; } auto *Bin = ExpectedBinary.get().getBinary(); auto *Obj = llvm::dyn_cast(Bin); if (!Obj) return DWARFError::UnsupportedFormat; std::map map_offsets; if (auto *ELF64LE = llvm::dyn_cast(Obj)) { build_map_offsets(ELF64LE, map_offsets); } else if (auto *ELF64BE = llvm::dyn_cast( Obj)) { build_map_offsets(ELF64BE, map_offsets); } else if (auto *ELF32LE = llvm::dyn_cast( Obj)) { build_map_offsets(ELF32LE, map_offsets); } else if (auto *ELF32BE = llvm::dyn_cast( Obj)) { build_map_offsets(ELF32BE, map_offsets); } else { LOG(V1) << "Not a recognized ELF object file."; return DWARFError::UnsupportedFormat; } return read_eh_frame(fn, oid, map_offsets); } #if LLVM_VERSION_MAJOR >= 21 static DWARFError not_implemented(const std::string &filename, const std::string &enc) { LOG(ERROR) << "DWARF encoding " << enc << " not supported in file " << filename; return DWARFError::ParseError; } #endif DWARFError DWARFUnwind::push_current_table() { if (current_table_.empty()) return DWARFError::Success; auto ext_table = current_table_; ext_table.resize(CHUNK_SIZE, 0); if (table_feed_cb_(TableType::UnwindTable, current_table_id_, ext_table)) return DWARFError::InternalError; return DWARFError::Success; } DWARFError DWARFUnwind::read_eh_frame( const std::string &filename, uint32_t oid, const std::map &map_offsets) { #if LLVM_VERSION_MAJOR >= 21 auto ExpectedBinary = llvm::object::createBinary(filename); if (!ExpectedBinary) return DWARFError::FileNotFound; auto *Bin = ExpectedBinary.get().getBinary(); auto *Obj = llvm::dyn_cast(Bin); if (!Obj) return DWARFError::UnsupportedFormat; auto DICtx = llvm::DWARFContext::create(*Obj); llvm::Expected FrameOrErr = nullptr; if (!DICtx->getDWARFObj().getEHFrameSection().Data.empty()) { FrameOrErr = DICtx->getEHFrame(); } else { FrameOrErr = DICtx->getDebugFrame(); } if (!FrameOrErr) { LOG(ERROR) << "object " << filename << " does not contain a .eh_frame " "or .debug_frame section, can't extract information for " "stack walking"; return DWARFError::ParseError; } const llvm::DWARFDebugFrame *Frame = *FrameOrErr; int fdeCount = 0; int rowCount = 0; std::map rows; std::vector s; s.reserve(CFT_ENTRY_SIZE); std::vector rs; rs.reserve(12); for (const auto &Entry : Frame->entries()) { if (Entry.getKind() == llvm::dwarf::FrameEntry::FK_FDE) { fdeCount++; const auto *fde = llvm::cast(&Entry); // find the largest mapping offset <= initial location uint64_t map_offset = 0; auto map_it = map_offsets.lower_bound(fde->getInitialLocation() + 1); if (map_it != map_offsets.begin()) { --map_it; map_offset = map_it->second; } auto table = llvm::dwarf::createUnwindTable(fde); for (const auto &row : *table) { ++rowCount; if (!row.hasAddress()) { LOG(V1) << "Row has no address."; return DWARFError::ParseError; } auto locations = row.getRegisterLocations(); if (!locations.hasLocations()) { LOG(V1) << "Row has no register locations."; return DWARFError::ParseError; } s.clear(); #ifdef notyet // Current llvm doesn't give us access to DW_CFA_GNU_args_size // It is also unclear to me atm when exactly we need to account // for it // https://github.com/llvm/llvm-project/issues/176318 append_u64(s, row.getGnuArgsSize()); #else append_u64(s, 0); #endif /* * convert row into the format used by our eBPF program */ auto cfa = row.getCFAValue(); if (cfa.getDereference()) { LOG(V1) << "CFA dereference not supported."; return DWARFError::ParseError; } switch (cfa.getLocation()) { case llvm::dwarf::UnwindLocation::RegPlusOffset: { append_u32(s, 1); append_u32(s, cfa.getRegister()); append_u64(s, cfa.getOffset()); break; } case llvm::dwarf::UnwindLocation::DWARFExpr: { auto expr_opt = cfa.getDWARFExpressionBytes(); if (!expr_opt.has_value()) { LOG(V1) << "Missing DWARF expression bytes for CFA."; return DWARFError::ParseError; } auto expr_id = add_expression(expr_opt.value()); if (!expr_id.has_value()) { return DWARFError::ParseError; } append_u32(s, 2); append_u32(s, *expr_id); append_u64(s, 0); break; } default: LOG(V1) << "Unsupported CFA location type."; return DWARFError::ParseError; } std::vector> reg_rules(NUM_REGISTERS); for (uint32_t reg : locations.getRegisters()) { auto loc_opt = locations.getRegisterLocation(reg); if (!loc_opt.has_value()) { LOG(V1) << "Missing location for register " << reg; continue; } auto loc = loc_opt.value(); if (reg >= NUM_REGISTERS) { LOG(V1) << "Register " << reg << " out of range."; continue; } rs.clear(); switch (loc.getLocation()) { case llvm::dwarf::UnwindLocation::Unspecified: LOG(V1) << "Unspecified location not expected."; continue; case llvm::dwarf::UnwindLocation::Undefined: append_u32(rs, 1); append_u64(rs, 0); break; case llvm::dwarf::UnwindLocation::Same: append_u32(rs, 2); append_u64(rs, 0); break; case llvm::dwarf::UnwindLocation::CFAPlusOffset: if (loc.getDereference()) { append_u32(rs, 3); // offset(N) } else { append_u32(rs, 4); // val_offset(N) } append_u64(rs, loc.getOffset()); break; case llvm::dwarf::UnwindLocation::RegPlusOffset: if (loc.getOffset() != 0) return not_implemented(filename, "RegPlusOffset with non-zero offset"); append_u32(rs, 5); // register(R) append_u64(rs, loc.getRegister()); break; case llvm::dwarf::UnwindLocation::DWARFExpr: { auto expr_opt = loc.getDWARFExpressionBytes(); if (!expr_opt.has_value()) { LOG(V1) << "Missing DWARF expression bytes for register."; continue; } auto expr_id = add_expression(expr_opt.value()); if (!expr_id.has_value()) { return DWARFError::ParseError; } if (loc.getDereference()) append_u32(rs, 6); // expression(E) else append_u32(rs, 7); // val_expression(E) append_u64(rs, *expr_id); break; } case llvm::dwarf::UnwindLocation::Constant: append_u32(rs, 8); append_u64(rs, loc.getOffset()); break; default: return not_implemented(filename, "location type " + loc.getLocation()); } reg_rules[reg] = rs; } for (int reg = 0; reg < NUM_REGISTERS; reg++) { if (reg_rules[reg].empty()) { // default to unspecifed append_u32(s, 0); append_u64(s, 0); } else { s.insert(s.end(), reg_rules[reg].begin(), reg_rules[reg].end()); } } if (s.size() != CFT_ENTRY_SIZE) { LOG(V1) << "Serialized row size " << s.size() << " does not match expected " << CFT_ENTRY_SIZE << " bytes."; return DWARFError::InternalError; } auto it = entries_.find(s); uint32_t id; if (it != entries_.end()) { id = it->second; } else { id = entries_.size() + 1; // reserve 0 for no entry entries_[s] = id; if (table_feed_cb_(TableType::UnwindEntries, id, s)) return DWARFError::InternalError; } auto start = row.getAddress() - map_offset; // start may override end // start may not override start // end overrides nothing // in case an FDE ends with advance_loc(0), we may have duplicate // entries auto r = rows.find(start); if (r != rows.end() && r->second != 0 && r->second != id) { LOG(V1) << "Start address " << std::hex << start << " already exists in rows" << std::dec; // XXX error out? } rows[start] = id; } auto end = fde->getInitialLocation() + fde->getAddressRange() - map_offset; auto r = rows.find(end); if (r == rows.end()) rows[end] = 0; } } if (fdeCount == 0) { LOG(WARNING) << "object " << filename << " does not contain information for stack walking"; } LOG(V1) << "Summary: Found " << fdeCount << " FDEs and " << rowCount << " rows."; LOG(V1) << "expressions: " << expressions_.size() << ", entries: " << entries_.size() << ", rows: " << rows.size(); std::vector> table_entries; for (const auto &row : rows) { table_entries.emplace_back(row.first, row.second); } size_t start = 0; while (start < table_entries.size()) { size_t out_entries = 0; auto sz = CHUNK_SIZE - current_table_.size() - 16; auto table_data = dwunwind_build_table( table_entries, start, sz, out_entries); LOG(V1) << "Built table chunk with " << out_entries << " entries, size " << table_data.size() << " bytes."; auto e = table_mappings_.emplace(oid, std::vector{}); e.first->second.push_back( TableMapping{ .file_offset = table_entries[start].first, .table_id = current_table_id_, .table_offset = current_table_.size() }); if (current_table_.empty()) { swap(current_table_, table_data); } else { current_table_.insert(current_table_.end(), table_data.begin(), table_data.end()); } if (current_table_.size() >= CHUNK_SIZE - 200) { auto push_ret = push_current_table(); if (push_ret != DWARFError::Success) return push_ret; current_table_.clear(); ++current_table_id_; } start += out_entries; } return DWARFError::Success; #else // avoid unused parameter warnings when DWARF_UNWIND is not defined (void)filename; (void)oid; (void)map_offsets; return DWARFError::UnsupportedFormat; #endif } struct ProcessMapEntry { uint64_t vm_start; uint64_t vm_end; uint64_t offset; std::string file_path; }; std::vector read_process_maps(int pid) { std::vector maps; std::string filename = "/proc/" + std::to_string(pid) + "/maps"; std::ifstream file(filename); if (!file.is_open()) return maps; std::string line; while (std::getline(file, line)) { std::istringstream iss(line); std::uintptr_t start = 0; std::uintptr_t end = 0; std::uint64_t offset = 0; unsigned long inode = 0; char dash = 0; std::string perms; std::string dev; std::string path; if (iss >> std::hex >> start >> dash >> end >> perms >> offset >> dev >> std::dec >> inode) { iss >> std::ws; // Read the remainder of the line as the path if (std::getline(iss, path) && !path.empty()) { if (!(path[0] == '/')) continue; if (perms.find("x") == std::string::npos) continue; if (path.size() > 10 && path.substr(path.size() - 10) == " (deleted)") { LOG(ERROR) << "object not available: " << path; continue; } maps.emplace_back(ProcessMapEntry{ .vm_start = start, .vm_end = end, .offset = offset, .file_path = std::move(path) }); } } } return maps; } DWARFError DWARFUnwind::add_pid(pid_t pid) { auto maps = read_process_maps(pid); // output mapping vector, reserve room for nentries record at the beginning std::vector s = { 0, 0, 0, 0, 0, 0, 0, 0 }; int num_entries = 0; s.reserve((MAX_MAPPINGS * 24) + 8); for (const auto &map : maps) { uint32_t oid; auto err = add_file_nopush(map.file_path, pid, oid); if (err != DWARFError::Success) { LOG(V1) << "File " << map.file_path << " not added: Error " << err; return err; } auto e = table_mappings_.find(oid); if (e == table_mappings_.end()) { LOG(V1) << "No table mapping found for OID " << oid; continue; } auto mapping = e->second; auto map_offset_end = map.offset + (map.vm_end - map.vm_start); for (const auto &me : mapping) { if (me.file_offset >= map_offset_end) { break; } if (me.file_offset < map.offset) { continue; } auto delta = me.file_offset - map.offset; auto start = map.vm_start + delta; auto offset = map.offset + delta; auto table_id = me.table_id; auto table_offset = me.table_offset; s.reserve(s.size() + 24); append_u64(s, start); append_u64(s, offset); append_u32(s, table_id); append_u32(s, table_offset); ++num_entries; } } auto push_ret = push_current_table(); if (push_ret != DWARFError::Success) return push_ret; // set number of entries at the beginning std::vector nentries; nentries.reserve(8); append_u64(nentries, num_entries); for (int i = 0; i < 8; i++) s[i] = nentries[i]; // fill up to expected size s.resize((MAX_MAPPINGS * 24) + 8, 0); if (table_feed_cb_(TableType::Mappings, pid, s)) return DWARFError::InternalError; return DWARFError::Success; } bpftrace-0.27.1/src/dwarf/dwunwind.h000066400000000000000000000042671526721631600173130ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" #define DWUNWIND_MAPPINGS "dwunwind_mappings" #define DWUNWIND_OFFSETMAPS "dwunwind_offsetmaps" #define DWUNWIND_CFTS "dwunwind_cfts" #define DWUNWIND_EXPRESSIONS "dwunwind_expressions" enum class DWARFError { Success = 0, FileNotFound, ParseError, UnsupportedFormat, InternalError, TooManyObjects, }; std::ostream &operator<<(std::ostream &os, const DWARFError &err); struct TableMapping { uint64_t file_offset; uint32_t table_id; uint64_t table_offset; }; enum class TableType { UnwindTable, UnwindEntries, Expressions, Mappings, }; class DWARFUnwind { public: using TableFeedCallback = std::function< int(TableType type, uint32_t key, const std::vector &value)>; DWARFUnwind(TableFeedCallback cb) { table_feed_cb_ = std::move(cb); } DWARFError add_object_file(const std::string &filename); DWARFError add_pid(pid_t pid); private: std::optional add_expression(llvm::DWARFExpression &expr); DWARFError add_new_file(const std::string &filename, int pid, uint32_t &out_oid); DWARFError add_file_nopush(const std::string &filename, int pid, uint32_t &out_oid); DWARFError push_current_table(); DWARFError read_eh_frame(const std::string &filename, uint32_t oid, const std::map &map_offsets); static std::string resolve_path(const std::string &filename, int pid); std::string file_cache_key(const std::string &filename, int pid); TableFeedCallback table_feed_cb_; uint32_t next_oid_{ 0 }; uint32_t current_table_id_{ 0 }; std::map, uint32_t> expressions_; std::map, uint32_t> entries_; std::unordered_map> table_mappings_; std::unordered_map tables_; std::vector current_table_; std::unordered_map> files_seen_; }; bpftrace-0.27.1/src/dwarf/dwunwind_loader.cpp000066400000000000000000000074451526721631600211750ustar00rootroot00000000000000#include "dwarf/dwunwind_loader.h" #include "bpfmap.h" #include "log.h" #include "util/result.h" namespace bpftrace { /* * Parse all DWARF unwind information here and buffer in RAM, so we * know how much space we need in the maps. Once dynamically allocated * hash maps are widely available, we can omit this step and directly * push to the maps in the step that is currently feed_dwarf_unwind(). */ int parse_dwarf_unwind( BpfBytecode &bytecode, const std::vector &pids, std::map>> &unwind_data, std::map> &unwind_mappings) { auto unwind = DWARFUnwind( [&unwind_data, &unwind_mappings](TableType t, uint32_t k, const std::vector &v) { if (t != TableType::Mappings) { if (!unwind_data.contains(t)) { unwind_data[t] = std::vector>(); } auto &table = unwind_data[t]; if (k < table.size()) { table[k] = v; } else if (k == table.size()) { table.emplace_back(v); } else { LOG(BUG) << "Unwind mapping key " << k << " out of order, expected " << table.size(); return -1; } } else { unwind_mappings[k] = v; } return 0; }); for (const auto &pid : pids) { auto ret = unwind.add_pid(pid); if (ret != DWARFError::Success) { LOG(ERROR) << "Failed to build unwind tables for pid " << pid << ": " << ret; return -1; } } // resize maps for (auto const &t : unwind_data) { Result<> ret = OK(); auto size = t.second.size(); if (t.first == TableType::UnwindTable) { ret = bytecode.getMap(DWUNWIND_OFFSETMAPS).resize(size); } else if (t.first == TableType::UnwindEntries) { ret = bytecode.getMap(DWUNWIND_CFTS).resize(size); } else if (t.first == TableType::Expressions) { ret = bytecode.getMap(DWUNWIND_EXPRESSIONS).resize(size); } else { LOG(BUG) << "Unknown table type: " << static_cast(t.first); return -1; } if (!ret) { LOG(BUG) << "Failed to resize unwind table: " << ret.takeError(); return -1; } } auto ret = bytecode.getMap(DWUNWIND_MAPPINGS).resize(unwind_mappings.size()); if (!ret) { LOG(BUG) << "Failed to resize unwind table: " << ret.takeError(); return -1; } return 0; } int feed_dwarf_unwind( BpfBytecode &bytecode, const std::map>> &unwind_data, const std::map> &unwind_mappings) { // update arrays for (auto const &t : unwind_data) { std::string name; const BpfMap *table; if (t.first == TableType::UnwindTable) { table = &bytecode.getMap(DWUNWIND_OFFSETMAPS); } else if (t.first == TableType::UnwindEntries) { table = &bytecode.getMap(DWUNWIND_CFTS); } else if (t.first == TableType::Expressions) { table = &bytecode.getMap(DWUNWIND_EXPRESSIONS); } else { LOG(BUG) << "Unknown table type: " << static_cast(t.first); return -1; } for (size_t i = 0; i < t.second.size(); i++) { auto ret = table->update_elem(&i, t.second[i].data()); if (!ret) { LOG(BUG) << "Failed to add unwind entry: " << ret.takeError(); return -1; } } } // unwind mappings are indexed by pid, so they are stored in a hash map auto table = bytecode.getMap(DWUNWIND_MAPPINGS); for (auto const &m : unwind_mappings) { auto ret = table.update_elem(&m.first, m.second.data()); if (!ret) { LOG(BUG) << "Failed to add unwind mapping: " << ret.takeError(); return -1; } } return 0; } } // namespace bpftrace bpftrace-0.27.1/src/dwarf/dwunwind_loader.h000066400000000000000000000011201526721631600206220ustar00rootroot00000000000000#pragma once #include #include #include #include "bpfbytecode.h" #include "dwarf/dwunwind.h" namespace bpftrace { int parse_dwarf_unwind( BpfBytecode &bytecode, const std::vector &pids, std::map>> &unwind_data, std::map> &unwind_mappings); int feed_dwarf_unwind( BpfBytecode &bytecode, const std::map>> &unwind_data, const std::map> &unwind_mappings); } // namespace bpftrace bpftrace-0.27.1/src/dwarf/dwunwind_table.cpp000066400000000000000000000235621526721631600210140ustar00rootroot00000000000000#include #include #include #include #include #include "log.h" // // Table entry format: // own key // left child ptr or leaf marker // own value // right subtree // left subtree // // key is relative to parent key // ptrs are offsets from end of current entry // a pointer marks whether it points to a leaf or not // // leaf node format: // own key // left key // left value // own value // right key // right value // // The tree can have one leaf in the tree that is not pointed to by a ptr, // thus not explicitly marked as leaf. If present, this is always the rightmost // leaf in the tree. All other leaves are full. // // incomplete leaf format; // own key (0 for empty leaf) // leaf marker (can be distinguished from ptrs) // left key (0 if no left entry) // left value // own value // right key (0 if no right entry) // right value // // encoding: // ptrs: we limit the table size to 2MB, so 21 bits // 00-CF: encode as 1 byte // D0-D8: first byte with 3 lower bits of value, followed by 2 bytes // (little-endian) // leaf ptrs: // D8-DF: first byte with 3 lower bits of value, followed by 2 bytes // (little-endian) // E0-FF: ptr as 1 byte // values: // 00-F6: encode as 1 byte // F8-FF: first byte with 3 lower bits of value, followed by 1 byte // F7 : followed by 3 bytes u64 // RelKey: // 00-DE: 1 byte, val + 111 // DF : followed by 8 bytes i64 (little-endian) // E0-FF: lower 5 bits, followed by 1 byte (little-endian) // // a ptr with value 0 is used to mark a leaf that is pointed to by a // non-leaf ptr // This can happen only for the last right child // // Maximum encodable table size is 256k // static std::vector enc_rel_key(int64_t rel_key) { auto ukey = static_cast(rel_key); if (rel_key >= -111 && rel_key <= 111) { return { static_cast(rel_key + 111) }; } else if (rel_key >= -0x1000 && rel_key < 0x1000) { return { static_cast(0xe0 | ((ukey >> 8) & 0x1f)), static_cast(ukey & 0xff) }; } else { return { 0xdf, static_cast(ukey & 0xff), static_cast((ukey >> 8) & 0xff), static_cast((ukey >> 16) & 0xff), static_cast((ukey >> 24) & 0xff), static_cast((ukey >> 32) & 0xff), static_cast((ukey >> 40) & 0xff), static_cast((ukey >> 48) & 0xff), static_cast((ukey >> 56) & 0xff) }; } } // returning an empty vector means the pointer is too large to encode static std::vector enc_rel_ptr(uint64_t rel_ptr) { if (rel_ptr <= 0xcf) { return { static_cast(rel_ptr) }; } else if (rel_ptr <= 0x3ffff) { return { static_cast(0xd0 | ((rel_ptr >> 16) & 0x07)), static_cast(rel_ptr & 0xff), static_cast(rel_ptr >> 8) }; } else { return {}; } } // returning an empty vector means the pointer is too large to encode static std::vector enc_rel_leaf_ptr(uint64_t rel_ptr) { if (rel_ptr <= 0x1f) { return { static_cast(0xe0 | rel_ptr) }; } else if (rel_ptr <= 0x3ffff) { return { static_cast(0xd8 | ((rel_ptr >> 16) & 0x07)), static_cast(rel_ptr & 0xff), static_cast(rel_ptr >> 8) }; } else { return {}; } } static std::vector enc_leaf_marker() { return { 0x00 }; } static std::vector enc_value(uint64_t val) { if (val <= 0xf6) { return { static_cast(val) }; } else if (val <= 0x3ff) { return { static_cast(0xf8 | ((val >> 8) & 0x07)), static_cast(val & 0xff) }; } else if (val <= 0xffffff) { return { 0xf7, static_cast((val >> 16) & 0xff), static_cast((val >> 8) & 0xff), static_cast(val & 0xff), }; } else { LOG(BUG) << "Encoding DWARF unwind table failed: value too large"; return {}; // unreachable } } static int push(std::vector& buf, const std::vector& data) { // insert in reverse order buf.insert(buf.end(), data.rbegin(), data.rend()); return data.size(); } struct BuildStats { uint64_t bytes_in_keys = 0; uint64_t bytes_in_values = 0; }; static std::optional build_recurse( BuildStats& stats, std::vector& buf, const std::vector>& entries, size_t start, size_t end, uint64_t parent_key, bool unmarked_leaf) { int n; // observations: // - due to the rules the split point is chosen, the left subtree will // always be full, so either a node has 2 full leaves or is a leaf itself // - if the left node is a leaf, the right also is // - if the left node is not a leaf, the right may be a leaf. As there is // no right pointer, we can't encode the leafness into the pointer, so // we encode it into the key // - the right node always immediately follows its parent, so we don't need // a right pointer // - to be able to calculate the forward pointers, we have to build from back // to front auto len = end - start; /* * leaf node */ if (len <= 3) { // [] // // a key of 0 means the entry is not valid // emitted back to front uint64_t own_key; if (len == 0) own_key = parent_key; // this entry is a dummy entry, choose it so it is 0 else if (len == 1) own_key = entries[start].first; else own_key = entries[start + 1].first; // right key/value if (len == 3) { n = push(buf, enc_value(entries[start + 2].second)); stats.bytes_in_values += n; n = push(buf, enc_rel_key(entries[start + 2].first - own_key)); stats.bytes_in_keys += n; } else { // dummy entry push(buf, enc_value(0)); push(buf, enc_rel_key(0)); } // own value if (len > 0) { auto own_value = entries[start + (len >= 2 ? 1 : 0)].second; n = push(buf, enc_value(own_value)); stats.bytes_in_values += n; } else { // dummy entry push(buf, enc_value(0)); } // left key/value if (len >= 2) { n = push(buf, enc_value(entries[start].second)); stats.bytes_in_values += n; n = push(buf, enc_rel_key(entries[start].first - own_key)); stats.bytes_in_keys += n; } else { // dummy entry push(buf, enc_value(0)); push(buf, enc_rel_key(0)); } // leaf marker if (unmarked_leaf) push(buf, enc_leaf_marker()); // own key if (len >= 1) { n = push(buf, enc_rel_key(own_key - parent_key)); stats.bytes_in_keys += n; } else { // dummy entry push(buf, enc_rel_key(0)); } return buf.size(); } /* * intermediate node */ // split point: find largest number that creates a tree with no empty pointers size_t split = 3; while ((2 * split) + 1 + 1 <= len) { split = (2 * split) + 1; } split += start; auto own_key = entries[split].first; auto own_value = entries[split].second; auto left_len = split - start; auto right_len = end - (split + 1); assert(left_len >= 3); auto left_is_leaf = left_len == 3; auto right_is_leaf = right_len <= 3; auto right_unmarked_leaf = right_is_leaf && !left_is_leaf; // // built from back to front // left subtree auto ret = build_recurse(stats, buf, entries, start, split, own_key, false); if (!ret.has_value()) return std::nullopt; auto left_ptr = ret.value(); // right subtree ret = build_recurse( stats, buf, entries, split + 1, end, own_key, right_unmarked_leaf); if (!ret.has_value()) return std::nullopt; // own value n = push(buf, enc_value(own_value)); stats.bytes_in_values += n; // left ptr std::vector enc_ptr; if (left_is_leaf) { enc_ptr = enc_rel_leaf_ptr(buf.size() - left_ptr); } else { enc_ptr = enc_rel_ptr(buf.size() - left_ptr); } if (enc_ptr.empty()) return std::nullopt; n = push(buf, enc_ptr); // own key n = push(buf, enc_rel_key(own_key - parent_key)); stats.bytes_in_keys += n; return buf.size(); } std::vector dwunwind_build_table( const std::vector>& entries, size_t start, size_t max_size, size_t& out_entries) { size_t left = 0; size_t right = entries.size() - start; size_t n = std::min(static_cast(max_size / 2.6), entries.size() - start); std::vector result_buf; size_t result_entries = 0; // find a number of entries that fills the available space well while (left < right) { BuildStats stats = {}; std::vector buf; auto ret = build_recurse(stats, buf, entries, start, start + n, 0, false); if (!ret.has_value()) { // this means the table is way too big, so we need to reduce the number of // entries. This should only happen if the initial estimate was way off, // so we can just drastically decrease the number of entries. right = n - 1; n = (left + right) / 2; continue; } auto diff = static_cast(buf.size()) - static_cast(max_size); auto adj = std::max(static_cast(labs(diff) / 2.6), static_cast(1)); if (buf.size() > max_size) { right = n - 1; n = std::max(n - adj, left); } else { std::swap(result_buf, buf); result_entries = n; left = n; n = std::min(n + adj, right); if (labs(diff) < 100) break; } } std::ranges::reverse(result_buf); out_entries = result_entries; if (result_entries > 0) return result_buf; else return {}; } bpftrace-0.27.1/src/dwarf/dwunwind_table.h000066400000000000000000000010101526721631600204410ustar00rootroot00000000000000#pragma once #include #include // Build the main table for dwarf unwinding. // This table maps a file offset into a specific elf file to an entry with // the actual unwind instructions. // Data is encoded as a compact binary tree suitable for lower bound style // lookups. // See dwunwind_table.cpp for details of the encoding. std::vector dwunwind_build_table( const std::vector>& entries, size_t start, size_t max_size, size_t& out_entries); bpftrace-0.27.1/src/dwarf_parser.cpp000066400000000000000000000454501526721631600173620ustar00rootroot00000000000000#include "dwarf_parser.h" namespace bpftrace { char DwarfParseError::ID; void DwarfParseError::log(llvm::raw_ostream &OS) const { OS << "DWARF error: " << msg_; } } // namespace bpftrace #ifdef HAVE_LIBDW #include "bpftrace.h" #include "log.h" #include "util/paths.h" #include #include #include namespace bpftrace { struct FuncInfo { std::string name; Dwarf_Die die; }; Dwarf::Dwarf(BPFtrace *bpftrace, const std::string &file_path, std::string debuginfo_path) : bpftrace_(bpftrace), file_path_(file_path), debuginfo_path_(std::move(debuginfo_path)) { debuginfo_path_cstr_ = debuginfo_path_.c_str(); callbacks.find_debuginfo = dwfl_standard_find_debuginfo; callbacks.section_address = dwfl_offline_section_address; callbacks.debuginfo_path = const_cast(&debuginfo_path_cstr_); dwfl = dwfl_begin(&callbacks); dwfl_report_offline(dwfl, file_path.c_str(), file_path.c_str(), -1); dwfl_report_end(dwfl, nullptr, nullptr); } static bool debug_alt_link_missing(::Dwarf *dwarf) { const char *alt_name = nullptr; const void *build_id = nullptr; return dwelf_dwarf_gnu_debugaltlink(dwarf, &alt_name, &build_id) > 0 && dwarf_getalt(dwarf) == nullptr; } std::unique_ptr Dwarf::GetFromBinary(BPFtrace *bpftrace, const std::string &file_path, const std::string &debuginfo_path) { std::unique_ptr dwarf(new Dwarf(bpftrace, file_path, debuginfo_path)); Dwarf_Addr bias; Dwarf_Die *cudie = dwfl_nextcu(dwarf->dwfl, nullptr, &bias); if (cudie == nullptr) return nullptr; // If the compilation units reference a separate partial type unit via // debugaltlink, perform an early check to ensure that the corresponding // shared file exists. This prevents unexpected nullptrs caused by missing // data from crashing the runtime. Dwfl_Module *mod = dwfl_cumodule(cudie); ::Dwarf *dw = dwfl_module_getdwarf(mod, &bias); if (debug_alt_link_missing(dw)) { return nullptr; } return dwarf; } Dwarf::~Dwarf() { dwfl_end(dwfl); } bool Dwarf::next_cu_info(CuInfo *cu_info) const { Dwarf_Addr cubias; cu_info->cudie = dwfl_nextcu(dwfl, cu_info->cudie, &cubias); if (cu_info->cudie == nullptr) return false; cu_info->split_cudie = std::nullopt; // Try to find split debug info for skeleton CU's . uint8_t unit_type = 0; Dwarf_Die subdie = {}; if (dwarf_cu_info(cu_info->cudie->cu, nullptr, &unit_type, nullptr, &subdie, nullptr, nullptr, nullptr) == 0 && unit_type == DW_UT_skeleton) { // libdw sets subdie to zero, if split CU is not found. const Dwarf_Die zero = {}; if (std::memcmp(&subdie, &zero, sizeof(Dwarf_Die)) != 0) { cu_info->split_cudie = subdie; } else { const char *dwo_name = nullptr; Dwarf_Attribute attr; if (dwarf_attr(cu_info->cudie, DW_AT_dwo_name, &attr) || dwarf_attr(cu_info->cudie, DW_AT_GNU_dwo_name, &attr)) { dwo_name = dwarf_formstring(&attr); } const std::string binary = std::filesystem::path(file_path_).stem().string(); // Fall back to binary.dwo, if the attribute is missing const std::string dwo = dwo_name ? std::filesystem::path(dwo_name).filename().string() : binary + ".dwo"; // Emit a warning instead of an error, since skeleton CU's do contain // minimal debug info (e.g. lines, address ranges). LOG(WARNING) << "Unable to find split debug file '" << dwo << "' or '" << binary << ".dwp' for '" << file_path_ << "', debugging information may be incomplete!"; } } return true; } static std::string get_die_name(Dwarf_Die *die) { // If the DWARF section containing the DIE name string is malformed or // missing, dwarf_diename() will return nullptr, so we wrap it to prevent // undefined behaviour. const char *name = dwarf_diename(die); return name ?: ""; } static int get_func_die_cb(Dwarf_Die *func_die, void *arg) { auto *func_info = static_cast(arg); if (dwarf_hasattr_integrate(func_die, DW_AT_name) && get_die_name(func_die) == func_info->name) { func_info->die = *func_die; return DWARF_CB_ABORT; } return DWARF_CB_OK; } std::optional Dwarf::get_func_die(const std::string &function) const { struct FuncInfo func_info = { .name = function, .die = {} }; CuInfo cu_info = {}; while (next_cu_info(&cu_info)) { if (dwarf_getfuncs(cu_info.cu_die(), get_func_die_cb, &func_info, 0) > 0) return func_info.die; } return std::nullopt; } static Dwarf_Die type_of(Dwarf_Die &die) { Dwarf_Attribute attr; Dwarf_Die type_die; dwarf_formref_die(dwarf_attr_integrate(&die, DW_AT_type, &attr), &type_die); return type_die; } std::vector Dwarf::function_param_dies( const std::string &function) const { auto func_die = get_func_die(function); if (!func_die) return {}; return get_all_children_with_tag(&func_die.value(), DW_TAG_formal_parameter); } std::string Dwarf::get_type_name(Dwarf_Die &type_die) const { auto tag = dwarf_tag(&type_die); switch (tag) { case DW_TAG_base_type: case DW_TAG_typedef: return get_die_name(&type_die); case DW_TAG_pointer_type: { if (dwarf_hasattr(&type_die, DW_AT_type)) { Dwarf_Die inner_type = type_of(type_die); return get_type_name(inner_type) + "*"; } return "void*"; } case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_enumeration_type: { std::string prefix; if (tag == DW_TAG_structure_type) prefix = STRUCT_PREFIX; else if (tag == DW_TAG_union_type) prefix = UNION_PREFIX; else prefix = ENUM_PREFIX; if (dwarf_hasattr(&type_die, DW_AT_name)) return prefix + get_die_name(&type_die); else return prefix + ""; } case DW_TAG_const_type: { Dwarf_Die inner_type = type_of(type_die); if (dwarf_tag(&inner_type) == DW_TAG_pointer_type) return get_type_name(inner_type) + " const"; else return "const " + get_type_name(inner_type); } default: return ""; } } Dwarf_Word Dwarf::get_type_encoding(Dwarf_Die &type_die) const { Dwarf_Attribute encoding_attr; Dwarf_Word encoding; dwarf_formudata( dwarf_attr_integrate(&type_die, DW_AT_encoding, &encoding_attr), &encoding); return encoding; } SizedType Dwarf::get_stype(Dwarf_Die &type_die, bool resolve_structs) const { Dwarf_Die type; dwarf_peel_type(&type_die, &type); auto tag = dwarf_tag(&type); auto bit_size = dwarf_hasattr(&type, DW_AT_bit_size) ? dwarf_bitsize(&type) : dwarf_bytesize(&type) * 8; switch (tag) { case DW_TAG_base_type: { Dwarf_Word encoding = get_type_encoding(type); switch (encoding) { case DW_ATE_boolean: case DW_ATE_unsigned: case DW_ATE_unsigned_char: return CreateUInt(bit_size); case DW_ATE_signed: case DW_ATE_signed_char: return CreateInt(bit_size); default: return CreateNone(); } } case DW_TAG_enumeration_type: return CreateUInt(bit_size); case DW_TAG_pointer_type: { if (dwarf_hasattr(&type, DW_AT_type)) { Dwarf_Die inner_type = type_of(type); return CreatePointer(get_stype(inner_type, false)); } // void * return CreatePointer(CreateNone()); } case DW_TAG_structure_type: case DW_TAG_union_type: { std::string name = get_die_name(&type_die); name = std::string(tag == DW_TAG_structure_type ? STRUCT_PREFIX : UNION_PREFIX) + name; auto result = CreateCStruct( name, bpftrace_->structs.LookupOrAdd(name, bit_size / 8)); if (resolve_structs) resolve_fields(result); return result; } case DW_TAG_array_type: { Dwarf_Die inner_type_die = type_of(type_die); Dwarf_Word inner_enc = get_type_encoding(inner_type_die); SizedType inner_type = get_stype(inner_type_die); SizedType result; for (auto &d : get_all_children_with_tag(&type_die, DW_TAG_subrange_type)) { ssize_t size = get_array_size(d); if (dwarf_tag(&inner_type_die) == DW_TAG_base_type && (inner_enc == DW_ATE_signed_char || inner_enc == DW_ATE_unsigned_char)) { // See src/btf.cpp for why this is converted to a string result = CreateString(size); } else { result = CreateArray(size, inner_type); } inner_type = result; } return result; } default: return CreateNone(); } } SizedType Dwarf::get_stype(const std::string &type_name) const { std::string name = type_name; if (name.starts_with(STRUCT_PREFIX)) name = name.substr(STRUCT_PREFIX.length()); auto type_die = find_type(name); if (!type_die) return CreateNone(); return get_stype(type_die.value()); } std::optional Dwarf::resolve_bitfield(Dwarf_Die &field_die) const { ssize_t bitfield_width = get_bitfield_size(field_die); if (bitfield_width == 0) return std::nullopt; ssize_t bit_offset = get_field_bit_offset(field_die); if (dwarf_hasattr(&field_die, DW_AT_data_bit_offset)) { // DWARF >= 4 // DW_AT_data_bit_offset is the offset in bits from the beginning of the // containing entity to the beginning of field. In this case, the byte // offset of the field is determined by (bit_offset / 8) so the bit offset // within the byte is given by (bit_offset % 8). return Bitfield(bit_offset % 8, bitfield_width); } else { // DWARF < 4 (some implementations of DWARF 4 use this, too) // Bit offset is given by DW_AT_bit_offset which is the offset in bits of // the high order bit of the container type to the high order bit of the // storage unit actually containing the bitfield. This representation was // designed for big-endian systems, so we must use the same approach to // determine the actual bit offset: // (size of the container field - DW_AT_bit_offset - bitfield size) auto field_size = dwarf_bytesize(&field_die) * 8; return Bitfield(field_size - bit_offset - bitfield_width, bitfield_width); } } void Dwarf::resolve_fields(const SizedType &type) const { if (!type.IsCTypeTy()) return; auto str = bpftrace_->structs.Lookup(type.GetName()).lock(); if (str->HasFields()) return; auto type_die = find_type(std::string(type.GetBaseName())); if (!type_die) return; for (auto &field_die : get_all_children_with_tag(&type_die.value(), DW_TAG_member)) { Dwarf_Die field_type = type_of(field_die); str->AddField(get_die_name(&field_die), get_stype(field_type), get_field_byte_offset(field_die), resolve_bitfield(field_die)); } } std::vector Dwarf::get_function_params( const std::string &function) const { std::vector result; for (auto ¶m_die : function_param_dies(function)) { Dwarf_Die type_die = type_of(param_die); const std::string type_name = get_type_name(type_die); if (dwarf_hasattr_integrate(¶m_die, DW_AT_name)) result.push_back(type_name + " " + get_die_name(¶m_die)); else result.push_back(type_name); } return result; } std::shared_ptr Dwarf::resolve_args(const std::string &function) { auto result = std::make_shared(0, false); int i = 0; for (auto ¶m_die : function_param_dies(function)) { Dwarf_Die type_die = type_of(param_die); SizedType arg_type = get_stype(type_die); arg_type.is_funcarg = true; arg_type.funcarg_idx = i++; const std::string name = dwarf_hasattr_integrate(¶m_die, DW_AT_name) ? get_die_name(¶m_die) : ""; result->AddField(name, arg_type, result->size); result->size += arg_type.GetSize(); } return result; } std::optional Dwarf::find_type(const std::string &name) const { CuInfo cu_info = {}; while (next_cu_info(&cu_info)) { if (auto type_die = get_child_with_tagname(cu_info.cu_die(), DW_TAG_structure_type, name)) return type_die; } return std::nullopt; } std::optional Dwarf::get_child_with_tagname(Dwarf_Die *die, int tag, const std::string &name) { Dwarf_Die child_die; Dwarf_Die *child_iter = &child_die; if (dwarf_child(die, &child_die) != 0) return std::nullopt; do { if (dwarf_tag(&child_die) == tag && dwarf_hasattr(&child_die, DW_AT_name) && get_die_name(&child_die) == name) return child_die; } while (dwarf_siblingof(child_iter, &child_die) == 0); return std::nullopt; } std::vector Dwarf::get_all_children_with_tag(Dwarf_Die *die, int tag) { Dwarf_Die child_die; Dwarf_Die *child_iter = &child_die; if (dwarf_child(die, &child_die) != 0) return {}; std::vector children; do { if (dwarf_tag(&child_die) == tag) children.push_back(child_die); } while (dwarf_siblingof(child_iter, &child_die) == 0); return children; } ssize_t Dwarf::get_array_size(Dwarf_Die &subrange_die) { Dwarf_Attribute size_attr; Dwarf_Word size; if (dwarf_hasattr(&subrange_die, DW_AT_upper_bound)) { dwarf_formudata( dwarf_attr_integrate(&subrange_die, DW_AT_upper_bound, &size_attr), &size); return static_cast(size) + 1; } if (dwarf_hasattr(&subrange_die, DW_AT_count)) { dwarf_formudata( dwarf_attr_integrate(&subrange_die, DW_AT_count, &size_attr), &size); return static_cast(size); } return 0; } ssize_t Dwarf::get_field_byte_offset(Dwarf_Die &field_die) { if (dwarf_hasattr(&field_die, DW_AT_data_member_location)) { Dwarf_Attribute attr; Dwarf_Word value; if (dwarf_formudata( dwarf_attr_integrate(&field_die, DW_AT_data_member_location, &attr), &value) >= 0) return static_cast(value); } return get_field_bit_offset(field_die) / 8; } ssize_t Dwarf::get_field_bit_offset(Dwarf_Die &field_die) { Dwarf_Attribute attr; Dwarf_Word value; if (dwarf_hasattr(&field_die, DW_AT_data_bit_offset)) { // DWARF >= 4 if (dwarf_formudata( dwarf_attr_integrate(&field_die, DW_AT_data_bit_offset, &attr), &value) >= 0) return static_cast(value); } if (dwarf_hasattr(&field_die, DW_AT_bit_offset)) { // DWARF < 4 if (dwarf_formudata( dwarf_attr_integrate(&field_die, DW_AT_bit_offset, &attr), &value) >= 0) return static_cast(value); } return 0; } ssize_t Dwarf::get_bitfield_size(Dwarf_Die &field_die) { Dwarf_Attribute attr; Dwarf_Word value; if (dwarf_hasattr(&field_die, DW_AT_bit_size)) { if (dwarf_formudata(dwarf_attr_integrate(&field_die, DW_AT_bit_size, &attr), &value) >= 0) return static_cast(value); } return 0; } std::vector Dwarf::get_cu_src_paths(Dwarf_Die *cudie) { std::vector result; Dwarf_Files *files; size_t nfiles; if (dwarf_getsrcfiles(cudie, &files, &nfiles) == 0 && nfiles > 0) { for (size_t i = 0; i < nfiles; i++) { // The returned source file path may either be absolute or relative. // According to the DWARF standard, source file paths should be locatable // by combining DW_AT_comp_dir with the CU's file name. However, // DW_AT_comp_dir may be missing or empty, therefore callers should not // assume the path is always absolute. // https://wiki.dwarfstd.org/Best_Practices.md const char *src = dwarf_filesrc(files, i, nullptr, nullptr); if (src) { result.emplace_back(src); } } } return result; } Result Dwarf::get_cu_by_src(const std::string &source_file) const { std::optional matched_cu; CuInfo cu_info = {}; while (next_cu_info(&cu_info)) { auto src_paths = get_cu_src_paths(cu_info.cu_die()); for (auto &src_path : src_paths) { if (util::path_ends_with(src_path, source_file)) { if (!matched_cu) { matched_cu = cu_info; matched_cu->source_path = src_path; } else if (matched_cu->source_path && src_path != *matched_cu->source_path) { return make_error( "Ambiguous source path, matches multiple files: " + matched_cu->source_path->string() + ", " + src_path.string()); } } } } if (!matched_cu) return make_error("No compilation unit matches " + source_file); return std::move(*matched_cu); } Result Dwarf::line_to_addr(const std::string &source_file, size_t line_num, size_t col_num) const { auto cu = get_cu_by_src(source_file); if (!cu) { return cu.takeError(); } if (!cu->source_path) { return make_error( "Failed to get compilation unit source path"); } Dwarf_Lines *lines = nullptr; size_t num_lines = 0; if (dwarf_getsrclines(cu->cu_die(), &lines, &num_lines) != 0) { return make_error( "Failed to get compilation unit source lines"); } for (size_t i = 0; i < num_lines; i++) { Dwarf_Line *line = dwarf_onesrcline(lines, i); if (!line) { continue; } int lineno, linecol; if (dwarf_lineno(line, &lineno) != 0 || dwarf_linecol(line, &linecol) != 0) { continue; } const char *linesrc = dwarf_linesrc(line, nullptr, nullptr); if (!linesrc) { continue; } // Check if the line source matches the CU's source path, to avoid // unintentionally accessing statements from included files. // // clang-tidy doesn't like the following line, even with an explicit check // NOLINTNEXTLINE(bugprone-unchecked-optional-access) if (util::path_ends_with(linesrc, *cu->source_path) && line_num == static_cast(lineno) && (col_num == 0 || col_num == static_cast(linecol))) { Dwarf_Addr addr; if (dwarf_lineaddr(line, &addr) == 0) { return addr; } } } return make_error( "Unable to map '" + source_file + ":" + std::to_string(line_num) + (col_num > 0 ? ":" + std::to_string(col_num) : "") + "' to address"); } } // namespace bpftrace #endif // HAVE_LIBDW bpftrace-0.27.1/src/dwarf_parser.h000066400000000000000000000133671526721631600170310ustar00rootroot00000000000000#pragma once #include "struct.h" #include "types.h" #include "util/result.h" #include #include #include #include namespace bpftrace { class DwarfParseError : public ErrorInfo { public: static char ID; void log(llvm::raw_ostream &OS) const override; DwarfParseError(std::string &&msg) : msg_(std::move(msg)) {}; DwarfParseError() = default; const std::string &msg() const { return msg_; } private: std::string msg_; }; } // namespace bpftrace #ifdef HAVE_LIBDW #include #include #include namespace bpftrace { class BPFtrace; class Dwarf { public: virtual ~Dwarf(); Dwarf(const Dwarf &) = delete; Dwarf &operator=(const Dwarf &) = delete; Dwarf(Dwarf &&) = delete; Dwarf &operator=(Dwarf &&) = delete; static std::unique_ptr GetFromBinary( BPFtrace *bpftrace, const std::string &file_path, const std::string &debuginfo_path); std::vector get_function_params( const std::string &function) const; std::shared_ptr resolve_args(const std::string &function); SizedType get_stype(const std::string &type_name) const; void resolve_fields(const SizedType &type) const; Result line_to_addr(const std::string &source_file, size_t line_num, size_t col_num = 0) const; private: // Compilation unit wrapper, abstracting over regular and split (DWO/DWP) // CU DIEs. class CuInfo { public: // Standard CU DIE, managed by the libdw session. Dwarf_Die *cudie = nullptr; // Split CU DIE loaded from a dwo/dwp file. Must be owned and managed // manually per the libdw API, and is valid for the lifetime of the CuInfo // instance. // // Present when cudie is a DW_UT_skeleton unit. In that case, this should // be used instead, as it holds vast majority of the debug info. libdw // automatically resolves references between the skeleton and split CU. std::optional split_cudie; // Returns split CU DIE if present (skeleton CU), otherwise cudie. Dwarf_Die *cu_die() { return split_cudie ? &split_cudie.value() : cudie; } // CU source file (filled when searching CU by source file) std::optional source_path; }; Dwarf(BPFtrace *bpftrace, const std::string &file_path, std::string debuginfo_path); bool next_cu_info(CuInfo *cu_info) const; std::vector function_param_dies(const std::string &function) const; std::optional get_func_die(const std::string &function) const; std::string get_type_name(Dwarf_Die &type_die) const; Dwarf_Word get_type_encoding(Dwarf_Die &type_die) const; std::optional find_type(const std::string &name) const; static ssize_t get_array_size(Dwarf_Die &subrange_die); static ssize_t get_field_byte_offset(Dwarf_Die &field_die); static ssize_t get_field_bit_offset(Dwarf_Die &field_die); static ssize_t get_bitfield_size(Dwarf_Die &field_die); std::optional resolve_bitfield(Dwarf_Die &field_die) const; SizedType get_stype(Dwarf_Die &type_die, bool resolve_structs = true) const; Result get_cu_by_src(const std::string &source_file) const; static std::optional get_child_with_tagname( Dwarf_Die *die, int tag, const std::string &name); static std::vector get_all_children_with_tag(Dwarf_Die *die, int tag); static std::vector get_cu_src_paths(Dwarf_Die *cudie); Dwfl *dwfl = nullptr; Dwfl_Callbacks callbacks; BPFtrace *bpftrace_; std::string file_path_; // Dwfl_Callbacks struct takes a char** pointing to a debuginfo path which has // to remain valid for the lifetime of the dwfl session, because debug info is // loaded lazily; e.g. dwfl_nextcu triggers the find_debuginfo callback on // first use for *each* module and dereferences the pointer. // // Each instance of this class owns a copy of the path string and keeps // debuginfo_path_cstr_ pointing to its internal buffer to pass a stable // char** to Dwfl_Callbacks. std::string debuginfo_path_; const char *debuginfo_path_cstr_; }; } // namespace bpftrace #else // HAVE_LIBDW #include "log.h" namespace bpftrace { class BPFtrace; class Dwarf { public: static std::unique_ptr GetFromBinary(BPFtrace *bpftrace __attribute__((unused)), const std::string &file_path_ __attribute__((unused)), const std::string &debuginfo_path __attribute__((unused))) { return nullptr; } std::vector get_function_params(const std::string &function __attribute__((unused))) const { return {}; } std::shared_ptr resolve_args(const std::string &function __attribute__((unused))) { return nullptr; } SizedType get_stype(const std::string &type_name __attribute__((unused))) const { return CreateNone(); } void resolve_fields(const SizedType &type __attribute__((unused))) const { } Result line_to_addr(const std::string &source_file __attribute__((unused)), size_t line_num __attribute__((unused)), size_t col_num __attribute__((unused))) const { return make_error(); } }; } // namespace bpftrace #endif // HAVE_LIBDW bpftrace-0.27.1/src/format_string.cpp000066400000000000000000000300561526721631600175550ustar00rootroot00000000000000#include #include #include "format_string.h" #include "output/output.h" #include "struct.h" #include "util/exceptions.h" #include "util/gfp_flags.h" #include "util/strings.h" namespace bpftrace { using namespace output; char FormatError::ID; void FormatError::log(llvm::raw_ostream& OS) const { OS << msg_; } // N.B. the `gr`, `r`, `rh` and `rx` specifiers are non-standard and also have // modifiers that *follow* the primary specifier. This means that they need // special cases, and the ordering matters to ensure that we capture the // modifiers if they are present (so `r` is the final match in the list). // The %gr specifier for GFP flag type in human-readable format. const std::regex FormatSpec::regex( R"(%(-?)(\+?)( ?)(#?)(0?)(\*|\d+)?(?:\.(\*|\d+))?([hlLjzt]*)([diouxXeEfFGaAcspn%]|gr|g|rh|rx|r))"); FormatSpec::FormatSpec(const std::smatch& match) { left_align = !match[1].str().empty(); show_sign = !match[2].str().empty(); space_prefix = !match[3].str().empty(); alternate_form = !match[4].str().empty(); lead_zeros = !match[5].str().empty(); if (!match[6].str().empty() && match[6].str() != "*") { width = std::stoi(match[6].str()); } if (!match[7].str().empty() && match[7].str() != "*") { precision = std::stoi(match[7].str()); } length_modifier = match[8].str(); specifier = match[9].str(); } FormatString::FormatString() = default; FormatString::FormatString(std::string fmt) : fmt_(std::move(fmt)) { parse(); } FormatString::~FormatString() = default; void FormatString::parse() { fragments.clear(); specs.clear(); auto begin = std::sregex_iterator(fmt_.begin(), fmt_.end(), FormatSpec::regex); auto end = std::sregex_iterator(); size_t last_match_end = 0; std::stringstream last_fragment; for (auto it = begin; it != end; ++it) { last_fragment << fmt_.substr(last_match_end, it->position() - last_match_end); last_match_end = it->position() + it->length(); auto spec = FormatSpec(*it); if (spec.specifier == "%") { last_fragment << "%"; continue; } fragments.emplace_back(last_fragment.str()); last_fragment.str(""); // Reset the fragment. specs.emplace_back(std::move(spec)); } last_fragment << fmt_.substr(last_match_end); fragments.emplace_back(last_fragment.str()); } Result<> FormatString::check(const std::vector& args) const { std::stringstream err; if (args.size() < specs.size()) { err << "not enough arguments for format string (" << args.size() << " supplied, " << specs.size() << " expected)"; return make_error(err.str()); } if (args.size() > specs.size()) { err << "too many arguments for format string (" << args.size() << " supplied, " << specs.size() << " expected)"; return make_error(err.str()); } // Walk over the arguments and check the most basic type information. static const std::vector any_integer = { Type::integer, Type::boolean, Type::pointer }; static const std::map> required_type = { { "d", any_integer }, { "i", any_integer }, { "u", any_integer }, { "o", any_integer }, { "x", any_integer }, { "X", any_integer }, { "c", any_integer }, { "r", { Type::buffer } }, { "rx", { Type::buffer } }, { "rh", { Type::buffer } }, { "s", {} }, { "p", any_integer }, { "gr", any_integer }, }; for (size_t i = 0; i < specs.size(); i++) { if (args[i].IsNoneTy() || args[i].IsVoidTy()) { err << "unable to print none type for specifier: " << specs[i].specifier; return make_error(err.str()); } auto it = required_type.find(specs[i].specifier); if (it == required_type.end()) { err << "unsupported format specifier: " << specs[i].specifier; return make_error(err.str()); } if (it->second.empty()) { // Anything goes. continue; } bool found = false; for (const auto& allowed : it->second) { if (args[i].GetTy() == allowed) { found = true; break; } } if (!found) { err << "unsupported format specifier for type '" << typestr(args[i]) << "': " << specs[i].specifier; return make_error(err.str()); } } return OK(); } template Result<> as_number(std::stringstream& ss, const Primitive& p) { return std::visit( [&](const auto& v) -> Result<> { if constexpr (std::is_same_v, output::Primitive::Symbolic>) { return as_number(ss, output::Primitive(v.numeric)); } else if constexpr (std::is_same_v, int64_t> || std::is_same_v, uint64_t> || std::is_same_v, double> || std::is_same_v, bool>) { if constexpr (std::is_same_v) { ss << reinterpret_cast(static_cast(v)); } else { ss << static_cast(static_cast(v)); } return OK(); } else { std::stringstream msg; msg << "invalid integer conversion: " << p; return make_error(msg.str()); } }, p.variant); } template Result<> as_signed_integer(std::stringstream& ss, const Primitive& p, const std::string& length_modifier) { if (length_modifier == "hh") { return as_number(ss, p); } else if (length_modifier == "h") { return as_number(ss, p); } else if (length_modifier == "l") { return as_number(ss, p); } else if (length_modifier == "ll") { return as_number(ss, p); } else if (length_modifier == "j") { return as_number(ss, p); } else if (length_modifier == "z") { return as_number(ss, p); } else if (length_modifier == "t") { return as_number(ss, p); } else { return as_number(ss, p); } } template Result<> as_unsigned_integer(std::stringstream& ss, const Primitive& p, const std::string& length_modifier) { if (length_modifier == "hh") { return as_number(ss, p); } else if (length_modifier == "h") { return as_number(ss, p); } else if (length_modifier == "l") { return as_number(ss, p); } else if (length_modifier == "ll") { return as_number(ss, p); } else if (length_modifier == "j") { return as_number(ss, p); } else if (length_modifier == "z") { return as_number(ss, p); } else if (length_modifier == "t") { return as_number(ss, p); } else { return as_number(ss, p); } } Result<> as_floating_point(std::stringstream& ss, const Primitive& p, const std::string& length_modifier) { if (length_modifier == "L") { return as_number(ss, p); } else { return as_number(ss, p); } } static Result<> as_string(std::stringstream& ss, const Primitive& p, [[maybe_unused]] const std::string& length_modifier) { ss << p; return OK(); } template static Result<> as_buffer(std::stringstream& ss, const Primitive& p, const std::string& length_modifier) { if (std::holds_alternative(p.variant)) { const auto& buf = std::get(p.variant); ss << util::hex_format_buffer( buf.data.data(), buf.data.size(), keep_ascii, escape_hex); return OK(); } else { return as_string(ss, p, length_modifier); } } static Result<> as_gfp_flags( std::stringstream& ss, const Primitive& p, [[maybe_unused]] const std::string& length_modifier) { return std::visit( [&](const auto& v) -> Result<> { if constexpr (std::is_same_v, output::Primitive::Symbolic>) { return as_gfp_flags(ss, output::Primitive(v.numeric), length_modifier); } else if constexpr (std::is_same_v, int64_t> || std::is_same_v, uint64_t>) { ss << util::GFPFlags::format(static_cast(v)); return OK(); } else { std::stringstream msg; msg << "invalid GFP flags conversion: " << p; return make_error(msg.str()); } }, p.variant); } Result FormatSpec::apply(const Primitive& p) const { std::stringstream ss; if (left_align) { ss << std::left; } else { ss << std::right; } if (width > 0) { ss << std::setw(width); } if (lead_zeros) { ss << std::setfill('0'); } if (precision >= 0 && (specifier == "f" || specifier == "F" || specifier == "e" || specifier == "E" || specifier == "g" || specifier == "G" || specifier == "a" || specifier == "A")) { ss << std::setprecision(precision); if (specifier == "f" || specifier == "F") { ss << std::fixed; } else if (specifier == "e" || specifier == "E") { ss << std::scientific; } } if (specifier == "o") { ss << std::oct; } else if (specifier == "x") { ss << std::hex << std::nouppercase; } else if (specifier == "X") { ss << std::hex << std::uppercase; } if (alternate_form) { ss << std::showbase; } if (show_sign) { ss << std::showpos; } using SpecifierHandler = Result<> (*)(std::stringstream&, const Primitive&, const std::string&); static const std::map specifier_dispatch = { { "d", as_signed_integer }, { "i", as_signed_integer }, { "u", as_unsigned_integer }, { "o", as_unsigned_integer }, { "x", as_unsigned_integer }, { "X", as_unsigned_integer }, { "f", as_floating_point }, { "F", as_floating_point }, { "e", as_floating_point }, { "E", as_floating_point }, { "g", as_floating_point }, { "G", as_floating_point }, { "a", as_floating_point }, { "A", as_floating_point }, { "c", as_signed_integer }, { "r", as_buffer }, { "rx", as_buffer }, { "rh", as_buffer }, { "s", as_string }, { "p", as_unsigned_integer }, { "gr", as_gfp_flags }, }; auto* dispatcher = as_string; // Default. auto it = specifier_dispatch.find(specifier); if (it != specifier_dispatch.end()) { dispatcher = it->second; } auto ok = dispatcher(ss, p, length_modifier); if (!ok) { return ok.takeError(); } return ss.str(); } std::string FormatString::format(const std::vector& args) const { std::stringstream ss; for (size_t i = 0; i < args.size(); i++) { ss << fragments[i]; auto s = specs[i].apply(args[i]); if (s) { // Write the formatted string. ss << *s; } else { // Nothing has been written, so just embed the error into the string here. // This is what happens in `Go` when a value cannot be formatted properly. ss << "!{" << s.takeError() << "}"; } } ss << fragments.back(); return ss.str(); } } // namespace bpftrace bpftrace-0.27.1/src/format_string.h000066400000000000000000000044261526721631600172240ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include "types.h" namespace bpftrace { class FormatError : public ErrorInfo { public: FormatError(std::string msg) : msg_(std::move(msg)) {}; static char ID; void log(llvm::raw_ostream &OS) const override; private: std::string msg_; }; namespace output { struct Primitive; } // namespace output // FormatSpec is a parsed format token. class FormatSpec { public: bool left_align = false; // - bool show_sign = false; // + bool space_prefix = false; // (space) bool alternate_form = false; // # bool lead_zeros = false; // 0 int width = 0; // field width int precision = -1; // precision after decimal point std::string length_modifier; // h, l, ll, etc. std::string specifier; // d, s, x, etc. private: static const std::regex regex; FormatSpec(const std::smatch &match); Result apply(const output::Primitive &p) const; friend class FormatString; }; class FormatString { public: FormatString(); FormatString(std::string fmt); ~FormatString(); // check can be used to check if the format is valid, given a set of arguments // passed in. This does a best effort analysis based on the types. Result<> check(const std::vector &args) const; // format formats the format string with the given args. Its up to the // caller to ensure that the argument types match those of the call to // validate_types. std::string format(const std::vector &args) const; // returns the original format string. const std::string &str() const { return fmt_; } // These may be used by callers to do manual validation. The fragments must be // exactly one element larger than the specs, and the sequence that is // constructed is: (fragment, spec, fragment, ..., spec, fragment). std::vector fragments; std::vector specs; private: std::string fmt_; // parses the internal format string. void parse(); friend class cereal::access; template void serialize(Archive &ar) { ar(fmt_); if (fragments.empty() && specs.empty()) { parse(); } } }; } // namespace bpftrace bpftrace-0.27.1/src/functions.cpp000066400000000000000000000110721526721631600167040ustar00rootroot00000000000000#include "functions.h" namespace bpftrace { namespace { std::string arg_types_str(const std::vector &arg_types) { std::string str = "("; bool first = true; for (const SizedType &arg_type : arg_types) { if (!first) str += ", "; str += typestr(arg_type); first = false; } str += ")"; return str; } std::string param_types_str(const std::vector ¶ms) { std::string str = "("; bool first = true; for (const Param ¶m : params) { if (!first) str += ", "; str += typestr(param.type()); first = false; } str += ")"; return str; } } // namespace const Function *FunctionRegistry::add(Function::Origin origin, std::string_view name, const SizedType &return_type, const std::vector ¶ms) { return add(origin, {}, name, return_type, params); } const Function *FunctionRegistry::add(Function::Origin origin, std::string_view ns, std::string_view name, const SizedType &return_type, const std::vector ¶ms) { FqName fq_name{ .ns = std::string{ ns }, .name = std::string{ name }, }; // Check for duplicate function definitions // The assumption is that builtin functions are all added to the registry // before any user-defined functions. // Builtin functions can be duplicated. Other functions can not. for (const Function &func : funcs_by_fq_name_[fq_name]) { if (func.origin() != Function::Origin::Builtin) { return nullptr; } } all_funcs_.push_back(std::make_unique( origin, std::string{ name }, return_type, params)); Function &new_func = *all_funcs_.back().get(); funcs_by_fq_name_[fq_name].emplace_back(new_func); return &new_func; } namespace { bool can_implicit_cast(const SizedType &from, const SizedType &to) { if (from.FitsInto(to)) return true; if (from.IsStringTy() && to.IsPtrTy() && to.GetPointeeTy().IsIntTy() && to.GetPointeeTy().GetSize() == 1) { // Allow casting from string to int8* or uint8* return true; } // Builtin and script functions do not care about string sizes. External // functions cannot be defined to accept string types (they'd take char*) if (from.IsStringTy() && to.IsStringTy()) return true; return false; } } // namespace // Find the best function by name for the given argument types. // // Returns either a single function or nullptr, when no such function exists. // // When there are multiple candidate functions with the same name, prefer the // non-builtin over the builtin function. // // Valid functions have the correct name and all arguments can be implicitly // casted into all parameter types. const Function *FunctionRegistry::get(std::string_view ns, std::string_view name, const std::vector &arg_types, const ast::Node &node) const { FqName fq_name = { .ns = std::string{ ns }, .name = std::string{ name }, }; auto it = funcs_by_fq_name_.find(fq_name); if (it == funcs_by_fq_name_.end()) { node.addError() << "Function not found: '" << name << "'"; return nullptr; } const auto &candidates = it->second; // We disallow duplicate functions other than for builtins, so expect at most // two exact matches. assert(candidates.size() <= 2); // No candidates => no match // 1 candidate => use it // 2 candidates => use non-builtin candidate const Function *candidate = nullptr; for (const Function &func : candidates) { candidate = &func; if (candidate->origin() != Function::Origin::Builtin) break; } // Validate that the candidate's parameters can take our arguments if (candidate) { bool valid = true; if (candidate->params().size() != arg_types.size()) { valid = false; } else { for (size_t i = 0; i < arg_types.size(); i++) { if (!can_implicit_cast(arg_types[i], candidate->params()[i].type())) { valid = false; break; } } } if (valid) return candidate; } auto &err = node.addError(); err << "Cannot call function '" << name << "' using argument types: " << arg_types_str(arg_types); err.addHint() << "Candidate function:\n " << candidate->name() << param_types_str(candidate->params()); return nullptr; } } // namespace bpftrace bpftrace-0.27.1/src/functions.h000066400000000000000000000063541526721631600163600ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include "ast/ast.h" #include "types.h" #include "util/hash.h" namespace bpftrace { // A parameter for a BpfScript function class Param { public: Param(std::string name, SizedType type) : name_(std::move(name)), type_(std::move(type)) { } const std::string &name() const { return name_; } const SizedType &type() const { return type_; } private: std::string name_; SizedType type_; }; // Represents the type of a function which is callable in a BpfScript program. // // The function's implementation is not contained here. class Function { public: // "Builtin" functions are hardcoded into bpftrace. // "Script" functions are user-defined in BpfScript. // "External" functions are imported from pre-compiled BPF programs. enum class Origin { Builtin, Script, External, }; Function(Origin origin, std::string name, SizedType return_type, const std::vector ¶ms) : name_(std::move(name)), return_type_(std::move(return_type)), params_(params), origin_(origin) { } const std::string &name() const { return name_; } const SizedType &return_type() const { return return_type_; } const std::vector ¶ms() const { return params_; } Origin origin() const { return origin_; } private: std::string name_; SizedType return_type_; std::vector params_; Origin origin_; }; // Registry of callable functions // // Non-builtin functions are not allowed to share the same name. When a builtin // and a non-builtin function share a name, the non-builtin is preferred. class FunctionRegistry { public: const Function *add(Function::Origin origin, std::string_view name, const SizedType &return_type, const std::vector ¶ms); const Function *add(Function::Origin origin, std::string_view ns, std::string_view name, const SizedType &return_type, const std::vector ¶ms); // Returns the best match for the given function name and arguments const Function *get(std::string_view ns, std::string_view name, const std::vector &arg_types, const ast::Node &node) const; private: struct FqName { std::string ns; std::string name; std::string str() const { if (ns.empty()) return name; return ns + "::" + name; } bool operator==(const FqName &other) const { return ns == other.ns && name == other.name; } }; class HashFqName { public: size_t operator()(const FqName &fq_name) const { std::size_t seed = 0; util::hash_combine(seed, fq_name.ns); util::hash_combine(seed, fq_name.name); return seed; } }; std::unordered_map>, HashFqName> funcs_by_fq_name_; std::vector> all_funcs_; }; } // namespace bpftrace bpftrace-0.27.1/src/globalvars.cpp000066400000000000000000000505631526721631600170400ustar00rootroot00000000000000#include #include #include #include #include "ast/passes/named_param.h" #include "bpftrace.h" #include "globalvars.h" #include "log.h" #include "required_resources.h" #include "types.h" #include "util/exceptions.h" #include "util/int_parser.h" #include "util/strings.h" namespace bpftrace::globalvars { char NamedParamError::ID; void NamedParamError::log(llvm::raw_ostream &OS) const { OS << "program command line option --" << param_ << " " << err_ << " (value: " << value_ << ")\n"; } char UnknownParamError::ID; void UnknownParamError::log(llvm::raw_ostream &OS) const { OS << err(); } static GlobalVarConfig::Type get_global_var_type(const GlobalVarValue &value) { if (std::holds_alternative(value)) { return GlobalVarConfig::opt_signed; } else if (std::holds_alternative(value)) { return GlobalVarConfig::opt_unsigned; } else if (std::holds_alternative(value)) { return GlobalVarConfig::opt_bool; } else if (std::holds_alternative(value)) { return GlobalVarConfig::opt_string; } else { LOG(BUG) << "Unknown global variable type"; } } static std::map find_btf_var_offsets( const struct bpf_object *bpf_object, std::string_view section_name, const std::unordered_set &needed_global_vars) { struct btf *self_btf = bpf_object__btf(bpf_object); if (!self_btf) { LOG(BUG) << "Failed to get BTF from BPF object"; } __s32 section_id = btf__find_by_name(self_btf, std::string(section_name).c_str()); if (section_id < 0) { LOG(BUG) << "Failed to find section " << section_name << " to update global vars"; } const struct btf_type *section_type = btf__type_by_id( self_btf, static_cast<__u32>(section_id)); if (!section_type) { LOG(BUG) << "Failed to get BTF type for section " << section_name; } // First locate the offsets of each global variable in the section with btf std::map vars_and_offsets; for (const auto &global_var : needed_global_vars) { vars_and_offsets[global_var] = -1; } uint16_t i; struct btf_var_secinfo *member; for (i = 0, member = btf_var_secinfos(section_type); i < btf_vlen(section_type); ++i, ++member) { const struct btf_type *type_id = btf__type_by_id(self_btf, member->type); if (!type_id) { continue; } std::string name = std::string( btf__name_by_offset(self_btf, type_id->name_off)); // Only deal with bpftrace's known global variables. Other global variables // could come from imported BPF libraries, for example. auto it = vars_and_offsets.find(name); if (it != vars_and_offsets.end()) { it->second = member->offset; } } for (const auto &[global_var, offset] : vars_and_offsets) { if (offset < 0) { LOG(BUG) << "Global variable " << global_var << " has not been added to the BPF code " "(codegen_llvm)"; } } return vars_and_offsets; } void update_global_vars_rodata( struct bpf_map *global_vars_map, const std::unordered_map &added_global_vars, const std::map &vars_and_offsets, const GlobalVarMap &global_var_vals) { size_t v_size; char *global_vars_buf = reinterpret_cast( bpf_map__initial_value(global_vars_map, &v_size)); if (!global_vars_buf) { LOG(BUG) << "Failed to get array buf for global variable map"; } // Update the values for the global vars (using the above offsets) for (const auto &[global_var, offset] : vars_and_offsets) { auto it = global_var_vals.find(global_var); if (it != global_var_vals.end()) { const auto &config = added_global_vars.at(global_var); if (!config.type) { LOG(BUG) << "Global variable " << global_var << " has no type"; } switch (*config.type) { case GlobalVarConfig::opt_signed: { auto *var = reinterpret_cast(global_vars_buf + offset); *var = std::get(it->second); break; } case GlobalVarConfig::opt_unsigned: { auto *var = reinterpret_cast(global_vars_buf + offset); *var = std::get(it->second); break; } case GlobalVarConfig::opt_bool: { auto *var = reinterpret_cast(global_vars_buf + offset); *var = std::get(it->second) ? 1 : 0; break; } case GlobalVarConfig::opt_string: { auto *var = global_vars_buf + offset; const auto &val = std::get(it->second); strncpy(var, val.c_str(), val.size() + 1); break; } } } } } void update_global_vars_custom_rw_section( const std::string §ion_name, struct bpf_map *global_vars_map, const std::map &vars_and_offsets, const std::unordered_set &needed_global_vars, int max_cpu_id) { if (needed_global_vars.size() > 1) { LOG(BUG) << "Multiple read-write global variables are in same section " << section_name; } auto global_var = *needed_global_vars.begin(); size_t actual_size; auto *buf = bpf_map__initial_value(global_vars_map, &actual_size); if (!buf) { LOG(BUG) << "Failed to get size for section " << section_name << " before resizing"; } if (actual_size == 0) { LOG(BUG) << "Section " << section_name << " has size of 0 "; } auto desired_size = (max_cpu_id + 1) * actual_size; auto err = bpf_map__set_value_size(global_vars_map, desired_size); if (err != 0) { throw util::FatalUserException("Failed to set size to " + std::to_string(desired_size) + " for section " + section_name); } buf = bpf_map__initial_value(global_vars_map, &actual_size); if (!buf) { LOG(BUG) << "Failed to get size for section " << section_name << " after resizing"; } if (actual_size != desired_size) { throw util::FatalUserException( "Failed to set size from " + std::to_string(actual_size) + " to " + std::to_string(desired_size) + " for section " + section_name); } // No need to memset to zero as we memset on each usage // Verify we can still find variable name via BTF and it hasn't been cleared // after size changes if (vars_and_offsets.at(global_var) != 0) { LOG(BUG) << "Read-write global variable " << global_var << " must be at offset 0 in section " << section_name; } } static SizedType make_rw_type(size_t num_elements, const SizedType &element_type) { auto subtype = CreateArray(num_elements, element_type); // For 1 CPU, will be adjusted to actual CPU count at runtime return CreateArray(1, subtype); } SizedType GlobalVars::get_sized_type(const std::string &global_var_name, const RequiredResources &resources, const Config &bpftrace_config) const { const auto &config = get_config(global_var_name); if (global_var_name == FMT_STRINGS_BUFFER) { assert(resources.max_fmtstring_args_size > 0); return make_rw_type( 1, CreateArray(resources.max_fmtstring_args_size, CreateInt8())); } if (global_var_name == ANON_STRUCT_BUFFER) { assert(resources.max_anon_struct_size > 0); assert(resources.anon_struct_buffers > 0); return make_rw_type(resources.anon_struct_buffers, CreateArray(resources.max_anon_struct_size, CreateInt8())); } if (global_var_name == CALL_STACK_BUFFER) { assert(resources.max_call_stack_size > 0); assert(resources.call_stack_buffers > 0); return make_rw_type(resources.call_stack_buffers, CreateArray(resources.max_call_stack_size, CreateInt8())); } if (global_var_name == GET_STR_BUFFER) { assert(resources.str_buffers > 0); const auto max_strlen = bpftrace_config.pad_max_strlen(); return make_rw_type(resources.str_buffers, CreateArray(max_strlen, CreateInt8())); } if (global_var_name == READ_MAP_VALUE_BUFFER) { assert(resources.max_read_map_value_size > 0); assert(resources.read_map_value_buffers > 0); return make_rw_type(resources.read_map_value_buffers, CreateArray(resources.max_read_map_value_size, CreateInt8())); } if (global_var_name == WRITE_MAP_VALUE_BUFFER) { assert(resources.max_write_map_value_size > 0); return make_rw_type( 1, CreateArray(resources.max_write_map_value_size, CreateInt8())); } if (global_var_name == VARIABLE_BUFFER) { assert(resources.variable_buffers > 0); assert(resources.max_variable_size > 0); const auto slot_size = (resources.max_variable_size + 7) / 8 * 8; return make_rw_type(resources.variable_buffers, CreateArray(slot_size, CreateInt8())); } if (global_var_name == MAP_KEY_BUFFER) { assert(resources.map_key_buffers > 0); assert(resources.max_map_key_size > 0); return make_rw_type(resources.map_key_buffers, CreateArray(resources.max_map_key_size, CreateInt8())); } if (global_var_name == EVENT_LOSS_COUNTER) { return make_rw_type(1, CreateUInt64()); } if (global_var_name == JOIN_BUFFER) { return make_rw_type(1, CreateArray(resources.join_value_size, CreateInt8())); } if (!config.type) { LOG(BUG) << "Unknown global variable " << global_var_name; } switch (*config.type) { case GlobalVarConfig::opt_signed: return CreateInt64(); case GlobalVarConfig::opt_unsigned: return CreateUInt64(); case GlobalVarConfig::opt_bool: return CreateInt8(); case GlobalVarConfig::opt_string: { const auto max_strlen = bpftrace_config.max_strlen; return make_rw_type(1, CreateArray(max_strlen, CreateInt8())); } } return CreateNone(); // Unreachable. } void GlobalVars::check_index(const std::string &global_var_name, const RequiredResources &resources, size_t index) const { if (global_var_name == ANON_STRUCT_BUFFER) { assert(index < resources.anon_struct_buffers); } else if (global_var_name == GET_STR_BUFFER) { assert(index < resources.str_buffers); } else if (global_var_name == READ_MAP_VALUE_BUFFER) { assert(index < resources.read_map_value_buffers); } else if (global_var_name == VARIABLE_BUFFER) { assert(index < resources.variable_buffers); } else if (global_var_name == MAP_KEY_BUFFER) { assert(index < resources.map_key_buffers); } } std::unordered_set get_section_names() { std::unordered_set ret; for (const auto &[_, config] : GLOBAL_VAR_CONFIGS) { ret.insert(config.section); } return ret; } void GlobalVars::add_known(const std::string_view &name) { if (!GLOBAL_VAR_CONFIGS.contains(name)) { LOG(BUG) << "Unknown global variable: " << name; } auto str_name = std::string(name); if (added_global_vars_.contains(str_name)) { return; } added_global_vars_[std::move(str_name)] = GLOBAL_VAR_CONFIGS.at(name); } void GlobalVars::add_named_param(const std::string &name, const GlobalVarValue &default_val, const std::string &description) { if (added_global_vars_.contains(name)) { return; } added_global_vars_[name] = GlobalVarConfig({ .section = std::string(RO_SECTION_NAME), .type = get_global_var_type(default_val), }); named_param_info_[name] = GlobalVarInfo({ .value = default_val, .description = description, }); } const GlobalVarConfig &GlobalVars::get_config(const std::string &name) const { auto it = added_global_vars_.find(name); if (it == added_global_vars_.end()) { LOG(BUG) << "Unknown global variable: " << name; } return it->second; } void GlobalVars::verify_maps_found( const std::unordered_map §ion_name_to_global_vars_map) { for (const auto &[name, config] : added_global_vars_) { if (!section_name_to_global_vars_map.contains(config.section)) { LOG(BUG) << "No map found in " << config.section << " which is needed to set global variable " << name; } } } Result GlobalVars::get_named_param_vals( std::vector raw_named_params) const { std::unordered_map> named_params; std::vector unexpected_params; for (const auto ¶m : raw_named_params) { if (param.find("=") != std::string::npos) { auto split = util::split_string(param, '=', /* remove_empty= */ true); named_params[split[0]] = split.size() == 2 ? split[1] : ""; if (!added_global_vars_.contains(split[0])) { unexpected_params.push_back(split[0]); } } else { named_params[param] = std::nullopt; if (!added_global_vars_.contains(param)) { unexpected_params.push_back(param); } } } if (!unexpected_params.empty()) { std::vector> expected_params; for (const auto &[name, info] : named_param_info_) { expected_params.emplace_back(name, info.description); } return make_error(std::move(unexpected_params), std::move(expected_params)); } GlobalVarMap named_param_vals; for (const auto &[name, info] : named_param_info_) { const auto &config = added_global_vars_.at(name); if (!config.type) { LOG(BUG) << "No type set for global variable."; } // Use the default. auto it = named_params.find(name); if (it == named_params.end()) { switch (*config.type) { case GlobalVarConfig::opt_signed: named_param_vals[name] = std::get(info.value); break; case GlobalVarConfig::opt_unsigned: named_param_vals[name] = std::get(info.value); break; case GlobalVarConfig::opt_bool: named_param_vals[name] = std::get(info.value); break; case GlobalVarConfig::opt_string: named_param_vals[name] = std::get(info.value); break; } continue; } // No value means it's a boolean. if (!it->second.has_value()) { switch (*config.type) { case GlobalVarConfig::opt_signed: case GlobalVarConfig::opt_unsigned: return make_error(name, "true", "expects an integer"); case GlobalVarConfig::opt_string: return make_error(name, "true", "expects a string"); case GlobalVarConfig::opt_bool: named_param_vals[name] = true; break; } continue; } const std::string &val = *it->second; switch (*config.type) { case GlobalVarConfig::opt_signed: { auto int_val = util::to_int(val); if (!int_val) { std::string err_msg; auto ok = handleErrors( std::move(int_val), [&](const util::OverflowError &) { err_msg = "value is out of range"; }, [&](const util::NumberFormatError &err) { err_msg = err.msg(); }); return make_error(name, val, err_msg); } named_param_vals[name] = *int_val; break; } case GlobalVarConfig::opt_unsigned: { auto uint_val = util::to_uint(val); if (!uint_val) { std::string err_msg; auto ok = handleErrors( std::move(uint_val), [&](const util::OverflowError &) { err_msg = "value is out of range"; }, [&](const util::NumberFormatError &err) { err_msg = err.msg(); }); return make_error(name, val, err_msg); } named_param_vals[name] = *uint_val; break; } case GlobalVarConfig::opt_bool: if (util::is_str_bool_truthy(val)) { named_param_vals[name] = true; } else if (util::is_str_bool_falsy(val)) { named_param_vals[name] = false; } else { return make_error(name, val, "expects a boolean (e.g. 'true')"); } break; case GlobalVarConfig::opt_string: named_param_vals[name] = val; break; } } return named_param_vals; } std::unordered_set GlobalVars::get_global_vars_for_section( std::string_view target_section) { std::unordered_set ret; for (const auto &[name, config] : added_global_vars_) { if (config.section == target_section) { ret.insert(name); } } return ret; } void GlobalVars::update_global_vars( const struct bpf_object *bpf_object, const std::unordered_map §ion_name_to_global_vars_map, GlobalVarMap &&global_var_vals, uint64_t ncpus, uint64_t max_cpu_id, std::optional child_pid) { global_var_vals[std::string(globalvars::NUM_CPUS)] = ncpus; global_var_vals[std::string(globalvars::MAX_CPU_ID)] = max_cpu_id; if (child_pid.has_value()) { auto value = static_cast(*child_pid); global_var_vals[std::string(globalvars::CHILD_PID)] = value; } else { uint64_t empty_value = 0; global_var_vals[std::string(globalvars::CHILD_PID)] = empty_value; } verify_maps_found(section_name_to_global_vars_map); for (const auto &[section_name, global_vars_map] : section_name_to_global_vars_map) { const auto needed_global_variables = get_global_vars_for_section( section_name); if (needed_global_variables.empty()) { continue; } std::map vars_and_offsets = find_btf_var_offsets( bpf_object, section_name, needed_global_variables); if (section_name == RO_SECTION_NAME) { update_global_vars_rodata(global_vars_map, added_global_vars_, vars_and_offsets, global_var_vals); } else { update_global_vars_custom_rw_section(section_name, global_vars_map, vars_and_offsets, needed_global_variables, max_cpu_id); } } } uint64_t *GlobalVars::get_global_var( const struct bpf_object *bpf_object, std::string_view target_section, const std::unordered_map §ion_name_to_global_vars_map) { verify_maps_found(section_name_to_global_vars_map); auto it = std::ranges::find_if(section_name_to_global_vars_map, [target_section](const auto &pair) { return pair.first == target_section; }); if (it == section_name_to_global_vars_map.end()) { LOG(BUG) << target_section << " not found"; } const auto &[section_name, global_vars_map] = *it; const auto needed_global_variables = get_global_vars_for_section( section_name); if (needed_global_variables.empty()) { LOG(BUG) << "No global variables found in section " << section_name; } else if (needed_global_variables.size() > 1) { LOG(BUG) << "Multiple read-write global variables are in same section " << section_name; } auto global_var = *needed_global_variables.begin(); auto vars_and_offsets = find_btf_var_offsets(bpf_object, section_name, needed_global_variables); if (vars_and_offsets.at(global_var) != 0) { LOG(BUG) << "Read-write global variable " << global_var << " must be at offset 0 in section " << section_name; } size_t v_size; auto *target_var = reinterpret_cast( bpf_map__initial_value(global_vars_map, &v_size)); if (!target_var) { LOG(BUG) << "Failed to get array buf for global variable map"; } return target_var; } } // namespace bpftrace::globalvars bpftrace-0.27.1/src/globalvars.h000066400000000000000000000211631526721631600164770ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include "types.h" #include "util/result.h" namespace bpftrace { class BPFtrace; class Config; class RequiredResources; namespace globalvars { class NamedParamError : public ErrorInfo { public: NamedParamError(std::string param, std::string value, std::string &&err) : param_(std::move(param)), value_(std::move(value)), err_(std::move(err)) {}; static char ID; void log(llvm::raw_ostream &OS) const override; const std::string &err() const { return err_; } private: std::string param_; std::string value_; std::string err_; }; class UnknownParamError : public ErrorInfo { public: UnknownParamError(std::vector &&unexpected, std::vector> &&expected) : unexpected_(std::move(unexpected)), expected_(std::move(expected)) {}; static char ID; void log(llvm::raw_ostream &OS) const override; std::string err() const { std::string err = "unexpected program command line options: "; size_t i; bool has_err = false; for (i = 0; i < unexpected_.size(); ++i) { if (unexpected_[i] == "help") { continue; } has_err = true; err += "--"; err += unexpected_[i]; if (i != unexpected_.size() - 1) { err += ", "; } } if (!has_err) { return {}; } else { return err; } } std::string hint() const { std::string hint = "expected program options:"; size_t j; bool help_mode = std::ranges::any_of(unexpected_, [](const auto &i) { return i == "help"; }); if (expected_.empty()) { return "no custom program options defined."; } hint += help_mode ? "\n" : " "; for (j = 0; j < expected_.size(); ++j) { hint += "--"; hint += expected_[j].first; if (help_mode && !expected_[j].second.empty()) { hint += ": "; hint += expected_[j].second; } if (j != expected_.size() - 1) { hint += help_mode ? "\n" : ": "; } } return hint; } private: std::vector unexpected_; std::vector> expected_; }; using GlobalVarValue = std::variant; using GlobalVarMap = std::unordered_map; struct GlobalVarInfo { GlobalVarValue value; std::string description; private: friend class cereal::access; template void serialize(Archive &archive) { archive(value, description); } }; // Known global variables constexpr std::string_view NUM_CPUS = "__bt__num_cpus"; constexpr std::string_view MAX_CPU_ID = "__bt__max_cpu_id"; constexpr std::string_view FMT_STRINGS_BUFFER = "__bt__fmt_str_buf"; constexpr std::string_view ANON_STRUCT_BUFFER = "__bt__anon_struct_buf"; constexpr std::string_view CALL_STACK_BUFFER = "__bt__call_stack_buf"; constexpr std::string_view GET_STR_BUFFER = "__bt__get_str_buf"; constexpr std::string_view READ_MAP_VALUE_BUFFER = "__bt__read_map_val_buf"; constexpr std::string_view WRITE_MAP_VALUE_BUFFER = "__bt__write_map_val_buf"; constexpr std::string_view VARIABLE_BUFFER = "__bt__var_buf"; constexpr std::string_view MAP_KEY_BUFFER = "__bt__map_key_buf"; constexpr std::string_view EVENT_LOSS_COUNTER = "__bt__event_loss_counter"; constexpr std::string_view JOIN_BUFFER = "__bt__join_buf"; constexpr std::string_view CHILD_PID = "__bt__child_pid"; // Section names constexpr std::string_view RO_SECTION_NAME = ".rodata"; constexpr std::string_view FMT_STRINGS_BUFFER_SECTION_NAME = ".data.fmt_str_buf"; constexpr std::string_view ANON_STRUCT_BUFFER_SECTION_NAME = ".data.anon_struct_buf"; constexpr std::string_view CALL_STACK_BUFFER_SECTION_NAME = ".data.call_stack_buf"; constexpr std::string_view GET_STR_BUFFER_SECTION_NAME = ".data.get_str_buf"; constexpr std::string_view READ_MAP_VALUE_BUFFER_SECTION_NAME = ".data.read_map_val_buf"; constexpr std::string_view WRITE_MAP_VALUE_BUFFER_SECTION_NAME = ".data.write_map_val_buf"; constexpr std::string_view VARIABLE_BUFFER_SECTION_NAME = ".data.var_buf"; constexpr std::string_view MAP_KEY_BUFFER_SECTION_NAME = ".data.map_key_buf"; constexpr std::string_view EVENT_LOSS_COUNTER_SECTION_NAME = ".data.event_loss_counter"; constexpr std::string_view JOIN_BUFFER_SECTION_NAME = ".data.join_buf"; struct GlobalVarConfig { std::string section; enum Type { opt_bool, opt_string, opt_signed, opt_unsigned, }; std::optional type = std::nullopt; private: friend class cereal::access; template void serialize(Archive &archive) { archive(section, type); } }; const std::unordered_map GLOBAL_VAR_CONFIGS = { { NUM_CPUS, { .section = std::string(RO_SECTION_NAME), .type = GlobalVarConfig::opt_unsigned } }, { MAX_CPU_ID, { .section = std::string(RO_SECTION_NAME), .type = GlobalVarConfig::opt_unsigned } }, { EVENT_LOSS_COUNTER, { .section = std::string(EVENT_LOSS_COUNTER_SECTION_NAME), .type = GlobalVarConfig::opt_unsigned } }, { FMT_STRINGS_BUFFER, { .section = std::string(FMT_STRINGS_BUFFER_SECTION_NAME) } }, { ANON_STRUCT_BUFFER, { .section = std::string(ANON_STRUCT_BUFFER_SECTION_NAME) } }, { CALL_STACK_BUFFER, { .section = std::string(CALL_STACK_BUFFER_SECTION_NAME) } }, { GET_STR_BUFFER, { .section = std::string(GET_STR_BUFFER_SECTION_NAME) } }, { READ_MAP_VALUE_BUFFER, { .section = std::string(READ_MAP_VALUE_BUFFER_SECTION_NAME) } }, { WRITE_MAP_VALUE_BUFFER, { .section = std::string(WRITE_MAP_VALUE_BUFFER_SECTION_NAME) } }, { VARIABLE_BUFFER, { .section = std::string(VARIABLE_BUFFER_SECTION_NAME) } }, { MAP_KEY_BUFFER, { .section = std::string(MAP_KEY_BUFFER_SECTION_NAME) } }, { JOIN_BUFFER, { .section = std::string(JOIN_BUFFER_SECTION_NAME) } }, { CHILD_PID, { .section = std::string(RO_SECTION_NAME), .type = GlobalVarConfig::opt_unsigned } }, }; class GlobalVars { public: GlobalVars() = default; GlobalVars(std::unordered_map global_var_map, std::unordered_map default_values) : added_global_vars_(std::move(global_var_map)), named_param_info_(std::move(default_values)) { } void add_known(const std::string_view &name); void add_named_param(const std::string &name, const GlobalVarValue &default_value, const std::string &description); Result get_named_param_vals( std::vector raw_named_params) const; const GlobalVarConfig &get_config(const std::string &name) const; SizedType get_sized_type(const std::string &global_var_name, const RequiredResources &resources, const Config &bpftrace_config) const; void check_index(const std::string &global_var_name, const RequiredResources &resources, size_t index) const; const std::unordered_map &global_var_map() const { return added_global_vars_; } void update_global_vars( const struct bpf_object *bpf_object, const std::unordered_map &global_vars_map, GlobalVarMap &&global_var_vals, uint64_t ncpus, uint64_t max_cpu_id, std::optional child_pid); std::unordered_set get_global_vars_for_section( std::string_view target_section); uint64_t *get_global_var( const struct bpf_object *bpf_object, std::string_view target_section, const std::unordered_map §ion_name_to_global_vars_map); protected: std::unordered_map added_global_vars_; std::unordered_map named_param_info_; private: friend class cereal::access; template void serialize(Archive &archive) { archive(added_global_vars_, named_param_info_); } void verify_maps_found(const std::unordered_map §ion_name_to_global_vars_map); }; SizedType get_type(const std::string &global_var_name, const RequiredResources &resources, const Config &bpftrace_config); std::unordered_set get_section_names(); } // namespace globalvars } // namespace bpftrace bpftrace-0.27.1/src/ksyms.cpp000066400000000000000000000112211526721631600160360ustar00rootroot00000000000000#include #include #include "ksyms.h" #include "scopeguard.h" namespace { std::string stringify_addr(uint64_t addr) { std::ostringstream symbol; symbol << reinterpret_cast(addr); return symbol.str(); } #ifdef HAVE_BLAZESYM std::string stringify_ksym(const char *name, const blaze_symbolize_code_info *code_info, uint64_t offset, bool show_offset, bool perf_mode, bool is_inlined) { std::ostringstream symbol; if (is_inlined && !perf_mode) { symbol << "[inlined] "; } symbol << name; if (show_offset) { symbol << "+" << offset; } if (perf_mode) { if (is_inlined) { symbol << " (inlined)"; } return symbol.str(); } if (code_info != nullptr) { if (code_info->dir != nullptr && code_info->file != nullptr) { symbol << "@" << code_info->dir << "/" << code_info->file << ":" << code_info->line; } else if (code_info->file != nullptr) { symbol << "@" << code_info->file << ":" << code_info->line; } } return symbol.str(); } #endif } // namespace namespace bpftrace { Ksyms::Ksyms(const Config &config) : config_(config) { } Ksyms::~Ksyms() { if (ksyms_) bcc_free_symcache(ksyms_, -1); #ifdef HAVE_BLAZESYM if (symbolizer_) blaze_symbolizer_free(symbolizer_); #endif } std::string Ksyms::resolve_bcc(uint64_t addr, bool show_offset) { struct bcc_symbol ksym; if (!ksyms_) ksyms_ = bcc_symcache_new(-1, nullptr); if (bcc_symcache_resolve(ksyms_, addr, &ksym) == 0) { std::ostringstream symbol; symbol << ksym.name; if (show_offset) symbol << "+" << ksym.offset; return symbol.str(); } return stringify_addr(addr); } #ifdef HAVE_BLAZESYM std::vector Ksyms::resolve_blazesym_impl(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info) { std::vector str_syms; if (symbolizer_ == nullptr) { blaze_symbolizer_opts opts = { .type_size = sizeof(opts), // Use the config here because the symbolizer is created once .code_info = config_.show_debug_info, .inlined_fns = config_.show_debug_info, }; symbolizer_ = blaze_symbolizer_new_opts(&opts); if (symbolizer_ == nullptr) return str_syms; } blaze_symbolize_src_kernel src = { .type_size = sizeof(src), // Use default system-wide kallsyms file. .kallsyms = nullptr, // Disable discovery and usage of a vmlinux file. // TODO: We should eventually support that, incorporating discovery logic // from find_vmlinux(). .vmlinux = "", .debug_syms = show_debug_info, }; const blaze_syms *syms = blaze_symbolize_kernel_abs_addrs( symbolizer_, &src, &addr, 1); if (syms == nullptr) return str_syms; SCOPE_EXIT { blaze_syms_free(syms); }; const blaze_sym *sym = &syms->syms[0]; const struct blaze_symbolize_inlined_fn *inlined; if (sym == nullptr || sym->name == nullptr) { return str_syms; } // bpftrace prints stacks leaf first so the inlined functions // need to come first in the list (and in reverse order) for (int j = static_cast(sym->inlined_cnt) - 1; j >= 0; j--) { inlined = &sym->inlined[j]; if (inlined != nullptr) { str_syms.push_back(stringify_ksym( inlined->name, &inlined->code_info, 0, false, perf_mode, true)); } } str_syms.push_back(stringify_ksym( sym->name, &sym->code_info, sym->offset, show_offset, perf_mode, false)); return str_syms; } std::vector Ksyms::resolve_blazesym(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info) { auto syms = resolve_blazesym_impl( addr, show_offset, perf_mode, show_debug_info); if (syms.empty()) { syms.push_back(stringify_addr(addr)); } return syms; } #endif std::vector Ksyms::resolve(uint64_t addr, bool show_offset, [[maybe_unused]] bool perf_mode, [[maybe_unused]] bool show_debug_info) { #ifdef HAVE_BLAZESYM if (config_.use_blazesym) return resolve_blazesym(addr, show_offset, perf_mode, show_debug_info); #endif return std::vector{ resolve_bcc(addr, show_offset) }; } } // namespace bpftrace bpftrace-0.27.1/src/ksyms.h000066400000000000000000000023651526721631600155140ustar00rootroot00000000000000#pragma once #include #include #include #ifdef HAVE_BLAZESYM #include #endif #include "config.h" namespace bpftrace { class Config; class Ksyms { public: Ksyms(const Config &config); ~Ksyms(); Ksyms(Ksyms &) = delete; Ksyms &operator=(const Ksyms &) = delete; std::vector resolve(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info); private: const Config &config_; void *ksyms_{ nullptr }; #ifdef HAVE_BLAZESYM blaze_symbolizer *symbolizer_{ nullptr }; std::vector resolve_blazesym_impl(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info); std::vector resolve_blazesym(uint64_t addr, bool show_offset, bool perf_mode, bool show_debug_info); #endif std::string resolve_bcc(uint64_t addr, bool show_offset); }; } // namespace bpftrace bpftrace-0.27.1/src/lockdown.cpp000066400000000000000000000030451526721631600165150ustar00rootroot00000000000000#include #include #include #include #include #include #include #include "lockdown.h" namespace bpftrace::lockdown { static LockdownState from_string(const std::string &s) { if (s == "none") return LockdownState::None; else if (s == "integrity") return LockdownState::Integrity; else if (s == "confidentiality") return LockdownState::Confidentiality; return LockdownState::Unknown; } static LockdownState read_security_lockdown() { std::ifstream file("/sys/kernel/security/lockdown"); if (file.fail()) return LockdownState::Unknown; // Format: none [integrity] confidentiality // read one field at a time, if it starts with [ it's the one we want while (!file.fail()) { std::string field; file >> field; if (field[0] == '[') return from_string(field.substr(1, field.length() - 2)); } return LockdownState::Unknown; } void emit_warning(std::ostream &out) { // clang-format off // these lines are ~80 chars wide in terminal out << "Kernel lockdown is enabled and set to 'confidentiality'. Lockdown mode blocks" << std::endl << "parts of BPF which makes it impossible for bpftrace to function. Please see " << std::endl << "https://github.com/bpftrace/bpftrace/blob/master/INSTALL.md#disable-lockdown" << std::endl << "for more details on lockdown and how to disable it." << std::endl; // clang-format on } LockdownState detect() { return read_security_lockdown(); } } // namespace bpftrace::lockdown bpftrace-0.27.1/src/lockdown.h000066400000000000000000000004611526721631600161610ustar00rootroot00000000000000#pragma once #include namespace bpftrace::lockdown { enum class LockdownState { None, Integrity, Confidentiality, Unknown, // Could not determine whether lockdown is enabled or not }; LockdownState detect(); void emit_warning(std::ostream &out); } // namespace bpftrace::lockdown bpftrace-0.27.1/src/log.cpp000066400000000000000000000071711526721631600154620ustar00rootroot00000000000000#include "log.h" #include namespace bpftrace { static std::string_view logtype_str(LogType t) { switch (t) { // clang-format off case LogType::DEBUG : return ""; case LogType::V1 : return ""; case LogType::HINT : return "HINT: "; case LogType::WARNING : return "WARNING: "; case LogType::ERROR : return "ERROR: "; case LogType::BUG : return "BUG: "; // clang-format on } return {}; // unreached } Log::Log() { enabled_map_[LogType::DEBUG] = true; enabled_map_[LogType::V1] = false; enabled_map_[LogType::HINT] = true; enabled_map_[LogType::WARNING] = true; enabled_map_[LogType::ERROR] = true; enabled_map_[LogType::BUG] = true; } Log& Log::get() { static Log log; return log; } void Log::take_input(LogType type, std::optional&& source_location, std::optional>&& source_context, std::ostream& out, std::string&& msg) { if (!msg.empty() && msg.back() == '\n') { msg.pop_back(); } const char* color_begin = LogColor::DEFAULT; const char* color_end = LogColor::DEFAULT; if (is_colorize_) { switch (type) { case LogType::ERROR: case LogType::BUG: color_begin = LogColor::RED; color_end = LogColor::RESET; break; case LogType::WARNING: color_begin = LogColor::YELLOW; color_end = LogColor::RESET; break; default: break; } } out << color_begin; if (source_location) { out << *source_location << ": "; } out << logtype_str(type) << msg << color_end << std::endl; if (source_context) { for (const auto& s : *source_context) { out << s << std::endl; } } } LogStream::LogStream(const std::string& file, int line, LogType type, std::ostream& out) : file_(file), line_(line), type_(type), out_(out) { } LogStream::LogStream(const std::string& file, int line, LogType type, std::string&& source_location, std::ostream& out) : file_(file), line_(line), type_(type), source_location_(std::move(source_location)), out_(out) { } LogStream::LogStream(const std::string& file, int line, LogType type, std::string&& source_location, std::vector&& source_context, std::ostream& out) : file_(file), line_(line), type_(type), source_location_(std::move(source_location)), source_context_(std::move(source_context)), out_(out) { } LogStream::~LogStream() { auto& sink = Log::get(); if (sink.is_enabled(type_)) { auto msg = buf_.str(); if (type_ == LogType::DEBUG) msg = internal_location() + msg; // Pass ownership of all the things to the sink itself, which will evaluate // what's available and what's not. sink.take_input(type_, std::move(source_location_), std::move(source_context_), out_, std::move(msg)); } } std::string LogStream::internal_location() { std::ostringstream ss; ss << "[" << file_ << ":" << line_ << "] "; return ss.str(); } [[noreturn]] LogStreamBug::~LogStreamBug() { auto& sink = Log::get(); sink.take_input(type_, std::nullopt, std::nullopt, out_, internal_location() + buf_.str()); abort(); } }; // namespace bpftrace bpftrace-0.27.1/src/log.h000066400000000000000000000077011526721631600151260ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include namespace bpftrace { namespace LogColor { constexpr const char* RESET = "\033[0m"; constexpr const char* RED = "\033[31m"; constexpr const char* YELLOW = "\033[33m"; constexpr const char* DEFAULT = ""; } // namespace LogColor // clang-format off enum class LogType { DEBUG, V1, HINT, WARNING, ERROR, BUG, }; // clang-format on class Log { public: Log(const Log& other) = delete; Log& operator=(const Log& other) = delete; Log(Log&& other) = delete; Log& operator=(Log&& other) = delete; static Log& get(); void take_input(LogType type, std::optional&& source_location, std::optional>&& source_context, std::ostream& out, std::string&& msg); void enable(LogType type) { enabled_map_[type] = true; } void disable(LogType type) { assert(type != LogType::BUG && type != LogType::ERROR); enabled_map_[type] = false; } bool is_enabled(LogType type) { return enabled_map_[type]; } void set_colorize(bool is_colorize) { is_colorize_ = is_colorize; } private: Log(); ~Log() = default; std::unordered_map enabled_map_; bool is_colorize_ = false; }; class LogStream { public: LogStream(const std::string& file, int line, LogType type, std::ostream& out = std::cerr); LogStream(const std::string& file, int line, LogType type, std::string&& source_location, std::ostream& out = std::cerr); LogStream(const std::string& file, int line, LogType type, std::string&& source_location, std::vector&& source_context, std::ostream& out = std::cerr); template LogStream& operator<<(const T& v) { auto& sink = Log::get(); if (sink.is_enabled(type_)) buf_ << v; return *this; } virtual ~LogStream(); protected: // This formats the `file_` and `line_` and may be used to prefix the message // for some types of log streams. std::string internal_location(); const std::string& file_; const int line_; LogType type_; std::optional source_location_; std::optional> source_context_; std::ostream& out_; std::ostringstream buf_; }; class LogStreamBug : public LogStream { public: LogStreamBug(const std::string& file, int line, __attribute__((unused)) LogType /*unused*/, std::ostream& out = std::cerr) : LogStream(file, line, LogType::BUG, out) {}; [[noreturn]] ~LogStreamBug() override; }; // clang-format off // Usage examples: // // 1. LOG(WARNING) << "this is a " << "warning!"; (this goes to std::cerr) // 2. LOG(DEBUG, std::cout) << "this is a " << " message."; // 3. LOG(ERROR, call.loc.source_location(), std::cerr) << "error with location"; // 4. LOG(ERROR, call.loc.source_location(), call.loc.source_context(), std::err) << "error with context"; // // Note: LogType::DEBUG will prepend __FILE__ and __LINE__ to the debug message. #define LOGSTREAM_COMMON(...) bpftrace::LogStream(__FILE__, __LINE__, __VA_ARGS__) #define LOGSTREAM_DEBUG(...) LOGSTREAM_COMMON(__VA_ARGS__) #define LOGSTREAM_V1(...) LOGSTREAM_COMMON(__VA_ARGS__) #define LOGSTREAM_HINT(...) LOGSTREAM_COMMON(__VA_ARGS__) #define LOGSTREAM_WARNING(...) LOGSTREAM_COMMON(__VA_ARGS__) #define LOGSTREAM_ERROR(...) LOGSTREAM_COMMON(__VA_ARGS__) #define LOGSTREAM_BUG(...) bpftrace::LogStreamBug(__FILE__, __LINE__, __VA_ARGS__) // clang-format on #define LOG(type, ...) LOGSTREAM_##type(bpftrace::LogType::type, ##__VA_ARGS__) #define DISABLE_LOG(type) bpftrace::Log::get().disable(LogType::type) #define ENABLE_LOG(type) bpftrace::Log::get().enable(LogType::type) }; // namespace bpftrace bpftrace-0.27.1/src/main.cpp000066400000000000000000001172141526721631600156250ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "aot/aot.h" #include "ast/diagnostic.h" #include "ast/helpers.h" #include "ast/pass_manager.h" #include "ast/passes/attachpoint_passes.h" #include "ast/passes/clang_build.h" #include "ast/passes/clang_parser.h" #include "ast/passes/codegen_llvm.h" #include "ast/passes/control_flow_analyser.h" #include "ast/passes/macro_expansion.h" #include "ast/passes/map_sugar.h" #include "ast/passes/named_param.h" #include "ast/passes/parse_passes.h" #include "ast/passes/pid_filter_pass.h" #include "ast/passes/portability_analyser.h" #include "ast/passes/printer.h" #include "ast/passes/recursion_check.h" #include "ast/passes/resource_analyser.h" #include "ast/passes/types/pre_type_check.h" #include "ast/passes/types/type_resolver.h" #include "ast/passes/types/type_system.h" #include "benchmark.h" #include "bpffeature.h" #include "bpftrace.h" #include "btf.h" #include "build_info.h" #include "config.h" #include "globalvars.h" #include "lockdown.h" #include "log.h" #include "output/buffer_mode.h" #include "probe_matcher.h" #include "run_bpftrace.h" #include "symbols/kernel.h" #include "symbols/user.h" #include "util/env.h" #include "util/int_parser.h" #include "util/proc.h" #include "util/strings.h" #include "util/temp.h" #include "version.h" using namespace bpftrace; namespace { enum class Mode { NONE = 0, CODEGEN, COMPILER_BENCHMARK, BPF_BENCHMARK, BPF_TEST, FORMAT, }; enum class BuildMode { // Compile script and run immediately DYNAMIC = 0, // Compile script into portable executable AHEAD_OF_TIME, }; enum Options { AOT = 2000, BENCH, // Alias for --mode=bench. BTF, CMD, DEBUG, DEBUGINFO, DRY_RUN, DWARF_PID, EMIT_ELF, EMIT_LLVM, FMT, // Alias for --mode=format. HELP, INCLUDE, INFO, LIST, NO_FEATURE, NO_WARNING, MODE, OUTPUT, PID, PROBE_FILTER, QUIET, TEST, // Alias for --mode=test. TRACEABLE_FUNCTIONS, UNSAFE, USDT_SEMAPHORE, VERBOSE, VERIFY_LLVM_IR, VERSION, WARNINGS, }; constexpr auto FULL_SEARCH = "*:*"; constexpr auto DEFAULT_DEBUG_INFO_PATHS = ":.debug:/usr/lib/debug"; } // namespace void usage(std::ostream& out) { // clang-format off out << "bpftrace - a high-level tracing language for Linux powered by BPF" << std::endl; out << std::endl; out << "USAGE:" << std::endl; out << " bpftrace [options] filename" << std::endl; out << " bpftrace [options] - " << std::endl; out << " bpftrace [options] -e 'program'" << std::endl; out << " use -- after filename/-e 'program' for named script parameters" << std::endl; out << std::endl; out << "OPTIONS:" << std::endl; out << " -e 'program' execute this program" << std::endl; out << " -l, --list [search|filename]" << std::endl; out << " list kernel probes or probes in a program" << std::endl; out << " -v, --verbose enable verbose messages; with -l, also show probe arguments" << std::endl; out << " -h, --help show this help message" << std::endl; out << " -V, --version bpftrace version" << std::endl; out << " --info print information about kernel BPF support" << std::endl; out << std::endl; out << " -p, --pid PID filter actions and enable USDT probes on PID" << std::endl; out << " -c, --cmd CMD run CMD and enable USDT probes on resulting process" << std::endl; #ifdef HAVE_DW_UNWIND out << " --dwarf-pid PID" << std::endl; out << " add additional pids to the DWARF-unwinder" << std::endl; #endif out << " --usdt-file-activation" << std::endl; out << " activate usdt semaphores based on file path" << std::endl; out << std::endl; out << " -o, --output FILE" << std::endl; out << " redirect bpftrace output to FILE" << std::endl; out << " -f FORMAT output format ('text', 'json')" << std::endl; out << " -B MODE output buffering mode ('line', 'full', 'none')" << std::endl; out << " -q, --quiet keep messages quiet" << std::endl; out << " -k, --warnings emit a warning when probe read helpers return an error" << std::endl; out << " --no-warnings disable all warning messages" << std::endl; out << std::endl; out << " -I DIR add the directory to the include search path" << std::endl; out << " --include FILE add an #include file before preprocessing" << std::endl; out << " --debuginfo DIR[:DIR]" << std::endl; out << " add directories to the debug info search path" << std::endl; out << " --traceable-functions FILE" << std::endl; out << " load the list of traceable kernel functions from FILE" << std::endl; out << std::endl; out << " --unsafe allow unsafe/destructive functionality" << std::endl; out << " --no-feature FEATURE[,FEATURE]" << std::endl; out << " disable use of detected features" << std::endl; out << std::endl; out << "DEVELOPER OPTIONS:" << std::endl; out << " --mode MODE used for benchmarking and testing" << std::endl; out << " ('codegen', 'compiler-bench', 'bench', 'test', 'format')" << std::endl; out << " --test run all test: probes (same as --mode test)" << std::endl; out << " --bench run all bench: probes (same as --mode bench)" << std::endl; out << " --probe-filter REGEX" << std::endl; out << " only run probes whose name matches REGEX" << std::endl; out << " --fmt format the input script and print it" << std::endl; out << std::endl; out << "TROUBLESHOOTING OPTIONS:" << std::endl; out << " --dry-run terminate execution right after attaching all the probes" << std::endl; out << " --verify-llvm-ir" << std::endl; out << " check that the generated LLVM IR is valid" << std::endl; out << " -d, --debug STAGE" << std::endl; out << " debug info for various stages of bpftrace execution" << std::endl; out << " ('all', 'ast', 'types', 'codegen', 'codegen-opt', 'libbpf', 'verifier')" << std::endl; out << " ('parse', 'dis') - available on debug builds" << std::endl; out << " --emit-elf FILE" << std::endl; out << " (dry run) generate ELF file with bpf programs and write to FILE" << std::endl; out << " --emit-llvm FILE" << std::endl; out << " write LLVM IR to FILE.original.ll and FILE.optimized.ll" << std::endl; out << std::endl; out << "CONFIGURATION:" << std::endl; out << " bpftrace also supports environment variables and config options" << std::endl; out << " for tuning behavior. See 'man bpftrace' or the online documentation" << std::endl; out << " for the full list." << std::endl; out << std::endl; out << "EXAMPLES:" << std::endl; out << R"( bpftrace -e 'kprobe:do_nanosleep { printf("PID %d sleeping...\n", pid); }')" << std::endl; out << " trace processes calling sleep" << std::endl; out << " bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }'" << std::endl; out << " count syscalls by process name" << std::endl; out << R"( bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args.filename)); }')" << std::endl; out << " trace file opens with process name and path" << std::endl; out << " bpftrace -e 'profile:hz:99 { @[kstack] = count(); }'" << std::endl; out << " profile kernel stacks at 99 Hertz" << std::endl; out << " bpftrace -e 'tracepoint:block:block_rq_issue { @ = hist(args.bytes); }'" << std::endl; out << " histogram of block I/O request sizes" << std::endl; out << R"( bpftrace -p 1337 -e 'uprobe:/usr/lib/libc.so.6:malloc { @[ustack] = count(); }')" << std::endl; out << " count malloc calls by user stack for a specific process" << std::endl; out << " bpftrace -l '*sleep*'" << std::endl; out << " list probes containing \"sleep\"" << std::endl; out << " bpftrace -lv 'kprobe:do_nanosleep'" << std::endl; out << " show the arguments for the do_nanosleep kprobe" << std::endl; out << std::endl; out << "DOCUMENTATION:" << std::endl; out << " https://bpftrace.org" << std::endl; out << " https://github.com/bpftrace/bpftrace" << std::endl; // clang-format on } static void enforce_infinite_rlimit_memlock() { struct rlimit rl = {}; int err; rl.rlim_max = RLIM_INFINITY; rl.rlim_cur = rl.rlim_max; err = setrlimit(RLIMIT_MEMLOCK, &rl); if (err) LOG(WARNING) << std::strerror(err) << ": couldn't set RLIMIT_MEMLOCK for " << "bpftrace. If your program is not loading, you can try " << "\"ulimit -l 8192\" to fix the problem"; } static void info(BPFnofeature no_feature) { struct utsname utsname; uname(&utsname); auto btf = bpftrace::BTF(); std::cout << "System" << std::endl << " OS: " << utsname.sysname << " " << utsname.release << " " << utsname.version << std::endl << " Arch: " << utsname.machine << std::endl; std::cout << std::endl; std::cout << BuildInfo::report(); std::cout << std::endl; std::cout << BPFfeature(no_feature, btf).report(); } static std::optional get_delta_with_boottime(int clock_type) { std::optional ret = std::nullopt; long lowest_delta = std::numeric_limits::max(); // Run the "triple vdso sandwich" 5 times, taking the result from the // iteration with the lowest delta between first and last clock_gettime() // calls. for (int i = 0; i < 5; ++i) { struct timespec before, after, boottime; long delta; if (::clock_gettime(clock_type, &before)) continue; if (::clock_gettime(CLOCK_BOOTTIME, &boottime)) continue; if (::clock_gettime(clock_type, &after)) continue; // There's no way 3 VDSO calls should take more than 1s. We'll // also ignore the case where we cross a 1s boundary b/c that // can only happen once and we're running this loop 5 times. // This helps keep the math simple. if (before.tv_sec != after.tv_sec) continue; delta = after.tv_nsec - before.tv_nsec; // Time went backwards if (delta < 0) continue; // Lowest delta seen so far, compute boot realtime and store it if (delta < lowest_delta) { struct timespec delta_with_boottime; long nsec_avg = (before.tv_nsec + after.tv_nsec) / 2; if (nsec_avg - boottime.tv_nsec < 0) { delta_with_boottime.tv_sec = after.tv_sec - boottime.tv_sec - 1; delta_with_boottime.tv_nsec = nsec_avg - boottime.tv_nsec + 1e9; } else { delta_with_boottime.tv_sec = after.tv_sec - boottime.tv_sec; delta_with_boottime.tv_nsec = nsec_avg - boottime.tv_nsec; } lowest_delta = delta; ret = delta_with_boottime; } } if (ret && lowest_delta >= 1e5) LOG(WARNING) << (lowest_delta / 1e3) << "us skew detected when calculating boot time. strftime() " "builtin may be inaccurate"; return ret; } static std::optional get_boottime() { return get_delta_with_boottime(CLOCK_REALTIME); } static std::optional get_delta_taitime() { return get_delta_with_boottime(CLOCK_TAI); } std::vector extra_flags( BPFtrace& bpftrace, const std::vector& include_dirs, const std::vector& include_files) { std::string ksrc, kobj; struct utsname utsname; std::vector extra_flags; uname(&utsname); bool found_kernel_headers = symbols::get_kernel_dirs(utsname, ksrc, kobj); if (found_kernel_headers) extra_flags = get_kernel_cflags( utsname.machine, ksrc, kobj, bpftrace.kconfig); for (auto dir : include_dirs) { extra_flags.emplace_back("-I"); extra_flags.push_back(dir); } for (auto file : include_files) { extra_flags.emplace_back("-include"); extra_flags.push_back(file); } return extra_flags; } struct Args { std::string pid_str; std::vector dwarf_pids_str; std::string cmd_str; bool listing = false; bool safe_mode = true; bool usdt_file_activation = false; int warning_level = 1; bool verify_llvm_ir = false; Mode mode = Mode::NONE; std::string script; std::string search; std::string filename; std::string debuginfo_path; std::string output_file; std::string output_format; std::string output_elf; std::string output_llvm; std::string aot; BPFnofeature no_feature; OutputBufferConfig obc = OutputBufferConfig::UNSET; BuildMode build_mode = BuildMode::DYNAMIC; std::vector include_dirs; std::vector include_files; std::vector params; std::vector debug_stages; std::vector named_params; std::string probe_filter; std::string traceable_functions_file; }; void CreateDynamicPasses(std::function add) { add(ast::CreateClangBuildPass()); add(ast::CreateTypeSystemPass()); add(ast::CreatePreTypeCheckPass()); add(ast::CreateTypeResolverPass()); add(ast::CreateResourcePass()); } void CreateAotPasses(std::function add) { add(ast::CreatePortabilityPass()); add(ast::CreateClangBuildPass()); add(ast::CreateTypeSystemPass()); add(ast::CreatePreTypeCheckPass()); add(ast::CreateTypeResolverPass()); add(ast::CreateResourcePass()); } ast::Pass printPass(const std::string& name) { return ast::Pass::create("print-" + name, [=](ast::ASTContext& ast) { std::cerr << "AST after: " << name << std::endl; std::cerr << "-------------------" << std::endl; ast::Printer printer(ast, std::cerr); printer.visit(ast.root); std::cerr << std::endl; }); }; static bool parse_debug_stages(const std::string& arg) { auto stages = util::split_string(arg, ',', /* remove_empty= */ true); for (const auto& stage : stages) { if (debug_stages.contains(stage)) { bt_debug.insert(debug_stages.at(stage)); } else if (stage == "all") { for (const auto& [_, s] : debug_stages) bt_debug.insert(s); } else { LOG(ERROR) << "USAGE: invalid option for -d: " << stage; return false; } } return true; } Args parse_args(int argc, char* argv[]) { Args args; const char* const short_options = "d:bB:f:e:hlp:vqc:Vo:I:k"; option long_options[] = { option{ .name = "aot", .has_arg = required_argument, .flag = nullptr, .val = Options::AOT }, option{ .name = "bench", .has_arg = no_argument, .flag = nullptr, .val = Options::BENCH }, option{ .name = "btf", .has_arg = no_argument, .flag = nullptr, .val = Options::BTF }, option{ .name = "cmd", .has_arg = required_argument, .flag = nullptr, .val = Options::CMD }, option{ .name = "debug", .has_arg = required_argument, .flag = nullptr, .val = Options::DEBUG }, option{ .name = "debuginfo", .has_arg = required_argument, .flag = nullptr, .val = Options::DEBUGINFO }, option{ .name = "dry-run", .has_arg = no_argument, .flag = nullptr, .val = Options::DRY_RUN }, option{ .name = "emit-elf", .has_arg = required_argument, .flag = nullptr, .val = Options::EMIT_ELF }, option{ .name = "emit-llvm", .has_arg = required_argument, .flag = nullptr, .val = Options::EMIT_LLVM }, option{ .name = "fmt", .has_arg = no_argument, .flag = nullptr, .val = Options::FMT }, option{ .name = "help", .has_arg = no_argument, .flag = nullptr, .val = Options::HELP }, option{ .name = "include", .has_arg = required_argument, .flag = nullptr, .val = Options::INCLUDE }, option{ .name = "info", .has_arg = no_argument, .flag = nullptr, .val = Options::INFO }, option{ .name = "list", .has_arg = no_argument, .flag = nullptr, .val = Options::LIST }, option{ .name = "no-feature", .has_arg = required_argument, .flag = nullptr, .val = Options::NO_FEATURE }, option{ .name = "no-warnings", .has_arg = no_argument, .flag = nullptr, .val = Options::NO_WARNING }, option{ .name = "output", .has_arg = required_argument, .flag = nullptr, .val = Options::OUTPUT }, option{ .name = "pid", .has_arg = required_argument, .flag = nullptr, .val = Options::PID }, option{ .name = "probe-filter", .has_arg = required_argument, .flag = nullptr, .val = Options::PROBE_FILTER }, option{ .name = "quiet", .has_arg = no_argument, .flag = nullptr, .val = Options::QUIET }, option{ .name = "test", .has_arg = no_argument, .flag = nullptr, .val = Options::TEST }, option{ .name = "mode", .has_arg = required_argument, .flag = nullptr, .val = Options::MODE }, option{ .name = "unsafe", .has_arg = no_argument, .flag = nullptr, .val = Options::UNSAFE }, option{ .name = "dwarf-pid", .has_arg = required_argument, .flag = nullptr, .val = Options::DWARF_PID }, option{ .name = "usdt-file-activation", .has_arg = no_argument, .flag = nullptr, .val = Options::USDT_SEMAPHORE }, option{ .name = "verbose", .has_arg = no_argument, .flag = nullptr, .val = Options::VERBOSE }, option{ .name = "verify-llvm-ir", .has_arg = no_argument, .flag = nullptr, .val = Options::VERIFY_LLVM_IR }, option{ .name = "version", .has_arg = no_argument, .flag = nullptr, .val = Options::VERSION }, option{ .name = "warnings", .has_arg = no_argument, .flag = nullptr, .val = Options::WARNINGS }, option{ .name = "traceable-functions", .has_arg = required_argument, .flag = nullptr, .val = Options::TRACEABLE_FUNCTIONS }, option{ .name = nullptr, .has_arg = 0, .flag = nullptr, .val = 0 }, // Must // be // last }; int c; while ((c = getopt_long(argc, argv, short_options, long_options, nullptr)) != -1) { switch (c) { case Options::INFO: // --info check_privileges(); info(args.no_feature); exit(0); break; case Options::EMIT_ELF: // --emit-elf args.output_elf = optarg; break; case Options::EMIT_LLVM: args.output_llvm = optarg; break; case Options::NO_WARNING: // --no-warnings if (args.warning_level == 2) { LOG(ERROR) << "USAGE: -k, --warnings conflicts with --no-warnings"; exit(1); } DISABLE_LOG(WARNING); args.warning_level = 0; break; case Options::MODE: // --mode if (std::strcmp(optarg, "codegen") == 0) { args.mode = Mode::CODEGEN; } else if (std::strcmp(optarg, "compiler-bench") == 0) { args.mode = Mode::COMPILER_BENCHMARK; } else if (std::strcmp(optarg, "bench") == 0) { args.mode = Mode::BPF_BENCHMARK; } else if (std::strcmp(optarg, "test") == 0) { args.mode = Mode::BPF_TEST; } else if (std::strcmp(optarg, "format") == 0) { args.mode = Mode::FORMAT; } else { LOG(ERROR) << "USAGE: --mode can only be 'codegen', " "'compiler-bench', 'bench', 'test' or 'format'."; exit(1); } break; case Options::TEST: // --test if (args.mode != Mode::NONE) { LOG(ERROR) << "USAGE: --test conflicts with existing --mode"; exit(1); } args.mode = Mode::BPF_TEST; break; case Options::BENCH: // --bench if (args.mode != Mode::NONE) { LOG(ERROR) << "USAGE: --bench conflicts with existing --mode"; exit(1); } args.mode = Mode::BPF_BENCHMARK; break; case Options::FMT: // --fmt if (args.mode != Mode::NONE) { LOG(ERROR) << "USAGE: --fmt conflicts with existing --mode"; exit(1); } args.mode = Mode::FORMAT; break; case Options::AOT: // --aot args.aot = optarg; args.build_mode = BuildMode::AHEAD_OF_TIME; break; case Options::NO_FEATURE: // --no-feature if (args.no_feature.parse(optarg)) { LOG(ERROR) << "USAGE: --no-feature can only have values " "'kprobe_multi,kprobe_session,uprobe_multi'."; exit(1); } break; case Options::DRY_RUN: dry_run = true; break; case Options::VERIFY_LLVM_IR: args.verify_llvm_ir = true; break; case 'o': case Options::OUTPUT: args.output_file = optarg; break; case 'd': case Options::DEBUG: if (!parse_debug_stages(optarg)) exit(1); break; case 'q': case Options::QUIET: bt_quiet = true; break; case 'v': case Options::VERBOSE: ENABLE_LOG(V1); bt_verbose = true; break; case 'B': if (std::strcmp(optarg, "line") == 0) { args.obc = OutputBufferConfig::LINE; } else if (std::strcmp(optarg, "full") == 0) { args.obc = OutputBufferConfig::FULL; } else if (std::strcmp(optarg, "none") == 0) { args.obc = OutputBufferConfig::NONE; } else { LOG(ERROR) << "USAGE: -B must be either 'line', 'full', or 'none'."; exit(1); } break; case 'f': args.output_format = optarg; break; case 'e': args.script = optarg; break; case 'p': case Options::PID: args.pid_str = optarg; break; case Options::PROBE_FILTER: args.probe_filter = optarg; break; #ifdef HAVE_DW_UNWIND case Options::DWARF_PID: args.dwarf_pids_str.emplace_back(optarg); break; #endif case 'I': args.include_dirs.emplace_back(optarg); break; case Options::INCLUDE: args.include_files.emplace_back(optarg); break; case 'l': case Options::LIST: args.listing = true; break; case 'c': case Options::CMD: args.cmd_str = optarg; break; case Options::USDT_SEMAPHORE: args.usdt_file_activation = true; break; case Options::UNSAFE: args.safe_mode = false; break; case 'b': case Options::BTF: break; case Options::DEBUGINFO: args.debuginfo_path += optarg; args.debuginfo_path += ":"; break; case 'h': case Options::HELP: usage(std::cout); exit(0); case 'V': case Options::VERSION: std::cout << "bpftrace " << BPFTRACE_VERSION << std::endl; exit(0); case 'k': case Options::WARNINGS: if (args.warning_level == 2) { LOG(ERROR) << "USAGE: -kk has been deprecated. Use a single -k for " "runtime warnings for errors in map " "lookups and probe reads."; exit(1); } if (args.warning_level == 0) { LOG(ERROR) << "USAGE: -k, --warnings conflicts with --no-warnings"; exit(1); } args.warning_level = 2; break; case Options::TRACEABLE_FUNCTIONS: args.traceable_functions_file = optarg; break; default: usage(std::cerr); exit(1); } } if (argc == 1) { usage(std::cerr); exit(1); } if (!args.cmd_str.empty() && !args.pid_str.empty()) { LOG(ERROR) << "USAGE: Cannot use both -c and -p."; usage(std::cerr); exit(1); } // Difficult to serialize flex generated types if (args.warning_level == 2 && args.build_mode == BuildMode::AHEAD_OF_TIME) { LOG(ERROR) << "Cannot use -k with --aot"; exit(1); } if (args.listing) { // Expect zero or one positional arguments if (optind == argc) { args.search = FULL_SEARCH; } else if (optind == argc - 1) { std::string val(argv[optind]); if (std::filesystem::exists(val)) { args.filename = val; } else { if (val == "*") { args.search = FULL_SEARCH; } else { args.search = val; } } optind++; } else { usage(std::cerr); exit(1); } } else { // Expect to find a script either through -e or filename if (args.script.empty() && argv[optind] == nullptr) { LOG(ERROR) << "USAGE: filename or -e 'program' required."; exit(1); } // If no script was specified with -e, then we expect to find a script file if (args.script.empty()) { args.filename = argv[optind]; optind++; } // Parse positional and named parameters. while (optind < argc) { auto pos_arg = std::string(argv[optind]); if (pos_arg.starts_with("--")) { args.named_params.emplace_back(pos_arg.substr(2)); } else { args.params.emplace_back(argv[optind]); } optind++; } } return args; } bool is_colorize() { const char* color_env = std::getenv("BPFTRACE_COLOR"); if (!color_env) { return isatty(STDOUT_FILENO) && isatty(STDERR_FILENO); } std::string_view mode(color_env); if (mode == "always") { return true; } else if (mode == "never") { return false; } else { if (mode != "auto") { LOG(WARNING) << "Invalid env value! The valid values of `BPFTRACE_COLOR` " "are [auto|always|never]. The current value is " << mode << "!"; } return isatty(STDOUT_FILENO) && isatty(STDERR_FILENO); } } void list_probes(BPFtrace& bpftrace, const std::string& search, const symbols::KernelInfo& kernel_func_info, const symbols::UserInfoImpl& user_func_info) { if (search.find(".") != std::string::npos && search.find_first_of(":*") == std::string::npos) { LOG(WARNING) << "It appears that \'" << search << "\' is a filename but the file does not exist. Treating \'" << search << "\' as a search pattern."; } for (auto& rawprobe : util::split_string(search, ',')) { std::string probe = util::normalize_whitespace(rawprobe); bool is_search_a_type = is_type_name(probe); // Ensure that BTF is loaded for all listing. auto parts = util::split_string(probe, ':'); if (is_search_a_type || parts.empty() || parts.size() < 3) { bpftrace.btf_->load_module_btfs(kernel_func_info.get_modules()); } else { bpftrace.btf_->load_module_btfs(kernel_func_info.get_modules(parts[1])); } // Use ProbeMatcher directly to list probes matching the search pattern. ProbeMatcher probe_matcher(&bpftrace, kernel_func_info, user_func_info); if (is_search_a_type) { for (const auto& s : probe_matcher.get_structs_for_listing(probe)) { std::cout << s << std::endl; } } else { // For patterns without a colon (like "*do_nanosleep*"), treat as // wildcard probe type with the pattern as function match. std::string value = probe; if (value.empty()) { value = "*:*"; } else if (value.find(':') == std::string::npos) { value = "*:" + value; } for (const auto& probe : probe_matcher.get_probes_for_listing(value, bpftrace.pid())) { std::cout << probe << std::endl; } } } } uint64_t parse_pid(std::string const& pid_str) { auto maybe_pid = util::to_uint(pid_str); if (!maybe_pid) { LOG(ERROR) << "Failed to parse pid: " << maybe_pid.takeError(); exit(1); } if (*maybe_pid > 0x400000) { // The actual maximum pid depends on the configuration for the specific // system, i.e. read from `/proc/sys/kernel/pid_max`. We can impose a // basic sanity check here against the nominal maximum for 64-bit // systems. LOG(ERROR) << "Pid out of range: " << *maybe_pid; exit(1); } return *maybe_pid; } int main(int argc, char* argv[]) { Log::get().set_colorize(is_colorize()); Args args = parse_args(argc, argv); switch (args.obc) { case OutputBufferConfig::UNSET: case OutputBufferConfig::LINE: std::setvbuf(stdout, nullptr, _IOLBF, BUFSIZ); break; case OutputBufferConfig::FULL: std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ); break; case OutputBufferConfig::NONE: std::setvbuf(stdout, nullptr, _IONBF, BUFSIZ); break; } libbpf_set_print(libbpf_print); auto config = std::make_unique(!args.cmd_str.empty()); BPFtrace bpftrace(args.no_feature, std::move(config)); // This is our primary program AST context. Initially it is empty, i.e. // there is no filename set or source file. The way we set it up depends on // the mode of execution below, and we expect that it will be reinitialized. ast::ASTContext ast; if (!args.filename.empty()) { std::stringstream buf; if (args.filename == "-") { std::string line; while (std::getline(std::cin, line)) { // Note we may add an extra newline if the input doesn't end in a new // line. This should not matter because bpftrace (the language) is not // whitespace sensitive. buf << line << std::endl; } ast = ast::ASTContext("stdin", buf.str()); } else { std::ifstream file(args.filename); if (file.fail()) { LOG(ERROR) << "failed to open file '" << args.filename << "': " << std::strerror(errno); exit(1); } buf << file.rdbuf(); ast = ast::ASTContext(args.filename, buf.str()); } } else { // Script is provided as a command line argument. ast = ast::ASTContext("stdin", args.script); } // Formatting is a purely local operation: we parse the source and print it // back out, without loading any BPF. Handle it before check_privileges() and // any kernel symbol loading so that it can be run as an unprivileged user. if (args.mode == Mode::FORMAT) { // For formatting, we parse the full file, but don't apply any other passes // or use any other diagnostics. It only matters whether the parse itself // was successful, and then we emit the formatted source code. ast::PassManager pm; pm.put(ast); pm.put(bpftrace); pm.add(CreateParsePass(bt_debug.contains(DebugStage::Parse))); auto ok = pm.run(); if (!ok) { std::cerr << ok.takeError() << "\n"; return 2; } if (!ast.diagnostics().ok()) { // We didn't successfully parse the file, so can't format it. ast.diagnostics().emit(std::cerr); return 1; } if (!args.output_file.empty()) { // To make this operation safe, we open a temporary file next to the // intented output file, and atomically rename when completed. auto file = util::TempFile::create(args.output_file + ".XXXXXX"); if (!file) { LOG(ERROR) << "unable to create temporary file: " << file.takeError(); return 1; } std::ofstream out(file->path()); if (out.fail()) { LOG(ERROR) << "failed to open file '" << file->path() << "': " << std::strerror(errno); return 1; } ast::Printer printer(ast, out, ast::FormatMode::Full); printer.visit(ast.root); std::filesystem::rename(file->path(), args.output_file); } else { ast::Printer printer(ast, std::cout, ast::FormatMode::Full); printer.visit(ast.root); } return 0; // All done. } check_privileges(); // Create function info objects for probe matching and pass state. auto kernel_func_info = symbols::KernelInfoImpl::open( args.traceable_functions_file); if (!kernel_func_info) { LOG(ERROR) << "Failed to open kernel function info: " << kernel_func_info.takeError(); return 1; } symbols::UserInfoImpl user_func_info; ast::FunctionInfo func_info_state(*kernel_func_info, user_func_info); bpftrace.usdt_file_activation_ = args.usdt_file_activation; bpftrace.safe_mode_ = args.safe_mode; bpftrace.warning_level_ = args.warning_level; bpftrace.boottime_ = get_boottime(); bpftrace.delta_taitime_ = get_delta_taitime(); bpftrace.run_tests_ = args.mode == Mode::BPF_TEST; bpftrace.run_benchmarks_ = args.mode == Mode::BPF_BENCHMARK; bpftrace.probe_filter_ = args.probe_filter; bpftrace.debuginfo_path_ = args.debuginfo_path + DEFAULT_DEBUG_INFO_PATHS; if (!args.pid_str.empty()) { auto pid = parse_pid(args.pid_str); auto proc = util::create_proc(pid); if (!proc) { LOG(ERROR) << "Failed to attach to pid: " << proc.takeError(); exit(1); } bpftrace.procmon_ = std::move(*proc); } for (auto const& pid_str : args.dwarf_pids_str) { auto pid = parse_pid(pid_str); bpftrace.dwarf_pids_.emplace_back(pid); } if (!args.cmd_str.empty()) { bpftrace.cmd_ = args.cmd_str; auto child = util::create_child(args.cmd_str); if (!child) { LOG(ERROR) << "Failed to fork child: " << child.takeError(); exit(1); } bpftrace.child_ = std::move(*child); } // Listing probes when there is no program. if (args.listing && args.script.empty() && args.filename.empty()) { list_probes(bpftrace, args.search, *kernel_func_info, user_func_info); return 0; } for (const auto& param : args.params) { bpftrace.add_param(param); } // If we are not running anything, then we don't require privileges. if (args.mode == Mode::NONE || args.mode == Mode::BPF_TEST || args.mode == Mode::BPF_BENCHMARK) { auto lockdown_state = lockdown::detect(); if (lockdown_state == lockdown::LockdownState::Confidentiality) { lockdown::emit_warning(std::cerr); return 1; } // FIXME (mmarchini): maybe we don't want to always enforce an infinite // rlimit? enforce_infinite_rlimit_memlock(); } // Temporarily, we make the full `BPFTrace` object available via the pass // manager (and objects are temporarily mutable). As passes are refactored // into lighter-weight components, the `BPFTrace` object should be // decomposed into its meaningful parts. Furthermore, the codegen and field // analysis passes will be rolled into the pass manager as regular passes; // the final binary is merely one of the outputs that can be extracted. ast::PassManager pm; pm.put(ast); pm.put(bpftrace); pm.put(func_info_state); auto flags = extra_flags(bpftrace, args.include_dirs, args.include_files); if (args.listing) { // For listing with a program, run the full parse passes (including // expansion) and then use ProbeMatcher to expand and list probes. for (auto& pass : ast::AllParsePasses( std::move(flags), {}, bt_debug.contains(DebugStage::Parse))) { pm.add(std::move(pass)); } auto pmresult = pm.run(); if (!pmresult) { std::cerr << pmresult.takeError() << "\n"; return 2; } else if (!ast.diagnostics().ok()) { ast.diagnostics().emit(std::cerr); return 1; } // Use ProbeMatcher to expand and list the probes. ProbeMatcher probe_matcher(&bpftrace, *kernel_func_info, user_func_info); for (const auto& probe : probe_matcher.get_probes_for_listing(ast.root)) { std::cout << probe << std::endl; } return 0; } // Wrap all added passes in passes that dump the intermediate state. These // could dump intermediate objects from the context as well, but preserve // existing behavior for now. auto addPass = [&pm](ast::Pass&& pass) { auto name = pass.name(); pm.add(std::move(pass)); if (bt_debug.contains(DebugStage::Ast)) { pm.add(printPass(name)); } }; // Start with all the basic parsing steps. for (auto& pass : ast::AllParsePasses(std::move(flags), {}, bt_debug.contains(DebugStage::Parse))) { addPass(std::move(pass)); } pm.add(ast::CreateLLVMInitPass()); switch (args.build_mode) { case BuildMode::DYNAMIC: CreateDynamicPasses(addPass); break; case BuildMode::AHEAD_OF_TIME: CreateAotPasses(addPass); break; } if (bt_debug.contains(DebugStage::Types)) { pm.add(ast::CreateDumpTypesPass(std::cout)); } pm.add(ast::CreateCompilePass()); pm.add(ast::CreateLinkBitcodePass()); if (bt_debug.contains(DebugStage::Codegen)) { pm.add(ast::Pass::create("dump-ir-prefix", [&] { std::cout << "LLVM IR before optimization\n"; std::cout << "---------------------------\n\n"; })); pm.add(ast::CreateDumpIRPass(std::cout)); } std::optional output_ir; if (!args.output_llvm.empty()) { output_ir = std::ofstream(args.output_llvm + ".original.ll"); pm.add(ast::CreateDumpIRPass(*output_ir)); } if (args.verify_llvm_ir) { pm.add(ast::CreateVerifyPass()); } pm.add(ast::CreateOptimizePass()); if (bt_debug.contains(DebugStage::CodegenOpt)) { pm.add(ast::Pass::create("dump-ir-opt-prefix", [&] { std::cout << "\nLLVM IR after optimization\n"; std::cout << "----------------------------\n\n"; })); pm.add(ast::CreateDumpIRPass(std::cout)); } std::optional output_ir_opt; if (!args.output_llvm.empty()) { output_ir_opt = std::ofstream(args.output_llvm + ".optimized.ll"); pm.add(ast::CreateDumpIRPass(*output_ir_opt)); } pm.add(ast::CreateObjectPass()); if (bt_debug.contains(DebugStage::Disassemble)) { pm.add(ast::Pass::create("dump-asm-prefix", [&] { std::cout << "\nDisassembled bytecode\n"; std::cout << "----------------------------\n\n"; })); pm.add(ast::CreateDumpASMPass(std::cout)); } if (!args.output_elf.empty()) { pm.add(ast::Pass::create("dump-elf", [&](ast::BpfObject& obj) { std::ofstream out(args.output_elf); out.write(obj.data.data(), obj.data.size()); })); } pm.add(ast::CreateExternObjectPass()); pm.add(ast::CreateLinkPass()); if (args.mode == Mode::COMPILER_BENCHMARK) { info(args.no_feature); auto ok = benchmark(std::cout, pm); if (!ok) { std::cerr << "Benchmark error: " << ok.takeError(); return 1; } return 0; } auto pmresult = pm.run(); if (!pmresult) { std::cerr << pmresult.takeError() << "\n"; return 2; } else if (!ast.diagnostics().ok()) { ast.diagnostics().emit(std::cerr); return 1; } // Emits warnings ast.diagnostics().emit(std::cerr); if (args.build_mode == BuildMode::AHEAD_OF_TIME) { // Note: this should use the fully-linked version in the future, but // presently it is just using the single object. auto& out = pmresult->get(); return aot::generate( bpftrace.resources, args.aot, out.data.data(), out.data.size()); } if (args.mode == Mode::CODEGEN) return 0; auto c_definitions = pmresult->get(); auto& bytecode = pmresult->get(); return run_bpftrace(bpftrace, args.output_file, args.output_format, c_definitions, bytecode, std::move(args.named_params), args.obc); } bpftrace-0.27.1/src/map_info.h000066400000000000000000000040371526721631600161340ustar00rootroot00000000000000#pragma once #include #include "types.h" namespace bpftrace { struct HistogramArgs { long bits = -1; bool scalar = true; bool operator==(const HistogramArgs &other) { return bits == other.bits && scalar == other.scalar; } bool operator!=(const HistogramArgs &other) { return !(*this == other); } private: friend class cereal::access; template void serialize(Archive &archive) { archive(bits, scalar); } }; struct LinearHistogramArgs { long min = -1; long max = -1; long step = -1; bool scalar = true; bool operator==(const LinearHistogramArgs &other) { return min == other.min && max == other.max && step == other.step && scalar == other.scalar; } bool operator!=(const LinearHistogramArgs &other) { return !(*this == other); } private: friend class cereal::access; template void serialize(Archive &archive) { archive(min, max, step, scalar); } }; struct TSeriesArgs { long interval_ns = -1; long num_intervals = -1; SizedType value_type; TSeriesAggFunc agg; bool operator==(const TSeriesArgs &other) { return interval_ns == other.interval_ns && num_intervals == other.num_intervals && value_type == other.value_type && agg == other.agg; } bool operator!=(const TSeriesArgs &other) { return !(*this == other); } private: friend class cereal::access; template void serialize(Archive &archive) { archive(interval_ns, num_intervals, value_type, agg); } }; struct MapInfo { SizedType key_type; SizedType value_type; std::variant detail; int id = -1; int max_entries = -1; bpf_map_type bpf_type = BPF_MAP_TYPE_HASH; bool is_scalar = false; private: friend class cereal::access; template void serialize(Archive &archive) { archive(key_type, value_type, detail, id, max_entries, bpf_type, is_scalar); } }; } // namespace bpftrace bpftrace-0.27.1/src/output/000077500000000000000000000000001526721631600155275ustar00rootroot00000000000000bpftrace-0.27.1/src/output/CMakeLists.txt000066400000000000000000000001441526721631600202660ustar00rootroot00000000000000add_library(output STATIC json.cpp output.cpp text.cpp ) target_link_libraries(output util) bpftrace-0.27.1/src/output/buffer_mode.h000066400000000000000000000002721526721631600201560ustar00rootroot00000000000000// Lightweight shared enum for output buffering mode #pragma once namespace bpftrace { enum class OutputBufferConfig { UNSET = 0, LINE, FULL, NONE, }; } // namespace bpftrace bpftrace-0.27.1/src/output/capture.h000066400000000000000000000042731526721631600173510ustar00rootroot00000000000000#pragma once #include "output/output.h" namespace bpftrace::output { class CaptureOutput : public Output { public: CaptureOutput(Output &output) : nested_(output) {}; // Simple passthrough. void map(const std::string &name, const Value &value) override { nested_.map(name, value); } void value(const Value &value) override { nested_.value(value); } void time(const std::string &time) override { nested_.time(time); } void cat(const std::string &cat) override { nested_.cat(cat); } void join(const std::string &join) override { nested_.join(join); } void syscall(const std::string &syscall) override { nested_.syscall(syscall); } // Special case: treat errorf as errors. void printf(const std::string &str, const SourceInfo &info, PrintfSeverity severity) override { if (severity == PrintfSeverity::ERROR) { error_count++; } nested_.printf(str, info, severity); } void test_result(const std::vector &all_tests, size_t index, std::chrono::nanoseconds duration, const std::vector &passed, std::string output) override { nested_.test_result(all_tests, index, duration, passed, output); } void benchmark_result(const std::vector &all_benches, size_t index, std::chrono::nanoseconds average, size_t iters) override { nested_.benchmark_result(all_benches, index, average, iters); } void end() override { nested_.end(); } // Increment our counters. void lost_events(uint64_t lost) override { lost_events_count += lost; nested_.lost_events(lost); } void attached_probes(uint64_t num_probes) override { attached_probes_count += num_probes; nested_.attached_probes(num_probes); } void runtime_error(int retcode, const RuntimeErrorInfo &info) override { error_count++; nested_.runtime_error(retcode, info); } size_t error_count = 0; size_t lost_events_count = 0; size_t attached_probes_count = 0; private: Output &nested_; }; } // namespace bpftrace::output bpftrace-0.27.1/src/output/discard.h000066400000000000000000000033071526721631600173140ustar00rootroot00000000000000#pragma once #include "output/output.h" namespace bpftrace::output { class DiscardOutput : public Output { public: DiscardOutput() = default; void map([[maybe_unused]] const std::string &name, [[maybe_unused]] const Value &value) override { } void value([[maybe_unused]] const Value &value) override { } void time([[maybe_unused]] const std::string &time) override { } void cat([[maybe_unused]] const std::string &cat) override { } void join([[maybe_unused]] const std::string &join) override { } void syscall([[maybe_unused]] const std::string &syscall) override { } void printf([[maybe_unused]] const std::string &str, [[maybe_unused]] const SourceInfo &info, [[maybe_unused]] PrintfSeverity severity) override { } void test_result([[maybe_unused]] const std::vector &all_tests, [[maybe_unused]] size_t index, [[maybe_unused]] std::chrono::nanoseconds duration, [[maybe_unused]] const std::vector &passed, [[maybe_unused]] std::string output) override { } void benchmark_result( [[maybe_unused]] const std::vector &all_benches, [[maybe_unused]] size_t index, [[maybe_unused]] std::chrono::nanoseconds average, [[maybe_unused]] size_t iters) override { } void end() override { } void lost_events([[maybe_unused]] uint64_t lost) override { } void attached_probes([[maybe_unused]] uint64_t num_probes) override { } void runtime_error([[maybe_unused]] int retcode, [[maybe_unused]] const RuntimeErrorInfo &info) override { } }; } // namespace bpftrace::output bpftrace-0.27.1/src/output/json.cpp000066400000000000000000000346731526721631600172210ustar00rootroot00000000000000#include #include #include "output/json.h" namespace bpftrace::output { template struct JsonEmitter; template <> struct JsonEmitter { static void emit(std::ostream &out, const bool &v) { if (v) { out << "true"; } else { out << "false"; } } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const std::string &s) { out << "\""; for (const char c : s) { switch (c) { case '"': out << "\\\""; break; case '\\': out << "\\\\"; break; case '\n': out << "\\n"; break; case '\r': out << "\\r"; break; case '\t': out << "\\t"; break; default: // c always >= '\x00' if (c <= '\x1f') { out << "\\u" << std::hex << std::setw(4) << std::setfill('0') << static_cast(c); } else { out << c; } } } out << "\""; } }; template requires(std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v) struct JsonEmitter { static void emit(std::ostream &out, const T &v) { // JSON does not support numbers other than floating point, therefore // we emit int64_t as a string if it is not representable as a 64-bit // floating point. This is encoded in the spec in RFC 8259, and is a // common footgun people encounter at some point after choosing JSON. auto s = std::to_string(v); if constexpr (!std::is_same_v) { if (static_cast(static_cast(v)) != v) { return JsonEmitter::emit(out, s); } } out << s; } }; template struct JsonEmitter>> { static void emit(std::ostream &out, const std::vector> &m) { out << "{"; bool first = true; for (const auto &[key, value] : m) { if (!first) { out << ", "; // N.B. Objects are spaced, see below. } // Keys are always converted to strings. If this corresponds to a tuple // string (e.g. "(1, 2)"), then we explicitly strip off the parentheses. std::string s; if constexpr (std::is_same_v, std::string>) { s = key; } else { std::stringstream ss; ss << Primitive(key); s = ss.str(); if (s.size() >= 2 && s[0] == '(' && s[s.size() - 1] == ')') { s = s.substr(1, s.size() - 2); } // We also don't like spaces in the key, so we strip those too. Note // that this is different from the text representation, which does // still include spaces for most tuples. std::erase(s, ' '); } JsonEmitter::emit(out, s); // Leave the values as they are. out << ": "; JsonEmitter>::emit(out, value); first = false; } out << "}"; } }; template struct JsonEmitter> { static void emit(std::ostream &out, const std::vector &v) { out << "["; bool first = true; for (const auto &elem : v) { if (!first) { out << ","; // N.B. Arrays are unspaced, see above. } JsonEmitter::emit(out, elem); first = false; } out << "]"; } }; template struct JsonEmitter> { static void emit(std::ostream &out, const std::variant &v) { std::visit( [&](const auto &v) { JsonEmitter>::emit(out, v); }, v); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, [[maybe_unused]] const std::monostate &v) { out << "null"; } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive &v) { JsonEmitter::emit(out, v.variant); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Record &v) { JsonEmitter>::emit(out, v.fields); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Array &v) { JsonEmitter>::emit(out, v.values); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Buffer &v) { JsonEmitter>::emit(out, v.data); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Tuple &v) { JsonEmitter>::emit(out, v.values); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Symbolic &v) { // JSON does not emit symbolic values. JsonEmitter::emit(out, v.numeric); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Timestamp &v) { std::stringstream ss; ss << v; // Use default representation. JsonEmitter::emit(out, ss.str()); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Primitive::Duration &v) { std::stringstream ss; ss << v; // Use default representation. JsonEmitter::emit(out, ss.str()); } }; template std::optional one_less(const T &v) { if constexpr (std::is_same_v) { return one_less(v.numeric); } else if constexpr (std::is_same_v) { return v - 1; } else if constexpr (std::is_same_v) { if (v == 0) { return -1; } else { // N.B. This can overflow, but what can we do? We can't even encode this // integer into JSON properly, so this isn't the biggest problem. return static_cast(v - 1); } } else if constexpr (std::is_same_v) { // Try to recursively unpack the value and return one less. return std::visit([](const auto &v) { return one_less(v); }, v.variant); } else { // Give up. return std::nullopt; } } template <> struct JsonEmitter { static void emit(std::ostream &out, const Value::Histogram &hist) { out << "["; bool first = true; for (size_t i = 0; i < hist.counts.size(); i++) { if (!first) { out << ","; } out << "{"; if (i == 0 && hist.lower_bound) { out << "\"min\": "; JsonEmitter::emit(out, *hist.lower_bound); out << ", "; } else if (i > 0) { out << "\"min\": "; JsonEmitter::emit(out, hist.labels[i - 1]); out << ", "; } if (i < hist.labels.size()) { // For whatever reason, the open-intervals for the JSON encoding are // not open-intervals, they are closed intervals. So we need to // subtract one from the integer extracted here. // // If we can't find a suitable "one less" representation, then we // just emit the label as is (be it string, whatever). out << "\"max\": "; auto v = one_less(hist.labels[i]); if (v) { JsonEmitter::emit(out, *v); } else { JsonEmitter::emit(out, hist.labels[i]); } out << ", "; } out << "\"count\": " << hist.counts[i]; out << "}"; first = false; } out << "]"; } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Value::OrderedMap &m) { JsonEmitter>::emit(out, m.values); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Value::Stats &s) { JsonEmitter>::emit(out, s.value); } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Value::TimeSeries &tseries) { bool first = true; out << "["; for (const auto &[ts, value] : tseries.values) { if (std::holds_alternative(value.variant)) { continue; } if (first) { first = false; } else { out << ","; } out << R"({"interval_start":")" << ts << R"(","value":)" << value << "}"; } out << "]"; } }; template <> struct JsonEmitter { static void emit(std::ostream &out, const Value &v) { JsonEmitter::emit(out, v.variant); } }; template void emit_data(std::ostream &out, const std::string &type, std::optional &&name, const T &v) { out << R"({"type": ")" << type << R"(", "data": )"; if (name) { out << "{"; JsonEmitter::emit(out, *name); out << ": "; } JsonEmitter::emit(out, v); if (name) { out << "}"; } out << "}" << std::endl; } template bool has_type(const Value &value) { if (std::holds_alternative(value.variant)) { return true; } if (std::holds_alternative>(value.variant)) { const auto &vec = std::get>(value.variant); if (!vec.empty()) { return has_type(vec.at(0)); } } if (std::holds_alternative(value.variant)) { const auto &m = std::get(value.variant); if (!m.values.empty()) { return has_type(m.values.at(0).second); } } return false; } void JsonOutput::map(const std::string &name, const Value &value) { if (std::holds_alternative(value.variant)) { if (std::get(value.variant).values.empty()) { return; } } // If the value is a histogram, or a map of histograms, then we set the type // to `hist`. If it is explicitly a `stats` map, then set that type. // Otherwise, just set the message type to `map`. std::string type = "map"; if (has_type(value)) { type = "stats"; } else if (has_type(value)) { type = "tseries"; } else if (has_type(value)) { type = "hist"; } emit_data(out_, type, name, value); } void JsonOutput::value(const Value &value) { emit_data(out_, "value", std::nullopt, value); } void JsonOutput::printf(const std::string &str, const SourceInfo &info, PrintfSeverity severity) { switch (severity) { case PrintfSeverity::NONE: { emit_data(out_, "printf", std::nullopt, str); return; } case PrintfSeverity::WARNING: case PrintfSeverity::ERROR: { bool is_error = severity == PrintfSeverity::ERROR; out_ << R"({"type": ")" << (is_error ? "errorf" : "warnf") << "\""; out_ << R"(, "msg": )"; std::stringstream ss; ss << str; JsonEmitter::emit(out_, ss.str()); // Json only prints the top level location out_ << R"(, "filename": )"; JsonEmitter::emit(out_, info.locations.begin()->filename); out_ << R"(, "line": )"; JsonEmitter::emit(out_, info.locations.begin()->line); out_ << R"(, "col": )"; JsonEmitter::emit(out_, info.locations.begin()->column); out_ << R"(})" << std::endl; return; } } } void JsonOutput::time(const std::string &time) { emit_data(out_, "time", std::nullopt, time); } void JsonOutput::cat(const std::string &cat) { emit_data(out_, "cat", std::nullopt, cat); } void JsonOutput::join(const std::string &join) { emit_data(out_, "join", std::nullopt, join); } void JsonOutput::syscall(const std::string &syscall) { emit_data(out_, "syscall", std::nullopt, syscall); } void JsonOutput::lost_events(uint64_t lost) { // This is a special case, it emits both a count and the `data` field. out_ << R"({"type": "lost_events", "count": )" << lost << R"(, "data": {"events": )" << lost << "}}" << std::endl; } void JsonOutput::attached_probes(uint64_t num_probes) { // As with lost_events, this is a special case, we do a `count` and `data` // field. out_ << R"({"type": "attached_probes", "count": )" << num_probes << R"(, "data": {"probes": )" << num_probes << "}}" << std::endl; } void JsonOutput::runtime_error(int retcode, const RuntimeErrorInfo &info) { if (info.error_id == RuntimeErrorId::HELPER_ERROR) { out_ << R"({"type": "helper_error")"; out_ << R"(, "msg": )"; JsonEmitter::emit(out_, strerror(-retcode)); out_ << R"(, "helper": )"; std::stringstream ss; ss << info.func_id; JsonEmitter::emit(out_, ss.str()); out_ << R"(, "retcode": )"; JsonEmitter::emit(out_, retcode); } else { out_ << R"({"type": "runtime_error")"; out_ << R"(, "msg": )"; std::stringstream ss; ss << info; JsonEmitter::emit(out_, ss.str()); } // Json only prints the top level location out_ << R"(, "filename": )"; JsonEmitter::emit(out_, info.locations.begin()->filename); out_ << R"(, "line": )"; JsonEmitter::emit(out_, info.locations.begin()->line); out_ << R"(, "col": )"; JsonEmitter::emit(out_, info.locations.begin()->column); out_ << R"(})" << std::endl; } void JsonOutput::test_result(const std::vector &all_tests, size_t index, std::chrono::nanoseconds duration, const std::vector &passed, std::string output) { Primitive::Record result; result.fields.emplace_back("duration", duration.count()); result.fields.emplace_back("passed", passed[index]); result.fields.emplace_back("output", output); emit_data(out_, "test_result", all_tests[index], result); } void JsonOutput::benchmark_result(const std::vector &all_benches, size_t index, std::chrono::nanoseconds average, size_t iters) { Primitive::Record result; result.fields.emplace_back("average", average.count()); result.fields.emplace_back("iters", static_cast(iters)); emit_data(out_, "benchmark_result", all_benches[index], result); } void JsonOutput::end() { // Nothing emitted. } } // namespace bpftrace::output bpftrace-0.27.1/src/output/json.h000066400000000000000000000025211526721631600166510ustar00rootroot00000000000000#pragma once #include #include "output/output.h" namespace bpftrace::output { class JsonOutput : public Output { public: explicit JsonOutput(std::ostream &out = std::cout) : out_(out) {}; void map(const std::string &name, const Value &value) override; void value(const Value &value) override; void printf(const std::string &str, const SourceInfo &info, PrintfSeverity severity) override; void time(const std::string &time) override; void cat(const std::string &cat) override; void join(const std::string &join) override; void syscall(const std::string &syscall) override; void lost_events(uint64_t lost) override; void attached_probes(uint64_t num_probes) override; void runtime_error(int retcode, const RuntimeErrorInfo &info) override; void end() override; void test_result(const std::vector &all_tests, size_t index, std::chrono::nanoseconds duration, const std::vector &passed, std::string output) override; void benchmark_result(const std::vector &all_benches, size_t index, std::chrono::nanoseconds average, size_t iters) override; private: std::ostream &out_; }; } // namespace bpftrace::output bpftrace-0.27.1/src/output/output.cpp000066400000000000000000000016001526721631600175700ustar00rootroot00000000000000#include "output/output.h" #include "output/text.h" namespace bpftrace::output { std::partial_ordering Primitive::Array::operator<=>(const Array &other) const { return values <=> other.values; } bool Primitive::Array::operator==(const Array &other) const { return values == other.values; } std::partial_ordering Primitive::Tuple::operator<=>(const Tuple &other) const { return values <=> other.values; } bool Primitive::Tuple::operator==(const Tuple &other) const { return values == other.values; } std::partial_ordering Primitive::Record::operator<=>(const Record &other) const { return fields <=> other.fields; } bool Primitive::Record::operator==(const Record &other) const { return fields == other.fields; } std::ostream &operator<<(std::ostream &out, const Primitive &p) { TextOutput output(out); output.primitive(p); return out; } } // namespace bpftrace::output bpftrace-0.27.1/src/output/output.h000066400000000000000000000141501526721631600172410ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include "required_resources.h" // For RuntimeErrorInfo. namespace bpftrace::output { // Primitive is a basic value. // // This covers basic atoms, arrays, structures, etc. Primitives are guaranteed // to be orderable and comparable. // // It does not cover any advanced maps. struct Primitive { struct Array { std::vector values; std::partial_ordering operator<=>(const Array& other) const; bool operator==(const Array& other) const; }; struct Buffer { std::vector data; std::strong_ordering operator<=>(const Buffer& other) const = default; bool operator==(const Buffer& other) const = default; }; struct Tuple { std::vector values; std::partial_ordering operator<=>(const Tuple& other) const; bool operator==(const Tuple& other) const; }; struct Record { std::vector> fields; std::partial_ordering operator<=>(const Record& other) const; bool operator==(const Record& other) const; }; struct Symbolic { Symbolic(std::string s, uint64_t n) : symbol(std::move(s)), numeric(n) {}; std::string symbol; uint64_t numeric; auto operator<=>(const Symbolic& other) const = default; bool operator==(const Symbolic& other) const = default; }; using Timestamp = std::chrono::time_point; using Duration = std::chrono::duration; using Variant = std::variant; template Primitive(T&& t) requires std::constructible_from : variant(std::forward(t)) {}; auto operator<=>(const Primitive& other) const = default; bool operator==(const Primitive& other) const = default; Variant variant; }; // Primitives have a default representation. std::ostream& operator<<(std::ostream& out, const Primitive& p); // Value is an arbitrary value. // // This is a primitive, or a high-level aggregation over values. It is not // guaranteed to be orderable or comparable. struct Value { // Histogram is a specific type of value, which contains a sequence // of labels that represent the end interval for buckets, and a sequence of // counts. All the labels are typically numbers, strings or `Symbolic`. // // The labels field represents the upper bounds for each of the buckets, // and if counts is larger than labels then the top bucket has no upper bound. // // If there is a lower-bound for the first bucket, it is specified within the // lower_bound field. struct Histogram { std::optional lower_bound; std::vector labels; std::vector counts; }; // OrderedMap defines a map that can be ordered externally, and therefore // is not necessarily bound to be ordered by key. struct OrderedMap { std::vector> values; }; // Stats is just an arbitrary classifier for another value. It changes // only some of the encoding used by some outputs. struct Stats { Stats(OrderedMap&& m) : value(std::move(m)) {}; Stats(Primitive&& p) : value(std::move(p)) {}; std::variant value; }; // TimeSeries is a sequence of values that are collected over time. struct TimeSeries { std::vector> values; }; using Variant = std::variant, OrderedMap, Stats, TimeSeries>; template Value(T&& t) requires std::constructible_from : variant(std::forward(t)) {}; Variant variant; }; // Abstract class for output. // // This should be overriden by individual implementations. class Output { public: virtual ~Output() = default; // Print high-level maps, with special support for histogram-type maps, // and "stats" maps, where richer statistics are required. The exact // statistics or method for publishing the histograms is up to the engine. // // The "stats" boolean indicates whether this should be considered as "stats" // map or not, in order to preserve message types for JSON encoding. virtual void map(const std::string& name, const Value& value) = 0; // Print an arbitrary value. virtual void value(const Value& value) = 0; // Specialized messages during execution. virtual void printf(const std::string& str, const SourceInfo& info, PrintfSeverity severity) = 0; virtual void time(const std::string& time) = 0; virtual void cat(const std::string& cat) = 0; virtual void join(const std::string& join) = 0; virtual void syscall(const std::string& syscall) = 0; virtual void end() = 0; // General events. virtual void lost_events(uint64_t lost) = 0; virtual void attached_probes(uint64_t num_probes) = 0; virtual void runtime_error(int retcode, const RuntimeErrorInfo& info) = 0; // Testing hooks. virtual void test_result(const std::vector& all_tests, size_t index, std::chrono::nanoseconds result, const std::vector& passed, std::string output) = 0; // Benchmark hooks. virtual void benchmark_result(const std::vector& all_benches, size_t index, std::chrono::nanoseconds average, size_t iters) = 0; }; } // namespace bpftrace::output bpftrace-0.27.1/src/output/text.cpp000066400000000000000000000554121526721631600172260ustar00rootroot00000000000000#include #include #include #include #include "log.h" #include "output/text.h" #include "util/strings.h" #include "util/time.h" namespace bpftrace::output { using namespace std::chrono_literals; template struct TextEmitter { static void emit(std::ostream &out, const T &v) { out << v; } }; template <> struct TextEmitter { static void emit(std::ostream &out, const bool &v) { if (v) { out << "true"; } else { out << "false"; } } }; template struct TextEmitter> { static void emit(std::ostream &out, const std::variant &v) { std::visit( [&](const auto &v) { TextEmitter>::emit(out, v); }, v); } }; template struct TextEmitter> { static void emit(std::ostream &out, const std::vector &v) { bool first = true; out << "["; for (const auto &elem : v) { if (!first) { out << ","; } TextEmitter::emit(out, elem); first = false; } out << "]"; } }; template <> struct TextEmitter { static void emit(std::ostream &out, [[maybe_unused]] const std::monostate &v) { out << "null"; } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive &v) { TextEmitter::emit(out, v.variant); } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Record &v) { bool first = true; if (v.fields.empty()) { out << "{}"; return; } out << "{ "; for (const auto &[key, elem] : v.fields) { if (!first) { out << ", "; // Structs always get spaces. } out << "."; TextEmitter::emit(out, key); out << " = "; TextEmitter::emit(out, elem); first = false; } out << " }"; } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Array &v) { TextEmitter>::emit(out, v.values); } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Buffer &v) { TextEmitter::emit( out, util::hex_format_buffer(v.data.data(), v.data.size())); } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Tuple &v) { bool first = true; out << "("; for (const auto &elem : v.values) { if (!first) { out << ", "; // N.B. tuples get spaces, arrays do not. } TextEmitter::emit(out, elem); first = false; } out << ")"; } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Symbolic &v) { // Always emit the symbolic value. TextEmitter::emit(out, v.symbol); } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Timestamp &v, const std::string &format = "%Y-%m-%dT%H:%M:%S", const util::DisplayUnit &unit = util::DisplayUnit::ns) { // Emit the time point in the ISO 8601 form. auto s = std::chrono::time_point_cast(v); auto ns = std::chrono::duration_cast(v - s).count(); std::time_t t = std::chrono::system_clock::to_time_t( std::chrono::system_clock::time_point(s.time_since_epoch())); std::tm tm; localtime_r(&t, &tm); std::stringstream ss; ss << std::put_time(&tm, format.c_str()); switch (unit) { case util::DisplayUnit::ns: ss << "." << std::setw(9) << std::setfill('0') << ns; break; case util::DisplayUnit::us: ss << "." << std::setw(6) << std::setfill('0') << ns / 1000; break; case util::DisplayUnit::ms: ss << "." << std::setw(3) << std::setfill('0') << ns / 1000000; break; default: // No additional trailing seconds. break; } TextEmitter::emit(out, ss.str()); } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Primitive::Duration &v) { // Just emit a string with the duration in human-readable format. auto [unit, scale] = util::duration_str(v); out << (v.count() / scale) << unit; } }; template static bool adjacent_values(const std::variant &first, const std::variant &second) { if (!std::holds_alternative(first) || !std::holds_alternative(second)) { return false; } return (std::get(first) + static_cast(1)) == std::get(second); } static bool single_value(const Primitive &first, const Primitive &second) { return adjacent_values(first.variant, second.variant) || adjacent_values(first.variant, second.variant); } template <> struct TextEmitter { static void emit(std::ostream &out, const Value::Histogram &hist) { // Start at one, not zero: the `div` passed to `print` is applied to each // bucket only after the histogram has been found to be non-empty, so a // large enough `div` can leave every count here at zero, and the bar // widths below would then be computed as 0/0 (a NaN, which has no valid // conversion to `int`). uint64_t max_value = 1; for (const auto &v : hist.counts) { max_value = std::max(max_value, v); } for (size_t i = 0; i < hist.counts.size() || i < hist.labels.size(); i++) { int max_width = 52; int bar_width = (hist.counts.at(i) / static_cast(max_value)) * max_width; std::ostringstream header; if (i == 0) { if (!hist.lower_bound) { header << "(..., "; TextEmitter::emit(header, hist.labels[i]); header << ")"; } else if (hist.labels.empty()) { // Histogram contains overflow-only case header << "["; TextEmitter::emit(header, *hist.lower_bound); header << ", ...)"; } else if (single_value(*hist.lower_bound, hist.labels[i])) { header << "["; TextEmitter::emit(header, *hist.lower_bound); header << "]"; } else { header << "["; TextEmitter::emit(header, *hist.lower_bound); header << ", "; TextEmitter::emit(header, hist.labels[i]); header << ")"; } } else if (i >= hist.labels.size()) { header << "["; TextEmitter::emit(header, hist.labels[i - 1]); header << ", ...)"; } else if (single_value(hist.labels[i - 1], hist.labels[i])) { header << "["; TextEmitter::emit(header, hist.labels[i - 1]); header << "]"; } else { header << "["; TextEmitter::emit(header, hist.labels[i - 1]); header << ", "; TextEmitter::emit(header, hist.labels[i]); header << ")"; } std::string bar(bar_width, '@'); out << std::setw(16) << std::left << header.str() << std::setw(8) << std::right << hist.counts.at(i) << " |" << std::setw(max_width) << std::left << bar << "|" << std::endl; } } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Value &v) { TextEmitter::emit(out, v.variant); } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Value::OrderedMap &m) { for (const auto &[key, value] : m.values) { out << "["; TextEmitter::emit(out, key); out << "]: "; TextEmitter::emit(out, value); out << std::endl; } } }; template <> struct TextEmitter { static void emit(std::ostream &out, const Value::Stats &s) { TextEmitter>::emit(out, s.value); } }; static void try_dec(Primitive &p) { if (std::holds_alternative(p.variant) && std::get(p.variant) > std::numeric_limits::min()) { std::get(p.variant)--; } else if (std::holds_alternative(p.variant) && std::get(p.variant) > std::numeric_limits::min()) { std::get(p.variant)--; } } static void try_inc(Primitive &p) { if (std::holds_alternative(p.variant) && std::get(p.variant) < std::numeric_limits::max()) { std::get(p.variant)++; } else if (std::holds_alternative(p.variant) && std::get(p.variant) < std::numeric_limits::max()) { std::get(p.variant)++; } } static int64_t distance(const Primitive &p, int64_t other) { if (std::holds_alternative(p.variant)) { const auto &v = std::get(p.variant); if (other < 0) { return static_cast(-other) + v; } if (v > static_cast(other)) { return static_cast(v - static_cast(other)); } else { return -static_cast(static_cast(other) - v); } } if (std::holds_alternative(p.variant)) { const auto &v = std::get(p.variant); return v - other; } return 0; } static int64_t distance(const Primitive &p, const Primitive &other) { if (std::holds_alternative(other.variant)) { return distance(p, std::get(other.variant)); } else if (std::holds_alternative(other.variant)) { return distance(p, static_cast(std::get(other.variant))); } else { return 0; // Only handle integer primitives for now. } } template <> struct TextEmitter { static void emit(std::ostream &out, const Value::TimeSeries &ts) { constexpr int graph_width = 53; if (ts.values.empty()) { out << ""; return; } std::vector times; output::Primitive min_value = ts.values.front().second; output::Primitive max_value = ts.values.front().second; for (const auto &[epoch, v] : ts.values) { if (std::holds_alternative(v.variant)) { continue; // Skip missing values. } if (v < min_value) { min_value = v; } if (v > max_value) { max_value = v; } } if (min_value == max_value) { // Generally prefer if we can add some buffer on both sides of the // points in the graph, but don't overflow if our min or max is at the // upper bound of the range. try_dec(min_value); try_inc(max_value); } // Figure out the interval. const auto interval = (ts.values.back().first - ts.values.front().first) / (ts.values.size() > 1 ? ts.values.size() - 1 : 1); const auto [unit, scale] = util::duration_str(interval); std::string time_fmt = "hh:mm:ss"; size_t time_size = time_fmt.size(); if (unit > util::DisplayUnit::s) { std::stringstream ss; ss << "." << unit; time_fmt += ss.str(); time_size += 1 + static_cast(unit); // See DisplayUnit. } static const char *time_format = "%H:%M:%S"; constexpr int padding = 21; std::stringstream res; res << std::setw(time_size + 1) << ""; res << std::setw(padding); res << std::left; TextEmitter::emit(res, min_value); res << std::setw(graph_width - padding); res << std::right; TextEmitter::emit(res, max_value); res << std::endl; std::string top(graph_width - 2, '_'); res << std::setw(time_size + 1) << std::left << time_fmt; res << "|" << top << "|" << std::endl; int zero_offset = 0; if (distance(min_value, 0) < 0 && distance(0, max_value) < 0) { zero_offset = static_cast(graph_width) * static_cast(distance(min_value, 0)) / static_cast(distance(min_value, max_value)); } for (const auto &[epoch, v] : ts.values) { std::string line(graph_width, ' '); TextEmitter::emit(res, epoch, time_format, unit); res << " "; line[0] = '|'; line[graph_width - 1] = '|'; if (zero_offset > 0) { line[zero_offset] = '.'; } // There may be epochs with no valid entry. if (!std::holds_alternative(v.variant)) { int point_offset = graph_width / 2; if (min_value != max_value) { point_offset = static_cast(graph_width - 1) * static_cast(distance(min_value, v)) / static_cast(distance(min_value, max_value)); } // Ensure that we don't have floating point issues. line[std::max(0, std::min(graph_width - 1, point_offset))] = '*'; res << line << " "; TextEmitter::emit(res, v); } else { res << line << " -"; } res << std::endl; } std::string bottom(graph_width, '_'); bottom[0] = 'v'; bottom[graph_width - 1] = 'v'; res << std::setw(time_size) << "" << " " << bottom << std::endl; res << std::setw(time_size) << "" << " "; res << std::setw(padding); res << std::left; TextEmitter::emit(res, min_value); res << std::setw(graph_width - padding); res << std::right; TextEmitter::emit(res, max_value); res << std::endl; out << res.str(); } }; static void emit_map(std::ostream &out, const std::string &name, const Value::OrderedMap &m) { // For legacy reasons, this is printed with the map name each time. Also, // we have special behavior for the case of a tuple-based keys, wherein // the tuple parenthesis are explicitly omitted for this line only. for (const auto &[key, value] : m.values) { out << name << "["; std::stringstream ss; ss << key; auto s = ss.str(); if (s.size() >= 2 && s[0] == '(' && s[s.size() - 1] == ')') { s = s.substr(1, s.size() - 2); } out << s; // If this is a primitive (and fits on a single line), then we emit // inline, otherwise we display the potentially multi-line value on // subsequent lines. if (!std::holds_alternative(value.variant)) { out << "]:"; out << std::endl; } else { out << "]: "; } TextEmitter::emit(out, value); out << std::endl; } } void TextOutput::map(const std::string &name, const Value &value) { if (std::holds_alternative(value.variant) || std::holds_alternative>(value.variant) || std::holds_alternative(value.variant)) { // These are printed on separate lines. out_ << name << ":" << std::endl; TextEmitter::emit(out_, value); out_ << std::endl; } else if (std::holds_alternative(value.variant)) { // Treat this as the top-level value and unpack. auto stats = std::get(value.variant); if (std::holds_alternative(stats.value)) { // Print as a normal map, per below. emit_map(out_, name, std::get(stats.value)); } else { // Print as a normal value, per below. out_ << name << ": "; TextEmitter::emit(out_, std::get(stats.value)); out_ << std::endl; } } else if (std::holds_alternative(value.variant)) { emit_map(out_, name, std::get(value.variant)); } else { // Single value. out_ << name << ": "; TextEmitter::emit(out_, value); out_ << std::endl; } } void TextOutput::value(const Value &value) { TextEmitter::emit(out_, value); out_ << std::endl; } void TextOutput::primitive(const Primitive &p) { TextEmitter::emit(out_, p); } void TextOutput::printf(const std::string &str, const SourceInfo &info, PrintfSeverity severity) { switch (severity) { case PrintfSeverity::NONE: { out_ << str; return; } case PrintfSeverity::WARNING: case PrintfSeverity::ERROR: { bool is_error = severity == PrintfSeverity::ERROR; bool first = true; for (const auto &loc : info.locations) { if (first) { // No need to print the source context as that's just the `errorf` or // `warnf` call if (is_error) { LOG(ERROR, std::string(loc.source_location), err_) << str; } else { LOG(WARNING, std::string(loc.source_location), err_) << str; } first = false; } else { if (is_error) { LOG(ERROR, std::string(loc.source_location), std::vector(loc.source_context), err_) << "expanded from"; } else { LOG(WARNING, std::string(loc.source_location), std::vector(loc.source_context), err_) << "expanded from"; } } } return; } } } void TextOutput::time(const std::string &time) { out_ << time; } void TextOutput::cat(const std::string &cat) { out_ << cat; } void TextOutput::join(const std::string &join) { out_ << join << std::endl; } void TextOutput::syscall(const std::string &syscall) { out_ << syscall << std::endl; } void TextOutput::lost_events(uint64_t lost) { err_ << "Lost " << lost << " events" << std::endl; } void TextOutput::attached_probes(uint64_t num_probes) { if (num_probes == 1) err_ << "Attached " << num_probes << " probe" << std::endl; else err_ << "Attached " << num_probes << " probes" << std::endl; } void TextOutput::runtime_error(int retcode, const RuntimeErrorInfo &info) { if (info.error_id == RuntimeErrorId::HELPER_ERROR) { std::string msg; if (info.func_id == BPF_FUNC_map_update_elem && retcode == -E2BIG) { msg = "Map full; can't update element. Try increasing max_map_keys " "config " "or manually setting the max entries in a map declaration e.g. " "`let " "@a = hash(5000)`"; } else if (info.func_id == BPF_FUNC_map_delete_elem && retcode == -ENOENT) { msg = "Can't delete map element because it does not exist."; } // bpftrace sets the return code to 0 for map_lookup_elem failures // which is why we're not also checking the retcode else if (info.func_id == BPF_FUNC_map_lookup_elem) { msg = "Can't lookup map element because it does not exist."; } else { msg = strerror(-retcode); } LOG(WARNING, std::string(info.locations.begin()->source_location), std::vector(info.locations.begin()->source_context), err_) << msg << "\nAdditional Info - helper: " << info.func_id << ", retcode: " << retcode; } else { LOG(WARNING, std::string(info.locations.begin()->source_location), std::vector(info.locations.begin()->source_context), err_) << info; } // Print the chain for (size_t i = 1; i < info.locations.size(); ++i) { LOG(WARNING, std::string(info.locations[i].source_location), std::vector(info.locations[i].source_context), err_) << "expanded from"; } } void TextOutput::test_result(const std::vector &all_tests, size_t index, std::chrono::nanoseconds duration, const std::vector &passed, std::string output) { if (index == 0) { out_ << "\033[32m[==========]\033[0m Running " << all_tests.size() << " tests." << std::endl; } out_ << "\033[32m[ RUN ]\033[0m " << all_tests[index] << std::endl; // If the test has passed, we suppress any output. If it does not pass, then // we dump the output betwween the RUN and FAIL lines. if (passed[index]) { out_ << "\033[32m[ OK ]\033[0m " << all_tests[index]; } else { auto lines = util::split_string(output, '\n'); for (const auto &line : lines) { if (!line.empty()) { out_ << line << std::endl; } } out_ << "\033[31m[ FAILED ]\033[0m " << all_tests[index]; } auto [unit, val] = util::duration_str(duration); out_ << " (" << val << " " << unit << ")" << std::endl; auto test_or_tests = [](size_t n) { return n == 1 ? "test" : "tests"; }; if (index == all_tests.size() - 1) { // Print the summary of what happened. out_ << "\033[32m[==========]\033[0m " << all_tests.size() << " " << test_or_tests(all_tests.size()) << " ran." << std::endl; // Count the number of passed and failed tests. auto failed_count = std::count(passed.begin(), passed.end(), false); auto passed_count = std::count(passed.begin(), passed.end(), true); out_ << "\033[32m[ PASSED ]\033[0m " << passed_count << " " << test_or_tests(passed_count) << "." << std::endl; // We provide a detailed summary of all failed tests. if (failed_count > 0) { out_ << "\033[31m[ FAILED ]\033[0m " << failed_count << " " << test_or_tests(failed_count) << ", listed below:" << std::endl; for (size_t i = 0; i < all_tests.size(); i++) { if (!passed[i]) { out_ << "\033[31m[ FAILED ]\033[0m " << all_tests[i] << std::endl; } } } } } void TextOutput::benchmark_result(const std::vector &all_benches, size_t index, std::chrono::nanoseconds average, size_t iters) { const std::string BENCHMARK = "Benchmark"; const std::string AVERAGE_TIME = "Time(ns)"; const std::string ITERATIONS = "Iterations"; size_t longest_name = std::max(static_cast(40), BENCHMARK.size()); size_t time_width = 15; for (const auto &name : all_benches) { longest_name = std::max(longest_name, name.size()); } if (index == 0) { out_ << std::left << std::setw(longest_name + 1) << std::setfill(' ') << BENCHMARK; out_ << std::left << std::setw(time_width) << std::setfill(' ') << AVERAGE_TIME; out_ << std::left << ITERATIONS; out_ << std::endl; out_ << std::string(longest_name + 1 + time_width + ITERATIONS.size(), '-') << std::endl; } out_ << std::left << std::setw(longest_name + 1) << std::setfill(' ') << all_benches[index]; out_ << std::left << std::setw(time_width) << std::setfill(' ') << average.count(); out_ << std::left << iters; out_ << std::endl; } void TextOutput::end() { out_ << std::endl; out_ << std::endl; } } // namespace bpftrace::output bpftrace-0.27.1/src/output/text.h000066400000000000000000000030041526721631600166610ustar00rootroot00000000000000#pragma once #include #include "output/output.h" namespace bpftrace::output { class TextOutput : public Output { public: explicit TextOutput(std::ostream &out = std::cout, std::ostream &err = std::cerr) : out_(out), err_(err) {}; void map(const std::string &name, const Value &value) override; void value(const Value &value) override; void printf(const std::string &str, const SourceInfo &info, PrintfSeverity severity) override; void time(const std::string &time) override; void cat(const std::string &cat) override; void join(const std::string &join) override; void syscall(const std::string &syscall) override; void lost_events(uint64_t lost) override; void attached_probes(uint64_t num_probes) override; void runtime_error(int retcode, const RuntimeErrorInfo &info) override; void end() override; void test_result(const std::vector &all_tests, size_t index, std::chrono::nanoseconds duration, const std::vector &passed, std::string output) override; void benchmark_result(const std::vector &all_benches, size_t index, std::chrono::nanoseconds average, size_t iters) override; // Allows formatting of a specific primitive. void primitive(const Primitive &p); private: std::ostream &out_; std::ostream &err_; }; } // namespace bpftrace::output bpftrace-0.27.1/src/parser.cpp000066400000000000000000002643241526721631600162020ustar00rootroot00000000000000#include "parser.h" #include #include #include #include #include #include #include "log.h" #include "types.h" #include "util/int_parser.h" // clang-format off #ifndef NDEBUG #define PARSE_TRACE(msg) \ do { \ if (debug_) \ LOG(DEBUG) << "[parse] " << line_ << ":" << col_ << " " << msg; \ } while (0) #else #define PARSE_TRACE(msg) ((void)0) #endif // clang-format on namespace bpftrace { using namespace ast; Program *Parser::parse() { input_ = &ctx_.source_->contents; pos_ = 0; line_ = 1; col_ = 1; return parse_program(); } // For the CMacroExpander pass std::optional Parser::parse_expr() { input_ = &ctx_.source_->contents; pos_ = 0; line_ = 1; col_ = 1; consume_layout(); if (at_end()) { return std::nullopt; } auto expr = parse_expression(); consume_layout(); if (!at_end()) { error("unexpected input"); } if (ctx_.diagnostics().ok()) { return expr; } return std::nullopt; } Program *Parser::parse_program() { PARSE_TRACE("parse_program"); RootImportList imports; RootStatements root_stmts; std::optional header; consume_layout(); // Skip shebang line (e.g. "#!/usr/bin/env bpftrace") if (peek() == '#' && peek(1) == '!') { size_t header_start = pos_; while (!at_end() && peek() != '\n') { advance(); } if (peek() == '\n') { advance(); } header = input_->substr(header_start, pos_ - header_start); consume_layout(); } // C definitions: #include, struct/union/enum definitions. // Must appear after header but before config/imports/probes. CStatementList c_stmts; consume_layout(); while (!at_end() && !has_errors()) { // C preprocessor directives: #include, #define, etc. if (peek() == '#' && peek(1) != '!') { c_stmts.push_back(parse_c_preprocessor()); consume_layout(); continue; } // C struct/union/enum definitions: struct Name { ... } auto kw = peek_keyword(); if ((kw == "struct" || kw == "union" || kw == "enum") && looks_like_c_definition()) { c_stmts.push_back(parse_c_definition()); consume_layout(); continue; } break; } // Config and imports: must appear after c_definitions but they can be // in any order relative to each other. Config *config = nullptr; while (!at_end() && !has_errors()) { auto kw = peek_keyword(); // Config block (at most one). if (kw == "config") { if (!config) { config = parse_config(); } else { skip_config_block("duplicate config block"); } consume_layout(); continue; } // Root-level imports. if (kw == "import") { auto *imp = parse_root_import(); if (imp) { imports.push_back(imp); } consume_layout(); continue; } break; } // Main loop: probes, macros, functions, and map declarations. while (!at_end() && !has_errors()) { consume_layout(); if (at_end()) { break; } size_t before = pos_; auto kw = peek_keyword(); if (peek() == '#' && peek(1) != '!') { auto current_pos = get_current_line_col(); c_stmts.push_back(parse_c_preprocessor()); error("C definitions must appear before probes and functions", current_pos.line, current_pos.col, line_, col_); } else if (kw == "struct" || kw == "union" || kw == "enum") { if (looks_like_c_definition()) { auto current_pos = get_current_line_col(); c_stmts.push_back(parse_c_definition()); error("C definitions must appear before probes and functions", current_pos.line, current_pos.col, line_, col_); } else { // Not a C definition — treat as probe. auto *probe = parse_probe(); if (probe) { root_stmts.emplace_back(probe); } } } else if (kw == "config") { skip_config_block("config must appear before probes and functions"); } else if (kw == "import") { auto current_pos = get_current_line_col(); match("import"); error("root imports must appear before probes and functions", current_pos.line, current_pos.col, line_, col_); while (!at_end() && peek() != ';' && peek() != '\n') { advance(); } match(';'); } else if (kw == "macro") { auto *macro = parse_macro(); if (macro) { root_stmts.emplace_back(macro); } } else if (kw == "fn") { auto *subprog = parse_subprog(); if (subprog) { root_stmts.emplace_back(subprog); } } else if (kw == "let") { // At root level, `let @...` is a map declaration. size_t p = scan_layout(pos_); p += kw.size(); p = scan_layout(p); if (char_at(p) == '@') { auto *map_decl = parse_map_decl_stmt(); if (map_decl) { root_stmts.emplace_back(map_decl); } } else { error("root-level let statements need to be map declarations, e.g. let " "@a = hash(2);"); advance(); } } else { auto *probe = parse_probe(); if (probe) { root_stmts.emplace_back(probe); } } // If nothing was consumed, skip the current character to avoid // an infinite loop (e.g. when parsing stdlib files that contain // only macros and the last token wasn't recognized). if (pos_ == before) { error("unexpected input"); advance(); } consume_layout(); } auto loc = make_loc(1, 1, line_, col_); return ctx_.make_node(loc, std::move(c_stmts), config, std::move(imports), std::move(root_stmts), std::move(header)); } CStatement *Parser::parse_c_preprocessor() { auto [begin_line, begin_col] = get_current_line_col(); std::string line; while (!at_end()) { char next = peek(); if (next == '\n') break; line += next; advance(); } // Trim trailing whitespace. while (!line.empty() && std::isspace(line.back())) { line.pop_back(); } auto loc = make_loc(begin_line, begin_col, line_, col_); if (!at_end() && peek() == '\n') { advance(); } return ctx_.make_node(loc, std::move(line)); } CStatement *Parser::parse_c_definition() { auto [begin_line, begin_col] = get_current_line_col(); std::string def; // Consume keyword and name up to '{'. while (!at_end()) { char next = peek(); if (next == '{') break; def += next; advance(); } // Consume balanced braces, skipping comments. int depth = 0; while (!at_end()) { char c = peek(); if (c == '/') { char next_next = peek(1); if (next_next == '/') { // Line comment: consume until newline. while (!at_end()) { char next = peek(); if (next == '\n') break; def += next; advance(); } continue; } if (next_next == '*') { // Block comment: consume until "*/". def += c; advance(); // '/' def += peek(); advance(); // '*' while (!at_end()) { char next = peek(); char next_next_b = peek(1); if (next == '*' && next_next_b == '/') { def += next; def += next_next_b; advance(); // '*' advance(); // '/' break; } def += next; advance(); } continue; } } if (c == '{') { depth++; } else if (c == '}') { depth--; } def += c; advance(); if (depth == 0) { break; } } // Trim trailing whitespace. while (!def.empty() && std::isspace(def.back())) { def.pop_back(); } // Consume attribute, like __attribute__((packed, aligned(1))), // supports specifying __attribute__ multiple times. size_t attr_pos = pos_; while (match("__attribute__")) { consume_layout(); // match __attribute__'s '((' if (peek() == '(' && peek(1) == '(') { size_t after = scan_balanced(pos_, '(', ')'); if (after == pos_ || char_at(after - 1) != ')') { error("__attribute__ syntax error, mismatched '(' and ')'"); } def += view(attr_pos, after); attr_pos = pos_ = after; } else { error("__attribute__ syntax error, expected '(('"); } } // Ensure trailing semicolon. if (!def.empty() && def.back() != ';') { def += ";"; } // Consume optional trailing semicolon from source. consume_layout(); if (!at_end() && peek() == ';') { advance(); } auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node(loc, std::move(def)); } Config *Parser::parse_config() { PARSE_TRACE("parse_config"); auto [begin_line, begin_col] = get_current_line_col(); if (!expect("config") || !expect('=') || !expect('{')) { return nullptr; } ConfigStatementList stmts; consume_layout(); while (peek() != '}' && !at_end()) { auto [stmt_line, stmt_col] = get_current_line_col(); auto key = consume_identifier("expected config key"); if (!key) { break; } if (!expect('=')) { break; } consume_layout(); auto stmt_loc = make_loc(stmt_line, stmt_col, line_, col_); if (peek() == '"') { auto val = consume_string(); stmt_loc = make_loc(stmt_line, stmt_col, line_, col_); stmts.push_back(ctx_.make_node(stmt_loc, std::move(*key), std::move(val))); } else if (check_keyword("true") || check_keyword("false")) { bool val = check_keyword("true"); if (val) { match("true"); } else { match("false"); } stmt_loc = make_loc(stmt_line, stmt_col, line_, col_); stmts.push_back(ctx_.make_node(stmt_loc, std::move(*key), val)); } else if (std::isdigit(peek())) { auto int_str = consume_integer_str(); auto res = util::to_uint(int_str, 0); if (!res) { error("invalid integer in config"); break; } stmt_loc = make_loc(stmt_line, stmt_col, line_, col_); stmts.push_back(ctx_.make_node( stmt_loc, std::move(*key), static_cast(*res))); } else { auto val = consume_identifier("expected string, int, boolean, or ident"); if (val) { stmt_loc = make_loc(stmt_line, stmt_col, line_, col_); stmts.push_back(ctx_.make_node( stmt_loc, std::move(*key), std::move(*val))); } } consume_layout(); if (peek() != '}' && !match(';')) { expect(';'); // Skip to closing '}' to avoid cascading errors. while (!at_end() && peek() != '}') { advance(); } break; } match(';'); consume_layout(); } expect('}'); auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node(loc, std::move(stmts)); } void Parser::skip_config_block(const std::string &err_msg) { auto current_pos = get_current_line_col(); match("config"); error(err_msg, current_pos.line, current_pos.col, line_, col_); consume_layout(); if (!match('=')) { return; } consume_layout(); if (!match('{')) { return; } int depth = 1; while (!at_end() && depth > 0) { char next = peek(); if (next == '{') { depth++; } else if (next == '}') { depth--; } if (depth > 0) { advance(); } } if (!at_end()) { advance(); // skip closing '}' } } RootImport *Parser::parse_root_import() { PARSE_TRACE("parse_root_import"); auto [begin_line, begin_col] = get_current_line_col(); if (!expect("import")) { return nullptr; } consume_layout(); if (peek() != '"') { error("expected string after 'import'"); return nullptr; } auto path = consume_string(); auto loc = make_loc(begin_line, begin_col, line_, col_); if (!match(';')) { error("expected ';' after import"); return nullptr; } return ctx_.make_node(loc, std::move(path)); } Macro *Parser::parse_macro() { PARSE_TRACE("parse_macro"); auto [begin_line, begin_col] = get_current_line_col(); if (!expect("macro")) { return nullptr; } auto name = consume_identifier("expected macro name"); if (!name) { return nullptr; } auto name_loc = make_loc(begin_line, begin_col, line_, col_); if (!expect('(')) { return nullptr; } // Parse macro arguments: $var, @map, or plain identifiers. ExpressionList args; consume_layout(); if (peek() != ')') { args.push_back(parse_macro_arg()); while (match(',')) { args.push_back(parse_macro_arg()); } } if (!expect(')')) { return nullptr; } auto *block = parse_block(); if (!block) { return nullptr; } return ctx_.make_node( name_loc, std::move(*name), std::move(args), block); } Expression Parser::parse_macro_arg() { consume_layout(); auto [begin_line, begin_col] = get_current_line_col(); if (peek() == '$') { auto var_name = consume_variable(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *var = ctx_.make_node(loc, var_name); return { var }; } if (peek() == '@') { auto map_name = consume_map(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *map = ctx_.make_node(loc, map_name); return { map }; } auto ident = consume_identifier( "expected macro argument ($var, @map, or identifier)"); if (!ident) { auto *none = make_none(); return { none }; } if (is_builtin(*ident)) { error("builtin '" + *ident + "' can't be used as a macro argument", begin_line, begin_col, line_, col_); auto *none = make_none(); return { none }; } auto loc = make_loc(begin_line, begin_col, line_, col_); auto *id = ctx_.make_node(loc, std::move(*ident)); return { id }; } Subprog *Parser::parse_subprog() { PARSE_TRACE("parse_subprog"); auto [begin_line, begin_col] = get_current_line_col(); if (!expect("fn")) { return nullptr; } auto name = consume_identifier("expected function name"); if (!name) { return nullptr; } auto name_loc = make_loc(begin_line, begin_col, line_, col_); if (!expect('(')) { return nullptr; } SubprogArgList args; consume_layout(); if (peek() != ')') { // Parse first arg: $var : type while (true) { consume_layout(); auto [arg_line, arg_col] = get_current_line_col(); if (peek() != '$') { error("expected variable in function argument"); break; } auto var_name = consume_variable(); auto var_loc = make_loc(arg_line, arg_col, line_, col_); auto *var = ctx_.make_node(var_loc, var_name); if (!expect(':')) { break; } auto *type = parse_type_annotation(true); if (!type) { break; } auto arg_loc = make_loc(arg_line, arg_col, line_, col_); args.push_back(ctx_.make_node(arg_loc, var, type)); if (!match(',')) { break; } } } if (!expect(')')) { return nullptr; } if (!expect(':')) { return nullptr; } auto *return_type = parse_type_annotation(true); if (!return_type) { return nullptr; } auto *block = parse_block(false); if (!block) { return nullptr; } return ctx_.make_node( name_loc, std::move(*name), return_type, std::move(args), block); } MapDeclStatement *Parser::parse_map_decl_stmt() { auto [begin_line, begin_col] = get_current_line_col(); if (!expect("let")) { return nullptr; } consume_layout(); if (peek() != '@') { error("expected '@' in map declaration"); return nullptr; } auto map_name = consume_map(); if (!expect('=')) { return nullptr; } auto type_name = consume_identifier("expected map type name"); if (!type_name) { return nullptr; } if (!expect('(')) { return nullptr; } auto int_str = consume_integer_str(); auto res = util::to_uint(int_str, 0); if (!res) { error("expected positive integer for map declaration max entries"); return nullptr; } if (!expect(')')) { return nullptr; } match(';'); auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node( loc, std::move(map_name), std::move(*type_name), *res); } ast::Probe *Parser::parse_probe() { PARSE_TRACE("parse_probe"); auto [begin_line, begin_col] = get_current_line_col(); AttachPointList attach_points; auto *ap = parse_attach_point(); if (!ap) { return nullptr; } attach_points.push_back(ap); // Multiple attach points separated by commas. while (match(',')) { consume_layout(); // Allow trailing comma. if (peek() == '/' || peek() == '{') { break; } ap = parse_attach_point(); if (!ap) { break; } attach_points.push_back(ap); } // The probe's location spans only the attach points (not the block). // Use the last attach point's end location. const auto &last_ap_loc = attach_points.back()->loc->current; auto ap_loc = make_loc( begin_line, begin_col, last_ap_loc.end.line, last_ap_loc.end.column); auto [pred_start_line, pred_start_col] = get_current_line_col(); auto pred = parse_predicate(); auto [pred_end_line, pred_end_col] = get_current_line_col(); auto *block = parse_block(false); if (!block) { return nullptr; } if (pred.has_value()) { // Desugar predicate into: { if pred { } } auto pred_loc = make_loc( pred_start_line, pred_start_col, pred_end_line, pred_end_col); auto *none = ctx_.make_node(pred_loc); auto *cond = ctx_.make_node(pred_loc, pred.value(), block, none); block = ctx_.make_node(pred_loc, StatementList{}, cond); } return ctx_.make_node(ap_loc, std::move(attach_points), block); } AttachPoint *Parser::parse_attach_point() { PARSE_TRACE("parse_attach_point"); consume_layout(); auto [begin_line, begin_col] = get_current_line_col(); // Consume everything up to a character that ends the attach point: '{', '/', // ',' or unescaped whitespace that is followed by one of those characters std::string raw; while (!at_end()) { char c = peek(); if (c == '{' || c == ',') { break; } // '/' could be a predicate start or part of a path. It's a path // component if we've seen a ':' in the raw text (paths appear after // the provider separator, e.g. uprobe:/my/program:func). if (c == '/' && !raw.empty() && raw.find(':') == std::string::npos) { // No ':' seen yet — this '/' can't be a path, it's a predicate but check // it's not a comment. char next = peek(1); if (next != '/' && next != '*') { break; } } if (std::isspace(c)) { size_t p = scan_layout(pos_); char after = char_at(p); if (after == '\0') { break; } if (after == '{' || after == ',' || after == '/') { break; } // If we hit a newline and the next non-ws char doesn't continue // the attach point, stop. Otherwise consume the whitespace. break; } // Quoted string: consume entirely (for things like uprobe:"lib":func). if (c == '"') { raw += c; advance(); while (!at_end()) { char next = peek(); if (next == '"') break; if (next == '\\') { raw += next; advance(); if (!at_end()) { raw += peek(); advance(); } continue; } raw += next; advance(); } if (!at_end()) { raw += peek(); // closing quote advance(); } continue; } raw += c; advance(); } if (raw.empty()) { error("expected attach point"); return nullptr; } auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node(loc, std::move(raw), false); } std::optional Parser::parse_predicate() { consume_layout(); if (peek() != '/') { return std::nullopt; } // Make sure this is a predicate '/' and not a comment '//' or '/*'. char next = peek(1); if (next == '/' || next == '*') { return std::nullopt; } advance(); auto expr = parse_expression(); if (!match('/')) { error("expected '/' to close predicate"); } return expr; } BlockExpr *Parser::parse_block(bool allow_trailing_expr) { PARSE_TRACE("parse_block"); auto [block_line, block_col] = get_current_line_col(); if (!expect('{')) { return nullptr; } StatementList stmts; std::optional trailing_expr; consume_layout(); while (peek() != '}' && !at_end() && !has_errors()) { size_t before = pos_; auto kw = peek_keyword(); if (kw == "import") { auto *imp = parse_statement_import(); if (imp) { stmts.emplace_back(imp); } consume_layout(); continue; } if (kw == "while" || kw == "unroll") { auto stmt = parse_while_or_unroll(); stmts.push_back(std::move(stmt)); consume_layout(); continue; } if (kw == "for") { auto stmt = parse_for(); stmts.push_back(std::move(stmt)); consume_layout(); continue; } if (kw == "break") { auto [begin_line, begin_col] = get_current_line_col(); match("break"); expect_stmt_end(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *jump = ctx_.make_node(loc, JumpType::BREAK); stmts.emplace_back(jump); consume_layout(); continue; } if (kw == "continue") { auto [begin_line, begin_col] = get_current_line_col(); match("continue"); expect_stmt_end(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *jump = ctx_.make_node(loc, JumpType::CONTINUE); stmts.emplace_back(jump); consume_layout(); continue; } if (kw == "return") { auto [begin_line, begin_col] = get_current_line_col(); match("return"); consume_layout(); char next = peek(); if (next == ';' || next == '}') { expect_stmt_end(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *jump = ctx_.make_node(loc, JumpType::RETURN); stmts.emplace_back(jump); } else { auto expr = parse_expression(); expect_stmt_end(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *jump = ctx_.make_node(loc, JumpType::RETURN, std::move(expr)); stmts.emplace_back(jump); } consume_layout(); continue; } // Discard expression: _ = expr; if (peek() == '_') { // Check if next non-ws after '_' is '=' size_t p = scan_layout(pos_ + 1); if (char_at(p) == '=' && char_at(p + 1) != '=') { auto [begin_line, begin_col] = get_current_line_col(); advance(); // consume '_' consume_layout(); advance(); // consume '=' auto expr = parse_expression(); auto loc = make_loc(begin_line, begin_col, line_, col_); expect_stmt_end(); auto *discard = ctx_.make_node(loc, std::move(expr)); stmts.emplace_back(discard); consume_layout(); continue; } } // Check if this is a statement (assignment/let) or an expression. if (kw == "let") { auto stmt = parse_statement(); stmts.push_back(std::move(stmt)); } else if (peek() == '$' || peek() == '@') { parse_sigiled_stmt_or_trailing_expr(stmts, trailing_expr); } else { auto [begin_line, begin_col] = get_current_line_col(); auto expr = parse_expression(); consume_layout(); char next = peek(); if (next == ';') { advance(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *expr_stmt = ctx_.make_node(loc, std::move(expr)); stmts.emplace_back(expr_stmt); } else if (next == '}') { // No semicolon before closing brace: trailing expression. trailing_expr = std::move(expr); } else { auto loc = make_loc(begin_line, begin_col, line_, col_); auto *expr_stmt = ctx_.make_node(loc, std::move(expr)); if (!expr_stmt->expr.is() && !expr_stmt->expr.is()) { error("expected ';'"); } stmts.emplace_back(expr_stmt); } } if (pos_ == before) { error("unexpected input in block"); advance(); } consume_layout(); } if (has_errors()) { return nullptr; } if (!expect('}')) { return nullptr; } auto loc = make_loc(block_line, block_col, line_, col_); if (trailing_expr && allow_trailing_expr) { return ctx_.make_node(loc, std::move(stmts), std::move(*trailing_expr)); } if (trailing_expr) { // Normalize nested block expressions before converting to statement. normalize_block_expression(*trailing_expr); // Convert trailing expression to a statement (none_block semantics). auto *expr_stmt = ctx_.make_node(loc, std::move(*trailing_expr)); stmts.emplace_back(expr_stmt); } auto *none = ctx_.make_node(loc); return ctx_.make_node(loc, std::move(stmts), Expression(none)); } void Parser::normalize_block_expression(Expression &expr) { if (auto *block = expr.as()) { for (auto &stmt : block->stmts) { if (auto *expr_stmt = stmt.as()) { normalize_block_expression(expr_stmt->expr); } } if (!block->expr.as()) { normalize_block_expression(block->expr); auto *expr_stmt = ctx_.make_node(block->loc, std::move(block->expr)); block->stmts.emplace_back(expr_stmt); auto *none = ctx_.make_node(block->loc); block->expr = Expression(none); } } if (auto *if_expr = expr.as()) { normalize_block_expression(if_expr->left); normalize_block_expression(if_expr->right); } } bool Parser::parse_sigiled_stmt_or_trailing_expr( StatementList &stmts, std::optional &trailing_expr) { auto stmt_begin = save_point(); size_t errors_before = ctx_.diagnostics().error_count(); auto stmt = parse_statement(); auto stmt_end = save_point(); consume_layout(); auto *expr_stmt = stmt.as(); if (!expr_stmt) { stmts.push_back(std::move(stmt)); return true; } if (ctx_.diagnostics().error_count() > errors_before) { stmts.push_back(std::move(stmt)); return true; } if (peek() == ';') { advance(); stmts.push_back(std::move(stmt)); return true; } if (peek() == '}') { stmt_begin.restore(); auto expr = parse_expression(); consume_layout(); if (peek() == '}') { trailing_expr = std::move(expr); return true; } stmt_end.restore(); stmts.push_back(std::move(stmt)); return true; } error("expected ';'"); stmts.push_back(std::move(stmt)); return true; } StatementImport *Parser::parse_statement_import() { auto [begin_line, begin_col] = get_current_line_col(); if (!expect("import")) { return nullptr; } consume_layout(); if (peek() != '"') { error("expected string after 'import'"); return nullptr; } auto path = consume_string(); auto loc = make_loc(begin_line, begin_col, line_, col_); if (!match(';')) { error("expected ';' after import"); return nullptr; } return ctx_.make_node(loc, std::move(path)); } Statement Parser::parse_while_or_unroll() { auto [begin_line, begin_col] = get_current_line_col(); bool is_while = check_keyword("while"); if (is_while) { match("while"); } else { match("unroll"); } // When the condition is parenthesized, consume the parens explicitly and // parse a full expression inside. This prevents the paren content from // being misinterpreted as a record (e.g. `while(x=1, y=2)` matching the // `ident=expr` record pattern). // Without parens, parse as a unary expression so that the opening '{' of // the block is not consumed as part of a binary expression. Expression cond; consume_layout(); if (peek() == '(') { advance(); // consume '(' cond = parse_expression(); expect(')'); } else { cond = parse_unary(); } auto *block = parse_block(false); auto loc = make_loc(begin_line, begin_col, line_, col_); if (is_while) { auto *w = ctx_.make_node(loc, std::move(cond), block); return { w }; } auto *u = ctx_.make_node(loc, std::move(cond), block); return { u }; } Statement Parser::parse_for() { auto [begin_line, begin_col] = get_current_line_col(); match("for"); bool has_open_paren = match('('); consume_layout(); if (peek() != '$') { error("expected variable in for loop"); skip_to_block_end(); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } auto [var_line, var_col] = get_current_line_col(); auto var_name = consume_variable(); auto var_loc = make_loc(var_line, var_col, line_, col_); auto *var = ctx_.make_node(var_loc, var_name); if (!expect(':')) { skip_to_block_end(); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } consume_layout(); auto first = parse_primary(); consume_layout(); // Check for range: first..end if (peek() == '.' && peek(1) == '.') { advance(2); auto end = parse_primary(); auto range_loc = make_loc(begin_line, begin_col, line_, col_); auto *range = ctx_.make_node(range_loc, std::move(first), std::move(end)); if (has_open_paren && !expect(')')) { skip_to_block_end(); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } auto *block = parse_block(false); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *f = ctx_.make_node(loc, var, range, block); return { f }; } // Must be a map. if (has_open_paren && !expect(')')) { skip_to_block_end(); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } auto *map_ptr = first.as(); if (!map_ptr) { error("expected map or range in for loop"); skip_to_block_end(); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } auto *block = parse_block(false); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *f = ctx_.make_node(loc, var, map_ptr, block); return { f }; } void Parser::skip_to_block_end() { // Skip past a closing ')' if present, then skip the block '{...}'. // This is used for error recovery in for/while loops to avoid cascading // errors from unconsumed tokens. while (!at_end()) { char next = peek(); if (next == '{' || next == '}') { break; } advance(); } if (!at_end() && peek() == '{') { advance(); int depth = 1; while (!at_end() && depth > 0) { char next = peek(); if (next == '{') { depth++; } else if (next == '}') { depth--; } advance(); } } } void Parser::expect_stmt_end() { consume_layout(); if (peek() != '}') { expect(';'); } else { match(';'); } } // Try to match a compound assignment operator. std::optional Parser::try_compound_op() { consume_layout(); if (at_end()) { return std::nullopt; } char c = peek(); char next = peek(1); // Three-char operators if (c == '<' && next == '<' && peek(2) == '=') { advance(3); return Operator::LEFT; } if (c == '>' && next == '>' && peek(2) == '=') { advance(3); return Operator::RIGHT; } // Two-char operators if (next == '=') { switch (c) { case '+': advance(2); return Operator::PLUS; case '-': advance(2); return Operator::MINUS; case '*': advance(2); return Operator::MUL; case '/': advance(2); return Operator::DIV; case '%': advance(2); return Operator::MOD; case '&': advance(2); return Operator::BAND; case '|': advance(2); return Operator::BOR; case '^': advance(2); return Operator::BXOR; default: break; } } return std::nullopt; } Statement Parser::make_assignment(Expression &lhs, Expression rhs, const SourceLocation &loc) { auto *map = lhs.as(); if (map) { auto *assign = ctx_.make_node(loc, map, std::move(rhs)); return { assign }; } auto *map_access = lhs.as(); if (map_access) { auto *assign = ctx_.make_node(loc, map_access, std::move(rhs)); return { assign }; } auto *var = lhs.as(); auto *assign = ctx_.make_node(loc, var, std::move(rhs)); return { assign }; } Statement Parser::make_assignment_or_expr(Expression lhs, int stmt_line, int stmt_col) { consume_layout(); // Simple assignment: lhs = expr char next = peek(); if (next == '=' && peek(1) != '=') { advance(); auto rhs = parse_expression(); auto loc = make_loc(stmt_line, stmt_col, line_, col_); expect_stmt_end(); return make_assignment(lhs, std::move(rhs), loc); } // Compound assignment: lhs += expr etc. { auto sp = save_point(); auto compound = try_compound_op(); if (compound) { auto rhs = parse_expression(); auto op_loc = make_loc(sp.line, sp.col, line_, col_); auto *binop = ctx_.make_node( op_loc, lhs, *compound, std::move(rhs)); auto loc = make_loc(stmt_line, stmt_col, line_, col_); expect_stmt_end(); return make_assignment(lhs, Expression(binop), loc); } sp.restore(); } // Post-increment or Post-decrement next = peek(); auto is_post_increment = next == '+' && peek(1) == '+'; auto is_post_decrement = next == '-' && peek(1) == '-'; if (is_post_increment || is_post_decrement) { advance(2); auto loc = make_loc(stmt_line, stmt_col, line_, col_); auto *unop = ctx_.make_node(loc, std::move(lhs), is_post_increment ? Operator::POST_INCREMENT : Operator::POST_DECREMENT); auto *es = ctx_.make_node(loc, Expression(unop)); return { es }; } // Not an assignment, treat as expression statement. // First apply postfix operators (e.g. $x[0], $x.field), then continue // parsing any remaining binary operators (e.g. $x[0] == 102). auto postfix = parse_postfix(std::move(lhs)); consume_layout(); next = peek(); if (next == '=' && peek(1) != '=') { // Tuple and record fields are immutable. if (postfix.as() || postfix.as()) { advance(); parse_expression(); auto loc = make_loc(stmt_line, stmt_col, line_, col_); error("Tuples and records are immutable once created. " "Consider creating a new value and assigning it instead.", stmt_line, stmt_col, loc.end.line, loc.end.column); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } advance(); auto rhs = parse_expression(); auto loc = make_loc(stmt_line, stmt_col, line_, col_); match(';'); auto *var = postfix.as(); if (var) { auto *assign = ctx_.make_node(loc, var, std::move(rhs)); return { assign }; } // Assignment to an invalid target (not a variable, map, or map access). error("invalid assignment target", stmt_line, stmt_col, loc.end.line, loc.end.column); auto *none = make_none(); auto *es = ctx_.make_node(none->loc, Expression(none)); return { es }; } // Continue parsing as a full expression (binary ops, ternary, etc.). auto expr = parse_binary(0, std::move(postfix)); auto loc = make_loc(stmt_line, stmt_col, line_, col_); auto *expr_stmt = ctx_.make_node(loc, std::move(expr)); return { expr_stmt }; } Statement Parser::parse_statement() { PARSE_TRACE("parse_statement"); auto [stmt_line, stmt_col] = get_current_line_col(); consume_layout(); // Let statement: let $x; let $x = expr; let $x : type = expr; if (match("let")) { consume_layout(); if (peek() != '$') { error("expected variable after 'let'"); auto *none = make_none(); auto *expr_stmt = ctx_.make_node(none->loc, Expression(none)); return { expr_stmt }; } auto [var_line, var_col] = get_current_line_col(); auto var_name = consume_variable(); auto var_loc = make_loc(var_line, var_col, line_, col_); auto *var = ctx_.make_node(var_loc, var_name); // The declaration location spans from 'let' through the variable name. auto decl_loc = make_loc(stmt_line, stmt_col, line_, col_); // Check for optional type annotation. Typeof *type_annotation = nullptr; consume_layout(); if (peek() == ':') { advance(); type_annotation = parse_type_annotation(true); } consume_layout(); if (peek() == '=') { // let $x = expr; or let $x : type = expr; advance(); auto rhs = parse_expression(); auto loc = make_loc(stmt_line, stmt_col, line_, col_); expect_stmt_end(); VarDeclStatement *decl; if (type_annotation) { decl = ctx_.make_node(decl_loc, var, type_annotation); } else { decl = ctx_.make_node(decl_loc, var); } auto *assign = ctx_.make_node(loc, decl, std::move(rhs)); return { assign }; } // let $x; or let $x : type; auto loc = make_loc(stmt_line, stmt_col, line_, col_); expect_stmt_end(); VarDeclStatement *decl; if (type_annotation) { decl = ctx_.make_node(decl_loc, var, type_annotation); } else { decl = ctx_.make_node(decl_loc, var); } return { decl }; } // Variable: $x = expr; or $x += expr; or $x++ etc. if (peek() == '$') { // Check for positional parameter ($N) or param count ($#). if (std::isdigit(static_cast(peek(1))) || peek(1) == '#') { // Not a variable — fall through to expression parsing. auto expr = parse_expression(); auto loc = make_loc(stmt_line, stmt_col, line_, col_); auto *expr_stmt = ctx_.make_node(loc, std::move(expr)); return { expr_stmt }; } auto [var_line, var_col] = get_current_line_col(); auto var_name = consume_variable(); auto var_loc = make_loc(var_line, var_col, line_, col_); auto *var = ctx_.make_node(var_loc, var_name); return make_assignment_or_expr(Expression(var), stmt_line, stmt_col); } // Map: @x = expr; or @x[key] = expr; or @x += expr; etc. if (peek() == '@') { auto [map_line, map_col] = get_current_line_col(); auto map_expr = parse_map_with_optional_keys(map_line, map_col); return make_assignment_or_expr(std::move(map_expr), stmt_line, stmt_col); } auto expr = parse_expression(); auto loc = make_loc(stmt_line, stmt_col, line_, col_); auto *expr_stmt = ctx_.make_node(loc, std::move(expr)); return { expr_stmt }; } // Type parsing ParsedType *Parser::parse_type(bool emit_error) { auto [begin_line, begin_col] = get_current_line_col(); auto name = emit_error ? consume_identifier("expected type name") : consume_identifier(); if (!name) { return nullptr; } ParsedType *type = nullptr; if (*name == "struct" || *name == "union" || *name == "enum") { auto type_name = emit_error ? consume_identifier("expected identifier") : consume_identifier(); if (!type_name) { return nullptr; } auto kind = ParsedType::Kind::Struct; if (*name == "union") { kind = ParsedType::Kind::Union; } else if (*name == "enum") { kind = ParsedType::Kind::Enum; } type = ctx_.make_node( make_loc(begin_line, begin_col, line_, col_), kind, *type_name); } else { type = ctx_.make_node( make_loc(begin_line, begin_col, line_, col_), ParsedType::Kind::Identifier, *name); } // Pointer and array suffixes in any order. consume_layout(); while (peek() == '*' || peek() == '[') { if (peek() == '*') { auto [pointer_line, pointer_col] = get_current_line_col(); advance(); type = ctx_.make_node( make_loc(pointer_line, pointer_col, line_, col_), type); consume_layout(); } else { auto [array_line, array_col] = get_current_line_col(); advance(); consume_layout(); uint64_t size = 0; if (peek() != ']') { auto int_str = consume_integer_str(); auto res = util::to_uint(int_str, 0); size = res ? *res : 0; } expect(']'); type = ctx_.make_node( make_loc(array_line, array_col, line_, col_), size, type); consume_layout(); } } return type; } std::optional Parser::scan_type_suffixes(size_t pos, bool &saw_suffix) const { pos = scan_layout(pos); while (true) { if (char_at(pos) == '*') { saw_suffix = true; pos = scan_pointer_suffix(pos); continue; } if (char_at(pos) == '[') { saw_suffix = true; size_t after = scan_balanced(pos, '[', ']'); if (after == pos || char_at(after - 1) != ']') { return std::nullopt; } pos = scan_layout(after); continue; } break; } return pos; } std::optional> Parser:: try_parse_type_reference(std::string_view end_chars) { auto sp = save_point(); consume_layout(); if (!is_identifier_start(peek())) { sp.restore(); return std::nullopt; } size_t lookahead = pos_; const size_t ident_start = lookahead; lookahead = scan_identifier_end(lookahead); const auto ident = view(ident_start, lookahead); if (is_builtin(ident)) { sp.restore(); return std::nullopt; } auto matches_terminator = [&](size_t end_pos) { char next = char_at(scan_layout(end_pos)); return next != '\0' && end_chars.find(next) != std::string_view::npos; }; bool is_unknown_typedef = true; if (ident == "struct" || ident == "union" || ident == "enum") { lookahead = scan_layout(lookahead); if (!is_identifier_start(char_at(lookahead))) { sp.restore(); return std::nullopt; } lookahead = scan_identifier_end(lookahead); is_unknown_typedef = false; } else if (ident_to_builtin_type(std::string(ident)).has_value()) { is_unknown_typedef = false; } bool saw_suffix = false; auto end_pos = scan_type_suffixes(lookahead, saw_suffix); if (!end_pos || !matches_terminator(*end_pos)) { sp.restore(); return std::nullopt; } bool parse_as_type = !is_unknown_typedef || saw_suffix; if (parse_as_type) { return parse_type(); } auto [begin_line, begin_col] = get_current_line_col(); auto parsed_ident = consume_identifier(); if (!parsed_ident) { sp.restore(); return std::nullopt; } auto loc = make_loc(begin_line, begin_col, line_, col_); auto *id = ctx_.make_node(loc, std::move(*parsed_ident)); return Expression(id); } Typeof *Parser::parse_type_annotation(bool type_only) { consume_layout(); auto [begin_line, begin_col] = get_current_line_col(); // typeof(expr_or_type) if (check_keyword("typeof")) { match("typeof"); expect('('); consume_layout(); if (auto type_ref = try_parse_type_reference(")")) { expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); if (auto *type = std::get_if(&*type_ref)) { return ctx_.make_node(loc, *type); } return ctx_.make_node(loc, std::move(std::get(*type_ref))); } auto expr = parse_expression(); expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node(loc, std::move(expr)); } if (type_only) { auto *type = parse_type(); if (!type) { return nullptr; } auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node(loc, type); } if (auto type_ref = try_parse_type_reference(";,=){}")) { auto loc = make_loc(begin_line, begin_col, line_, col_); if (auto *type = std::get_if(&*type_ref)) { return ctx_.make_node(loc, *type); } return ctx_.make_node(loc, std::move(std::get(*type_ref))); } // Not a type — parse as expression. auto expr = parse_expression(); auto loc = make_loc(begin_line, begin_col, line_, col_); return ctx_.make_node(loc, std::move(expr)); } // Expression grammar // Entry point for parsing any expression. Ternary is currently the // lowest-precedence operator, but this wrapper keeps callers insulated // if the grammar changes. Expression Parser::parse_expression() { PARSE_TRACE("parse_expression"); return parse_ternary(); } // Ternary: expr ? expr : expr or expr ? : expr Expression Parser::parse_ternary() { PARSE_TRACE("parse_ternary"); auto expr = parse_binary(0); auto sp = save_point(); consume_layout(); if (peek() != '?') { sp.restore(); return expr; } const auto &expr_begin = expr.loc()->current.begin; advance(); consume_layout(); Expression then_expr; if (peek() == ':') { // Short form: expr ?: expr advance(); auto else_expr = parse_ternary(); auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *if_node = ctx_.make_node( loc, expr, expr, std::move(else_expr)); return { if_node }; } then_expr = parse_ternary(); expect(':'); auto else_expr = parse_ternary(); auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *if_node = ctx_.make_node( loc, expr, std::move(then_expr), std::move(else_expr)); return { if_node }; } namespace { enum class BinopPrecedence : int { LogicalOr = 1, LogicalAnd, BitwiseOr, BitwiseXor, BitwiseAnd, Equality, Relational, Shift, Additive, Multiplicative, }; constexpr int prec(BinopPrecedence precedence) { return static_cast(precedence); } int op_length(Operator op) { switch (op) { case Operator::LOR: case Operator::LAND: case Operator::EQ: case Operator::NE: case Operator::LE: case Operator::GE: case Operator::LEFT: case Operator::RIGHT: return 2; default: return 1; } } } // namespace // Returns the operator and precedence for a binary operator token, // or std::nullopt if the current position is not a binary operator. std::optional Parser::peek_binop() const { char c = peek(); if (c == '\0') { return std::nullopt; } char next = peek(1); // Skip compound assignments — they are not binary ops in expression context. if (next == '=' && (c == '+' || c == '-' || c == '*' || c == '/' || c == '%' || c == '&' || c == '|' || c == '^')) { return std::nullopt; } // <<= and >>= if ((c == '<' && next == '<') || (c == '>' && next == '>')) { if (peek(2) == '=') { return std::nullopt; } } // Two-character operators first. if (c == '|' && next == '|') { return BinopInfo{ .op = Operator::LOR, .prec = prec(BinopPrecedence::LogicalOr) }; } if (c == '&' && next == '&') { return BinopInfo{ .op = Operator::LAND, .prec = prec(BinopPrecedence::LogicalAnd) }; } if (c == '=' && next == '=') { return BinopInfo{ .op = Operator::EQ, .prec = prec(BinopPrecedence::Equality) }; } if (c == '!' && next == '=') { return BinopInfo{ .op = Operator::NE, .prec = prec(BinopPrecedence::Equality) }; } if (c == '<' && next == '=') { return BinopInfo{ .op = Operator::LE, .prec = prec(BinopPrecedence::Relational) }; } if (c == '>' && next == '=') { return BinopInfo{ .op = Operator::GE, .prec = prec(BinopPrecedence::Relational) }; } if (c == '<' && next == '<') { return BinopInfo{ .op = Operator::LEFT, .prec = prec(BinopPrecedence::Shift) }; } if (c == '>' && next == '>') { return BinopInfo{ .op = Operator::RIGHT, .prec = prec(BinopPrecedence::Shift) }; } // Single-character operators. if (c == '|' && next != '|') { return BinopInfo{ .op = Operator::BOR, .prec = prec(BinopPrecedence::BitwiseOr) }; } if (c == '^') { return BinopInfo{ .op = Operator::BXOR, .prec = prec(BinopPrecedence::BitwiseXor) }; } if (c == '&' && next != '&') { return BinopInfo{ .op = Operator::BAND, .prec = prec(BinopPrecedence::BitwiseAnd) }; } if (c == '<' && next != '<' && next != '=') { return BinopInfo{ .op = Operator::LT, .prec = prec(BinopPrecedence::Relational) }; } if (c == '>' && next != '>' && next != '=') { return BinopInfo{ .op = Operator::GT, .prec = prec(BinopPrecedence::Relational) }; } if (c == '+' && next != '+') { return BinopInfo{ .op = Operator::PLUS, .prec = prec(BinopPrecedence::Additive) }; } if (c == '-' && next != '-') { return BinopInfo{ .op = Operator::MINUS, .prec = prec(BinopPrecedence::Additive) }; } if (c == '*') { return BinopInfo{ .op = Operator::MUL, .prec = prec(BinopPrecedence::Multiplicative) }; } if (c == '/') { // If '/' is followed (after whitespace) by '{', it's the end of a // predicate, not a division operator size_t p = scan_layout(pos_ + 1); if (char_at(p) == '{') { return std::nullopt; } return BinopInfo{ .op = Operator::DIV, .prec = prec(BinopPrecedence::Multiplicative) }; } if (c == '%') { return BinopInfo{ .op = Operator::MOD, .prec = prec(BinopPrecedence::Multiplicative) }; } return std::nullopt; } // Precedence-climbing binary expression parser. Expression Parser::parse_binary(int min_prec) { PARSE_TRACE("parse_binary min_prec=" << min_prec); return parse_binary(min_prec, parse_unary()); } Expression Parser::parse_binary(int min_prec, Expression left) { while (true) { auto sp = save_point(); consume_layout(); auto info = peek_binop(); if (!info || info->prec < min_prec) { sp.restore(); break; } const auto &left_begin = left.loc()->current.begin; int len = op_length(info->op); for (int i = 0; i < len; i++) { advance(); } auto right = parse_binary(info->prec + 1); auto loc = make_loc(left_begin.line, left_begin.column, line_, col_); auto *binop = ctx_.make_node( loc, std::move(left), info->op, std::move(right)); left = Expression(binop); } return left; } // Unary prefix expressions: *expr, -expr, !expr, ~expr, ++$var, --$var Expression Parser::parse_unary() { PARSE_TRACE("parse_unary"); consume_layout(); auto [begin_line, begin_col] = get_current_line_col(); // Pre-increment or -decrement: ++$var or ++@map / --$var or --@map auto is_pre_increment = peek() == '+' && peek(1) == '+'; auto is_pre_decrement = peek() == '-' && peek(1) == '-'; if (is_pre_increment || is_pre_decrement) { advance(2); auto expr = parse_unary(); if (!expr.as() && !expr.as() && !expr.as()) { error("increment/decrement requires a variable or map", expr.loc()->current.begin.line, expr.loc()->current.begin.column, expr.loc()->current.end.line, expr.loc()->current.end.column); } auto loc = make_loc(begin_line, begin_col, line_, col_); auto *unop = ctx_.make_node(loc, std::move(expr), is_pre_increment ? Operator::PRE_INCREMENT : Operator::PRE_DECREMENT); return { unop }; } // Address-of: &$var or &@map if (peek() == '&') { advance(); consume_layout(); if (peek() == '$') { auto [var_line, var_col] = get_current_line_col(); auto var_name = consume_variable(); auto var_loc = make_loc(var_line, var_col, line_, col_); auto *var = ctx_.make_node(var_loc, var_name); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *addr = ctx_.make_node(loc, var); return { addr }; } if (peek() == '@') { auto [map_line, map_col] = get_current_line_col(); auto map_name = consume_map(); auto map_loc = make_loc(map_line, map_col, line_, col_); auto *map = ctx_.make_node(map_loc, map_name); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *addr = ctx_.make_node(loc, map); return { addr }; } error("address-of operator (&) can only be used on a map or variable"); auto expr = parse_unary(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *unop = ctx_.make_node(loc, std::move(expr), Operator::BAND); return { unop }; } Operator op; char next = peek(); if (next == '*') { op = Operator::MUL; } else if (next == '!' && peek(1) != '=') { op = Operator::LNOT; } else if (next == '~') { op = Operator::BNOT; } else if (next == '-' && peek(1) != '-') { op = Operator::MINUS; } else { return parse_postfix(parse_primary()); } advance(); auto expr = parse_unary(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *unop = ctx_.make_node(loc, std::move(expr), op); return { unop }; } // Postfix operations: .field, ->field, .N (tuple), [expr], ++, -- Expression Parser::parse_postfix(Expression expr) { PARSE_TRACE("parse_postfix"); while (true) { // Save position before whitespace lookahead so we don't advance // past the end of the expression when no postfix op is found. auto sp = save_point(); consume_layout(); const auto &expr_begin = expr.loc()->current.begin; // Field access: expr.field or tuple access: expr.N char next = peek(); if (next == '.') { // Make sure it's not '..' (range operator) if (peek(1) == '.') { break; } advance(); consume_layout(); // Tuple access: expr.N if (std::isdigit(peek())) { auto int_str = consume_integer_str(); auto res = util::to_uint(int_str, 0); auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *ta = ctx_.make_node( loc, std::move(expr), static_cast(res ? *res : 0)); expr = Expression(ta); continue; } // Field access: expr.field auto field = consume_identifier("expected field name after '.'"); if (!field) { break; } auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *fa = ctx_.make_node(loc, std::move(expr), std::move(*field)); expr = Expression(fa); continue; } // Arrow access: expr->field if (next == '-' && peek(1) == '>') { advance(2); auto field = consume_identifier("expected field name after '->'"); if (!field) { break; } auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *fa = ctx_.make_node(loc, std::move(expr), std::move(*field)); expr = Expression(fa); continue; } // Array access: expr[index] if (next == '[') { advance(); auto index = parse_expression(); expect(']'); auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *aa = ctx_.make_node(loc, std::move(expr), std::move(index)); expr = Expression(aa); continue; } // Post-increment/decrement: expr++ / expr-- auto is_post_increment = next == '+' && peek(1) == '+'; auto is_post_decrement = next == '-' && peek(1) == '-'; if (is_post_increment || is_post_decrement) { if (!expr.as() && !expr.as() && !expr.as()) { auto [op_line, op_col] = get_current_line_col(); advance(2); error("increment/decrement requires a variable or map", op_line, op_col, line_, col_); break; } advance(2); auto loc = make_loc(expr_begin.line, expr_begin.column, line_, col_); auto *unop = ctx_.make_node(loc, std::move(expr), is_post_increment ? Operator::POST_INCREMENT : Operator::POST_DECREMENT); expr = Expression(unop); continue; } // No postfix op found sp.restore(); break; } return expr; } // Primary expressions: atoms, calls, parenthesized/tuple/record exprs, // if-expressions, sizeof, offsetof, typeinfo, comptime. Expression Parser::parse_primary() { PARSE_TRACE("parse_primary, next='" << peek() << "'"); consume_layout(); auto [begin_line, begin_col] = get_current_line_col(); // Parenthesized expression, cast, tuple, or record. if (peek() == '(') { return parse_paren_expr(); } // If expression: if cond { expr } else { expr } if (match("if")) { // When the condition is parenthesized, consume the parens explicitly and // parse a full expression inside. This prevents the paren content from // being misinterpreted as a record. // Without parens, parse as a unary expression so that the opening '{' of // the block is not consumed as part of a binary expression. Expression cond; consume_layout(); if (peek() == '(') { advance(); // consume '(' cond = parse_expression(); expect(')'); } else { cond = parse_unary(); } auto *then_block = parse_block(); auto sp = save_point(); consume_layout(); Expression else_expr; if (match("else")) { consume_layout(); if (peek() == '{') { auto *else_block = parse_block(); else_expr = Expression(else_block); } else if (check_keyword("if")) { // else if ... else_expr = parse_primary(); } else { error("expected '{' or 'if' after 'else'"); } } else { sp.restore(); auto *none = make_none(); else_expr = Expression(none); } auto loc = make_loc(begin_line, begin_col, line_, col_); auto *if_node = ctx_.make_node( loc, std::move(cond), then_block, std::move(else_expr)); return { if_node }; } // sizeof(type_or_expr) if (match("sizeof")) { expect('('); auto *typeof_node = parse_type_annotation(); expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *s = ctx_.make_node(loc, typeof_node); return { s }; } // offsetof(type_or_expr, field.field...) if (match("offsetof")) { expect('('); auto *typeof_node = parse_type_annotation(); expect(','); auto fields = parse_field_access(); expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *o = ctx_.make_node(loc, typeof_node, std::move(fields)); return { o }; } // typeinfo(type_or_expr) if (match("typeinfo")) { expect('('); auto *typeof_node = parse_type_annotation(); expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *ti = ctx_.make_node(loc, typeof_node); return { ti }; } // comptime expr if (match("comptime")) { auto expr = parse_unary(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *ct = ctx_.make_node(loc, std::move(expr)); return { ct }; } // Block expression: { stmts; expr } if (peek() == '{') { auto *block = parse_block(); if (block) { return { block }; } auto *none = make_none(); return { none }; } // Try to read an identifier - could be a function call, builtin, or keyword. auto name = consume_identifier(); if (name) { auto name_loc = make_loc(begin_line, begin_col, line_, col_); // Boolean literals. if (*name == "true" || *name == "false") { auto *boolean = ctx_.make_node(name_loc, *name == "true"); return { boolean }; } consume_layout(); if (peek() == '(') { return parse_call_expression(*name, name_loc); } if (is_builtin(*name)) { auto *builtin = ctx_.make_node(name_loc, std::move(*name)); return { builtin }; } // Just an identifier. auto *ident = ctx_.make_node(name_loc, std::move(*name)); return { ident }; } // Try a map (@name or @name[key]). if (peek() == '@') { return parse_map_with_optional_keys(begin_line, begin_col); } // Try a variable ($name), positional parameter ($N), or param count ($#). if (peek() == '$') { if (peek(1) == '#') { advance(2); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *ppc = ctx_.make_node(loc); return { ppc }; } if (std::isdigit(peek(1))) { advance(); std::string digits; while (!at_end() && std::isdigit(peek())) { digits += peek(); advance(); } auto loc = make_loc(begin_line, begin_col, line_, col_); try { long n = std::stol(digits); if (n < 1) { error("param $" + digits + " is out of integer range [1, " + std::to_string(std::numeric_limits::max()) + "]", begin_line, begin_col, line_, col_); } auto *pp = ctx_.make_node(loc, n); return { pp }; } catch (...) { error("param $" + digits + " is out of integer range [1, " + std::to_string(std::numeric_limits::max()) + "]", begin_line, begin_col, line_, col_); auto *pp = ctx_.make_node(loc, 0); return { pp }; } } auto var_name = consume_variable(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *var = ctx_.make_node(loc, var_name); return { var }; } // Try an integer literal. if (std::isdigit(peek())) { auto int_str = consume_integer_str(); auto res = util::to_uint(int_str, 0); if (res) { auto loc = make_loc(begin_line, begin_col, line_, col_); auto *integer = ctx_.make_node(loc, *res, std::move(int_str)); return { integer }; } std::stringstream ss; ss << res.takeError(); error(ss.str(), begin_line, begin_col, line_, col_); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *integer = ctx_.make_node(loc, 0); return { integer }; } // Try a string literal. if (peek() == '"') { auto str = consume_string(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *string_node = ctx_.make_node(loc, std::move(str)); return { string_node }; } error("expected expression"); auto *none = make_none(); return { none }; } // Parse parenthesized expressions, casts, tuples, and records. Expression Parser::parse_paren_expr() { auto [begin_line, begin_col] = get_current_line_col(); advance(); // consume '(' consume_layout(); // Empty tuple: () if (peek() == ')') { advance(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *tuple = ctx_.make_node(loc, ExpressionList{}); return { tuple }; } if (auto record = try_parse_record(begin_line, begin_col)) { return std::move(*record); } if (auto cast = try_parse_cast_expr(begin_line, begin_col)) { return std::move(*cast); } return parse_tuple_or_grouping_expr(begin_line, begin_col); } std::optional Parser::try_parse_record(int begin_line, int begin_col) { // (ident=expr, ident_b=expr, ...) size_t p = scan_layout(pos_); char ch = char_at(p); if (!is_identifier_start(ch)) { return std::nullopt; } size_t id_start = p; p = scan_identifier_end(p); size_t id_end = p; p = scan_layout(p); if (char_at(p) != '=' || char_at(p + 1) == '=') { return std::nullopt; } if (is_builtin(view(id_start, id_end))) { return std::nullopt; } NamedArgumentList named_args; std::set seen_names; bool record_error = false; while (true) { consume_layout(); auto [arg_line, arg_col] = get_current_line_col(); auto arg_name = consume_identifier("expected identifier"); if (!arg_name) { record_error = true; break; } expect('='); auto arg_expr = parse_expression(); auto arg_loc = make_loc(arg_line, arg_col, line_, col_); if (seen_names.contains(*arg_name)) { error("Named argument list already contains name: " + *arg_name, arg_line, arg_col, line_, col_); } else { seen_names.insert(*arg_name); } named_args.push_back(ctx_.make_node(arg_loc, std::move(*arg_name), std::move(arg_expr))); if (!match(',')) { break; } } if (record_error) { // Skip to closing ')' to avoid cascading errors. int depth = 1; while (!at_end() && depth > 0) { char next = peek(); if (next == '(') { depth++; } else if (next == ')') { depth--; } if (depth > 0) { advance(); } } } expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *record = ctx_.make_node(loc, std::move(named_args)); return Expression(record); } std::optional Parser::try_parse_cast_expr(int begin_line, int begin_col) { auto sp = save_point(); Typeof *typeof_node = nullptr; if (check_keyword("typeof")) { typeof_node = parse_type_annotation(); } else { consume_layout(); if (!is_identifier_start(peek())) { sp.restore(); return std::nullopt; } size_t lookahead = pos_; const size_t ident_start = lookahead; lookahead = scan_identifier_end(lookahead); if (is_builtin(view(ident_start, lookahead))) { sp.restore(); return std::nullopt; } auto [type_begin_line, type_begin_col] = get_current_line_col(); if (auto *type = parse_type(false)) { auto loc = make_loc(type_begin_line, type_begin_col, line_, col_); typeof_node = ctx_.make_node(loc, type); } else { sp.restore(); return std::nullopt; } } consume_layout(); if (peek() != ')') { sp.restore(); return std::nullopt; } advance(); consume_layout(); if (!can_start_expression()) { sp.restore(); return std::nullopt; } auto loc = make_loc(begin_line, begin_col, line_, col_); auto cast_target = parse_unary(); auto *cast = ctx_.make_node(loc, typeof_node, std::move(cast_target)); return Expression(cast); } Expression Parser::parse_tuple_or_grouping_expr(int begin_line, int begin_col) { auto first = parse_expression(); consume_layout(); // Simple parenthesized expression. if (peek() != ',') { expect(')'); return first; } // Tuple: (expr, ...) or (expr,) advance(); consume_layout(); ExpressionList elems; elems.push_back(std::move(first)); // (expr,) — single-element tuple with trailing comma if (peek() == ')') { advance(); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *tuple = ctx_.make_node(loc, std::move(elems)); return { tuple }; } // Multi-element tuple elems.push_back(parse_expression()); while (match(',')) { consume_layout(); if (peek() == ')') { break; // trailing comma } elems.push_back(parse_expression()); } expect(')'); auto loc = make_loc(begin_line, begin_col, line_, col_); auto *tuple = ctx_.make_node(loc, std::move(elems)); return { tuple }; } Expression Parser::parse_call_expression(const std::string &name, const SourceLocation &start_loc) { expect('('); ExpressionList args; consume_layout(); auto add_expr_or_type_arg = [&, this]() { auto [begin_line, begin_col] = get_current_line_col(); if (check_keyword("typeof")) { auto *typeof_node = parse_type_annotation(); auto loc = make_loc(begin_line, begin_col, line_, col_); args.emplace_back(ctx_.make_node(loc, typeof_node)); return; } args.push_back(parse_expression()); }; if (peek() != ')') { add_expr_or_type_arg(); while (match(',')) { add_expr_or_type_arg(); } } expect(')'); auto loc = make_loc( start_loc.begin.line, start_loc.begin.column, line_, col_); auto *call = ctx_.make_node(loc, std::string(name), std::move(args)); return { call }; } // Expression helpers Expression Parser::parse_map_with_optional_keys(int begin_line, int begin_col) { auto map_name = consume_map(); // may be empty for anonymous map auto map_loc = make_loc(begin_line, begin_col, line_, col_); auto *map = ctx_.make_node(map_loc, map_name); consume_layout(); if (peek() != '[') { return { map }; } advance(); ExpressionList keys; keys.push_back(parse_expression()); while (match(',')) { keys.push_back(parse_expression()); } expect(']'); auto access_loc = make_loc(begin_line, begin_col, line_, col_); Expression key_expr; if (keys.size() > 1) { auto *tuple = ctx_.make_node(access_loc, std::move(keys)); key_expr = Expression(tuple); } else { key_expr = std::move(keys.back()); } auto *map_access = ctx_.make_node(access_loc, map, std::move(key_expr)); return { map_access }; } std::vector Parser::parse_field_access() { std::vector fields; fields.push_back(consume_identifier().value_or("")); while (true) { consume_layout(); if (match('.')) { fields.push_back(consume_identifier().value_or("")); } else { break; } } return fields; } // Lexer helpers void Parser::advance(int n) { for (int i = 0; i < n && !at_end(); i++) { if (at(pos_) == '\n') { line_++; col_ = 1; } else { col_++; } pos_++; } } char Parser::peek(size_t offset) const { if (!in_bounds(pos_ + offset)) { return '\0'; } return at(pos_ + offset); } char Parser::char_at(size_t pos) const { return in_bounds(pos) ? at(pos) : '\0'; } bool Parser::at_end() const { return !in_bounds(pos_); } char Parser::previous_non_hspace() const { size_t p = pos_; while (p > 0) { p--; char c = at(p); if (!is_hspace(c)) { return c; } } return '\0'; } void Parser::consume_line_comment() { advance(2); if (!at_end() && peek() == ' ') { advance(); } int begin_line = line_; int begin_col = col_; while (!at_end() && peek() != '\n') { advance(); } ctx_.add_comment(make_loc(begin_line, begin_col, line_, col_)); } void Parser::consume_block_comment() { // Skip the opening "/*" advance(2); // Skip an optional space after "/*" (e.g. "/* comment" -> "comment") if (!at_end() && peek() == ' ') { advance(); } while (!at_end()) { // Record the content of each line within the block comment int begin_line = line_; int begin_col = col_; while (!at_end()) { char next = peek(); if (next == '\n' || (next == '*' && peek(1) == '/')) break; advance(); } // Store this line's comment text if it was non-empty if (line_ != begin_line || col_ != begin_col) { ctx_.add_comment(make_loc(begin_line, begin_col, line_, col_)); } // Check for closing "*/" if (!at_end() && peek() == '*' && peek(1) == '/') { advance(2); break; } if (at_end()) { break; } // Skip the newline character advance(); // Skip leading horizontal whitespace on the new line while (!at_end()) { char next = peek(); if (!is_hspace(next)) break; advance(); } // Re-check for closing "*/" after whitespace (e.g. " */") if (peek() == '*' && peek(1) == '/') { continue; } // Strip leading stars and one optional space that are common in // block comment formatting (e.g. " * comment text") bool stripped_stars = false; while (!at_end() && peek() == '*') { stripped_stars = true; advance(); } if (stripped_stars && !at_end() && peek() == ' ') { advance(); } // If this line is blank or ends immediately with "*/", record an // empty comment to preserve blank lines within the block comment char next = peek(); if (next == '\n' || (next == '*' && peek(1) == '/')) { ctx_.add_comment(make_loc(line_, col_, line_, col_)); } } } void Parser::consume_layout() { bool just_consumed_comment = false; while (!at_end()) { char next = peek(); if (is_hspace(next)) { advance(); } else if (next == '\n') { int begin_line = line_; int begin_col = col_; bool suppress_vspace = just_consumed_comment; if (!suppress_vspace) { char prev = previous_non_hspace(); suppress_vspace = prev == ';' || prev == '{' || prev == '}'; } advance(); if (!suppress_vspace) { ctx_.add_vspace(make_loc(begin_line, begin_col, line_, col_), 1); } just_consumed_comment = false; } else if (next == '/') { char next_next = peek(1); if (next_next == '/') { consume_line_comment(); just_consumed_comment = true; } else if (next_next == '*') { consume_block_comment(); just_consumed_comment = true; } else { break; } } else { break; } } } size_t Parser::scan_layout(size_t pos) const { while (in_bounds(pos)) { char ch = at(pos); if (std::isspace(static_cast(ch))) { pos++; } else if (ch == '/') { char next = char_at(pos + 1); if (next == '/') { while (char_at(pos) != '\n' && in_bounds(pos)) { pos++; } } else if (next == '*') { pos += 2; while (in_bounds(pos)) { if (at(pos) == '*' && char_at(pos + 1) == '/') { pos += 2; break; } pos++; } } else { break; } } else { break; } } return pos; } bool Parser::is_hspace(char c) { return c == ' ' || c == '\t' || c == '\r'; } bool Parser::is_identifier_start(char c) { return std::isalpha(static_cast(c)) || c == '_'; } bool Parser::is_identifier_body(char c) { return std::isalnum(static_cast(c)) || c == '_'; } size_t Parser::scan_identifier_end(size_t pos) const { char ch; while ((ch = char_at(pos)) != '\0' && is_identifier_body(ch)) { pos++; } return pos; } size_t Parser::scan_balanced(size_t pos, char open, char close) const { if (char_at(pos) != open) { return pos; } int depth = 1; pos++; while (in_bounds(pos) && depth > 0) { if (at(pos) == open) { depth++; } else if (at(pos) == close) { depth--; } pos++; } return pos; } size_t Parser::scan_pointer_suffix(size_t pos) const { pos = scan_layout(pos); while (char_at(pos) == '*') { pos++; pos = scan_layout(pos); } return pos; } std::string_view Parser::view(size_t start, size_t end) const { return std::string_view(*input_).substr(start, end - start); } std::string_view Parser::peek_keyword() const { return view(pos_, scan_identifier_end(pos_)); } bool Parser::match(char c) { consume_layout(); if (peek() == c) { advance(); return true; } return false; } bool Parser::match(const std::string &s) { consume_layout(); if (!in_bounds(pos_ + s.size() - 1)) { return false; } for (size_t i = 0; i < s.size(); i++) { if (at(pos_ + i) != s[i]) { return false; } } // Make sure the keyword isn't a prefix of a longer identifier. char after = char_at(pos_ + s.size()); if (is_identifier_body(after)) { return false; } for (size_t i = 0; i < s.size(); i++) { advance(); } return true; } bool Parser::check_keyword(const std::string &s) const { size_t p = scan_layout(pos_); if (!in_bounds(p + s.size() - 1)) { return false; } for (size_t i = 0; i < s.size(); i++) { if (at(p + i) != s[i]) { return false; } } // Ensure it's not a prefix of a longer identifier. char after = char_at(p + s.size()); return !is_identifier_body(after); } bool Parser::expect(char c) { if (!match(c)) { error(std::string("expected '") + c + "'"); return false; } return true; } bool Parser::expect(const std::string &s) { if (!match(s)) { error("expected '" + s + "'"); return false; } return true; } std::string Parser::consume_ident_from(size_t scan_start) { size_t start = pos_; size_t end = scan_identifier_end(scan_start); pos_ = end; col_ += static_cast(end - start); return std::string(view(start, end)); } std::optional Parser::consume_identifier(std::string err_msg) { consume_layout(); if (!is_identifier_start(peek())) { if (!err_msg.empty()) { error(err_msg); } return std::nullopt; } return consume_ident_from(pos_); } std::string Parser::consume_variable() { if (!is_identifier_start(peek(1))) { error("expected identifier after '$'"); return ""; } return consume_ident_from(pos_ + 1); } std::string Parser::consume_map() { // Unlike variables, maps can be a bare sigil if (!is_identifier_start(peek(1))) { advance(); return "@"; } return consume_ident_from(pos_ + 1); } std::string Parser::consume_string() { // Opening quote already confirmed by caller, consume it. advance(); std::string result; while (!at_end()) { char next = peek(); if (next == '"') break; if (next == '\n') { error("unterminated string"); return result; } if (next != '\\') { result += next; advance(); continue; } int esc_line = line_; int esc_col = col_; advance(); if (at_end()) { error("unterminated string"); return result; } char esc = peek(); switch (esc) { case 'n': result += '\n'; break; case 't': result += '\t'; break; case 'r': result += '\r'; break; case '"': result += '"'; break; case '\\': result += '\\'; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { // Octal escape: up to 3 octal digits. std::string oct; oct += esc; advance(); for (int i = 0; i < 2 && !at_end(); i++) { char next = peek(); if (next < '0' || next > '7') break; oct += next; advance(); } long value = std::strtol(oct.c_str(), nullptr, 8); if (value > UCHAR_MAX) { error("octal escape sequence out of range '\\" + oct + "'", esc_line, esc_col, line_, col_); } result += static_cast(value); continue; // Already advanced past octal digits. } case 'x': case 'X': { advance(); std::string hex; for (int i = 0; i < 2 && !at_end(); i++) { char next = peek(); if (!std::isxdigit(next)) break; hex += next; advance(); } if (hex.empty()) { error("invalid hex escape sequence"); } else { result += static_cast(std::strtol(hex.c_str(), nullptr, 16)); } continue; // Already advanced past hex digits. } default: error(std::string("invalid escape character '\\") + esc + "'"); break; } advance(); } if (!at_end()) { advance(); // Closing quote. } else { error("unterminated string"); } return result; } // Consume an integer literal as a raw string. Handles decimal, hex (0x...), // exponent notation (NeM), underscore separators, and optional suffixes. std::string Parser::consume_integer_str() { consume_layout(); std::string result; // Hex prefix char next = peek(); if (next == '0' && (peek(1) == 'x' || peek(1) == 'X')) { result += next; advance(); result += peek(); advance(); while (!at_end()) { char next = peek(); if (!std::isxdigit(next) && next != '_') break; result += next; advance(); } if (!result.empty() && result.back() == '_') { error("trailing underscore in integer literal", line_, col_ - 1, line_, col_); } return result; } // Decimal digits with possible underscores while (!at_end()) { char next = peek(); if (!std::isdigit(next) && next != '_') break; result += next; advance(); } if (!result.empty() && result.back() == '_') { error( "trailing underscore in integer literal", line_, col_ - 1, line_, col_); } // Exponent notation: e.g. 1e6 if (!at_end()) { char ec = peek(); if (ec == 'e' || ec == 'E') { result += ec; advance(); while (!at_end()) { char next = peek(); if (!std::isdigit(next) && next != '_') break; result += next; advance(); } if (!result.empty() && result.back() == '_') { error("trailing underscore in integer literal", line_, col_ - 1, line_, col_); } } } // Optional suffix (u, l, ll, ul, ull, ns, us, ms, s, m, h, d) if (!at_end()) { char sc = peek(); // Check for time/size suffixes: ns, us, ms if ((sc == 'n' || sc == 'u' || sc == 'm') && peek(1) == 's') { result += sc; advance(); result += peek(); advance(); } else if (sc == 's' || sc == 'm' || sc == 'h' || sc == 'd') { result += sc; advance(); } else if (sc == 'u' || sc == 'U') { result += sc; advance(); // Possible 'l' or 'll' after 'u' if (!at_end()) { char lc = peek(); if (lc == 'l' || lc == 'L') { result += lc; advance(); if (!at_end()) { lc = peek(); if (lc == 'l' || lc == 'L') { result += lc; advance(); } } } } } else if (sc == 'l' || sc == 'L') { result += sc; advance(); if (!at_end()) { char lc = peek(); if (lc == 'l' || lc == 'L') { result += lc; advance(); } } } } // If alphanumeric characters still follow, the suffix is invalid. // Consume them to avoid cascading errors. if (!at_end()) { char fc = peek(); if (is_identifier_start(fc)) { auto [err_line, err_col] = get_current_line_col(); std::string bad; while (!at_end()) { char next = peek(); if (!is_identifier_body(next)) break; bad += next; advance(); } error("invalid integer suffix '" + bad + "'", err_line, err_col, line_, col_); } } return result; } // Error reporting bool Parser::has_errors() const { return ctx_.state_->diagnostics_->error_count() > 0; } void Parser::error(const std::string &msg) { auto sp = save_point(); consume_layout(); auto [begin_line, begin_col] = get_current_line_col(); // Scan past the current token to find its end. if (!at_end()) { char next = peek(); if (is_identifier_start(next)) { while (!at_end()) { char next = peek(); if (!is_identifier_body(next)) break; advance(); } } else if (std::isdigit(next)) { while (!at_end()) { char next = peek(); if (!std::isalnum(next) && next != '.') break; advance(); } } else if (next == '@' || next == '$') { advance(); while (!at_end()) { char next = peek(); if (!is_identifier_body(next)) break; advance(); } } else { advance(); } } auto [end_line, end_col] = get_current_line_col(); sp.restore(); error(msg, begin_line, begin_col, end_line, end_col); } void Parser::error(const std::string &msg, int begin_line, int begin_col, int end_line, int end_col) { auto loc = make_loc(begin_line, begin_col, end_line, end_col); SourceLocation valid(ctx_.source()); valid.begin = loc.begin; valid.end = loc.end; ctx_.state_->diagnostics_->addError( std::make_shared(std::move(valid))) << "syntax: " << msg; } // Source location tracking SourceLocation Parser::make_loc(int begin_line, int begin_col, int end_line, int end_col) const { SourceLocation loc(ctx_.source()); loc.begin.line = begin_line; loc.begin.column = begin_col; loc.end.line = end_line; loc.end.column = end_col; return loc; } None *Parser::make_none() { return ctx_.make_node(make_loc(line_, col_, line_, col_)); } Parser::LineCol Parser::get_current_line_col() { return { .line = line_, .col = col_ }; } // Lookahead helpers bool Parser::is_builtin(std::string_view name) { static const std::unordered_set builtins = { "args", "ctx", "kstack", "nsecs", "pid", "tid", "ustack", "__builtin_arch", "__builtin_comm", "__builtin_config", "__builtin_cpid", "__builtin_cpu", "__builtin_dw_ustack", "__builtin_elapsed", "__builtin_elf_ino", "__builtin_elf_is_exe", "__builtin_func", "__builtin_is_literal", "__builtin_kfunc_allowed", "__builtin_kfunc_exist", "__builtin_ncpus", "__builtin_probe", "__builtin_probetype", "__builtin_retval", "__builtin_safe_mode", "__builtin_signal_num", "__builtin_uaddr", "__builtin_usermode", }; if (builtins.contains(name)) { return true; } // Handle parameterized builtins: arg0-arg9+, sarg0-sarg9 if (name.size() >= 4 && name.starts_with("arg") && std::all_of(name.begin() + 3, name.end(), [](char c) { return std::isdigit(static_cast(c)); })) { return true; } if (name.size() >= 5 && name.starts_with("sarg") && std::all_of(name.begin() + 4, name.end(), [](char c) { return std::isdigit(static_cast(c)); })) { return true; } return false; } bool Parser::can_start_expression() const { size_t p = scan_layout(pos_); char c = char_at(p); return std::isdigit(static_cast(c)) || c == '$' || c == '@' || c == '"' || c == '(' || c == '-' || c == '!' || c == '~' || c == '*' || c == '&' || is_identifier_start(c); } bool Parser::looks_like_c_definition() const { size_t p = scan_layout(pos_); // Skip keyword (struct/union/enum), then accept an arbitrary sequence of // identifiers and balanced (...) / [...] groups before the opening brace. // This covers declarations like: // struct __attribute__((packed)) Foo { // while still rejecting attach points such as: // struct:probe { ... } p = scan_identifier_end(p); p = scan_layout(p); while (in_bounds(p)) { char ch = char_at(p); if (ch == '{') { return true; } if (ch == ':' || ch == '/' || ch == ',' || ch == ';') { return false; } if (is_identifier_start(ch)) { p = scan_identifier_end(p); p = scan_layout(p); continue; } if (ch == '(' || ch == '[') { char close = ch == '(' ? ')' : ']'; size_t after = scan_balanced(p, ch, close); if (after == p || char_at(after - 1) != close) { return false; } p = scan_layout(after); continue; } return false; } return false; } Pass CreateParsePass(bool debug) { return Pass::create("parse", [=](ASTContext &ast) { Parser parser(ast, debug); ast.root = parser.parse(); }); } } // namespace bpftrace bpftrace-0.27.1/src/parser.h000066400000000000000000000137721526721631600156460ustar00rootroot00000000000000#pragma once #include #include #include #include #include "ast/ast.h" #include "ast/context.h" #include "ast/pass_manager.h" namespace bpftrace { ast::Pass CreateParsePass(bool debug = false); // RD -> Recursive Descent // N.B. the debug argument is only valid if compiled in DEBUG mode class Parser { public: explicit Parser(ast::ASTContext &ctx, bool debug = false) : ctx_(ctx), debug_(debug) {}; ast::Program *parse(); std::optional parse_expr(); private: // Root-level grammar ast::Program *parse_program(); ast::CStatement *parse_c_preprocessor(); ast::CStatement *parse_c_definition(); ast::RootImport *parse_root_import(); ast::StatementImport *parse_statement_import(); ast::Macro *parse_macro(); ast::Expression parse_macro_arg(); ast::Subprog *parse_subprog(); ast::MapDeclStatement *parse_map_decl_stmt(); ast::Config *parse_config(); void skip_config_block(const std::string &err_msg); ast::Probe *parse_probe(); ast::AttachPoint *parse_attach_point(); std::optional parse_predicate(); // Block and statement grammar ast::BlockExpr *parse_block(bool allow_trailing_expr = true); ast::Statement parse_while_or_unroll(); ast::Statement parse_for(); void skip_to_block_end(); void expect_stmt_end(); void normalize_block_expression(ast::Expression &expr); bool parse_sigiled_stmt_or_trailing_expr( ast::StatementList &stmts, std::optional &trailing_expr); std::optional try_compound_op(); ast::Statement make_assignment(ast::Expression &lhs, ast::Expression rhs, const ast::SourceLocation &loc); ast::Statement make_assignment_or_expr(ast::Expression lhs, int stmt_line, int stmt_col); ast::Statement parse_statement(); // Type parsing ast::ParsedType *parse_type(bool emit_error = true); ast::Typeof *parse_type_annotation(bool type_only = false); std::optional scan_type_suffixes(size_t pos, bool &saw_suffix) const; std::optional> try_parse_type_reference( std::string_view end_chars); // Expression grammar ast::Expression parse_expression(); ast::Expression parse_ternary(); ast::Expression parse_binary(int min_prec); ast::Expression parse_binary(int min_prec, ast::Expression left); ast::Expression parse_unary(); ast::Expression parse_postfix(ast::Expression expr); ast::Expression parse_primary(); ast::Expression parse_call_expression(const std::string &name, const ast::SourceLocation &start_loc); ast::Expression parse_paren_expr(); std::optional try_parse_record(int begin_line, int begin_col); std::optional try_parse_cast_expr(int begin_line, int begin_col); ast::Expression parse_tuple_or_grouping_expr(int begin_line, int begin_col); ast::Expression parse_map_with_optional_keys(int begin_line, int begin_col); std::vector parse_field_access(); // Lexer helpers: peek/check (do not advance pos_) char at(size_t pos) const { return (*input_)[pos]; } bool in_bounds(size_t pos) const { return pos < input_->size(); } bool at_end() const; char peek(size_t offset = 0) const; char char_at(size_t pos) const; char previous_non_hspace() const; std::string_view view(size_t start, size_t end) const; std::string_view peek_keyword() const; bool check_keyword(const std::string &s) const; struct BinopInfo { ast::Operator op; int prec; }; std::optional peek_binop() const; static bool is_hspace(char c); static bool is_identifier_start(char c); static bool is_identifier_body(char c); static bool is_builtin(std::string_view name); bool can_start_expression() const; bool looks_like_c_definition() const; // Lexer helpers: scan (take pos, return new pos, no advance pos_) size_t scan_layout(size_t pos) const; size_t scan_identifier_end(size_t pos) const; size_t scan_balanced(size_t pos, char open, char close) const; size_t scan_pointer_suffix(size_t pos) const; // Lexer helpers: consume (advance pos_/line_/col_) void advance(int n = 1); void consume_layout(); void consume_line_comment(); void consume_block_comment(); bool match(char c); bool match(const std::string &s); bool expect(char c); bool expect(const std::string &s); std::string consume_ident_from(size_t start); std::optional consume_identifier(std::string err_msg = ""); std::string consume_variable(); std::string consume_map(); std::string consume_string(); std::string consume_integer_str(); // Error reporting bool has_errors() const; void error(const std::string &msg); void error(const std::string &msg, int begin_line, int begin_col, int end_line, int end_col); ast::None *make_none(); // Source location tracking ast::SourceLocation make_loc(int begin_line, int begin_col, int end_line, int end_col) const; struct LineCol { int line; int col; }; LineCol get_current_line_col(); // Saves parser position for backtracking. Call restore() to rewind. struct SavePoint { size_t pos; int line; int col; explicit SavePoint(Parser &p) : pos(p.pos_), line(p.line_), col(p.col_), parser_(p) { } void restore() { parser_.pos_ = pos; parser_.line_ = line; parser_.col_ = col; } private: Parser &parser_; }; SavePoint save_point() { return SavePoint(*this); } ast::ASTContext &ctx_; const bool debug_; const std::string *input_ = nullptr; size_t pos_ = 0; int line_ = 1; int col_ = 1; }; } // namespace bpftrace bpftrace-0.27.1/src/pcap_writer.cpp000066400000000000000000000025011526721631600172100ustar00rootroot00000000000000#include "pcap_writer.h" #ifdef HAVE_LIBPCAP #include namespace bpftrace { bool PCAPwriter::open(std::string file) { pd_ = pcap_open_dead(DLT_RAW, 65535); if (!pd_) return false; pdumper_ = pcap_dump_open(pd_, file.c_str()); return true; } void PCAPwriter::close() { pcap_close(pd_); pcap_dump_close(pdumper_); } #define NSEC_PER_SEC 1000000000L #define NSEC_PER_USEC 1000L bool PCAPwriter::write(uint64_t ns, const void *pkt, unsigned int size) { time_t secs, usecs, nsecs = ns; secs = nsecs / NSEC_PER_SEC; nsecs -= secs * NSEC_PER_SEC; usecs = nsecs / NSEC_PER_USEC; struct pcap_pkthdr hdr = { .ts = { .tv_sec = secs, .tv_usec = usecs, }, .caplen = size, .len = size, }; pcap_dump(reinterpret_cast(pdumper_), &hdr, static_cast(pkt)); return true; } }; // namespace bpftrace #else namespace bpftrace { bool PCAPwriter::open(std::string file __attribute__((__unused__))) { return false; } void PCAPwriter::close(void) { } bool PCAPwriter::write(uint64_t ns __attribute__((__unused__)), const void *pkt __attribute__((__unused__)), unsigned int size __attribute__((__unused__))) { return false; } }; // namespace bpftrace #endif // HAVE_LIBPCAP bpftrace-0.27.1/src/pcap_writer.h000066400000000000000000000007041526721631600166600ustar00rootroot00000000000000#pragma once #include #include struct pcap; using pcap_t = struct pcap; struct pcap_dumper; using pcap_dumper_t = struct pcap_dumper; namespace bpftrace { class PCAPwriter { public: PCAPwriter() = default; ~PCAPwriter() = default; bool open(std::string file); void close(); bool write(uint64_t ns, const void *pkt, unsigned int size); private: pcap_t *pd_; pcap_dumper_t *pdumper_; }; }; // namespace bpftrace bpftrace-0.27.1/src/probe_matcher.cpp000066400000000000000000000635461526721631600175230ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include "bpftrace.h" #include "btf.h" #include "cxxdemangler/cxxdemangler.h" #include "dwarf_parser.h" #include "log.h" #include "probe_matcher.h" #include "scopeguard.h" #include "symbols/kernel.h" #include "tracefs/tracefs.h" #include "util/paths.h" #include "util/strings.h" #include "util/symbols.h" #include "util/wildcard.h" namespace bpftrace { // Finds all matches of search_input in the provided input stream. std::set ProbeMatcher::get_matches_in_stream( const std::string& search_input, std::istream& symbol_stream, bool demangle_symbols, const char delim) { bool start_wildcard, end_wildcard; auto tokens = util::get_wildcard_tokens(search_input, start_wildcard, end_wildcard); // Since demangled_name contains function parameters, we need to remove // them unless the user specified '(' in the search input (i.e. wants // to match against the parameters explicitly). // Only used for C++ when demangling is enabled. auto has_parameter = [](const std::string& token) { return token.find('(') != std::string::npos; }; const bool truncate_parameters = std::ranges::none_of(tokens, has_parameter); std::string line; std::set matches; while (std::getline(symbol_stream, line, delim)) { if (!util::wildcard_match(line, tokens, start_wildcard, end_wildcard)) { if (demangle_symbols) { auto fun_line = line; auto prefix = fun_line.find(':') != std::string::npos ? util::erase_prefix(fun_line) + ":" : ""; if (util::symbol_has_cpp_mangled_signature(fun_line)) { char* demangled_name = cxxdemangle(fun_line.c_str()); if (!demangled_name) continue; SCOPE_EXIT { ::free(demangled_name); }; // Match against the demanled name. std::string match_line = prefix + demangled_name; if (truncate_parameters) { util::erase_parameter_list(match_line); } if (util::wildcard_match( match_line, tokens, start_wildcard, end_wildcard)) { goto out; } } } continue; } out: // skip the ".part.N" kprobe variants, as they can't be traced: if (line.find(".part.") != std::string::npos) continue; matches.insert(line); } return matches; } // Get matches of search_input (containing a wildcard) for a given probe_type. // probe_type determines where to take the candidate matches from. // Some probe types (e.g. uprobe) require target to be specified. std::set ProbeMatcher::get_matches_for_probetype( const ProbeType& probe_type, const std::string& target, const std::string& search_input, bool demangle_symbols) { std::unique_ptr symbol_stream; switch (probe_type) { case ProbeType::kprobe: case ProbeType::kretprobe: { if (target.empty()) { symbol_stream = get_symbols_from_traceable_funcs(false); } else if (!util::has_wildcard(target)) { symbol_stream = get_symbols_from_traceable_funcs(true, target); } else { symbol_stream = get_symbols_from_traceable_funcs(true); } break; } case ProbeType::uprobe: case ProbeType::uretprobe: { auto result = [&]() { if (bpftrace_->pid()) { auto pid_symbols = user_func_info_.func_symbols_for_pid( *bpftrace_->pid()); if (pid_symbols) { return *pid_symbols; } } return symbols::BinaryFuncMap(); }(); // Expand to the full set of possible matching paths, unless a pid is // given with -p and target is '*'. In that case, we already have // the full set of symbols. if (!bpftrace_->pid() || target != "*") { auto paths = util::resolve_binary_path(target, bpftrace_->pid(), bpftrace_->safe_mode_); for (const auto& path : paths) { auto ok = user_func_info_.func_symbols_for_path(path); if (ok) { for (const auto& sym : *ok) { result[path].insert(sym); } } } } std::stringstream ss; for (const auto& [path, symbols] : result) { for (const auto& sym : symbols) { ss << path << ":" << sym << "\n"; } } symbol_stream = std::make_unique(ss.str()); break; } case ProbeType::tracepoint: { auto result = kernel_func_info_.get_tracepoints(); std::stringstream ss; for (const auto& [category, events] : result) { for (const auto& event : *events) { ss << category << ":" << event << "\n"; } } symbol_stream = std::make_unique(ss.str()); break; } // The two `has_btf_data` checks below for fentry/fexit/rawtracepoints // are more about ordering than system properties. // Initially, before BTF is loaded and we want to determine what modules to // load BTF from we check "/sys/kernel/tracing/available_filter_functions". // Then we check the BTF to filter out functions from that list that don't // have any BTF definitions. case ProbeType::rawtracepoint: { symbol_stream = get_raw_tracepoint_symbols(); break; } case ProbeType::fentry: case ProbeType::fexit: { if (target == "bpf") { symbol_stream = get_running_bpf_programs(); } else { symbol_stream = get_fentry_symbols(target); } break; } case ProbeType::usdt: { // If pid is set, then we grab symbols directly from the binary. auto result = [&]() { if (bpftrace_->pid()) { auto pid_symbols = user_func_info_.usdt_probes_for_pid( *bpftrace_->pid()); if (pid_symbols) { return *pid_symbols; } } return symbols::BinaryUSDTMap(); }(); // Like the uprobe case above, we expand to the full set of paths. auto paths = util::resolve_binary_path(target, bpftrace_->pid()); for (const auto& path : paths) { auto ok = user_func_info_.usdt_probes_for_path(path); if (ok) { for (const auto& sym : *ok) { result[path].insert(sym); } } } std::stringstream ss; for (const auto& [path, symbols] : result) { for (const auto& sym : symbols) { ss << path << ":" << sym.provider << ":" << sym.name + "\n"; } } symbol_stream = std::make_unique(ss.str()); break; } case ProbeType::software: { symbol_stream = get_symbols_from_list(SW_PROBE_LIST); break; } case ProbeType::hardware: { symbol_stream = get_symbols_from_list(HW_PROBE_LIST); break; } case ProbeType::iter: { if (!bpftrace_->has_btf_data()) break; std::string ret; auto iters = bpftrace_->btf_->get_all_iters(); for (const auto& iter : iters) { // second check if (bpftrace_->feature_->has_iter(iter)) ret += iter + "\n"; else LOG(WARNING) << "The kernel contains bpf_iter__" << iter << " struct but does not support loading an iterator" " program against it. Please report this bug."; } symbol_stream = std::make_unique(ret); break; } case ProbeType::interval: case ProbeType::profile: { std::string ret; for (const auto& unit : TIME_UNITS) ret += unit + ":\n"; symbol_stream = std::make_unique(ret); break; } case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: return { target + ":" }; default: return {}; } if (symbol_stream) return get_matches_in_stream(search_input, *symbol_stream, demangle_symbols); else return {}; } // Find all matches of search_input in set std::set ProbeMatcher::get_matches_in_set( const std::string& search_input, const std::set& set) { std::string stream_in; // Strings in the set may contain a newline character, so we use '$' // as a delimiter. for (const auto& str : set) stream_in.append(str + "$"); std::istringstream stream(stream_in); return get_matches_in_stream(search_input, stream, false, '$'); } std::unique_ptr ProbeMatcher::get_symbols_from_traceable_funcs( bool with_modules, std::optional module) const { std::stringstream ss; for (const auto& [mod, funcs] : kernel_func_info_.get_traceable_funcs(module)) { for (const auto& func : *funcs) { if (with_modules) { ss << mod << ":" << func << "\n"; } else { ss << func << "\n"; } } } return std::make_unique(ss.str()); } std::unique_ptr ProbeMatcher::get_fentry_symbols( const std::string& mod) const { if (bpftrace_->btf_->has_data() && bpftrace_->btf_->modules_loaded()) { return bpftrace_->btf_->get_all_traceable_funcs(kernel_func_info_); } else if (!mod.empty() && !util::has_wildcard(mod)) { return get_symbols_from_traceable_funcs(true, mod); } else { return get_symbols_from_traceable_funcs(true); } } std::unique_ptr ProbeMatcher::get_running_bpf_programs() const { std::string funcs; auto ids_and_syms = kernel_func_info_.get_bpf_progs(); for (const auto& [id, symbol] : ids_and_syms) { funcs += "bpf:" + std::to_string(id) + ":" + symbol + "\n"; } return std::make_unique(funcs); } std::unique_ptr ProbeMatcher::get_raw_tracepoint_symbols() const { if (bpftrace_->btf_->has_data() && bpftrace_->btf_->modules_loaded()) { return bpftrace_->btf_->get_all_raw_tracepoints(); } else { std::string rts; for (const auto& [module, events] : kernel_func_info_.get_raw_tracepoints()) { for (const auto& event : *events) { rts += module + ":" + event + "\n"; } } return std::make_unique(rts); } } std::unique_ptr ProbeMatcher::get_symbols_from_list( const std::vector& probes_list) const { std::string symbols; for (const auto& probe : probes_list) { symbols += probe.path + ":\n"; if (!probe.alias.empty()) symbols += probe.alias + ":\n"; } return std::make_unique(symbols); } // Get list of kernel probe types for the purpose of listing. // Ignore return probes and aliases. std::unique_ptr ProbeMatcher::kernel_probe_list() { std::string probes; for (const auto& p : PROBE_LIST) { if (!p.show_in_kernel_list) { continue; } probes += p.name + "\n"; } return std::make_unique(probes); } // Get list of userspace probe types for the purpose of listing. // Ignore return probes. std::unique_ptr ProbeMatcher::userspace_probe_list() { std::string probes; for (const auto& p : PROBE_LIST) { if (p.show_in_userspace_list) { probes += p.name + "\n"; } } return std::make_unique(probes); } FuncParamLists ProbeMatcher::get_tracepoints_params( const std::set& tracepoints) { FuncParamLists params; for (const auto& tracepoint : tracepoints) { auto event = tracepoint; auto category = util::erase_prefix(event); std::string format_file_path = tracefs::event_format_file(category, event); std::ifstream format_file(format_file_path.c_str()); std::string line; if (format_file.fail()) { LOG(ERROR) << "tracepoint format file not found: " << format_file_path; return {}; } // Skip lines until the first empty line do { getline(format_file, line); } while (!line.empty()); while (getline(format_file, line)) { if (line.starts_with("\tfield:")) { size_t col_pos = line.find(':') + 1; params[tracepoint].push_back( line.substr(col_pos, line.find(';') - col_pos)); } } } return params; } FuncParamLists ProbeMatcher::get_iters_params( const std::set& iters) { const std::string prefix = "vmlinux:bpf_iter_"; FuncParamLists params; std::set funcs; for (const auto& iter : iters) funcs.insert(prefix + iter); params = bpftrace_->btf_->get_params(funcs); for (auto func : funcs) { // delete `int retval` params[func].pop_back(); // delete `struct bpf_iter_meta * meta` params[func].erase(params[func].begin()); // restore key value auto param = params.extract(func); param.key() = func.substr(prefix.size()); params.insert(std::move(param)); } return params; } FuncParamLists ProbeMatcher::get_uprobe_params( const std::set& uprobes) { FuncParamLists params; static std::set warned_paths; for (const auto& match : uprobes) { std::string fun = match; std::string path = util::erase_prefix(fun); auto dwarf = Dwarf::GetFromBinary(nullptr, path, bpftrace_->debuginfo_path_); if (dwarf) { params.emplace(match, dwarf->get_function_params(fun)); } else { if (warned_paths.insert(path).second) LOG(WARNING) << "No DWARF found for \"" << path << "\"" << ", cannot show parameter info"; } } return params; } FuncParamLists ProbeMatcher::get_params_for_matches( ProbeType probe_type, const std::set& matches) { if (!bt_verbose) return {}; switch (probe_type) { case ProbeType::tracepoint: return get_tracepoints_params(matches); case ProbeType::fentry: { auto params = bpftrace_->btf_->get_params(matches); // fentry (kfunc) does not have a return value, so strip the retval // entry that get_params() unconditionally appends. Inspect the last // element rather than blindly popping so a future change in // get_params() can't silently drop a real parameter. for (auto& [name, p] : params) { if (!p.empty() && p.back().ends_with(" retval")) p.pop_back(); } return params; } case ProbeType::fexit: return bpftrace_->btf_->get_params(matches); case ProbeType::rawtracepoint: return bpftrace_->btf_->get_rawtracepoint_params(matches); case ProbeType::iter: return get_iters_params(matches); case ProbeType::uprobe: return get_uprobe_params(matches); case ProbeType::kprobe: return bpftrace_->btf_->get_kprobes_params(matches); case ProbeType::kretprobe: return bpftrace_->btf_->get_kretprobes_params(matches); default: return {}; } } void ProbeMatcher::format_matches_for_listing( ProbeType probe_type, const std::set& matches, const FuncParamLists& param_lists, std::vector& results, const std::string& lang) { for (const auto& match : matches) { std::string match_print = match; if (lang == "cpp") { std::string target = util::erase_prefix(match_print); char* demangled_name = cxxdemangle(match_print.c_str()); SCOPE_EXIT { ::free(demangled_name); }; // Demangled name may contain symbols not accepted by the attach // point parser, so surround it with quotes to make the entry // directly usable as an attach point. auto func = demangled_name ? "\"" + std::string(demangled_name) + "\"" : match_print; match_print = target + ":" + lang + ":" + func; } std::ostringstream ss; ss << probe_type << ":" << match_print; results.push_back(ss.str()); if (bt_verbose) { auto it = param_lists.find(match); if (it != param_lists.end()) { for (const auto& param : it->second) results.push_back(" " + param); } } } } std::vector ProbeMatcher::get_probes_for_listing( ast::Program* prog) { std::vector results; for (auto* probe : prog->probes) { for (auto* ap : probe->attach_points) { auto probe_type = probetype(ap->provider); // Skip special probes (begin, end, self). if (probe_type == ProbeType::special) continue; auto matches = get_matches_for_ap(*ap); auto param_lists = get_params_for_matches(probe_type, matches); format_matches_for_listing( probe_type, matches, param_lists, results, ap->lang); } } return results; } std::vector ProbeMatcher::get_probes_for_listing( const std::string& pattern, std::optional pid) { std::vector results; // Split the pattern by ':' to extract probe type and search components. // Pattern format: "probe_type:target:func" or "probe_type:func" etc. auto parts = util::split_string(pattern, ':'); if (parts.empty()) { return results; } // Build the search input from remaining parts. std::string search_suffix; auto colon_pos = pattern.find(':'); if (colon_pos != std::string::npos) { search_suffix = pattern.substr(colon_pos + 1); } if (search_suffix.empty() && parts.size() == 1) { search_suffix = "*"; } // Determine which probe types to search. std::set probe_types; const auto& probe_type_pattern = parts[0]; // Include userspace probe types only if: // 1. The probe type is explicitly specified (not wildcarded), OR // 2. A PID is provided to scope the search, OR // 3. A specific (non-wildcarded) target file exists to scope the search bool has_specific_target = parts.size() > 1 && !parts[1].empty() && !util::has_wildcard(parts[1]) && std::filesystem::exists(parts[1]); bool include_userspace = (!util::has_wildcard(probe_type_pattern) && !probe_type_pattern.empty()) || pid.has_value() || has_specific_target; // For single-part patterns (like "*" or "kprobe"), expand probe types. if (util::has_wildcard(probe_type_pattern) || parts.size() == 1) { // Expand to all matching probe types. auto kernel_types = expand_probetype_kernel( probe_type_pattern.empty() ? "*" : probe_type_pattern); probe_types.insert(kernel_types.begin(), kernel_types.end()); if (include_userspace) { auto userspace_types = expand_probetype_userspace( probe_type_pattern.empty() ? "*" : probe_type_pattern); probe_types.insert(userspace_types.begin(), userspace_types.end()); } } else { probe_types.insert(expand_probe_name(probe_type_pattern)); } for (const auto& probe_type_str : probe_types) { if (probe_type_str == "self") { auto self_probes = get_self_probes_for_listing(search_suffix); results.insert(results.end(), self_probes.begin(), self_probes.end()); continue; } auto probe_type = probetype(probe_type_str); if (probe_type == ProbeType::invalid) continue; std::string target; std::string search_input = search_suffix; // For probe types that require a target, extract it from search_suffix. switch (probe_type) { case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::usdt: case ProbeType::tracepoint: { // These need target:func format. if (parts.size() > 2) { target = parts[1]; search_input = search_suffix; } else { target = "*"; search_input = "*:" + search_suffix; } break; } case ProbeType::kprobe: case ProbeType::kretprobe: { // These can be target:func or just func. if (parts.size() > 2) { target = parts[1]; } search_input = search_suffix; break; } case ProbeType::fentry: case ProbeType::fexit: case ProbeType::rawtracepoint: { // These can be target:func or just func. For the latter, we have to // explicitly add the "*:" prefix to search_input since symbols // extracted from BTF have the "module:func" form. if (parts.size() > 2) { target = parts[1]; search_input = search_suffix; } else { target = "*"; search_input = "*:" + search_suffix; } break; } default: // For other probe types, use search_suffix as-is. search_input = search_suffix.empty() ? "*" : search_suffix; break; } auto matches = get_matches_for_probetype( probe_type, target, search_input, false /* demangle_symbols */); auto param_lists = get_params_for_matches(probe_type, matches); format_matches_for_listing(probe_type, matches, param_lists, results); } return results; } std::vector ProbeMatcher::get_self_probes_for_listing( const std::string& search_input) { std::string probes; for (const auto& signal : SIGNALS) { probes += "signal:" + signal + "\n"; } std::istringstream probe_stream(probes); std::vector results; auto search = search_input.empty() ? "*" : search_input; for (const auto& match : get_matches_in_stream(search, probe_stream, false)) { results.push_back("self:" + match); } return results; } std::set ProbeMatcher::get_matches_for_ap( const ast::AttachPoint& attach_point) { std::string search_input; switch (probetype(attach_point.provider)) { case ProbeType::kprobe: case ProbeType::kretprobe: { if (!attach_point.target.empty()) search_input = attach_point.target + ":" + attach_point.func; else search_input = attach_point.func; break; } case ProbeType::rawtracepoint: { search_input = attach_point.target + ":" + attach_point.func; break; } case ProbeType::iter: { search_input = attach_point.func; break; } case ProbeType::fentry: case ProbeType::fexit: { if (attach_point.target == "bpf") { search_input = "bpf:" + (attach_point.bpf_prog_id ? std::to_string(attach_point.bpf_prog_id) : "*") + ":" + attach_point.func; break; } [[fallthrough]]; } case ProbeType::special: case ProbeType::test: case ProbeType::benchmark: case ProbeType::uprobe: case ProbeType::uretprobe: case ProbeType::tracepoint: { // Do not expand "target:" as that would match all functions in // target. This may occur when an absolute address is given instead of // a function. if (attach_point.func.empty()) return { attach_point.target + ":" }; search_input = attach_point.target + ":" + attach_point.func; break; } case ProbeType::hardware: case ProbeType::software: case ProbeType::profile: case ProbeType::interval: case ProbeType::watchpoint: { search_input = attach_point.target + ":"; break; } case ProbeType::usdt: { auto target = attach_point.target; // If PID is specified, targets in symbol_stream may have the // "/proc//root" prefix followed by an absolute path, so we make // the target absolute and add a leading wildcard. if (bpftrace_->pid().has_value()) { if (!target.empty()) { if (auto abs_target = util::abs_path(target)) target = "*" + abs_target.value(); } else { target = "*"; } } auto ns = attach_point.ns.empty() ? "*" : attach_point.ns; search_input = target + ":" + ns + ":" + attach_point.func; break; } case ProbeType::invalid: throw WildcardException( "Wildcard matches aren't available on probe type '" + attach_point.provider + "'"); } return get_matches_for_probetype(probetype(attach_point.provider), attach_point.target, search_input, attach_point.lang == "cpp"); } std::set ProbeMatcher::expand_probetype_kernel( const std::string& probe_type) { if (util::has_wildcard(probe_type)) return get_matches_in_stream(probe_type, *kernel_probe_list()); else return { probe_type }; } std::set ProbeMatcher::expand_probetype_userspace( const std::string& probe_type) { if (util::has_wildcard(probe_type)) return get_matches_in_stream(probe_type, *userspace_probe_list()); else return { probe_type }; } std::vector ProbeMatcher::get_structs_for_listing( const std::string& search) { std::vector results; std::set structs; auto structmap = bpftrace_->btf_->get_all_structs(); std::string search_input = search; // If verbose is on, structs will contain full definitions if (bt_verbose) search_input += " *{*}*"; for (const auto& s : structmap) { structs.insert(s.first); } for (const auto& match : get_matches_in_set(search_input, structs)) { auto sm = structmap.find(match); // If in verbose mode, display module information. if (sm != structmap.end() && bt_verbose) { // The exact same structure definition may appear in multiple BTFs. If // the structure is defined in vmlinux, then it does not need to be // printed in other BTFs. if (sm->second.contains("vmlinux")) { results.push_back(std::string("vmlinux: ") + match); } else { for (const auto& mod : sm->second) { results.push_back(mod + std::string(": ") + match); } } } else { results.push_back(match); } } return results; } } // namespace bpftrace bpftrace-0.27.1/src/probe_matcher.h000066400000000000000000000147601526721631600171620ustar00rootroot00000000000000#pragma once #include #include #include "ast/ast.h" #include "btf.h" #include "symbols/kernel.h" #include "symbols/user.h" namespace bpftrace { struct ProbeListItem { std::string path; std::string alias; uint32_t type; uint64_t defaultp; }; // clang-format off const std::vector SW_PROBE_LIST = { { .path="alignment-faults", .alias="", .type=PERF_COUNT_SW_ALIGNMENT_FAULTS, .defaultp=1 }, { .path="bpf-output", .alias="", .type=PERF_COUNT_SW_BPF_OUTPUT, .defaultp=1 }, { .path="context-switches", .alias="cs", .type=PERF_COUNT_SW_CONTEXT_SWITCHES, .defaultp=1000 }, { .path="cpu-clock", .alias="cpu", .type=PERF_COUNT_SW_CPU_CLOCK, .defaultp=1000000 }, { .path="cpu-migrations", .alias="", .type=PERF_COUNT_SW_CPU_MIGRATIONS, .defaultp=1 }, { .path="dummy", .alias="", .type=PERF_COUNT_SW_DUMMY, .defaultp=1 }, { .path="emulation-faults", .alias="", .type=PERF_COUNT_SW_EMULATION_FAULTS, .defaultp=1 }, { .path="major-faults", .alias="", .type=PERF_COUNT_SW_PAGE_FAULTS_MAJ, .defaultp=1 }, { .path="minor-faults", .alias="", .type=PERF_COUNT_SW_PAGE_FAULTS_MIN, .defaultp=100 }, { .path="page-faults", .alias="faults", .type=PERF_COUNT_SW_PAGE_FAULTS, .defaultp=100 }, { .path="task-clock", .alias="", .type=PERF_COUNT_SW_TASK_CLOCK, .defaultp=1 }, }; const std::vector HW_PROBE_LIST = { { .path="backend-stalls", .alias="", .type=PERF_COUNT_HW_STALLED_CYCLES_BACKEND, .defaultp=1000000 }, { .path="branch-instructions", .alias="branches", .type=PERF_COUNT_HW_BRANCH_INSTRUCTIONS, .defaultp=100000 }, { .path="branch-misses", .alias="", .type=PERF_COUNT_HW_BRANCH_MISSES, .defaultp=100000 }, { .path="bus-cycles", .alias="", .type=PERF_COUNT_HW_BUS_CYCLES, .defaultp=100000 }, { .path="cache-misses", .alias="", .type=PERF_COUNT_HW_CACHE_MISSES, .defaultp=1000000 }, { .path="cache-references", .alias="", .type=PERF_COUNT_HW_CACHE_REFERENCES, .defaultp=1000000 }, { .path="cpu-cycles", .alias="cycles", .type=PERF_COUNT_HW_CPU_CYCLES, .defaultp=1000000 }, { .path="frontend-stalls", .alias="", .type=PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, .defaultp=1000000 }, { .path="instructions", .alias="", .type=PERF_COUNT_HW_INSTRUCTIONS, .defaultp=1000000 }, { .path="ref-cycles", .alias="", .type=PERF_COUNT_HW_REF_CPU_CYCLES, .defaultp=1000000 } }; // clang-format on const std::unordered_set TIME_UNITS = { "s", "ms", "us", "hz" }; const std::unordered_set SIGNALS = { "SIGUSR1" }; class BPFtrace; class ProbeMatcher { public: explicit ProbeMatcher(BPFtrace *bpftrace, const symbols::KernelInfo &kernel_func_info, const symbols::UserInfo &user_func_info) : bpftrace_(bpftrace), kernel_func_info_(kernel_func_info), user_func_info_(user_func_info) { } virtual ~ProbeMatcher() = default; // Get all matches for attach point containing a wildcard. // The output strings format depends on the probe type. std::set get_matches_for_ap( const ast::AttachPoint &attach_point); // Expanding probe type containing a wildcard. std::set expand_probetype_kernel(const std::string &probe_type); std::set expand_probetype_userspace( const std::string &probe_type); // Match all probes in prog and return them as formatted strings. std::vector get_probes_for_listing(ast::Program *prog); // Get probes matching a raw pattern string (e.g., "kprobe:*", "*:*foo*"). // If pid is provided, userspace probes will be included even with wildcard // probe types; otherwise userspace probes require explicit probe type. std::vector get_probes_for_listing( const std::string &pattern, std::optional pid = std::nullopt); // Get definitions of structures matching search. std::vector get_structs_for_listing(const std::string &search); const BPFtrace *bpftrace_; const symbols::KernelInfo &kernel_func_info_; const symbols::UserInfo &user_func_info_; private: std::set get_matches_in_stream(const std::string &search_input, std::istream &symbol_stream, bool demangle_symbols = true, char delim = '\n'); std::set get_matches_for_probetype( const ProbeType &probe_type, const std::string &target, const std::string &search_input, bool demangle_symbols); std::set get_matches_in_set(const std::string &search_input, const std::set &set); std::vector get_self_probes_for_listing( const std::string &search_input); virtual std::unique_ptr get_symbols_from_traceable_funcs( bool with_modules = false, std::optional module = std::nullopt) const; virtual std::unique_ptr get_symbols_from_list( const std::vector &probes_list) const; virtual std::unique_ptr get_fentry_symbols( const std::string &mod) const; virtual std::unique_ptr get_running_bpf_programs() const; virtual std::unique_ptr get_raw_tracepoint_symbols() const; std::unique_ptr get_iter_symbols() const; std::unique_ptr kernel_probe_list(); std::unique_ptr userspace_probe_list(); FuncParamLists get_tracepoints_params( const std::set &tracepoints); FuncParamLists get_iters_params(const std::set &iters); FuncParamLists get_uprobe_params(const std::set &uprobes); FuncParamLists get_params_for_matches(ProbeType probe_type, const std::set &matches); void format_matches_for_listing(ProbeType probe_type, const std::set &matches, const FuncParamLists ¶m_lists, std::vector &results, const std::string &lang = ""); }; } // namespace bpftrace bpftrace-0.27.1/src/probe_types.cpp000066400000000000000000000051011526721631600172230ustar00rootroot00000000000000#include #include #include #include "probe_types.h" #include "util/strings.h" namespace bpftrace { std::ostream &operator<<(std::ostream &os, ProbeType type) { os << probetypeName(type); return os; } ProbeType probetype(const std::string &probeName) { ProbeType retType = ProbeType::invalid; const std::string lowerProbeName = util::to_lower(probeName); auto v = std::ranges::find_if(PROBE_LIST, [&lowerProbeName](const ProbeItem &p) { return (p.name == lowerProbeName || p.aliases.contains(lowerProbeName)); }); if (v != PROBE_LIST.end()) retType = v->type; return retType; } std::string expand_probe_name(const std::string &orig_name) { std::string expanded_name = util::to_lower(orig_name); auto v = std::ranges::find_if(PROBE_LIST, [&orig_name](const ProbeItem &p) { return (p.name == orig_name || p.aliases.contains(orig_name)); }); if (v != PROBE_LIST.end()) expanded_name = v->name; return expanded_name; } // probetypeName is often used in string concatenations so do not use // string_view to avoid extra casts // NOLINTNEXTLINE(modernize-use-string-view) std::string probetypeName(ProbeType t) { // clang-format off switch (t) { case ProbeType::invalid: return "invalid"; break; case ProbeType::special: return "special"; break; case ProbeType::test: return "test"; break; case ProbeType::benchmark: return "benchmark"; break; case ProbeType::kprobe: return "kprobe"; break; case ProbeType::kretprobe: return "kretprobe"; break; case ProbeType::uprobe: return "uprobe"; break; case ProbeType::uretprobe: return "uretprobe"; break; case ProbeType::usdt: return "usdt"; break; case ProbeType::tracepoint: return "tracepoint"; break; case ProbeType::profile: return "profile"; break; case ProbeType::interval: return "interval"; break; case ProbeType::software: return "software"; break; case ProbeType::hardware: return "hardware"; break; case ProbeType::watchpoint: return "watchpoint"; break; case ProbeType::fentry: return "fentry"; break; case ProbeType::fexit: return "fexit"; break; case ProbeType::iter: return "iter"; break; case ProbeType::rawtracepoint: return "rawtracepoint"; break; } // clang-format on return {}; // unreached } } // namespace bpftrace bpftrace-0.27.1/src/probe_types.h000066400000000000000000000075611526721631600167040ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include #include namespace bpftrace { enum class ProbeType { invalid, special, test, benchmark, kprobe, kretprobe, uprobe, uretprobe, usdt, tracepoint, profile, interval, software, hardware, watchpoint, fentry, fexit, iter, rawtracepoint, }; std::ostream &operator<<(std::ostream &os, ProbeType type); struct ProbeItem { std::string name; std::unordered_set aliases; ProbeType type; // these are used in bpftrace -l // to show which probes are available to attach to bool show_in_kernel_list = false; bool show_in_userspace_list = false; }; const std::vector PROBE_LIST = { { .name = "kprobe", .aliases = { "k" }, .type = ProbeType::kprobe, .show_in_kernel_list = true }, { .name = "kretprobe", .aliases = { "kr" }, .type = ProbeType::kretprobe }, { .name = "uprobe", .aliases = { "u" }, .type = ProbeType::uprobe, .show_in_userspace_list = true }, { .name = "uretprobe", .aliases = { "ur" }, .type = ProbeType::uretprobe }, { .name = "usdt", .aliases = { "U" }, .type = ProbeType::usdt, .show_in_userspace_list = true }, { .name = "begin", .aliases = {}, .type = ProbeType::special }, { .name = "end", .aliases = {}, .type = ProbeType::special }, { .name = "self", .aliases = {}, .type = ProbeType::special }, { .name = "test", .aliases = {}, .type = ProbeType::test }, { .name = "bench", .aliases = {}, .type = ProbeType::benchmark }, { .name = "tracepoint", .aliases = { "t" }, .type = ProbeType::tracepoint, .show_in_kernel_list = true }, { .name = "profile", .aliases = { "p" }, .type = ProbeType::profile }, { .name = "interval", .aliases = { "i" }, .type = ProbeType::interval }, { .name = "software", .aliases = { "s" }, .type = ProbeType::software, .show_in_kernel_list = true }, { .name = "hardware", .aliases = { "h" }, .type = ProbeType::hardware, .show_in_kernel_list = true }, { .name = "watchpoint", .aliases = { "w" }, .type = ProbeType::watchpoint }, { .name = "fentry", .aliases = { "f", "kfunc" }, .type = ProbeType::fentry, .show_in_kernel_list = true }, { .name = "fexit", .aliases = { "fr", "kretfunc" }, .type = ProbeType::fexit }, { .name = "iter", .aliases = { "it" }, .type = ProbeType::iter, .show_in_kernel_list = true }, { .name = "rawtracepoint", .aliases = { "rt" }, .type = ProbeType::rawtracepoint, .show_in_kernel_list = true }, }; ProbeType probetype(const std::string &probeName); std::string expand_probe_name(const std::string &orig_name); std::string probetypeName(ProbeType t); struct Probe { ProbeType type; std::string path; // file path if used std::string attach_point; // probe name (last component) std::string name; // full probe name std::string pin; // pin file for iterator probes std::string ns; // for USDT probes, if provider namespace not from path uint64_t loc = 0; // for USDT probes uint64_t log_size = 1000000; int index = 0; int freq = 0; uint64_t len = 0; // for watchpoint probes, size of region std::string mode; // for watchpoint probes, watch mode (rwx) uint64_t address = 0; uint64_t func_offset = 0; uint64_t bpf_prog_id = 0; std::set funcs; bool is_session = false; private: friend class cereal::access; template void serialize(Archive &archive) { archive(type, path, attach_point, name, pin, ns, loc, log_size, index, freq, len, mode, address, func_offset, funcs); } }; } // namespace bpftrace bpftrace-0.27.1/src/required_resources.cpp000066400000000000000000000035671526721631600206200ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "required_resources.h" namespace bpftrace { void RequiredResources::save_state(std::ostream &out) const { cereal::BinaryOutputArchive archive(out); archive(*this); } void RequiredResources::load_state(std::istream &in) { cereal::BinaryInputArchive archive(in); archive(*this); } class Membuf : public std::streambuf { public: Membuf(uint8_t *begin, uint8_t *end) { auto *b = reinterpret_cast(begin); auto *e = reinterpret_cast(end); this->setg(b, b, e); } }; void RequiredResources::load_state(const uint8_t *ptr, size_t len) { auto *addr = const_cast(ptr); Membuf mbuf(addr, addr + len); std::istream istream(&mbuf); cereal::BinaryInputArchive archive(istream); archive(*this); } std::ostream &operator<<(std::ostream &os, const RuntimeErrorInfo &info) { switch (info.error_id) { case RuntimeErrorId::HELPER_ERROR: { // Helper errors are handled separately in output. os << ""; break; } case RuntimeErrorId::DIVIDE_BY_ZERO: { os << DIVIDE_BY_ZERO_MSG; break; } case RuntimeErrorId::ARRAY_ACCESS_OOB: { os << ARRAY_ACCESS_OOB_MSG; break; } case RuntimeErrorId::CPU_COUNT_MISMATCH: { os << CPU_COUNT_MISMATCH_MSG; break; } case RuntimeErrorId::KSTACK: { os << KSTACK_MSG; break; } case RuntimeErrorId::USTACK: { os << USTACK_MSG; break; } case RuntimeErrorId::DW_USTACK_NO_DWARF: { os << DW_USTACK_NO_DWARF_MSG; break; } } return os; } } // namespace bpftrace bpftrace-0.27.1/src/required_resources.h000066400000000000000000000211351526721631600202540ustar00rootroot00000000000000#pragma once #include #include #include #include #include #include #include #include #include #include "ast/location.h" #include "format_string.h" #include "globalvars.h" #include "map_info.h" #include "struct.h" #include "types.h" #include "util/bpf_funcs.h" namespace bpftrace { class BPFtrace; static const auto DIVIDE_BY_ZERO_MSG = "Divide or modulo by 0 detected. This can lead to unexpected " "results. 1 is being used as the result."; static const auto ARRAY_ACCESS_OOB_MSG = "Array access out of bounds. This can lead to unexpected " "results."; static const auto CPU_COUNT_MISMATCH_MSG = "CPU count mismatch; unable to find per-cpu data."; static const auto KSTACK_MSG = "Error reading kstack."; static const auto USTACK_MSG = "Error reading ustack."; static const auto DW_USTACK_NO_DWARF_MSG = "No DWARF unwind data available for this process. " "Use -p or --dwarf-pid to specify target PIDs."; enum class RuntimeErrorId { DIVIDE_BY_ZERO, HELPER_ERROR, ARRAY_ACCESS_OOB, CPU_COUNT_MISMATCH, KSTACK, USTACK, DW_USTACK_NO_DWARF, }; enum class PrintfSeverity { NONE, ERROR, WARNING, }; struct SourceLocation { std::string filename; int line; int column; std::string source_location; std::vector source_context; private: friend class cereal::access; template void serialize(Archive &archive) { archive(filename, line, column, source_location, source_context); } }; class SourceInfo { public: SourceInfo(const ast::Location &loc) { auto curr_loc = loc; while (curr_loc) { locations.emplace_back(curr_loc->filename(), curr_loc->line(), curr_loc->column(), curr_loc->source_location(), curr_loc->source_context()); auto &parent = curr_loc->parent; if (parent) { curr_loc = parent->loc; } else { break; } } } SourceInfo() = default; std::vector locations; private: friend class cereal::access; template void serialize(Archive &archive) { archive(locations); } }; class RuntimeErrorInfo : public SourceInfo { public: // This class effectively wraps a location, but preserves only the parts that // are needed to emit the error in a useful way. This is because it may be // serialized and used by a separate runtime. RuntimeErrorInfo(RuntimeErrorId error_id, bpf_func_id func_id, const ast::Location &loc) : SourceInfo(loc), error_id(error_id), func_id(func_id) { } RuntimeErrorInfo(RuntimeErrorId error_id, const ast::Location &loc) : RuntimeErrorInfo(error_id, __BPF_FUNC_MAX_ID, loc) {}; RuntimeErrorInfo() : error_id(RuntimeErrorId::HELPER_ERROR), func_id(__BPF_FUNC_MAX_ID) {}; RuntimeErrorId error_id; bpf_func_id func_id; private: friend class cereal::access; template void serialize(Archive &archive) { archive(error_id, func_id); } }; std::ostream &operator<<(std::ostream &os, const RuntimeErrorInfo &info); // This class contains script-specific metadata that bpftrace's runtime needs. // // This class is intended to completely encapsulate all of a script's runtime // needs such as maps, async printf argument metadata, etc. An instance of this // class plus the actual bpf bytecode should be all that's necessary to run a // script on another host. class RequiredResources { public: // `save_state()` serializes `RequiredResources` and writes results into // `out`. `load_state()` does the reverse: takes serialized data and loads it // into the current instance. // // NB: The serialized data is not versioned and is not forward/backwards // compatible. // // NB: both the output and input stream must be opened in binary // (std::ios::binary) mode to avoid binary data from being interpreted wrong void save_state(std::ostream &out) const; void load_state(std::istream &in); void load_state(const uint8_t *ptr, size_t len); // Async argument metadata // There is both a vector and a map of AST pointers to vector index. // We only need the latter for a later passes that want to accurately // access the id for a specific node so it can be passed into userspace // when the script is executing. std::vector< std::tuple, PrintfSeverity, SourceInfo>> printf_args; std::unordered_map printf_args_id_map; std::vector>> system_args; std::unordered_map system_args_id_map; // fmt strings for BPF helpers (bpf_seq_printf, bpf_trace_printk) std::vector bpf_print_fmts; std::unordered_map bpf_print_fmts_id_map; std::vector>> cat_args; std::unordered_map cat_args_id_map; std::vector join_args; std::unordered_map join_args_id_map; std::vector time_args; std::unordered_map time_args_id_map; std::vector strftime_args; std::unordered_map strftime_args_id_map; std::vector cgroup_path_args; std::unordered_map cgroup_path_args_id_map; std::vector non_map_print_args; std::unordered_map non_map_print_args_id_map; std::vector> skboutput_args_; std::unordered_map skboutput_args_id_map; // While max fmtstring args size is not used at runtime, the size // calculation requires taking into account struct alignment semantics, // and that is tricky enough that we want to minimize repetition of // such logic in the codebase. So keep it in resource analysis // rather than duplicating it in CodegenResources. uint64_t max_fmtstring_args_size = 0; // Required for sizing of tuple/record scratch buffer size_t anon_struct_buffers = 0; size_t max_anon_struct_size = 0; // Required for sizing of kstack and ustack scratch buffer size_t call_stack_buffers = 0; size_t max_call_stack_size = 0; // Required for sizing of string scratch buffer size_t str_buffers = 0; // Required for sizing of map value scratch buffers size_t read_map_value_buffers = 0; size_t max_read_map_value_size = 0; size_t max_write_map_value_size = 0; // Required for sizing of variable scratch buffers size_t variable_buffers = 0; size_t max_variable_size = 0; // Required for sizing of map key scratch buffers size_t map_key_buffers = 0; size_t max_map_key_size = 0; size_t join_value_size = 0; // Async argument metadata that codegen creates. Ideally ResourceAnalyser // pass should be collecting this, but it's complex to move the logic. // // Don't add more async arguments here!. std::unordered_map runtime_error_info; std::vector probe_ids; // Map metadata std::map maps_info; globalvars::GlobalVars global_vars; bool using_skboutput = false; bool needs_elapsed_map = false; // Probe metadata // // Probe metadata that codegen creates. Ideally ResourceAnalyser pass should // be collecting this, but it's complex to move the logic. std::vector probes; std::vector begin_probes; std::vector end_probes; std::vector test_probes; std::vector benchmark_probes; std::vector signal_probes; std::vector watchpoint_probes; size_t num_probes() const { return probes.size() + begin_probes.size() + end_probes.size() + test_probes.size() + benchmark_probes.size() + signal_probes.size() + watchpoint_probes.size(); } // List of probes using userspace symbol resolution std::unordered_set probes_using_usym; private: friend class cereal::access; template void serialize(Archive &archive) { archive(system_args, bpf_print_fmts, join_args, time_args, strftime_args, cat_args, non_map_print_args, runtime_error_info, printf_args, probe_ids, maps_info, global_vars, using_skboutput, probes, signal_probes, begin_probes, end_probes, test_probes, benchmark_probes); } }; } // namespace bpftrace bpftrace-0.27.1/src/run_bpftrace.cpp000066400000000000000000000174271526721631600173600ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include "log.h" #include "output/buffer_mode.h" #include "output/json.h" #include "output/text.h" #include "run_bpftrace.h" #include "symbols/kernel.h" #include "types_format.h" #include "version.h" using namespace bpftrace; static const char *libbpf_print_level_string(enum libbpf_print_level level) { switch (level) { case LIBBPF_WARN: return "WARN"; case LIBBPF_INFO: return "INFO"; default: return "DEBUG"; } } int libbpf_print(enum libbpf_print_level level, const char *msg, va_list ap) { if (!bt_debug.contains(DebugStage::Libbpf)) return 0; printf("[%s] ", libbpf_print_level_string(level)); return vprintf(msg, ap); } void check_privileges() { struct __user_cap_header_struct header = { .version = _LINUX_CAPABILITY_VERSION_3, .pid = getpid(), }; static_assert(_LINUX_CAPABILITY_U32S_3 == 2); struct __user_cap_data_struct data[_LINUX_CAPABILITY_U32S_3]; // There is no syscall wrapper for capget() in libc so we have // to use syscall() here. if (syscall(SYS_capget, &header, data) < 0) { LOG(ERROR) << "Failed to query process capabilities: " << strerror(errno); exit(1); } uint64_t effective = static_cast(data[0].effective) | (static_cast(data[1].effective) << 32); static const char *root_user_msg = "please run bpftrace as the root user."; // If we're not running as root, we need both CAP_DAC capabilities to be able // to read inside of /sys/fs/bpf which is mounted with mode 0700 by default. if (geteuid() != 0 && !(effective & (1ULL << CAP_DAC_READ_SEARCH))) { LOG(ERROR) << "Missing CAP_DAC_READ_SEARCH capability, " << root_user_msg; exit(1); } if (geteuid() != 0 && !(effective & (1ULL << CAP_DAC_OVERRIDE))) { LOG(ERROR) << "Missing CAP_DAC_OVERRIDE capability" << root_user_msg; exit(1); } // CAP_SYS_ADMIN covers both CAP_BPF and CAP_PERFMON for backwards compat. if (effective & (1ULL << CAP_SYS_ADMIN)) return; if (!(effective & (1ULL << CAP_BPF))) { LOG(ERROR) << "Missing CAP_BPF capability, " << root_user_msg; exit(1); } if (!(effective & (1ULL << CAP_PERFMON))) { LOG(ERROR) << "Missing CAP_PERFMON capability, " << root_user_msg; exit(1); } } // Simple forwarding streambuf that can flush on-demand. namespace { class flushing_streambuf : public std::streambuf { public: flushing_streambuf(std::streambuf *dest, OutputBufferConfig mode) : dest_(dest), mode_(mode) { } protected: int_type overflow(int_type ch) override { if (traits_type::eq_int_type(ch, traits_type::eof())) return dest_->sputc(ch); auto res = dest_->sputc(traits_type::to_char_type(ch)); if (mode_ == OutputBufferConfig::NONE || ((mode_ == OutputBufferConfig::UNSET || mode_ == OutputBufferConfig::LINE) && ch == '\n')) dest_->pubsync(); return res; } std::streamsize xsputn(const char *s, std::streamsize n) override { auto res = dest_->sputn(s, n); if (res > 0) { if (mode_ == OutputBufferConfig::NONE) { dest_->pubsync(); } else if (mode_ == OutputBufferConfig::UNSET || mode_ == OutputBufferConfig::LINE) { // Flush if any newline was written if (std::memchr(s, '\n', static_cast(res)) != nullptr) dest_->pubsync(); } } return res; } int sync() override { return dest_->pubsync(); } private: std::streambuf *dest_; OutputBufferConfig mode_; }; } // namespace int run_bpftrace(BPFtrace &bpftrace, const std::string &output_file, const std::string &output_format, const ast::CDefinitions &c_definitions, BpfBytecode &bytecode, std::vector &&named_params, OutputBufferConfig out_buf_config) { int err; auto k_version = symbols::kernel_version(symbols::KernelVersionMethod::UTS); auto min_k_version = static_cast( KERNEL_VERSION(MIN_KERNEL_VERSION_MAJOR, MIN_KERNEL_VERSION_MINOR, MIN_KERNEL_VERSION_PATCH)); if (k_version < min_k_version) { struct utsname utsname; uname(&utsname); LOG(WARNING) << "Kernel version (" << utsname.release << ") is lower than the minimum supported kernel version (" << MIN_KERNEL_VERSION_MAJOR << "." << MIN_KERNEL_VERSION_MINOR << "." << MIN_KERNEL_VERSION_PATCH << "). Some features/scripts may not work as expected."; } // Process all arguments. auto named_param_vals = bpftrace.resources.global_vars.get_named_param_vals( named_params); if (!named_param_vals) { auto ok = handleErrors(std::move(named_param_vals), [&](const globalvars::UnknownParamError &uo_err) { auto err = uo_err.err(); if (!err.empty()) { LOG(ERROR) << err; } auto hint = uo_err.hint(); if (!hint.empty()) { LOG(HINT) << hint; } }); if (!ok) { LOG(ERROR) << ok.takeError(); } return 1; } bytecode.update_global_vars(bpftrace, std::move(*named_param_vals)); // Create our output. std::ostream *os = &std::cout; std::ofstream outputstream; if (!output_file.empty()) { outputstream.open(output_file); if (outputstream.fail()) { LOG(ERROR) << "Failed to open output file: \"" << output_file << "\": " << strerror(errno); return 1; } os = &outputstream; } std::unique_ptr output; // Optionally wrap the output stream to control flushing behavior. // Keep these local so their lifetime covers the entire execution. std::optional fsb; std::optional wrapped_os; if (out_buf_config != OutputBufferConfig::FULL) { fsb.emplace(os->rdbuf(), out_buf_config); wrapped_os.emplace(&*fsb); os = &wrapped_os.value(); } if (output_format.empty() || output_format == "text") { // Note that there are two parameters here: we leave the err output as // std::cerr, so this can be seen while running. output = std::make_unique(*os); } else if (output_format == "json") { output = std::make_unique(*os); } else { LOG(ERROR) << "Invalid output format \"" << output_format << "\"\n" << "Valid formats: 'text', 'json'"; return 1; } // Signal handler that lets us know an exit signal was received. struct sigaction act = {}; act.sa_handler = [](int) { BPFtrace::exitsig_recv = true; }; sigaction(SIGINT, &act, nullptr); sigaction(SIGTERM, &act, nullptr); // Signal handler that prints all maps when SIGUSR1 was received. act.sa_handler = [](int) { BPFtrace::sigusr1_recv = true; }; sigaction(SIGUSR1, &act, nullptr); // Record the error code, but finish the actions below. err = bpftrace.run(*output, c_definitions, std::move(bytecode)); // We are now post-processing, remove our signal handler. act.sa_handler = SIG_DFL; sigaction(SIGINT, &act, nullptr); // Kill the child, if needed. if (bpftrace.child_) { if (auto val = bpftrace.child_->term_signal(); val.has_value()) LOG(V1) << "Child terminated by signal: " << *val; if (auto val = bpftrace.child_->exit_code(); val.has_value()) LOG(V1) << "Child exited with code: " << *val; } // See above; return any error. if (err) { return err; } return bpftrace.exit_code; } bpftrace-0.27.1/src/run_bpftrace.h000066400000000000000000000011511526721631600170100ustar00rootroot00000000000000#pragma once #include "bpftrace.h" #include "output/buffer_mode.h" int libbpf_print(enum libbpf_print_level level, const char *msg, va_list ap); void check_privileges(); int run_bpftrace(bpftrace::BPFtrace &bpftrace, const std::string &output_file, const std::string &output_format, const bpftrace::ast::CDefinitions &c_definitions, bpftrace::BpfBytecode &bytecode, std::vector &&named_params, bpftrace::OutputBufferConfig out_buf_config = bpftrace::OutputBufferConfig::UNSET); bpftrace-0.27.1/src/scopeguard.h000066400000000000000000000012601526721631600164730ustar00rootroot00000000000000#pragma once #include // Need two levels of indirection here for __LINE__ to correctly expand #define _CONCAT2(a, b) a##b #define _CONCAT(a, b) _CONCAT2(a, b) #define _ANON_VAR(str) _CONCAT(str, __LINE__) namespace bpftrace { enum class ScopeGuardExit {}; class ScopeGuard { public: explicit ScopeGuard(std::function fn) { fn_ = fn; } ~ScopeGuard() { if (fn_) { fn_(); } } private: std::function fn_; }; inline ScopeGuard operator+(ScopeGuardExit /*unused*/, std::function fn) { return ScopeGuard(fn); } } // namespace bpftrace #define SCOPE_EXIT auto _ANON_VAR(SCOPE_EXIT_STATE) = ScopeGuardExit() + [&]() bpftrace-0.27.1/src/stdlib/000077500000000000000000000000001526721631600154505ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/CMakeLists.txt000066400000000000000000000071621526721631600202160ustar00rootroot00000000000000include(Embed) # The standard library is effectively a bunch of embedded files. # # The data layout is standardized by `stdlib.h`, but we generate # stdlib.c which includes the relevant generated headers. # # * Basically, everything here that is `*.c`, `*.h` and `*.bt` goes # into the `stdlib` embedded directory. Structure is preserved. # * Everything that is in `include` goes into `include` and is # available by default to extensions. # * The `libbpf` header are embedded in `include` also. file(GLOB_RECURSE STDLIB_SOURCES "*.c" "*.h" "*.bt") file(GLOB_RECURSE PUBLIC_HEADERS "include/*.h") file(GLOB_RECURSE TEST_SCRIPTS "*_test.bt") file(GLOB_RECURSE BPF_HEADERS "${LIBBPF_INCLUDE_DIRS}/bpf/*.h") list(REMOVE_ITEM STDLIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/stdlib.h") list(REMOVE_ITEM STDLIB_SOURCES ${PUBLIC_HEADERS}) list(REMOVE_ITEM STDLIB_SOURCES ${TEST_SCRIPTS}) function(add_stdlib_source PREFIX FILENAME) # Generate our embedded header. get_filename_component(name "${FILENAME}" NAME) string(REPLACE "." "_" header_name "${name}") string(REPLACE "/" "_" rule_name "${PREFIX}/${header_name}") string(REPLACE "-" "_" rule_name "${rule_name}") embed( ${rule_name} ${FILENAME} OUTPUT ${PREFIX}/${header_name}.h VAR ${rule_name} ) # Add the file to the list of rules we need, and add the original # source file to the list of sources we need to depend on. list(APPEND STDLIB_TARGETS "${rule_name}") set(STDLIB_TARGETS "${STDLIB_TARGETS}" PARENT_SCOPE) # Set globals that are used to configure the template. set(STDLIB_INCLUDES "${STDLIB_INCLUDES} #include \"${PREFIX}/${header_name}.h\"" PARENT_SCOPE) get_filename_component(ext "${FILENAME}" EXT) if(ext STREQUAL ".bt") set(STDLIB_BT_FILES "${STDLIB_BT_FILES} { \"${PREFIX}/${name}\", make_view(${rule_name}, sizeof(${rule_name})) }," PARENT_SCOPE) else() set(STDLIB_C_FILES "${STDLIB_C_FILES} { \"${PREFIX}/${name}\", make_view(${rule_name}, sizeof(${rule_name})) }," PARENT_SCOPE) endif() endfunction() foreach(filename ${STDLIB_SOURCES}) string(REGEX REPLACE "^${CMAKE_CURRENT_SOURCE_DIR}/" "" suffix "${filename}") get_filename_component(prefix "stdlib/${suffix}" DIRECTORY) add_stdlib_source("${prefix}" "${filename}") endforeach() foreach(filename ${PUBLIC_HEADERS}) string(REGEX REPLACE "^${CMAKE_CURRENT_SOURCE_DIR}/include/" "" suffix "${filename}") get_filename_component(prefix "include/${suffix}" DIRECTORY) add_stdlib_source("${prefix}" "${filename}") endforeach() foreach(filename ${BPF_HEADERS}) string(REGEX REPLACE "^${LIBBPF_INCLUDE_DIRS}/" "" suffix "${filename}") get_filename_component(prefix "include/${suffix}" DIRECTORY) add_stdlib_source("${prefix}" "${filename}") endforeach() # Extract macro names from .bt files and build a macro-name-to-filename map. file(GLOB STDLIB_BT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.bt") set(STDLIB_MACROS "") set(SEEN_MACROS "") foreach(bt_file ${STDLIB_BT_SOURCES}) get_filename_component(bt_name "${bt_file}" NAME) file(READ "${bt_file}" bt_content) string(REGEX MATCHALL "(^|\n)[ \t]*macro [a-zA-Z_][a-zA-Z0-9_]*\\(" macro_matches "${bt_content}") foreach(match ${macro_matches}) string(REGEX REPLACE "(^|\n)[ \t]*macro ([a-zA-Z_][a-zA-Z0-9_]*)\\(" "\\2" macro_name "${match}") if(NOT "${macro_name}" IN_LIST SEEN_MACROS) list(APPEND SEEN_MACROS "${macro_name}") string(APPEND STDLIB_MACROS "\n { \"${macro_name}\", \"stdlib/${bt_name}\" },") endif() endforeach() endforeach() configure_file(stdlib.cpp.in stdlib.cpp) add_library(stdlib STATIC ${CMAKE_CURRENT_BINARY_DIR}/stdlib.cpp) add_dependencies(stdlib ${STDLIB_TARGETS}) bpftrace-0.27.1/src/stdlib/base.bpf.c000066400000000000000000000023351526721631600172770ustar00rootroot00000000000000#define __KERNEL__ #include #include #include // Kernel v7.0+ signature with ctx parameter. // The ___with_ctx suffix is stripped by libbpf, mapping to kernel symbol "bpf_session_is_return" extern _Bool bpf_session_is_return___with_ctx(void *ctx) __ksym __weak; // Kernel < v7.0 signature without ctx parameter. // The ___no_ctx suffix is stripped by libbpf, mapping to kernel symbol "bpf_session_is_return" extern _Bool bpf_session_is_return___no_ctx(void) __ksym __weak; // Try to limit the functions that get added in this file // as these will always be imported/compiled by every script // Always called with ctx. If the kernel exposes the newer ctx aware kfunc, // use it. otherwise fall back to the no arg variant. _Bool __session_is_return(void *ctx) { if (bpf_session_is_return___with_ctx) return bpf_session_is_return___with_ctx(ctx); if (bpf_session_is_return___no_ctx) return bpf_session_is_return___no_ctx(); return 0; } int __memcmp(const char * mem_left, const char * mem_right, size_t count) { for (size_t i = 0; i < count; ++i) { if (mem_left[i] != mem_right[i]) { return (int)mem_left[i] - (int)mem_right[i]; } } return 0; } bpftrace-0.27.1/src/stdlib/base.bt000066400000000000000000001415121526721631600167150ustar00rootroot00000000000000// :variant void assert(bool condition, string message) // Simple assertion macro that will exit the entire script with an error code if the condition is not met. macro assert(cond, msg) { if (!cond) { errorf("assert failed: %s", msg); exit(1); } } // :function bswap // :variant uint8 bswap(uint8 n) // :variant uint16 bswap(uint16 n) // :variant uint32 bswap(uint32 n) // :variant uint64 bswap(uint64 n) // // `bswap` reverses the order of the bytes in integer `n`. In case of 8 bit integers, `n` is returned without being modified. // The return type is an unsigned integer of the same width as `n`. // :function buf // :variant buffer buf(void * data, [int64 length]) // // `buf` reads `length` amount of bytes from address `data`. // The maximum value of `length` is limited to the `BPFTRACE_MAX_STRLEN` variable. // For arrays the `length` is optional, it is automatically inferred from the signature. // // `buf` is address space aware and will call the correct helper based on the address space associated with `data`. // // The `buffer` object returned by `buf` can safely be printed as a hex encoded string with the `%r` format specifier. // // Bytes with values >=32 and \<=126 are printed using their ASCII character, other bytes are printed in hex form (e.g. `\x00`). The `%rx` format specifier can be used to print everything in hex form, including ASCII characters. The similar `%rh` format specifier prints everything in hex form without `\x` and with spaces between bytes (e.g. `0a fe`). // // ``` // interval:s:1 { // printf("%r\n", buf(kaddr("avenrun"), 8)); // } // ``` // // ``` // \x00\x03\x00\x00\x00\x00\x00\x00 // \xc2\x02\x00\x00\x00\x00\x00\x00 // ``` // :function cat // :variant void cat(string namefmt, [...args]) // // **async** // // Dump the contents of the named file to stdout. // `cat` supports the same format string and arguments that `printf` does. // If the file cannot be opened or read an error is printed to stderr. // // ``` // tracepoint:syscalls:sys_enter_execve { // cat("/proc/%d/maps", pid); // } // ``` // // ``` // 55f683ebd000-55f683ec1000 r--p 00000000 08:01 1843399 /usr/bin/ls // 55f683ec1000-55f683ed6000 r-xp 00004000 08:01 1843399 /usr/bin/ls // 55f683ed6000-55f683edf000 r--p 00019000 08:01 1843399 /usr/bin/ls // 55f683edf000-55f683ee2000 rw-p 00021000 08:01 1843399 /usr/bin/ls // 55f683ee2000-55f683ee3000 rw-p 00000000 00:00 0 // ``` // :variant uint64 cgroup() // ID of the cgroup the current process belongs to // // Only works with cgroupv2 // // This utilizes the BPF helper `get_current_cgroup_id` macro cgroup() { import "stdlib/process/process.bpf.c"; __get_cgroup() } // :function cgroupid // :variant uint64 cgroupid(const string path) // // **compile time** // // `cgroupid` retrieves the cgroupv2 ID of the cgroup available at `path`. // // ``` // BEGIN { // print(cgroupid("/sys/fs/cgroup/system.slice")); // } // ``` // :function cgroup_path // :variant cgroup_path_t cgroup_path(int cgroupid, string filter) // // Convert cgroup id to cgroup path. // This is done asynchronously in userspace when the cgroup_path value is printed, // therefore it can resolve to a different value if the cgroup id gets reassigned. // This also means that the returned value can only be used for printing. // // A string literal may be passed as an optional second argument to filter cgroup // hierarchies in which the cgroup id is looked up by a wildcard expression (cgroup2 // is always represented by "unified", regardless of where it is mounted). // // The currently mounted hierarchy at /sys/fs/cgroup is used to do the lookup. If // the cgroup with the given id isn’t present here (e.g. when running in a Docker // container), the cgroup path won’t be found (unlike when looking up the cgroup // path of a process via /proc/.../cgroup). // // ``` // BEGIN { // $cgroup_path = cgroup_path(3436); // print($cgroup_path); // print($cgroup_path); /* This may print a different path */ // printf("%s %s", $cgroup_path, $cgroup_path); /* This may print two different paths */ // } // ``` // :function clear // :variant void clear(map m) // // **async** // // Clear all keys/values from map `m`. // // ``` // interval:ms:100 { // @[rand % 10] = count(); // } // // interval:s:10 { // print(@); // clear(@); // } // ``` // :variant Record config() // // Returns a `Record` containing the current `bpftrace` configuration settings. [List of config variables](./language.md#config-variables) // // ``` // printf("max_strlen: %d, stack_mode: %s\n", config.max_strlen, config.stack_mode); // } // ``` macro config() { __builtin_config } // :variant string comm() // :variant string comm(uint32 pid) // Name of the current thread or the process with the specified PID // // This utilizes the BPF helper `get_current_comm` macro comm() { __builtin_comm } macro comm($pid) { import "stdlib/task/task.bpf.c"; if comptime (!is_integer($pid)) { fail("Only integer supported for comm()'s pid"); } let $name : string[64]; if comptime kfunc_allowed("bpf_task_from_pid") { let $ret = __bpf_task_comm_from_pid((int32)$pid, &$name); // EOPNOTSUPP: Operation not supported if ($ret == ((int32)(-95))) { warnf( "'bpf_task_from_pid kfunc', which is used for getting the process comm, is not supported on your system." ); $name = "[unknown]"; // ESRCH: No such process } else if ($ret == ((int32)(-3))) { warnf("No such process (pid=%d)", $pid); $name = "N/A"; } } else { fail("Syntax comm(PID) is not supported in this probe type yet. Type: %s", probetype); } $name } macro comm(arg_pid) { let $pid = arg_pid; comm($pid) } // :variant bool has_cpid() // Returns true iff cpid is available. macro has_cpid() { __builtin_cpid == 0 } // :variant uint32 cpid() // Child process ID, if bpftrace is invoked with `-c`. // // If there is no child process, a runtime warning will be issued and the // return value will be zero. This warning can be avoided by using `has_cpid` // to check if `cpid` has a value, prior to referencing `cpid`. macro cpid() { let $cpid = __builtin_cpid; if (__builtin_cpid == 0) { warnf("No child command (`-c`); cpid is zero"); } $cpid } // :variant uint32 cpu() // ID of the processor executing the BPF program // // BPF program, in this case, is the probe body // // This utilizes the BPF helper `raw_smp_processor_id` macro cpu() { __builtin_cpu } // :variant uint64 curtask() // Pointer to `struct task_struct` of the current task // // This utilizes the BPF helper `get_current_task` macro curtask() { import "stdlib/process/process.bpf.c"; kptr((struct task_struct*)__get_current_task()) } // :variant bool delete(map m, mapkey k) // :deprecated_variant bool delete(mapkey k) // // Delete a single key from a map. // For scalar maps (e.g. no explicit keys), the key is omitted and is equivalent to calling `clear`. // For map keys that are composed of multiple values (e.g. `@mymap[3, "hello"] = 1` - remember these values are represented as a tuple) the syntax would be: `delete(@mymap, (3, "hello"));` // // If deletion fails (e.g. the key doesn’t exist) the function returns false (0). // Additionally, if the return value for `delete` is discarded, and deletion fails, you will get a warning. // // ``` // @a[1] = 1; // // delete(@a, 1); // no warning (the key exists) // // if (delete(@a, 2)) { // no warning (return value is used) // ... // } // // $did_delete = delete(@a, 2); // no warning (return value is used) // // delete(@a, 2); // warning (return value is discarded and the key doesn’t exist) // ``` // // The, now deprecated, API (supported in version <= 0.21.x) of passing map arguments with the key is still supported: // e.g. `delete(@mymap[3, "hello"]);`. // // ``` // kprobe:dummy { // @scalar = 1; // delete(@scalar); // ok // @single["hello"] = 1; // delete(@single, "hello"); // ok // @associative[1,2] = 1; // delete(@associative, (1,2)); // ok // delete(@associative); // error // delete(@associative, 1); // error // // // deprecated but ok // delete(@single["hello"]); // delete(@associative[1, 2]); // } // ``` macro delete(@map, $key) { import "stdlib/map/map.bpf.c"; check_key(@map, $key, "delete() with two arguments"); __delete((void*)(&@map), (void*)(&$key)) == 0 } macro delete(@map, key) { import "stdlib/map/map.bpf.c"; check_key(@map, key, "delete() with two arguments"); let $key : typeof(@map) = key; __delete((void*)(&@map), (void*)(&$key)) == 0 } macro delete(@map) { import "stdlib/map/map.bpf.c"; if comptime (!is_scalar(@map)) { fail( "call to delete() with a single argument expects a map without explicit keys (scalar map)" ); false } else { let $key : int64 = 0; __delete((void*)(&@map), (void*)(&$key)) == 0 } } macro delete(map_access) { // This supports the deprecated delete API, e.g. `delete(@a[1])` // which is handled in the map_sugar pass __deprecated_delete(map_access) } // :variant uint64 elapsed() // ktime_get_ns - ktime_get_boot_ns macro elapsed() { __builtin_elapsed } // :function errorf // :variant void errorf(const string fmt, args...) // // **async** // // `errorf()` formats and prints data (similar to [`printf`](#printf)) as an error message with the source location. // // ``` // BEGIN { errorf("Something bad with args: %d, %s", 10, "arg2"); } // ``` // // Prints: // // ``` // EXPECT stdin:1:9-62: ERROR: Something bad with args: 10, arg2 // ``` // :function exit // :variant void exit([int code]) // // **async** // // Terminate bpftrace, as if a `SIGTERM` was received. // The `END` probe will still trigger (if specified) and maps will be printed. // An optional exit code can be provided. // // ``` // BEGIN { // exit(); // } // ``` // // Or // // ``` // BEGIN { // exit(1); // } // ``` // :function fail // :variant void fail(const string fmt, args...) // // `fail()` formats and prints data (similar to [`printf`](#printf)) as an error message with the source location but, as opposed to [`errorf`](#errorf), is treated like a static assert and halts compilation if it is visited. All args have to be literals since they are evaluated at compile time. // // ``` // BEGIN { if ($1 < 2) { fail("Expected the first positional param to be greater than 1. Got %d", $1); } } // ``` // // :variant boolean find(map m, mapkey k, mapvalue result) // // Return `true` if the key exists in this map and sets the passed scratch variable (result) to the value of that map key. // Otherwise return `false` and don't mutate result. // Use this instead of `has_key` and a map access to avoid an additional map lookup. // Error if called with a map that has no keys (aka scalar map). // // ``` // kprobe:dummy { // @map[2] = (1, "hello"); // let $val; // if (find(@map, 2, $val)) { // print($val); // prints (1, "hello") // } // } // ``` macro find(@map, key, $var) { import "stdlib/map/map.bpf.c"; check_key(@map, key, "find"); let $key : typeof(@map) = key; $result = __lookup_elem((void*)(&@map), (void*)(&$key)); if ((bool)$result) { $var = *((typeof({ $a = @map[$key]; &$a }))$result); true } else { false } } // :variant ksym_t func() // :variant usym_t func() // Name of the current function being traced (kprobes,uprobes,fentry) macro func() { __builtin_func } // :function getopt // :variant bool getopt(string arg_name) // :variant bool getopt(string arg_name, bool default_value, [string description]) // :variant int getopt(string arg_name, int default_value, [string description]) // :variant string getopt(string arg_name, string default_value, [string description]) // // Get the named command line argument/option e.g. // ``` // # bpftrace -e 'BEGIN { print(getopt("hello", 1, "Description of hello")); }' -- --hello=5 // // ``` // // `getopt` defines the type of the argument by the default value’s type. // If no default type is provided, the option is treated like a boolean arg e.g. `getopt("hello")` would evaluate to `false` if `--hello` is not specified on the command line or `true` if `--hello` is passed or set to one of the following values: `true`, `1`. // Additionally, boolean args accept the following false values: `0`, `false` e.g. `--hello=false`. // If the arg is not set on the command line, the default value is used. // `getopt` calls may optionally specify a string with the argument description (except for a boolean arg without a default value). // // You can use `--help` to see all named arguments/options. // // ``` // # bpftrace -e 'BEGIN { print((getopt("aa", 10, "Description of aa"), getopt("bb", "hello"), getopt("cc"), getopt("dd", false))); }' -- --cc --bb=bye // // ``` // :variant uint64 gid() // Group ID of the current thread, as seen from the init namespace // // This utilizes the BPF helper `get_current_uid_gid` macro gid() { import "stdlib/process/process.bpf.c"; __get_current_uid_gid() >> 32 } // :variant boolean has_key(map m, mapkey k) // // Return `true` if the key exists in this map. // Otherwise return `false`. // Error if called with a map that has no keys (aka scalar map). // // ``` // kprobe:dummy { // @associative[1,2] = 1; // if (!has_key(@associative, (1,3))) { // ok // print(("bye")); // } // // @scalar = 1; // if (has_key(@scalar)) { // error // print(("hello")); // } // } // ``` macro has_key(@map, key) { import "stdlib/map/map.bpf.c"; check_key(@map, key, "has_key()"); let $key : typeof(@map) = key; (bool)__lookup_elem((void*)(&@map), (void*)(&$key)) } // :variant bool is_err(void * ptr) // Returns true if the pointer is an ERR_PTR, i.e. it encodes a kernel error code. // // In the Linux kernel, some functions return error codes encoded as pointers // using the `ERR_PTR` macro. These are pointer values in the range // `(unsigned long)(-4095)` to `(unsigned long)(-1)`. // // This is equivalent to the kernel's `IS_ERR()` macro. // // ``` // fexit:do_filp_open { // if (is_err(retval)) { // printf("error: %ld\n", (int64)retval); // } // } // ``` macro is_err(ptr) { ((int64)ptr) < 0 && ((int64)ptr) >= (-4095) } // :variant uint64 jiffies() // Jiffies of the kernel // // On 32-bit systems, using this builtin might be slower // // This utilizes the BPF helper `get_jiffies_64` macro jiffies() { import "stdlib/system/system.bpf.c"; __get_jiffies() } // :function join // :variant void join(char *arr[], [char * sep = ' ']) // // **async** // // `join` joins a char * `arr` with `sep` as separator into one string. // This string will be printed to stdout directly, it cannot be used as string value. // // The concatenation of the array members is done in BPF and the printing happens in userspace. // // ``` // tracepoint:syscalls:sys_enter_execve { // join(args.argv); // } // ``` // :function kaddr // :variant uint64 kaddr(const string name) // // **compile time** // // Get the address of the kernel symbol `name`. // // ``` // interval:s:1 { // $avenrun = kaddr("avenrun"); // $load1 = *$avenrun; // } // ``` // // You can find all kernel symbols at `/proc/kallsyms`. // :function kptr // :variant T * kptr(T * ptr) // // Marks `ptr` as a kernel address space pointer. // See the address-spaces section for more information on address-spaces. // The pointer type is left unchanged. // :function kstack // :variant kstack_t kstack([StackMode mode, ][int limit]) // // There are several [formatting/StackMode options](./language.md#stack_mode). // // ``` // kprobe:ip_output { @[kstack()] = count(); } // // /* // * Sample output: // * @[ // * ip_output+1 // * tcp_transmit_skb+1308 // * tcp_write_xmit+482 // * tcp_release_cb+225 // * release_sock+64 // * tcp_sendmsg+49 // * sock_sendmsg+48 // * sock_write_iter+135 // * __vfs_write+247 // * vfs_write+179 // * sys_write+82 // * entry_SYSCALL_64_fastpath+30 // * ]: 1708 // */ // ``` // // Sampling only three frames from the stack (limit = 3): // // ``` // kprobe:ip_output { @[kstack(3)] = count(); } // // /* // * Sample output: // * @[ // * ip_output+1 // * tcp_transmit_skb+1308 // * tcp_write_xmit+482 // * ]: 1708 // */ // ``` // // Note: If a limit is used and `show_debug_info` is enabled then the number of symbolized frames might exceed that limit in the output as `limit` refers to instruction pointers, which can translate to multiple inlined symbols. // // Example using `perf` StackMode: // // ``` // kprobe:ip_output { @[kstack(perf, 3)] = count(); } // // /* // * Sample output: // * @[ // * ffffffffb4019501 do_mmap+1 // * ffffffffb401700a sys_mmap_pgoff+266 // * ffffffffb3e334eb sys_mmap+27 // * ]: 1708 // */ // ``` // :function ksym // :variant ksym_t ksym(uint64 addr) // // **async** // // Retrieve the name of the function that contains address `addr`. // The address to name mapping happens in user-space. // // The `ksym_t` type can be printed with the `%s` format specifier. // // ``` // kprobe:do_nanosleep // { // printf("%s\n", ksym(reg("ip"))); // } // // /* // * Sample output: // * do_nanosleep // */ // ``` // :function len // :variant int64 len(map m) // :variant int64 len(ustack stack) // :variant int64 len(kstack stack) // // For maps, return the number of elements in the map. // // For kstack/ustack, return the depth (measured in # of frames) of the call stack. macro len(@map) { import "stdlib/map/map.bpf.c"; if comptime is_scalar(@map) { fail("call to len() expects a map with explicit keys (non-scalar map)") } else { __elem_count((void*)(&@map)) } } macro len(e) { if comptime (typeinfo(e).base_type != typeinfo(ustack).base_type && typeinfo(e).base_type != typeinfo(kstack).base_type) { fail("call to len() expects a map, ustack, or kstack") } else { // This is handled in codegen for now stack_len(e) } } // :function macaddr // :variant macaddr_t macaddr(char [6] mac) // // Create a buffer that holds a macaddress as read from `mac` // This buffer can be printed in the canonical string format using the `%s` format specifier. // // ``` // kprobe:arp_create { // $stack_arg0 = *(uint8*)(reg("sp") + 8); // $stack_arg1 = *(uint8*)(reg("sp") + 16); // printf("SRC %s, DST %s\n", macaddr($stack_arg0), macaddr($stack_arg1)); // } // // /* // * Sample output: // * SRC 18:C0:4D:08:2E:BB, DST 74:83:C2:7F:8C:FF // */ // ``` // :variant uint64 ncpus() // Number of CPUs macro ncpus() { __builtin_ncpus } // :function nsecs // :variant timestamp nsecs([TimestampMode mode]) // :variant timestamp nsecs // Returns a timestamp in nanoseconds, as given by the requested kernel clock. // Defaults to `boot` if no clock is explicitly requested. // // :variant nsecs(monotonic) - nanosecond timestamp since boot, exclusive of time the system spent suspended (CLOCK_MONOTONIC) // :variant nsecs(boot) - nanoseconds since boot, inclusive of time the system spent suspended (CLOCK_BOOTTIME) // :variant nsecs(tai) - TAI timestamp in nanoseconds (CLOCK_TAI) // :variant nsecs(sw_tai) - approximation of TAI timestamp in nanoseconds, is obtained through the "triple vdso sandwich" method. For older kernels without direct TAI timestamp access in BPF. // // ``` // interval:s:1 { // $sw_tai1 = nsecs(sw_tai); // $tai = nsecs(tai); // $sw_tai2 = nsecs(sw_tai); // printf("sw_tai precision: %lldns\n", ($sw_tai1 + $sw_tai2)/2 - $tai); // } // // /* // * Sample output: // * sw_tai precision: -98ns // * sw_tai precision: -99ns // * ... // */ // ``` // :function ntop // :variant inet ntop([int64 af, ] int addr) // :variant inet ntop([int64 af, ] char addr[4]) // :variant inet ntop([int64 af, ] char addr[16]) // // `ntop` returns the string representation of an IPv4 or IPv6 address. // `ntop` will infer the address type (IPv4 or IPv6) based on the `addr` type and size. // If an integer or `char[4]` is given, ntop assumes IPv4, if a `char[16]` is given, ntop assumes IPv6. // You can also pass the address type (e.g. AF_INET) explicitly as the first parameter. // :variant uint32 numaid() // ID of the NUMA node executing the BPF program // // BPF program, in this case, is the probe body // // This utilizes the BPF helper `numa_node_id` macro numaid() { import "stdlib/system/system.bpf.c"; (uint64)__get_numa_node_id() } // :function offsetof // :variant uint64 offsetof(STRUCT, FIELD[.SUBFIELD]) // :variant uint64 offsetof(EXPRESSION, FIELD[.SUBFIELD]) // // **compile time** // // Returns offset of the field offset bytes in struct. // Similar to kernel `offsetof` operator. // // Support any number of sub field levels, for example: // // ``` // struct Foo { // struct { // struct { // struct { // int d; // } c; // } b; // } a; // } // BEGIN { // @x = offsetof(struct Foo, a.b.c.d); // exit(); // } // ``` // :function override // :variant void override(uint64 rc) // // **unsafe** // // **Kernel** 4.16 // // This utilizes the BPF helper `bpf_override` // // **Supported probes** // // * kprobe // // When using `override` the probed function will not be executed and instead `rc` will be returned. // // ``` // kprobe:__x64_sys_getuid // /comm == "id"/ { // override(2<<21); // } // ``` // // ``` // uid=4194304 gid=0(root) euid=0(root) groups=0(root) // ``` // // This feature only works on kernels compiled with `CONFIG_BPF_KPROBE_OVERRIDE` and only works on functions tagged `ALLOW_ERROR_INJECTION`. // // bpftrace does not test whether error injection is allowed for the probed function, instead if will fail to load the program into the kernel: // // ``` // ioctl(PERF_EVENT_IOC_SET_BPF): Invalid argument // Error attaching probe: 'kprobe:vfs_read' // ``` macro override(expr) { import "stdlib/system/system.bpf.c"; if comptime (probetype != "kprobe") { fail("override() can only be used inside kprobes"); } else if comptime __builtin_safe_mode { fail("override() is unsafe. To use you need the --unsafe flag"); } else if comptime (typeinfo(expr).base_type != typeinfo(0).base_type) { fail("override() only supports int arguments (%s provided)", typeinfo(expr).base_type); } else { __override((void*)ctx, (uint64)expr); } } // :variant bool write_user(T * dst, T * src, uint32 len) // // **unsafe** // // Writes `len` bytes from BPF program memory at `src` to user-space address // `dst` using the BPF helper `bpf_probe_write_user`. // // Returns true on success, or false on failure. // // **Warning**: This can crash or corrupt the target process if used incorrectly. // Only use on user-space memory addresses belonging to the current task. // The kernel will print a warning to dmesg when this helper is used. // // ``` // tracepoint:syscalls:sys_enter_openat // /comm == "myapp"/ { // $new_path = "/tmp/redirected\0"; // if (write_user(args.filename, $new_path, 16)) { // printf("redirected open for pid %d\n", pid); // } // } // ``` macro write_user(dst, src, len) { import "stdlib/system/system.bpf.c"; if comptime __builtin_safe_mode { fail("write_user() is unsafe. To use you need the --unsafe flag"); } else { __probe_write_user((void*)dst, (void*)src, (uint32)len) == 0; } } // :function path // :variant char * path(struct path * path [, int32 size]) // // **Kernel** 5.10 // // This utilizes the BPF helper `bpf_d_path` // // Return full path referenced by struct path pointer in argument. If `size` is set, // the path will be clamped by `size` otherwise `BPFTRACE_MAX_STRLEN` is used. // // If `size` is smaller than the resolved path, the resulting string will be truncated at the front rather than at the end. // // This function can only be used by functions that are allowed to, these functions are contained in the `btf_allowlist_d_path` set in the kernel. // :function percpu_kaddr // :variant uint64 *percpu_kaddr(const string name) // :variant uint64 *percpu_kaddr(const string name, int cpu) // // **sync** // // Get the address of the percpu kernel symbol `name` for CPU `cpu`. When `cpu` is // omitted, the current CPU is used. // // ``` // interval:s:1 { // $proc_cnt = percpu_kaddr("process_counts"); // printf("% processes are running on CPU %d\n", *$proc_cnt, cpu); // } // ``` // // The second variant may return NULL if `cpu` is higher than the number of // available CPUs. Therefore, it is necessary to perform a NULL-check on the result // when accessing fields of the pointed structure, otherwise the BPF program will // be rejected. // // ``` // interval:s:1 { // $runqueues = (struct rq *)percpu_kaddr("runqueues", 0); // if ($runqueues != 0) { // The check is mandatory here // print($runqueues.nr_running); // } // } // ``` // :function pid // :variant uint32 pid([curr_ns|init]) // :variant uint32 pid // // Returns the process ID of the current thread. // Defaults to `curr_ns`. // // * `pid(curr_ns)` - The process ID as seen from the PID namespace of bpftrace. // * `pid(init)` - The process ID as seen from the initial PID namespace. // :variant uint32 ppid() // :variant uint32 ppid(struct task_struct * task) // // Get the pid of the parent process for the passed task or the current task if called without arguments. // This is an alias for `task.real_parent.pid`, which is different than `task.group_leader.pid`, which you can get from calling `leader_tid()`. macro ppid(task) { task.real_parent.pid } macro ppid() { ppid(curtask) } // :variant string leader_tid() // :variant string leader_tid(struct task_struct * task) // // Get the thread id of the thread group leader for the passed task or the current task if called without arguments. // This is an alias for `task.group_leader.pid`, which is different than `task.real_parent.pid`, which you can get from calling `ppid()`. // See `ppid()` for more details. macro leader_tid(task) { task.group_leader.pid } macro leader_tid() { leader_tid(curtask) } // :variant string pcomm() // :variant string pcomm(struct task_struct * task) // // Get the name of the parent process for the passed task or the current task if called without arguments. // This is an alias for `task.real_parent.comm`, which is different than `task.group_leader.comm`, which you can get from calling `leader_comm()`. macro pcomm(task) { task.real_parent.comm } macro pcomm() { pcomm(curtask) } // :variant string leader_comm() // :variant string leader_comm(struct task_struct * task) // // Get the thread name of the thread group leader for the passed task or the current task if called without arguments. // This is an alias for `task.group_leader.comm`, which is different than `task.real_parent.comm`, which you can get from calling `pcomm()`. // See `pcomm()` for more details. macro leader_comm(task) { task.group_leader.comm } macro leader_comm() { leader_comm(curtask) } // :function print // :variant void print(T val) // // **async** // :variant void print(T val) // :variant void print(@map) // :variant void print(@map, uint64 top) // :variant void print(@map, uint64 top, uint64 div) // // `print` prints a the value, which can be a map or a scalar value, with the default formatting for the type. // // ``` // interval:s:1 { // print(123); // print("abc"); // exit(); // } // // /* // * Sample output: // * 123 // * abc // */ // ``` // // ``` // interval:ms:10 { @=hist(rand); } // interval:s:1 { // print(@); // exit(); // } // ``` // // Prints: // // ``` // @: // [16M, 32M) 3 |@@@ | // [32M, 64M) 2 |@@ | // [64M, 128M) 1 |@ | // [128M, 256M) 4 |@@@@ | // [256M, 512M) 3 |@@@ | // [512M, 1G) 14 |@@@@@@@@@@@@@@ | // [1G, 2G) 22 |@@@@@@@@@@@@@@@@@@@@@@ | // [2G, 4G) 51 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // ``` // // Declared maps and histograms are automatically printed out on program termination. // // Note that maps are printed by reference while scalar values are copied. // This means that updating and printing maps in a fast loop will likely result in bogus map values as the map will be updated before userspace gets the time to dump and print it. // // The printing of maps supports the optional `top` and `div` arguments. // `top` limits the printing to the top N entries with the highest integer values // // ``` // BEGIN { // $i = 11; // for $elem : 1..$i { // @[$elem] = $elem-1; // } // print(@, 2); // clear(@); // exit() // } // // /* // * Sample output: // * @[9]: 8 // * @[10]: 9 // */ // ``` // // The `div` argument scales the values prior to printing them. // Scaling values before storing them can result in rounding errors. // Consider the following program: // // ``` // kprobe:f { // @[func] += arg0/10; // } // ``` // // With the following sequence as numbers for arg0: `134, 377, 111, 99`. // The total is `721` which rounds to `72` when scaled by 10 but the program would print `70` due to the rounding of individual values. // // Changing the print call to `print(@, 5, 2)` will take the top 5 values and scale them by 2: // // ``` // @[6]: 3 // @[7]: 3 // @[8]: 4 // @[9]: 4 // @[10]: 5 // ``` // :function printf // :variant void printf(const string fmt, args...) // // **async** // // `printf()` formats and prints data. // It behaves similar to `printf()` found in `C` and many other languages. // // The format string has to be a constant, it cannot be modified at runtime. // The formatting of the string happens in user space. // Values are copied and passed by value. // // bpftrace supports all the typical format specifiers like `%llx` and `%hhu`. // The non-standard ones can be found in the table below: // // | Specifier | Type | Format | Description | // | --- | --- | --- | --- | // | r | buffer | normal hex | Hex-formatted string to print arbitrary binary content returned by the [buf](#buf) function. | // | rh | buffer | formatted hex | Prints in hex-formatted string without `\x` and with spaces between bytes (e.g. `0a fe`) | // | rx | buffer | escaped hex | Prints in hex-formatted string with `\x` without spaces between bytes (e.g. `\x0a\xfe`) | // | gr | integer | human readable | Formats GFP (Get Free Pages) flags into human-readable strings, similar to Linux kernel's `%pGg` format. | // // `printf()` can also symbolize enums as strings. User defined enums as well as enums // defined in the kernel are supported. For example: // // ``` // enum custom { // CUSTOM_ENUM = 3, // }; // // BEGIN { // $r = SKB_DROP_REASON_SOCKET_FILTER; // printf("%d, %s, %s\n", $r, $r, CUSTOM_ENUM); // exit(); // } // ``` // // yields: // // ``` // 6, SKB_DROP_REASON_SOCKET_FILTER, CUSTOM_ENUM // ``` // // The `%gr` specifier can be used to format GFP (Get Free Pages) flags into human-readable strings: // // ``` // tracepoint:kmem:kmalloc { // printf("GFP flags: %gr\n", args->gfp_flags); // } // ``` // // This would output something like: // // ``` // GFP flags: GFP_KERNEL // GFP flags: GFP_ATOMIC|__GFP_HIGHMEM // GFP flags: __GFP_IO|__GFP_FS|__GFP_DIRECT_RECLAIM // ``` // // Colors are supported too, using standard terminal escape sequences: // // ``` // print("\033[31mRed\t\033[33mYellow\033[0m\n") // ``` // :variant string probe() // Name of the fully expanded probe // // For example: `kprobe:do_nanosleep` macro probe() { __builtin_probe } // :variant string probetype() // Name of the probe type. // Note: `begin` and `end` probes are of type `special`. // // For example: `kprobe`, `special`, `tracepoint` macro probetype() { __builtin_probetype } // :function pton // :variant char addr[4] pton(const string *addr_v4) // :variant char addr[16] pton(const string *addr_v6) // // **compile time** // // `pton` converts a text representation of an IPv4 or IPv6 address to byte array. // `pton` infers the address family based on `.` or `:` in the given argument. // `pton` comes in handy when we need to select packets with certain IP addresses. // // When casting the result of `pton()` to an integer (e.g. `(uint32)pton("127.0.0.1")`), the resulting value depends on the system's endianness. The byte array returned by `pton()` is stored in network byte order (big-endian), and when cast to an integer, it is interpreted according to the system's native byte order: // **Little-endian systems**: The bytes are reversed when interpreted as an integer. For example, `(uint32)pton("127.0.0.1")` yields `0x100007f` (bytes: `[0x7f, 0x00, 0x00, 0x01]` interpreted as little-endian). // **Big-endian systems**: The bytes maintain their network byte order. For example, `(uint32)pton("127.0.0.1")` yields `0x7f000001` (bytes: `[0x7f, 0x00, 0x00, 0x01]` interpreted as big-endian). // This behavior is consistent with how the underlying `inet_pton()` function works. // :variant uint32 rand() // Get a pseudo random number // // This utilizes the BPF helper `get_prandom_u32` macro rand() { import "stdlib/system/system.bpf.c"; __get_rand() } // :function reg // :variant uint64 reg(const string name) // // **Supported probes** // // * kprobe // * uprobe // // Get the contents of the register identified by `name`. // Valid names depend on the CPU architecture. // :variant uint64 retval() // Value returned by the function being traced // // (kretprobe, uretprobe, fexit) // For kretprobe and uretprobe, its type is uint64, but for fexit it depends. You can look up the type using `bpftrace -lv` macro retval() { __builtin_retval } // :variant void signal(const string sig) // :variant void signal(uint32 signum) // // **unsafe** // // This utilizes the BPF helper `bpf_send_signal`. // // Probe types: k(ret)probe, u(ret)probe, USDT, profile // // Send a signal to the process being traced (any thread). // Use `signal_thread` to send to the thread being traced. // The signal can either be identified by name, e.g. `SIGSTOP` or by ID, e.g. `19` as found in `kill -l`. // // ``` // kprobe:__x64_sys_execve // /comm == "bash"/ { // signal(5); // } // ``` // ``` // $ ls // Trace/breakpoint trap (core dumped) // ``` macro signal(expr) { __signal(expr, false); } // :variant void signal_thread(const string sig) // :variant void signal_thread(uint32 signum) // // **unsafe** // // This utilizes the BPF helper `bpf_send_signal_thread`. // // Probe types: k(ret)probe, u(ret)probe, USDT, profile // // Send a signal to the thread being traced. // Use `signal` to send to the process being traced (any thread). // The signal can either be identified by name, e.g. `SIGSTOP` or by ID, e.g. `19` as found in `kill -l`. macro signal_thread(expr) { __signal(expr, true); } // :function sizeof // :variant uint64 sizeof(TYPE) // :variant uint64 sizeof(EXPRESSION) // // **compile time** // // Returns size of the argument in bytes. // Similar to C/C++ `sizeof` operator. // Note that the expression does not get evaluated. // :function skboutput // :variant uint32 skboutput(const string path, struct sk_buff *skb, uint64 length, const uint64 offset) // // **Kernel** 5.5 // // This utilizes the BPF helper `bpf_skb_output` // // Write sk_buff `skb` 's data section to a PCAP file in the `path`, starting from `offset` to `offset` + `length`. // // The PCAP file is encapsulated in RAW IP, so no ethernet header is included. // The `data` section in the struct `skb` may contain ethernet header in some kernel contexts, you may set `offset` to 14 bytes to exclude ethernet header. // // Each packet’s timestamp is determined by adding `nsecs` and boot time, the accuracy varies on different kernels, see `nsecs`. // // This function returns 0 on success, or a negative error in case of failure. // // Environment variable `BPFTRACE_PERF_RB_PAGES` should be increased in order to capture large packets, or else these packets will be dropped. // // Usage // // ``` // # cat dump.bt // fentry:napi_gro_receive { // $ret = skboutput("receive.pcap", args.skb, args.skb.len, 0); // } // // fentry:dev_queue_xmit { // // setting offset to 14, to exclude ethernet header // $ret = skboutput("output.pcap", args.skb, args.skb.len, 14); // printf("skboutput returns %d\n", $ret); // } // // # export BPFTRACE_PERF_RB_PAGES=1024 // # bpftrace dump.bt // ... // // # tcpdump -n -r ./receive.pcap | head -3 // reading from file ./receive.pcap, link-type RAW (Raw IP) // dropped privs to tcpdump // 10:23:44.674087 IP 22.128.74.231.63175 > 192.168.0.23.22: Flags [.], ack 3513221061, win 14009, options [nop,nop,TS val 721277750 ecr 3115333619], length 0 // 10:23:45.823194 IP 100.101.2.146.53 > 192.168.0.23.46619: 17273 0/1/0 (130) // 10:23:45.823229 IP 100.101.2.146.53 > 192.168.0.23.46158: 45799 1/0/0 A 100.100.45.106 (60) // ``` // :function socket_cookie // :variant uint64 socket_cookie(struct sock *sk) // // This utilizes the BPF helper `bpf_get_socket_cookie` // // Retrieve the cookie (generated by the kernel) of the socket. // If no cookie has been set yet, generate a new cookie. Once generated, the socket cookie remains stable for the life of the socket. // // This function returns a `uint64` unique number on success, or 0 if **sk** is NULL. // // ``` // fentry:tcp_rcv_established // { // $cookie = socket_cookie(args.sk); // @psize[$cookie] = hist(args.skb.len); // } // ``` // // Prints: // // ``` // @psize[65551]: // [32, 64) 4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // // @psize[504]: // [32, 64) 4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // [64, 128) 1 |@@@@@@@@@@@@@ | // [128, 256) 0 | | // [256, 512) 1 |@@@@@@@@@@@@@ | // [512, 1K) 0 | | // [1K, 2K) 0 | | // [2K, 4K) 1 |@@@@@@@@@@@@@ | // ``` // :function str // :variant string str(char * data [, uint32 length) // // This utilizes the BPF helpers `probe_read_str, probe_read_{kernel,user}_str` // // `str` reads a NULL terminated (`\0`) string from `data`. // The maximum string length is limited by the `BPFTRACE_MAX_STRLEN` env variable, unless `length` is specified and shorter than the maximum. // In case the string is longer than the specified length only `length - 1` bytes are copied and a NULL byte is appended at the end. // // bpftrace will automatically use the `kernel` or `user` variant of `probe_read_{kernel,user}_str` based on the address space of `data`, see [Address-spaces](./language.md#address-spaces) for more information. // :function strftime // :variant timestamp strftime(const string fmt, uint64 timestamp_ns) // // **async** // // Format the nanoseconds since boot timestamp `timestamp_ns` according to the format specified by `fmt`. // The time conversion and formatting happens in user space, therefore the `timestamp` value returned can only be used for printing using the `%s` format specifier. // **Note:** `timestamp_ns` must be non-negative. Negative timestamp literals are rejected. // // bpftrace uses the `strftime(3)` function for formatting time and supports the same format specifiers. // // ``` // interval:s:1 { // printf("%s\n", strftime("%H:%M:%S", nsecs)); // } // ``` // // bpftrace also supports the following format string extensions: // // | Specifier | Description | // | --- | --- | // | `%f` | Microsecond as a decimal number, zero-padded on the left | // :function strncmp // :variant int64 strncmp(char * s1, char * s2, int64 n) // // `strncmp` compares up to `n` characters string `s1` and string `s2`. // If they’re equal `0` is returned, else a non-zero value is returned. // // bpftrace doesn’t read past the length of the shortest string. // // The use of the `==` and `!=` operators is recommended over calling `strncmp` directly. // :function system // :variant void system(string namefmt [, ...args]) // // **unsafe** // **async** // // `system` lets bpftrace run the specified command (`fork` and `exec`) until it completes and print its stdout. // The `command` is run with the same privileges as bpftrace and it blocks execution of the processing threads which can lead to missed events and delays processing of async events. // // ``` // interval:s:1 { // time("%H:%M:%S: "); // printf("%d\n", @++); // } // interval:s:10 { // system("/bin/sleep 10"); // } // interval:s:30 { // exit(); // } // ``` // // Note how the async `time` and `printf` first print every second until the `interval:s:10` probe hits, then they print every 10 seconds due to bpftrace blocking on `sleep`. // // ``` // Attached 3 probes // 08:50:37: 0 // 08:50:38: 1 // 08:50:39: 2 // 08:50:40: 3 // 08:50:41: 4 // 08:50:42: 5 // 08:50:43: 6 // 08:50:44: 7 // 08:50:45: 8 // 08:50:46: 9 // 08:50:56: 10 // 08:50:56: 11 // 08:50:56: 12 // 08:50:56: 13 // 08:50:56: 14 // 08:50:56: 15 // 08:50:56: 16 // 08:50:56: 17 // 08:50:56: 18 // 08:50:56: 19 // ``` // // `system` supports the same format string and arguments that `printf` does. // // ``` // tracepoint:syscalls:sys_enter_execve { // system("/bin/grep %s /proc/%d/status", "vmswap", pid); // } // ``` // :function tid // :variant uint32 tid([curr_ns|init]) // :variant uint32 tid // // Returns the thread ID of the current thread. // Defaults to `curr_ns`. // // * `tid(curr_ns)` - The thread ID as seen from the PID namespace of bpftrace. // * `tid(init)` - The thread ID as seen from the initial PID namespace. // :function time // :variant void time(const string fmt) // // **async** // // Format the current wall time according to the format specifier `fmt` and print it to stdout. // Unlike `strftime()` `time()` doesn’t send a timestamp from the probe, instead it is the time at which user-space processes the event. // // bpftrace uses the `strftime(3)` function for formatting time and supports the same format specifiers. // :function typeof // :variant TYPE typeof(TYPE) // :variant TYPE typeof(EXPRESSION) // // This is a special builtin that can only be used in the following contexts: // - variable declarations e.g. `let $a: typeof($b);` // - cast expressions e.g. `$a = (typeof($b))2;` // - macro expansion calls to pass a type parameter e.g. `my_macro(typeof(uint64 *));` // - type accepting builtins: `sizeof`, `offsetof`, `typeinfo` // // This builtin evaluates to the static type of either the parsed TYPE or the raw EXPRESSION parameter. // :variant T * uaddr(const string sym) // // **Supported probes** // // * uprobes // * uretprobes // * USDT // // If kernel supports task_vma open-coded iterator kfuncs (linux >= 6.7), uaddr() will correct the symbol addresses of PIE and dynamic libraries instead of directly using the symbol addresses in the ELF file, see https://github.com/torvalds/linux/commit/4ac454682158. // // The `uaddr` function returns the address of the specified symbol. // This lookup happens during program compilation and cannot be used dynamically. // // The default return type is `uint64*`. // If the ELF object size matches a known integer size (1, 2, 4 or 8 bytes) the return type is modified to match the width (`uint8*`, `uint16*`, `uint32*` or `uint64*` resp.). // As ELF does not contain type info the type is always assumed to be unsigned. // // ``` // uprobe:/bin/bash:readline { // printf("PS1: %s\n", str(*uaddr("ps1_prompt"))); // } // ``` macro uaddr(sym) { import "stdlib/task/vma.bpf.c"; let $addr = __builtin_uaddr(sym); // There are three types of ELF that use uprobe: PIE, EXEC, and dynamic // libraries. Among them, PIE and dynamic libraries need to correct the // symbol address according to the actual load address. if comptime (!elf_is_exe) { $offset = __bpf_task_map_file_min_addr((uint64)elf_info); // Recast to the original pointer type to preserve dereference size. $addr = (typeof($addr))((uint64)$addr + $offset); } $addr } // :variant uint64 uid() // User ID of the current thread, as seen from the init namespace // // This utilizes the BPF helper `get_current_uid_gid` macro uid() { import "stdlib/process/process.bpf.c"; __get_current_uid_gid() & 0xffffffff } // :function uptr // :variant T * uptr(T * ptr) // // Marks `ptr` as a user address space pointer. // See the address-spaces section for more information on address-spaces. // The pointer type is left unchanged. // :variant uint8 usermode() // Returns 1 if the current process is in user mode, 0 otherwise // // Currently only available on x86_64. macro usermode() { __builtin_usermode } // :variant string username() // Get the current username // // Often this is just "root" macro username() { (username_t)uid } // :function ustack // :variant ustack_t ustack([StackMode mode, ][int limit]) // // There are several [formatting/StackMode options](./language.md#stack_mode). // // ``` // kprobe:do_sys_open /comm == "bash"/ { @[ustack()] = count(); } // // /* // * Sample output: // * @[ // * __open_nocancel+65 // * command_word_completion_function+3604 // * rl_completion_matches+370 // * bash_default_completion+540 // * attempt_shell_completion+2092 // * gen_completion_matches+82 // * rl_complete_internal+288 // * rl_complete+145 // * _rl_dispatch_subseq+647 // * _rl_dispatch+44 // * readline_internal_char+479 // * readline_internal_charloop+22 // * readline_internal+23 // * readline+91 // * yy_readline_get+152 // * yy_readline_get+429 // * yy_getc+13 // * shell_getc+469 // * read_token+251 // * yylex+192 // * yyparse+777 // * parse_command+126 // * read_command+207 // * reader_loop+391 // * main+2409 // * __libc_start_main+231 // * 0x61ce258d4c544155 // * ]: 9 // */ // ``` // // Sampling only three frames from the stack (limit = 3): // // ``` // kprobe:ip_output { @[ustack(3)] = count(); } // // /* // * Sample output: // * @[ // * __open_nocancel+65 // * command_word_completion_function+3604 // * rl_completion_matches+370 // * ]: 20 // */ // ``` // // Note: If a limit is used and `show_debug_info` is enabled then the number of symbolized frames might exceed that limit in the output as `limit` refers to instruction pointers, which can translate to multiple inlined symbols. // // Example using `perf` StackMode: // // ``` // kprobe:ip_output { @[ustack(perf, 3)] = count(); } // // /* // * Sample output: // * @[ // * 5649feec4090 readline+0 (/home/mmarchini/bash/bash/bash) // * 5649fee2bfa6 yy_readline_get+451 (/home/mmarchini/bash/bash/bash) // * 5649fee2bdc6 yy_getc+13 (/home/mmarchini/bash/bash/bash) // * ]: 20 // */ // ``` // // Note that for these examples to work, bash had to be recompiled with frame pointers. // :function dw_ustack // :variant ustack_t dw_ustack([StackMode mode, ][int limit]) // // DWARF-based user-space stack unwinding. Unlike [ustack](#ustack), which // relies on frame pointers, `dw_ustack` uses DWARF `.eh_frame` debug // information to unwind the stack. This makes it possible to collect complete // user-space stack traces from programs compiled without frame pointers. // // The signature and output format are the same as `ustack`. // // Bpftrace needs to read the DWARF information for the target processes at startup. // For this, one or more pids have to be specified. This can either be done via // `-p`, `-c` (implicitly) or `--dwarf-pid`. If `dw_ustack` cannot find unwind // information for a process, a runtime warning is emitted. // // `dw_ustack` is currently only available on x86_64. // // **Unstable feature** // // `dw_ustack` is an unstable feature. By default a warning is printed when it // is used. Set the config flag to suppress the warning or to make it an error: // // ``` // config = { unstable_dw_ustack=enable } // ``` // // For usage examples see [ustack](#ustack). macro dw_ustack(mode, limit) { import "stdlib/stack/dwunwind.bpf.c"; __builtin_dw_ustack(mode, limit) } macro dw_ustack(mode) { import "stdlib/stack/dwunwind.bpf.c"; __builtin_dw_ustack(mode) } macro dw_ustack() { import "stdlib/stack/dwunwind.bpf.c"; __builtin_dw_ustack } // :function usym // :variant usym_t usym(uint64 * addr) // // **async** // // **Supported probes** // // * uprobes // * uretprobes // // Equal to [ksym](#ksym) but resolves user space symbols. // // If ASLR is enabled, user space symbolication only works when the process is running at either the time of the symbol resolution or the time of the probe attachment. The latter requires `BPFTRACE_CACHE_USER_SYMBOLS` to be set to `PER_PID`, and might not work with older versions of BCC. A similar limitation also applies to dynamically loaded symbols. // // ``` // uprobe:/bin/bash:readline // { // printf("%s\n", usym(reg("ip"))); // } // // /* // * Sample output: // * readline // */ // ``` // :function unwatch // :variant void unwatch(void * addr) // // **async** // // Removes a watchpoint // :function zero // :variant void zero(map m) // // **async** // // Set all values (for all keys) in the map to zero. // :function warnf // :variant void warnf(const string fmt, args...) // // **async** // // `warnf()` formats and prints data (similar to [`printf`](#printf)) as an warning message with the source location. This respects the "--no-warnings" flag and will be silent if that is used. // // ``` // BEGIN { warnf("Something kinda bad with args: %d, %s", 10, "arg2"); } // ``` // // Prints: // // ``` // EXPECT stdin:1:9-62: WARNING: Something kinda bad with args: 10, arg2 // ``` bpftrace-0.27.1/src/stdlib/include/000077500000000000000000000000001526721631600170735ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/.clang-format000066400000000000000000000000501526721631600214410ustar00rootroot00000000000000DisableFormat: true SortIncludes: Never bpftrace-0.27.1/src/stdlib/include/__stddef_max_align_t.h000066400000000000000000000033521526721631600233600ustar00rootroot00000000000000/*===---- __stddef_max_align_t.h - Definition of max_align_t for modules ---=== * * Copyright (c) 2014 Chandler Carruth * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * *===-----------------------------------------------------------------------=== */ #ifndef __CLANG_MAX_ALIGN_T_DEFINED #define __CLANG_MAX_ALIGN_T_DEFINED #if defined(_MSC_VER) typedef double max_align_t; #elif defined(__APPLE__) typedef long double max_align_t; #else // Define 'max_align_t' to match the GCC definition. typedef struct { long long __clang_max_align_nonce1 __attribute__((__aligned__(__alignof__(long long)))); long double __clang_max_align_nonce2 __attribute__((__aligned__(__alignof__(long double)))); } max_align_t; #endif #endif bpftrace-0.27.1/src/stdlib/include/asm-generic/000077500000000000000000000000001526721631600212655ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm-generic/bitsperlong.h000066400000000000000000000021231526721631600237640ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG #define _UAPI__ASM_GENERIC_BITS_PER_LONG #ifndef __BITS_PER_LONG /* * In order to keep safe and avoid regression, only unify uapi * bitsperlong.h for some archs which are using newer toolchains * that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__. * See the following link for more info: * https://lore.kernel.org/linux-arch/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/ */ #if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__) #define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__) #else /* * There seems to be no way of detecting this automatically from user * space, so 64 bit architectures should override this in their * bitsperlong.h. In particular, an architecture that supports * both 32 and 64 bit user space must not rely on CONFIG_64BIT * to decide it, but rather check a compiler provided macro. */ #define __BITS_PER_LONG 32 #endif #endif #ifndef __BITS_PER_LONG_LONG #define __BITS_PER_LONG_LONG 64 #endif #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */ bpftrace-0.27.1/src/stdlib/include/asm-generic/errno-base.h000066400000000000000000000031141526721631600234720ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_BASE_H #define _ASM_GENERIC_ERRNO_BASE_H #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Argument list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */ #endif bpftrace-0.27.1/src/stdlib/include/asm-generic/errno.h000066400000000000000000000130201526721631600225570ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm-generic/fcntl.h000066400000000000000000000126731526721631600225550ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_FCNTL_H #define _ASM_GENERIC_FCNTL_H #include /* * FMODE_EXEC is 0x20 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris */ /* * When introducing new O_* bits, please check its uniqueness in fcntl_init(). */ #define O_ACCMODE 00000003 #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 #ifndef O_CREAT #define O_CREAT 00000100 /* not fcntl */ #endif #ifndef O_EXCL #define O_EXCL 00000200 /* not fcntl */ #endif #ifndef O_NOCTTY #define O_NOCTTY 00000400 /* not fcntl */ #endif #ifndef O_TRUNC #define O_TRUNC 00001000 /* not fcntl */ #endif #ifndef O_APPEND #define O_APPEND 00002000 #endif #ifndef O_NONBLOCK #define O_NONBLOCK 00004000 #endif #ifndef O_DSYNC #define O_DSYNC 00010000 /* used to be O_SYNC, see below */ #endif #ifndef FASYNC #define FASYNC 00020000 /* fcntl, for BSD compatibility */ #endif #ifndef O_DIRECT #define O_DIRECT 00040000 /* direct disk access hint */ #endif #ifndef O_LARGEFILE #define O_LARGEFILE 00100000 #endif #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 /* must be a directory */ #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 00400000 /* don't follow links */ #endif #ifndef O_NOATIME #define O_NOATIME 01000000 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #ifndef O_SYNC #define __O_SYNC 04000000 #define O_SYNC (__O_SYNC|O_DSYNC) #endif #ifndef O_PATH #define O_PATH 010000000 #endif #ifndef __O_TMPFILE #define __O_TMPFILE 020000000 #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ #define F_SETFD 2 /* set/clear close_on_exec */ #define F_GETFL 3 /* get file->f_flags */ #define F_SETFL 4 /* set file->f_flags */ #ifndef F_GETLK #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 #endif #ifndef F_SETOWN #define F_SETOWN 8 /* for sockets. */ #define F_GETOWN 9 /* for sockets. */ #endif #ifndef F_SETSIG #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ #endif #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #ifndef F_GETLK64 #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 #endif #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #ifndef F_SETOWN_EX #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 #endif #ifndef F_GETOWNER_UIDS #define F_GETOWNER_UIDS 17 #endif /* * Open File Description Locks * * Usually record locks held by a process are released on *any* close and are * not inherited across a fork(). * * These cmd values will set locks that conflict with process-associated * record locks, but are "owned" by the open file description, not the * process. This means that they are inherited across fork() like BSD (flock) * locks, and they are only released automatically when the last reference to * the the open file against which they were acquired is put. */ #define F_OFD_GETLK 36 #define F_OFD_SETLK 37 #define F_OFD_SETLKW 38 #define F_OWNER_TID 0 #define F_OWNER_PID 1 #define F_OWNER_PGRP 2 struct f_owner_ex { int type; __kernel_pid_t pid; }; /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ /* for posix fcntl() and lockf() */ #ifndef F_RDLCK #define F_RDLCK 0 #define F_WRLCK 1 #define F_UNLCK 2 #endif /* for old implementation of bsd flock () */ #ifndef F_EXLCK #define F_EXLCK 4 /* or 3 */ #define F_SHLCK 8 /* or 4 */ #endif /* operations for bsd flock(), also used by the kernel implementation */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* or'd with one of the above to prevent blocking */ #define LOCK_UN 8 /* remove lock */ /* * LOCK_MAND support has been removed from the kernel. We leave the symbols * here to not break legacy builds, but these should not be used in new code. */ #define LOCK_MAND 32 /* This is a mandatory flock ... */ #define LOCK_READ 64 /* which allows concurrent read operations */ #define LOCK_WRITE 128 /* which allows concurrent write operations */ #define LOCK_RW 192 /* which allows concurrent read & write ops */ #define F_LINUX_SPECIFIC_BASE 1024 #ifndef HAVE_ARCH_STRUCT_FLOCK struct flock { short l_type; short l_whence; __kernel_off_t l_start; __kernel_off_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK_EXTRA_SYSID __ARCH_FLOCK_EXTRA_SYSID #endif #ifdef __ARCH_FLOCK_PAD __ARCH_FLOCK_PAD #endif }; struct flock64 { short l_type; short l_whence; __kernel_loff_t l_start; __kernel_loff_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK64_PAD __ARCH_FLOCK64_PAD #endif }; #endif /* HAVE_ARCH_STRUCT_FLOCK */ #endif /* _ASM_GENERIC_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm-generic/int-ll64.h000066400000000000000000000015571526721631600230170ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * asm-generic/int-ll64.h * * Integer declarations for architectures which use "long long" * for 64-bit types. */ #ifndef _UAPI_ASM_GENERIC_INT_LL64_H #define _UAPI_ASM_GENERIC_INT_LL64_H #include #ifndef __ASSEMBLY__ /* * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the * header files exported to user space */ typedef __signed__ char __s8; typedef unsigned char __u8; typedef __signed__ short __s16; typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; #ifdef __GNUC__ __extension__ typedef __signed__ long long __s64; __extension__ typedef unsigned long long __u64; #else typedef __signed__ long long __s64; typedef unsigned long long __u64; #endif #endif /* __ASSEMBLY__ */ #endif /* _UAPI_ASM_GENERIC_INT_LL64_H */ bpftrace-0.27.1/src/stdlib/include/asm-generic/ioctl.h000066400000000000000000000067471526721631600225660ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm-generic/posix_types.h000066400000000000000000000045421526721631600240310ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_POSIX_TYPES_H #define __ASM_GENERIC_POSIX_TYPES_H #include /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. * * First the types that are often defined in different ways across * architectures, so that you can override them. */ #ifndef __kernel_long_t typedef long __kernel_long_t; typedef unsigned long __kernel_ulong_t; #endif #ifndef __kernel_ino_t typedef __kernel_ulong_t __kernel_ino_t; #endif #ifndef __kernel_mode_t typedef unsigned int __kernel_mode_t; #endif #ifndef __kernel_pid_t typedef int __kernel_pid_t; #endif #ifndef __kernel_ipc_pid_t typedef int __kernel_ipc_pid_t; #endif #ifndef __kernel_uid_t typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; #endif #ifndef __kernel_suseconds_t typedef __kernel_long_t __kernel_suseconds_t; #endif #ifndef __kernel_daddr_t typedef int __kernel_daddr_t; #endif #ifndef __kernel_uid32_t typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; #endif #ifndef __kernel_old_uid_t typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_gid_t __kernel_old_gid_t; #endif #ifndef __kernel_old_dev_t typedef unsigned int __kernel_old_dev_t; #endif /* * Most 32 bit architectures use "unsigned int" size_t, * and all 64 bit architectures use "unsigned long" size_t. */ #ifndef __kernel_size_t #if __BITS_PER_LONG != 64 typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; #else typedef __kernel_ulong_t __kernel_size_t; typedef __kernel_long_t __kernel_ssize_t; typedef __kernel_long_t __kernel_ptrdiff_t; #endif #endif #ifndef __kernel_fsid_t typedef struct { int val[2]; } __kernel_fsid_t; #endif /* * anything below here should be completely generic */ typedef __kernel_long_t __kernel_off_t; typedef long long __kernel_loff_t; typedef __kernel_long_t __kernel_old_time_t; #ifndef __KERNEL__ typedef __kernel_long_t __kernel_time_t; #endif typedef long long __kernel_time64_t; typedef __kernel_long_t __kernel_clock_t; typedef int __kernel_timer_t; typedef int __kernel_clockid_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; #endif /* __ASM_GENERIC_POSIX_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm-generic/types.h000066400000000000000000000003701526721631600226020ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_TYPES_H #define _UAPI_ASM_GENERIC_TYPES_H /* * int-ll64 is used everywhere now. */ #include #endif /* _UAPI_ASM_GENERIC_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/000077500000000000000000000000001526721631600176535ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/arm/000077500000000000000000000000001526721631600204325ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/arm/bitsperlong.h000066400000000000000000000021231526721631600231310ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG #define _UAPI__ASM_GENERIC_BITS_PER_LONG #ifndef __BITS_PER_LONG /* * In order to keep safe and avoid regression, only unify uapi * bitsperlong.h for some archs which are using newer toolchains * that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__. * See the following link for more info: * https://lore.kernel.org/linux-arch/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/ */ #if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__) #define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__) #else /* * There seems to be no way of detecting this automatically from user * space, so 64 bit architectures should override this in their * bitsperlong.h. In particular, an architecture that supports * both 32 and 64 bit user space must not rely on CONFIG_64BIT * to decide it, but rather check a compiler provided macro. */ #define __BITS_PER_LONG 32 #endif #endif #ifndef __BITS_PER_LONG_LONG #define __BITS_PER_LONG_LONG 64 #endif #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */ bpftrace-0.27.1/src/stdlib/include/asm/arm/byteorder.h000066400000000000000000000013071526721631600226030ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * arch/arm/include/asm/byteorder.h * * ARM Endian-ness. In little endian mode, the data bus is connected such * that byte accesses appear as: * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 * and word accesses (data or instruction) appear as: * d0...d31 * * When in big endian mode, byte accesses appear as: * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 * and word accesses (data or instruction) appear as: * d0...d31 */ #ifndef __ASM_ARM_BYTEORDER_H #define __ASM_ARM_BYTEORDER_H #ifdef __ARMEB__ #include #else #include #endif #endif bpftrace-0.27.1/src/stdlib/include/asm/arm/errno.h000066400000000000000000000130201526721631600217240ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm/arm/fcntl.h000066400000000000000000000005431526721631600217130ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ARM_FCNTL_H #define _ARM_FCNTL_H #define O_DIRECTORY 040000 /* must be a directory */ #define O_NOFOLLOW 0100000 /* don't follow links */ #define O_DIRECT 0200000 /* direct disk access hint - currently ignored */ #define O_LARGEFILE 0400000 #include #endif bpftrace-0.27.1/src/stdlib/include/asm/arm/ioctl.h000066400000000000000000000067471526721631600217330ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm/posix_types.h000066400000000000000000000020471526721631600231740ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * arch/arm/include/asm/posix_types.h * * Copyright (C) 1996-1998 Russell King. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Changelog: * 27-06-1996 RMK Created */ #ifndef __ARCH_ARM_POSIX_TYPES_H #define __ARCH_ARM_POSIX_TYPES_H /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ typedef unsigned short __kernel_mode_t; #define __kernel_mode_t __kernel_mode_t typedef unsigned short __kernel_ipc_pid_t; #define __kernel_ipc_pid_t __kernel_ipc_pid_t typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; #define __kernel_uid_t __kernel_uid_t typedef unsigned short __kernel_old_dev_t; #define __kernel_old_dev_t __kernel_old_dev_t #include #endif bpftrace-0.27.1/src/stdlib/include/asm/arm/rwonce.h000066400000000000000000000062051526721631600221030ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm/swab.h000066400000000000000000000026641526721631600215470ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * arch/arm/include/asm/byteorder.h * * ARM Endian-ness. In little endian mode, the data bus is connected such * that byte accesses appear as: * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 * and word accesses (data or instruction) appear as: * d0...d31 * * When in big endian mode, byte accesses appear as: * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 * and word accesses (data or instruction) appear as: * d0...d31 */ #ifndef _UAPI__ASM_ARM_SWAB_H #define _UAPI__ASM_ARM_SWAB_H #include #include #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) # define __SWAB_64_THRU_32__ #endif #if !defined(__KERNEL__) || __LINUX_ARM_ARCH__ < 6 static inline __attribute_const__ __u32 __arch_swab32(__u32 x) { __u32 t; #ifndef __thumb__ if (!__builtin_constant_p(x)) { /* * The compiler needs a bit of a hint here to always do the * right thing and not screw it up to different degrees * depending on the gcc version. */ asm ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x)); } else #endif t = x ^ ((x << 16) | (x >> 16)); /* eor r1,r0,r0,ror #16 */ x = (x << 24) | (x >> 8); /* mov r0,r0,ror #8 */ t &= ~0x00FF0000; /* bic r1,r1,#0x00FF0000 */ x ^= (t >> 8); /* eor r0,r0,r1,lsr #8 */ return x; } #define __arch_swab32 __arch_swab32 #endif #endif /* _UAPI__ASM_ARM_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm/types.h000066400000000000000000000027051526721631600217530ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_TYPES_H #define _UAPI_ASM_TYPES_H #include /* * The C99 types uintXX_t that are usually defined in 'stdint.h' are not as * unambiguous on ARM as you would expect. For the types below, there is a * difference on ARM between GCC built for bare metal ARM, GCC built for glibc * and the kernel itself, which results in build errors if you try to build with * -ffreestanding and include 'stdint.h' (such as when you include 'arm_neon.h' * in order to use NEON intrinsics) * * As the typedefs for these types in 'stdint.h' are based on builtin defines * supplied by GCC, we can tweak these to align with the kernel's idea of those * types, so 'linux/types.h' and 'stdint.h' can be safely included from the same * source file (provided that -ffreestanding is used). * * int32_t uint32_t uintptr_t * bare metal GCC long unsigned long unsigned int * glibc GCC int unsigned int unsigned int * kernel int unsigned int unsigned long */ #ifdef __INT32_TYPE__ #undef __INT32_TYPE__ #define __INT32_TYPE__ int #endif #ifdef __UINT32_TYPE__ #undef __UINT32_TYPE__ #define __UINT32_TYPE__ unsigned int #endif #ifdef __UINTPTR_TYPE__ #undef __UINTPTR_TYPE__ #define __UINTPTR_TYPE__ unsigned long #endif #endif /* _UAPI_ASM_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/000077500000000000000000000000001526721631600206045ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/arm64/bitsperlong.h000066400000000000000000000015111526721631600233030ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (C) 2012 ARM Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program 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 for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __ASM_BITSPERLONG_H #define __ASM_BITSPERLONG_H #define __BITS_PER_LONG 64 #include #endif /* __ASM_BITSPERLONG_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/byteorder.h000066400000000000000000000015671526721631600227650ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (C) 2012 ARM Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program 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 for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __ASM_BYTEORDER_H #define __ASM_BYTEORDER_H #ifdef __AARCH64EB__ #include #else #include #endif #endif /* __ASM_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/errno.h000066400000000000000000000130201526721631600220760ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm/arm64/fcntl.h000066400000000000000000000020251526721631600220620ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (C) 2012 ARM Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program 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 for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __ASM_FCNTL_H #define __ASM_FCNTL_H /* * Using our own definitions for AArch32 (compat) support. */ #define O_DIRECTORY 040000 /* must be a directory */ #define O_NOFOLLOW 0100000 /* don't follow links */ #define O_DIRECT 0200000 /* direct disk access hint - currently ignored */ #define O_LARGEFILE 0400000 #include #endif bpftrace-0.27.1/src/stdlib/include/asm/arm64/ioctl.h000066400000000000000000000067471526721631600221050ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/posix_types.h000066400000000000000000000005051526721631600233430ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_POSIX_TYPES_H #define __ASM_POSIX_TYPES_H typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; #define __kernel_old_uid_t __kernel_old_uid_t #include #endif /* __ASM_POSIX_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/rwonce.h000066400000000000000000000062051526721631600222550ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/swab.h000066400000000000000000000007661526721631600217220ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_SWAB_H #define _ASM_GENERIC_SWAB_H #include /* * 32 bit architectures typically (but not always) want to * set __SWAB_64_THRU_32__. In user space, this is only * valid if the compiler supports 64 bit data types. */ #if __BITS_PER_LONG == 32 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) #define __SWAB_64_THRU_32__ #endif #endif #endif /* _ASM_GENERIC_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/arm64/types.h000066400000000000000000000003701526721631600221210ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_TYPES_H #define _UAPI_ASM_GENERIC_TYPES_H /* * int-ll64 is used everywhere now. */ #include #endif /* _UAPI_ASM_GENERIC_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/000077500000000000000000000000001526721631600216275ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/loongarch/bitsperlong.h000066400000000000000000000021231526721631600243260ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG #define _UAPI__ASM_GENERIC_BITS_PER_LONG #ifndef __BITS_PER_LONG /* * In order to keep safe and avoid regression, only unify uapi * bitsperlong.h for some archs which are using newer toolchains * that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__. * See the following link for more info: * https://lore.kernel.org/linux-arch/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/ */ #if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__) #define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__) #else /* * There seems to be no way of detecting this automatically from user * space, so 64 bit architectures should override this in their * bitsperlong.h. In particular, an architecture that supports * both 32 and 64 bit user space must not rely on CONFIG_64BIT * to decide it, but rather check a compiler provided macro. */ #define __BITS_PER_LONG 32 #endif #endif #ifndef __BITS_PER_LONG_LONG #define __BITS_PER_LONG_LONG 64 #endif #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/byteorder.h000066400000000000000000000005441526721631600240020ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * Author: Hanlu Li * Huacai Chen * * Copyright (C) 2020-2022 Loongson Technology Corporation Limited */ #ifndef _ASM_BYTEORDER_H #define _ASM_BYTEORDER_H #include #endif /* _ASM_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/errno.h000066400000000000000000000130201526721631600231210ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm/loongarch/fcntl.h000066400000000000000000000126731526721631600231170ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_FCNTL_H #define _ASM_GENERIC_FCNTL_H #include /* * FMODE_EXEC is 0x20 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris */ /* * When introducing new O_* bits, please check its uniqueness in fcntl_init(). */ #define O_ACCMODE 00000003 #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 #ifndef O_CREAT #define O_CREAT 00000100 /* not fcntl */ #endif #ifndef O_EXCL #define O_EXCL 00000200 /* not fcntl */ #endif #ifndef O_NOCTTY #define O_NOCTTY 00000400 /* not fcntl */ #endif #ifndef O_TRUNC #define O_TRUNC 00001000 /* not fcntl */ #endif #ifndef O_APPEND #define O_APPEND 00002000 #endif #ifndef O_NONBLOCK #define O_NONBLOCK 00004000 #endif #ifndef O_DSYNC #define O_DSYNC 00010000 /* used to be O_SYNC, see below */ #endif #ifndef FASYNC #define FASYNC 00020000 /* fcntl, for BSD compatibility */ #endif #ifndef O_DIRECT #define O_DIRECT 00040000 /* direct disk access hint */ #endif #ifndef O_LARGEFILE #define O_LARGEFILE 00100000 #endif #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 /* must be a directory */ #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 00400000 /* don't follow links */ #endif #ifndef O_NOATIME #define O_NOATIME 01000000 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #ifndef O_SYNC #define __O_SYNC 04000000 #define O_SYNC (__O_SYNC|O_DSYNC) #endif #ifndef O_PATH #define O_PATH 010000000 #endif #ifndef __O_TMPFILE #define __O_TMPFILE 020000000 #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ #define F_SETFD 2 /* set/clear close_on_exec */ #define F_GETFL 3 /* get file->f_flags */ #define F_SETFL 4 /* set file->f_flags */ #ifndef F_GETLK #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 #endif #ifndef F_SETOWN #define F_SETOWN 8 /* for sockets. */ #define F_GETOWN 9 /* for sockets. */ #endif #ifndef F_SETSIG #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ #endif #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #ifndef F_GETLK64 #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 #endif #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #ifndef F_SETOWN_EX #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 #endif #ifndef F_GETOWNER_UIDS #define F_GETOWNER_UIDS 17 #endif /* * Open File Description Locks * * Usually record locks held by a process are released on *any* close and are * not inherited across a fork(). * * These cmd values will set locks that conflict with process-associated * record locks, but are "owned" by the open file description, not the * process. This means that they are inherited across fork() like BSD (flock) * locks, and they are only released automatically when the last reference to * the the open file against which they were acquired is put. */ #define F_OFD_GETLK 36 #define F_OFD_SETLK 37 #define F_OFD_SETLKW 38 #define F_OWNER_TID 0 #define F_OWNER_PID 1 #define F_OWNER_PGRP 2 struct f_owner_ex { int type; __kernel_pid_t pid; }; /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ /* for posix fcntl() and lockf() */ #ifndef F_RDLCK #define F_RDLCK 0 #define F_WRLCK 1 #define F_UNLCK 2 #endif /* for old implementation of bsd flock () */ #ifndef F_EXLCK #define F_EXLCK 4 /* or 3 */ #define F_SHLCK 8 /* or 4 */ #endif /* operations for bsd flock(), also used by the kernel implementation */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* or'd with one of the above to prevent blocking */ #define LOCK_UN 8 /* remove lock */ /* * LOCK_MAND support has been removed from the kernel. We leave the symbols * here to not break legacy builds, but these should not be used in new code. */ #define LOCK_MAND 32 /* This is a mandatory flock ... */ #define LOCK_READ 64 /* which allows concurrent read operations */ #define LOCK_WRITE 128 /* which allows concurrent write operations */ #define LOCK_RW 192 /* which allows concurrent read & write ops */ #define F_LINUX_SPECIFIC_BASE 1024 #ifndef HAVE_ARCH_STRUCT_FLOCK struct flock { short l_type; short l_whence; __kernel_off_t l_start; __kernel_off_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK_EXTRA_SYSID __ARCH_FLOCK_EXTRA_SYSID #endif #ifdef __ARCH_FLOCK_PAD __ARCH_FLOCK_PAD #endif }; struct flock64 { short l_type; short l_whence; __kernel_loff_t l_start; __kernel_loff_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK64_PAD __ARCH_FLOCK64_PAD #endif }; #endif /* HAVE_ARCH_STRUCT_FLOCK */ #endif /* _ASM_GENERIC_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/ioctl.h000066400000000000000000000067471526721631600231300ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/posix_types.h000066400000000000000000000045421526721631600243730ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_POSIX_TYPES_H #define __ASM_GENERIC_POSIX_TYPES_H #include /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. * * First the types that are often defined in different ways across * architectures, so that you can override them. */ #ifndef __kernel_long_t typedef long __kernel_long_t; typedef unsigned long __kernel_ulong_t; #endif #ifndef __kernel_ino_t typedef __kernel_ulong_t __kernel_ino_t; #endif #ifndef __kernel_mode_t typedef unsigned int __kernel_mode_t; #endif #ifndef __kernel_pid_t typedef int __kernel_pid_t; #endif #ifndef __kernel_ipc_pid_t typedef int __kernel_ipc_pid_t; #endif #ifndef __kernel_uid_t typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; #endif #ifndef __kernel_suseconds_t typedef __kernel_long_t __kernel_suseconds_t; #endif #ifndef __kernel_daddr_t typedef int __kernel_daddr_t; #endif #ifndef __kernel_uid32_t typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; #endif #ifndef __kernel_old_uid_t typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_gid_t __kernel_old_gid_t; #endif #ifndef __kernel_old_dev_t typedef unsigned int __kernel_old_dev_t; #endif /* * Most 32 bit architectures use "unsigned int" size_t, * and all 64 bit architectures use "unsigned long" size_t. */ #ifndef __kernel_size_t #if __BITS_PER_LONG != 64 typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; #else typedef __kernel_ulong_t __kernel_size_t; typedef __kernel_long_t __kernel_ssize_t; typedef __kernel_long_t __kernel_ptrdiff_t; #endif #endif #ifndef __kernel_fsid_t typedef struct { int val[2]; } __kernel_fsid_t; #endif /* * anything below here should be completely generic */ typedef __kernel_long_t __kernel_off_t; typedef long long __kernel_loff_t; typedef __kernel_long_t __kernel_old_time_t; #ifndef __KERNEL__ typedef __kernel_long_t __kernel_time_t; #endif typedef long long __kernel_time64_t; typedef __kernel_long_t __kernel_clock_t; typedef int __kernel_timer_t; typedef int __kernel_clockid_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; #endif /* __ASM_GENERIC_POSIX_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/rwonce.h000066400000000000000000000062051526721631600233000ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/swab.h000066400000000000000000000007661526721631600227450ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_SWAB_H #define _ASM_GENERIC_SWAB_H #include /* * 32 bit architectures typically (but not always) want to * set __SWAB_64_THRU_32__. In user space, this is only * valid if the compiler supports 64 bit data types. */ #if __BITS_PER_LONG == 32 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) #define __SWAB_64_THRU_32__ #endif #endif #endif /* _ASM_GENERIC_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/loongarch/types.h000066400000000000000000000003701526721631600231440ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_TYPES_H #define _UAPI_ASM_GENERIC_TYPES_H /* * int-ll64 is used everywhere now. */ #include #endif /* _UAPI_ASM_GENERIC_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/000077500000000000000000000000001526721631600206235ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/mips/bitsperlong.h000066400000000000000000000003641526721631600233270ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_MIPS_BITSPERLONG_H #define __ASM_MIPS_BITSPERLONG_H #define __BITS_PER_LONG _MIPS_SZLONG #include #endif /* __ASM_MIPS_BITSPERLONG_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/byteorder.h000066400000000000000000000011041526721631600227670ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1996, 99, 2003 by Ralf Baechle */ #ifndef _ASM_BYTEORDER_H #define _ASM_BYTEORDER_H #if defined(__MIPSEB__) #include #elif defined(__MIPSEL__) #include #else # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" #endif #endif /* _ASM_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/errno.h000066400000000000000000000132401526721631600221210ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1995, 1999, 2001, 2002 by Ralf Baechle */ #ifndef _UAPI_ASM_ERRNO_H #define _UAPI_ASM_ERRNO_H /* * These error numbers are intended to be MIPS ABI compatible */ #include #define ENOMSG 35 /* No message of desired type */ #define EIDRM 36 /* Identifier removed */ #define ECHRNG 37 /* Channel number out of range */ #define EL2NSYNC 38 /* Level 2 not synchronized */ #define EL3HLT 39 /* Level 3 halted */ #define EL3RST 40 /* Level 3 reset */ #define ELNRNG 41 /* Link number out of range */ #define EUNATCH 42 /* Protocol driver not attached */ #define ENOCSI 43 /* No CSI structure available */ #define EL2HLT 44 /* Level 2 halted */ #define EDEADLK 45 /* Resource deadlock would occur */ #define ENOLCK 46 /* No record locks available */ #define EBADE 50 /* Invalid exchange */ #define EBADR 51 /* Invalid request descriptor */ #define EXFULL 52 /* Exchange full */ #define ENOANO 53 /* No anode */ #define EBADRQC 54 /* Invalid request code */ #define EBADSLT 55 /* Invalid slot */ #define EDEADLOCK 56 /* File locking deadlock error */ #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EDOTDOT 73 /* RFS specific error */ #define EMULTIHOP 74 /* Multihop attempted */ #define EBADMSG 77 /* Not a data message */ #define ENAMETOOLONG 78 /* File name too long */ #define EOVERFLOW 79 /* Value too large for defined data type */ #define ENOTUNIQ 80 /* Name not unique on network */ #define EBADFD 81 /* File descriptor in bad state */ #define EREMCHG 82 /* Remote address changed */ #define ELIBACC 83 /* Can not access a needed shared library */ #define ELIBBAD 84 /* Accessing a corrupted shared library */ #define ELIBSCN 85 /* .lib section in a.out corrupted */ #define ELIBMAX 86 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 87 /* Cannot exec a shared library directly */ #define EILSEQ 88 /* Illegal byte sequence */ #define ENOSYS 89 /* Function not implemented */ #define ELOOP 90 /* Too many symbolic links encountered */ #define ERESTART 91 /* Interrupted system call should be restarted */ #define ESTRPIPE 92 /* Streams pipe error */ #define ENOTEMPTY 93 /* Directory not empty */ #define EUSERS 94 /* Too many users */ #define ENOTSOCK 95 /* Socket operation on non-socket */ #define EDESTADDRREQ 96 /* Destination address required */ #define EMSGSIZE 97 /* Message too long */ #define EPROTOTYPE 98 /* Protocol wrong type for socket */ #define ENOPROTOOPT 99 /* Protocol not available */ #define EPROTONOSUPPORT 120 /* Protocol not supported */ #define ESOCKTNOSUPPORT 121 /* Socket type not supported */ #define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 123 /* Protocol family not supported */ #define EAFNOSUPPORT 124 /* Address family not supported by protocol */ #define EADDRINUSE 125 /* Address already in use */ #define EADDRNOTAVAIL 126 /* Cannot assign requested address */ #define ENETDOWN 127 /* Network is down */ #define ENETUNREACH 128 /* Network is unreachable */ #define ENETRESET 129 /* Network dropped connection because of reset */ #define ECONNABORTED 130 /* Software caused connection abort */ #define ECONNRESET 131 /* Connection reset by peer */ #define ENOBUFS 132 /* No buffer space available */ #define EISCONN 133 /* Transport endpoint is already connected */ #define ENOTCONN 134 /* Transport endpoint is not connected */ #define EUCLEAN 135 /* Structure needs cleaning */ #define ENOTNAM 137 /* Not a XENIX named type file */ #define ENAVAIL 138 /* No XENIX semaphores available */ #define EISNAM 139 /* Is a named type file */ #define EREMOTEIO 140 /* Remote I/O error */ #define EINIT 141 /* Reserved */ #define EREMDEV 142 /* Error 142 */ #define ESHUTDOWN 143 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 144 /* Too many references: cannot splice */ #define ETIMEDOUT 145 /* Connection timed out */ #define ECONNREFUSED 146 /* Connection refused */ #define EHOSTDOWN 147 /* Host is down */ #define EHOSTUNREACH 148 /* No route to host */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define EALREADY 149 /* Operation already in progress */ #define EINPROGRESS 150 /* Operation now in progress */ #define ESTALE 151 /* Stale file handle */ #define ECANCELED 158 /* AIO operation canceled */ /* * These error are Linux extensions. */ #define ENOMEDIUM 159 /* No medium found */ #define EMEDIUMTYPE 160 /* Wrong medium type */ #define ENOKEY 161 /* Required key not available */ #define EKEYEXPIRED 162 /* Key has expired */ #define EKEYREVOKED 163 /* Key has been revoked */ #define EKEYREJECTED 164 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 165 /* Owner died */ #define ENOTRECOVERABLE 166 /* State not recoverable */ #define ERFKILL 167 /* Operation not possible due to RF-kill */ #define EHWPOISON 168 /* Memory page has hardware error */ #define EDQUOT 1133 /* Quota exceeded */ #endif /* _UAPI_ASM_ERRNO_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/fcntl.h000066400000000000000000000037541526721631600221130ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1995, 96, 97, 98, 99, 2003, 05 Ralf Baechle */ #ifndef _UAPI_ASM_FCNTL_H #define _UAPI_ASM_FCNTL_H #include #define O_APPEND 0x0008 #define O_DSYNC 0x0010 /* used to be O_SYNC, see below */ #define O_NONBLOCK 0x0080 #define O_CREAT 0x0100 /* not fcntl */ #define O_TRUNC 0x0200 /* not fcntl */ #define O_EXCL 0x0400 /* not fcntl */ #define O_NOCTTY 0x0800 /* not fcntl */ #define FASYNC 0x1000 /* fcntl, for BSD compatibility */ #define O_LARGEFILE 0x2000 /* allow large file opens */ /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #define __O_SYNC 0x4000 #define O_SYNC (__O_SYNC|O_DSYNC) #define O_DIRECT 0x8000 /* direct disk access hint */ #define F_GETLK 14 #define F_SETLK 6 #define F_SETLKW 7 #define F_SETOWN 24 /* for sockets. */ #define F_GETOWN 23 /* for sockets. */ #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #define F_GETLK64 33 /* using 'struct flock64' */ #define F_SETLK64 34 #define F_SETLKW64 35 #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #if _MIPS_SIM != _MIPS_SIM_ABI64 #define __ARCH_FLOCK_EXTRA_SYSID long l_sysid; #define __ARCH_FLOCK_PAD long pad[4]; #endif #include #endif /* _UAPI_ASM_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/ioctl.h000066400000000000000000000014151526721631600221070ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1995, 96, 99, 2001 Ralf Baechle * Copyright (C) 2009 Wind River Systems * Written by Ralf Baechle */ #ifndef __ASM_IOCTL_H #define __ASM_IOCTL_H #define _IOC_SIZEBITS 13 #define _IOC_DIRBITS 3 /* * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit. * And this turns out useful to catch old ioctl numbers in header * files for us. */ #define _IOC_NONE 1U #define _IOC_READ 2U #define _IOC_WRITE 4U #include #endif /* __ASM_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/posix_types.h000066400000000000000000000013651526721631600233670ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1996, 97, 98, 99, 2000 by Ralf Baechle * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ #ifndef _ASM_POSIX_TYPES_H #define _ASM_POSIX_TYPES_H #include /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ typedef long __kernel_daddr_t; #define __kernel_daddr_t __kernel_daddr_t #include #endif /* _ASM_POSIX_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/rwonce.h000066400000000000000000000062051526721631600222740ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/swab.h000066400000000000000000000027741526721631600217420ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1996, 99, 2003 by Ralf Baechle */ #ifndef _ASM_SWAB_H #define _ASM_SWAB_H #include #include #define __SWAB_64_THRU_32__ #if !defined(__mips16) && \ ((defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \ defined(_MIPS_ARCH_LOONGSON3A)) static inline __attribute_const__ __u16 __arch_swab16(__u16 x) { __asm__( " .set push \n" " .set arch=mips32r2 \n" " wsbh %0, %1 \n" " .set pop \n" : "=r" (x) : "r" (x)); return x; } #define __arch_swab16 __arch_swab16 static inline __attribute_const__ __u32 __arch_swab32(__u32 x) { __asm__( " .set push \n" " .set arch=mips32r2 \n" " wsbh %0, %1 \n" " rotr %0, %0, 16 \n" " .set pop \n" : "=r" (x) : "r" (x)); return x; } #define __arch_swab32 __arch_swab32 /* * Having already checked for MIPS R2, enable the optimized version for * 64-bit kernel on r2 CPUs. */ #ifdef __mips64 static inline __attribute_const__ __u64 __arch_swab64(__u64 x) { __asm__( " .set push \n" " .set arch=mips64r2 \n" " dsbh %0, %1 \n" " dshd %0, %0 \n" " .set pop \n" : "=r" (x) : "r" (x)); return x; } #define __arch_swab64 __arch_swab64 #endif /* __mips64 */ #endif /* (not __mips16) and (MIPS R2 or newer or Loongson 3A) */ #endif /* _ASM_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/mips/types.h000066400000000000000000000016321526721631600221420ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle * Copyright (C) 2008 Wind River Systems, * written by Ralf Baechle * Copyright (C) 1999 Silicon Graphics, Inc. */ #ifndef _UAPI_ASM_TYPES_H #define _UAPI_ASM_TYPES_H /* * We don't use int-l64.h for the kernel anymore but still use it for * userspace to avoid code changes. * * However, some user programs (e.g. perf) may not want this. They can * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here. */ #ifndef __KERNEL__ # if _MIPS_SZLONG == 64 && !defined(__SANE_USERSPACE_TYPES__) # include # else # include # endif #endif #endif /* _UAPI_ASM_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/000077500000000000000000000000001526721631600213325ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/powerpc/bitsperlong.h000066400000000000000000000004701526721631600240340ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_POWERPC_BITSPERLONG_H #define __ASM_POWERPC_BITSPERLONG_H #if defined(__powerpc64__) # define __BITS_PER_LONG 64 #else # define __BITS_PER_LONG 32 #endif #include #endif /* __ASM_POWERPC_BITSPERLONG_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/byteorder.h000066400000000000000000000010461526721631600235030ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ #ifndef _ASM_POWERPC_BYTEORDER_H #define _ASM_POWERPC_BYTEORDER_H /* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #ifdef __LITTLE_ENDIAN__ #include #else #include #endif #endif /* _ASM_POWERPC_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/errno.h000066400000000000000000000004261526721631600226320ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_POWERPC_ERRNO_H #define _ASM_POWERPC_ERRNO_H #undef EDEADLOCK #include #undef EDEADLOCK #define EDEADLOCK 58 /* File locking deadlock error */ #endif /* _ASM_POWERPC_ERRNO_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/fcntl.h000066400000000000000000000005571526721631600226200ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_FCNTL_H #define _ASM_FCNTL_H #define O_DIRECTORY 040000 /* must be a directory */ #define O_NOFOLLOW 0100000 /* don't follow links */ #define O_LARGEFILE 0200000 #define O_DIRECT 0400000 /* direct disk access hint */ #include #endif /* _ASM_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/ioctl.h000066400000000000000000000004561526721631600226220ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_POWERPC_IOCTL_H #define _ASM_POWERPC_IOCTL_H #define _IOC_SIZEBITS 13 #define _IOC_DIRBITS 3 #define _IOC_NONE 1U #define _IOC_READ 2U #define _IOC_WRITE 4U #include #endif /* _ASM_POWERPC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/posix_types.h000066400000000000000000000011221526721631600240650ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_POWERPC_POSIX_TYPES_H #define _ASM_POWERPC_POSIX_TYPES_H /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ #ifdef __powerpc64__ typedef unsigned long __kernel_old_dev_t; #define __kernel_old_dev_t __kernel_old_dev_t #else typedef short __kernel_ipc_pid_t; #define __kernel_ipc_pid_t __kernel_ipc_pid_t #endif #include #endif /* _ASM_POWERPC_POSIX_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/rwonce.h000066400000000000000000000062051526721631600230030ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/swab.h000066400000000000000000000011321526721631600224340ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #ifndef _UAPI_ASM_POWERPC_SWAB_H #define _UAPI_ASM_POWERPC_SWAB_H #include #include #ifdef __GNUC__ #ifndef __powerpc64__ #define __SWAB_64_THRU_32__ #endif /* __powerpc64__ */ #endif /* __GNUC__ */ #endif /* _UAPI_ASM_POWERPC_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/powerpc/types.h000066400000000000000000000024471526721631600226560ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * This file is never included by application software unless * explicitly requested (e.g., via linux/types.h) in which case the * application is Linux specific so (user-) name space pollution is * not a major issue. However, for interoperability, libraries still * need to be careful to avoid a name clashes. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #ifndef _UAPI_ASM_POWERPC_TYPES_H #define _UAPI_ASM_POWERPC_TYPES_H /* * This is here because we used to use l64 for 64bit powerpc * and we don't want to impact user mode with our change to ll64 * in the kernel. * * However, some user programs are fine with this. They can * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here. */ #if !defined(__SANE_USERSPACE_TYPES__) && defined(__powerpc64__) && !defined(__KERNEL__) # include #else # include #endif #ifndef __ASSEMBLY__ typedef struct { __u32 u[4]; } __attribute__((aligned(16))) __vector128; #endif /* __ASSEMBLY__ */ #endif /* _UAPI_ASM_POWERPC_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/000077500000000000000000000000001526721631600210015ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/riscv/bitsperlong.h000066400000000000000000000005711526721631600235050ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (C) 2012 ARM Ltd. * Copyright (C) 2015 Regents of the University of California */ #ifndef _UAPI_ASM_RISCV_BITSPERLONG_H #define _UAPI_ASM_RISCV_BITSPERLONG_H #define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8) #include #endif /* _UAPI_ASM_RISCV_BITSPERLONG_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/byteorder.h000066400000000000000000000005071526721631600231530ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (C) 2012 ARM Ltd. * Copyright (C) 2015 Regents of the University of California */ #ifndef _UAPI_ASM_RISCV_BYTEORDER_H #define _UAPI_ASM_RISCV_BYTEORDER_H #include #endif /* _UAPI_ASM_RISCV_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/errno.h000066400000000000000000000130201526721631600222730ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm/riscv/fcntl.h000066400000000000000000000126731526721631600222710ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_FCNTL_H #define _ASM_GENERIC_FCNTL_H #include /* * FMODE_EXEC is 0x20 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris */ /* * When introducing new O_* bits, please check its uniqueness in fcntl_init(). */ #define O_ACCMODE 00000003 #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 #ifndef O_CREAT #define O_CREAT 00000100 /* not fcntl */ #endif #ifndef O_EXCL #define O_EXCL 00000200 /* not fcntl */ #endif #ifndef O_NOCTTY #define O_NOCTTY 00000400 /* not fcntl */ #endif #ifndef O_TRUNC #define O_TRUNC 00001000 /* not fcntl */ #endif #ifndef O_APPEND #define O_APPEND 00002000 #endif #ifndef O_NONBLOCK #define O_NONBLOCK 00004000 #endif #ifndef O_DSYNC #define O_DSYNC 00010000 /* used to be O_SYNC, see below */ #endif #ifndef FASYNC #define FASYNC 00020000 /* fcntl, for BSD compatibility */ #endif #ifndef O_DIRECT #define O_DIRECT 00040000 /* direct disk access hint */ #endif #ifndef O_LARGEFILE #define O_LARGEFILE 00100000 #endif #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 /* must be a directory */ #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 00400000 /* don't follow links */ #endif #ifndef O_NOATIME #define O_NOATIME 01000000 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #ifndef O_SYNC #define __O_SYNC 04000000 #define O_SYNC (__O_SYNC|O_DSYNC) #endif #ifndef O_PATH #define O_PATH 010000000 #endif #ifndef __O_TMPFILE #define __O_TMPFILE 020000000 #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ #define F_SETFD 2 /* set/clear close_on_exec */ #define F_GETFL 3 /* get file->f_flags */ #define F_SETFL 4 /* set file->f_flags */ #ifndef F_GETLK #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 #endif #ifndef F_SETOWN #define F_SETOWN 8 /* for sockets. */ #define F_GETOWN 9 /* for sockets. */ #endif #ifndef F_SETSIG #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ #endif #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #ifndef F_GETLK64 #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 #endif #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #ifndef F_SETOWN_EX #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 #endif #ifndef F_GETOWNER_UIDS #define F_GETOWNER_UIDS 17 #endif /* * Open File Description Locks * * Usually record locks held by a process are released on *any* close and are * not inherited across a fork(). * * These cmd values will set locks that conflict with process-associated * record locks, but are "owned" by the open file description, not the * process. This means that they are inherited across fork() like BSD (flock) * locks, and they are only released automatically when the last reference to * the the open file against which they were acquired is put. */ #define F_OFD_GETLK 36 #define F_OFD_SETLK 37 #define F_OFD_SETLKW 38 #define F_OWNER_TID 0 #define F_OWNER_PID 1 #define F_OWNER_PGRP 2 struct f_owner_ex { int type; __kernel_pid_t pid; }; /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ /* for posix fcntl() and lockf() */ #ifndef F_RDLCK #define F_RDLCK 0 #define F_WRLCK 1 #define F_UNLCK 2 #endif /* for old implementation of bsd flock () */ #ifndef F_EXLCK #define F_EXLCK 4 /* or 3 */ #define F_SHLCK 8 /* or 4 */ #endif /* operations for bsd flock(), also used by the kernel implementation */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* or'd with one of the above to prevent blocking */ #define LOCK_UN 8 /* remove lock */ /* * LOCK_MAND support has been removed from the kernel. We leave the symbols * here to not break legacy builds, but these should not be used in new code. */ #define LOCK_MAND 32 /* This is a mandatory flock ... */ #define LOCK_READ 64 /* which allows concurrent read operations */ #define LOCK_WRITE 128 /* which allows concurrent write operations */ #define LOCK_RW 192 /* which allows concurrent read & write ops */ #define F_LINUX_SPECIFIC_BASE 1024 #ifndef HAVE_ARCH_STRUCT_FLOCK struct flock { short l_type; short l_whence; __kernel_off_t l_start; __kernel_off_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK_EXTRA_SYSID __ARCH_FLOCK_EXTRA_SYSID #endif #ifdef __ARCH_FLOCK_PAD __ARCH_FLOCK_PAD #endif }; struct flock64 { short l_type; short l_whence; __kernel_loff_t l_start; __kernel_loff_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK64_PAD __ARCH_FLOCK64_PAD #endif }; #endif /* HAVE_ARCH_STRUCT_FLOCK */ #endif /* _ASM_GENERIC_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/ioctl.h000066400000000000000000000067471526721631600223020ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/posix_types.h000066400000000000000000000045421526721631600235450ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_POSIX_TYPES_H #define __ASM_GENERIC_POSIX_TYPES_H #include /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. * * First the types that are often defined in different ways across * architectures, so that you can override them. */ #ifndef __kernel_long_t typedef long __kernel_long_t; typedef unsigned long __kernel_ulong_t; #endif #ifndef __kernel_ino_t typedef __kernel_ulong_t __kernel_ino_t; #endif #ifndef __kernel_mode_t typedef unsigned int __kernel_mode_t; #endif #ifndef __kernel_pid_t typedef int __kernel_pid_t; #endif #ifndef __kernel_ipc_pid_t typedef int __kernel_ipc_pid_t; #endif #ifndef __kernel_uid_t typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; #endif #ifndef __kernel_suseconds_t typedef __kernel_long_t __kernel_suseconds_t; #endif #ifndef __kernel_daddr_t typedef int __kernel_daddr_t; #endif #ifndef __kernel_uid32_t typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; #endif #ifndef __kernel_old_uid_t typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_gid_t __kernel_old_gid_t; #endif #ifndef __kernel_old_dev_t typedef unsigned int __kernel_old_dev_t; #endif /* * Most 32 bit architectures use "unsigned int" size_t, * and all 64 bit architectures use "unsigned long" size_t. */ #ifndef __kernel_size_t #if __BITS_PER_LONG != 64 typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; #else typedef __kernel_ulong_t __kernel_size_t; typedef __kernel_long_t __kernel_ssize_t; typedef __kernel_long_t __kernel_ptrdiff_t; #endif #endif #ifndef __kernel_fsid_t typedef struct { int val[2]; } __kernel_fsid_t; #endif /* * anything below here should be completely generic */ typedef __kernel_long_t __kernel_off_t; typedef long long __kernel_loff_t; typedef __kernel_long_t __kernel_old_time_t; #ifndef __KERNEL__ typedef __kernel_long_t __kernel_time_t; #endif typedef long long __kernel_time64_t; typedef __kernel_long_t __kernel_clock_t; typedef int __kernel_timer_t; typedef int __kernel_clockid_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; #endif /* __ASM_GENERIC_POSIX_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/rwonce.h000066400000000000000000000062051526721631600224520ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/swab.h000066400000000000000000000007661526721631600221170ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_SWAB_H #define _ASM_GENERIC_SWAB_H #include /* * 32 bit architectures typically (but not always) want to * set __SWAB_64_THRU_32__. In user space, this is only * valid if the compiler supports 64 bit data types. */ #if __BITS_PER_LONG == 32 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) #define __SWAB_64_THRU_32__ #endif #endif #endif /* _ASM_GENERIC_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/riscv/types.h000066400000000000000000000003701526721631600223160ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_TYPES_H #define _UAPI_ASM_GENERIC_TYPES_H /* * int-ll64 is used everywhere now. */ #include #endif /* _UAPI_ASM_GENERIC_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/000077500000000000000000000000001526721631600203515ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/s390/bitsperlong.h000066400000000000000000000004451526721631600230550ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_S390_BITSPERLONG_H #define __ASM_S390_BITSPERLONG_H #ifndef __s390x__ #define __BITS_PER_LONG 32 #else #define __BITS_PER_LONG 64 #endif #include #endif /* __ASM_S390_BITSPERLONG_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/byteorder.h000066400000000000000000000002741526721631600225240ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _S390_BYTEORDER_H #define _S390_BYTEORDER_H #include #endif /* _S390_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/errno.h000066400000000000000000000130201526721631600216430ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm/s390/fcntl.h000066400000000000000000000126731526721631600216410ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_FCNTL_H #define _ASM_GENERIC_FCNTL_H #include /* * FMODE_EXEC is 0x20 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris */ /* * When introducing new O_* bits, please check its uniqueness in fcntl_init(). */ #define O_ACCMODE 00000003 #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 #ifndef O_CREAT #define O_CREAT 00000100 /* not fcntl */ #endif #ifndef O_EXCL #define O_EXCL 00000200 /* not fcntl */ #endif #ifndef O_NOCTTY #define O_NOCTTY 00000400 /* not fcntl */ #endif #ifndef O_TRUNC #define O_TRUNC 00001000 /* not fcntl */ #endif #ifndef O_APPEND #define O_APPEND 00002000 #endif #ifndef O_NONBLOCK #define O_NONBLOCK 00004000 #endif #ifndef O_DSYNC #define O_DSYNC 00010000 /* used to be O_SYNC, see below */ #endif #ifndef FASYNC #define FASYNC 00020000 /* fcntl, for BSD compatibility */ #endif #ifndef O_DIRECT #define O_DIRECT 00040000 /* direct disk access hint */ #endif #ifndef O_LARGEFILE #define O_LARGEFILE 00100000 #endif #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 /* must be a directory */ #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 00400000 /* don't follow links */ #endif #ifndef O_NOATIME #define O_NOATIME 01000000 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #ifndef O_SYNC #define __O_SYNC 04000000 #define O_SYNC (__O_SYNC|O_DSYNC) #endif #ifndef O_PATH #define O_PATH 010000000 #endif #ifndef __O_TMPFILE #define __O_TMPFILE 020000000 #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ #define F_SETFD 2 /* set/clear close_on_exec */ #define F_GETFL 3 /* get file->f_flags */ #define F_SETFL 4 /* set file->f_flags */ #ifndef F_GETLK #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 #endif #ifndef F_SETOWN #define F_SETOWN 8 /* for sockets. */ #define F_GETOWN 9 /* for sockets. */ #endif #ifndef F_SETSIG #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ #endif #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #ifndef F_GETLK64 #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 #endif #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #ifndef F_SETOWN_EX #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 #endif #ifndef F_GETOWNER_UIDS #define F_GETOWNER_UIDS 17 #endif /* * Open File Description Locks * * Usually record locks held by a process are released on *any* close and are * not inherited across a fork(). * * These cmd values will set locks that conflict with process-associated * record locks, but are "owned" by the open file description, not the * process. This means that they are inherited across fork() like BSD (flock) * locks, and they are only released automatically when the last reference to * the the open file against which they were acquired is put. */ #define F_OFD_GETLK 36 #define F_OFD_SETLK 37 #define F_OFD_SETLKW 38 #define F_OWNER_TID 0 #define F_OWNER_PID 1 #define F_OWNER_PGRP 2 struct f_owner_ex { int type; __kernel_pid_t pid; }; /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ /* for posix fcntl() and lockf() */ #ifndef F_RDLCK #define F_RDLCK 0 #define F_WRLCK 1 #define F_UNLCK 2 #endif /* for old implementation of bsd flock () */ #ifndef F_EXLCK #define F_EXLCK 4 /* or 3 */ #define F_SHLCK 8 /* or 4 */ #endif /* operations for bsd flock(), also used by the kernel implementation */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* or'd with one of the above to prevent blocking */ #define LOCK_UN 8 /* remove lock */ /* * LOCK_MAND support has been removed from the kernel. We leave the symbols * here to not break legacy builds, but these should not be used in new code. */ #define LOCK_MAND 32 /* This is a mandatory flock ... */ #define LOCK_READ 64 /* which allows concurrent read operations */ #define LOCK_WRITE 128 /* which allows concurrent write operations */ #define LOCK_RW 192 /* which allows concurrent read & write ops */ #define F_LINUX_SPECIFIC_BASE 1024 #ifndef HAVE_ARCH_STRUCT_FLOCK struct flock { short l_type; short l_whence; __kernel_off_t l_start; __kernel_off_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK_EXTRA_SYSID __ARCH_FLOCK_EXTRA_SYSID #endif #ifdef __ARCH_FLOCK_PAD __ARCH_FLOCK_PAD #endif }; struct flock64 { short l_type; short l_whence; __kernel_loff_t l_start; __kernel_loff_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK64_PAD __ARCH_FLOCK64_PAD #endif }; #endif /* HAVE_ARCH_STRUCT_FLOCK */ #endif /* _ASM_GENERIC_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/ioctl.h000066400000000000000000000067471526721631600216520ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/posix_types.h000066400000000000000000000030721526721631600231120ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * S390 version * */ #ifndef __ARCH_S390_POSIX_TYPES_H #define __ARCH_S390_POSIX_TYPES_H /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ typedef unsigned long __kernel_size_t; typedef long __kernel_ssize_t; #define __kernel_size_t __kernel_size_t typedef unsigned short __kernel_old_dev_t; #define __kernel_old_dev_t __kernel_old_dev_t #ifdef __KERNEL__ typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; #define __kernel_old_uid_t __kernel_old_uid_t #endif #ifndef __s390x__ typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; typedef int __kernel_ptrdiff_t; #else /* __s390x__ */ typedef unsigned int __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef int __kernel_ipc_pid_t; typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; typedef long __kernel_ptrdiff_t; typedef unsigned long __kernel_sigset_t; /* at least 32 bits */ #endif /* __s390x__ */ #define __kernel_ino_t __kernel_ino_t #define __kernel_mode_t __kernel_mode_t #define __kernel_ipc_pid_t __kernel_ipc_pid_t #define __kernel_uid_t __kernel_uid_t #define __kernel_gid_t __kernel_gid_t #include #endif bpftrace-0.27.1/src/stdlib/include/asm/s390/rwonce.h000066400000000000000000000062051526721631600220220ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/swab.h000066400000000000000000000007661526721631600214670ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_SWAB_H #define _ASM_GENERIC_SWAB_H #include /* * 32 bit architectures typically (but not always) want to * set __SWAB_64_THRU_32__. In user space, this is only * valid if the compiler supports 64 bit data types. */ #if __BITS_PER_LONG == 32 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) #define __SWAB_64_THRU_32__ #endif #endif #endif /* _ASM_GENERIC_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/s390/types.h000066400000000000000000000007771526721631600217010ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * S390 version * * Derived from "include/asm-i386/types.h" */ #ifndef _UAPI_S390_TYPES_H #define _UAPI_S390_TYPES_H #include #ifndef __ASSEMBLY__ typedef unsigned long addr_t; typedef __signed__ long saddr_t; typedef struct { union { struct { __u64 high; __u64 low; }; __u32 u[4]; }; } __attribute__((packed, aligned(4))) __vector128; #endif /* __ASSEMBLY__ */ #endif /* _UAPI_S390_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/000077500000000000000000000000001526721631600203005ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/asm/x86/bitsperlong.h000066400000000000000000000005011526721631600227750ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_X86_BITSPERLONG_H #define __ASM_X86_BITSPERLONG_H #if defined(__x86_64__) && !defined(__ILP32__) # define __BITS_PER_LONG 64 #else # define __BITS_PER_LONG 32 #endif #include #endif /* __ASM_X86_BITSPERLONG_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/byteorder.h000066400000000000000000000003101526721631600224420ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_X86_BYTEORDER_H #define _ASM_X86_BYTEORDER_H #include #endif /* _ASM_X86_BYTEORDER_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/errno.h000066400000000000000000000130201526721631600215720ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif bpftrace-0.27.1/src/stdlib/include/asm/x86/fcntl.h000066400000000000000000000126731526721631600215700ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_FCNTL_H #define _ASM_GENERIC_FCNTL_H #include /* * FMODE_EXEC is 0x20 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris */ /* * When introducing new O_* bits, please check its uniqueness in fcntl_init(). */ #define O_ACCMODE 00000003 #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 #ifndef O_CREAT #define O_CREAT 00000100 /* not fcntl */ #endif #ifndef O_EXCL #define O_EXCL 00000200 /* not fcntl */ #endif #ifndef O_NOCTTY #define O_NOCTTY 00000400 /* not fcntl */ #endif #ifndef O_TRUNC #define O_TRUNC 00001000 /* not fcntl */ #endif #ifndef O_APPEND #define O_APPEND 00002000 #endif #ifndef O_NONBLOCK #define O_NONBLOCK 00004000 #endif #ifndef O_DSYNC #define O_DSYNC 00010000 /* used to be O_SYNC, see below */ #endif #ifndef FASYNC #define FASYNC 00020000 /* fcntl, for BSD compatibility */ #endif #ifndef O_DIRECT #define O_DIRECT 00040000 /* direct disk access hint */ #endif #ifndef O_LARGEFILE #define O_LARGEFILE 00100000 #endif #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 /* must be a directory */ #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 00400000 /* don't follow links */ #endif #ifndef O_NOATIME #define O_NOATIME 01000000 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #ifndef O_SYNC #define __O_SYNC 04000000 #define O_SYNC (__O_SYNC|O_DSYNC) #endif #ifndef O_PATH #define O_PATH 010000000 #endif #ifndef __O_TMPFILE #define __O_TMPFILE 020000000 #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ #define F_SETFD 2 /* set/clear close_on_exec */ #define F_GETFL 3 /* get file->f_flags */ #define F_SETFL 4 /* set file->f_flags */ #ifndef F_GETLK #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 #endif #ifndef F_SETOWN #define F_SETOWN 8 /* for sockets. */ #define F_GETOWN 9 /* for sockets. */ #endif #ifndef F_SETSIG #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ #endif #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #ifndef F_GETLK64 #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 #endif #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #ifndef F_SETOWN_EX #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 #endif #ifndef F_GETOWNER_UIDS #define F_GETOWNER_UIDS 17 #endif /* * Open File Description Locks * * Usually record locks held by a process are released on *any* close and are * not inherited across a fork(). * * These cmd values will set locks that conflict with process-associated * record locks, but are "owned" by the open file description, not the * process. This means that they are inherited across fork() like BSD (flock) * locks, and they are only released automatically when the last reference to * the the open file against which they were acquired is put. */ #define F_OFD_GETLK 36 #define F_OFD_SETLK 37 #define F_OFD_SETLKW 38 #define F_OWNER_TID 0 #define F_OWNER_PID 1 #define F_OWNER_PGRP 2 struct f_owner_ex { int type; __kernel_pid_t pid; }; /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ /* for posix fcntl() and lockf() */ #ifndef F_RDLCK #define F_RDLCK 0 #define F_WRLCK 1 #define F_UNLCK 2 #endif /* for old implementation of bsd flock () */ #ifndef F_EXLCK #define F_EXLCK 4 /* or 3 */ #define F_SHLCK 8 /* or 4 */ #endif /* operations for bsd flock(), also used by the kernel implementation */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* or'd with one of the above to prevent blocking */ #define LOCK_UN 8 /* remove lock */ /* * LOCK_MAND support has been removed from the kernel. We leave the symbols * here to not break legacy builds, but these should not be used in new code. */ #define LOCK_MAND 32 /* This is a mandatory flock ... */ #define LOCK_READ 64 /* which allows concurrent read operations */ #define LOCK_WRITE 128 /* which allows concurrent write operations */ #define LOCK_RW 192 /* which allows concurrent read & write ops */ #define F_LINUX_SPECIFIC_BASE 1024 #ifndef HAVE_ARCH_STRUCT_FLOCK struct flock { short l_type; short l_whence; __kernel_off_t l_start; __kernel_off_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK_EXTRA_SYSID __ARCH_FLOCK_EXTRA_SYSID #endif #ifdef __ARCH_FLOCK_PAD __ARCH_FLOCK_PAD #endif }; struct flock64 { short l_type; short l_whence; __kernel_loff_t l_start; __kernel_loff_t l_len; __kernel_pid_t l_pid; #ifdef __ARCH_FLOCK64_PAD __ARCH_FLOCK64_PAD #endif }; #endif /* HAVE_ARCH_STRUCT_FLOCK */ #endif /* _ASM_GENERIC_FCNTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/ioctl.h000066400000000000000000000067471526721631600216010ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_IOCTL_H #define _UAPI_ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #ifndef __KERNEL__ #define _IOC_TYPECHECK(t) (sizeof(t)) #endif /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOW(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOWR(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(argtype))) #define _IOR_BAD(type,nr,argtype) _IOC(_IOC_READ,(type),(nr),sizeof(argtype)) #define _IOW_BAD(type,nr,argtype) _IOC(_IOC_WRITE,(type),(nr),sizeof(argtype)) #define _IOWR_BAD(type,nr,argtype) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(argtype)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _UAPI_ASM_GENERIC_IOCTL_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/posix_types.h000066400000000000000000000003721526721631600230410ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __KERNEL__ # ifdef __i386__ # include # elif defined(__ILP32__) # include # else # include # endif #endif bpftrace-0.27.1/src/stdlib/include/asm/x86/posix_types_64.h000066400000000000000000000011411526721631600233450ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_X86_POSIX_TYPES_64_H #define _ASM_X86_POSIX_TYPES_64_H /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; #define __kernel_old_uid_t __kernel_old_uid_t typedef unsigned long __kernel_old_dev_t; #define __kernel_old_dev_t __kernel_old_dev_t #include #endif /* _ASM_X86_POSIX_TYPES_64_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/rwonce.h000066400000000000000000000062051526721631600217510ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ /* * Prevent the compiler from merging or refetching reads or writes. The * compiler is also forbidden from reordering successive instances of * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some * particular ordering. One way to make the compiler aware of ordering is to * put the two invocations of READ_ONCE or WRITE_ONCE in different C * statements. * * These two macros will also work on aggregate data types like structs or * unions. * * Their two major use cases are: (1) Mediating communication between * process-level code and irq/NMI handlers, all running on the same CPU, * and (2) Ensuring that the compiler does not fold, spindle, or otherwise * mutilate accesses that either do not require ordering or that interact * with an explicit memory barrier or atomic instruction that provides the * required ordering. */ #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ #include #include #include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will * actually be atomic in some cases (namely Armv7 + LPAE), but for others we * rely on the access being split into 2x32-bit accesses for a 32-bit quantity * (e.g. a virtual address) and a strong prevailing wind. */ #define compiletime_assert_rwonce_type(t) \ compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ "Unsupported access size for {READ,WRITE}_ONCE().") /* * Use __READ_ONCE() instead of READ_ONCE() if you do not require any * atomicity. Note that this may result in tears! */ #ifndef __READ_ONCE #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) #endif #define READ_ONCE(x) \ ({ \ compiletime_assert_rwonce_type(x); \ __READ_ONCE(x); \ }) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) #define WRITE_ONCE(x, val) \ do { \ compiletime_assert_rwonce_type(x); \ __WRITE_ONCE(x, val); \ } while (0) static __no_sanitize_or_inline unsigned long __read_once_word_nocheck(const void *addr) { return __READ_ONCE(*(unsigned long *)addr); } /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a * word from memory atomically but without telling KASAN/KCSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ (typeof(x))__read_once_word_nocheck(&(x)); \ }) static __no_sanitize_or_inline unsigned long read_word_at_a_time(const void *addr) { /* open-coded instrument_read(addr, 1) */ kasan_check_read(addr, 1); kcsan_check_read(addr, 1); /* * This load can race with concurrent stores to out-of-bounds memory, * but READ_ONCE() can't be used because it requires higher alignment * than plain loads in arm64 builds with LTO. */ return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_RWONCE_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/swab.h000066400000000000000000000014011526721631600214010ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_X86_SWAB_H #define _ASM_X86_SWAB_H #include #include static inline __attribute_const__ __u32 __arch_swab32(__u32 val) { asm("bswapl %0" : "=r" (val) : "0" (val)); return val; } #define __arch_swab32 __arch_swab32 static inline __attribute_const__ __u64 __arch_swab64(__u64 val) { #ifdef __i386__ union { struct { __u32 a; __u32 b; } s; __u64 u; } v; v.u = val; asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); return v.u; #else /* __i386__ */ asm("bswapq %0" : "=r" (val) : "0" (val)); return val; #endif } #define __arch_swab64 __arch_swab64 #endif /* _ASM_X86_SWAB_H */ bpftrace-0.27.1/src/stdlib/include/asm/x86/types.h000066400000000000000000000003701526721631600216150ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_ASM_GENERIC_TYPES_H #define _UAPI_ASM_GENERIC_TYPES_H /* * int-ll64 is used everywhere now. */ #include #endif /* _UAPI_ASM_GENERIC_TYPES_H */ bpftrace-0.27.1/src/stdlib/include/float.h000066400000000000000000000121071526721631600203520ustar00rootroot00000000000000/*===---- float.h - Characteristics of floating point types ----------------=== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * *===-----------------------------------------------------------------------=== */ #ifndef __FLOAT_H #define __FLOAT_H /* If we're on MinGW, fall back to the system's float.h, which might have * additional definitions provided for Windows. * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx * * Also fall back on Darwin to allow additional definitions and * implementation-defined values. */ #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ __STDC_HOSTED__ && __has_include_next() /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level * of #include_next to keep Metrowerks compilers happy. Avoid this * extra indirection. */ #ifdef __APPLE__ #define _FLOAT_H_ #endif # include_next /* Undefine anything that we'll be redefining below. */ # undef FLT_EVAL_METHOD # undef FLT_ROUNDS # undef FLT_RADIX # undef FLT_MANT_DIG # undef DBL_MANT_DIG # undef LDBL_MANT_DIG # if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) # undef DECIMAL_DIG # endif # undef FLT_DIG # undef DBL_DIG # undef LDBL_DIG # undef FLT_MIN_EXP # undef DBL_MIN_EXP # undef LDBL_MIN_EXP # undef FLT_MIN_10_EXP # undef DBL_MIN_10_EXP # undef LDBL_MIN_10_EXP # undef FLT_MAX_EXP # undef DBL_MAX_EXP # undef LDBL_MAX_EXP # undef FLT_MAX_10_EXP # undef DBL_MAX_10_EXP # undef LDBL_MAX_10_EXP # undef FLT_MAX # undef DBL_MAX # undef LDBL_MAX # undef FLT_EPSILON # undef DBL_EPSILON # undef LDBL_EPSILON # undef FLT_MIN # undef DBL_MIN # undef LDBL_MIN # if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) # undef FLT_TRUE_MIN # undef DBL_TRUE_MIN # undef LDBL_TRUE_MIN # undef FLT_DECIMAL_DIG # undef DBL_DECIMAL_DIG # undef LDBL_DECIMAL_DIG # endif #endif /* Characteristics of floating point types, C99 5.2.4.2.2 */ #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ #define FLT_ROUNDS (__builtin_flt_rounds()) #define FLT_RADIX __FLT_RADIX__ #define FLT_MANT_DIG __FLT_MANT_DIG__ #define DBL_MANT_DIG __DBL_MANT_DIG__ #define LDBL_MANT_DIG __LDBL_MANT_DIG__ #if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) # define DECIMAL_DIG __DECIMAL_DIG__ #endif #define FLT_DIG __FLT_DIG__ #define DBL_DIG __DBL_DIG__ #define LDBL_DIG __LDBL_DIG__ #define FLT_MIN_EXP __FLT_MIN_EXP__ #define DBL_MIN_EXP __DBL_MIN_EXP__ #define LDBL_MIN_EXP __LDBL_MIN_EXP__ #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ #define FLT_MAX_EXP __FLT_MAX_EXP__ #define DBL_MAX_EXP __DBL_MAX_EXP__ #define LDBL_MAX_EXP __LDBL_MAX_EXP__ #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ #define FLT_MAX __FLT_MAX__ #define DBL_MAX __DBL_MAX__ #define LDBL_MAX __LDBL_MAX__ #define FLT_EPSILON __FLT_EPSILON__ #define DBL_EPSILON __DBL_EPSILON__ #define LDBL_EPSILON __LDBL_EPSILON__ #define FLT_MIN __FLT_MIN__ #define DBL_MIN __DBL_MIN__ #define LDBL_MIN __LDBL_MIN__ #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) # define FLT_TRUE_MIN __FLT_DENORM_MIN__ # define DBL_TRUE_MIN __DBL_DENORM_MIN__ # define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ # define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ # define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ #endif #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ # define FLT16_MANT_DIG __FLT16_MANT_DIG__ # define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ # define FLT16_DIG __FLT16_DIG__ # define FLT16_MIN_EXP __FLT16_MIN_EXP__ # define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ # define FLT16_MAX_EXP __FLT16_MAX_EXP__ # define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ # define FLT16_MAX __FLT16_MAX__ # define FLT16_EPSILON __FLT16_EPSILON__ # define FLT16_MIN __FLT16_MIN__ # define FLT16_TRUE_MIN __FLT16_TRUE_MIN__ #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ #endif /* __FLOAT_H */ bpftrace-0.27.1/src/stdlib/include/limits.h000066400000000000000000000072261526721631600205540ustar00rootroot00000000000000/*===---- limits.h - Standard header for integer sizes --------------------===*\ * * Copyright (c) 2009 Chris Lattner * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * \*===----------------------------------------------------------------------===*/ #ifndef __CLANG_LIMITS_H #define __CLANG_LIMITS_H /* The system's limits.h may, in turn, try to #include_next GCC's limits.h. Avert this #include_next madness. */ #if defined __GNUC__ && !defined _GCC_LIMITS_H_ #define _GCC_LIMITS_H_ #endif /* System headers include a number of constants from POSIX in . Include it if we're hosted. */ #if __STDC_HOSTED__ && __has_include_next() #include_next #endif /* Many system headers try to "help us out" by defining these. No really, we know how big each datatype is. */ #undef SCHAR_MIN #undef SCHAR_MAX #undef UCHAR_MAX #undef SHRT_MIN #undef SHRT_MAX #undef USHRT_MAX #undef INT_MIN #undef INT_MAX #undef UINT_MAX #undef LONG_MIN #undef LONG_MAX #undef ULONG_MAX #undef CHAR_BIT #undef CHAR_MIN #undef CHAR_MAX /* C90/99 5.2.4.2.1 */ #define SCHAR_MAX __SCHAR_MAX__ #define SHRT_MAX __SHRT_MAX__ #define INT_MAX __INT_MAX__ #define LONG_MAX __LONG_MAX__ #define SCHAR_MIN (-__SCHAR_MAX__-1) #define SHRT_MIN (-__SHRT_MAX__ -1) #define INT_MIN (-__INT_MAX__ -1) #define LONG_MIN (-__LONG_MAX__ -1L) #define UCHAR_MAX (__SCHAR_MAX__*2 +1) #define USHRT_MAX (__SHRT_MAX__ *2 +1) #define UINT_MAX (__INT_MAX__ *2U +1U) #define ULONG_MAX (__LONG_MAX__ *2UL+1UL) #ifndef MB_LEN_MAX #define MB_LEN_MAX 1 #endif #define CHAR_BIT __CHAR_BIT__ #ifdef __CHAR_UNSIGNED__ /* -funsigned-char */ #define CHAR_MIN 0 #define CHAR_MAX UCHAR_MAX #else #define CHAR_MIN SCHAR_MIN #define CHAR_MAX __SCHAR_MAX__ #endif /* C99 5.2.4.2.1: Added long long. C++11 18.3.3.2: same contents as the Standard C Library header . */ #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L #undef LLONG_MIN #undef LLONG_MAX #undef ULLONG_MAX #define LLONG_MAX __LONG_LONG_MAX__ #define LLONG_MIN (-__LONG_LONG_MAX__-1LL) #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL) #endif /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad that we don't have something like #pragma poison that could be used to deprecate a macro - the code should just use LLONG_MAX and friends. */ #if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__) #undef LONG_LONG_MIN #undef LONG_LONG_MAX #undef ULONG_LONG_MAX #define LONG_LONG_MAX __LONG_LONG_MAX__ #define LONG_LONG_MIN (-__LONG_LONG_MAX__-1LL) #define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL) #endif #endif /* __CLANG_LIMITS_H */ bpftrace-0.27.1/src/stdlib/include/linux/000077500000000000000000000000001526721631600202325ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/linux/bpf.h000066400000000000000000010471101526721631600211560ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ #ifndef _UAPI__LINUX_BPF_H__ #define _UAPI__LINUX_BPF_H__ #include #include /* Extended instruction set based on top of classic BPF */ /* instruction classes */ #define BPF_JMP32 0x06 /* jmp mode in word width */ #define BPF_ALU64 0x07 /* alu mode in double word width */ /* ld/ldx fields */ #define BPF_DW 0x18 /* double word (64-bit) */ #define BPF_MEMSX 0x80 /* load with sign extension */ #define BPF_ATOMIC 0xc0 /* atomic memory ops - op type in immediate */ #define BPF_XADD 0xc0 /* exclusive add - legacy name */ /* alu/jmp fields */ #define BPF_MOV 0xb0 /* mov reg to reg */ #define BPF_ARSH 0xc0 /* sign extending arithmetic shift right */ /* change endianness of a register */ #define BPF_END 0xd0 /* flags for endianness conversion: */ #define BPF_TO_LE 0x00 /* convert to little-endian */ #define BPF_TO_BE 0x08 /* convert to big-endian */ #define BPF_FROM_LE BPF_TO_LE #define BPF_FROM_BE BPF_TO_BE /* jmp encodings */ #define BPF_JNE 0x50 /* jump != */ #define BPF_JLT 0xa0 /* LT is unsigned, '<' */ #define BPF_JLE 0xb0 /* LE is unsigned, '<=' */ #define BPF_JSGT 0x60 /* SGT is signed '>', GT in x86 */ #define BPF_JSGE 0x70 /* SGE is signed '>=', GE in x86 */ #define BPF_JSLT 0xc0 /* SLT is signed, '<' */ #define BPF_JSLE 0xd0 /* SLE is signed, '<=' */ #define BPF_JCOND 0xe0 /* conditional pseudo jumps: may_goto, goto_or_nop */ #define BPF_CALL 0x80 /* function call */ #define BPF_EXIT 0x90 /* function return */ /* atomic op type fields (stored in immediate) */ #define BPF_FETCH 0x01 /* not an opcode on its own, used to build others */ #define BPF_XCHG (0xe0 | BPF_FETCH) /* atomic exchange */ #define BPF_CMPXCHG (0xf0 | BPF_FETCH) /* atomic compare-and-write */ #define BPF_LOAD_ACQ 0x100 /* load-acquire */ #define BPF_STORE_REL 0x110 /* store-release */ enum bpf_cond_pseudo_jmp { BPF_MAY_GOTO = 0, }; /* Register numbers */ enum { BPF_REG_0 = 0, BPF_REG_1, BPF_REG_2, BPF_REG_3, BPF_REG_4, BPF_REG_5, BPF_REG_6, BPF_REG_7, BPF_REG_8, BPF_REG_9, BPF_REG_10, __MAX_BPF_REG, }; /* BPF has 10 general purpose 64-bit registers and stack frame. */ #define MAX_BPF_REG __MAX_BPF_REG struct bpf_insn { __u8 code; /* opcode */ __u8 dst_reg:4; /* dest register */ __u8 src_reg:4; /* source register */ __s16 off; /* signed offset */ __s32 imm; /* signed immediate constant */ }; /* Deprecated: use struct bpf_lpm_trie_key_u8 (when the "data" member is needed for * byte access) or struct bpf_lpm_trie_key_hdr (when using an alternative type for * the trailing flexible array member) instead. */ struct bpf_lpm_trie_key { __u32 prefixlen; /* up to 32 for AF_INET, 128 for AF_INET6 */ __u8 data[0]; /* Arbitrary size */ }; /* Header for bpf_lpm_trie_key structs */ struct bpf_lpm_trie_key_hdr { __u32 prefixlen; }; /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry, with trailing byte array. */ struct bpf_lpm_trie_key_u8 { union { struct bpf_lpm_trie_key_hdr hdr; __u32 prefixlen; }; __u8 data[]; /* Arbitrary size */ }; struct bpf_cgroup_storage_key { __u64 cgroup_inode_id; /* cgroup inode id */ __u32 attach_type; /* program attach type (enum bpf_attach_type) */ }; enum bpf_cgroup_iter_order { BPF_CGROUP_ITER_ORDER_UNSPEC = 0, BPF_CGROUP_ITER_SELF_ONLY, /* process only a single object. */ BPF_CGROUP_ITER_DESCENDANTS_PRE, /* walk descendants in pre-order. */ BPF_CGROUP_ITER_DESCENDANTS_POST, /* walk descendants in post-order. */ BPF_CGROUP_ITER_ANCESTORS_UP, /* walk ancestors upward. */ }; union bpf_iter_link_info { struct { __u32 map_fd; } map; struct { enum bpf_cgroup_iter_order order; /* At most one of cgroup_fd and cgroup_id can be non-zero. If * both are zero, the walk starts from the default cgroup v2 * root. For walking v1 hierarchy, one should always explicitly * specify cgroup_fd. */ __u32 cgroup_fd; __u64 cgroup_id; } cgroup; /* Parameters of task iterators. */ struct { __u32 tid; __u32 pid; __u32 pid_fd; } task; }; /* BPF syscall commands, see bpf(2) man-page for more details. */ /** * DOC: eBPF Syscall Preamble * * The operation to be performed by the **bpf**\ () system call is determined * by the *cmd* argument. Each operation takes an accompanying argument, * provided via *attr*, which is a pointer to a union of type *bpf_attr* (see * below). The size argument is the size of the union pointed to by *attr*. */ /** * DOC: eBPF Syscall Commands * * BPF_MAP_CREATE * Description * Create a map and return a file descriptor that refers to the * map. The close-on-exec file descriptor flag (see **fcntl**\ (2)) * is automatically enabled for the new file descriptor. * * Applying **close**\ (2) to the file descriptor returned by * **BPF_MAP_CREATE** will delete the map (but see NOTES). * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_MAP_LOOKUP_ELEM * Description * Look up an element with a given *key* in the map referred to * by the file descriptor *map_fd*. * * The *flags* argument may be specified as one of the * following: * * **BPF_F_LOCK** * Look up the value of a spin-locked map without * returning the lock. This must be specified if the * elements contain a spinlock. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_MAP_UPDATE_ELEM * Description * Create or update an element (key/value pair) in a specified map. * * The *flags* argument should be specified as one of the * following: * * **BPF_ANY** * Create a new element or update an existing element. * **BPF_NOEXIST** * Create a new element only if it did not exist. * **BPF_EXIST** * Update an existing element. * **BPF_F_LOCK** * Update a spin_lock-ed map element. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * May set *errno* to **EINVAL**, **EPERM**, **ENOMEM**, * **E2BIG**, **EEXIST**, or **ENOENT**. * * **E2BIG** * The number of elements in the map reached the * *max_entries* limit specified at map creation time. * **EEXIST** * If *flags* specifies **BPF_NOEXIST** and the element * with *key* already exists in the map. * **ENOENT** * If *flags* specifies **BPF_EXIST** and the element with * *key* does not exist in the map. * * BPF_MAP_DELETE_ELEM * Description * Look up and delete an element by key in a specified map. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_MAP_GET_NEXT_KEY * Description * Look up an element by key in a specified map and return the key * of the next element. Can be used to iterate over all elements * in the map. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * The following cases can be used to iterate over all elements of * the map: * * * If *key* is not found, the operation returns zero and sets * the *next_key* pointer to the key of the first element. * * If *key* is found, the operation returns zero and sets the * *next_key* pointer to the key of the next element. * * If *key* is the last element, returns -1 and *errno* is set * to **ENOENT**. * * May set *errno* to **ENOMEM**, **EFAULT**, **EPERM**, or * **EINVAL** on error. * * BPF_PROG_LOAD * Description * Verify and load an eBPF program, returning a new file * descriptor associated with the program. * * Applying **close**\ (2) to the file descriptor returned by * **BPF_PROG_LOAD** will unload the eBPF program (but see NOTES). * * The close-on-exec file descriptor flag (see **fcntl**\ (2)) is * automatically enabled for the new file descriptor. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_OBJ_PIN * Description * Pin an eBPF program or map referred by the specified *bpf_fd* * to the provided *pathname* on the filesystem. * * The *pathname* argument must not contain a dot ("."). * * On success, *pathname* retains a reference to the eBPF object, * preventing deallocation of the object when the original * *bpf_fd* is closed. This allow the eBPF object to live beyond * **close**\ (\ *bpf_fd*\ ), and hence the lifetime of the parent * process. * * Applying **unlink**\ (2) or similar calls to the *pathname* * unpins the object from the filesystem, removing the reference. * If no other file descriptors or filesystem nodes refer to the * same object, it will be deallocated (see NOTES). * * The filesystem type for the parent directory of *pathname* must * be **BPF_FS_MAGIC**. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_OBJ_GET * Description * Open a file descriptor for the eBPF object pinned to the * specified *pathname*. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_PROG_ATTACH * Description * Attach an eBPF program to a *target_fd* at the specified * *attach_type* hook. * * The *attach_type* specifies the eBPF attachment point to * attach the program to, and must be one of *bpf_attach_type* * (see below). * * The *attach_bpf_fd* must be a valid file descriptor for a * loaded eBPF program of a cgroup, flow dissector, LIRC, sockmap * or sock_ops type corresponding to the specified *attach_type*. * * The *target_fd* must be a valid file descriptor for a kernel * object which depends on the attach type of *attach_bpf_fd*: * * **BPF_PROG_TYPE_CGROUP_DEVICE**, * **BPF_PROG_TYPE_CGROUP_SKB**, * **BPF_PROG_TYPE_CGROUP_SOCK**, * **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, * **BPF_PROG_TYPE_CGROUP_SOCKOPT**, * **BPF_PROG_TYPE_CGROUP_SYSCTL**, * **BPF_PROG_TYPE_SOCK_OPS** * * Control Group v2 hierarchy with the eBPF controller * enabled. Requires the kernel to be compiled with * **CONFIG_CGROUP_BPF**. * * **BPF_PROG_TYPE_FLOW_DISSECTOR** * * Network namespace (eg /proc/self/ns/net). * * **BPF_PROG_TYPE_LIRC_MODE2** * * LIRC device path (eg /dev/lircN). Requires the kernel * to be compiled with **CONFIG_BPF_LIRC_MODE2**. * * **BPF_PROG_TYPE_SK_SKB**, * **BPF_PROG_TYPE_SK_MSG** * * eBPF map of socket type (eg **BPF_MAP_TYPE_SOCKHASH**). * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_PROG_DETACH * Description * Detach the eBPF program associated with the *target_fd* at the * hook specified by *attach_type*. The program must have been * previously attached using **BPF_PROG_ATTACH**. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_PROG_TEST_RUN * Description * Run the eBPF program associated with the *prog_fd* a *repeat* * number of times against a provided program context *ctx_in* and * data *data_in*, and return the modified program context * *ctx_out*, *data_out* (for example, packet data), result of the * execution *retval*, and *duration* of the test run. * * The sizes of the buffers provided as input and output * parameters *ctx_in*, *ctx_out*, *data_in*, and *data_out* must * be provided in the corresponding variables *ctx_size_in*, * *ctx_size_out*, *data_size_in*, and/or *data_size_out*. If any * of these parameters are not provided (ie set to NULL), the * corresponding size field must be zero. * * Some program types have particular requirements: * * **BPF_PROG_TYPE_SK_LOOKUP** * *data_in* and *data_out* must be NULL. * * **BPF_PROG_TYPE_RAW_TRACEPOINT**, * **BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE** * * *ctx_out*, *data_in* and *data_out* must be NULL. * *repeat* must be zero. * * BPF_PROG_RUN is an alias for BPF_PROG_TEST_RUN. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * **ENOSPC** * Either *data_size_out* or *ctx_size_out* is too small. * **ENOTSUPP** * This command is not supported by the program type of * the program referred to by *prog_fd*. * * BPF_PROG_GET_NEXT_ID * Description * Fetch the next eBPF program currently loaded into the kernel. * * Looks for the eBPF program with an id greater than *start_id* * and updates *next_id* on success. If no other eBPF programs * remain with ids higher than *start_id*, returns -1 and sets * *errno* to **ENOENT**. * * Return * Returns zero on success. On error, or when no id remains, -1 * is returned and *errno* is set appropriately. * * BPF_MAP_GET_NEXT_ID * Description * Fetch the next eBPF map currently loaded into the kernel. * * Looks for the eBPF map with an id greater than *start_id* * and updates *next_id* on success. If no other eBPF maps * remain with ids higher than *start_id*, returns -1 and sets * *errno* to **ENOENT**. * * Return * Returns zero on success. On error, or when no id remains, -1 * is returned and *errno* is set appropriately. * * BPF_PROG_GET_FD_BY_ID * Description * Open a file descriptor for the eBPF program corresponding to * *prog_id*. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_MAP_GET_FD_BY_ID * Description * Open a file descriptor for the eBPF map corresponding to * *map_id*. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_OBJ_GET_INFO_BY_FD * Description * Obtain information about the eBPF object corresponding to * *bpf_fd*. * * Populates up to *info_len* bytes of *info*, which will be in * one of the following formats depending on the eBPF object type * of *bpf_fd*: * * * **struct bpf_prog_info** * * **struct bpf_map_info** * * **struct bpf_btf_info** * * **struct bpf_link_info** * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_PROG_QUERY * Description * Obtain information about eBPF programs associated with the * specified *attach_type* hook. * * The *target_fd* must be a valid file descriptor for a kernel * object which depends on the attach type of *attach_bpf_fd*: * * **BPF_PROG_TYPE_CGROUP_DEVICE**, * **BPF_PROG_TYPE_CGROUP_SKB**, * **BPF_PROG_TYPE_CGROUP_SOCK**, * **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, * **BPF_PROG_TYPE_CGROUP_SOCKOPT**, * **BPF_PROG_TYPE_CGROUP_SYSCTL**, * **BPF_PROG_TYPE_SOCK_OPS** * * Control Group v2 hierarchy with the eBPF controller * enabled. Requires the kernel to be compiled with * **CONFIG_CGROUP_BPF**. * * **BPF_PROG_TYPE_FLOW_DISSECTOR** * * Network namespace (eg /proc/self/ns/net). * * **BPF_PROG_TYPE_LIRC_MODE2** * * LIRC device path (eg /dev/lircN). Requires the kernel * to be compiled with **CONFIG_BPF_LIRC_MODE2**. * * **BPF_PROG_QUERY** always fetches the number of programs * attached and the *attach_flags* which were used to attach those * programs. Additionally, if *prog_ids* is nonzero and the number * of attached programs is less than *prog_cnt*, populates * *prog_ids* with the eBPF program ids of the programs attached * at *target_fd*. * * The following flags may alter the result: * * **BPF_F_QUERY_EFFECTIVE** * Only return information regarding programs which are * currently effective at the specified *target_fd*. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_RAW_TRACEPOINT_OPEN * Description * Attach an eBPF program to a tracepoint *name* to access kernel * internal arguments of the tracepoint in their raw form. * * The *prog_fd* must be a valid file descriptor associated with * a loaded eBPF program of type **BPF_PROG_TYPE_RAW_TRACEPOINT**. * * No ABI guarantees are made about the content of tracepoint * arguments exposed to the corresponding eBPF program. * * Applying **close**\ (2) to the file descriptor returned by * **BPF_RAW_TRACEPOINT_OPEN** will delete the map (but see NOTES). * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_BTF_LOAD * Description * Verify and load BPF Type Format (BTF) metadata into the kernel, * returning a new file descriptor associated with the metadata. * BTF is described in more detail at * https://www.kernel.org/doc/html/latest/bpf/btf.html. * * The *btf* parameter must point to valid memory providing * *btf_size* bytes of BTF binary metadata. * * The returned file descriptor can be passed to other **bpf**\ () * subcommands such as **BPF_PROG_LOAD** or **BPF_MAP_CREATE** to * associate the BTF with those objects. * * Similar to **BPF_PROG_LOAD**, **BPF_BTF_LOAD** has optional * parameters to specify a *btf_log_buf*, *btf_log_size* and * *btf_log_level* which allow the kernel to return freeform log * output regarding the BTF verification process. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_BTF_GET_FD_BY_ID * Description * Open a file descriptor for the BPF Type Format (BTF) * corresponding to *btf_id*. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_TASK_FD_QUERY * Description * Obtain information about eBPF programs associated with the * target process identified by *pid* and *fd*. * * If the *pid* and *fd* are associated with a tracepoint, kprobe * or uprobe perf event, then the *prog_id* and *fd_type* will * be populated with the eBPF program id and file descriptor type * of type **bpf_task_fd_type**. If associated with a kprobe or * uprobe, the *probe_offset* and *probe_addr* will also be * populated. Optionally, if *buf* is provided, then up to * *buf_len* bytes of *buf* will be populated with the name of * the tracepoint, kprobe or uprobe. * * The resulting *prog_id* may be introspected in deeper detail * using **BPF_PROG_GET_FD_BY_ID** and **BPF_OBJ_GET_INFO_BY_FD**. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_MAP_LOOKUP_AND_DELETE_ELEM * Description * Look up an element with the given *key* in the map referred to * by the file descriptor *fd*, and if found, delete the element. * * For **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map * types, the *flags* argument needs to be set to 0, but for other * map types, it may be specified as: * * **BPF_F_LOCK** * Look up and delete the value of a spin-locked map * without returning the lock. This must be specified if * the elements contain a spinlock. * * The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types * implement this command as a "pop" operation, deleting the top * element rather than one corresponding to *key*. * The *key* and *key_len* parameters should be zeroed when * issuing this operation for these map types. * * This command is only valid for the following map types: * * **BPF_MAP_TYPE_QUEUE** * * **BPF_MAP_TYPE_STACK** * * **BPF_MAP_TYPE_HASH** * * **BPF_MAP_TYPE_PERCPU_HASH** * * **BPF_MAP_TYPE_LRU_HASH** * * **BPF_MAP_TYPE_LRU_PERCPU_HASH** * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_MAP_FREEZE * Description * Freeze the permissions of the specified map. * * Write permissions may be frozen by passing zero *flags*. * Upon success, no future syscall invocations may alter the * map state of *map_fd*. Write operations from eBPF programs * are still possible for a frozen map. * * Not supported for maps of type **BPF_MAP_TYPE_STRUCT_OPS**. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_BTF_GET_NEXT_ID * Description * Fetch the next BPF Type Format (BTF) object currently loaded * into the kernel. * * Looks for the BTF object with an id greater than *start_id* * and updates *next_id* on success. If no other BTF objects * remain with ids higher than *start_id*, returns -1 and sets * *errno* to **ENOENT**. * * Return * Returns zero on success. On error, or when no id remains, -1 * is returned and *errno* is set appropriately. * * BPF_MAP_LOOKUP_BATCH * Description * Iterate and fetch multiple elements in a map. * * Two opaque values are used to manage batch operations, * *in_batch* and *out_batch*. Initially, *in_batch* must be set * to NULL to begin the batched operation. After each subsequent * **BPF_MAP_LOOKUP_BATCH**, the caller should pass the resultant * *out_batch* as the *in_batch* for the next operation to * continue iteration from the current point. Both *in_batch* and * *out_batch* must point to memory large enough to hold a key, * except for maps of type **BPF_MAP_TYPE_{HASH, PERCPU_HASH, * LRU_HASH, LRU_PERCPU_HASH}**, for which batch parameters * must be at least 4 bytes wide regardless of key size. * * The *keys* and *values* are output parameters which must point * to memory large enough to hold *count* items based on the key * and value size of the map *map_fd*. The *keys* buffer must be * of *key_size* * *count*. The *values* buffer must be of * *value_size* * *count*. * * The *elem_flags* argument may be specified as one of the * following: * * **BPF_F_LOCK** * Look up the value of a spin-locked map without * returning the lock. This must be specified if the * elements contain a spinlock. * * On success, *count* elements from the map are copied into the * user buffer, with the keys copied into *keys* and the values * copied into the corresponding indices in *values*. * * If an error is returned and *errno* is not **EFAULT**, *count* * is set to the number of successfully processed elements. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * May set *errno* to **ENOSPC** to indicate that *keys* or * *values* is too small to dump an entire bucket during * iteration of a hash-based map type. * * BPF_MAP_LOOKUP_AND_DELETE_BATCH * Description * Iterate and delete all elements in a map. * * This operation has the same behavior as * **BPF_MAP_LOOKUP_BATCH** with two exceptions: * * * Every element that is successfully returned is also deleted * from the map. This is at least *count* elements. Note that * *count* is both an input and an output parameter. * * Upon returning with *errno* set to **EFAULT**, up to * *count* elements may be deleted without returning the keys * and values of the deleted elements. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_MAP_UPDATE_BATCH * Description * Update multiple elements in a map by *key*. * * The *keys* and *values* are input parameters which must point * to memory large enough to hold *count* items based on the key * and value size of the map *map_fd*. The *keys* buffer must be * of *key_size* * *count*. The *values* buffer must be of * *value_size* * *count*. * * Each element specified in *keys* is sequentially updated to the * value in the corresponding index in *values*. The *in_batch* * and *out_batch* parameters are ignored and should be zeroed. * * The *elem_flags* argument should be specified as one of the * following: * * **BPF_ANY** * Create new elements or update a existing elements. * **BPF_NOEXIST** * Create new elements only if they do not exist. * **BPF_EXIST** * Update existing elements. * **BPF_F_LOCK** * Update spin_lock-ed map elements. This must be * specified if the map value contains a spinlock. * * On success, *count* elements from the map are updated. * * If an error is returned and *errno* is not **EFAULT**, *count* * is set to the number of successfully processed elements. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * May set *errno* to **EINVAL**, **EPERM**, **ENOMEM**, or * **E2BIG**. **E2BIG** indicates that the number of elements in * the map reached the *max_entries* limit specified at map * creation time. * * May set *errno* to one of the following error codes under * specific circumstances: * * **EEXIST** * If *flags* specifies **BPF_NOEXIST** and the element * with *key* already exists in the map. * **ENOENT** * If *flags* specifies **BPF_EXIST** and the element with * *key* does not exist in the map. * * BPF_MAP_DELETE_BATCH * Description * Delete multiple elements in a map by *key*. * * The *keys* parameter is an input parameter which must point * to memory large enough to hold *count* items based on the key * size of the map *map_fd*, that is, *key_size* * *count*. * * Each element specified in *keys* is sequentially deleted. The * *in_batch*, *out_batch*, and *values* parameters are ignored * and should be zeroed. * * The *elem_flags* argument may be specified as one of the * following: * * **BPF_F_LOCK** * Look up the value of a spin-locked map without * returning the lock. This must be specified if the * elements contain a spinlock. * * On success, *count* elements from the map are updated. * * If an error is returned and *errno* is not **EFAULT**, *count* * is set to the number of successfully processed elements. If * *errno* is **EFAULT**, up to *count* elements may be been * deleted. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_LINK_CREATE * Description * Attach an eBPF program to a *target_fd* at the specified * *attach_type* hook and return a file descriptor handle for * managing the link. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_LINK_UPDATE * Description * Update the eBPF program in the specified *link_fd* to * *new_prog_fd*. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_LINK_GET_FD_BY_ID * Description * Open a file descriptor for the eBPF Link corresponding to * *link_id*. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_LINK_GET_NEXT_ID * Description * Fetch the next eBPF link currently loaded into the kernel. * * Looks for the eBPF link with an id greater than *start_id* * and updates *next_id* on success. If no other eBPF links * remain with ids higher than *start_id*, returns -1 and sets * *errno* to **ENOENT**. * * Return * Returns zero on success. On error, or when no id remains, -1 * is returned and *errno* is set appropriately. * * BPF_ENABLE_STATS * Description * Enable eBPF runtime statistics gathering. * * Runtime statistics gathering for the eBPF runtime is disabled * by default to minimize the corresponding performance overhead. * This command enables statistics globally. * * Multiple programs may independently enable statistics. * After gathering the desired statistics, eBPF runtime statistics * may be disabled again by calling **close**\ (2) for the file * descriptor returned by this function. Statistics will only be * disabled system-wide when all outstanding file descriptors * returned by prior calls for this subcommand are closed. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_ITER_CREATE * Description * Create an iterator on top of the specified *link_fd* (as * previously created using **BPF_LINK_CREATE**) and return a * file descriptor that can be used to trigger the iteration. * * If the resulting file descriptor is pinned to the filesystem * using **BPF_OBJ_PIN**, then subsequent **read**\ (2) syscalls * for that path will trigger the iterator to read kernel state * using the eBPF program attached to *link_fd*. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * BPF_LINK_DETACH * Description * Forcefully detach the specified *link_fd* from its * corresponding attachment point. * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_PROG_BIND_MAP * Description * Bind a map to the lifetime of an eBPF program. * * The map identified by *map_fd* is bound to the program * identified by *prog_fd* and only released when *prog_fd* is * released. This may be used in cases where metadata should be * associated with a program which otherwise does not contain any * references to the map (for example, embedded in the eBPF * program instructions). * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. * * BPF_TOKEN_CREATE * Description * Create BPF token with embedded information about what * BPF-related functionality it allows: * - a set of allowed bpf() syscall commands; * - a set of allowed BPF map types to be created with * BPF_MAP_CREATE command, if BPF_MAP_CREATE itself is allowed; * - a set of allowed BPF program types and BPF program attach * types to be loaded with BPF_PROG_LOAD command, if * BPF_PROG_LOAD itself is allowed. * * BPF token is created (derived) from an instance of BPF FS, * assuming it has necessary delegation mount options specified. * This BPF token can be passed as an extra parameter to various * bpf() syscall commands to grant BPF subsystem functionality to * unprivileged processes. * * When created, BPF token is "associated" with the owning * user namespace of BPF FS instance (super block) that it was * derived from, and subsequent BPF operations performed with * BPF token would be performing capabilities checks (i.e., * CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, CAP_SYS_ADMIN) within * that user namespace. Without BPF token, such capabilities * have to be granted in init user namespace, making bpf() * syscall incompatible with user namespace, for the most part. * * Return * A new file descriptor (a nonnegative integer), or -1 if an * error occurred (in which case, *errno* is set appropriately). * * NOTES * eBPF objects (maps and programs) can be shared between processes. * * * After **fork**\ (2), the child inherits file descriptors * referring to the same eBPF objects. * * File descriptors referring to eBPF objects can be transferred over * **unix**\ (7) domain sockets. * * File descriptors referring to eBPF objects can be duplicated in the * usual way, using **dup**\ (2) and similar calls. * * File descriptors referring to eBPF objects can be pinned to the * filesystem using the **BPF_OBJ_PIN** command of **bpf**\ (2). * * An eBPF object is deallocated only after all file descriptors referring * to the object have been closed and no references remain pinned to the * filesystem or attached (for example, bound to a program or device). */ enum bpf_cmd { BPF_MAP_CREATE, BPF_MAP_LOOKUP_ELEM, BPF_MAP_UPDATE_ELEM, BPF_MAP_DELETE_ELEM, BPF_MAP_GET_NEXT_KEY, BPF_PROG_LOAD, BPF_OBJ_PIN, BPF_OBJ_GET, BPF_PROG_ATTACH, BPF_PROG_DETACH, BPF_PROG_TEST_RUN, BPF_PROG_RUN = BPF_PROG_TEST_RUN, BPF_PROG_GET_NEXT_ID, BPF_MAP_GET_NEXT_ID, BPF_PROG_GET_FD_BY_ID, BPF_MAP_GET_FD_BY_ID, BPF_OBJ_GET_INFO_BY_FD, BPF_PROG_QUERY, BPF_RAW_TRACEPOINT_OPEN, BPF_BTF_LOAD, BPF_BTF_GET_FD_BY_ID, BPF_TASK_FD_QUERY, BPF_MAP_LOOKUP_AND_DELETE_ELEM, BPF_MAP_FREEZE, BPF_BTF_GET_NEXT_ID, BPF_MAP_LOOKUP_BATCH, BPF_MAP_LOOKUP_AND_DELETE_BATCH, BPF_MAP_UPDATE_BATCH, BPF_MAP_DELETE_BATCH, BPF_LINK_CREATE, BPF_LINK_UPDATE, BPF_LINK_GET_FD_BY_ID, BPF_LINK_GET_NEXT_ID, BPF_ENABLE_STATS, BPF_ITER_CREATE, BPF_LINK_DETACH, BPF_PROG_BIND_MAP, BPF_TOKEN_CREATE, __MAX_BPF_CMD, }; enum bpf_map_type { BPF_MAP_TYPE_UNSPEC, BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_ARRAY, BPF_MAP_TYPE_PROG_ARRAY, BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_MAP_TYPE_PERCPU_HASH, BPF_MAP_TYPE_PERCPU_ARRAY, BPF_MAP_TYPE_STACK_TRACE, BPF_MAP_TYPE_CGROUP_ARRAY, BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, BPF_MAP_TYPE_LPM_TRIE, BPF_MAP_TYPE_ARRAY_OF_MAPS, BPF_MAP_TYPE_HASH_OF_MAPS, BPF_MAP_TYPE_DEVMAP, BPF_MAP_TYPE_SOCKMAP, BPF_MAP_TYPE_CPUMAP, BPF_MAP_TYPE_XSKMAP, BPF_MAP_TYPE_SOCKHASH, BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED, /* BPF_MAP_TYPE_CGROUP_STORAGE is available to bpf programs attaching * to a cgroup. The newer BPF_MAP_TYPE_CGRP_STORAGE is available to * both cgroup-attached and other progs and supports all functionality * provided by BPF_MAP_TYPE_CGROUP_STORAGE. So mark * BPF_MAP_TYPE_CGROUP_STORAGE deprecated. */ BPF_MAP_TYPE_CGROUP_STORAGE = BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED, /* BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE is available to bpf programs * attaching to a cgroup. The new mechanism (BPF_MAP_TYPE_CGRP_STORAGE + * local percpu kptr) supports all BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE * functionality and more. So mark * BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE * deprecated. */ BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED, BPF_MAP_TYPE_QUEUE, BPF_MAP_TYPE_STACK, BPF_MAP_TYPE_SK_STORAGE, BPF_MAP_TYPE_DEVMAP_HASH, BPF_MAP_TYPE_STRUCT_OPS, BPF_MAP_TYPE_RINGBUF, BPF_MAP_TYPE_INODE_STORAGE, BPF_MAP_TYPE_TASK_STORAGE, BPF_MAP_TYPE_BLOOM_FILTER, BPF_MAP_TYPE_USER_RINGBUF, BPF_MAP_TYPE_CGRP_STORAGE, BPF_MAP_TYPE_ARENA, __MAX_BPF_MAP_TYPE }; /* Note that tracing related programs such as * BPF_PROG_TYPE_{KPROBE,TRACEPOINT,PERF_EVENT,RAW_TRACEPOINT} * are not subject to a stable API since kernel internal data * structures can change from release to release and may * therefore break existing tracing BPF programs. Tracing BPF * programs correspond to /a/ specific kernel which is to be * analyzed, and not /a/ specific kernel /and/ all future ones. */ enum bpf_prog_type { BPF_PROG_TYPE_UNSPEC, BPF_PROG_TYPE_SOCKET_FILTER, BPF_PROG_TYPE_KPROBE, BPF_PROG_TYPE_SCHED_CLS, BPF_PROG_TYPE_SCHED_ACT, BPF_PROG_TYPE_TRACEPOINT, BPF_PROG_TYPE_XDP, BPF_PROG_TYPE_PERF_EVENT, BPF_PROG_TYPE_CGROUP_SKB, BPF_PROG_TYPE_CGROUP_SOCK, BPF_PROG_TYPE_LWT_IN, BPF_PROG_TYPE_LWT_OUT, BPF_PROG_TYPE_LWT_XMIT, BPF_PROG_TYPE_SOCK_OPS, BPF_PROG_TYPE_SK_SKB, BPF_PROG_TYPE_CGROUP_DEVICE, BPF_PROG_TYPE_SK_MSG, BPF_PROG_TYPE_RAW_TRACEPOINT, BPF_PROG_TYPE_CGROUP_SOCK_ADDR, BPF_PROG_TYPE_LWT_SEG6LOCAL, BPF_PROG_TYPE_LIRC_MODE2, BPF_PROG_TYPE_SK_REUSEPORT, BPF_PROG_TYPE_FLOW_DISSECTOR, BPF_PROG_TYPE_CGROUP_SYSCTL, BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE, BPF_PROG_TYPE_CGROUP_SOCKOPT, BPF_PROG_TYPE_TRACING, BPF_PROG_TYPE_STRUCT_OPS, BPF_PROG_TYPE_EXT, BPF_PROG_TYPE_LSM, BPF_PROG_TYPE_SK_LOOKUP, BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */ BPF_PROG_TYPE_NETFILTER, __MAX_BPF_PROG_TYPE }; enum bpf_attach_type { BPF_CGROUP_INET_INGRESS, BPF_CGROUP_INET_EGRESS, BPF_CGROUP_INET_SOCK_CREATE, BPF_CGROUP_SOCK_OPS, BPF_SK_SKB_STREAM_PARSER, BPF_SK_SKB_STREAM_VERDICT, BPF_CGROUP_DEVICE, BPF_SK_MSG_VERDICT, BPF_CGROUP_INET4_BIND, BPF_CGROUP_INET6_BIND, BPF_CGROUP_INET4_CONNECT, BPF_CGROUP_INET6_CONNECT, BPF_CGROUP_INET4_POST_BIND, BPF_CGROUP_INET6_POST_BIND, BPF_CGROUP_UDP4_SENDMSG, BPF_CGROUP_UDP6_SENDMSG, BPF_LIRC_MODE2, BPF_FLOW_DISSECTOR, BPF_CGROUP_SYSCTL, BPF_CGROUP_UDP4_RECVMSG, BPF_CGROUP_UDP6_RECVMSG, BPF_CGROUP_GETSOCKOPT, BPF_CGROUP_SETSOCKOPT, BPF_TRACE_RAW_TP, BPF_TRACE_FENTRY, BPF_TRACE_FEXIT, BPF_MODIFY_RETURN, BPF_LSM_MAC, BPF_TRACE_ITER, BPF_CGROUP_INET4_GETPEERNAME, BPF_CGROUP_INET6_GETPEERNAME, BPF_CGROUP_INET4_GETSOCKNAME, BPF_CGROUP_INET6_GETSOCKNAME, BPF_XDP_DEVMAP, BPF_CGROUP_INET_SOCK_RELEASE, BPF_XDP_CPUMAP, BPF_SK_LOOKUP, BPF_XDP, BPF_SK_SKB_VERDICT, BPF_SK_REUSEPORT_SELECT, BPF_SK_REUSEPORT_SELECT_OR_MIGRATE, BPF_PERF_EVENT, BPF_TRACE_KPROBE_MULTI, BPF_LSM_CGROUP, BPF_STRUCT_OPS, BPF_NETFILTER, BPF_TCX_INGRESS, BPF_TCX_EGRESS, BPF_TRACE_UPROBE_MULTI, BPF_CGROUP_UNIX_CONNECT, BPF_CGROUP_UNIX_SENDMSG, BPF_CGROUP_UNIX_RECVMSG, BPF_CGROUP_UNIX_GETPEERNAME, BPF_CGROUP_UNIX_GETSOCKNAME, BPF_NETKIT_PRIMARY, BPF_NETKIT_PEER, BPF_TRACE_KPROBE_SESSION, BPF_TRACE_UPROBE_SESSION, __MAX_BPF_ATTACH_TYPE }; #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE /* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[] * in sync with the definitions below. */ enum bpf_link_type { BPF_LINK_TYPE_UNSPEC = 0, BPF_LINK_TYPE_RAW_TRACEPOINT = 1, BPF_LINK_TYPE_TRACING = 2, BPF_LINK_TYPE_CGROUP = 3, BPF_LINK_TYPE_ITER = 4, BPF_LINK_TYPE_NETNS = 5, BPF_LINK_TYPE_XDP = 6, BPF_LINK_TYPE_PERF_EVENT = 7, BPF_LINK_TYPE_KPROBE_MULTI = 8, BPF_LINK_TYPE_STRUCT_OPS = 9, BPF_LINK_TYPE_NETFILTER = 10, BPF_LINK_TYPE_TCX = 11, BPF_LINK_TYPE_UPROBE_MULTI = 12, BPF_LINK_TYPE_NETKIT = 13, BPF_LINK_TYPE_SOCKMAP = 14, __MAX_BPF_LINK_TYPE, }; #define MAX_BPF_LINK_TYPE __MAX_BPF_LINK_TYPE enum bpf_perf_event_type { BPF_PERF_EVENT_UNSPEC = 0, BPF_PERF_EVENT_UPROBE = 1, BPF_PERF_EVENT_URETPROBE = 2, BPF_PERF_EVENT_KPROBE = 3, BPF_PERF_EVENT_KRETPROBE = 4, BPF_PERF_EVENT_TRACEPOINT = 5, BPF_PERF_EVENT_EVENT = 6, }; /* cgroup-bpf attach flags used in BPF_PROG_ATTACH command * * NONE(default): No further bpf programs allowed in the subtree. * * BPF_F_ALLOW_OVERRIDE: If a sub-cgroup installs some bpf program, * the program in this cgroup yields to sub-cgroup program. * * BPF_F_ALLOW_MULTI: If a sub-cgroup installs some bpf program, * that cgroup program gets run in addition to the program in this cgroup. * * Only one program is allowed to be attached to a cgroup with * NONE or BPF_F_ALLOW_OVERRIDE flag. * Attaching another program on top of NONE or BPF_F_ALLOW_OVERRIDE will * release old program and attach the new one. Attach flags has to match. * * Multiple programs are allowed to be attached to a cgroup with * BPF_F_ALLOW_MULTI flag. They are executed in FIFO order * (those that were attached first, run first) * The programs of sub-cgroup are executed first, then programs of * this cgroup and then programs of parent cgroup. * When children program makes decision (like picking TCP CA or sock bind) * parent program has a chance to override it. * * With BPF_F_ALLOW_MULTI a new program is added to the end of the list of * programs for a cgroup. Though it's possible to replace an old program at * any position by also specifying BPF_F_REPLACE flag and position itself in * replace_bpf_fd attribute. Old program at this position will be released. * * A cgroup with MULTI or OVERRIDE flag allows any attach flags in sub-cgroups. * A cgroup with NONE doesn't allow any programs in sub-cgroups. * Ex1: * cgrp1 (MULTI progs A, B) -> * cgrp2 (OVERRIDE prog C) -> * cgrp3 (MULTI prog D) -> * cgrp4 (OVERRIDE prog E) -> * cgrp5 (NONE prog F) * the event in cgrp5 triggers execution of F,D,A,B in that order. * if prog F is detached, the execution is E,D,A,B * if prog F and D are detached, the execution is E,A,B * if prog F, E and D are detached, the execution is C,A,B * * All eligible programs are executed regardless of return code from * earlier programs. */ #define BPF_F_ALLOW_OVERRIDE (1U << 0) #define BPF_F_ALLOW_MULTI (1U << 1) /* Generic attachment flags. */ #define BPF_F_REPLACE (1U << 2) #define BPF_F_BEFORE (1U << 3) #define BPF_F_AFTER (1U << 4) #define BPF_F_ID (1U << 5) #define BPF_F_PREORDER (1U << 6) #define BPF_F_LINK BPF_F_LINK /* 1 << 13 */ /* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the * verifier will perform strict alignment checking as if the kernel * has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set, * and NET_IP_ALIGN defined to 2. */ #define BPF_F_STRICT_ALIGNMENT (1U << 0) /* If BPF_F_ANY_ALIGNMENT is used in BPF_PROG_LOAD command, the * verifier will allow any alignment whatsoever. On platforms * with strict alignment requirements for loads ands stores (such * as sparc and mips) the verifier validates that all loads and * stores provably follow this requirement. This flag turns that * checking and enforcement off. * * It is mostly used for testing when we want to validate the * context and memory access aspects of the verifier, but because * of an unaligned access the alignment check would trigger before * the one we are interested in. */ #define BPF_F_ANY_ALIGNMENT (1U << 1) /* BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose. * Verifier does sub-register def/use analysis and identifies instructions whose * def only matters for low 32-bit, high 32-bit is never referenced later * through implicit zero extension. Therefore verifier notifies JIT back-ends * that it is safe to ignore clearing high 32-bit for these instructions. This * saves some back-ends a lot of code-gen. However such optimization is not * necessary on some arches, for example x86_64, arm64 etc, whose JIT back-ends * hence hasn't used verifier's analysis result. But, we really want to have a * way to be able to verify the correctness of the described optimization on * x86_64 on which testsuites are frequently exercised. * * So, this flag is introduced. Once it is set, verifier will randomize high * 32-bit for those instructions who has been identified as safe to ignore them. * Then, if verifier is not doing correct analysis, such randomization will * regress tests to expose bugs. */ #define BPF_F_TEST_RND_HI32 (1U << 2) /* The verifier internal test flag. Behavior is undefined */ #define BPF_F_TEST_STATE_FREQ (1U << 3) /* If BPF_F_SLEEPABLE is used in BPF_PROG_LOAD command, the verifier will * restrict map and helper usage for such programs. Sleepable BPF programs can * only be attached to hooks where kernel execution context allows sleeping. * Such programs are allowed to use helpers that may sleep like * bpf_copy_from_user(). */ #define BPF_F_SLEEPABLE (1U << 4) /* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program * fully support xdp frags. */ #define BPF_F_XDP_HAS_FRAGS (1U << 5) /* If BPF_F_XDP_DEV_BOUND_ONLY is used in BPF_PROG_LOAD command, the loaded * program becomes device-bound but can access XDP metadata. */ #define BPF_F_XDP_DEV_BOUND_ONLY (1U << 6) /* The verifier internal test flag. Behavior is undefined */ #define BPF_F_TEST_REG_INVARIANTS (1U << 7) /* link_create.kprobe_multi.flags used in LINK_CREATE command for * BPF_TRACE_KPROBE_MULTI attach type to create return probe. */ enum { BPF_F_KPROBE_MULTI_RETURN = (1U << 0) }; /* link_create.uprobe_multi.flags used in LINK_CREATE command for * BPF_TRACE_UPROBE_MULTI attach type to create return probe. */ enum { BPF_F_UPROBE_MULTI_RETURN = (1U << 0) }; /* link_create.netfilter.flags used in LINK_CREATE command for * BPF_PROG_TYPE_NETFILTER to enable IP packet defragmentation. */ #define BPF_F_NETFILTER_IP_DEFRAG (1U << 0) /* When BPF ldimm64's insn[0].src_reg != 0 then this can have * the following extensions: * * insn[0].src_reg: BPF_PSEUDO_MAP_[FD|IDX] * insn[0].imm: map fd or fd_idx * insn[1].imm: 0 * insn[0].off: 0 * insn[1].off: 0 * ldimm64 rewrite: address of map * verifier type: CONST_PTR_TO_MAP */ #define BPF_PSEUDO_MAP_FD 1 #define BPF_PSEUDO_MAP_IDX 5 /* insn[0].src_reg: BPF_PSEUDO_MAP_[IDX_]VALUE * insn[0].imm: map fd or fd_idx * insn[1].imm: offset into value * insn[0].off: 0 * insn[1].off: 0 * ldimm64 rewrite: address of map[0]+offset * verifier type: PTR_TO_MAP_VALUE */ #define BPF_PSEUDO_MAP_VALUE 2 #define BPF_PSEUDO_MAP_IDX_VALUE 6 /* insn[0].src_reg: BPF_PSEUDO_BTF_ID * insn[0].imm: kernel btd id of VAR * insn[1].imm: 0 * insn[0].off: 0 * insn[1].off: 0 * ldimm64 rewrite: address of the kernel variable * verifier type: PTR_TO_BTF_ID or PTR_TO_MEM, depending on whether the var * is struct/union. */ #define BPF_PSEUDO_BTF_ID 3 /* insn[0].src_reg: BPF_PSEUDO_FUNC * insn[0].imm: insn offset to the func * insn[1].imm: 0 * insn[0].off: 0 * insn[1].off: 0 * ldimm64 rewrite: address of the function * verifier type: PTR_TO_FUNC. */ #define BPF_PSEUDO_FUNC 4 /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative * offset to another bpf function */ #define BPF_PSEUDO_CALL 1 /* when bpf_call->src_reg == BPF_PSEUDO_KFUNC_CALL, * bpf_call->imm == btf_id of a BTF_KIND_FUNC in the running kernel */ #define BPF_PSEUDO_KFUNC_CALL 2 enum bpf_addr_space_cast { BPF_ADDR_SPACE_CAST = 1, }; /* flags for BPF_MAP_UPDATE_ELEM command */ enum { BPF_ANY = 0, /* create new element or update existing */ BPF_NOEXIST = 1, /* create new element if it didn't exist */ BPF_EXIST = 2, /* update existing element */ BPF_F_LOCK = 4, /* spin_lock-ed map_lookup/map_update */ }; /* flags for BPF_MAP_CREATE command */ enum { BPF_F_NO_PREALLOC = (1U << 0), /* Instead of having one common LRU list in the * BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list * which can scale and perform better. * Note, the LRU nodes (including free nodes) cannot be moved * across different LRU lists. */ BPF_F_NO_COMMON_LRU = (1U << 1), /* Specify numa node during map creation */ BPF_F_NUMA_NODE = (1U << 2), /* Flags for accessing BPF object from syscall side. */ BPF_F_RDONLY = (1U << 3), BPF_F_WRONLY = (1U << 4), /* Flag for stack_map, store build_id+offset instead of pointer */ BPF_F_STACK_BUILD_ID = (1U << 5), /* Zero-initialize hash function seed. This should only be used for testing. */ BPF_F_ZERO_SEED = (1U << 6), /* Flags for accessing BPF object from program side. */ BPF_F_RDONLY_PROG = (1U << 7), BPF_F_WRONLY_PROG = (1U << 8), /* Clone map from listener for newly accepted socket */ BPF_F_CLONE = (1U << 9), /* Enable memory-mapping BPF map */ BPF_F_MMAPABLE = (1U << 10), /* Share perf_event among processes */ BPF_F_PRESERVE_ELEMS = (1U << 11), /* Create a map that is suitable to be an inner map with dynamic max entries */ BPF_F_INNER_MAP = (1U << 12), /* Create a map that will be registered/unregesitered by the backed bpf_link */ BPF_F_LINK = (1U << 13), /* Get path from provided FD in BPF_OBJ_PIN/BPF_OBJ_GET commands */ BPF_F_PATH_FD = (1U << 14), /* Flag for value_type_btf_obj_fd, the fd is available */ BPF_F_VTYPE_BTF_OBJ_FD = (1U << 15), /* BPF token FD is passed in a corresponding command's token_fd field */ BPF_F_TOKEN_FD = (1U << 16), /* When user space page faults in bpf_arena send SIGSEGV instead of inserting new page */ BPF_F_SEGV_ON_FAULT = (1U << 17), /* Do not translate kernel bpf_arena pointers to user pointers */ BPF_F_NO_USER_CONV = (1U << 18), }; /* Flags for BPF_PROG_QUERY. */ /* Query effective (directly attached + inherited from ancestor cgroups) * programs that will be executed for events within a cgroup. * attach_flags with this flag are always returned 0. */ #define BPF_F_QUERY_EFFECTIVE (1U << 0) /* Flags for BPF_PROG_TEST_RUN */ /* If set, run the test on the cpu specified by bpf_attr.test.cpu */ #define BPF_F_TEST_RUN_ON_CPU (1U << 0) /* If set, XDP frames will be transmitted after processing */ #define BPF_F_TEST_XDP_LIVE_FRAMES (1U << 1) /* If set, apply CHECKSUM_COMPLETE to skb and validate the checksum */ #define BPF_F_TEST_SKB_CHECKSUM_COMPLETE (1U << 2) /* type for BPF_ENABLE_STATS */ enum bpf_stats_type { /* enabled run_time_ns and run_cnt */ BPF_STATS_RUN_TIME = 0, }; enum bpf_stack_build_id_status { /* user space need an empty entry to identify end of a trace */ BPF_STACK_BUILD_ID_EMPTY = 0, /* with valid build_id and offset */ BPF_STACK_BUILD_ID_VALID = 1, /* couldn't get build_id, fallback to ip */ BPF_STACK_BUILD_ID_IP = 2, }; #define BPF_BUILD_ID_SIZE 20 struct bpf_stack_build_id { __s32 status; unsigned char build_id[BPF_BUILD_ID_SIZE]; union { __u64 offset; __u64 ip; }; }; #define BPF_OBJ_NAME_LEN 16U union bpf_attr { struct { /* anonymous struct used by BPF_MAP_CREATE command */ __u32 map_type; /* one of enum bpf_map_type */ __u32 key_size; /* size of key in bytes */ __u32 value_size; /* size of value in bytes */ __u32 max_entries; /* max number of entries in a map */ __u32 map_flags; /* BPF_MAP_CREATE related * flags defined above. */ __u32 inner_map_fd; /* fd pointing to the inner map */ __u32 numa_node; /* numa node (effective only if * BPF_F_NUMA_NODE is set). */ char map_name[BPF_OBJ_NAME_LEN]; __u32 map_ifindex; /* ifindex of netdev to create on */ __u32 btf_fd; /* fd pointing to a BTF type data */ __u32 btf_key_type_id; /* BTF type_id of the key */ __u32 btf_value_type_id; /* BTF type_id of the value */ __u32 btf_vmlinux_value_type_id;/* BTF type_id of a kernel- * struct stored as the * map value */ /* Any per-map-type extra fields * * BPF_MAP_TYPE_BLOOM_FILTER - the lowest 4 bits indicate the * number of hash functions (if 0, the bloom filter will default * to using 5 hash functions). * * BPF_MAP_TYPE_ARENA - contains the address where user space * is going to mmap() the arena. It has to be page aligned. */ __u64 map_extra; __s32 value_type_btf_obj_fd; /* fd pointing to a BTF * type data for * btf_vmlinux_value_type_id. */ /* BPF token FD to use with BPF_MAP_CREATE operation. * If provided, map_flags should have BPF_F_TOKEN_FD flag set. */ __s32 map_token_fd; }; struct { /* anonymous struct used by BPF_MAP_*_ELEM and BPF_MAP_FREEZE commands */ __u32 map_fd; __aligned_u64 key; union { __aligned_u64 value; __aligned_u64 next_key; }; __u64 flags; }; struct { /* struct used by BPF_MAP_*_BATCH commands */ __aligned_u64 in_batch; /* start batch, * NULL to start from beginning */ __aligned_u64 out_batch; /* output: next start batch */ __aligned_u64 keys; __aligned_u64 values; __u32 count; /* input/output: * input: # of key/value * elements * output: # of filled elements */ __u32 map_fd; __u64 elem_flags; __u64 flags; } batch; struct { /* anonymous struct used by BPF_PROG_LOAD command */ __u32 prog_type; /* one of enum bpf_prog_type */ __u32 insn_cnt; __aligned_u64 insns; __aligned_u64 license; __u32 log_level; /* verbosity level of verifier */ __u32 log_size; /* size of user buffer */ __aligned_u64 log_buf; /* user supplied buffer */ __u32 kern_version; /* not used */ __u32 prog_flags; char prog_name[BPF_OBJ_NAME_LEN]; __u32 prog_ifindex; /* ifindex of netdev to prep for */ /* For some prog types expected attach type must be known at * load time to verify attach type specific parts of prog * (context accesses, allowed helpers, etc). */ __u32 expected_attach_type; __u32 prog_btf_fd; /* fd pointing to BTF type data */ __u32 func_info_rec_size; /* userspace bpf_func_info size */ __aligned_u64 func_info; /* func info */ __u32 func_info_cnt; /* number of bpf_func_info records */ __u32 line_info_rec_size; /* userspace bpf_line_info size */ __aligned_u64 line_info; /* line info */ __u32 line_info_cnt; /* number of bpf_line_info records */ __u32 attach_btf_id; /* in-kernel BTF type id to attach to */ union { /* valid prog_fd to attach to bpf prog */ __u32 attach_prog_fd; /* or valid module BTF object fd or 0 to attach to vmlinux */ __u32 attach_btf_obj_fd; }; __u32 core_relo_cnt; /* number of bpf_core_relo */ __aligned_u64 fd_array; /* array of FDs */ __aligned_u64 core_relos; __u32 core_relo_rec_size; /* sizeof(struct bpf_core_relo) */ /* output: actual total log contents size (including termintaing zero). * It could be both larger than original log_size (if log was * truncated), or smaller (if log buffer wasn't filled completely). */ __u32 log_true_size; /* BPF token FD to use with BPF_PROG_LOAD operation. * If provided, prog_flags should have BPF_F_TOKEN_FD flag set. */ __s32 prog_token_fd; /* The fd_array_cnt can be used to pass the length of the * fd_array array. In this case all the [map] file descriptors * passed in this array will be bound to the program, even if * the maps are not referenced directly. The functionality is * similar to the BPF_PROG_BIND_MAP syscall, but maps can be * used by the verifier during the program load. If provided, * then the fd_array[0,...,fd_array_cnt-1] is expected to be * continuous. */ __u32 fd_array_cnt; }; struct { /* anonymous struct used by BPF_OBJ_* commands */ __aligned_u64 pathname; __u32 bpf_fd; __u32 file_flags; /* Same as dirfd in openat() syscall; see openat(2) * manpage for details of path FD and pathname semantics; * path_fd should accompanied by BPF_F_PATH_FD flag set in * file_flags field, otherwise it should be set to zero; * if BPF_F_PATH_FD flag is not set, AT_FDCWD is assumed. */ __s32 path_fd; }; struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ union { __u32 target_fd; /* target object to attach to or ... */ __u32 target_ifindex; /* target ifindex */ }; __u32 attach_bpf_fd; __u32 attach_type; __u32 attach_flags; __u32 replace_bpf_fd; union { __u32 relative_fd; __u32 relative_id; }; __u64 expected_revision; }; struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */ __u32 prog_fd; __u32 retval; __u32 data_size_in; /* input: len of data_in */ __u32 data_size_out; /* input/output: len of data_out * returns ENOSPC if data_out * is too small. */ __aligned_u64 data_in; __aligned_u64 data_out; __u32 repeat; __u32 duration; __u32 ctx_size_in; /* input: len of ctx_in */ __u32 ctx_size_out; /* input/output: len of ctx_out * returns ENOSPC if ctx_out * is too small. */ __aligned_u64 ctx_in; __aligned_u64 ctx_out; __u32 flags; __u32 cpu; __u32 batch_size; } test; struct { /* anonymous struct used by BPF_*_GET_*_ID */ union { __u32 start_id; __u32 prog_id; __u32 map_id; __u32 btf_id; __u32 link_id; }; __u32 next_id; __u32 open_flags; __s32 fd_by_id_token_fd; }; struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */ __u32 bpf_fd; __u32 info_len; __aligned_u64 info; } info; struct { /* anonymous struct used by BPF_PROG_QUERY command */ union { __u32 target_fd; /* target object to query or ... */ __u32 target_ifindex; /* target ifindex */ }; __u32 attach_type; __u32 query_flags; __u32 attach_flags; __aligned_u64 prog_ids; union { __u32 prog_cnt; __u32 count; }; __u32 :32; /* output: per-program attach_flags. * not allowed to be set during effective query. */ __aligned_u64 prog_attach_flags; __aligned_u64 link_ids; __aligned_u64 link_attach_flags; __u64 revision; } query; struct { /* anonymous struct used by BPF_RAW_TRACEPOINT_OPEN command */ __u64 name; __u32 prog_fd; __u32 :32; __aligned_u64 cookie; } raw_tracepoint; struct { /* anonymous struct for BPF_BTF_LOAD */ __aligned_u64 btf; __aligned_u64 btf_log_buf; __u32 btf_size; __u32 btf_log_size; __u32 btf_log_level; /* output: actual total log contents size (including termintaing zero). * It could be both larger than original log_size (if log was * truncated), or smaller (if log buffer wasn't filled completely). */ __u32 btf_log_true_size; __u32 btf_flags; /* BPF token FD to use with BPF_BTF_LOAD operation. * If provided, btf_flags should have BPF_F_TOKEN_FD flag set. */ __s32 btf_token_fd; }; struct { __u32 pid; /* input: pid */ __u32 fd; /* input: fd */ __u32 flags; /* input: flags */ __u32 buf_len; /* input/output: buf len */ __aligned_u64 buf; /* input/output: * tp_name for tracepoint * symbol for kprobe * filename for uprobe */ __u32 prog_id; /* output: prod_id */ __u32 fd_type; /* output: BPF_FD_TYPE_* */ __u64 probe_offset; /* output: probe_offset */ __u64 probe_addr; /* output: probe_addr */ } task_fd_query; struct { /* struct used by BPF_LINK_CREATE command */ union { __u32 prog_fd; /* eBPF program to attach */ __u32 map_fd; /* struct_ops to attach */ }; union { __u32 target_fd; /* target object to attach to or ... */ __u32 target_ifindex; /* target ifindex */ }; __u32 attach_type; /* attach type */ __u32 flags; /* extra flags */ union { __u32 target_btf_id; /* btf_id of target to attach to */ struct { __aligned_u64 iter_info; /* extra bpf_iter_link_info */ __u32 iter_info_len; /* iter_info length */ }; struct { /* black box user-provided value passed through * to BPF program at the execution time and * accessible through bpf_get_attach_cookie() BPF helper */ __u64 bpf_cookie; } perf_event; struct { __u32 flags; __u32 cnt; __aligned_u64 syms; __aligned_u64 addrs; __aligned_u64 cookies; } kprobe_multi; struct { /* this is overlaid with the target_btf_id above. */ __u32 target_btf_id; /* black box user-provided value passed through * to BPF program at the execution time and * accessible through bpf_get_attach_cookie() BPF helper */ __u64 cookie; } tracing; struct { __u32 pf; __u32 hooknum; __s32 priority; __u32 flags; } netfilter; struct { union { __u32 relative_fd; __u32 relative_id; }; __u64 expected_revision; } tcx; struct { __aligned_u64 path; __aligned_u64 offsets; __aligned_u64 ref_ctr_offsets; __aligned_u64 cookies; __u32 cnt; __u32 flags; __u32 pid; } uprobe_multi; struct { union { __u32 relative_fd; __u32 relative_id; }; __u64 expected_revision; } netkit; }; } link_create; struct { /* struct used by BPF_LINK_UPDATE command */ __u32 link_fd; /* link fd */ union { /* new program fd to update link with */ __u32 new_prog_fd; /* new struct_ops map fd to update link with */ __u32 new_map_fd; }; __u32 flags; /* extra flags */ union { /* expected link's program fd; is specified only if * BPF_F_REPLACE flag is set in flags. */ __u32 old_prog_fd; /* expected link's map fd; is specified only * if BPF_F_REPLACE flag is set. */ __u32 old_map_fd; }; } link_update; struct { __u32 link_fd; } link_detach; struct { /* struct used by BPF_ENABLE_STATS command */ __u32 type; } enable_stats; struct { /* struct used by BPF_ITER_CREATE command */ __u32 link_fd; __u32 flags; } iter_create; struct { /* struct used by BPF_PROG_BIND_MAP command */ __u32 prog_fd; __u32 map_fd; __u32 flags; /* extra flags */ } prog_bind_map; struct { /* struct used by BPF_TOKEN_CREATE command */ __u32 flags; __u32 bpffs_fd; } token_create; } __attribute__((aligned(8))); /* The description below is an attempt at providing documentation to eBPF * developers about the multiple available eBPF helper functions. It can be * parsed and used to produce a manual page. The workflow is the following, * and requires the rst2man utility: * * $ ./scripts/bpf_doc.py \ * --filename include/uapi/linux/bpf.h > /tmp/bpf-helpers.rst * $ rst2man /tmp/bpf-helpers.rst > /tmp/bpf-helpers.7 * $ man /tmp/bpf-helpers.7 * * Note that in order to produce this external documentation, some RST * formatting is used in the descriptions to get "bold" and "italics" in * manual pages. Also note that the few trailing white spaces are * intentional, removing them would break paragraphs for rst2man. * * Start of BPF helper function descriptions: * * void *bpf_map_lookup_elem(struct bpf_map *map, const void *key) * Description * Perform a lookup in *map* for an entry associated to *key*. * Return * Map value associated to *key*, or **NULL** if no entry was * found. * * long bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags) * Description * Add or update the value of the entry associated to *key* in * *map* with *value*. *flags* is one of: * * **BPF_NOEXIST** * The entry for *key* must not exist in the map. * **BPF_EXIST** * The entry for *key* must already exist in the map. * **BPF_ANY** * No condition on the existence of the entry for *key*. * * Flag value **BPF_NOEXIST** cannot be used for maps of types * **BPF_MAP_TYPE_ARRAY** or **BPF_MAP_TYPE_PERCPU_ARRAY** (all * elements always exist), the helper would return an error. * Return * 0 on success, or a negative error in case of failure. * * long bpf_map_delete_elem(struct bpf_map *map, const void *key) * Description * Delete entry with *key* from *map*. * Return * 0 on success, or a negative error in case of failure. * * long bpf_probe_read(void *dst, u32 size, const void *unsafe_ptr) * Description * For tracing programs, safely attempt to read *size* bytes from * kernel space address *unsafe_ptr* and store the data in *dst*. * * Generally, use **bpf_probe_read_user**\ () or * **bpf_probe_read_kernel**\ () instead. * Return * 0 on success, or a negative error in case of failure. * * u64 bpf_ktime_get_ns(void) * Description * Return the time elapsed since system boot, in nanoseconds. * Does not include time the system was suspended. * See: **clock_gettime**\ (**CLOCK_MONOTONIC**) * Return * Current *ktime*. * * long bpf_trace_printk(const char *fmt, u32 fmt_size, ...) * Description * This helper is a "printk()-like" facility for debugging. It * prints a message defined by format *fmt* (of size *fmt_size*) * to file *\/sys/kernel/tracing/trace* from TraceFS, if * available. It can take up to three additional **u64** * arguments (as an eBPF helpers, the total number of arguments is * limited to five). * * Each time the helper is called, it appends a line to the trace. * Lines are discarded while *\/sys/kernel/tracing/trace* is * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this. * The format of the trace is customizable, and the exact output * one will get depends on the options set in * *\/sys/kernel/tracing/trace_options* (see also the * *README* file under the same directory). However, it usually * defaults to something like: * * :: * * telnet-470 [001] .N.. 419421.045894: 0x00000001: * * In the above: * * * ``telnet`` is the name of the current task. * * ``470`` is the PID of the current task. * * ``001`` is the CPU number on which the task is * running. * * In ``.N..``, each character refers to a set of * options (whether irqs are enabled, scheduling * options, whether hard/softirqs are running, level of * preempt_disabled respectively). **N** means that * **TIF_NEED_RESCHED** and **PREEMPT_NEED_RESCHED** * are set. * * ``419421.045894`` is a timestamp. * * ``0x00000001`` is a fake value used by BPF for the * instruction pointer register. * * ```` is the message formatted with * *fmt*. * * The conversion specifiers supported by *fmt* are similar, but * more limited than for printk(). They are **%d**, **%i**, * **%u**, **%x**, **%ld**, **%li**, **%lu**, **%lx**, **%lld**, * **%lli**, **%llu**, **%llx**, **%p**, **%s**. No modifier (size * of field, padding with zeroes, etc.) is available, and the * helper will return **-EINVAL** (but print nothing) if it * encounters an unknown specifier. * * Also, note that **bpf_trace_printk**\ () is slow, and should * only be used for debugging purposes. For this reason, a notice * block (spanning several lines) is printed to kernel logs and * states that the helper should not be used "for production use" * the first time this helper is used (or more precisely, when * **trace_printk**\ () buffers are allocated). For passing values * to user space, perf events should be preferred. * Return * The number of bytes written to the buffer, or a negative error * in case of failure. * * u32 bpf_get_prandom_u32(void) * Description * Get a pseudo-random number. * * From a security point of view, this helper uses its own * pseudo-random internal state, and cannot be used to infer the * seed of other random functions in the kernel. However, it is * essential to note that the generator used by the helper is not * cryptographically secure. * Return * A random 32-bit unsigned value. * * u32 bpf_get_smp_processor_id(void) * Description * Get the SMP (symmetric multiprocessing) processor id. Note that * all programs run with migration disabled, which means that the * SMP processor id is stable during all the execution of the * program. * Return * The SMP id of the processor running the program. * Attributes * __bpf_fastcall * * long bpf_skb_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len, u64 flags) * Description * Store *len* bytes from address *from* into the packet * associated to *skb*, at *offset*. The *flags* are a combination * of the following values: * * **BPF_F_RECOMPUTE_CSUM** * Automatically update *skb*\ **->csum** after storing the * bytes. * **BPF_F_INVALIDATE_HASH** * Set *skb*\ **->hash**, *skb*\ **->swhash** and *skb*\ * **->l4hash** to 0. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_l3_csum_replace(struct sk_buff *skb, u32 offset, u64 from, u64 to, u64 size) * Description * Recompute the layer 3 (e.g. IP) checksum for the packet * associated to *skb*. Computation is incremental, so the helper * must know the former value of the header field that was * modified (*from*), the new value of this field (*to*), and the * number of bytes (2 or 4) for this field, stored in *size*. * Alternatively, it is possible to store the difference between * the previous and the new values of the header field in *to*, by * setting *from* and *size* to 0. For both methods, *offset* * indicates the location of the IP checksum within the packet. * * This helper works in combination with **bpf_csum_diff**\ (), * which does not update the checksum in-place, but offers more * flexibility and can handle sizes larger than 2 or 4 for the * checksum to update. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_l4_csum_replace(struct sk_buff *skb, u32 offset, u64 from, u64 to, u64 flags) * Description * Recompute the layer 4 (e.g. TCP, UDP or ICMP) checksum for the * packet associated to *skb*. Computation is incremental, so the * helper must know the former value of the header field that was * modified (*from*), the new value of this field (*to*), and the * number of bytes (2 or 4) for this field, stored on the lowest * four bits of *flags*. Alternatively, it is possible to store * the difference between the previous and the new values of the * header field in *to*, by setting *from* and the four lowest * bits of *flags* to 0. For both methods, *offset* indicates the * location of the IP checksum within the packet. In addition to * the size of the field, *flags* can be added (bitwise OR) actual * flags. With **BPF_F_MARK_MANGLED_0**, a null checksum is left * untouched (unless **BPF_F_MARK_ENFORCE** is added as well), and * for updates resulting in a null checksum the value is set to * **CSUM_MANGLED_0** instead. Flag **BPF_F_PSEUDO_HDR** indicates * that the modified header field is part of the pseudo-header. * Flag **BPF_F_IPV6** should be set for IPv6 packets. * * This helper works in combination with **bpf_csum_diff**\ (), * which does not update the checksum in-place, but offers more * flexibility and can handle sizes larger than 2 or 4 for the * checksum to update. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_tail_call(void *ctx, struct bpf_map *prog_array_map, u32 index) * Description * This special helper is used to trigger a "tail call", or in * other words, to jump into another eBPF program. The same stack * frame is used (but values on stack and in registers for the * caller are not accessible to the callee). This mechanism allows * for program chaining, either for raising the maximum number of * available eBPF instructions, or to execute given programs in * conditional blocks. For security reasons, there is an upper * limit to the number of successive tail calls that can be * performed. * * Upon call of this helper, the program attempts to jump into a * program referenced at index *index* in *prog_array_map*, a * special map of type **BPF_MAP_TYPE_PROG_ARRAY**, and passes * *ctx*, a pointer to the context. * * If the call succeeds, the kernel immediately runs the first * instruction of the new program. This is not a function call, * and it never returns to the previous program. If the call * fails, then the helper has no effect, and the caller continues * to run its subsequent instructions. A call can fail if the * destination program for the jump does not exist (i.e. *index* * is superior to the number of entries in *prog_array_map*), or * if the maximum number of tail calls has been reached for this * chain of programs. This limit is defined in the kernel by the * macro **MAX_TAIL_CALL_CNT** (not accessible to user space), * which is currently set to 33. * Return * 0 on success, or a negative error in case of failure. * * long bpf_clone_redirect(struct sk_buff *skb, u32 ifindex, u64 flags) * Description * Clone and redirect the packet associated to *skb* to another * net device of index *ifindex*. Both ingress and egress * interfaces can be used for redirection. The **BPF_F_INGRESS** * value in *flags* is used to make the distinction (ingress path * is selected if the flag is present, egress path otherwise). * This is the only flag supported for now. * * In comparison with **bpf_redirect**\ () helper, * **bpf_clone_redirect**\ () has the associated cost of * duplicating the packet buffer, but this can be executed out of * the eBPF program. Conversely, **bpf_redirect**\ () is more * efficient, but it is handled through an action code where the * redirection happens only after the eBPF program has returned. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. Positive * error indicates a potential drop or congestion in the target * device. The particular positive error codes are not defined. * * u64 bpf_get_current_pid_tgid(void) * Description * Get the current pid and tgid. * Return * A 64-bit integer containing the current tgid and pid, and * created as such: * *current_task*\ **->tgid << 32 \|** * *current_task*\ **->pid**. * * u64 bpf_get_current_uid_gid(void) * Description * Get the current uid and gid. * Return * A 64-bit integer containing the current GID and UID, and * created as such: *current_gid* **<< 32 \|** *current_uid*. * * long bpf_get_current_comm(void *buf, u32 size_of_buf) * Description * Copy the **comm** attribute of the current task into *buf* of * *size_of_buf*. The **comm** attribute contains the name of * the executable (excluding the path) for the current task. The * *size_of_buf* must be strictly positive. On success, the * helper makes sure that the *buf* is NUL-terminated. On failure, * it is filled with zeroes. * Return * 0 on success, or a negative error in case of failure. * * u32 bpf_get_cgroup_classid(struct sk_buff *skb) * Description * Retrieve the classid for the current task, i.e. for the net_cls * cgroup to which *skb* belongs. * * This helper can be used on TC egress path, but not on ingress. * * The net_cls cgroup provides an interface to tag network packets * based on a user-provided identifier for all traffic coming from * the tasks belonging to the related cgroup. See also the related * kernel documentation, available from the Linux sources in file * *Documentation/admin-guide/cgroup-v1/net_cls.rst*. * * The Linux kernel has two versions for cgroups: there are * cgroups v1 and cgroups v2. Both are available to users, who can * use a mixture of them, but note that the net_cls cgroup is for * cgroup v1 only. This makes it incompatible with BPF programs * run on cgroups, which is a cgroup-v2-only feature (a socket can * only hold data for one version of cgroups at a time). * * This helper is only available is the kernel was compiled with * the **CONFIG_CGROUP_NET_CLASSID** configuration option set to * "**y**" or to "**m**". * Return * The classid, or 0 for the default unconfigured classid. * * long bpf_skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) * Description * Push a *vlan_tci* (VLAN tag control information) of protocol * *vlan_proto* to the packet associated to *skb*, then update * the checksum. Note that if *vlan_proto* is different from * **ETH_P_8021Q** and **ETH_P_8021AD**, it is considered to * be **ETH_P_8021Q**. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_vlan_pop(struct sk_buff *skb) * Description * Pop a VLAN header from the packet associated to *skb*. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_get_tunnel_key(struct sk_buff *skb, struct bpf_tunnel_key *key, u32 size, u64 flags) * Description * Get tunnel metadata. This helper takes a pointer *key* to an * empty **struct bpf_tunnel_key** of **size**, that will be * filled with tunnel metadata for the packet associated to *skb*. * The *flags* can be set to **BPF_F_TUNINFO_IPV6**, which * indicates that the tunnel is based on IPv6 protocol instead of * IPv4. * * The **struct bpf_tunnel_key** is an object that generalizes the * principal parameters used by various tunneling protocols into a * single struct. This way, it can be used to easily make a * decision based on the contents of the encapsulation header, * "summarized" in this struct. In particular, it holds the IP * address of the remote end (IPv4 or IPv6, depending on the case) * in *key*\ **->remote_ipv4** or *key*\ **->remote_ipv6**. Also, * this struct exposes the *key*\ **->tunnel_id**, which is * generally mapped to a VNI (Virtual Network Identifier), making * it programmable together with the **bpf_skb_set_tunnel_key**\ * () helper. * * Let's imagine that the following code is part of a program * attached to the TC ingress interface, on one end of a GRE * tunnel, and is supposed to filter out all messages coming from * remote ends with IPv4 address other than 10.0.0.1: * * :: * * int ret; * struct bpf_tunnel_key key = {}; * * ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); * if (ret < 0) * return TC_ACT_SHOT; // drop packet * * if (key.remote_ipv4 != 0x0a000001) * return TC_ACT_SHOT; // drop packet * * return TC_ACT_OK; // accept packet * * This interface can also be used with all encapsulation devices * that can operate in "collect metadata" mode: instead of having * one network device per specific configuration, the "collect * metadata" mode only requires a single device where the * configuration can be extracted from this helper. * * This can be used together with various tunnels such as VXLan, * Geneve, GRE or IP in IP (IPIP). * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_set_tunnel_key(struct sk_buff *skb, struct bpf_tunnel_key *key, u32 size, u64 flags) * Description * Populate tunnel metadata for packet associated to *skb.* The * tunnel metadata is set to the contents of *key*, of *size*. The * *flags* can be set to a combination of the following values: * * **BPF_F_TUNINFO_IPV6** * Indicate that the tunnel is based on IPv6 protocol * instead of IPv4. * **BPF_F_ZERO_CSUM_TX** * For IPv4 packets, add a flag to tunnel metadata * indicating that checksum computation should be skipped * and checksum set to zeroes. * **BPF_F_DONT_FRAGMENT** * Add a flag to tunnel metadata indicating that the * packet should not be fragmented. * **BPF_F_SEQ_NUMBER** * Add a flag to tunnel metadata indicating that a * sequence number should be added to tunnel header before * sending the packet. This flag was added for GRE * encapsulation, but might be used with other protocols * as well in the future. * **BPF_F_NO_TUNNEL_KEY** * Add a flag to tunnel metadata indicating that no tunnel * key should be set in the resulting tunnel header. * * Here is a typical usage on the transmit path: * * :: * * struct bpf_tunnel_key key; * populate key ... * bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0); * bpf_clone_redirect(skb, vxlan_dev_ifindex, 0); * * See also the description of the **bpf_skb_get_tunnel_key**\ () * helper for additional information. * Return * 0 on success, or a negative error in case of failure. * * u64 bpf_perf_event_read(struct bpf_map *map, u64 flags) * Description * Read the value of a perf event counter. This helper relies on a * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. The nature of * the perf event counter is selected when *map* is updated with * perf event file descriptors. The *map* is an array whose size * is the number of available CPUs, and each cell contains a value * relative to one CPU. The value to retrieve is indicated by * *flags*, that contains the index of the CPU to look up, masked * with **BPF_F_INDEX_MASK**. Alternatively, *flags* can be set to * **BPF_F_CURRENT_CPU** to indicate that the value for the * current CPU should be retrieved. * * Note that before Linux 4.13, only hardware perf event can be * retrieved. * * Also, be aware that the newer helper * **bpf_perf_event_read_value**\ () is recommended over * **bpf_perf_event_read**\ () in general. The latter has some ABI * quirks where error and counter value are used as a return code * (which is wrong to do since ranges may overlap). This issue is * fixed with **bpf_perf_event_read_value**\ (), which at the same * time provides more features over the **bpf_perf_event_read**\ * () interface. Please refer to the description of * **bpf_perf_event_read_value**\ () for details. * Return * The value of the perf event counter read from the map, or a * negative error code in case of failure. * * long bpf_redirect(u32 ifindex, u64 flags) * Description * Redirect the packet to another net device of index *ifindex*. * This helper is somewhat similar to **bpf_clone_redirect**\ * (), except that the packet is not cloned, which provides * increased performance. * * Except for XDP, both ingress and egress interfaces can be used * for redirection. The **BPF_F_INGRESS** value in *flags* is used * to make the distinction (ingress path is selected if the flag * is present, egress path otherwise). Currently, XDP only * supports redirection to the egress interface, and accepts no * flag at all. * * The same effect can also be attained with the more generic * **bpf_redirect_map**\ (), which uses a BPF map to store the * redirect target instead of providing it directly to the helper. * Return * For XDP, the helper returns **XDP_REDIRECT** on success or * **XDP_ABORTED** on error. For other program types, the values * are **TC_ACT_REDIRECT** on success or **TC_ACT_SHOT** on * error. * * u32 bpf_get_route_realm(struct sk_buff *skb) * Description * Retrieve the realm or the route, that is to say the * **tclassid** field of the destination for the *skb*. The * identifier retrieved is a user-provided tag, similar to the * one used with the net_cls cgroup (see description for * **bpf_get_cgroup_classid**\ () helper), but here this tag is * held by a route (a destination entry), not by a task. * * Retrieving this identifier works with the clsact TC egress hook * (see also **tc-bpf(8)**), or alternatively on conventional * classful egress qdiscs, but not on TC ingress path. In case of * clsact TC egress hook, this has the advantage that, internally, * the destination entry has not been dropped yet in the transmit * path. Therefore, the destination entry does not need to be * artificially held via **netif_keep_dst**\ () for a classful * qdisc until the *skb* is freed. * * This helper is available only if the kernel was compiled with * **CONFIG_IP_ROUTE_CLASSID** configuration option. * Return * The realm of the route for the packet associated to *skb*, or 0 * if none was found. * * long bpf_perf_event_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) * Description * Write raw *data* blob into a special BPF perf event held by * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf * event must have the following attributes: **PERF_SAMPLE_RAW** * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. * * The *flags* are used to indicate the index in *map* for which * the value must be put, masked with **BPF_F_INDEX_MASK**. * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** * to indicate that the index of the current CPU core should be * used. * * The value to write, of *size*, is passed through eBPF stack and * pointed by *data*. * * The context of the program *ctx* needs also be passed to the * helper. * * On user space, a program willing to read the values needs to * call **perf_event_open**\ () on the perf event (either for * one or for all CPUs) and to store the file descriptor into the * *map*. This must be done before the eBPF program can send data * into it. An example is available in file * *samples/bpf/trace_output_user.c* in the Linux kernel source * tree (the eBPF program counterpart is in * *samples/bpf/trace_output_kern.c*). * * **bpf_perf_event_output**\ () achieves better performance * than **bpf_trace_printk**\ () for sharing data with user * space, and is much better suitable for streaming data from eBPF * programs. * * Note that this helper is not restricted to tracing use cases * and can be used with programs attached to TC or XDP as well, * where it allows for passing data to user space listeners. Data * can be: * * * Only custom structs, * * Only the packet payload, or * * A combination of both. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_load_bytes(const void *skb, u32 offset, void *to, u32 len) * Description * This helper was provided as an easy way to load data from a * packet. It can be used to load *len* bytes from *offset* from * the packet associated to *skb*, into the buffer pointed by * *to*. * * Since Linux 4.7, usage of this helper has mostly been replaced * by "direct packet access", enabling packet data to be * manipulated with *skb*\ **->data** and *skb*\ **->data_end** * pointing respectively to the first byte of packet data and to * the byte after the last byte of packet data. However, it * remains useful if one wishes to read large quantities of data * at once from a packet into the eBPF stack. * Return * 0 on success, or a negative error in case of failure. * * long bpf_get_stackid(void *ctx, struct bpf_map *map, u64 flags) * Description * Walk a user or a kernel stack and return its id. To achieve * this, the helper needs *ctx*, which is a pointer to the context * on which the tracing program is executed, and a pointer to a * *map* of type **BPF_MAP_TYPE_STACK_TRACE**. * * The last argument, *flags*, holds the number of stack frames to * skip (from 0 to 255), masked with * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set * a combination of the following flags: * * **BPF_F_USER_STACK** * Collect a user space stack instead of a kernel stack. * **BPF_F_FAST_STACK_CMP** * Compare stacks by hash only. * **BPF_F_REUSE_STACKID** * If two different stacks hash into the same *stackid*, * discard the old one. * * The stack id retrieved is a 32 bit long integer handle which * can be further combined with other data (including other stack * ids) and used as a key into maps. This can be useful for * generating a variety of graphs (such as flame graphs or off-cpu * graphs). * * For walking a stack, this helper is an improvement over * **bpf_probe_read**\ (), which can be used with unrolled loops * but is not efficient and consumes a lot of eBPF instructions. * Instead, **bpf_get_stackid**\ () can collect up to * **PERF_MAX_STACK_DEPTH** both kernel and user frames. Note that * this limit can be controlled with the **sysctl** program, and * that it should be manually increased in order to profile long * user stacks (such as stacks for Java programs). To do so, use: * * :: * * # sysctl kernel.perf_event_max_stack= * Return * The positive or null stack id on success, or a negative error * in case of failure. * * s64 bpf_csum_diff(__be32 *from, u32 from_size, __be32 *to, u32 to_size, __wsum seed) * Description * Compute a checksum difference, from the raw buffer pointed by * *from*, of length *from_size* (that must be a multiple of 4), * towards the raw buffer pointed by *to*, of size *to_size* * (same remark). An optional *seed* can be added to the value * (this can be cascaded, the seed may come from a previous call * to the helper). * * This is flexible enough to be used in several ways: * * * With *from_size* == 0, *to_size* > 0 and *seed* set to * checksum, it can be used when pushing new data. * * With *from_size* > 0, *to_size* == 0 and *seed* set to * checksum, it can be used when removing data from a packet. * * With *from_size* > 0, *to_size* > 0 and *seed* set to 0, it * can be used to compute a diff. Note that *from_size* and * *to_size* do not need to be equal. * * This helper can be used in combination with * **bpf_l3_csum_replace**\ () and **bpf_l4_csum_replace**\ (), to * which one can feed in the difference computed with * **bpf_csum_diff**\ (). * Return * The checksum result, or a negative error code in case of * failure. * * long bpf_skb_get_tunnel_opt(struct sk_buff *skb, void *opt, u32 size) * Description * Retrieve tunnel options metadata for the packet associated to * *skb*, and store the raw tunnel option data to the buffer *opt* * of *size*. * * This helper can be used with encapsulation devices that can * operate in "collect metadata" mode (please refer to the related * note in the description of **bpf_skb_get_tunnel_key**\ () for * more details). A particular example where this can be used is * in combination with the Geneve encapsulation protocol, where it * allows for pushing (with **bpf_skb_get_tunnel_opt**\ () helper) * and retrieving arbitrary TLVs (Type-Length-Value headers) from * the eBPF program. This allows for full customization of these * headers. * Return * The size of the option data retrieved. * * long bpf_skb_set_tunnel_opt(struct sk_buff *skb, void *opt, u32 size) * Description * Set tunnel options metadata for the packet associated to *skb* * to the option data contained in the raw buffer *opt* of *size*. * * See also the description of the **bpf_skb_get_tunnel_opt**\ () * helper for additional information. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_change_proto(struct sk_buff *skb, __be16 proto, u64 flags) * Description * Change the protocol of the *skb* to *proto*. Currently * supported are transition from IPv4 to IPv6, and from IPv6 to * IPv4. The helper takes care of the groundwork for the * transition, including resizing the socket buffer. The eBPF * program is expected to fill the new headers, if any, via * **skb_store_bytes**\ () and to recompute the checksums with * **bpf_l3_csum_replace**\ () and **bpf_l4_csum_replace**\ * (). The main case for this helper is to perform NAT64 * operations out of an eBPF program. * * Internally, the GSO type is marked as dodgy so that headers are * checked and segments are recalculated by the GSO/GRO engine. * The size for GSO target is adapted as well. * * All values for *flags* are reserved for future usage, and must * be left at zero. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_change_type(struct sk_buff *skb, u32 type) * Description * Change the packet type for the packet associated to *skb*. This * comes down to setting *skb*\ **->pkt_type** to *type*, except * the eBPF program does not have a write access to *skb*\ * **->pkt_type** beside this helper. Using a helper here allows * for graceful handling of errors. * * The major use case is to change incoming *skb*s to * **PACKET_HOST** in a programmatic way instead of having to * recirculate via **redirect**\ (..., **BPF_F_INGRESS**), for * example. * * Note that *type* only allows certain values. At this time, they * are: * * **PACKET_HOST** * Packet is for us. * **PACKET_BROADCAST** * Send packet to all. * **PACKET_MULTICAST** * Send packet to group. * **PACKET_OTHERHOST** * Send packet to someone else. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_under_cgroup(struct sk_buff *skb, struct bpf_map *map, u32 index) * Description * Check whether *skb* is a descendant of the cgroup2 held by * *map* of type **BPF_MAP_TYPE_CGROUP_ARRAY**, at *index*. * Return * The return value depends on the result of the test, and can be: * * * 0, if the *skb* failed the cgroup2 descendant test. * * 1, if the *skb* succeeded the cgroup2 descendant test. * * A negative error code, if an error occurred. * * u32 bpf_get_hash_recalc(struct sk_buff *skb) * Description * Retrieve the hash of the packet, *skb*\ **->hash**. If it is * not set, in particular if the hash was cleared due to mangling, * recompute this hash. Later accesses to the hash can be done * directly with *skb*\ **->hash**. * * Calling **bpf_set_hash_invalid**\ (), changing a packet * prototype with **bpf_skb_change_proto**\ (), or calling * **bpf_skb_store_bytes**\ () with the * **BPF_F_INVALIDATE_HASH** are actions susceptible to clear * the hash and to trigger a new computation for the next call to * **bpf_get_hash_recalc**\ (). * Return * The 32-bit hash. * * u64 bpf_get_current_task(void) * Description * Get the current task. * Return * A pointer to the current task struct. * * long bpf_probe_write_user(void *dst, const void *src, u32 len) * Description * Attempt in a safe way to write *len* bytes from the buffer * *src* to *dst* in memory. It only works for threads that are in * user context, and *dst* must be a valid user space address. * * This helper should not be used to implement any kind of * security mechanism because of TOC-TOU attacks, but rather to * debug, divert, and manipulate execution of semi-cooperative * processes. * * Keep in mind that this feature is meant for experiments, and it * has a risk of crashing the system and running programs. * Therefore, when an eBPF program using this helper is attached, * a warning including PID and process name is printed to kernel * logs. * Return * 0 on success, or a negative error in case of failure. * * long bpf_current_task_under_cgroup(struct bpf_map *map, u32 index) * Description * Check whether the probe is being run is the context of a given * subset of the cgroup2 hierarchy. The cgroup2 to test is held by * *map* of type **BPF_MAP_TYPE_CGROUP_ARRAY**, at *index*. * Return * The return value depends on the result of the test, and can be: * * * 1, if current task belongs to the cgroup2. * * 0, if current task does not belong to the cgroup2. * * A negative error code, if an error occurred. * * long bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags) * Description * Resize (trim or grow) the packet associated to *skb* to the * new *len*. The *flags* are reserved for future usage, and must * be left at zero. * * The basic idea is that the helper performs the needed work to * change the size of the packet, then the eBPF program rewrites * the rest via helpers like **bpf_skb_store_bytes**\ (), * **bpf_l3_csum_replace**\ (), **bpf_l3_csum_replace**\ () * and others. This helper is a slow path utility intended for * replies with control messages. And because it is targeted for * slow path, the helper itself can afford to be slow: it * implicitly linearizes, unclones and drops offloads from the * *skb*. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_pull_data(struct sk_buff *skb, u32 len) * Description * Pull in non-linear data in case the *skb* is non-linear and not * all of *len* are part of the linear section. Make *len* bytes * from *skb* readable and writable. If a zero value is passed for * *len*, then all bytes in the linear part of *skb* will be made * readable and writable. * * This helper is only needed for reading and writing with direct * packet access. * * For direct packet access, testing that offsets to access * are within packet boundaries (test on *skb*\ **->data_end**) is * susceptible to fail if offsets are invalid, or if the requested * data is in non-linear parts of the *skb*. On failure the * program can just bail out, or in the case of a non-linear * buffer, use a helper to make the data available. The * **bpf_skb_load_bytes**\ () helper is a first solution to access * the data. Another one consists in using **bpf_skb_pull_data** * to pull in once the non-linear parts, then retesting and * eventually access the data. * * At the same time, this also makes sure the *skb* is uncloned, * which is a necessary condition for direct write. As this needs * to be an invariant for the write part only, the verifier * detects writes and adds a prologue that is calling * **bpf_skb_pull_data()** to effectively unclone the *skb* from * the very beginning in case it is indeed cloned. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * s64 bpf_csum_update(struct sk_buff *skb, __wsum csum) * Description * Add the checksum *csum* into *skb*\ **->csum** in case the * driver has supplied a checksum for the entire packet into that * field. Return an error otherwise. This helper is intended to be * used in combination with **bpf_csum_diff**\ (), in particular * when the checksum needs to be updated after data has been * written into the packet through direct packet access. * Return * The checksum on success, or a negative error code in case of * failure. * * void bpf_set_hash_invalid(struct sk_buff *skb) * Description * Invalidate the current *skb*\ **->hash**. It can be used after * mangling on headers through direct packet access, in order to * indicate that the hash is outdated and to trigger a * recalculation the next time the kernel tries to access this * hash or when the **bpf_get_hash_recalc**\ () helper is called. * Return * void. * * long bpf_get_numa_node_id(void) * Description * Return the id of the current NUMA node. The primary use case * for this helper is the selection of sockets for the local NUMA * node, when the program is attached to sockets using the * **SO_ATTACH_REUSEPORT_EBPF** option (see also **socket(7)**), * but the helper is also available to other eBPF program types, * similarly to **bpf_get_smp_processor_id**\ (). * Return * The id of current NUMA node. * * long bpf_skb_change_head(struct sk_buff *skb, u32 len, u64 flags) * Description * Grows headroom of packet associated to *skb* and adjusts the * offset of the MAC header accordingly, adding *len* bytes of * space. It automatically extends and reallocates memory as * required. * * This helper can be used on a layer 3 *skb* to push a MAC header * for redirection into a layer 2 device. * * All values for *flags* are reserved for future usage, and must * be left at zero. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_xdp_adjust_head(struct xdp_buff *xdp_md, int delta) * Description * Adjust (move) *xdp_md*\ **->data** by *delta* bytes. Note that * it is possible to use a negative value for *delta*. This helper * can be used to prepare the packet for pushing or popping * headers. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_probe_read_str(void *dst, u32 size, const void *unsafe_ptr) * Description * Copy a NUL terminated string from an unsafe kernel address * *unsafe_ptr* to *dst*. See **bpf_probe_read_kernel_str**\ () for * more details. * * Generally, use **bpf_probe_read_user_str**\ () or * **bpf_probe_read_kernel_str**\ () instead. * Return * On success, the strictly positive length of the string, * including the trailing NUL character. On error, a negative * value. * * u64 bpf_get_socket_cookie(struct sk_buff *skb) * Description * If the **struct sk_buff** pointed by *skb* has a known socket, * retrieve the cookie (generated by the kernel) of this socket. * If no cookie has been set yet, generate a new cookie. Once * generated, the socket cookie remains stable for the life of the * socket. This helper can be useful for monitoring per socket * networking traffic statistics as it provides a global socket * identifier that can be assumed unique. * Return * A 8-byte long unique number on success, or 0 if the socket * field is missing inside *skb*. * * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) * Description * Equivalent to bpf_get_socket_cookie() helper that accepts * *skb*, but gets socket from **struct bpf_sock_addr** context. * Return * A 8-byte long unique number. * * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) * Description * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts * *skb*, but gets socket from **struct bpf_sock_ops** context. * Return * A 8-byte long unique number. * * u64 bpf_get_socket_cookie(struct sock *sk) * Description * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts * *sk*, but gets socket from a BTF **struct sock**. This helper * also works for sleepable programs. * Return * A 8-byte long unique number or 0 if *sk* is NULL. * * u32 bpf_get_socket_uid(struct sk_buff *skb) * Description * Get the owner UID of the socked associated to *skb*. * Return * The owner UID of the socket associated to *skb*. If the socket * is **NULL**, or if it is not a full socket (i.e. if it is a * time-wait or a request socket instead), **overflowuid** value * is returned (note that **overflowuid** might also be the actual * UID value for the socket). * * long bpf_set_hash(struct sk_buff *skb, u32 hash) * Description * Set the full hash for *skb* (set the field *skb*\ **->hash**) * to value *hash*. * Return * 0 * * long bpf_setsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen) * Description * Emulate a call to **setsockopt()** on the socket associated to * *bpf_socket*, which must be a full socket. The *level* at * which the option resides and the name *optname* of the option * must be specified, see **setsockopt(2)** for more information. * The option value of length *optlen* is pointed by *optval*. * * *bpf_socket* should be one of the following: * * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**, * **BPF_CGROUP_INET6_CONNECT** and **BPF_CGROUP_UNIX_CONNECT**. * * This helper actually implements a subset of **setsockopt()**. * It supports the following *level*\ s: * * * **SOL_SOCKET**, which supports the following *optname*\ s: * **SO_RCVBUF**, **SO_SNDBUF**, **SO_MAX_PACING_RATE**, * **SO_PRIORITY**, **SO_RCVLOWAT**, **SO_MARK**, * **SO_BINDTODEVICE**, **SO_KEEPALIVE**, **SO_REUSEADDR**, * **SO_REUSEPORT**, **SO_BINDTOIFINDEX**, **SO_TXREHASH**. * * **IPPROTO_TCP**, which supports the following *optname*\ s: * **TCP_CONGESTION**, **TCP_BPF_IW**, * **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, * **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**, * **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**, * **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**, * **TCP_BPF_RTO_MIN**, **TCP_BPF_SOCK_OPS_CB_FLAGS**. * * **IPPROTO_IP**, which supports *optname* **IP_TOS**. * * **IPPROTO_IPV6**, which supports the following *optname*\ s: * **IPV6_TCLASS**, **IPV6_AUTOFLOWLABEL**. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_adjust_room(struct sk_buff *skb, s32 len_diff, u32 mode, u64 flags) * Description * Grow or shrink the room for data in the packet associated to * *skb* by *len_diff*, and according to the selected *mode*. * * By default, the helper will reset any offloaded checksum * indicator of the skb to CHECKSUM_NONE. This can be avoided * by the following flag: * * * **BPF_F_ADJ_ROOM_NO_CSUM_RESET**: Do not reset offloaded * checksum data of the skb to CHECKSUM_NONE. * * There are two supported modes at this time: * * * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer * (room space is added or removed between the layer 2 and * layer 3 headers). * * * **BPF_ADJ_ROOM_NET**: Adjust room at the network layer * (room space is added or removed between the layer 3 and * layer 4 headers). * * The following flags are supported at this time: * * * **BPF_F_ADJ_ROOM_FIXED_GSO**: Do not adjust gso_size. * Adjusting mss in this way is not allowed for datagrams. * * * **BPF_F_ADJ_ROOM_ENCAP_L3_IPV4**, * **BPF_F_ADJ_ROOM_ENCAP_L3_IPV6**: * Any new space is reserved to hold a tunnel header. * Configure skb offsets and other fields accordingly. * * * **BPF_F_ADJ_ROOM_ENCAP_L4_GRE**, * **BPF_F_ADJ_ROOM_ENCAP_L4_UDP**: * Use with ENCAP_L3 flags to further specify the tunnel type. * * * **BPF_F_ADJ_ROOM_ENCAP_L2**\ (*len*): * Use with ENCAP_L3/L4 flags to further specify the tunnel * type; *len* is the length of the inner MAC header. * * * **BPF_F_ADJ_ROOM_ENCAP_L2_ETH**: * Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the * L2 type as Ethernet. * * * **BPF_F_ADJ_ROOM_DECAP_L3_IPV4**, * **BPF_F_ADJ_ROOM_DECAP_L3_IPV6**: * Indicate the new IP header version after decapsulating the outer * IP header. Used when the inner and outer IP versions are different. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_redirect_map(struct bpf_map *map, u64 key, u64 flags) * Description * Redirect the packet to the endpoint referenced by *map* at * index *key*. Depending on its type, this *map* can contain * references to net devices (for forwarding packets through other * ports), or to CPUs (for redirecting XDP frames to another CPU; * but this is only implemented for native XDP (with driver * support) as of this writing). * * The lower two bits of *flags* are used as the return code if * the map lookup fails. This is so that the return value can be * one of the XDP program return codes up to **XDP_TX**, as chosen * by the caller. The higher bits of *flags* can be set to * BPF_F_BROADCAST or BPF_F_EXCLUDE_INGRESS as defined below. * * With BPF_F_BROADCAST the packet will be broadcasted to all the * interfaces in the map, with BPF_F_EXCLUDE_INGRESS the ingress * interface will be excluded when do broadcasting. * * See also **bpf_redirect**\ (), which only supports redirecting * to an ifindex, but doesn't require a map to do so. * Return * **XDP_REDIRECT** on success, or the value of the two lower bits * of the *flags* argument on error. * * long bpf_sk_redirect_map(struct sk_buff *skb, struct bpf_map *map, u32 key, u64 flags) * Description * Redirect the packet to the socket referenced by *map* (of type * **BPF_MAP_TYPE_SOCKMAP**) at index *key*. Both ingress and * egress interfaces can be used for redirection. The * **BPF_F_INGRESS** value in *flags* is used to make the * distinction (ingress path is selected if the flag is present, * egress path otherwise). This is the only flag supported for now. * Return * **SK_PASS** on success, or **SK_DROP** on error. * * long bpf_sock_map_update(struct bpf_sock_ops *skops, struct bpf_map *map, void *key, u64 flags) * Description * Add an entry to, or update a *map* referencing sockets. The * *skops* is used as a new value for the entry associated to * *key*. *flags* is one of: * * **BPF_NOEXIST** * The entry for *key* must not exist in the map. * **BPF_EXIST** * The entry for *key* must already exist in the map. * **BPF_ANY** * No condition on the existence of the entry for *key*. * * If the *map* has eBPF programs (parser and verdict), those will * be inherited by the socket being added. If the socket is * already attached to eBPF programs, this results in an error. * Return * 0 on success, or a negative error in case of failure. * * long bpf_xdp_adjust_meta(struct xdp_buff *xdp_md, int delta) * Description * Adjust the address pointed by *xdp_md*\ **->data_meta** by * *delta* (which can be positive or negative). Note that this * operation modifies the address stored in *xdp_md*\ **->data**, * so the latter must be loaded only after the helper has been * called. * * The use of *xdp_md*\ **->data_meta** is optional and programs * are not required to use it. The rationale is that when the * packet is processed with XDP (e.g. as DoS filter), it is * possible to push further meta data along with it before passing * to the stack, and to give the guarantee that an ingress eBPF * program attached as a TC classifier on the same device can pick * this up for further post-processing. Since TC works with socket * buffers, it remains possible to set from XDP the **mark** or * **priority** pointers, or other pointers for the socket buffer. * Having this scratch space generic and programmable allows for * more flexibility as the user is free to store whatever meta * data they need. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_perf_event_read_value(struct bpf_map *map, u64 flags, struct bpf_perf_event_value *buf, u32 buf_size) * Description * Read the value of a perf event counter, and store it into *buf* * of size *buf_size*. This helper relies on a *map* of type * **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. The nature of the perf event * counter is selected when *map* is updated with perf event file * descriptors. The *map* is an array whose size is the number of * available CPUs, and each cell contains a value relative to one * CPU. The value to retrieve is indicated by *flags*, that * contains the index of the CPU to look up, masked with * **BPF_F_INDEX_MASK**. Alternatively, *flags* can be set to * **BPF_F_CURRENT_CPU** to indicate that the value for the * current CPU should be retrieved. * * This helper behaves in a way close to * **bpf_perf_event_read**\ () helper, save that instead of * just returning the value observed, it fills the *buf* * structure. This allows for additional data to be retrieved: in * particular, the enabled and running times (in *buf*\ * **->enabled** and *buf*\ **->running**, respectively) are * copied. In general, **bpf_perf_event_read_value**\ () is * recommended over **bpf_perf_event_read**\ (), which has some * ABI issues and provides fewer functionalities. * * These values are interesting, because hardware PMU (Performance * Monitoring Unit) counters are limited resources. When there are * more PMU based perf events opened than available counters, * kernel will multiplex these events so each event gets certain * percentage (but not all) of the PMU time. In case that * multiplexing happens, the number of samples or counter value * will not reflect the case compared to when no multiplexing * occurs. This makes comparison between different runs difficult. * Typically, the counter value should be normalized before * comparing to other experiments. The usual normalization is done * as follows. * * :: * * normalized_counter = counter * t_enabled / t_running * * Where t_enabled is the time enabled for event and t_running is * the time running for event since last normalization. The * enabled and running times are accumulated since the perf event * open. To achieve scaling factor between two invocations of an * eBPF program, users can use CPU id as the key (which is * typical for perf array usage model) to remember the previous * value and do the calculation inside the eBPF program. * Return * 0 on success, or a negative error in case of failure. * * long bpf_perf_prog_read_value(struct bpf_perf_event_data *ctx, struct bpf_perf_event_value *buf, u32 buf_size) * Description * For an eBPF program attached to a perf event, retrieve the * value of the event counter associated to *ctx* and store it in * the structure pointed by *buf* and of size *buf_size*. Enabled * and running times are also stored in the structure (see * description of helper **bpf_perf_event_read_value**\ () for * more details). * Return * 0 on success, or a negative error in case of failure. * * long bpf_getsockopt(void *bpf_socket, int level, int optname, void *optval, int optlen) * Description * Emulate a call to **getsockopt()** on the socket associated to * *bpf_socket*, which must be a full socket. The *level* at * which the option resides and the name *optname* of the option * must be specified, see **getsockopt(2)** for more information. * The retrieved value is stored in the structure pointed by * *opval* and of length *optlen*. * * *bpf_socket* should be one of the following: * * * **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. * * **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**, * **BPF_CGROUP_INET6_CONNECT** and **BPF_CGROUP_UNIX_CONNECT**. * * This helper actually implements a subset of **getsockopt()**. * It supports the same set of *optname*\ s that is supported by * the **bpf_setsockopt**\ () helper. The exceptions are * **TCP_BPF_*** is **bpf_setsockopt**\ () only and * **TCP_SAVED_SYN** is **bpf_getsockopt**\ () only. * Return * 0 on success, or a negative error in case of failure. * * long bpf_override_return(struct pt_regs *regs, u64 rc) * Description * Used for error injection, this helper uses kprobes to override * the return value of the probed function, and to set it to *rc*. * The first argument is the context *regs* on which the kprobe * works. * * This helper works by setting the PC (program counter) * to an override function which is run in place of the original * probed function. This means the probed function is not run at * all. The replacement function just returns with the required * value. * * This helper has security implications, and thus is subject to * restrictions. It is only available if the kernel was compiled * with the **CONFIG_BPF_KPROBE_OVERRIDE** configuration * option, and in this case it only works on functions tagged with * **ALLOW_ERROR_INJECTION** in the kernel code. * Return * 0 * * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval) * Description * Attempt to set the value of the **bpf_sock_ops_cb_flags** field * for the full TCP socket associated to *bpf_sock_ops* to * *argval*. * * The primary use of this field is to determine if there should * be calls to eBPF programs of type * **BPF_PROG_TYPE_SOCK_OPS** at various points in the TCP * code. A program of the same type can change its value, per * connection and as necessary, when the connection is * established. This field is directly accessible for reading, but * this helper must be used for updates in order to return an * error if an eBPF program tries to set a callback that is not * supported in the current kernel. * * *argval* is a flag array which can combine these flags: * * * **BPF_SOCK_OPS_RTO_CB_FLAG** (retransmission time out) * * **BPF_SOCK_OPS_RETRANS_CB_FLAG** (retransmission) * * **BPF_SOCK_OPS_STATE_CB_FLAG** (TCP state change) * * **BPF_SOCK_OPS_RTT_CB_FLAG** (every RTT) * * Therefore, this function can be used to clear a callback flag by * setting the appropriate bit to zero. e.g. to disable the RTO * callback: * * **bpf_sock_ops_cb_flags_set(bpf_sock,** * **bpf_sock->bpf_sock_ops_cb_flags & ~BPF_SOCK_OPS_RTO_CB_FLAG)** * * Here are some examples of where one could call such eBPF * program: * * * When RTO fires. * * When a packet is retransmitted. * * When the connection terminates. * * When a packet is sent. * * When a packet is received. * Return * Code **-EINVAL** if the socket is not a full TCP socket; * otherwise, a positive number containing the bits that could not * be set is returned (which comes down to 0 if all bits were set * as required). * * long bpf_msg_redirect_map(struct sk_msg_buff *msg, struct bpf_map *map, u32 key, u64 flags) * Description * This helper is used in programs implementing policies at the * socket level. If the message *msg* is allowed to pass (i.e. if * the verdict eBPF program returns **SK_PASS**), redirect it to * the socket referenced by *map* (of type * **BPF_MAP_TYPE_SOCKMAP**) at index *key*. Both ingress and * egress interfaces can be used for redirection. The * **BPF_F_INGRESS** value in *flags* is used to make the * distinction (ingress path is selected if the flag is present, * egress path otherwise). This is the only flag supported for now. * Return * **SK_PASS** on success, or **SK_DROP** on error. * * long bpf_msg_apply_bytes(struct sk_msg_buff *msg, u32 bytes) * Description * For socket policies, apply the verdict of the eBPF program to * the next *bytes* (number of bytes) of message *msg*. * * For example, this helper can be used in the following cases: * * * A single **sendmsg**\ () or **sendfile**\ () system call * contains multiple logical messages that the eBPF program is * supposed to read and for which it should apply a verdict. * * An eBPF program only cares to read the first *bytes* of a * *msg*. If the message has a large payload, then setting up * and calling the eBPF program repeatedly for all bytes, even * though the verdict is already known, would create unnecessary * overhead. * * When called from within an eBPF program, the helper sets a * counter internal to the BPF infrastructure, that is used to * apply the last verdict to the next *bytes*. If *bytes* is * smaller than the current data being processed from a * **sendmsg**\ () or **sendfile**\ () system call, the first * *bytes* will be sent and the eBPF program will be re-run with * the pointer for start of data pointing to byte number *bytes* * **+ 1**. If *bytes* is larger than the current data being * processed, then the eBPF verdict will be applied to multiple * **sendmsg**\ () or **sendfile**\ () calls until *bytes* are * consumed. * * Note that if a socket closes with the internal counter holding * a non-zero value, this is not a problem because data is not * being buffered for *bytes* and is sent as it is received. * Return * 0 * * long bpf_msg_cork_bytes(struct sk_msg_buff *msg, u32 bytes) * Description * For socket policies, prevent the execution of the verdict eBPF * program for message *msg* until *bytes* (byte number) have been * accumulated. * * This can be used when one needs a specific number of bytes * before a verdict can be assigned, even if the data spans * multiple **sendmsg**\ () or **sendfile**\ () calls. The extreme * case would be a user calling **sendmsg**\ () repeatedly with * 1-byte long message segments. Obviously, this is bad for * performance, but it is still valid. If the eBPF program needs * *bytes* bytes to validate a header, this helper can be used to * prevent the eBPF program to be called again until *bytes* have * been accumulated. * Return * 0 * * long bpf_msg_pull_data(struct sk_msg_buff *msg, u32 start, u32 end, u64 flags) * Description * For socket policies, pull in non-linear data from user space * for *msg* and set pointers *msg*\ **->data** and *msg*\ * **->data_end** to *start* and *end* bytes offsets into *msg*, * respectively. * * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a * *msg* it can only parse data that the (**data**, **data_end**) * pointers have already consumed. For **sendmsg**\ () hooks this * is likely the first scatterlist element. But for calls relying * on the **sendpage** handler (e.g. **sendfile**\ ()) this will * be the range (**0**, **0**) because the data is shared with * user space and by default the objective is to avoid allowing * user space to modify data while (or after) eBPF verdict is * being decided. This helper can be used to pull in data and to * set the start and end pointer to given values. Data will be * copied if necessary (i.e. if data was not linear and if start * and end pointers do not point to the same chunk). * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * * All values for *flags* are reserved for future usage, and must * be left at zero. * Return * 0 on success, or a negative error in case of failure. * * long bpf_bind(struct bpf_sock_addr *ctx, struct sockaddr *addr, int addr_len) * Description * Bind the socket associated to *ctx* to the address pointed by * *addr*, of length *addr_len*. This allows for making outgoing * connection from the desired IP address, which can be useful for * example when all processes inside a cgroup should use one * single IP address on a host that has multiple IP configured. * * This helper works for IPv4 and IPv6, TCP and UDP sockets. The * domain (*addr*\ **->sa_family**) must be **AF_INET** (or * **AF_INET6**). It's advised to pass zero port (**sin_port** * or **sin6_port**) which triggers IP_BIND_ADDRESS_NO_PORT-like * behavior and lets the kernel efficiently pick up an unused * port as long as 4-tuple is unique. Passing non-zero port might * lead to degraded performance. * Return * 0 on success, or a negative error in case of failure. * * long bpf_xdp_adjust_tail(struct xdp_buff *xdp_md, int delta) * Description * Adjust (move) *xdp_md*\ **->data_end** by *delta* bytes. It is * possible to both shrink and grow the packet tail. * Shrink done via *delta* being a negative integer. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_skb_get_xfrm_state(struct sk_buff *skb, u32 index, struct bpf_xfrm_state *xfrm_state, u32 size, u64 flags) * Description * Retrieve the XFRM state (IP transform framework, see also * **ip-xfrm(8)**) at *index* in XFRM "security path" for *skb*. * * The retrieved value is stored in the **struct bpf_xfrm_state** * pointed by *xfrm_state* and of length *size*. * * All values for *flags* are reserved for future usage, and must * be left at zero. * * This helper is available only if the kernel was compiled with * **CONFIG_XFRM** configuration option. * Return * 0 on success, or a negative error in case of failure. * * long bpf_get_stack(void *ctx, void *buf, u32 size, u64 flags) * Description * Return a user or a kernel stack in bpf program provided buffer. * To achieve this, the helper needs *ctx*, which is a pointer * to the context on which the tracing program is executed. * To store the stacktrace, the bpf program provides *buf* with * a nonnegative *size*. * * The last argument, *flags*, holds the number of stack frames to * skip (from 0 to 255), masked with * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set * the following flags: * * **BPF_F_USER_STACK** * Collect a user space stack instead of a kernel stack. * **BPF_F_USER_BUILD_ID** * Collect (build_id, file_offset) instead of ips for user * stack, only valid if **BPF_F_USER_STACK** is also * specified. * * *file_offset* is an offset relative to the beginning * of the executable or shared object file backing the vma * which the *ip* falls in. It is *not* an offset relative * to that object's base address. Accordingly, it must be * adjusted by adding (sh_addr - sh_offset), where * sh_{addr,offset} correspond to the executable section * containing *file_offset* in the object, for comparisons * to symbols' st_value to be valid. * * **bpf_get_stack**\ () can collect up to * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject * to sufficient large buffer size. Note that * this limit can be controlled with the **sysctl** program, and * that it should be manually increased in order to profile long * user stacks (such as stacks for Java programs). To do so, use: * * :: * * # sysctl kernel.perf_event_max_stack= * Return * The non-negative copied *buf* length equal to or less than * *size* on success, or a negative error in case of failure. * * long bpf_skb_load_bytes_relative(const void *skb, u32 offset, void *to, u32 len, u32 start_header) * Description * This helper is similar to **bpf_skb_load_bytes**\ () in that * it provides an easy way to load *len* bytes from *offset* * from the packet associated to *skb*, into the buffer pointed * by *to*. The difference to **bpf_skb_load_bytes**\ () is that * a fifth argument *start_header* exists in order to select a * base offset to start from. *start_header* can be one of: * * **BPF_HDR_START_MAC** * Base offset to load data from is *skb*'s mac header. * **BPF_HDR_START_NET** * Base offset to load data from is *skb*'s network header. * * In general, "direct packet access" is the preferred method to * access packet data, however, this helper is in particular useful * in socket filters where *skb*\ **->data** does not always point * to the start of the mac header and where "direct packet access" * is not available. * Return * 0 on success, or a negative error in case of failure. * * long bpf_fib_lookup(void *ctx, struct bpf_fib_lookup *params, int plen, u32 flags) * Description * Do FIB lookup in kernel tables using parameters in *params*. * If lookup is successful and result shows packet is to be * forwarded, the neighbor tables are searched for the nexthop. * If successful (ie., FIB lookup shows forwarding and nexthop * is resolved), the nexthop address is returned in ipv4_dst * or ipv6_dst based on family, smac is set to mac address of * egress device, dmac is set to nexthop mac address, rt_metric * is set to metric from route (IPv4/IPv6 only), and ifindex * is set to the device index of the nexthop from the FIB lookup. * * *plen* argument is the size of the passed in struct. * *flags* argument can be a combination of one or more of the * following values: * * **BPF_FIB_LOOKUP_DIRECT** * Do a direct table lookup vs full lookup using FIB * rules. * **BPF_FIB_LOOKUP_TBID** * Used with BPF_FIB_LOOKUP_DIRECT. * Use the routing table ID present in *params*->tbid * for the fib lookup. * **BPF_FIB_LOOKUP_OUTPUT** * Perform lookup from an egress perspective (default is * ingress). * **BPF_FIB_LOOKUP_SKIP_NEIGH** * Skip the neighbour table lookup. *params*->dmac * and *params*->smac will not be set as output. A common * use case is to call **bpf_redirect_neigh**\ () after * doing **bpf_fib_lookup**\ (). * **BPF_FIB_LOOKUP_SRC** * Derive and set source IP addr in *params*->ipv{4,6}_src * for the nexthop. If the src addr cannot be derived, * **BPF_FIB_LKUP_RET_NO_SRC_ADDR** is returned. In this * case, *params*->dmac and *params*->smac are not set either. * **BPF_FIB_LOOKUP_MARK** * Use the mark present in *params*->mark for the fib lookup. * This option should not be used with BPF_FIB_LOOKUP_DIRECT, * as it only has meaning for full lookups. * * *ctx* is either **struct xdp_md** for XDP programs or * **struct sk_buff** tc cls_act programs. * Return * * < 0 if any input argument is invalid * * 0 on success (packet is forwarded, nexthop neighbor exists) * * > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the * packet is not forwarded or needs assist from full stack * * If lookup fails with BPF_FIB_LKUP_RET_FRAG_NEEDED, then the MTU * was exceeded and output params->mtu_result contains the MTU. * * long bpf_sock_hash_update(struct bpf_sock_ops *skops, struct bpf_map *map, void *key, u64 flags) * Description * Add an entry to, or update a sockhash *map* referencing sockets. * The *skops* is used as a new value for the entry associated to * *key*. *flags* is one of: * * **BPF_NOEXIST** * The entry for *key* must not exist in the map. * **BPF_EXIST** * The entry for *key* must already exist in the map. * **BPF_ANY** * No condition on the existence of the entry for *key*. * * If the *map* has eBPF programs (parser and verdict), those will * be inherited by the socket being added. If the socket is * already attached to eBPF programs, this results in an error. * Return * 0 on success, or a negative error in case of failure. * * long bpf_msg_redirect_hash(struct sk_msg_buff *msg, struct bpf_map *map, void *key, u64 flags) * Description * This helper is used in programs implementing policies at the * socket level. If the message *msg* is allowed to pass (i.e. if * the verdict eBPF program returns **SK_PASS**), redirect it to * the socket referenced by *map* (of type * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and * egress interfaces can be used for redirection. The * **BPF_F_INGRESS** value in *flags* is used to make the * distinction (ingress path is selected if the flag is present, * egress path otherwise). This is the only flag supported for now. * Return * **SK_PASS** on success, or **SK_DROP** on error. * * long bpf_sk_redirect_hash(struct sk_buff *skb, struct bpf_map *map, void *key, u64 flags) * Description * This helper is used in programs implementing policies at the * skb socket level. If the sk_buff *skb* is allowed to pass (i.e. * if the verdict eBPF program returns **SK_PASS**), redirect it * to the socket referenced by *map* (of type * **BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and * egress interfaces can be used for redirection. The * **BPF_F_INGRESS** value in *flags* is used to make the * distinction (ingress path is selected if the flag is present, * egress otherwise). This is the only flag supported for now. * Return * **SK_PASS** on success, or **SK_DROP** on error. * * long bpf_lwt_push_encap(struct sk_buff *skb, u32 type, void *hdr, u32 len) * Description * Encapsulate the packet associated to *skb* within a Layer 3 * protocol header. This header is provided in the buffer at * address *hdr*, with *len* its size in bytes. *type* indicates * the protocol of the header and can be one of: * * **BPF_LWT_ENCAP_SEG6** * IPv6 encapsulation with Segment Routing Header * (**struct ipv6_sr_hdr**). *hdr* only contains the SRH, * the IPv6 header is computed by the kernel. * **BPF_LWT_ENCAP_SEG6_INLINE** * Only works if *skb* contains an IPv6 packet. Insert a * Segment Routing Header (**struct ipv6_sr_hdr**) inside * the IPv6 header. * **BPF_LWT_ENCAP_IP** * IP encapsulation (GRE/GUE/IPIP/etc). The outer header * must be IPv4 or IPv6, followed by zero or more * additional headers, up to **LWT_BPF_MAX_HEADROOM** * total bytes in all prepended headers. Please note that * if **skb_is_gso**\ (*skb*) is true, no more than two * headers can be prepended, and the inner header, if * present, should be either GRE or UDP/GUE. * * **BPF_LWT_ENCAP_SEG6**\ \* types can be called by BPF programs * of type **BPF_PROG_TYPE_LWT_IN**; **BPF_LWT_ENCAP_IP** type can * be called by bpf programs of types **BPF_PROG_TYPE_LWT_IN** and * **BPF_PROG_TYPE_LWT_XMIT**. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_lwt_seg6_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len) * Description * Store *len* bytes from address *from* into the packet * associated to *skb*, at *offset*. Only the flags, tag and TLVs * inside the outermost IPv6 Segment Routing Header can be * modified through this helper. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_lwt_seg6_adjust_srh(struct sk_buff *skb, u32 offset, s32 delta) * Description * Adjust the size allocated to TLVs in the outermost IPv6 * Segment Routing Header contained in the packet associated to * *skb*, at position *offset* by *delta* bytes. Only offsets * after the segments are accepted. *delta* can be as well * positive (growing) as negative (shrinking). * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_lwt_seg6_action(struct sk_buff *skb, u32 action, void *param, u32 param_len) * Description * Apply an IPv6 Segment Routing action of type *action* to the * packet associated to *skb*. Each action takes a parameter * contained at address *param*, and of length *param_len* bytes. * *action* can be one of: * * **SEG6_LOCAL_ACTION_END_X** * End.X action: Endpoint with Layer-3 cross-connect. * Type of *param*: **struct in6_addr**. * **SEG6_LOCAL_ACTION_END_T** * End.T action: Endpoint with specific IPv6 table lookup. * Type of *param*: **int**. * **SEG6_LOCAL_ACTION_END_B6** * End.B6 action: Endpoint bound to an SRv6 policy. * Type of *param*: **struct ipv6_sr_hdr**. * **SEG6_LOCAL_ACTION_END_B6_ENCAP** * End.B6.Encap action: Endpoint bound to an SRv6 * encapsulation policy. * Type of *param*: **struct ipv6_sr_hdr**. * * A call to this helper is susceptible to change the underlying * packet buffer. Therefore, at load time, all checks on pointers * previously done by the verifier are invalidated and must be * performed again, if the helper is used in combination with * direct packet access. * Return * 0 on success, or a negative error in case of failure. * * long bpf_rc_repeat(void *ctx) * Description * This helper is used in programs implementing IR decoding, to * report a successfully decoded repeat key message. This delays * the generation of a key up event for previously generated * key down event. * * Some IR protocols like NEC have a special IR message for * repeating last button, for when a button is held down. * * The *ctx* should point to the lirc sample as passed into * the program. * * This helper is only available is the kernel was compiled with * the **CONFIG_BPF_LIRC_MODE2** configuration option set to * "**y**". * Return * 0 * * long bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) * Description * This helper is used in programs implementing IR decoding, to * report a successfully decoded key press with *scancode*, * *toggle* value in the given *protocol*. The scancode will be * translated to a keycode using the rc keymap, and reported as * an input key down event. After a period a key up event is * generated. This period can be extended by calling either * **bpf_rc_keydown**\ () again with the same values, or calling * **bpf_rc_repeat**\ (). * * Some protocols include a toggle bit, in case the button was * released and pressed again between consecutive scancodes. * * The *ctx* should point to the lirc sample as passed into * the program. * * The *protocol* is the decoded protocol number (see * **enum rc_proto** for some predefined values). * * This helper is only available is the kernel was compiled with * the **CONFIG_BPF_LIRC_MODE2** configuration option set to * "**y**". * Return * 0 * * u64 bpf_skb_cgroup_id(struct sk_buff *skb) * Description * Return the cgroup v2 id of the socket associated with the *skb*. * This is roughly similar to the **bpf_get_cgroup_classid**\ () * helper for cgroup v1 by providing a tag resp. identifier that * can be matched on or used for map lookups e.g. to implement * policy. The cgroup v2 id of a given path in the hierarchy is * exposed in user space through the f_handle API in order to get * to the same 64-bit id. * * This helper can be used on TC egress path, but not on ingress, * and is available only if the kernel was compiled with the * **CONFIG_SOCK_CGROUP_DATA** configuration option. * Return * The id is returned or 0 in case the id could not be retrieved. * * u64 bpf_get_current_cgroup_id(void) * Description * Get the current cgroup id based on the cgroup within which * the current task is running. * Return * A 64-bit integer containing the current cgroup id based * on the cgroup within which the current task is running. * * void *bpf_get_local_storage(void *map, u64 flags) * Description * Get the pointer to the local storage area. * The type and the size of the local storage is defined * by the *map* argument. * The *flags* meaning is specific for each map type, * and has to be 0 for cgroup local storage. * * Depending on the BPF program type, a local storage area * can be shared between multiple instances of the BPF program, * running simultaneously. * * A user should care about the synchronization by himself. * For example, by using the **BPF_ATOMIC** instructions to alter * the shared data. * Return * A pointer to the local storage area. * * long bpf_sk_select_reuseport(struct sk_reuseport_md *reuse, struct bpf_map *map, void *key, u64 flags) * Description * Select a **SO_REUSEPORT** socket from a * **BPF_MAP_TYPE_REUSEPORT_SOCKARRAY** *map*. * It checks the selected socket is matching the incoming * request in the socket buffer. * Return * 0 on success, or a negative error in case of failure. * * u64 bpf_skb_ancestor_cgroup_id(struct sk_buff *skb, int ancestor_level) * Description * Return id of cgroup v2 that is ancestor of cgroup associated * with the *skb* at the *ancestor_level*. The root cgroup is at * *ancestor_level* zero and each step down the hierarchy * increments the level. If *ancestor_level* == level of cgroup * associated with *skb*, then return value will be same as that * of **bpf_skb_cgroup_id**\ (). * * The helper is useful to implement policies based on cgroups * that are upper in hierarchy than immediate cgroup associated * with *skb*. * * The format of returned id and helper limitations are same as in * **bpf_skb_cgroup_id**\ (). * Return * The id is returned or 0 in case the id could not be retrieved. * * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) * Description * Look for TCP socket matching *tuple*, optionally in a child * network namespace *netns*. The return value must be checked, * and if non-**NULL**, released via **bpf_sk_release**\ (). * * The *ctx* should point to the context of the program, such as * the skb or socket (depending on the hook in use). This is used * to determine the base network namespace for the lookup. * * *tuple_size* must be one of: * * **sizeof**\ (*tuple*\ **->ipv4**) * Look for an IPv4 socket. * **sizeof**\ (*tuple*\ **->ipv6**) * Look for an IPv6 socket. * * If the *netns* is a negative signed 32-bit integer, then the * socket lookup table in the netns associated with the *ctx* * will be used. For the TC hooks, this is the netns of the device * in the skb. For socket hooks, this is the netns of the socket. * If *netns* is any other signed 32-bit value greater than or * equal to zero then it specifies the ID of the netns relative to * the netns associated with the *ctx*. *netns* values beyond the * range of 32-bit integers are reserved for future use. * * All values for *flags* are reserved for future usage, and must * be left at zero. * * This helper is available only if the kernel was compiled with * **CONFIG_NET** configuration option. * Return * Pointer to **struct bpf_sock**, or **NULL** in case of failure. * For sockets with reuseport option, the **struct bpf_sock** * result is from *reuse*\ **->socks**\ [] using the hash of the * tuple. * * struct bpf_sock *bpf_sk_lookup_udp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) * Description * Look for UDP socket matching *tuple*, optionally in a child * network namespace *netns*. The return value must be checked, * and if non-**NULL**, released via **bpf_sk_release**\ (). * * The *ctx* should point to the context of the program, such as * the skb or socket (depending on the hook in use). This is used * to determine the base network namespace for the lookup. * * *tuple_size* must be one of: * * **sizeof**\ (*tuple*\ **->ipv4**) * Look for an IPv4 socket. * **sizeof**\ (*tuple*\ **->ipv6**) * Look for an IPv6 socket. * * If the *netns* is a negative signed 32-bit integer, then the * socket lookup table in the netns associated with the *ctx* * will be used. For the TC hooks, this is the netns of the device * in the skb. For socket hooks, this is the netns of the socket. * If *netns* is any other signed 32-bit value greater than or * equal to zero then it specifies the ID of the netns relative to * the netns associated with the *ctx*. *netns* values beyond the * range of 32-bit integers are reserved for future use. * * All values for *flags* are reserved for future usage, and must * be left at zero. * * This helper is available only if the kernel was compiled with * **CONFIG_NET** configuration option. * Return * Pointer to **struct bpf_sock**, or **NULL** in case of failure. * For sockets with reuseport option, the **struct bpf_sock** * result is from *reuse*\ **->socks**\ [] using the hash of the * tuple. * * long bpf_sk_release(void *sock) * Description * Release the reference held by *sock*. *sock* must be a * non-**NULL** pointer that was returned from * **bpf_sk_lookup_xxx**\ (). * Return * 0 on success, or a negative error in case of failure. * * long bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags) * Description * Push an element *value* in *map*. *flags* is one of: * * **BPF_EXIST** * If the queue/stack is full, the oldest element is * removed to make room for this. * Return * 0 on success, or a negative error in case of failure. * * long bpf_map_pop_elem(struct bpf_map *map, void *value) * Description * Pop an element from *map*. * Return * 0 on success, or a negative error in case of failure. * * long bpf_map_peek_elem(struct bpf_map *map, void *value) * Description * Get an element from *map* without removing it. * Return * 0 on success, or a negative error in case of failure. * * long bpf_msg_push_data(struct sk_msg_buff *msg, u32 start, u32 len, u64 flags) * Description * For socket policies, insert *len* bytes into *msg* at offset * *start*. * * If a program of type **BPF_PROG_TYPE_SK_MSG** is run on a * *msg* it may want to insert metadata or options into the *msg*. * This can later be read and used by any of the lower layer BPF * hooks. * * This helper may fail if under memory pressure (a malloc * fails) in these cases BPF programs will get an appropriate * error and BPF programs will need to handle them. * Return * 0 on success, or a negative error in case of failure. * * long bpf_msg_pop_data(struct sk_msg_buff *msg, u32 start, u32 len, u64 flags) * Description * Will remove *len* bytes from a *msg* starting at byte *start*. * This may result in **ENOMEM** errors under certain situations if * an allocation and copy are required due to a full ring buffer. * However, the helper will try to avoid doing the allocation * if possible. Other errors can occur if input parameters are * invalid either due to *start* byte not being valid part of *msg* * payload and/or *pop* value being to large. * Return * 0 on success, or a negative error in case of failure. * * long bpf_rc_pointer_rel(void *ctx, s32 rel_x, s32 rel_y) * Description * This helper is used in programs implementing IR decoding, to * report a successfully decoded pointer movement. * * The *ctx* should point to the lirc sample as passed into * the program. * * This helper is only available is the kernel was compiled with * the **CONFIG_BPF_LIRC_MODE2** configuration option set to * "**y**". * Return * 0 * * long bpf_spin_lock(struct bpf_spin_lock *lock) * Description * Acquire a spinlock represented by the pointer *lock*, which is * stored as part of a value of a map. Taking the lock allows to * safely update the rest of the fields in that value. The * spinlock can (and must) later be released with a call to * **bpf_spin_unlock**\ (\ *lock*\ ). * * Spinlocks in BPF programs come with a number of restrictions * and constraints: * * * **bpf_spin_lock** objects are only allowed inside maps of * types **BPF_MAP_TYPE_HASH** and **BPF_MAP_TYPE_ARRAY** (this * list could be extended in the future). * * BTF description of the map is mandatory. * * The BPF program can take ONE lock at a time, since taking two * or more could cause dead locks. * * Only one **struct bpf_spin_lock** is allowed per map element. * * When the lock is taken, calls (either BPF to BPF or helpers) * are not allowed. * * The **BPF_LD_ABS** and **BPF_LD_IND** instructions are not * allowed inside a spinlock-ed region. * * The BPF program MUST call **bpf_spin_unlock**\ () to release * the lock, on all execution paths, before it returns. * * The BPF program can access **struct bpf_spin_lock** only via * the **bpf_spin_lock**\ () and **bpf_spin_unlock**\ () * helpers. Loading or storing data into the **struct * bpf_spin_lock** *lock*\ **;** field of a map is not allowed. * * To use the **bpf_spin_lock**\ () helper, the BTF description * of the map value must be a struct and have **struct * bpf_spin_lock** *anyname*\ **;** field at the top level. * Nested lock inside another struct is not allowed. * * The **struct bpf_spin_lock** *lock* field in a map value must * be aligned on a multiple of 4 bytes in that value. * * Syscall with command **BPF_MAP_LOOKUP_ELEM** does not copy * the **bpf_spin_lock** field to user space. * * Syscall with command **BPF_MAP_UPDATE_ELEM**, or update from * a BPF program, do not update the **bpf_spin_lock** field. * * **bpf_spin_lock** cannot be on the stack or inside a * networking packet (it can only be inside of a map values). * * **bpf_spin_lock** is available to root only. * * Tracing programs and socket filter programs cannot use * **bpf_spin_lock**\ () due to insufficient preemption checks * (but this may change in the future). * * **bpf_spin_lock** is not allowed in inner maps of map-in-map. * Return * 0 * * long bpf_spin_unlock(struct bpf_spin_lock *lock) * Description * Release the *lock* previously locked by a call to * **bpf_spin_lock**\ (\ *lock*\ ). * Return * 0 * * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk) * Description * This helper gets a **struct bpf_sock** pointer such * that all the fields in this **bpf_sock** can be accessed. * Return * A **struct bpf_sock** pointer on success, or **NULL** in * case of failure. * * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk) * Description * This helper gets a **struct bpf_tcp_sock** pointer from a * **struct bpf_sock** pointer. * Return * A **struct bpf_tcp_sock** pointer on success, or **NULL** in * case of failure. * * long bpf_skb_ecn_set_ce(struct sk_buff *skb) * Description * Set ECN (Explicit Congestion Notification) field of IP header * to **CE** (Congestion Encountered) if current value is **ECT** * (ECN Capable Transport). Otherwise, do nothing. Works with IPv6 * and IPv4. * Return * 1 if the **CE** flag is set (either by the current helper call * or because it was already present), 0 if it is not set. * * struct bpf_sock *bpf_get_listener_sock(struct bpf_sock *sk) * Description * Return a **struct bpf_sock** pointer in **TCP_LISTEN** state. * **bpf_sk_release**\ () is unnecessary and not allowed. * Return * A **struct bpf_sock** pointer on success, or **NULL** in * case of failure. * * struct bpf_sock *bpf_skc_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) * Description * Look for TCP socket matching *tuple*, optionally in a child * network namespace *netns*. The return value must be checked, * and if non-**NULL**, released via **bpf_sk_release**\ (). * * This function is identical to **bpf_sk_lookup_tcp**\ (), except * that it also returns timewait or request sockets. Use * **bpf_sk_fullsock**\ () or **bpf_tcp_sock**\ () to access the * full structure. * * This helper is available only if the kernel was compiled with * **CONFIG_NET** configuration option. * Return * Pointer to **struct bpf_sock**, or **NULL** in case of failure. * For sockets with reuseport option, the **struct bpf_sock** * result is from *reuse*\ **->socks**\ [] using the hash of the * tuple. * * long bpf_tcp_check_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len) * Description * Check whether *iph* and *th* contain a valid SYN cookie ACK for * the listening socket in *sk*. * * *iph* points to the start of the IPv4 or IPv6 header, while * *iph_len* contains **sizeof**\ (**struct iphdr**) or * **sizeof**\ (**struct ipv6hdr**). * * *th* points to the start of the TCP header, while *th_len* * contains the length of the TCP header (at least * **sizeof**\ (**struct tcphdr**)). * Return * 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative * error otherwise. * * long bpf_sysctl_get_name(struct bpf_sysctl *ctx, char *buf, size_t buf_len, u64 flags) * Description * Get name of sysctl in /proc/sys/ and copy it into provided by * program buffer *buf* of size *buf_len*. * * The buffer is always NUL terminated, unless it's zero-sized. * * If *flags* is zero, full name (e.g. "net/ipv4/tcp_mem") is * copied. Use **BPF_F_SYSCTL_BASE_NAME** flag to copy base name * only (e.g. "tcp_mem"). * Return * Number of character copied (not including the trailing NUL). * * **-E2BIG** if the buffer wasn't big enough (*buf* will contain * truncated name in this case). * * long bpf_sysctl_get_current_value(struct bpf_sysctl *ctx, char *buf, size_t buf_len) * Description * Get current value of sysctl as it is presented in /proc/sys * (incl. newline, etc), and copy it as a string into provided * by program buffer *buf* of size *buf_len*. * * The whole value is copied, no matter what file position user * space issued e.g. sys_read at. * * The buffer is always NUL terminated, unless it's zero-sized. * Return * Number of character copied (not including the trailing NUL). * * **-E2BIG** if the buffer wasn't big enough (*buf* will contain * truncated name in this case). * * **-EINVAL** if current value was unavailable, e.g. because * sysctl is uninitialized and read returns -EIO for it. * * long bpf_sysctl_get_new_value(struct bpf_sysctl *ctx, char *buf, size_t buf_len) * Description * Get new value being written by user space to sysctl (before * the actual write happens) and copy it as a string into * provided by program buffer *buf* of size *buf_len*. * * User space may write new value at file position > 0. * * The buffer is always NUL terminated, unless it's zero-sized. * Return * Number of character copied (not including the trailing NUL). * * **-E2BIG** if the buffer wasn't big enough (*buf* will contain * truncated name in this case). * * **-EINVAL** if sysctl is being read. * * long bpf_sysctl_set_new_value(struct bpf_sysctl *ctx, const char *buf, size_t buf_len) * Description * Override new value being written by user space to sysctl with * value provided by program in buffer *buf* of size *buf_len*. * * *buf* should contain a string in same form as provided by user * space on sysctl write. * * User space may write new value at file position > 0. To override * the whole sysctl value file position should be set to zero. * Return * 0 on success. * * **-E2BIG** if the *buf_len* is too big. * * **-EINVAL** if sysctl is being read. * * long bpf_strtol(const char *buf, size_t buf_len, u64 flags, long *res) * Description * Convert the initial part of the string from buffer *buf* of * size *buf_len* to a long integer according to the given base * and save the result in *res*. * * The string may begin with an arbitrary amount of white space * (as determined by **isspace**\ (3)) followed by a single * optional '**-**' sign. * * Five least significant bits of *flags* encode base, other bits * are currently unused. * * Base must be either 8, 10, 16 or 0 to detect it automatically * similar to user space **strtol**\ (3). * Return * Number of characters consumed on success. Must be positive but * no more than *buf_len*. * * **-EINVAL** if no valid digits were found or unsupported base * was provided. * * **-ERANGE** if resulting value was out of range. * * long bpf_strtoul(const char *buf, size_t buf_len, u64 flags, unsigned long *res) * Description * Convert the initial part of the string from buffer *buf* of * size *buf_len* to an unsigned long integer according to the * given base and save the result in *res*. * * The string may begin with an arbitrary amount of white space * (as determined by **isspace**\ (3)). * * Five least significant bits of *flags* encode base, other bits * are currently unused. * * Base must be either 8, 10, 16 or 0 to detect it automatically * similar to user space **strtoul**\ (3). * Return * Number of characters consumed on success. Must be positive but * no more than *buf_len*. * * **-EINVAL** if no valid digits were found or unsupported base * was provided. * * **-ERANGE** if resulting value was out of range. * * void *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags) * Description * Get a bpf-local-storage from a *sk*. * * Logically, it could be thought of getting the value from * a *map* with *sk* as the **key**. From this * perspective, the usage is not much different from * **bpf_map_lookup_elem**\ (*map*, **&**\ *sk*) except this * helper enforces the key must be a full socket and the map must * be a **BPF_MAP_TYPE_SK_STORAGE** also. * * Underneath, the value is stored locally at *sk* instead of * the *map*. The *map* is used as the bpf-local-storage * "type". The bpf-local-storage "type" (i.e. the *map*) is * searched against all bpf-local-storages residing at *sk*. * * *sk* is a kernel **struct sock** pointer for LSM program. * *sk* is a **struct bpf_sock** pointer for other program types. * * An optional *flags* (**BPF_SK_STORAGE_GET_F_CREATE**) can be * used such that a new bpf-local-storage will be * created if one does not exist. *value* can be used * together with **BPF_SK_STORAGE_GET_F_CREATE** to specify * the initial value of a bpf-local-storage. If *value* is * **NULL**, the new bpf-local-storage will be zero initialized. * Return * A bpf-local-storage pointer is returned on success. * * **NULL** if not found or there was an error in adding * a new bpf-local-storage. * * long bpf_sk_storage_delete(struct bpf_map *map, void *sk) * Description * Delete a bpf-local-storage from a *sk*. * Return * 0 on success. * * **-ENOENT** if the bpf-local-storage cannot be found. * **-EINVAL** if sk is not a fullsock (e.g. a request_sock). * * long bpf_send_signal(u32 sig) * Description * Send signal *sig* to the process of the current task. * The signal may be delivered to any of this process's threads. * Return * 0 on success or successfully queued. * * **-EBUSY** if work queue under nmi is full. * * **-EINVAL** if *sig* is invalid. * * **-EPERM** if no permission to send the *sig*. * * **-EAGAIN** if bpf program can try again. * * s64 bpf_tcp_gen_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len) * Description * Try to issue a SYN cookie for the packet with corresponding * IP/TCP headers, *iph* and *th*, on the listening socket in *sk*. * * *iph* points to the start of the IPv4 or IPv6 header, while * *iph_len* contains **sizeof**\ (**struct iphdr**) or * **sizeof**\ (**struct ipv6hdr**). * * *th* points to the start of the TCP header, while *th_len* * contains the length of the TCP header with options (at least * **sizeof**\ (**struct tcphdr**)). * Return * On success, lower 32 bits hold the generated SYN cookie in * followed by 16 bits which hold the MSS value for that cookie, * and the top 16 bits are unused. * * On failure, the returned value is one of the following: * * **-EINVAL** SYN cookie cannot be issued due to error * * **-ENOENT** SYN cookie should not be issued (no SYN flood) * * **-EOPNOTSUPP** kernel configuration does not enable SYN cookies * * **-EPROTONOSUPPORT** IP packet version is not 4 or 6 * * long bpf_skb_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) * Description * Write raw *data* blob into a special BPF perf event held by * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf * event must have the following attributes: **PERF_SAMPLE_RAW** * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. * * The *flags* are used to indicate the index in *map* for which * the value must be put, masked with **BPF_F_INDEX_MASK**. * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** * to indicate that the index of the current CPU core should be * used. * * The value to write, of *size*, is passed through eBPF stack and * pointed by *data*. * * *ctx* is a pointer to in-kernel struct sk_buff. * * This helper is similar to **bpf_perf_event_output**\ () but * restricted to raw_tracepoint bpf programs. * Return * 0 on success, or a negative error in case of failure. * * long bpf_probe_read_user(void *dst, u32 size, const void *unsafe_ptr) * Description * Safely attempt to read *size* bytes from user space address * *unsafe_ptr* and store the data in *dst*. * Return * 0 on success, or a negative error in case of failure. * * long bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr) * Description * Safely attempt to read *size* bytes from kernel space address * *unsafe_ptr* and store the data in *dst*. * Return * 0 on success, or a negative error in case of failure. * * long bpf_probe_read_user_str(void *dst, u32 size, const void *unsafe_ptr) * Description * Copy a NUL terminated string from an unsafe user address * *unsafe_ptr* to *dst*. The *size* should include the * terminating NUL byte. In case the string length is smaller than * *size*, the target is not padded with further NUL bytes. If the * string length is larger than *size*, just *size*-1 bytes are * copied and the last byte is set to NUL. * * On success, returns the number of bytes that were written, * including the terminal NUL. This makes this helper useful in * tracing programs for reading strings, and more importantly to * get its length at runtime. See the following snippet: * * :: * * SEC("kprobe/sys_open") * void bpf_sys_open(struct pt_regs *ctx) * { * char buf[PATHLEN]; // PATHLEN is defined to 256 * int res = bpf_probe_read_user_str(buf, sizeof(buf), * ctx->di); * * // Consume buf, for example push it to * // userspace via bpf_perf_event_output(); we * // can use res (the string length) as event * // size, after checking its boundaries. * } * * In comparison, using **bpf_probe_read_user**\ () helper here * instead to read the string would require to estimate the length * at compile time, and would often result in copying more memory * than necessary. * * Another useful use case is when parsing individual process * arguments or individual environment variables navigating * *current*\ **->mm->arg_start** and *current*\ * **->mm->env_start**: using this helper and the return value, * one can quickly iterate at the right offset of the memory area. * Return * On success, the strictly positive length of the output string, * including the trailing NUL character. On error, a negative * value. * * long bpf_probe_read_kernel_str(void *dst, u32 size, const void *unsafe_ptr) * Description * Copy a NUL terminated string from an unsafe kernel address *unsafe_ptr* * to *dst*. Same semantics as with **bpf_probe_read_user_str**\ () apply. * Return * On success, the strictly positive length of the string, including * the trailing NUL character. On error, a negative value. * * long bpf_tcp_send_ack(void *tp, u32 rcv_nxt) * Description * Send out a tcp-ack. *tp* is the in-kernel struct **tcp_sock**. * *rcv_nxt* is the ack_seq to be sent out. * Return * 0 on success, or a negative error in case of failure. * * long bpf_send_signal_thread(u32 sig) * Description * Send signal *sig* to the thread corresponding to the current task. * Return * 0 on success or successfully queued. * * **-EBUSY** if work queue under nmi is full. * * **-EINVAL** if *sig* is invalid. * * **-EPERM** if no permission to send the *sig*. * * **-EAGAIN** if bpf program can try again. * * u64 bpf_jiffies64(void) * Description * Obtain the 64bit jiffies * Return * The 64 bit jiffies * * long bpf_read_branch_records(struct bpf_perf_event_data *ctx, void *buf, u32 size, u64 flags) * Description * For an eBPF program attached to a perf event, retrieve the * branch records (**struct perf_branch_entry**) associated to *ctx* * and store it in the buffer pointed by *buf* up to size * *size* bytes. * Return * On success, number of bytes written to *buf*. On error, a * negative value. * * The *flags* can be set to **BPF_F_GET_BRANCH_RECORDS_SIZE** to * instead return the number of bytes required to store all the * branch entries. If this flag is set, *buf* may be NULL. * * **-EINVAL** if arguments invalid or **size** not a multiple * of **sizeof**\ (**struct perf_branch_entry**\ ). * * **-ENOENT** if architecture does not support branch records. * * long bpf_get_ns_current_pid_tgid(u64 dev, u64 ino, struct bpf_pidns_info *nsdata, u32 size) * Description * Returns 0 on success, values for *pid* and *tgid* as seen from the current * *namespace* will be returned in *nsdata*. * Return * 0 on success, or one of the following in case of failure: * * **-EINVAL** if dev and inum supplied don't match dev_t and inode number * with nsfs of current task, or if dev conversion to dev_t lost high bits. * * **-ENOENT** if pidns does not exists for the current task. * * long bpf_xdp_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) * Description * Write raw *data* blob into a special BPF perf event held by * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf * event must have the following attributes: **PERF_SAMPLE_RAW** * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. * * The *flags* are used to indicate the index in *map* for which * the value must be put, masked with **BPF_F_INDEX_MASK**. * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** * to indicate that the index of the current CPU core should be * used. * * The value to write, of *size*, is passed through eBPF stack and * pointed by *data*. * * *ctx* is a pointer to in-kernel struct xdp_buff. * * This helper is similar to **bpf_perf_eventoutput**\ () but * restricted to raw_tracepoint bpf programs. * Return * 0 on success, or a negative error in case of failure. * * u64 bpf_get_netns_cookie(void *ctx) * Description * Retrieve the cookie (generated by the kernel) of the network * namespace the input *ctx* is associated with. The network * namespace cookie remains stable for its lifetime and provides * a global identifier that can be assumed unique. If *ctx* is * NULL, then the helper returns the cookie for the initial * network namespace. The cookie itself is very similar to that * of **bpf_get_socket_cookie**\ () helper, but for network * namespaces instead of sockets. * Return * A 8-byte long opaque number. * * u64 bpf_get_current_ancestor_cgroup_id(int ancestor_level) * Description * Return id of cgroup v2 that is ancestor of the cgroup associated * with the current task at the *ancestor_level*. The root cgroup * is at *ancestor_level* zero and each step down the hierarchy * increments the level. If *ancestor_level* == level of cgroup * associated with the current task, then return value will be the * same as that of **bpf_get_current_cgroup_id**\ (). * * The helper is useful to implement policies based on cgroups * that are upper in hierarchy than immediate cgroup associated * with the current task. * * The format of returned id and helper limitations are same as in * **bpf_get_current_cgroup_id**\ (). * Return * The id is returned or 0 in case the id could not be retrieved. * * long bpf_sk_assign(struct sk_buff *skb, void *sk, u64 flags) * Description * Helper is overloaded depending on BPF program type. This * description applies to **BPF_PROG_TYPE_SCHED_CLS** and * **BPF_PROG_TYPE_SCHED_ACT** programs. * * Assign the *sk* to the *skb*. When combined with appropriate * routing configuration to receive the packet towards the socket, * will cause *skb* to be delivered to the specified socket. * Subsequent redirection of *skb* via **bpf_redirect**\ (), * **bpf_clone_redirect**\ () or other methods outside of BPF may * interfere with successful delivery to the socket. * * This operation is only valid from TC ingress path. * * The *flags* argument must be zero. * Return * 0 on success, or a negative error in case of failure: * * **-EINVAL** if specified *flags* are not supported. * * **-ENOENT** if the socket is unavailable for assignment. * * **-ENETUNREACH** if the socket is unreachable (wrong netns). * * **-EOPNOTSUPP** if the operation is not supported, for example * a call from outside of TC ingress. * * long bpf_sk_assign(struct bpf_sk_lookup *ctx, struct bpf_sock *sk, u64 flags) * Description * Helper is overloaded depending on BPF program type. This * description applies to **BPF_PROG_TYPE_SK_LOOKUP** programs. * * Select the *sk* as a result of a socket lookup. * * For the operation to succeed passed socket must be compatible * with the packet description provided by the *ctx* object. * * L4 protocol (**IPPROTO_TCP** or **IPPROTO_UDP**) must * be an exact match. While IP family (**AF_INET** or * **AF_INET6**) must be compatible, that is IPv6 sockets * that are not v6-only can be selected for IPv4 packets. * * Only TCP listeners and UDP unconnected sockets can be * selected. *sk* can also be NULL to reset any previous * selection. * * *flags* argument can combination of following values: * * * **BPF_SK_LOOKUP_F_REPLACE** to override the previous * socket selection, potentially done by a BPF program * that ran before us. * * * **BPF_SK_LOOKUP_F_NO_REUSEPORT** to skip * load-balancing within reuseport group for the socket * being selected. * * On success *ctx->sk* will point to the selected socket. * * Return * 0 on success, or a negative errno in case of failure. * * * **-EAFNOSUPPORT** if socket family (*sk->family*) is * not compatible with packet family (*ctx->family*). * * * **-EEXIST** if socket has been already selected, * potentially by another program, and * **BPF_SK_LOOKUP_F_REPLACE** flag was not specified. * * * **-EINVAL** if unsupported flags were specified. * * * **-EPROTOTYPE** if socket L4 protocol * (*sk->protocol*) doesn't match packet protocol * (*ctx->protocol*). * * * **-ESOCKTNOSUPPORT** if socket is not in allowed * state (TCP listening or UDP unconnected). * * u64 bpf_ktime_get_boot_ns(void) * Description * Return the time elapsed since system boot, in nanoseconds. * Does include the time the system was suspended. * See: **clock_gettime**\ (**CLOCK_BOOTTIME**) * Return * Current *ktime*. * * long bpf_seq_printf(struct seq_file *m, const char *fmt, u32 fmt_size, const void *data, u32 data_len) * Description * **bpf_seq_printf**\ () uses seq_file **seq_printf**\ () to print * out the format string. * The *m* represents the seq_file. The *fmt* and *fmt_size* are for * the format string itself. The *data* and *data_len* are format string * arguments. The *data* are a **u64** array and corresponding format string * values are stored in the array. For strings and pointers where pointees * are accessed, only the pointer values are stored in the *data* array. * The *data_len* is the size of *data* in bytes - must be a multiple of 8. * * Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory. * Reading kernel memory may fail due to either invalid address or * valid address but requiring a major memory fault. If reading kernel memory * fails, the string for **%s** will be an empty string, and the ip * address for **%p{i,I}{4,6}** will be 0. Not returning error to * bpf program is consistent with what **bpf_trace_printk**\ () does for now. * Return * 0 on success, or a negative error in case of failure: * * **-EBUSY** if per-CPU memory copy buffer is busy, can try again * by returning 1 from bpf program. * * **-EINVAL** if arguments are invalid, or if *fmt* is invalid/unsupported. * * **-E2BIG** if *fmt* contains too many format specifiers. * * **-EOVERFLOW** if an overflow happened: The same object will be tried again. * * long bpf_seq_write(struct seq_file *m, const void *data, u32 len) * Description * **bpf_seq_write**\ () uses seq_file **seq_write**\ () to write the data. * The *m* represents the seq_file. The *data* and *len* represent the * data to write in bytes. * Return * 0 on success, or a negative error in case of failure: * * **-EOVERFLOW** if an overflow happened: The same object will be tried again. * * u64 bpf_sk_cgroup_id(void *sk) * Description * Return the cgroup v2 id of the socket *sk*. * * *sk* must be a non-**NULL** pointer to a socket, e.g. one * returned from **bpf_sk_lookup_xxx**\ (), * **bpf_sk_fullsock**\ (), etc. The format of returned id is * same as in **bpf_skb_cgroup_id**\ (). * * This helper is available only if the kernel was compiled with * the **CONFIG_SOCK_CGROUP_DATA** configuration option. * Return * The id is returned or 0 in case the id could not be retrieved. * * u64 bpf_sk_ancestor_cgroup_id(void *sk, int ancestor_level) * Description * Return id of cgroup v2 that is ancestor of cgroup associated * with the *sk* at the *ancestor_level*. The root cgroup is at * *ancestor_level* zero and each step down the hierarchy * increments the level. If *ancestor_level* == level of cgroup * associated with *sk*, then return value will be same as that * of **bpf_sk_cgroup_id**\ (). * * The helper is useful to implement policies based on cgroups * that are upper in hierarchy than immediate cgroup associated * with *sk*. * * The format of returned id and helper limitations are same as in * **bpf_sk_cgroup_id**\ (). * Return * The id is returned or 0 in case the id could not be retrieved. * * long bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) * Description * Copy *size* bytes from *data* into a ring buffer *ringbuf*. * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification * of new data availability is sent. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. * If **0** is specified in *flags*, an adaptive notification * of new data availability is sent. * * An adaptive notification is a notification sent whenever the user-space * process has caught up and consumed all available payloads. In case the user-space * process is still processing a previous payload, then no notification is needed * as it will process the newly added payload automatically. * Return * 0 on success, or a negative error in case of failure. * * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags) * Description * Reserve *size* bytes of payload in a ring buffer *ringbuf*. * *flags* must be 0. * Return * Valid pointer with *size* bytes of memory available; NULL, * otherwise. * * void bpf_ringbuf_submit(void *data, u64 flags) * Description * Submit reserved ring buffer sample, pointed to by *data*. * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification * of new data availability is sent. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. * If **0** is specified in *flags*, an adaptive notification * of new data availability is sent. * * See 'bpf_ringbuf_output()' for the definition of adaptive notification. * Return * Nothing. Always succeeds. * * void bpf_ringbuf_discard(void *data, u64 flags) * Description * Discard reserved ring buffer sample, pointed to by *data*. * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification * of new data availability is sent. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. * If **0** is specified in *flags*, an adaptive notification * of new data availability is sent. * * See 'bpf_ringbuf_output()' for the definition of adaptive notification. * Return * Nothing. Always succeeds. * * u64 bpf_ringbuf_query(void *ringbuf, u64 flags) * Description * Query various characteristics of provided ring buffer. What * exactly is queries is determined by *flags*: * * * **BPF_RB_AVAIL_DATA**: Amount of data not yet consumed. * * **BPF_RB_RING_SIZE**: The size of ring buffer. * * **BPF_RB_CONS_POS**: Consumer position (can wrap around). * * **BPF_RB_PROD_POS**: Producer(s) position (can wrap around). * * Data returned is just a momentary snapshot of actual values * and could be inaccurate, so this facility should be used to * power heuristics and for reporting, not to make 100% correct * calculation. * Return * Requested value, or 0, if *flags* are not recognized. * * long bpf_csum_level(struct sk_buff *skb, u64 level) * Description * Change the skbs checksum level by one layer up or down, or * reset it entirely to none in order to have the stack perform * checksum validation. The level is applicable to the following * protocols: TCP, UDP, GRE, SCTP, FCOE. For example, a decap of * | ETH | IP | UDP | GUE | IP | TCP | into | ETH | IP | TCP | * through **bpf_skb_adjust_room**\ () helper with passing in * **BPF_F_ADJ_ROOM_NO_CSUM_RESET** flag would require one call * to **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_DEC** since * the UDP header is removed. Similarly, an encap of the latter * into the former could be accompanied by a helper call to * **bpf_csum_level**\ () with **BPF_CSUM_LEVEL_INC** if the * skb is still intended to be processed in higher layers of the * stack instead of just egressing at tc. * * There are three supported level settings at this time: * * * **BPF_CSUM_LEVEL_INC**: Increases skb->csum_level for skbs * with CHECKSUM_UNNECESSARY. * * **BPF_CSUM_LEVEL_DEC**: Decreases skb->csum_level for skbs * with CHECKSUM_UNNECESSARY. * * **BPF_CSUM_LEVEL_RESET**: Resets skb->csum_level to 0 and * sets CHECKSUM_NONE to force checksum validation by the stack. * * **BPF_CSUM_LEVEL_QUERY**: No-op, returns the current * skb->csum_level. * Return * 0 on success, or a negative error in case of failure. In the * case of **BPF_CSUM_LEVEL_QUERY**, the current skb->csum_level * is returned or the error code -EACCES in case the skb is not * subject to CHECKSUM_UNNECESSARY. * * struct tcp6_sock *bpf_skc_to_tcp6_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *tcp6_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * struct tcp_sock *bpf_skc_to_tcp_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *tcp_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * struct tcp_timewait_sock *bpf_skc_to_tcp_timewait_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *tcp_timewait_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * struct tcp_request_sock *bpf_skc_to_tcp_request_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *tcp_request_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * struct udp6_sock *bpf_skc_to_udp6_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *udp6_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * long bpf_get_task_stack(struct task_struct *task, void *buf, u32 size, u64 flags) * Description * Return a user or a kernel stack in bpf program provided buffer. * Note: the user stack will only be populated if the *task* is * the current task; all other tasks will return -EOPNOTSUPP. * To achieve this, the helper needs *task*, which is a valid * pointer to **struct task_struct**. To store the stacktrace, the * bpf program provides *buf* with a nonnegative *size*. * * The last argument, *flags*, holds the number of stack frames to * skip (from 0 to 255), masked with * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set * the following flags: * * **BPF_F_USER_STACK** * Collect a user space stack instead of a kernel stack. * The *task* must be the current task. * **BPF_F_USER_BUILD_ID** * Collect buildid+offset instead of ips for user stack, * only valid if **BPF_F_USER_STACK** is also specified. * * **bpf_get_task_stack**\ () can collect up to * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject * to sufficient large buffer size. Note that * this limit can be controlled with the **sysctl** program, and * that it should be manually increased in order to profile long * user stacks (such as stacks for Java programs). To do so, use: * * :: * * # sysctl kernel.perf_event_max_stack= * Return * The non-negative copied *buf* length equal to or less than * *size* on success, or a negative error in case of failure. * * long bpf_load_hdr_opt(struct bpf_sock_ops *skops, void *searchby_res, u32 len, u64 flags) * Description * Load header option. Support reading a particular TCP header * option for bpf program (**BPF_PROG_TYPE_SOCK_OPS**). * * If *flags* is 0, it will search the option from the * *skops*\ **->skb_data**. The comment in **struct bpf_sock_ops** * has details on what skb_data contains under different * *skops*\ **->op**. * * The first byte of the *searchby_res* specifies the * kind that it wants to search. * * If the searching kind is an experimental kind * (i.e. 253 or 254 according to RFC6994). It also * needs to specify the "magic" which is either * 2 bytes or 4 bytes. It then also needs to * specify the size of the magic by using * the 2nd byte which is "kind-length" of a TCP * header option and the "kind-length" also * includes the first 2 bytes "kind" and "kind-length" * itself as a normal TCP header option also does. * * For example, to search experimental kind 254 with * 2 byte magic 0xeB9F, the searchby_res should be * [ 254, 4, 0xeB, 0x9F, 0, 0, .... 0 ]. * * To search for the standard window scale option (3), * the *searchby_res* should be [ 3, 0, 0, .... 0 ]. * Note, kind-length must be 0 for regular option. * * Searching for No-Op (0) and End-of-Option-List (1) are * not supported. * * *len* must be at least 2 bytes which is the minimal size * of a header option. * * Supported flags: * * * **BPF_LOAD_HDR_OPT_TCP_SYN** to search from the * saved_syn packet or the just-received syn packet. * * Return * > 0 when found, the header option is copied to *searchby_res*. * The return value is the total length copied. On failure, a * negative error code is returned: * * **-EINVAL** if a parameter is invalid. * * **-ENOMSG** if the option is not found. * * **-ENOENT** if no syn packet is available when * **BPF_LOAD_HDR_OPT_TCP_SYN** is used. * * **-ENOSPC** if there is not enough space. Only *len* number of * bytes are copied. * * **-EFAULT** on failure to parse the header options in the * packet. * * **-EPERM** if the helper cannot be used under the current * *skops*\ **->op**. * * long bpf_store_hdr_opt(struct bpf_sock_ops *skops, const void *from, u32 len, u64 flags) * Description * Store header option. The data will be copied * from buffer *from* with length *len* to the TCP header. * * The buffer *from* should have the whole option that * includes the kind, kind-length, and the actual * option data. The *len* must be at least kind-length * long. The kind-length does not have to be 4 byte * aligned. The kernel will take care of the padding * and setting the 4 bytes aligned value to th->doff. * * This helper will check for duplicated option * by searching the same option in the outgoing skb. * * This helper can only be called during * **BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. * * Return * 0 on success, or negative error in case of failure: * * **-EINVAL** If param is invalid. * * **-ENOSPC** if there is not enough space in the header. * Nothing has been written * * **-EEXIST** if the option already exists. * * **-EFAULT** on failure to parse the existing header options. * * **-EPERM** if the helper cannot be used under the current * *skops*\ **->op**. * * long bpf_reserve_hdr_opt(struct bpf_sock_ops *skops, u32 len, u64 flags) * Description * Reserve *len* bytes for the bpf header option. The * space will be used by **bpf_store_hdr_opt**\ () later in * **BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. * * If **bpf_reserve_hdr_opt**\ () is called multiple times, * the total number of bytes will be reserved. * * This helper can only be called during * **BPF_SOCK_OPS_HDR_OPT_LEN_CB**. * * Return * 0 on success, or negative error in case of failure: * * **-EINVAL** if a parameter is invalid. * * **-ENOSPC** if there is not enough space in the header. * * **-EPERM** if the helper cannot be used under the current * *skops*\ **->op**. * * void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags) * Description * Get a bpf_local_storage from an *inode*. * * Logically, it could be thought of as getting the value from * a *map* with *inode* as the **key**. From this * perspective, the usage is not much different from * **bpf_map_lookup_elem**\ (*map*, **&**\ *inode*) except this * helper enforces the key must be an inode and the map must also * be a **BPF_MAP_TYPE_INODE_STORAGE**. * * Underneath, the value is stored locally at *inode* instead of * the *map*. The *map* is used as the bpf-local-storage * "type". The bpf-local-storage "type" (i.e. the *map*) is * searched against all bpf_local_storage residing at *inode*. * * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be * used such that a new bpf_local_storage will be * created if one does not exist. *value* can be used * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify * the initial value of a bpf_local_storage. If *value* is * **NULL**, the new bpf_local_storage will be zero initialized. * Return * A bpf_local_storage pointer is returned on success. * * **NULL** if not found or there was an error in adding * a new bpf_local_storage. * * int bpf_inode_storage_delete(struct bpf_map *map, void *inode) * Description * Delete a bpf_local_storage from an *inode*. * Return * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. * * long bpf_d_path(struct path *path, char *buf, u32 sz) * Description * Return full path for given **struct path** object, which * needs to be the kernel BTF *path* object. The path is * returned in the provided buffer *buf* of size *sz* and * is zero terminated. * * Return * On success, the strictly positive length of the string, * including the trailing NUL character. On error, a negative * value. * * long bpf_copy_from_user(void *dst, u32 size, const void *user_ptr) * Description * Read *size* bytes from user space address *user_ptr* and store * the data in *dst*. This is a wrapper of **copy_from_user**\ (). * Return * 0 on success, or a negative error in case of failure. * * long bpf_snprintf_btf(char *str, u32 str_size, struct btf_ptr *ptr, u32 btf_ptr_size, u64 flags) * Description * Use BTF to store a string representation of *ptr*->ptr in *str*, * using *ptr*->type_id. This value should specify the type * that *ptr*->ptr points to. LLVM __builtin_btf_type_id(type, 1) * can be used to look up vmlinux BTF type ids. Traversing the * data structure using BTF, the type information and values are * stored in the first *str_size* - 1 bytes of *str*. Safe copy of * the pointer data is carried out to avoid kernel crashes during * operation. Smaller types can use string space on the stack; * larger programs can use map data to store the string * representation. * * The string can be subsequently shared with userspace via * bpf_perf_event_output() or ring buffer interfaces. * bpf_trace_printk() is to be avoided as it places too small * a limit on string size to be useful. * * *flags* is a combination of * * **BTF_F_COMPACT** * no formatting around type information * **BTF_F_NONAME** * no struct/union member names/types * **BTF_F_PTR_RAW** * show raw (unobfuscated) pointer values; * equivalent to printk specifier %px. * **BTF_F_ZERO** * show zero-valued struct/union members; they * are not displayed by default * * Return * The number of bytes that were written (or would have been * written if output had to be truncated due to string size), * or a negative error in cases of failure. * * long bpf_seq_printf_btf(struct seq_file *m, struct btf_ptr *ptr, u32 ptr_size, u64 flags) * Description * Use BTF to write to seq_write a string representation of * *ptr*->ptr, using *ptr*->type_id as per bpf_snprintf_btf(). * *flags* are identical to those used for bpf_snprintf_btf. * Return * 0 on success or a negative error in case of failure. * * u64 bpf_skb_cgroup_classid(struct sk_buff *skb) * Description * See **bpf_get_cgroup_classid**\ () for the main description. * This helper differs from **bpf_get_cgroup_classid**\ () in that * the cgroup v1 net_cls class is retrieved only from the *skb*'s * associated socket instead of the current process. * Return * The id is returned or 0 in case the id could not be retrieved. * * long bpf_redirect_neigh(u32 ifindex, struct bpf_redir_neigh *params, int plen, u64 flags) * Description * Redirect the packet to another net device of index *ifindex* * and fill in L2 addresses from neighboring subsystem. This helper * is somewhat similar to **bpf_redirect**\ (), except that it * populates L2 addresses as well, meaning, internally, the helper * relies on the neighbor lookup for the L2 address of the nexthop. * * The helper will perform a FIB lookup based on the skb's * networking header to get the address of the next hop, unless * this is supplied by the caller in the *params* argument. The * *plen* argument indicates the len of *params* and should be set * to 0 if *params* is NULL. * * The *flags* argument is reserved and must be 0. The helper is * currently only supported for tc BPF program types, and enabled * for IPv4 and IPv6 protocols. * Return * The helper returns **TC_ACT_REDIRECT** on success or * **TC_ACT_SHOT** on error. * * void *bpf_per_cpu_ptr(const void *percpu_ptr, u32 cpu) * Description * Take a pointer to a percpu ksym, *percpu_ptr*, and return a * pointer to the percpu kernel variable on *cpu*. A ksym is an * extern variable decorated with '__ksym'. For ksym, there is a * global var (either static or global) defined of the same name * in the kernel. The ksym is percpu if the global var is percpu. * The returned pointer points to the global percpu var on *cpu*. * * bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the * kernel, except that bpf_per_cpu_ptr() may return NULL. This * happens if *cpu* is larger than nr_cpu_ids. The caller of * bpf_per_cpu_ptr() must check the returned value. * Return * A pointer pointing to the kernel percpu variable on *cpu*, or * NULL, if *cpu* is invalid. * * void *bpf_this_cpu_ptr(const void *percpu_ptr) * Description * Take a pointer to a percpu ksym, *percpu_ptr*, and return a * pointer to the percpu kernel variable on this cpu. See the * description of 'ksym' in **bpf_per_cpu_ptr**\ (). * * bpf_this_cpu_ptr() has the same semantic as this_cpu_ptr() in * the kernel. Different from **bpf_per_cpu_ptr**\ (), it would * never return NULL. * Return * A pointer pointing to the kernel percpu variable on this cpu. * * long bpf_redirect_peer(u32 ifindex, u64 flags) * Description * Redirect the packet to another net device of index *ifindex*. * This helper is somewhat similar to **bpf_redirect**\ (), except * that the redirection happens to the *ifindex*' peer device and * the netns switch takes place from ingress to ingress without * going through the CPU's backlog queue. * * *skb*\ **->mark** and *skb*\ **->tstamp** are not cleared during * the netns switch. * * The *flags* argument is reserved and must be 0. The helper is * currently only supported for tc BPF program types at the * ingress hook and for veth and netkit target device types. The * peer device must reside in a different network namespace. * Return * The helper returns **TC_ACT_REDIRECT** on success or * **TC_ACT_SHOT** on error. * * void *bpf_task_storage_get(struct bpf_map *map, struct task_struct *task, void *value, u64 flags) * Description * Get a bpf_local_storage from the *task*. * * Logically, it could be thought of as getting the value from * a *map* with *task* as the **key**. From this * perspective, the usage is not much different from * **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this * helper enforces the key must be a task_struct and the map must also * be a **BPF_MAP_TYPE_TASK_STORAGE**. * * Underneath, the value is stored locally at *task* instead of * the *map*. The *map* is used as the bpf-local-storage * "type". The bpf-local-storage "type" (i.e. the *map*) is * searched against all bpf_local_storage residing at *task*. * * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be * used such that a new bpf_local_storage will be * created if one does not exist. *value* can be used * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify * the initial value of a bpf_local_storage. If *value* is * **NULL**, the new bpf_local_storage will be zero initialized. * Return * A bpf_local_storage pointer is returned on success. * * **NULL** if not found or there was an error in adding * a new bpf_local_storage. * * long bpf_task_storage_delete(struct bpf_map *map, struct task_struct *task) * Description * Delete a bpf_local_storage from a *task*. * Return * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. * * struct task_struct *bpf_get_current_task_btf(void) * Description * Return a BTF pointer to the "current" task. * This pointer can also be used in helpers that accept an * *ARG_PTR_TO_BTF_ID* of type *task_struct*. * Return * Pointer to the current task. * * long bpf_bprm_opts_set(struct linux_binprm *bprm, u64 flags) * Description * Set or clear certain options on *bprm*: * * **BPF_F_BPRM_SECUREEXEC** Set the secureexec bit * which sets the **AT_SECURE** auxv for glibc. The bit * is cleared if the flag is not specified. * Return * **-EINVAL** if invalid *flags* are passed, zero otherwise. * * u64 bpf_ktime_get_coarse_ns(void) * Description * Return a coarse-grained version of the time elapsed since * system boot, in nanoseconds. Does not include time the system * was suspended. * * See: **clock_gettime**\ (**CLOCK_MONOTONIC_COARSE**) * Return * Current *ktime*. * * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size) * Description * Returns the stored IMA hash of the *inode* (if it's available). * If the hash is larger than *size*, then only *size* * bytes will be copied to *dst* * Return * The **hash_algo** is returned on success, * **-EOPNOTSUPP** if IMA is disabled or **-EINVAL** if * invalid arguments are passed. * * struct socket *bpf_sock_from_file(struct file *file) * Description * If the given file represents a socket, returns the associated * socket. * Return * A pointer to a struct socket on success or NULL if the file is * not a socket. * * long bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags) * Description * Check packet size against exceeding MTU of net device (based * on *ifindex*). This helper will likely be used in combination * with helpers that adjust/change the packet size. * * The argument *len_diff* can be used for querying with a planned * size change. This allows to check MTU prior to changing packet * ctx. Providing a *len_diff* adjustment that is larger than the * actual packet size (resulting in negative packet size) will in * principle not exceed the MTU, which is why it is not considered * a failure. Other BPF helpers are needed for performing the * planned size change; therefore the responsibility for catching * a negative packet size belongs in those helpers. * * Specifying *ifindex* zero means the MTU check is performed * against the current net device. This is practical if this isn't * used prior to redirect. * * On input *mtu_len* must be a valid pointer, else verifier will * reject BPF program. If the value *mtu_len* is initialized to * zero then the ctx packet size is use. When value *mtu_len* is * provided as input this specify the L3 length that the MTU check * is done against. Remember XDP and TC length operate at L2, but * this value is L3 as this correlate to MTU and IP-header tot_len * values which are L3 (similar behavior as bpf_fib_lookup). * * The Linux kernel route table can configure MTUs on a more * specific per route level, which is not provided by this helper. * For route level MTU checks use the **bpf_fib_lookup**\ () * helper. * * *ctx* is either **struct xdp_md** for XDP programs or * **struct sk_buff** for tc cls_act programs. * * The *flags* argument can be a combination of one or more of the * following values: * * **BPF_MTU_CHK_SEGS** * This flag will only works for *ctx* **struct sk_buff**. * If packet context contains extra packet segment buffers * (often knows as GSO skb), then MTU check is harder to * check at this point, because in transmit path it is * possible for the skb packet to get re-segmented * (depending on net device features). This could still be * a MTU violation, so this flag enables performing MTU * check against segments, with a different violation * return code to tell it apart. Check cannot use len_diff. * * On return *mtu_len* pointer contains the MTU value of the net * device. Remember the net device configured MTU is the L3 size, * which is returned here and XDP and TC length operate at L2. * Helper take this into account for you, but remember when using * MTU value in your BPF-code. * * Return * * 0 on success, and populate MTU value in *mtu_len* pointer. * * * < 0 if any input argument is invalid (*mtu_len* not updated) * * MTU violations return positive values, but also populate MTU * value in *mtu_len* pointer, as this can be needed for * implementing PMTU handing: * * * **BPF_MTU_CHK_RET_FRAG_NEEDED** * * **BPF_MTU_CHK_RET_SEGS_TOOBIG** * * long bpf_for_each_map_elem(struct bpf_map *map, void *callback_fn, void *callback_ctx, u64 flags) * Description * For each element in **map**, call **callback_fn** function with * **map**, **callback_ctx** and other map-specific parameters. * The **callback_fn** should be a static function and * the **callback_ctx** should be a pointer to the stack. * The **flags** is used to control certain aspects of the helper. * Currently, the **flags** must be 0. * * The following are a list of supported map types and their * respective expected callback signatures: * * BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_PERCPU_HASH, * BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, * BPF_MAP_TYPE_ARRAY, BPF_MAP_TYPE_PERCPU_ARRAY * * long (\*callback_fn)(struct bpf_map \*map, const void \*key, void \*value, void \*ctx); * * For per_cpu maps, the map_value is the value on the cpu where the * bpf_prog is running. * * If **callback_fn** return 0, the helper will continue to the next * element. If return value is 1, the helper will skip the rest of * elements and return. Other return values are not used now. * * Return * The number of traversed map elements for success, **-EINVAL** for * invalid **flags**. * * long bpf_snprintf(char *str, u32 str_size, const char *fmt, u64 *data, u32 data_len) * Description * Outputs a string into the **str** buffer of size **str_size** * based on a format string stored in a read-only map pointed by * **fmt**. * * Each format specifier in **fmt** corresponds to one u64 element * in the **data** array. For strings and pointers where pointees * are accessed, only the pointer values are stored in the *data* * array. The *data_len* is the size of *data* in bytes - must be * a multiple of 8. * * Formats **%s** and **%p{i,I}{4,6}** require to read kernel * memory. Reading kernel memory may fail due to either invalid * address or valid address but requiring a major memory fault. If * reading kernel memory fails, the string for **%s** will be an * empty string, and the ip address for **%p{i,I}{4,6}** will be 0. * Not returning error to bpf program is consistent with what * **bpf_trace_printk**\ () does for now. * * Return * The strictly positive length of the formatted string, including * the trailing zero character. If the return value is greater than * **str_size**, **str** contains a truncated string, guaranteed to * be zero-terminated except when **str_size** is 0. * * Or **-EBUSY** if the per-CPU memory copy buffer is busy. * * long bpf_sys_bpf(u32 cmd, void *attr, u32 attr_size) * Description * Execute bpf syscall with given arguments. * Return * A syscall result. * * long bpf_btf_find_by_name_kind(char *name, int name_sz, u32 kind, int flags) * Description * Find BTF type with given name and kind in vmlinux BTF or in module's BTFs. * Return * Returns btf_id and btf_obj_fd in lower and upper 32 bits. * * long bpf_sys_close(u32 fd) * Description * Execute close syscall for given FD. * Return * A syscall result. * * long bpf_timer_init(struct bpf_timer *timer, struct bpf_map *map, u64 flags) * Description * Initialize the timer. * First 4 bits of *flags* specify clockid. * Only CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_BOOTTIME are allowed. * All other bits of *flags* are reserved. * The verifier will reject the program if *timer* is not from * the same *map*. * Return * 0 on success. * **-EBUSY** if *timer* is already initialized. * **-EINVAL** if invalid *flags* are passed. * **-EPERM** if *timer* is in a map that doesn't have any user references. * The user space should either hold a file descriptor to a map with timers * or pin such map in bpffs. When map is unpinned or file descriptor is * closed all timers in the map will be cancelled and freed. * * long bpf_timer_set_callback(struct bpf_timer *timer, void *callback_fn) * Description * Configure the timer to call *callback_fn* static function. * Return * 0 on success. * **-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier. * **-EPERM** if *timer* is in a map that doesn't have any user references. * The user space should either hold a file descriptor to a map with timers * or pin such map in bpffs. When map is unpinned or file descriptor is * closed all timers in the map will be cancelled and freed. * * long bpf_timer_start(struct bpf_timer *timer, u64 nsecs, u64 flags) * Description * Set timer expiration N nanoseconds from the current time. The * configured callback will be invoked in soft irq context on some cpu * and will not repeat unless another bpf_timer_start() is made. * In such case the next invocation can migrate to a different cpu. * Since struct bpf_timer is a field inside map element the map * owns the timer. The bpf_timer_set_callback() will increment refcnt * of BPF program to make sure that callback_fn code stays valid. * When user space reference to a map reaches zero all timers * in a map are cancelled and corresponding program's refcnts are * decremented. This is done to make sure that Ctrl-C of a user * process doesn't leave any timers running. If map is pinned in * bpffs the callback_fn can re-arm itself indefinitely. * bpf_map_update/delete_elem() helpers and user space sys_bpf commands * cancel and free the timer in the given map element. * The map can contain timers that invoke callback_fn-s from different * programs. The same callback_fn can serve different timers from * different maps if key/value layout matches across maps. * Every bpf_timer_set_callback() can have different callback_fn. * * *flags* can be one of: * * **BPF_F_TIMER_ABS** * Start the timer in absolute expire value instead of the * default relative one. * **BPF_F_TIMER_CPU_PIN** * Timer will be pinned to the CPU of the caller. * * Return * 0 on success. * **-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier * or invalid *flags* are passed. * * long bpf_timer_cancel(struct bpf_timer *timer) * Description * Cancel the timer and wait for callback_fn to finish if it was running. * Return * 0 if the timer was not active. * 1 if the timer was active. * **-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier. * **-EDEADLK** if callback_fn tried to call bpf_timer_cancel() on its * own timer which would have led to a deadlock otherwise. * * u64 bpf_get_func_ip(void *ctx) * Description * Get address of the traced function (for tracing and kprobe programs). * * When called for kprobe program attached as uprobe it returns * probe address for both entry and return uprobe. * * Return * Address of the traced function for kprobe. * 0 for kprobes placed within the function (not at the entry). * Address of the probe for uprobe and return uprobe. * * u64 bpf_get_attach_cookie(void *ctx) * Description * Get bpf_cookie value provided (optionally) during the program * attachment. It might be different for each individual * attachment, even if BPF program itself is the same. * Expects BPF program context *ctx* as a first argument. * * Supported for the following program types: * - kprobe/uprobe; * - tracepoint; * - perf_event. * Return * Value specified by user at BPF link creation/attachment time * or 0, if it was not specified. * * long bpf_task_pt_regs(struct task_struct *task) * Description * Get the struct pt_regs associated with **task**. * Return * A pointer to struct pt_regs. * * long bpf_get_branch_snapshot(void *entries, u32 size, u64 flags) * Description * Get branch trace from hardware engines like Intel LBR. The * hardware engine is stopped shortly after the helper is * called. Therefore, the user need to filter branch entries * based on the actual use case. To capture branch trace * before the trigger point of the BPF program, the helper * should be called at the beginning of the BPF program. * * The data is stored as struct perf_branch_entry into output * buffer *entries*. *size* is the size of *entries* in bytes. * *flags* is reserved for now and must be zero. * * Return * On success, number of bytes written to *buf*. On error, a * negative value. * * **-EINVAL** if *flags* is not zero. * * **-ENOENT** if architecture does not support branch records. * * long bpf_trace_vprintk(const char *fmt, u32 fmt_size, const void *data, u32 data_len) * Description * Behaves like **bpf_trace_printk**\ () helper, but takes an array of u64 * to format and can handle more format args as a result. * * Arguments are to be used as in **bpf_seq_printf**\ () helper. * Return * The number of bytes written to the buffer, or a negative error * in case of failure. * * struct unix_sock *bpf_skc_to_unix_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *unix_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * long bpf_kallsyms_lookup_name(const char *name, int name_sz, int flags, u64 *res) * Description * Get the address of a kernel symbol, returned in *res*. *res* is * set to 0 if the symbol is not found. * Return * On success, zero. On error, a negative value. * * **-EINVAL** if *flags* is not zero. * * **-EINVAL** if string *name* is not the same size as *name_sz*. * * **-ENOENT** if symbol is not found. * * **-EPERM** if caller does not have permission to obtain kernel address. * * long bpf_find_vma(struct task_struct *task, u64 addr, void *callback_fn, void *callback_ctx, u64 flags) * Description * Find vma of *task* that contains *addr*, call *callback_fn* * function with *task*, *vma*, and *callback_ctx*. * The *callback_fn* should be a static function and * the *callback_ctx* should be a pointer to the stack. * The *flags* is used to control certain aspects of the helper. * Currently, the *flags* must be 0. * * The expected callback signature is * * long (\*callback_fn)(struct task_struct \*task, struct vm_area_struct \*vma, void \*callback_ctx); * * Return * 0 on success. * **-ENOENT** if *task->mm* is NULL, or no vma contains *addr*. * **-EBUSY** if failed to try lock mmap_lock. * **-EINVAL** for invalid **flags**. * * long bpf_loop(u32 nr_loops, void *callback_fn, void *callback_ctx, u64 flags) * Description * For **nr_loops**, call **callback_fn** function * with **callback_ctx** as the context parameter. * The **callback_fn** should be a static function and * the **callback_ctx** should be a pointer to the stack. * The **flags** is used to control certain aspects of the helper. * Currently, the **flags** must be 0. Currently, nr_loops is * limited to 1 << 23 (~8 million) loops. * * long (\*callback_fn)(u64 index, void \*ctx); * * where **index** is the current index in the loop. The index * is zero-indexed. * * If **callback_fn** returns 0, the helper will continue to the next * loop. If return value is 1, the helper will skip the rest of * the loops and return. Other return values are not used now, * and will be rejected by the verifier. * * Return * The number of loops performed, **-EINVAL** for invalid **flags**, * **-E2BIG** if **nr_loops** exceeds the maximum number of loops. * * long bpf_strncmp(const char *s1, u32 s1_sz, const char *s2) * Description * Do strncmp() between **s1** and **s2**. **s1** doesn't need * to be null-terminated and **s1_sz** is the maximum storage * size of **s1**. **s2** must be a read-only string. * Return * An integer less than, equal to, or greater than zero * if the first **s1_sz** bytes of **s1** is found to be * less than, to match, or be greater than **s2**. * * long bpf_get_func_arg(void *ctx, u32 n, u64 *value) * Description * Get **n**-th argument register (zero based) of the traced function (for tracing programs) * returned in **value**. * * Return * 0 on success. * **-EINVAL** if n >= argument register count of traced function. * * long bpf_get_func_ret(void *ctx, u64 *value) * Description * Get return value of the traced function (for tracing programs) * in **value**. * * Return * 0 on success. * **-EOPNOTSUPP** for tracing programs other than BPF_TRACE_FEXIT or BPF_MODIFY_RETURN. * * long bpf_get_func_arg_cnt(void *ctx) * Description * Get number of registers of the traced function (for tracing programs) where * function arguments are stored in these registers. * * Return * The number of argument registers of the traced function. * * int bpf_get_retval(void) * Description * Get the BPF program's return value that will be returned to the upper layers. * * This helper is currently supported by cgroup programs and only by the hooks * where BPF program's return value is returned to the userspace via errno. * Return * The BPF program's return value. * * int bpf_set_retval(int retval) * Description * Set the BPF program's return value that will be returned to the upper layers. * * This helper is currently supported by cgroup programs and only by the hooks * where BPF program's return value is returned to the userspace via errno. * * Note that there is the following corner case where the program exports an error * via bpf_set_retval but signals success via 'return 1': * * bpf_set_retval(-EPERM); * return 1; * * In this case, the BPF program's return value will use helper's -EPERM. This * still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case. * * Return * 0 on success, or a negative error in case of failure. * * u64 bpf_xdp_get_buff_len(struct xdp_buff *xdp_md) * Description * Get the total size of a given xdp buff (linear and paged area) * Return * The total size of a given xdp buffer. * * long bpf_xdp_load_bytes(struct xdp_buff *xdp_md, u32 offset, void *buf, u32 len) * Description * This helper is provided as an easy way to load data from a * xdp buffer. It can be used to load *len* bytes from *offset* from * the frame associated to *xdp_md*, into the buffer pointed by * *buf*. * Return * 0 on success, or a negative error in case of failure. * * long bpf_xdp_store_bytes(struct xdp_buff *xdp_md, u32 offset, void *buf, u32 len) * Description * Store *len* bytes from buffer *buf* into the frame * associated to *xdp_md*, at *offset*. * Return * 0 on success, or a negative error in case of failure. * * long bpf_copy_from_user_task(void *dst, u32 size, const void *user_ptr, struct task_struct *tsk, u64 flags) * Description * Read *size* bytes from user space address *user_ptr* in *tsk*'s * address space, and stores the data in *dst*. *flags* is not * used yet and is provided for future extensibility. This helper * can only be used by sleepable programs. * Return * 0 on success, or a negative error in case of failure. On error * *dst* buffer is zeroed out. * * long bpf_skb_set_tstamp(struct sk_buff *skb, u64 tstamp, u32 tstamp_type) * Description * Change the __sk_buff->tstamp_type to *tstamp_type* * and set *tstamp* to the __sk_buff->tstamp together. * * If there is no need to change the __sk_buff->tstamp_type, * the tstamp value can be directly written to __sk_buff->tstamp * instead. * * BPF_SKB_TSTAMP_DELIVERY_MONO is the only tstamp that * will be kept during bpf_redirect_*(). A non zero * *tstamp* must be used with the BPF_SKB_TSTAMP_DELIVERY_MONO * *tstamp_type*. * * A BPF_SKB_TSTAMP_UNSPEC *tstamp_type* can only be used * with a zero *tstamp*. * * Only IPv4 and IPv6 skb->protocol are supported. * * This function is most useful when it needs to set a * mono delivery time to __sk_buff->tstamp and then * bpf_redirect_*() to the egress of an iface. For example, * changing the (rcv) timestamp in __sk_buff->tstamp at * ingress to a mono delivery time and then bpf_redirect_*() * to sch_fq@phy-dev. * Return * 0 on success. * **-EINVAL** for invalid input * **-EOPNOTSUPP** for unsupported protocol * * long bpf_ima_file_hash(struct file *file, void *dst, u32 size) * Description * Returns a calculated IMA hash of the *file*. * If the hash is larger than *size*, then only *size* * bytes will be copied to *dst* * Return * The **hash_algo** is returned on success, * **-EOPNOTSUPP** if the hash calculation failed or **-EINVAL** if * invalid arguments are passed. * * void *bpf_kptr_xchg(void *dst, void *ptr) * Description * Exchange kptr at pointer *dst* with *ptr*, and return the old value. * *dst* can be map value or local kptr. *ptr* can be NULL, otherwise * it must be a referenced pointer which will be released when this helper * is called. * Return * The old value of kptr (which can be NULL). The returned pointer * if not NULL, is a reference which must be released using its * corresponding release function, or moved into a BPF map before * program exit. * * void *bpf_map_lookup_percpu_elem(struct bpf_map *map, const void *key, u32 cpu) * Description * Perform a lookup in *percpu map* for an entry associated to * *key* on *cpu*. * Return * Map value associated to *key* on *cpu*, or **NULL** if no entry * was found or *cpu* is invalid. * * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk) * Description * Dynamically cast a *sk* pointer to a *mptcp_sock* pointer. * Return * *sk* if casting is valid, or **NULL** otherwise. * * long bpf_dynptr_from_mem(void *data, u32 size, u64 flags, struct bpf_dynptr *ptr) * Description * Get a dynptr to local memory *data*. * * *data* must be a ptr to a map value. * The maximum *size* supported is DYNPTR_MAX_SIZE. * *flags* is currently unused. * Return * 0 on success, -E2BIG if the size exceeds DYNPTR_MAX_SIZE, * -EINVAL if flags is not 0. * * long bpf_ringbuf_reserve_dynptr(void *ringbuf, u32 size, u64 flags, struct bpf_dynptr *ptr) * Description * Reserve *size* bytes of payload in a ring buffer *ringbuf* * through the dynptr interface. *flags* must be 0. * * Please note that a corresponding bpf_ringbuf_submit_dynptr or * bpf_ringbuf_discard_dynptr must be called on *ptr*, even if the * reservation fails. This is enforced by the verifier. * Return * 0 on success, or a negative error in case of failure. * * void bpf_ringbuf_submit_dynptr(struct bpf_dynptr *ptr, u64 flags) * Description * Submit reserved ring buffer sample, pointed to by *data*, * through the dynptr interface. This is a no-op if the dynptr is * invalid/null. * * For more information on *flags*, please see * 'bpf_ringbuf_submit'. * Return * Nothing. Always succeeds. * * void bpf_ringbuf_discard_dynptr(struct bpf_dynptr *ptr, u64 flags) * Description * Discard reserved ring buffer sample through the dynptr * interface. This is a no-op if the dynptr is invalid/null. * * For more information on *flags*, please see * 'bpf_ringbuf_discard'. * Return * Nothing. Always succeeds. * * long bpf_dynptr_read(void *dst, u32 len, const struct bpf_dynptr *src, u32 offset, u64 flags) * Description * Read *len* bytes from *src* into *dst*, starting from *offset* * into *src*. * *flags* is currently unused. * Return * 0 on success, -E2BIG if *offset* + *len* exceeds the length * of *src*'s data, -EINVAL if *src* is an invalid dynptr or if * *flags* is not 0. * * long bpf_dynptr_write(const struct bpf_dynptr *dst, u32 offset, void *src, u32 len, u64 flags) * Description * Write *len* bytes from *src* into *dst*, starting from *offset* * into *dst*. * * *flags* must be 0 except for skb-type dynptrs. * * For skb-type dynptrs: * * All data slices of the dynptr are automatically * invalidated after **bpf_dynptr_write**\ (). This is * because writing may pull the skb and change the * underlying packet buffer. * * * For *flags*, please see the flags accepted by * **bpf_skb_store_bytes**\ (). * Return * 0 on success, -E2BIG if *offset* + *len* exceeds the length * of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst* * is a read-only dynptr or if *flags* is not correct. For skb-type dynptrs, * other errors correspond to errors returned by **bpf_skb_store_bytes**\ (). * * void *bpf_dynptr_data(const struct bpf_dynptr *ptr, u32 offset, u32 len) * Description * Get a pointer to the underlying dynptr data. * * *len* must be a statically known value. The returned data slice * is invalidated whenever the dynptr is invalidated. * * skb and xdp type dynptrs may not use bpf_dynptr_data. They should * instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr. * Return * Pointer to the underlying dynptr data, NULL if the dynptr is * read-only, if the dynptr is invalid, or if the offset and length * is out of bounds. * * s64 bpf_tcp_raw_gen_syncookie_ipv4(struct iphdr *iph, struct tcphdr *th, u32 th_len) * Description * Try to issue a SYN cookie for the packet with corresponding * IPv4/TCP headers, *iph* and *th*, without depending on a * listening socket. * * *iph* points to the IPv4 header. * * *th* points to the start of the TCP header, while *th_len* * contains the length of the TCP header (at least * **sizeof**\ (**struct tcphdr**)). * Return * On success, lower 32 bits hold the generated SYN cookie in * followed by 16 bits which hold the MSS value for that cookie, * and the top 16 bits are unused. * * On failure, the returned value is one of the following: * * **-EINVAL** if *th_len* is invalid. * * s64 bpf_tcp_raw_gen_syncookie_ipv6(struct ipv6hdr *iph, struct tcphdr *th, u32 th_len) * Description * Try to issue a SYN cookie for the packet with corresponding * IPv6/TCP headers, *iph* and *th*, without depending on a * listening socket. * * *iph* points to the IPv6 header. * * *th* points to the start of the TCP header, while *th_len* * contains the length of the TCP header (at least * **sizeof**\ (**struct tcphdr**)). * Return * On success, lower 32 bits hold the generated SYN cookie in * followed by 16 bits which hold the MSS value for that cookie, * and the top 16 bits are unused. * * On failure, the returned value is one of the following: * * **-EINVAL** if *th_len* is invalid. * * **-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin. * * long bpf_tcp_raw_check_syncookie_ipv4(struct iphdr *iph, struct tcphdr *th) * Description * Check whether *iph* and *th* contain a valid SYN cookie ACK * without depending on a listening socket. * * *iph* points to the IPv4 header. * * *th* points to the TCP header. * Return * 0 if *iph* and *th* are a valid SYN cookie ACK. * * On failure, the returned value is one of the following: * * **-EACCES** if the SYN cookie is not valid. * * long bpf_tcp_raw_check_syncookie_ipv6(struct ipv6hdr *iph, struct tcphdr *th) * Description * Check whether *iph* and *th* contain a valid SYN cookie ACK * without depending on a listening socket. * * *iph* points to the IPv6 header. * * *th* points to the TCP header. * Return * 0 if *iph* and *th* are a valid SYN cookie ACK. * * On failure, the returned value is one of the following: * * **-EACCES** if the SYN cookie is not valid. * * **-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin. * * u64 bpf_ktime_get_tai_ns(void) * Description * A nonsettable system-wide clock derived from wall-clock time but * ignoring leap seconds. This clock does not experience * discontinuities and backwards jumps caused by NTP inserting leap * seconds as CLOCK_REALTIME does. * * See: **clock_gettime**\ (**CLOCK_TAI**) * Return * Current *ktime*. * * long bpf_user_ringbuf_drain(struct bpf_map *map, void *callback_fn, void *ctx, u64 flags) * Description * Drain samples from the specified user ring buffer, and invoke * the provided callback for each such sample: * * long (\*callback_fn)(const struct bpf_dynptr \*dynptr, void \*ctx); * * If **callback_fn** returns 0, the helper will continue to try * and drain the next sample, up to a maximum of * BPF_MAX_USER_RINGBUF_SAMPLES samples. If the return value is 1, * the helper will skip the rest of the samples and return. Other * return values are not used now, and will be rejected by the * verifier. * Return * The number of drained samples if no error was encountered while * draining samples, or 0 if no samples were present in the ring * buffer. If a user-space producer was epoll-waiting on this map, * and at least one sample was drained, they will receive an event * notification notifying them of available space in the ring * buffer. If the BPF_RB_NO_WAKEUP flag is passed to this * function, no wakeup notification will be sent. If the * BPF_RB_FORCE_WAKEUP flag is passed, a wakeup notification will * be sent even if no sample was drained. * * On failure, the returned value is one of the following: * * **-EBUSY** if the ring buffer is contended, and another calling * context was concurrently draining the ring buffer. * * **-EINVAL** if user-space is not properly tracking the ring * buffer due to the producer position not being aligned to 8 * bytes, a sample not being aligned to 8 bytes, or the producer * position not matching the advertised length of a sample. * * **-E2BIG** if user-space has tried to publish a sample which is * larger than the size of the ring buffer, or which cannot fit * within a struct bpf_dynptr. * * void *bpf_cgrp_storage_get(struct bpf_map *map, struct cgroup *cgroup, void *value, u64 flags) * Description * Get a bpf_local_storage from the *cgroup*. * * Logically, it could be thought of as getting the value from * a *map* with *cgroup* as the **key**. From this * perspective, the usage is not much different from * **bpf_map_lookup_elem**\ (*map*, **&**\ *cgroup*) except this * helper enforces the key must be a cgroup struct and the map must also * be a **BPF_MAP_TYPE_CGRP_STORAGE**. * * In reality, the local-storage value is embedded directly inside of the * *cgroup* object itself, rather than being located in the * **BPF_MAP_TYPE_CGRP_STORAGE** map. When the local-storage value is * queried for some *map* on a *cgroup* object, the kernel will perform an * O(n) iteration over all of the live local-storage values for that * *cgroup* object until the local-storage value for the *map* is found. * * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be * used such that a new bpf_local_storage will be * created if one does not exist. *value* can be used * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify * the initial value of a bpf_local_storage. If *value* is * **NULL**, the new bpf_local_storage will be zero initialized. * Return * A bpf_local_storage pointer is returned on success. * * **NULL** if not found or there was an error in adding * a new bpf_local_storage. * * long bpf_cgrp_storage_delete(struct bpf_map *map, struct cgroup *cgroup) * Description * Delete a bpf_local_storage from a *cgroup*. * Return * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \ FN(map_lookup_elem, 1, ##ctx) \ FN(map_update_elem, 2, ##ctx) \ FN(map_delete_elem, 3, ##ctx) \ FN(probe_read, 4, ##ctx) \ FN(ktime_get_ns, 5, ##ctx) \ FN(trace_printk, 6, ##ctx) \ FN(get_prandom_u32, 7, ##ctx) \ FN(get_smp_processor_id, 8, ##ctx) \ FN(skb_store_bytes, 9, ##ctx) \ FN(l3_csum_replace, 10, ##ctx) \ FN(l4_csum_replace, 11, ##ctx) \ FN(tail_call, 12, ##ctx) \ FN(clone_redirect, 13, ##ctx) \ FN(get_current_pid_tgid, 14, ##ctx) \ FN(get_current_uid_gid, 15, ##ctx) \ FN(get_current_comm, 16, ##ctx) \ FN(get_cgroup_classid, 17, ##ctx) \ FN(skb_vlan_push, 18, ##ctx) \ FN(skb_vlan_pop, 19, ##ctx) \ FN(skb_get_tunnel_key, 20, ##ctx) \ FN(skb_set_tunnel_key, 21, ##ctx) \ FN(perf_event_read, 22, ##ctx) \ FN(redirect, 23, ##ctx) \ FN(get_route_realm, 24, ##ctx) \ FN(perf_event_output, 25, ##ctx) \ FN(skb_load_bytes, 26, ##ctx) \ FN(get_stackid, 27, ##ctx) \ FN(csum_diff, 28, ##ctx) \ FN(skb_get_tunnel_opt, 29, ##ctx) \ FN(skb_set_tunnel_opt, 30, ##ctx) \ FN(skb_change_proto, 31, ##ctx) \ FN(skb_change_type, 32, ##ctx) \ FN(skb_under_cgroup, 33, ##ctx) \ FN(get_hash_recalc, 34, ##ctx) \ FN(get_current_task, 35, ##ctx) \ FN(probe_write_user, 36, ##ctx) \ FN(current_task_under_cgroup, 37, ##ctx) \ FN(skb_change_tail, 38, ##ctx) \ FN(skb_pull_data, 39, ##ctx) \ FN(csum_update, 40, ##ctx) \ FN(set_hash_invalid, 41, ##ctx) \ FN(get_numa_node_id, 42, ##ctx) \ FN(skb_change_head, 43, ##ctx) \ FN(xdp_adjust_head, 44, ##ctx) \ FN(probe_read_str, 45, ##ctx) \ FN(get_socket_cookie, 46, ##ctx) \ FN(get_socket_uid, 47, ##ctx) \ FN(set_hash, 48, ##ctx) \ FN(setsockopt, 49, ##ctx) \ FN(skb_adjust_room, 50, ##ctx) \ FN(redirect_map, 51, ##ctx) \ FN(sk_redirect_map, 52, ##ctx) \ FN(sock_map_update, 53, ##ctx) \ FN(xdp_adjust_meta, 54, ##ctx) \ FN(perf_event_read_value, 55, ##ctx) \ FN(perf_prog_read_value, 56, ##ctx) \ FN(getsockopt, 57, ##ctx) \ FN(override_return, 58, ##ctx) \ FN(sock_ops_cb_flags_set, 59, ##ctx) \ FN(msg_redirect_map, 60, ##ctx) \ FN(msg_apply_bytes, 61, ##ctx) \ FN(msg_cork_bytes, 62, ##ctx) \ FN(msg_pull_data, 63, ##ctx) \ FN(bind, 64, ##ctx) \ FN(xdp_adjust_tail, 65, ##ctx) \ FN(skb_get_xfrm_state, 66, ##ctx) \ FN(get_stack, 67, ##ctx) \ FN(skb_load_bytes_relative, 68, ##ctx) \ FN(fib_lookup, 69, ##ctx) \ FN(sock_hash_update, 70, ##ctx) \ FN(msg_redirect_hash, 71, ##ctx) \ FN(sk_redirect_hash, 72, ##ctx) \ FN(lwt_push_encap, 73, ##ctx) \ FN(lwt_seg6_store_bytes, 74, ##ctx) \ FN(lwt_seg6_adjust_srh, 75, ##ctx) \ FN(lwt_seg6_action, 76, ##ctx) \ FN(rc_repeat, 77, ##ctx) \ FN(rc_keydown, 78, ##ctx) \ FN(skb_cgroup_id, 79, ##ctx) \ FN(get_current_cgroup_id, 80, ##ctx) \ FN(get_local_storage, 81, ##ctx) \ FN(sk_select_reuseport, 82, ##ctx) \ FN(skb_ancestor_cgroup_id, 83, ##ctx) \ FN(sk_lookup_tcp, 84, ##ctx) \ FN(sk_lookup_udp, 85, ##ctx) \ FN(sk_release, 86, ##ctx) \ FN(map_push_elem, 87, ##ctx) \ FN(map_pop_elem, 88, ##ctx) \ FN(map_peek_elem, 89, ##ctx) \ FN(msg_push_data, 90, ##ctx) \ FN(msg_pop_data, 91, ##ctx) \ FN(rc_pointer_rel, 92, ##ctx) \ FN(spin_lock, 93, ##ctx) \ FN(spin_unlock, 94, ##ctx) \ FN(sk_fullsock, 95, ##ctx) \ FN(tcp_sock, 96, ##ctx) \ FN(skb_ecn_set_ce, 97, ##ctx) \ FN(get_listener_sock, 98, ##ctx) \ FN(skc_lookup_tcp, 99, ##ctx) \ FN(tcp_check_syncookie, 100, ##ctx) \ FN(sysctl_get_name, 101, ##ctx) \ FN(sysctl_get_current_value, 102, ##ctx) \ FN(sysctl_get_new_value, 103, ##ctx) \ FN(sysctl_set_new_value, 104, ##ctx) \ FN(strtol, 105, ##ctx) \ FN(strtoul, 106, ##ctx) \ FN(sk_storage_get, 107, ##ctx) \ FN(sk_storage_delete, 108, ##ctx) \ FN(send_signal, 109, ##ctx) \ FN(tcp_gen_syncookie, 110, ##ctx) \ FN(skb_output, 111, ##ctx) \ FN(probe_read_user, 112, ##ctx) \ FN(probe_read_kernel, 113, ##ctx) \ FN(probe_read_user_str, 114, ##ctx) \ FN(probe_read_kernel_str, 115, ##ctx) \ FN(tcp_send_ack, 116, ##ctx) \ FN(send_signal_thread, 117, ##ctx) \ FN(jiffies64, 118, ##ctx) \ FN(read_branch_records, 119, ##ctx) \ FN(get_ns_current_pid_tgid, 120, ##ctx) \ FN(xdp_output, 121, ##ctx) \ FN(get_netns_cookie, 122, ##ctx) \ FN(get_current_ancestor_cgroup_id, 123, ##ctx) \ FN(sk_assign, 124, ##ctx) \ FN(ktime_get_boot_ns, 125, ##ctx) \ FN(seq_printf, 126, ##ctx) \ FN(seq_write, 127, ##ctx) \ FN(sk_cgroup_id, 128, ##ctx) \ FN(sk_ancestor_cgroup_id, 129, ##ctx) \ FN(ringbuf_output, 130, ##ctx) \ FN(ringbuf_reserve, 131, ##ctx) \ FN(ringbuf_submit, 132, ##ctx) \ FN(ringbuf_discard, 133, ##ctx) \ FN(ringbuf_query, 134, ##ctx) \ FN(csum_level, 135, ##ctx) \ FN(skc_to_tcp6_sock, 136, ##ctx) \ FN(skc_to_tcp_sock, 137, ##ctx) \ FN(skc_to_tcp_timewait_sock, 138, ##ctx) \ FN(skc_to_tcp_request_sock, 139, ##ctx) \ FN(skc_to_udp6_sock, 140, ##ctx) \ FN(get_task_stack, 141, ##ctx) \ FN(load_hdr_opt, 142, ##ctx) \ FN(store_hdr_opt, 143, ##ctx) \ FN(reserve_hdr_opt, 144, ##ctx) \ FN(inode_storage_get, 145, ##ctx) \ FN(inode_storage_delete, 146, ##ctx) \ FN(d_path, 147, ##ctx) \ FN(copy_from_user, 148, ##ctx) \ FN(snprintf_btf, 149, ##ctx) \ FN(seq_printf_btf, 150, ##ctx) \ FN(skb_cgroup_classid, 151, ##ctx) \ FN(redirect_neigh, 152, ##ctx) \ FN(per_cpu_ptr, 153, ##ctx) \ FN(this_cpu_ptr, 154, ##ctx) \ FN(redirect_peer, 155, ##ctx) \ FN(task_storage_get, 156, ##ctx) \ FN(task_storage_delete, 157, ##ctx) \ FN(get_current_task_btf, 158, ##ctx) \ FN(bprm_opts_set, 159, ##ctx) \ FN(ktime_get_coarse_ns, 160, ##ctx) \ FN(ima_inode_hash, 161, ##ctx) \ FN(sock_from_file, 162, ##ctx) \ FN(check_mtu, 163, ##ctx) \ FN(for_each_map_elem, 164, ##ctx) \ FN(snprintf, 165, ##ctx) \ FN(sys_bpf, 166, ##ctx) \ FN(btf_find_by_name_kind, 167, ##ctx) \ FN(sys_close, 168, ##ctx) \ FN(timer_init, 169, ##ctx) \ FN(timer_set_callback, 170, ##ctx) \ FN(timer_start, 171, ##ctx) \ FN(timer_cancel, 172, ##ctx) \ FN(get_func_ip, 173, ##ctx) \ FN(get_attach_cookie, 174, ##ctx) \ FN(task_pt_regs, 175, ##ctx) \ FN(get_branch_snapshot, 176, ##ctx) \ FN(trace_vprintk, 177, ##ctx) \ FN(skc_to_unix_sock, 178, ##ctx) \ FN(kallsyms_lookup_name, 179, ##ctx) \ FN(find_vma, 180, ##ctx) \ FN(loop, 181, ##ctx) \ FN(strncmp, 182, ##ctx) \ FN(get_func_arg, 183, ##ctx) \ FN(get_func_ret, 184, ##ctx) \ FN(get_func_arg_cnt, 185, ##ctx) \ FN(get_retval, 186, ##ctx) \ FN(set_retval, 187, ##ctx) \ FN(xdp_get_buff_len, 188, ##ctx) \ FN(xdp_load_bytes, 189, ##ctx) \ FN(xdp_store_bytes, 190, ##ctx) \ FN(copy_from_user_task, 191, ##ctx) \ FN(skb_set_tstamp, 192, ##ctx) \ FN(ima_file_hash, 193, ##ctx) \ FN(kptr_xchg, 194, ##ctx) \ FN(map_lookup_percpu_elem, 195, ##ctx) \ FN(skc_to_mptcp_sock, 196, ##ctx) \ FN(dynptr_from_mem, 197, ##ctx) \ FN(ringbuf_reserve_dynptr, 198, ##ctx) \ FN(ringbuf_submit_dynptr, 199, ##ctx) \ FN(ringbuf_discard_dynptr, 200, ##ctx) \ FN(dynptr_read, 201, ##ctx) \ FN(dynptr_write, 202, ##ctx) \ FN(dynptr_data, 203, ##ctx) \ FN(tcp_raw_gen_syncookie_ipv4, 204, ##ctx) \ FN(tcp_raw_gen_syncookie_ipv6, 205, ##ctx) \ FN(tcp_raw_check_syncookie_ipv4, 206, ##ctx) \ FN(tcp_raw_check_syncookie_ipv6, 207, ##ctx) \ FN(ktime_get_tai_ns, 208, ##ctx) \ FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ /* This helper list is effectively frozen. If you are trying to \ * add a new helper, you should add a kfunc instead which has \ * less stability guarantees. See Documentation/bpf/kfuncs.rst \ */ /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't * know or care about integer value that is now passed as second argument */ #define __BPF_FUNC_MAPPER_APPLY(name, value, FN) FN(name), #define __BPF_FUNC_MAPPER(FN) ___BPF_FUNC_MAPPER(__BPF_FUNC_MAPPER_APPLY, FN) /* integer value in 'imm' field of BPF_CALL instruction selects which helper * function eBPF program intends to call */ #define __BPF_ENUM_FN(x, y) BPF_FUNC_ ## x = y, enum bpf_func_id { ___BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID, }; #undef __BPF_ENUM_FN /* All flags used by eBPF helper functions, placed here. */ /* BPF_FUNC_skb_store_bytes flags. */ enum { BPF_F_RECOMPUTE_CSUM = (1ULL << 0), BPF_F_INVALIDATE_HASH = (1ULL << 1), }; /* BPF_FUNC_l3_csum_replace and BPF_FUNC_l4_csum_replace flags. * First 4 bits are for passing the header field size. */ enum { BPF_F_HDR_FIELD_MASK = 0xfULL, }; /* BPF_FUNC_l4_csum_replace flags. */ enum { BPF_F_PSEUDO_HDR = (1ULL << 4), BPF_F_MARK_MANGLED_0 = (1ULL << 5), BPF_F_MARK_ENFORCE = (1ULL << 6), BPF_F_IPV6 = (1ULL << 7), }; /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ enum { BPF_F_TUNINFO_IPV6 = (1ULL << 0), }; /* flags for both BPF_FUNC_get_stackid and BPF_FUNC_get_stack. */ enum { BPF_F_SKIP_FIELD_MASK = 0xffULL, BPF_F_USER_STACK = (1ULL << 8), /* flags used by BPF_FUNC_get_stackid only. */ BPF_F_FAST_STACK_CMP = (1ULL << 9), BPF_F_REUSE_STACKID = (1ULL << 10), /* flags used by BPF_FUNC_get_stack only. */ BPF_F_USER_BUILD_ID = (1ULL << 11), }; /* BPF_FUNC_skb_set_tunnel_key flags. */ enum { BPF_F_ZERO_CSUM_TX = (1ULL << 1), BPF_F_DONT_FRAGMENT = (1ULL << 2), BPF_F_SEQ_NUMBER = (1ULL << 3), BPF_F_NO_TUNNEL_KEY = (1ULL << 4), }; /* BPF_FUNC_skb_get_tunnel_key flags. */ enum { BPF_F_TUNINFO_FLAGS = (1ULL << 4), }; /* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and * BPF_FUNC_perf_event_read_value flags. */ enum { BPF_F_INDEX_MASK = 0xffffffffULL, BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK, /* BPF_FUNC_perf_event_output for sk_buff input context. */ BPF_F_CTXLEN_MASK = (0xfffffULL << 32), }; /* Current network namespace */ enum { BPF_F_CURRENT_NETNS = (-1L), }; /* BPF_FUNC_csum_level level values. */ enum { BPF_CSUM_LEVEL_QUERY, BPF_CSUM_LEVEL_INC, BPF_CSUM_LEVEL_DEC, BPF_CSUM_LEVEL_RESET, }; /* BPF_FUNC_skb_adjust_room flags. */ enum { BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0), BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1), BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2), BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3), BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4), BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5), BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6), BPF_F_ADJ_ROOM_DECAP_L3_IPV4 = (1ULL << 7), BPF_F_ADJ_ROOM_DECAP_L3_IPV6 = (1ULL << 8), }; enum { BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff, BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56, }; #define BPF_F_ADJ_ROOM_ENCAP_L2(len) (((__u64)len & \ BPF_ADJ_ROOM_ENCAP_L2_MASK) \ << BPF_ADJ_ROOM_ENCAP_L2_SHIFT) /* BPF_FUNC_sysctl_get_name flags. */ enum { BPF_F_SYSCTL_BASE_NAME = (1ULL << 0), }; /* BPF_FUNC__storage_get flags */ enum { BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0), /* BPF_SK_STORAGE_GET_F_CREATE is only kept for backward compatibility * and BPF_LOCAL_STORAGE_GET_F_CREATE must be used instead. */ BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE, }; /* BPF_FUNC_read_branch_records flags. */ enum { BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0), }; /* BPF_FUNC_bpf_ringbuf_commit, BPF_FUNC_bpf_ringbuf_discard, and * BPF_FUNC_bpf_ringbuf_output flags. */ enum { BPF_RB_NO_WAKEUP = (1ULL << 0), BPF_RB_FORCE_WAKEUP = (1ULL << 1), }; /* BPF_FUNC_bpf_ringbuf_query flags */ enum { BPF_RB_AVAIL_DATA = 0, BPF_RB_RING_SIZE = 1, BPF_RB_CONS_POS = 2, BPF_RB_PROD_POS = 3, }; /* BPF ring buffer constants */ enum { BPF_RINGBUF_BUSY_BIT = (1U << 31), BPF_RINGBUF_DISCARD_BIT = (1U << 30), BPF_RINGBUF_HDR_SZ = 8, }; /* BPF_FUNC_sk_assign flags in bpf_sk_lookup context. */ enum { BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0), BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1), }; /* Mode for BPF_FUNC_skb_adjust_room helper. */ enum bpf_adj_room_mode { BPF_ADJ_ROOM_NET, BPF_ADJ_ROOM_MAC, }; /* Mode for BPF_FUNC_skb_load_bytes_relative helper. */ enum bpf_hdr_start_off { BPF_HDR_START_MAC, BPF_HDR_START_NET, }; /* Encapsulation type for BPF_FUNC_lwt_push_encap helper. */ enum bpf_lwt_encap_mode { BPF_LWT_ENCAP_SEG6, BPF_LWT_ENCAP_SEG6_INLINE, BPF_LWT_ENCAP_IP, }; /* Flags for bpf_bprm_opts_set helper */ enum { BPF_F_BPRM_SECUREEXEC = (1ULL << 0), }; /* Flags for bpf_redirect and bpf_redirect_map helpers */ enum { BPF_F_INGRESS = (1ULL << 0), /* used for skb path */ BPF_F_BROADCAST = (1ULL << 3), /* used for XDP path */ BPF_F_EXCLUDE_INGRESS = (1ULL << 4), /* used for XDP path */ #define BPF_F_REDIRECT_FLAGS (BPF_F_INGRESS | BPF_F_BROADCAST | BPF_F_EXCLUDE_INGRESS) }; #define __bpf_md_ptr(type, name) \ union { \ type name; \ __u64 :64; \ } __attribute__((aligned(8))) /* The enum used in skb->tstamp_type. It specifies the clock type * of the time stored in the skb->tstamp. */ enum { BPF_SKB_TSTAMP_UNSPEC = 0, /* DEPRECATED */ BPF_SKB_TSTAMP_DELIVERY_MONO = 1, /* DEPRECATED */ BPF_SKB_CLOCK_REALTIME = 0, BPF_SKB_CLOCK_MONOTONIC = 1, BPF_SKB_CLOCK_TAI = 2, /* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle, * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid. */ }; /* user accessible mirror of in-kernel sk_buff. * new fields can only be added to the end of this structure */ struct __sk_buff { __u32 len; __u32 pkt_type; __u32 mark; __u32 queue_mapping; __u32 protocol; __u32 vlan_present; __u32 vlan_tci; __u32 vlan_proto; __u32 priority; __u32 ingress_ifindex; __u32 ifindex; __u32 tc_index; __u32 cb[5]; __u32 hash; __u32 tc_classid; __u32 data; __u32 data_end; __u32 napi_id; /* Accessed by BPF_PROG_TYPE_sk_skb types from here to ... */ __u32 family; __u32 remote_ip4; /* Stored in network byte order */ __u32 local_ip4; /* Stored in network byte order */ __u32 remote_ip6[4]; /* Stored in network byte order */ __u32 local_ip6[4]; /* Stored in network byte order */ __u32 remote_port; /* Stored in network byte order */ __u32 local_port; /* stored in host byte order */ /* ... here. */ __u32 data_meta; __bpf_md_ptr(struct bpf_flow_keys *, flow_keys); __u64 tstamp; __u32 wire_len; __u32 gso_segs; __bpf_md_ptr(struct bpf_sock *, sk); __u32 gso_size; __u8 tstamp_type; __u32 :24; /* Padding, future use. */ __u64 hwtstamp; }; struct bpf_tunnel_key { __u32 tunnel_id; union { __u32 remote_ipv4; __u32 remote_ipv6[4]; }; __u8 tunnel_tos; __u8 tunnel_ttl; union { __u16 tunnel_ext; /* compat */ __be16 tunnel_flags; }; __u32 tunnel_label; union { __u32 local_ipv4; __u32 local_ipv6[4]; }; }; /* user accessible mirror of in-kernel xfrm_state. * new fields can only be added to the end of this structure */ struct bpf_xfrm_state { __u32 reqid; __u32 spi; /* Stored in network byte order */ __u16 family; __u16 ext; /* Padding, future use. */ union { __u32 remote_ipv4; /* Stored in network byte order */ __u32 remote_ipv6[4]; /* Stored in network byte order */ }; }; /* Generic BPF return codes which all BPF program types may support. * The values are binary compatible with their TC_ACT_* counter-part to * provide backwards compatibility with existing SCHED_CLS and SCHED_ACT * programs. * * XDP is handled seprately, see XDP_*. */ enum bpf_ret_code { BPF_OK = 0, /* 1 reserved */ BPF_DROP = 2, /* 3-6 reserved */ BPF_REDIRECT = 7, /* >127 are reserved for prog type specific return codes. * * BPF_LWT_REROUTE: used by BPF_PROG_TYPE_LWT_IN and * BPF_PROG_TYPE_LWT_XMIT to indicate that skb had been * changed and should be routed based on its new L3 header. * (This is an L3 redirect, as opposed to L2 redirect * represented by BPF_REDIRECT above). */ BPF_LWT_REROUTE = 128, /* BPF_FLOW_DISSECTOR_CONTINUE: used by BPF_PROG_TYPE_FLOW_DISSECTOR * to indicate that no custom dissection was performed, and * fallback to standard dissector is requested. */ BPF_FLOW_DISSECTOR_CONTINUE = 129, }; struct bpf_sock { __u32 bound_dev_if; __u32 family; __u32 type; __u32 protocol; __u32 mark; __u32 priority; /* IP address also allows 1 and 2 bytes access */ __u32 src_ip4; __u32 src_ip6[4]; __u32 src_port; /* host byte order */ __be16 dst_port; /* network byte order */ __u16 :16; /* zero padding */ __u32 dst_ip4; __u32 dst_ip6[4]; __u32 state; __s32 rx_queue_mapping; }; struct bpf_tcp_sock { __u32 snd_cwnd; /* Sending congestion window */ __u32 srtt_us; /* smoothed round trip time << 3 in usecs */ __u32 rtt_min; __u32 snd_ssthresh; /* Slow start size threshold */ __u32 rcv_nxt; /* What we want to receive next */ __u32 snd_nxt; /* Next sequence we send */ __u32 snd_una; /* First byte we want an ack for */ __u32 mss_cache; /* Cached effective mss, not including SACKS */ __u32 ecn_flags; /* ECN status bits. */ __u32 rate_delivered; /* saved rate sample: packets delivered */ __u32 rate_interval_us; /* saved rate sample: time elapsed */ __u32 packets_out; /* Packets which are "in flight" */ __u32 retrans_out; /* Retransmitted packets out */ __u32 total_retrans; /* Total retransmits for entire connection */ __u32 segs_in; /* RFC4898 tcpEStatsPerfSegsIn * total number of segments in. */ __u32 data_segs_in; /* RFC4898 tcpEStatsPerfDataSegsIn * total number of data segments in. */ __u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut * The total number of segments sent. */ __u32 data_segs_out; /* RFC4898 tcpEStatsPerfDataSegsOut * total number of data segments sent. */ __u32 lost_out; /* Lost packets */ __u32 sacked_out; /* SACK'd packets */ __u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived * sum(delta(rcv_nxt)), or how many bytes * were acked. */ __u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked * sum(delta(snd_una)), or how many bytes * were acked. */ __u32 dsack_dups; /* RFC4898 tcpEStatsStackDSACKDups * total number of DSACK blocks received */ __u32 delivered; /* Total data packets delivered incl. rexmits */ __u32 delivered_ce; /* Like the above but only ECE marked packets */ __u32 icsk_retransmits; /* Number of unrecovered [RTO] timeouts */ }; struct bpf_sock_tuple { union { struct { __be32 saddr; __be32 daddr; __be16 sport; __be16 dport; } ipv4; struct { __be32 saddr[4]; __be32 daddr[4]; __be16 sport; __be16 dport; } ipv6; }; }; /* (Simplified) user return codes for tcx prog type. * A valid tcx program must return one of these defined values. All other * return codes are reserved for future use. Must remain compatible with * their TC_ACT_* counter-parts. For compatibility in behavior, unknown * return codes are mapped to TCX_NEXT. */ enum tcx_action_base { TCX_NEXT = -1, TCX_PASS = 0, TCX_DROP = 2, TCX_REDIRECT = 7, }; struct bpf_xdp_sock { __u32 queue_id; }; #define XDP_PACKET_HEADROOM 256 /* User return codes for XDP prog type. * A valid XDP program must return one of these defined values. All other * return codes are reserved for future use. Unknown return codes will * result in packet drops and a warning via bpf_warn_invalid_xdp_action(). */ enum xdp_action { XDP_ABORTED = 0, XDP_DROP, XDP_PASS, XDP_TX, XDP_REDIRECT, }; /* user accessible metadata for XDP packet hook * new fields must be added to the end of this structure */ struct xdp_md { __u32 data; __u32 data_end; __u32 data_meta; /* Below access go through struct xdp_rxq_info */ __u32 ingress_ifindex; /* rxq->dev->ifindex */ __u32 rx_queue_index; /* rxq->queue_index */ __u32 egress_ifindex; /* txq->dev->ifindex */ }; /* DEVMAP map-value layout * * The struct data-layout of map-value is a configuration interface. * New members can only be added to the end of this structure. */ struct bpf_devmap_val { __u32 ifindex; /* device index */ union { int fd; /* prog fd on map write */ __u32 id; /* prog id on map read */ } bpf_prog; }; /* CPUMAP map-value layout * * The struct data-layout of map-value is a configuration interface. * New members can only be added to the end of this structure. */ struct bpf_cpumap_val { __u32 qsize; /* queue size to remote target CPU */ union { int fd; /* prog fd on map write */ __u32 id; /* prog id on map read */ } bpf_prog; }; enum sk_action { SK_DROP = 0, SK_PASS, }; /* user accessible metadata for SK_MSG packet hook, new fields must * be added to the end of this structure */ struct sk_msg_md { __bpf_md_ptr(void *, data); __bpf_md_ptr(void *, data_end); __u32 family; __u32 remote_ip4; /* Stored in network byte order */ __u32 local_ip4; /* Stored in network byte order */ __u32 remote_ip6[4]; /* Stored in network byte order */ __u32 local_ip6[4]; /* Stored in network byte order */ __u32 remote_port; /* Stored in network byte order */ __u32 local_port; /* stored in host byte order */ __u32 size; /* Total size of sk_msg */ __bpf_md_ptr(struct bpf_sock *, sk); /* current socket */ }; struct sk_reuseport_md { /* * Start of directly accessible data. It begins from * the tcp/udp header. */ __bpf_md_ptr(void *, data); /* End of directly accessible data */ __bpf_md_ptr(void *, data_end); /* * Total length of packet (starting from the tcp/udp header). * Note that the directly accessible bytes (data_end - data) * could be less than this "len". Those bytes could be * indirectly read by a helper "bpf_skb_load_bytes()". */ __u32 len; /* * Eth protocol in the mac header (network byte order). e.g. * ETH_P_IP(0x0800) and ETH_P_IPV6(0x86DD) */ __u32 eth_protocol; __u32 ip_protocol; /* IP protocol. e.g. IPPROTO_TCP, IPPROTO_UDP */ __u32 bind_inany; /* Is sock bound to an INANY address? */ __u32 hash; /* A hash of the packet 4 tuples */ /* When reuse->migrating_sk is NULL, it is selecting a sk for the * new incoming connection request (e.g. selecting a listen sk for * the received SYN in the TCP case). reuse->sk is one of the sk * in the reuseport group. The bpf prog can use reuse->sk to learn * the local listening ip/port without looking into the skb. * * When reuse->migrating_sk is not NULL, reuse->sk is closed and * reuse->migrating_sk is the socket that needs to be migrated * to another listening socket. migrating_sk could be a fullsock * sk that is fully established or a reqsk that is in-the-middle * of 3-way handshake. */ __bpf_md_ptr(struct bpf_sock *, sk); __bpf_md_ptr(struct bpf_sock *, migrating_sk); }; #define BPF_TAG_SIZE 8 struct bpf_prog_info { __u32 type; __u32 id; __u8 tag[BPF_TAG_SIZE]; __u32 jited_prog_len; __u32 xlated_prog_len; __aligned_u64 jited_prog_insns; __aligned_u64 xlated_prog_insns; __u64 load_time; /* ns since boottime */ __u32 created_by_uid; __u32 nr_map_ids; __aligned_u64 map_ids; char name[BPF_OBJ_NAME_LEN]; __u32 ifindex; __u32 gpl_compatible:1; __u32 :31; /* alignment pad */ __u64 netns_dev; __u64 netns_ino; __u32 nr_jited_ksyms; __u32 nr_jited_func_lens; __aligned_u64 jited_ksyms; __aligned_u64 jited_func_lens; __u32 btf_id; __u32 func_info_rec_size; __aligned_u64 func_info; __u32 nr_func_info; __u32 nr_line_info; __aligned_u64 line_info; __aligned_u64 jited_line_info; __u32 nr_jited_line_info; __u32 line_info_rec_size; __u32 jited_line_info_rec_size; __u32 nr_prog_tags; __aligned_u64 prog_tags; __u64 run_time_ns; __u64 run_cnt; __u64 recursion_misses; __u32 verified_insns; __u32 attach_btf_obj_id; __u32 attach_btf_id; } __attribute__((aligned(8))); struct bpf_map_info { __u32 type; __u32 id; __u32 key_size; __u32 value_size; __u32 max_entries; __u32 map_flags; char name[BPF_OBJ_NAME_LEN]; __u32 ifindex; __u32 btf_vmlinux_value_type_id; __u64 netns_dev; __u64 netns_ino; __u32 btf_id; __u32 btf_key_type_id; __u32 btf_value_type_id; __u32 btf_vmlinux_id; __u64 map_extra; } __attribute__((aligned(8))); struct bpf_btf_info { __aligned_u64 btf; __u32 btf_size; __u32 id; __aligned_u64 name; __u32 name_len; __u32 kernel_btf; } __attribute__((aligned(8))); struct bpf_link_info { __u32 type; __u32 id; __u32 prog_id; union { struct { __aligned_u64 tp_name; /* in/out: tp_name buffer ptr */ __u32 tp_name_len; /* in/out: tp_name buffer len */ } raw_tracepoint; struct { __u32 attach_type; __u32 target_obj_id; /* prog_id for PROG_EXT, otherwise btf object id */ __u32 target_btf_id; /* BTF type id inside the object */ } tracing; struct { __u64 cgroup_id; __u32 attach_type; } cgroup; struct { __aligned_u64 target_name; /* in/out: target_name buffer ptr */ __u32 target_name_len; /* in/out: target_name buffer len */ /* If the iter specific field is 32 bits, it can be put * in the first or second union. Otherwise it should be * put in the second union. */ union { struct { __u32 map_id; } map; }; union { struct { __u64 cgroup_id; __u32 order; } cgroup; struct { __u32 tid; __u32 pid; } task; }; } iter; struct { __u32 netns_ino; __u32 attach_type; } netns; struct { __u32 ifindex; } xdp; struct { __u32 map_id; } struct_ops; struct { __u32 pf; __u32 hooknum; __s32 priority; __u32 flags; } netfilter; struct { __aligned_u64 addrs; __u32 count; /* in/out: kprobe_multi function count */ __u32 flags; __u64 missed; __aligned_u64 cookies; } kprobe_multi; struct { __aligned_u64 path; __aligned_u64 offsets; __aligned_u64 ref_ctr_offsets; __aligned_u64 cookies; __u32 path_size; /* in/out: real path size on success, including zero byte */ __u32 count; /* in/out: uprobe_multi offsets/ref_ctr_offsets/cookies count */ __u32 flags; __u32 pid; } uprobe_multi; struct { __u32 type; /* enum bpf_perf_event_type */ __u32 :32; union { struct { __aligned_u64 file_name; /* in/out */ __u32 name_len; __u32 offset; /* offset from file_name */ __u64 cookie; __u64 ref_ctr_offset; } uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */ struct { __aligned_u64 func_name; /* in/out */ __u32 name_len; __u32 offset; /* offset from func_name */ __u64 addr; __u64 missed; __u64 cookie; } kprobe; /* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ struct { __aligned_u64 tp_name; /* in/out */ __u32 name_len; __u32 :32; __u64 cookie; } tracepoint; /* BPF_PERF_EVENT_TRACEPOINT */ struct { __u64 config; __u32 type; __u32 :32; __u64 cookie; } event; /* BPF_PERF_EVENT_EVENT */ }; } perf_event; struct { __u32 ifindex; __u32 attach_type; } tcx; struct { __u32 ifindex; __u32 attach_type; } netkit; struct { __u32 map_id; __u32 attach_type; } sockmap; }; } __attribute__((aligned(8))); /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed * by user and intended to be used by socket (e.g. to bind to, depends on * attach type). */ struct bpf_sock_addr { __u32 user_family; /* Allows 4-byte read, but no write. */ __u32 user_ip4; /* Allows 1,2,4-byte read and 4-byte write. * Stored in network byte order. */ __u32 user_ip6[4]; /* Allows 1,2,4,8-byte read and 4,8-byte write. * Stored in network byte order. */ __u32 user_port; /* Allows 1,2,4-byte read and 4-byte write. * Stored in network byte order */ __u32 family; /* Allows 4-byte read, but no write */ __u32 type; /* Allows 4-byte read, but no write */ __u32 protocol; /* Allows 4-byte read, but no write */ __u32 msg_src_ip4; /* Allows 1,2,4-byte read and 4-byte write. * Stored in network byte order. */ __u32 msg_src_ip6[4]; /* Allows 1,2,4,8-byte read and 4,8-byte write. * Stored in network byte order. */ __bpf_md_ptr(struct bpf_sock *, sk); }; /* User bpf_sock_ops struct to access socket values and specify request ops * and their replies. * Some of this fields are in network (bigendian) byte order and may need * to be converted before use (bpf_ntohl() defined in samples/bpf/bpf_endian.h). * New fields can only be added at the end of this structure */ struct bpf_sock_ops { __u32 op; union { __u32 args[4]; /* Optionally passed to bpf program */ __u32 reply; /* Returned by bpf program */ __u32 replylong[4]; /* Optionally returned by bpf prog */ }; __u32 family; __u32 remote_ip4; /* Stored in network byte order */ __u32 local_ip4; /* Stored in network byte order */ __u32 remote_ip6[4]; /* Stored in network byte order */ __u32 local_ip6[4]; /* Stored in network byte order */ __u32 remote_port; /* Stored in network byte order */ __u32 local_port; /* stored in host byte order */ __u32 is_fullsock; /* Some TCP fields are only valid if * there is a full socket. If not, the * fields read as zero. */ __u32 snd_cwnd; __u32 srtt_us; /* Averaged RTT << 3 in usecs */ __u32 bpf_sock_ops_cb_flags; /* flags defined in uapi/linux/tcp.h */ __u32 state; __u32 rtt_min; __u32 snd_ssthresh; __u32 rcv_nxt; __u32 snd_nxt; __u32 snd_una; __u32 mss_cache; __u32 ecn_flags; __u32 rate_delivered; __u32 rate_interval_us; __u32 packets_out; __u32 retrans_out; __u32 total_retrans; __u32 segs_in; __u32 data_segs_in; __u32 segs_out; __u32 data_segs_out; __u32 lost_out; __u32 sacked_out; __u32 sk_txhash; __u64 bytes_received; __u64 bytes_acked; __bpf_md_ptr(struct bpf_sock *, sk); /* [skb_data, skb_data_end) covers the whole TCP header. * * BPF_SOCK_OPS_PARSE_HDR_OPT_CB: The packet received * BPF_SOCK_OPS_HDR_OPT_LEN_CB: Not useful because the * header has not been written. * BPF_SOCK_OPS_WRITE_HDR_OPT_CB: The header and options have * been written so far. * BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: The SYNACK that concludes * the 3WHS. * BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: The ACK that concludes * the 3WHS. * * bpf_load_hdr_opt() can also be used to read a particular option. */ __bpf_md_ptr(void *, skb_data); __bpf_md_ptr(void *, skb_data_end); __u32 skb_len; /* The total length of a packet. * It includes the header, options, * and payload. */ __u32 skb_tcp_flags; /* tcp_flags of the header. It provides * an easy way to check for tcp_flags * without parsing skb_data. * * In particular, the skb_tcp_flags * will still be available in * BPF_SOCK_OPS_HDR_OPT_LEN even though * the outgoing header has not * been written yet. */ __u64 skb_hwtstamp; }; /* Definitions for bpf_sock_ops_cb_flags */ enum { BPF_SOCK_OPS_RTO_CB_FLAG = (1<<0), BPF_SOCK_OPS_RETRANS_CB_FLAG = (1<<1), BPF_SOCK_OPS_STATE_CB_FLAG = (1<<2), BPF_SOCK_OPS_RTT_CB_FLAG = (1<<3), /* Call bpf for all received TCP headers. The bpf prog will be * called under sock_ops->op == BPF_SOCK_OPS_PARSE_HDR_OPT_CB * * Please refer to the comment in BPF_SOCK_OPS_PARSE_HDR_OPT_CB * for the header option related helpers that will be useful * to the bpf programs. * * It could be used at the client/active side (i.e. connect() side) * when the server told it that the server was in syncookie * mode and required the active side to resend the bpf-written * options. The active side can keep writing the bpf-options until * it received a valid packet from the server side to confirm * the earlier packet (and options) has been received. The later * example patch is using it like this at the active side when the * server is in syncookie mode. * * The bpf prog will usually turn this off in the common cases. */ BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1<<4), /* Call bpf when kernel has received a header option that * the kernel cannot handle. The bpf prog will be called under * sock_ops->op == BPF_SOCK_OPS_PARSE_HDR_OPT_CB. * * Please refer to the comment in BPF_SOCK_OPS_PARSE_HDR_OPT_CB * for the header option related helpers that will be useful * to the bpf programs. */ BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1<<5), /* Call bpf when the kernel is writing header options for the * outgoing packet. The bpf prog will first be called * to reserve space in a skb under * sock_ops->op == BPF_SOCK_OPS_HDR_OPT_LEN_CB. Then * the bpf prog will be called to write the header option(s) * under sock_ops->op == BPF_SOCK_OPS_WRITE_HDR_OPT_CB. * * Please refer to the comment in BPF_SOCK_OPS_HDR_OPT_LEN_CB * and BPF_SOCK_OPS_WRITE_HDR_OPT_CB for the header option * related helpers that will be useful to the bpf programs. * * The kernel gets its chance to reserve space and write * options first before the BPF program does. */ BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6), /* Mask of all currently supported cb flags */ BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F, }; enum { SK_BPF_CB_TX_TIMESTAMPING = 1<<0, SK_BPF_CB_MASK = (SK_BPF_CB_TX_TIMESTAMPING - 1) | SK_BPF_CB_TX_TIMESTAMPING }; /* List of known BPF sock_ops operators. * New entries can only be added at the end */ enum { BPF_SOCK_OPS_VOID, BPF_SOCK_OPS_TIMEOUT_INIT, /* Should return SYN-RTO value to use or * -1 if default value should be used */ BPF_SOCK_OPS_RWND_INIT, /* Should return initial advertized * window (in packets) or -1 if default * value should be used */ BPF_SOCK_OPS_TCP_CONNECT_CB, /* Calls BPF program right before an * active connection is initialized */ BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB, /* Calls BPF program when an * active connection is * established */ BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, /* Calls BPF program when a * passive connection is * established */ BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control * needs ECN */ BPF_SOCK_OPS_BASE_RTT, /* Get base RTT. The correct value is * based on the path and may be * dependent on the congestion control * algorithm. In general it indicates * a congestion threshold. RTTs above * this indicate congestion */ BPF_SOCK_OPS_RTO_CB, /* Called when an RTO has triggered. * Arg1: value of icsk_retransmits * Arg2: value of icsk_rto * Arg3: whether RTO has expired */ BPF_SOCK_OPS_RETRANS_CB, /* Called when skb is retransmitted. * Arg1: sequence number of 1st byte * Arg2: # segments * Arg3: return value of * tcp_transmit_skb (0 => success) */ BPF_SOCK_OPS_STATE_CB, /* Called when TCP changes state. * Arg1: old_state * Arg2: new_state */ BPF_SOCK_OPS_TCP_LISTEN_CB, /* Called on listen(2), right after * socket transition to LISTEN state. */ BPF_SOCK_OPS_RTT_CB, /* Called on every RTT. * Arg1: measured RTT input (mrtt) * Arg2: updated srtt */ BPF_SOCK_OPS_PARSE_HDR_OPT_CB, /* Parse the header option. * It will be called to handle * the packets received at * an already established * connection. * * sock_ops->skb_data: * Referring to the received skb. * It covers the TCP header only. * * bpf_load_hdr_opt() can also * be used to search for a * particular option. */ BPF_SOCK_OPS_HDR_OPT_LEN_CB, /* Reserve space for writing the * header option later in * BPF_SOCK_OPS_WRITE_HDR_OPT_CB. * Arg1: bool want_cookie. (in * writing SYNACK only) * * sock_ops->skb_data: * Not available because no header has * been written yet. * * sock_ops->skb_tcp_flags: * The tcp_flags of the * outgoing skb. (e.g. SYN, ACK, FIN). * * bpf_reserve_hdr_opt() should * be used to reserve space. */ BPF_SOCK_OPS_WRITE_HDR_OPT_CB, /* Write the header options * Arg1: bool want_cookie. (in * writing SYNACK only) * * sock_ops->skb_data: * Referring to the outgoing skb. * It covers the TCP header * that has already been written * by the kernel and the * earlier bpf-progs. * * sock_ops->skb_tcp_flags: * The tcp_flags of the outgoing * skb. (e.g. SYN, ACK, FIN). * * bpf_store_hdr_opt() should * be used to write the * option. * * bpf_load_hdr_opt() can also * be used to search for a * particular option that * has already been written * by the kernel or the * earlier bpf-progs. */ BPF_SOCK_OPS_TSTAMP_SCHED_CB, /* Called when skb is passing * through dev layer when * SK_BPF_CB_TX_TIMESTAMPING * feature is on. */ BPF_SOCK_OPS_TSTAMP_SND_SW_CB, /* Called when skb is about to send * to the nic when SK_BPF_CB_TX_TIMESTAMPING * feature is on. */ BPF_SOCK_OPS_TSTAMP_SND_HW_CB, /* Called in hardware phase when * SK_BPF_CB_TX_TIMESTAMPING feature * is on. */ BPF_SOCK_OPS_TSTAMP_ACK_CB, /* Called when all the skbs in the * same sendmsg call are acked * when SK_BPF_CB_TX_TIMESTAMPING * feature is on. */ BPF_SOCK_OPS_TSTAMP_SENDMSG_CB, /* Called when every sendmsg syscall * is triggered. It's used to correlate * sendmsg timestamp with corresponding * tskey. */ }; /* List of TCP states. There is a build check in net/ipv4/tcp.c to detect * changes between the TCP and BPF versions. Ideally this should never happen. * If it does, we need to add code to convert them before calling * the BPF sock_ops function. */ enum { BPF_TCP_ESTABLISHED = 1, BPF_TCP_SYN_SENT, BPF_TCP_SYN_RECV, BPF_TCP_FIN_WAIT1, BPF_TCP_FIN_WAIT2, BPF_TCP_TIME_WAIT, BPF_TCP_CLOSE, BPF_TCP_CLOSE_WAIT, BPF_TCP_LAST_ACK, BPF_TCP_LISTEN, BPF_TCP_CLOSING, /* Now a valid state */ BPF_TCP_NEW_SYN_RECV, BPF_TCP_BOUND_INACTIVE, BPF_TCP_MAX_STATES /* Leave at the end! */ }; enum { TCP_BPF_IW = 1001, /* Set TCP initial congestion window */ TCP_BPF_SNDCWND_CLAMP = 1002, /* Set sndcwnd_clamp */ TCP_BPF_DELACK_MAX = 1003, /* Max delay ack in usecs */ TCP_BPF_RTO_MIN = 1004, /* Min delay ack in usecs */ /* Copy the SYN pkt to optval * * BPF_PROG_TYPE_SOCK_OPS only. It is similar to the * bpf_getsockopt(TCP_SAVED_SYN) but it does not limit * to only getting from the saved_syn. It can either get the * syn packet from: * * 1. the just-received SYN packet (only available when writing the * SYNACK). It will be useful when it is not necessary to * save the SYN packet for latter use. It is also the only way * to get the SYN during syncookie mode because the syn * packet cannot be saved during syncookie. * * OR * * 2. the earlier saved syn which was done by * bpf_setsockopt(TCP_SAVE_SYN). * * The bpf_getsockopt(TCP_BPF_SYN*) option will hide where the * SYN packet is obtained. * * If the bpf-prog does not need the IP[46] header, the * bpf-prog can avoid parsing the IP header by using * TCP_BPF_SYN. Otherwise, the bpf-prog can get both * IP[46] and TCP header by using TCP_BPF_SYN_IP. * * >0: Total number of bytes copied * -ENOSPC: Not enough space in optval. Only optlen number of * bytes is copied. * -ENOENT: The SYN skb is not available now and the earlier SYN pkt * is not saved by setsockopt(TCP_SAVE_SYN). */ TCP_BPF_SYN = 1005, /* Copy the TCP header */ TCP_BPF_SYN_IP = 1006, /* Copy the IP[46] and TCP header */ TCP_BPF_SYN_MAC = 1007, /* Copy the MAC, IP[46], and TCP header */ TCP_BPF_SOCK_OPS_CB_FLAGS = 1008, /* Get or Set TCP sock ops flags */ SK_BPF_CB_FLAGS = 1009, /* Get or set sock ops flags in socket */ }; enum { BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0), }; /* args[0] value during BPF_SOCK_OPS_HDR_OPT_LEN_CB and * BPF_SOCK_OPS_WRITE_HDR_OPT_CB. */ enum { BPF_WRITE_HDR_TCP_CURRENT_MSS = 1, /* Kernel is finding the * total option spaces * required for an established * sk in order to calculate the * MSS. No skb is actually * sent. */ BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2, /* Kernel is in syncookie mode * when sending a SYN. */ }; struct bpf_perf_event_value { __u64 counter; __u64 enabled; __u64 running; }; enum { BPF_DEVCG_ACC_MKNOD = (1ULL << 0), BPF_DEVCG_ACC_READ = (1ULL << 1), BPF_DEVCG_ACC_WRITE = (1ULL << 2), }; enum { BPF_DEVCG_DEV_BLOCK = (1ULL << 0), BPF_DEVCG_DEV_CHAR = (1ULL << 1), }; struct bpf_cgroup_dev_ctx { /* access_type encoded as (BPF_DEVCG_ACC_* << 16) | BPF_DEVCG_DEV_* */ __u32 access_type; __u32 major; __u32 minor; }; struct bpf_raw_tracepoint_args { __u64 args[0]; }; /* DIRECT: Skip the FIB rules and go to FIB table associated with device * OUTPUT: Do lookup from egress perspective; default is ingress */ enum { BPF_FIB_LOOKUP_DIRECT = (1U << 0), BPF_FIB_LOOKUP_OUTPUT = (1U << 1), BPF_FIB_LOOKUP_SKIP_NEIGH = (1U << 2), BPF_FIB_LOOKUP_TBID = (1U << 3), BPF_FIB_LOOKUP_SRC = (1U << 4), BPF_FIB_LOOKUP_MARK = (1U << 5), }; enum { BPF_FIB_LKUP_RET_SUCCESS, /* lookup successful */ BPF_FIB_LKUP_RET_BLACKHOLE, /* dest is blackholed; can be dropped */ BPF_FIB_LKUP_RET_UNREACHABLE, /* dest is unreachable; can be dropped */ BPF_FIB_LKUP_RET_PROHIBIT, /* dest not allowed; can be dropped */ BPF_FIB_LKUP_RET_NOT_FWDED, /* packet is not forwarded */ BPF_FIB_LKUP_RET_FWD_DISABLED, /* fwding is not enabled on ingress */ BPF_FIB_LKUP_RET_UNSUPP_LWT, /* fwd requires encapsulation */ BPF_FIB_LKUP_RET_NO_NEIGH, /* no neighbor entry for nh */ BPF_FIB_LKUP_RET_FRAG_NEEDED, /* fragmentation required to fwd */ BPF_FIB_LKUP_RET_NO_SRC_ADDR, /* failed to derive IP src addr */ }; struct bpf_fib_lookup { /* input: network family for lookup (AF_INET, AF_INET6) * output: network family of egress nexthop */ __u8 family; /* set if lookup is to consider L4 data - e.g., FIB rules */ __u8 l4_protocol; __be16 sport; __be16 dport; union { /* used for MTU check */ /* input to lookup */ __u16 tot_len; /* L3 length from network hdr (iph->tot_len) */ /* output: MTU value */ __u16 mtu_result; } __attribute__((packed, aligned(2))); /* input: L3 device index for lookup * output: device index from FIB lookup */ __u32 ifindex; union { /* inputs to lookup */ __u8 tos; /* AF_INET */ __be32 flowinfo; /* AF_INET6, flow_label + priority */ /* output: metric of fib result (IPv4/IPv6 only) */ __u32 rt_metric; }; /* input: source address to consider for lookup * output: source address result from lookup */ union { __be32 ipv4_src; __u32 ipv6_src[4]; /* in6_addr; network order */ }; /* input to bpf_fib_lookup, ipv{4,6}_dst is destination address in * network header. output: bpf_fib_lookup sets to gateway address * if FIB lookup returns gateway route */ union { __be32 ipv4_dst; __u32 ipv6_dst[4]; /* in6_addr; network order */ }; union { struct { /* output */ __be16 h_vlan_proto; __be16 h_vlan_TCI; }; /* input: when accompanied with the * 'BPF_FIB_LOOKUP_DIRECT | BPF_FIB_LOOKUP_TBID` flags, a * specific routing table to use for the fib lookup. */ __u32 tbid; }; union { /* input */ struct { __u32 mark; /* policy routing */ /* 2 4-byte holes for input */ }; /* output: source and dest mac */ struct { __u8 smac[6]; /* ETH_ALEN */ __u8 dmac[6]; /* ETH_ALEN */ }; }; }; struct bpf_redir_neigh { /* network family for lookup (AF_INET, AF_INET6) */ __u32 nh_family; /* network address of nexthop; skips fib lookup to find gateway */ union { __be32 ipv4_nh; __u32 ipv6_nh[4]; /* in6_addr; network order */ }; }; /* bpf_check_mtu flags*/ enum bpf_check_mtu_flags { BPF_MTU_CHK_SEGS = (1U << 0), }; enum bpf_check_mtu_ret { BPF_MTU_CHK_RET_SUCCESS, /* check and lookup successful */ BPF_MTU_CHK_RET_FRAG_NEEDED, /* fragmentation required to fwd */ BPF_MTU_CHK_RET_SEGS_TOOBIG, /* GSO re-segmentation needed to fwd */ }; enum bpf_task_fd_type { BPF_FD_TYPE_RAW_TRACEPOINT, /* tp name */ BPF_FD_TYPE_TRACEPOINT, /* tp name */ BPF_FD_TYPE_KPROBE, /* (symbol + offset) or addr */ BPF_FD_TYPE_KRETPROBE, /* (symbol + offset) or addr */ BPF_FD_TYPE_UPROBE, /* filename + offset */ BPF_FD_TYPE_URETPROBE, /* filename + offset */ }; enum { BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0), BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1), BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2), }; struct bpf_flow_keys { __u16 nhoff; __u16 thoff; __u16 addr_proto; /* ETH_P_* of valid addrs */ __u8 is_frag; __u8 is_first_frag; __u8 is_encap; __u8 ip_proto; __be16 n_proto; __be16 sport; __be16 dport; union { struct { __be32 ipv4_src; __be32 ipv4_dst; }; struct { __u32 ipv6_src[4]; /* in6_addr; network order */ __u32 ipv6_dst[4]; /* in6_addr; network order */ }; }; __u32 flags; __be32 flow_label; }; struct bpf_func_info { __u32 insn_off; __u32 type_id; }; #define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10) #define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff) struct bpf_line_info { __u32 insn_off; __u32 file_name_off; __u32 line_off; __u32 line_col; }; struct bpf_spin_lock { __u32 val; }; struct bpf_timer { __u64 __opaque[2]; } __attribute__((aligned(8))); struct bpf_wq { __u64 __opaque[2]; } __attribute__((aligned(8))); struct bpf_dynptr { __u64 __opaque[2]; } __attribute__((aligned(8))); struct bpf_list_head { __u64 __opaque[2]; } __attribute__((aligned(8))); struct bpf_list_node { __u64 __opaque[3]; } __attribute__((aligned(8))); struct bpf_rb_root { __u64 __opaque[2]; } __attribute__((aligned(8))); struct bpf_rb_node { __u64 __opaque[4]; } __attribute__((aligned(8))); struct bpf_refcount { __u32 __opaque[1]; } __attribute__((aligned(4))); struct bpf_sysctl { __u32 write; /* Sysctl is being read (= 0) or written (= 1). * Allows 1,2,4-byte read, but no write. */ __u32 file_pos; /* Sysctl file position to read from, write to. * Allows 1,2,4-byte read an 4-byte write. */ }; struct bpf_sockopt { __bpf_md_ptr(struct bpf_sock *, sk); __bpf_md_ptr(void *, optval); __bpf_md_ptr(void *, optval_end); __s32 level; __s32 optname; __s32 optlen; __s32 retval; }; struct bpf_pidns_info { __u32 pid; __u32 tgid; }; /* User accessible data for SK_LOOKUP programs. Add new fields at the end. */ struct bpf_sk_lookup { union { __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ __u64 cookie; /* Non-zero if socket was selected in PROG_TEST_RUN */ }; __u32 family; /* Protocol family (AF_INET, AF_INET6) */ __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ __u32 remote_ip4; /* Network byte order */ __u32 remote_ip6[4]; /* Network byte order */ __be16 remote_port; /* Network byte order */ __u16 :16; /* Zero padding */ __u32 local_ip4; /* Network byte order */ __u32 local_ip6[4]; /* Network byte order */ __u32 local_port; /* Host byte order */ __u32 ingress_ifindex; /* The arriving interface. Determined by inet_iif. */ }; /* * struct btf_ptr is used for typed pointer representation; the * type id is used to render the pointer data as the appropriate type * via the bpf_snprintf_btf() helper described above. A flags field - * potentially to specify additional details about the BTF pointer * (rather than its mode of display) - is included for future use. * Display flags - BTF_F_* - are passed to bpf_snprintf_btf separately. */ struct btf_ptr { void *ptr; __u32 type_id; __u32 flags; /* BTF ptr flags; unused at present. */ }; /* * Flags to control bpf_snprintf_btf() behaviour. * - BTF_F_COMPACT: no formatting around type information * - BTF_F_NONAME: no struct/union member names/types * - BTF_F_PTR_RAW: show raw (unobfuscated) pointer values; * equivalent to %px. * - BTF_F_ZERO: show zero-valued struct/union members; they * are not displayed by default */ enum { BTF_F_COMPACT = (1ULL << 0), BTF_F_NONAME = (1ULL << 1), BTF_F_PTR_RAW = (1ULL << 2), BTF_F_ZERO = (1ULL << 3), }; /* bpf_core_relo_kind encodes which aspect of captured field/type/enum value * has to be adjusted by relocations. It is emitted by llvm and passed to * libbpf and later to the kernel. */ enum bpf_core_relo_kind { BPF_CORE_FIELD_BYTE_OFFSET = 0, /* field byte offset */ BPF_CORE_FIELD_BYTE_SIZE = 1, /* field size in bytes */ BPF_CORE_FIELD_EXISTS = 2, /* field existence in target kernel */ BPF_CORE_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */ BPF_CORE_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */ BPF_CORE_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */ BPF_CORE_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */ BPF_CORE_TYPE_ID_TARGET = 7, /* type ID in target kernel */ BPF_CORE_TYPE_EXISTS = 8, /* type existence in target kernel */ BPF_CORE_TYPE_SIZE = 9, /* type size in bytes */ BPF_CORE_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */ BPF_CORE_ENUMVAL_VALUE = 11, /* enum value integer value */ BPF_CORE_TYPE_MATCHES = 12, /* type match in target kernel */ }; /* * "struct bpf_core_relo" is used to pass relocation data form LLVM to libbpf * and from libbpf to the kernel. * * CO-RE relocation captures the following data: * - insn_off - instruction offset (in bytes) within a BPF program that needs * its insn->imm field to be relocated with actual field info; * - type_id - BTF type ID of the "root" (containing) entity of a relocatable * type or field; * - access_str_off - offset into corresponding .BTF string section. String * interpretation depends on specific relocation kind: * - for field-based relocations, string encodes an accessed field using * a sequence of field and array indices, separated by colon (:). It's * conceptually very close to LLVM's getelementptr ([0]) instruction's * arguments for identifying offset to a field. * - for type-based relocations, strings is expected to be just "0"; * - for enum value-based relocations, string contains an index of enum * value within its enum type; * - kind - one of enum bpf_core_relo_kind; * * Example: * struct sample { * int a; * struct { * int b[10]; * }; * }; * * struct sample *s = ...; * int *x = &s->a; // encoded as "0:0" (a is field #0) * int *y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1, * // b is field #0 inside anon struct, accessing elem #5) * int *z = &s[10]->b; // encoded as "10:1" (ptr is used as an array) * * type_id for all relocs in this example will capture BTF type id of * `struct sample`. * * Such relocation is emitted when using __builtin_preserve_access_index() * Clang built-in, passing expression that captures field address, e.g.: * * bpf_probe_read(&dst, sizeof(dst), * __builtin_preserve_access_index(&src->a.b.c)); * * In this case Clang will emit field relocation recording necessary data to * be able to find offset of embedded `a.b.c` field within `src` struct. * * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction */ struct bpf_core_relo { __u32 insn_off; __u32 type_id; __u32 access_str_off; enum bpf_core_relo_kind kind; }; /* * Flags to control bpf_timer_start() behaviour. * - BPF_F_TIMER_ABS: Timeout passed is absolute time, by default it is * relative to current time. * - BPF_F_TIMER_CPU_PIN: Timer will be pinned to the CPU of the caller. */ enum { BPF_F_TIMER_ABS = (1ULL << 0), BPF_F_TIMER_CPU_PIN = (1ULL << 1), }; /* BPF numbers iterator state */ struct bpf_iter_num { /* opaque iterator state; having __u64 here allows to preserve correct * alignment requirements in vmlinux.h, generated from BTF */ __u64 __opaque[1]; } __attribute__((aligned(8))); /* * Flags to control BPF kfunc behaviour. * - BPF_F_PAD_ZEROS: Pad destination buffer with zeros. (See the respective * helper documentation for details.) */ enum bpf_kfunc_flags { BPF_F_PAD_ZEROS = (1ULL << 0), }; #endif /* _UAPI__LINUX_BPF_H__ */ bpftrace-0.27.1/src/stdlib/include/linux/bpf_common.h000066400000000000000000000025461526721631600225310ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI__LINUX_BPF_COMMON_H__ #define _UAPI__LINUX_BPF_COMMON_H__ /* Instruction classes */ #define BPF_CLASS(code) ((code) & 0x07) #define BPF_LD 0x00 #define BPF_LDX 0x01 #define BPF_ST 0x02 #define BPF_STX 0x03 #define BPF_ALU 0x04 #define BPF_JMP 0x05 #define BPF_RET 0x06 #define BPF_MISC 0x07 /* ld/ldx fields */ #define BPF_SIZE(code) ((code) & 0x18) #define BPF_W 0x00 /* 32-bit */ #define BPF_H 0x08 /* 16-bit */ #define BPF_B 0x10 /* 8-bit */ /* eBPF BPF_DW 0x18 64-bit */ #define BPF_MODE(code) ((code) & 0xe0) #define BPF_IMM 0x00 #define BPF_ABS 0x20 #define BPF_IND 0x40 #define BPF_MEM 0x60 #define BPF_LEN 0x80 #define BPF_MSH 0xa0 /* alu/jmp fields */ #define BPF_OP(code) ((code) & 0xf0) #define BPF_ADD 0x00 #define BPF_SUB 0x10 #define BPF_MUL 0x20 #define BPF_DIV 0x30 #define BPF_OR 0x40 #define BPF_AND 0x50 #define BPF_LSH 0x60 #define BPF_RSH 0x70 #define BPF_NEG 0x80 #define BPF_MOD 0x90 #define BPF_XOR 0xa0 #define BPF_JA 0x00 #define BPF_JEQ 0x10 #define BPF_JGT 0x20 #define BPF_JGE 0x30 #define BPF_JSET 0x40 #define BPF_SRC(code) ((code) & 0x08) #define BPF_K 0x00 #define BPF_X 0x08 #ifndef BPF_MAXINSNS #define BPF_MAXINSNS 4096 #endif #endif /* _UAPI__LINUX_BPF_COMMON_H__ */ bpftrace-0.27.1/src/stdlib/include/linux/btf.h000066400000000000000000000130121526721631600211530ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* Copyright (c) 2018 Facebook */ #ifndef _UAPI__LINUX_BTF_H__ #define _UAPI__LINUX_BTF_H__ #include #define BTF_MAGIC 0xeB9F #define BTF_VERSION 1 struct btf_header { __u16 magic; __u8 version; __u8 flags; __u32 hdr_len; /* All offsets are in bytes relative to the end of this header */ __u32 type_off; /* offset of type section */ __u32 type_len; /* length of type section */ __u32 str_off; /* offset of string section */ __u32 str_len; /* length of string section */ }; /* Max # of type identifier */ #define BTF_MAX_TYPE 0x000fffff /* Max offset into the string section */ #define BTF_MAX_NAME_OFFSET 0x00ffffff /* Max # of struct/union/enum members or func args */ #define BTF_MAX_VLEN 0xffff struct btf_type { __u32 name_off; /* "info" bits arrangement * bits 0-15: vlen (e.g. # of struct's members) * bits 16-23: unused * bits 24-28: kind (e.g. int, ptr, array...etc) * bits 29-30: unused * bit 31: kind_flag, currently used by * struct, union, enum, fwd, enum64, * decl_tag and type_tag */ __u32 info; /* "size" is used by INT, ENUM, STRUCT, UNION, DATASEC and ENUM64. * "size" tells the size of the type it is describing. * * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, * FUNC, FUNC_PROTO, VAR, DECL_TAG and TYPE_TAG. * "type" is a type_id referring to another type. */ union { __u32 size; __u32 type; }; }; #define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f) #define BTF_INFO_VLEN(info) ((info) & 0xffff) #define BTF_INFO_KFLAG(info) ((info) >> 31) enum { BTF_KIND_UNKN = 0, /* Unknown */ BTF_KIND_INT = 1, /* Integer */ BTF_KIND_PTR = 2, /* Pointer */ BTF_KIND_ARRAY = 3, /* Array */ BTF_KIND_STRUCT = 4, /* Struct */ BTF_KIND_UNION = 5, /* Union */ BTF_KIND_ENUM = 6, /* Enumeration up to 32-bit values */ BTF_KIND_FWD = 7, /* Forward */ BTF_KIND_TYPEDEF = 8, /* Typedef */ BTF_KIND_VOLATILE = 9, /* Volatile */ BTF_KIND_CONST = 10, /* Const */ BTF_KIND_RESTRICT = 11, /* Restrict */ BTF_KIND_FUNC = 12, /* Function */ BTF_KIND_FUNC_PROTO = 13, /* Function Proto */ BTF_KIND_VAR = 14, /* Variable */ BTF_KIND_DATASEC = 15, /* Section */ BTF_KIND_FLOAT = 16, /* Floating point */ BTF_KIND_DECL_TAG = 17, /* Decl Tag */ BTF_KIND_TYPE_TAG = 18, /* Type Tag */ BTF_KIND_ENUM64 = 19, /* Enumeration up to 64-bit values */ NR_BTF_KINDS, BTF_KIND_MAX = NR_BTF_KINDS - 1, }; /* For some specific BTF_KIND, "struct btf_type" is immediately * followed by extra data. */ /* BTF_KIND_INT is followed by a u32 and the following * is the 32 bits arrangement: */ #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) #define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16) #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) /* Attributes stored in the BTF_INT_ENCODING */ #define BTF_INT_SIGNED (1 << 0) #define BTF_INT_CHAR (1 << 1) #define BTF_INT_BOOL (1 << 2) /* BTF_KIND_ENUM is followed by multiple "struct btf_enum". * The exact number of btf_enum is stored in the vlen (of the * info in "struct btf_type"). */ struct btf_enum { __u32 name_off; __s32 val; }; /* BTF_KIND_ARRAY is followed by one "struct btf_array" */ struct btf_array { __u32 type; __u32 index_type; __u32 nelems; }; /* BTF_KIND_STRUCT and BTF_KIND_UNION are followed * by multiple "struct btf_member". The exact number * of btf_member is stored in the vlen (of the info in * "struct btf_type"). */ struct btf_member { __u32 name_off; __u32 type; /* If the type info kind_flag is set, the btf_member offset * contains both member bitfield size and bit offset. The * bitfield size is set for bitfield members. If the type * info kind_flag is not set, the offset contains only bit * offset. */ __u32 offset; }; /* If the struct/union type info kind_flag is set, the * following two macros are used to access bitfield_size * and bit_offset from btf_member.offset. */ #define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24) #define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff) /* BTF_KIND_FUNC_PROTO is followed by multiple "struct btf_param". * The exact number of btf_param is stored in the vlen (of the * info in "struct btf_type"). */ struct btf_param { __u32 name_off; __u32 type; }; enum { BTF_VAR_STATIC = 0, BTF_VAR_GLOBAL_ALLOCATED = 1, BTF_VAR_GLOBAL_EXTERN = 2, }; enum btf_func_linkage { BTF_FUNC_STATIC = 0, BTF_FUNC_GLOBAL = 1, BTF_FUNC_EXTERN = 2, }; /* BTF_KIND_VAR is followed by a single "struct btf_var" to describe * additional information related to the variable such as its linkage. */ struct btf_var { __u32 linkage; }; /* BTF_KIND_DATASEC is followed by multiple "struct btf_var_secinfo" * to describe all BTF_KIND_VAR types it contains along with it's * in-section offset as well as size. */ struct btf_var_secinfo { __u32 type; __u32 offset; __u32 size; }; /* BTF_KIND_DECL_TAG is followed by a single "struct btf_decl_tag" to describe * additional information related to the tag applied location. * If component_idx == -1, the tag is applied to a struct, union, * variable or function. Otherwise, it is applied to a struct/union * member or a func argument, and component_idx indicates which member * or argument (0 ... vlen-1). */ struct btf_decl_tag { __s32 component_idx; }; /* BTF_KIND_ENUM64 is followed by multiple "struct btf_enum64". * The exact number of btf_enum64 is stored in the vlen (of the * info in "struct btf_type"). */ struct btf_enum64 { __u32 name_off; __u32 val_lo32; __u32 val_hi32; }; #endif /* _UAPI__LINUX_BTF_H__ */ bpftrace-0.27.1/src/stdlib/include/linux/byteorder/000077500000000000000000000000001526721631600222315ustar00rootroot00000000000000bpftrace-0.27.1/src/stdlib/include/linux/byteorder/big_endian.h000066400000000000000000000074471526721631600244750ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_LINUX_BYTEORDER_BIG_ENDIAN_H #define _UAPI_LINUX_BYTEORDER_BIG_ENDIAN_H #ifndef __BIG_ENDIAN #define __BIG_ENDIAN 4321 #endif #ifndef __BIG_ENDIAN_BITFIELD #define __BIG_ENDIAN_BITFIELD #endif #include #include #include #define __constant_htonl(x) ((__force __be32)(__u32)(x)) #define __constant_ntohl(x) ((__force __u32)(__be32)(x)) #define __constant_htons(x) ((__force __be16)(__u16)(x)) #define __constant_ntohs(x) ((__force __u16)(__be16)(x)) #define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x))) #define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x)) #define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x))) #define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x)) #define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x))) #define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x)) #define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x)) #define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x)) #define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x)) #define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x)) #define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x)) #define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x)) #define __cpu_to_le64(x) ((__force __le64)__swab64((x))) #define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x)) #define __cpu_to_le32(x) ((__force __le32)__swab32((x))) #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x)) #define __cpu_to_le16(x) ((__force __le16)__swab16((x))) #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x)) #define __cpu_to_be64(x) ((__force __be64)(__u64)(x)) #define __be64_to_cpu(x) ((__force __u64)(__be64)(x)) #define __cpu_to_be32(x) ((__force __be32)(__u32)(x)) #define __be32_to_cpu(x) ((__force __u32)(__be32)(x)) #define __cpu_to_be16(x) ((__force __be16)(__u16)(x)) #define __be16_to_cpu(x) ((__force __u16)(__be16)(x)) static __always_inline __le64 __cpu_to_le64p(const __u64 *p) { return (__force __le64)__swab64p(p); } static __always_inline __u64 __le64_to_cpup(const __le64 *p) { return __swab64p((__u64 *)p); } static __always_inline __le32 __cpu_to_le32p(const __u32 *p) { return (__force __le32)__swab32p(p); } static __always_inline __u32 __le32_to_cpup(const __le32 *p) { return __swab32p((__u32 *)p); } static __always_inline __le16 __cpu_to_le16p(const __u16 *p) { return (__force __le16)__swab16p(p); } static __always_inline __u16 __le16_to_cpup(const __le16 *p) { return __swab16p((__u16 *)p); } static __always_inline __be64 __cpu_to_be64p(const __u64 *p) { return (__force __be64)*p; } static __always_inline __u64 __be64_to_cpup(const __be64 *p) { return (__force __u64)*p; } static __always_inline __be32 __cpu_to_be32p(const __u32 *p) { return (__force __be32)*p; } static __always_inline __u32 __be32_to_cpup(const __be32 *p) { return (__force __u32)*p; } static __always_inline __be16 __cpu_to_be16p(const __u16 *p) { return (__force __be16)*p; } static __always_inline __u16 __be16_to_cpup(const __be16 *p) { return (__force __u16)*p; } #define __cpu_to_le64s(x) __swab64s((x)) #define __le64_to_cpus(x) __swab64s((x)) #define __cpu_to_le32s(x) __swab32s((x)) #define __le32_to_cpus(x) __swab32s((x)) #define __cpu_to_le16s(x) __swab16s((x)) #define __le16_to_cpus(x) __swab16s((x)) #define __cpu_to_be64s(x) do { (void)(x); } while (0) #define __be64_to_cpus(x) do { (void)(x); } while (0) #define __cpu_to_be32s(x) do { (void)(x); } while (0) #define __be32_to_cpus(x) do { (void)(x); } while (0) #define __cpu_to_be16s(x) do { (void)(x); } while (0) #define __be16_to_cpus(x) do { (void)(x); } while (0) #endif /* _UAPI_LINUX_BYTEORDER_BIG_ENDIAN_H */ bpftrace-0.27.1/src/stdlib/include/linux/byteorder/little_endian.h000066400000000000000000000075541526721631600252300ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _UAPI_LINUX_BYTEORDER_LITTLE_ENDIAN_H #define _UAPI_LINUX_BYTEORDER_LITTLE_ENDIAN_H #ifndef __LITTLE_ENDIAN #define __LITTLE_ENDIAN 1234 #endif #ifndef __LITTLE_ENDIAN_BITFIELD #define __LITTLE_ENDIAN_BITFIELD #endif #include #include #include #define __constant_htonl(x) ((__force __be32)___constant_swab32((x))) #define __constant_ntohl(x) ___constant_swab32((__force __be32)(x)) #define __constant_htons(x) ((__force __be16)___constant_swab16((x))) #define __constant_ntohs(x) ___constant_swab16((__force __be16)(x)) #define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x)) #define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x)) #define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x)) #define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x)) #define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x)) #define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x)) #define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x))) #define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x)) #define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x))) #define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x)) #define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x))) #define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x)) #define __cpu_to_le64(x) ((__force __le64)(__u64)(x)) #define __le64_to_cpu(x) ((__force __u64)(__le64)(x)) #define __cpu_to_le32(x) ((__force __le32)(__u32)(x)) #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) #define __cpu_to_le16(x) ((__force __le16)(__u16)(x)) #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) #define __cpu_to_be64(x) ((__force __be64)__swab64((x))) #define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x)) #define __cpu_to_be32(x) ((__force __be32)__swab32((x))) #define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x)) #define __cpu_to_be16(x) ((__force __be16)__swab16((x))) #define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x)) static __always_inline __le64 __cpu_to_le64p(const __u64 *p) { return (__force __le64)*p; } static __always_inline __u64 __le64_to_cpup(const __le64 *p) { return (__force __u64)*p; } static __always_inline __le32 __cpu_to_le32p(const __u32 *p) { return (__force __le32)*p; } static __always_inline __u32 __le32_to_cpup(const __le32 *p) { return (__force __u32)*p; } static __always_inline __le16 __cpu_to_le16p(const __u16 *p) { return (__force __le16)*p; } static __always_inline __u16 __le16_to_cpup(const __le16 *p) { return (__force __u16)*p; } static __always_inline __be64 __cpu_to_be64p(const __u64 *p) { return (__force __be64)__swab64p(p); } static __always_inline __u64 __be64_to_cpup(const __be64 *p) { return __swab64p((__u64 *)p); } static __always_inline __be32 __cpu_to_be32p(const __u32 *p) { return (__force __be32)__swab32p(p); } static __always_inline __u32 __be32_to_cpup(const __be32 *p) { return __swab32p((__u32 *)p); } static __always_inline __be16 __cpu_to_be16p(const __u16 *p) { return (__force __be16)__swab16p(p); } static __always_inline __u16 __be16_to_cpup(const __be16 *p) { return __swab16p((__u16 *)p); } #define __cpu_to_le64s(x) do { (void)(x); } while (0) #define __le64_to_cpus(x) do { (void)(x); } while (0) #define __cpu_to_le32s(x) do { (void)(x); } while (0) #define __le32_to_cpus(x) do { (void)(x); } while (0) #define __cpu_to_le16s(x) do { (void)(x); } while (0) #define __le16_to_cpus(x) do { (void)(x); } while (0) #define __cpu_to_be64s(x) __swab64s((x)) #define __be64_to_cpus(x) __swab64s((x)) #define __cpu_to_be32s(x) __swab32s((x)) #define __be32_to_cpus(x) __swab32s((x)) #define __cpu_to_be16s(x) __swab16s((x)) #define __be16_to_cpus(x) __swab16s((x)) #endif /* _UAPI_LINUX_BYTEORDER_LITTLE_ENDIAN_H */ bpftrace-0.27.1/src/stdlib/include/linux/compiler-clang.h000066400000000000000000000106011526721631600232750ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __LINUX_COMPILER_TYPES_H #error "Please do not include directly, include instead." #endif /* Compiler specific definitions for Clang compiler */ /* * Clang prior to 17 is being silly and considers many __cleanup() variables * as unused (because they are, their sole purpose is to go out of scope). * * https://github.com/llvm/llvm-project/commit/877210faa447f4cc7db87812f8ed80e398fedd61 */ #undef __cleanup #define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func))) /* all clang versions usable with the kernel support KASAN ABI version 5 */ #define KASAN_ABI_VERSION 5 /* * Note: Checking __has_feature(*_sanitizer) is only true if the feature is * enabled. Therefore it is not required to additionally check defined(CONFIG_*) * to avoid adding redundant attributes in other configurations. */ #if __has_feature(address_sanitizer) || __has_feature(hwaddress_sanitizer) /* Emulate GCC's __SANITIZE_ADDRESS__ flag */ #define __SANITIZE_ADDRESS__ #define __no_sanitize_address \ __attribute__((no_sanitize("address", "hwaddress"))) #else #define __no_sanitize_address #endif #if __has_feature(thread_sanitizer) /* emulate gcc's __SANITIZE_THREAD__ flag */ #define __SANITIZE_THREAD__ #define __no_sanitize_thread \ __attribute__((no_sanitize("thread"))) #else #define __no_sanitize_thread #endif #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) #define __HAVE_BUILTIN_BSWAP32__ #define __HAVE_BUILTIN_BSWAP64__ #define __HAVE_BUILTIN_BSWAP16__ #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ #if __has_feature(undefined_behavior_sanitizer) /* GCC does not have __SANITIZE_UNDEFINED__ */ #define __no_sanitize_undefined \ __attribute__((no_sanitize("undefined"))) #else #define __no_sanitize_undefined #endif #if __has_feature(memory_sanitizer) #define __SANITIZE_MEMORY__ /* * Unlike other sanitizers, KMSAN still inserts code into functions marked with * no_sanitize("kernel-memory"). Using disable_sanitizer_instrumentation * provides the behavior consistent with other __no_sanitize_ attributes, * guaranteeing that __no_sanitize_memory functions remain uninstrumented. */ #define __no_sanitize_memory __disable_sanitizer_instrumentation /* * The __no_kmsan_checks attribute ensures that a function does not produce * false positive reports by: * - initializing all local variables and memory stores in this function; * - skipping all shadow checks; * - passing initialized arguments to this function's callees. */ #define __no_kmsan_checks __attribute__((no_sanitize("kernel-memory"))) #else #define __no_sanitize_memory #define __no_kmsan_checks #endif /* * Support for __has_feature(coverage_sanitizer) was added in Clang 13 together * with no_sanitize("coverage"). Prior versions of Clang support coverage * instrumentation, but cannot be queried for support by the preprocessor. */ #if __has_feature(coverage_sanitizer) #define __no_sanitize_coverage __attribute__((no_sanitize("coverage"))) #else #define __no_sanitize_coverage #endif #if __has_feature(shadow_call_stack) # define __noscs __attribute__((__no_sanitize__("shadow-call-stack"))) #endif #if __has_feature(kcfi) /* Disable CFI checking inside a function. */ #define __nocfi __attribute__((__no_sanitize__("kcfi"))) #endif /* * Turn individual warnings and errors on and off locally, depending * on version. */ #define __diag_clang(version, severity, s) \ __diag_clang_ ## version(__diag_clang_ ## severity s) /* Severity used in pragma directives */ #define __diag_clang_ignore ignored #define __diag_clang_warn warning #define __diag_clang_error error #define __diag_str1(s) #s #define __diag_str(s) __diag_str1(s) #define __diag(s) _Pragma(__diag_str(clang diagnostic s)) #define __diag_clang_13(s) __diag(s) #define __diag_ignore_all(option, comment) \ __diag_clang(13, ignore, option) /* * clang has horrible behavior with "g" or "rm" constraints for asm * inputs, turning them into something worse than "m". Avoid using * constraints with multiple possible uses (but "ir" seems to be ok): * * https://github.com/llvm/llvm-project/issues/20571 */ #define ASM_INPUT_G "ir" #define ASM_INPUT_RM "r" /* * Declare compiler support for __typeof_unqual__() operator. * * Bindgen uses LLVM even if our C compiler is GCC, so we cannot * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL. */ #define CC_HAS_TYPEOF_UNQUAL (__clang_major__ >= 19) bpftrace-0.27.1/src/stdlib/include/linux/compiler.h000066400000000000000000000330241526721631600222170ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __LINUX_COMPILER_H #define __LINUX_COMPILER_H #include #ifndef __ASSEMBLY__ #ifdef __KERNEL__ /* * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code * to disable branch tracing on a per file basis. */ void ftrace_likely_update(struct ftrace_likely_data *f, int val, int expect, int is_constant); #if defined(CONFIG_TRACE_BRANCH_PROFILING) \ && !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__) #define likely_notrace(x) __builtin_expect(!!(x), 1) #define unlikely_notrace(x) __builtin_expect(!!(x), 0) #define __branch_check__(x, expect, is_constant) ({ \ long ______r; \ static struct ftrace_likely_data \ __aligned(4) \ __section("_ftrace_annotated_branch") \ ______f = { \ .data.func = __func__, \ .data.file = __FILE__, \ .data.line = __LINE__, \ }; \ ______r = __builtin_expect(!!(x), expect); \ ftrace_likely_update(&______f, ______r, \ expect, is_constant); \ ______r; \ }) /* * Using __builtin_constant_p(x) to ignore cases where the return * value is always the same. This idea is taken from a similar patch * written by Daniel Walker. */ # ifndef likely # define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x))) # endif # ifndef unlikely # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) # endif #ifdef CONFIG_PROFILE_ALL_BRANCHES /* * "Define 'is'", Bill Clinton * "Define 'if'", Steven Rostedt */ #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) #define __trace_if_value(cond) ({ \ static struct ftrace_branch_data \ __aligned(4) \ __section("_ftrace_branch") \ __if_trace = { \ .func = __func__, \ .file = __FILE__, \ .line = __LINE__, \ }; \ (cond) ? \ (__if_trace.miss_hit[1]++,1) : \ (__if_trace.miss_hit[0]++,0); \ }) #endif /* CONFIG_PROFILE_ALL_BRANCHES */ #else # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) # define likely_notrace(x) likely(x) # define unlikely_notrace(x) unlikely(x) #endif /* Optimization barrier */ #ifndef barrier /* The "volatile" is due to gcc bugs */ # define barrier() __asm__ __volatile__("": : :"memory") #endif #ifndef barrier_data /* * This version is i.e. to prevent dead stores elimination on @ptr * where gcc and llvm may behave differently when otherwise using * normal barrier(): while gcc behavior gets along with a normal * barrier(), llvm needs an explicit input variable to be assumed * clobbered. The issue is as follows: while the inline asm might * access any memory it wants, the compiler could have fit all of * @ptr into memory registers instead, and since @ptr never escaped * from that, it proved that the inline asm wasn't touching any of * it. This version works well with both compilers, i.e. we're telling * the compiler that the inline asm absolutely may see the contents * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495 */ # define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory") #endif /* workaround for GCC PR82365 if needed */ #ifndef barrier_before_unreachable # define barrier_before_unreachable() do { } while (0) #endif /* Unreachable code */ #ifdef CONFIG_OBJTOOL /* Annotate a C jump table to allow objtool to follow the code flow */ #define __annotate_jump_table __section(".data.rel.ro.c_jump_table") #else /* !CONFIG_OBJTOOL */ #define __annotate_jump_table #endif /* CONFIG_OBJTOOL */ /* * Mark a position in code as unreachable. This can be used to * suppress control flow warnings after asm blocks that transfer * control elsewhere. */ #define unreachable() do { \ barrier_before_unreachable(); \ __builtin_unreachable(); \ } while (0) /* * KENTRY - kernel entry point * This can be used to annotate symbols (functions or data) that are used * without their linker symbol being referenced explicitly. For example, * interrupt vector handlers, or functions in the kernel image that are found * programatically. * * Not required for symbols exported with EXPORT_SYMBOL, or initcalls. Those * are handled in their own way (with KEEP() in linker scripts). * * KENTRY can be avoided if the symbols in question are marked as KEEP() in the * linker script. For example an architecture could KEEP() its entire * boot/exception vector code rather than annotate each function and data. */ #ifndef KENTRY # define KENTRY(sym) \ extern typeof(sym) sym; \ static const unsigned long __kentry_##sym \ __used \ __attribute__((__section__("___kentry+" #sym))) \ = (unsigned long)&sym; #endif #ifndef RELOC_HIDE # define RELOC_HIDE(ptr, off) \ ({ unsigned long __ptr; \ __ptr = (unsigned long) (ptr); \ (typeof(ptr)) (__ptr + (off)); }) #endif #define absolute_pointer(val) RELOC_HIDE((void *)(val), 0) #ifndef OPTIMIZER_HIDE_VAR /* Make the optimizer believe the variable can be manipulated arbitrarily. */ #define OPTIMIZER_HIDE_VAR(var) \ __asm__ ("" : "=r" (var) : "0" (var)) #endif #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) /** * data_race - mark an expression as containing intentional data races * * This data_race() macro is useful for situations in which data races * should be forgiven. One example is diagnostic code that accesses * shared variables but is not a part of the core synchronization design. * For example, if accesses to a given variable are protected by a lock, * except for diagnostic code, then the accesses under the lock should * be plain C-language accesses and those in the diagnostic code should * use data_race(). This way, KCSAN will complain if buggy lockless * accesses to that variable are introduced, even if the buggy accesses * are protected by READ_ONCE() or WRITE_ONCE(). * * This macro *does not* affect normal code generation, but is a hint * to tooling that data races here are to be ignored. If the access must * be atomic *and* KCSAN should ignore the access, use both data_race() * and READ_ONCE(), for example, data_race(READ_ONCE(x)). */ #define data_race(expr) \ ({ \ __kcsan_disable_current(); \ __auto_type __v = (expr); \ __kcsan_enable_current(); \ __v; \ }) #ifdef __CHECKER__ #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) (0) #else /* __CHECKER__ */ #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);})) #endif /* __CHECKER__ */ /* &a[0] degrades to a pointer: a different type from an array */ #define __is_array(a) (!__same_type((a), &(a)[0])) #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \ "must be array") #define __is_byte_array(a) (__is_array(a) && sizeof((a)[0]) == 1) #define __must_be_byte_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_byte_array(a), \ "must be byte array") /* * If the "nonstring" attribute isn't available, we have to return true * so the __must_*() checks pass when "nonstring" isn't supported. */ #if __has_attribute(__nonstring__) && defined(__annotated) #define __is_cstr(a) (!__annotated(a, nonstring)) #define __is_noncstr(a) (__annotated(a, nonstring)) #else #define __is_cstr(a) (true) #define __is_noncstr(a) (true) #endif /* Require C Strings (i.e. NUL-terminated) lack the "nonstring" attribute. */ #define __must_be_cstr(p) \ __BUILD_BUG_ON_ZERO_MSG(!__is_cstr(p), \ "must be C-string (NUL-terminated)") #define __must_be_noncstr(p) \ __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ "must be non-C-string (not NUL-terminated)") /* * Use __typeof_unqual__() when available. * * XXX: Remove test for __CHECKER__ once * sparse learns about __typeof_unqual__(). */ #if CC_HAS_TYPEOF_UNQUAL && !defined(__CHECKER__) # define USE_TYPEOF_UNQUAL 1 #endif /* * Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof * operator when available, to return an unqualified type of the exp. */ #if defined(USE_TYPEOF_UNQUAL) # define TYPEOF_UNQUAL(exp) __typeof_unqual__(exp) #else # define TYPEOF_UNQUAL(exp) __typeof__(exp) #endif #endif /* __KERNEL__ */ #if defined(CONFIG_CFI_CLANG) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO) /* * Force a reference to the external symbol so the compiler generates * __kcfi_typid. */ #define KCFI_REFERENCE(sym) __ADDRESSABLE(sym) #else #define KCFI_REFERENCE(sym) #endif /** * offset_to_ptr - convert a relative memory offset to an absolute pointer * @off: the address of the 32-bit offset value */ static inline void *offset_to_ptr(const int *off) { return (void *)((unsigned long)off + *off); } #endif /* __ASSEMBLY__ */ #ifdef CONFIG_64BIT #define ARCH_SEL(a,b) a #else #define ARCH_SEL(a,b) b #endif /* * Force the compiler to emit 'sym' as a symbol, so that we can reference * it from inline assembler. Necessary in case 'sym' could be inlined * otherwise, or eliminated entirely due to lack of references that are * visible to the compiler. */ #define ___ADDRESSABLE(sym, __attrs) \ static void * __used __attrs \ __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym; #define __ADDRESSABLE(sym) \ ___ADDRESSABLE(sym, __section(".discard.addressable")) #define __ADDRESSABLE_ASM(sym) \ .pushsection .discard.addressable,"aw"; \ .align ARCH_SEL(8,4); \ ARCH_SEL(.quad, .long) __stringify(sym); \ .popsection; #define __ADDRESSABLE_ASM_STR(sym) __stringify(__ADDRESSABLE_ASM(sym)) /* * This returns a constant expression while determining if an argument is * a constant expression, most importantly without evaluating the argument. * Glory to Martin Uecker * * Details: * - sizeof() return an integer constant expression, and does not evaluate * the value of its operand; it only examines the type of its operand. * - The results of comparing two integer constant expressions is also * an integer constant expression. * - The first literal "8" isn't important. It could be any literal value. * - The second literal "8" is to avoid warnings about unaligned pointers; * this could otherwise just be "1". * - (long)(x) is used to avoid warnings about 64-bit types on 32-bit * architectures. * - The C Standard defines "null pointer constant", "(void *)0", as * distinct from other void pointers. * - If (x) is an integer constant expression, then the "* 0l" resolves * it into an integer constant expression of value 0. Since it is cast to * "void *", this makes the second operand a null pointer constant. * - If (x) is not an integer constant expression, then the second operand * resolves to a void pointer (but not a null pointer constant: the value * is not an integer constant 0). * - The conditional operator's third operand, "(int *)8", is an object * pointer (to type "int"). * - The behavior (including the return type) of the conditional operator * ("operand1 ? operand2 : operand3") depends on the kind of expressions * given for the second and third operands. This is the central mechanism * of the macro: * - When one operand is a null pointer constant (i.e. when x is an integer * constant expression) and the other is an object pointer (i.e. our * third operand), the conditional operator returns the type of the * object pointer operand (i.e. "int *"). Here, within the sizeof(), we * would then get: * sizeof(*((int *)(...)) == sizeof(int) == 4 * - When one operand is a void pointer (i.e. when x is not an integer * constant expression) and the other is an object pointer (i.e. our * third operand), the conditional operator returns a "void *" type. * Here, within the sizeof(), we would then get: * sizeof(*((void *)(...)) == sizeof(void) == 1 * - The equality comparison to "sizeof(int)" therefore depends on (x): * sizeof(int) == sizeof(int) (x) was a constant expression * sizeof(int) != sizeof(void) (x) was not a constant expression */ #define __is_constexpr(x) \ (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) /* * Whether 'type' is a signed type or an unsigned type. Supports scalar types, * bool and also pointer types. */ #define is_signed_type(type) (((type)(-1)) < (__force type)1) #define is_unsigned_type(type) (!is_signed_type(type)) /* * Useful shorthand for "is this condition known at compile-time?" * * Note that the condition may involve non-constant values, * but the compiler may know enough about the details of the * values to determine that the condition is statically true. */ #define statically_true(x) (__builtin_constant_p(x) && (x)) /* * Similar to statically_true() but produces a constant expression * * To be used in conjunction with macros, such as BUILD_BUG_ON_ZERO(), * which require their input to be a constant expression and for which * statically_true() would otherwise fail. * * This is a trade-off: const_true() requires all its operands to be * compile time constants. Else, it would always returns false even on * the most trivial cases like: * * true || non_const_var * * On the opposite, statically_true() is able to fold more complex * tautologies and will return true on expressions such as: * * !(non_const_var * 8 % 4) * * For the general case, statically_true() is better. */ #define const_true(x) __builtin_choose_expr(__is_constexpr(x), x, false) /* * This is needed in functions which generate the stack canary, see * arch/x86/kernel/smpboot.c::start_secondary() for an example. */ #define prevent_tail_call_optimization() mb() #include #endif /* __LINUX_COMPILER_H */ bpftrace-0.27.1/src/stdlib/include/linux/compiler_attributes.h000066400000000000000000000376471526721631600245040ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __LINUX_COMPILER_ATTRIBUTES_H #define __LINUX_COMPILER_ATTRIBUTES_H /* * The attributes in this file are unconditionally defined and they directly * map to compiler attribute(s), unless one of the compilers does not support * the attribute. In that case, __has_attribute is used to check for support * and the reason is stated in its comment ("Optional: ..."). * * Any other "attributes" (i.e. those that depend on a configuration option, * on a compiler, on an architecture, on plugins, on other attributes...) * should be defined elsewhere (e.g. compiler_types.h or compiler-*.h). * The intention is to keep this file as simple as possible, as well as * compiler- and version-agnostic (e.g. avoiding GCC_VERSION checks). * * This file is meant to be sorted (by actual attribute name, * not by #define identifier). Use the __attribute__((__name__)) syntax * (i.e. with underscores) to avoid future collisions with other macros. * Provide links to the documentation of each supported compiler, if it exists. */ /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute */ #define __alias(symbol) __attribute__((__alias__(#symbol))) /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-aligned-variable-attribute */ #define __aligned(x) __attribute__((__aligned__(x))) #define __aligned_largest __attribute__((__aligned__)) /* * Note: do not use this directly. Instead, use __alloc_size() since it is conditionally * available and includes other attributes. For GCC < 9.1, __alloc_size__ gets undefined * in compiler-gcc.h, due to misbehaviors. * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#alloc-size */ #define __alloc_size__(x, ...) __attribute__((__alloc_size__(x, ## __VA_ARGS__))) /* * Note: users of __always_inline currently do not write "inline" themselves, * which seems to be required by gcc to apply the attribute according * to its docs (and also "warning: always_inline function might not be * inlinable [-Wattributes]" is emitted). * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute * clang: mentioned */ #define __always_inline inline __attribute__((__always_inline__)) /* * The second argument is optional (default 0), so we use a variadic macro * to make the shorthand. * * Beware: Do not apply this to functions which may return * ERR_PTRs. Also, it is probably unwise to apply it to functions * returning extra information in the low bits (but in that case the * compiler should see some alignment anyway, when the return value is * massaged by 'flags = ptr & 3; ptr &= ~3;'). * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-assume_005faligned-function-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#assume-aligned */ #define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__))) /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-cleanup-variable-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#cleanup */ #define __cleanup(func) __attribute__((__cleanup__(func))) /* * Note the long name. * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute */ #define __attribute_const__ __attribute__((__const__)) /* * Optional: only supported since gcc >= 9 * Optional: not supported by clang * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-copy-function-attribute */ #if __has_attribute(__copy__) # define __copy(symbol) __attribute__((__copy__(symbol))) #else # define __copy(symbol) #endif /* * Optional: not supported by gcc * Optional: only supported since clang >= 14.0 * * clang: https://clang.llvm.org/docs/AttributeReference.html#diagnose_as_builtin */ #if __has_attribute(__diagnose_as_builtin__) # define __diagnose_as(builtin...) __attribute__((__diagnose_as_builtin__(builtin))) #else # define __diagnose_as(builtin...) #endif /* * Don't. Just don't. See commit 771c035372a0 ("deprecate the '__deprecated' * attribute warnings entirely and for good") for more information. * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-deprecated-type-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-deprecated-variable-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html#index-deprecated-enumerator-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#deprecated */ #define __deprecated /* * Optional: not supported by clang * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-designated_005finit-type-attribute */ #if __has_attribute(__designated_init__) # define __designated_init __attribute__((__designated_init__)) #else # define __designated_init #endif /* * Optional: only supported since clang >= 14.0 * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute */ #if __has_attribute(__error__) # define __compiletime_error(msg) __attribute__((__error__(msg))) #else # define __compiletime_error(msg) #endif /* * Optional: not supported by clang * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-externally_005fvisible-function-attribute */ #if __has_attribute(__externally_visible__) # define __visible __attribute__((__externally_visible__)) #else # define __visible #endif /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-format-function-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#format */ #define __printf(a, b) __attribute__((__format__(printf, a, b))) #define __scanf(a, b) __attribute__((__format__(scanf, a, b))) /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-gnu_005finline-function-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#gnu-inline */ #define __gnu_inline __attribute__((__gnu_inline__)) /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#malloc */ #define __malloc __attribute__((__malloc__)) /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-mode-type-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-mode-variable-attribute */ #define __mode(x) __attribute__((__mode__(x))) /* * Optional: only supported since gcc >= 7 * * gcc: https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#index-no_005fcaller_005fsaved_005fregisters-function-attribute_002c-x86 * clang: https://clang.llvm.org/docs/AttributeReference.html#no-caller-saved-registers */ #if __has_attribute(__no_caller_saved_registers__) # define __no_caller_saved_registers __attribute__((__no_caller_saved_registers__)) #else # define __no_caller_saved_registers #endif /* * Optional: not supported by clang * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noclone-function-attribute */ #if __has_attribute(__noclone__) # define __noclone __attribute__((__noclone__)) #else # define __noclone #endif /* * Add the pseudo keyword 'fallthrough' so case statement blocks * must end with any of these keywords: * break; * fallthrough; * continue; * goto