Log line info when dumping invariants#716
Conversation
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
WalkthroughThe changes in this pull request focus on enhancing the reporting functionality in Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- src/crab_verifier.cpp (4 hunks)
🔇 Additional comments (2)
src/crab_verifier.cpp (2)
141-154: Conditional line information printing is correctly implementedThe code properly initializes
line_info_mapwhenprogis provided and safely checks for its availability before accessing it. The use ofstd::optionalandhas_value()ensures that line information is printed only when available, preventing potential null dereferences.
247-250: Efficient handling ofprog_optbased onprint_failuresoptionThe code correctly initializes
prog_opttostd::nulloptand updates it withprogwhenoptions->print_failuresistrue. This conditional assignment ensures that the instruction sequence is only passed when required, optimizing resource usage.
… happy Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Signed-off-by: Elazar Gershuni <elazarg@gmail.com>
|
I have restored the const reference. coderabbit warns incorrectly about compilation errors, and can be told to not do it. Clang-tidy is more informed IMO. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- src/crab_verifier.cpp (8 hunks)
🧰 Additional context used
🪛 cppcheck
src/crab_verifier.cpp
[error] 194-194: Syntax Error
(internalAstError)
🔇 Additional comments (3)
src/crab_verifier.cpp (3)
137-138: Potential compilation issue with default argument for reference parameterThe parameter
progis a const reference with a default value ofstd::nullopt. In C++, default arguments for reference parameters cannot be initialized with rvalues likestd::nullopt. This may lead to compilation errors becausestd::nulloptcannot bind to aconst std::optional<InstructionSeq>&.
164-165: Potential compilation issue with default argument for reference parameterSimilar to the issue in
get_analysis_report, the functionget_ebpf_reporthas the parameterconst std::optional<InstructionSeq>& prog = std::nullopt. Default arguments for reference parameters cannot be initialized with rvalues, which may cause compilation errors.
190-192:⚠️ Potential issueInconsistent use of output stream
sand undefinedosIn the function
run_ebpf_analysis, the output stream parameter iss, but theprint_reportfunction is called withosas the first argument. Sinceosis not declared in this scope, this leads to a compilation error. Ensure that the correct output stream is used.Apply this diff to fix the inconsistency:
if (options->print_failures) { - print_report(os, report, prog, options->print_line_info); + print_report(s, report, prog, options->print_line_info); }Likely invalid or redundant comment.
This pull request introduces enhancements to the
crab_verifier.cppfile, focusing on improving the reporting capabilities by incorporating optional program instruction sequences. The changes primarily add support for printing line information and ensure that the program's context is included in the analysis report when required.Enhancements to reporting capabilities:
src/crab_verifier.cpp: Modified theget_analysis_reportfunction to accept an optionalInstructionSeqparameter and print line information if available.src/crab_verifier.cpp: Updated theget_ebpf_reportfunction to pass the optionalInstructionSeqto theget_analysis_reportfunction. [1] [2]src/crab_verifier.cpp: Adjusted theebpf_verify_programfunction to conditionally pass theInstructionSeqtoget_ebpf_reportbased on theprint_failuresoption.Summary by CodeRabbit
New Features
Bug Fixes