diff --git a/sandboxed_api/sandbox2/BUILD.bazel b/sandboxed_api/sandbox2/BUILD.bazel index aa40229..1dbaad8 100644 --- a/sandboxed_api/sandbox2/BUILD.bazel +++ b/sandboxed_api/sandbox2/BUILD.bazel @@ -29,7 +29,11 @@ cc_library( srcs = ["bpfdisassembler.cc"], hdrs = ["bpfdisassembler.h"], copts = sapi_platform_copts(), - deps = ["@com_google_absl//absl/strings"], + visibility = ["//visibility:public"], + deps = [ + "@com_google_absl//absl/strings", + "@com_google_absl//absl/types:span", + ], ) cc_library( diff --git a/sandboxed_api/sandbox2/CMakeLists.txt b/sandboxed_api/sandbox2/CMakeLists.txt index 14c9c80..918eda0 100644 --- a/sandboxed_api/sandbox2/CMakeLists.txt +++ b/sandboxed_api/sandbox2/CMakeLists.txt @@ -24,6 +24,7 @@ add_library(sandbox2_bpfdisassembler ${SAPI_LIB_TYPE} ) add_library(sandbox2::bpfdisassembler ALIAS sandbox2_bpfdisassembler) target_link_libraries(sandbox2_bpfdisassembler PRIVATE + absl::span absl::strings sapi::base ) diff --git a/sandboxed_api/sandbox2/bpfdisassembler.cc b/sandboxed_api/sandbox2/bpfdisassembler.cc index 0b87d1f..f533a3e 100644 --- a/sandboxed_api/sandbox2/bpfdisassembler.cc +++ b/sandboxed_api/sandbox2/bpfdisassembler.cc @@ -234,9 +234,9 @@ std::string DecodeInstruction(const sock_filter& inst, int pc) { } } -std::string Disasm(const std::vector& prog) { +std::string Disasm(absl::Span prog) { std::string rv; - for (size_t i = 0, len = prog.size(); i < len; ++i) { + for (size_t i = 0; i < prog.size(); ++i) { absl::StrAppend(&rv, absl::Dec(i, absl::kZeroPad3), ": ", DecodeInstruction(prog[i], i), "\n"); } diff --git a/sandboxed_api/sandbox2/bpfdisassembler.h b/sandboxed_api/sandbox2/bpfdisassembler.h index a7bcad9..0868dd3 100644 --- a/sandboxed_api/sandbox2/bpfdisassembler.h +++ b/sandboxed_api/sandbox2/bpfdisassembler.h @@ -18,6 +18,8 @@ #include #include +#include "absl/types/span.h" + struct sock_filter; namespace sandbox2 { @@ -28,7 +30,7 @@ std::string DecodeInstruction(const sock_filter& inst, int pc); // Disassembles a BPF program. // Returns a human-readable textual represenation. -std::string Disasm(const std::vector& prog); +std::string Disasm(absl::Span prog); } // namespace bpf } // namespace sandbox2