Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix P4Dummy Backend Failure with External Input Program #2

Merged
merged 2 commits into from
Mar 16, 2024

Conversation

snapdgn
Copy link
Contributor

@snapdgn snapdgn commented Mar 16, 2024

Fixes #1

Let me know if this is ok.

@fruffy
Copy link
Owner

fruffy commented Mar 16, 2024

How are you invoking the program? This should not be necessary.

@fruffy
Copy link
Owner

fruffy commented Mar 16, 2024

Also what is the failure you are seeing?

@snapdgn
Copy link
Contributor Author

snapdgn commented Mar 16, 2024

How are you invoking the program? This should not be necessary.

I'm invoking it as ./build/p4dummy example.p4, relative to the p4c dir. This doesn't generate any error, but exits by printing the usage.
Apologies if i've missed something obvious here(?)

@fruffy
Copy link
Owner

fruffy commented Mar 16, 2024

Thanks for finding this issue:
This patch should fix things, please test it and see whether it fixes your issue:

diff --git a/dummy.cpp b/dummy.cpp
index 722875a..4507902 100644
--- a/dummy.cpp
+++ b/dummy.cpp
@@ -132,18 +133,16 @@ V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main;)";
 int main(int argc, char *const argv[]) {
     AutoCompileContext autoP4DummyContext(new P4Dummy::P4DummyContext);
     auto &options = P4Dummy::P4DummyContext::get().options();
-    options.langVersion = CompilerOptions::FrontendVersion::P4_16;
 
     if (options.process(argc, argv) == nullptr) {
         return EXIT_FAILURE;
     }
 
-    const IR::P4Program *program = nullptr;
-    if (options.file == nullptr && !options.useFixed) {
-        options.usage();
-        return EXIT_FAILURE;
+    if (!options.useFixed) {
+        options.setInputFile();
     }
 
+    const IR::P4Program *program = nullptr;
     if (options.useFixed) {
         program = P4Dummy::parseDummyP4(options);
     } else {

@snapdgn
Copy link
Contributor Author

snapdgn commented Mar 16, 2024

see whether it fixes your issue

Thanks, this works.

I've updated the PR with the new patch.

Copy link
Owner

@fruffy fruffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fruffy fruffy merged commit 4eccbfa into fruffy:master Mar 16, 2024
1 check passed
@snapdgn snapdgn deleted the bugfix branch March 17, 2024 04:24
fruffy pushed a commit that referenced this pull request Mar 17, 2024
#3)

After PR #2 the else condition code becomes redundant this PR fixes
this. Also the comment is misleading in my view hence fixed that also.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

p4dummy fails with an externally supplied input program.
2 participants