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

feat: Add break <line-number> command #5021

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smanilov
Copy link

This makes it much easier to find the correct place to add a break point while debugging a program.

For example, now one can do the following:

$ cd test_programs/execution_success/merkle_insert/
$ nargo debug
[merkle_insert] Starting debugger
At opcode 0: BRILLIG CALL func 0: PREDICATE = %EXPR [ 1 ]%
inputs: [Single(Expression { mul_terms: [], linear_combina [...]
> next
At opcode 0.17: Const { destination: MemoryAddress(21), bi [...]
At [...]/test_programs/execution_success/merkle_insert/src/main.nr:12:3
  7    ...
  8        new_root: pub Field,
  9        leaf: Field,
 10        index: Field,
 11        mimc_input: [Field; 4]
 12 -> ) {
 13        assert(old_root == std::merkle::compute_merkle_ [...]
 14
 15        let calculated_root = std::merkle::compute_merk [...]
 16        assert(new_root == calculated_root);
 17
 18        let h = mimc::mimc_bn254(mimc_input);
 19        // Regression test for PR #891
 20        std::println(h);
 21        assert(h == 18226366069841799622585958305961373 [...]
 22    }
> break 18     # ** <- this is the new command **
Added breakpoint at opcode 0.1274
> continue
(Continuing execution...)
Stopped at breakpoint in opcode 0.1274
At opcode 0.1274: Const { destination: MemoryAddress(36),  [...]
At /home/stan/code/repos/noir/test_programs/execution_succ [...]
 13    ...
 14
 15        let calculated_root = std::merkle::compute_merk [...]
 16        assert(new_root == calculated_root);
 17
 18 ->     let h = mimc::mimc_bn254(mimc_input);
 19        // Regression test for PR #891
 20        std::println(h);
 21        assert(h == 18226366069841799622585958305961373 [...]
 22    }
>

Description

This PR is in the spirit of "submit your feature request as a PR".

Problem*

At the moment, one can only do break <opcode> and not break <line-number> in nargo debug.

Summary*

This PR adds the necessary functionality and implements the break <line-number> command.

Additional Context

I am exploring the current capabilities of nargo debug and found it would be very useful to add this command.

Documentation*

The new command automatically appears in the help command of nargo debug.

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link
Contributor

Thank you for your contribution to the Noir language.

Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch.

Thanks for your understanding.

This makes it much easier to find the correct place to add a break point
while debugging a program.

For example, now one can do the following:

```
$ cd test_programs/execution_success/merkle_insert/
$ nargo debug
[merkle_insert] Starting debugger
At opcode 0: BRILLIG CALL func 0: PREDICATE = %EXPR [ 1 ]%
inputs: [Single(Expression { mul_terms: [], linear_combina [...]
> next
At opcode 0.17: Const { destination: MemoryAddress(21), bi [...]
At [...]/test_programs/execution_success/merkle_insert/src/main.nr:12:3
  7    ...
  8        new_root: pub Field,
  9        leaf: Field,
 10        index: Field,
 11        mimc_input: [Field; 4]
 12 -> ) {
 13        assert(old_root == std::merkle::compute_merkle_ [...]
 14
 15        let calculated_root = std::merkle::compute_merk [...]
 16        assert(new_root == calculated_root);
 17
 18        let h = mimc::mimc_bn254(mimc_input);
 19        // Regression test for PR noir-lang#891
 20        std::println(h);
 21        assert(h == 18226366069841799622585958305961373 [...]
 22    }
> break 18
Added breakpoint at opcode 0.1274
> continue
(Continuing execution...)
Stopped at breakpoint in opcode 0.1274
At opcode 0.1274: Const { destination: MemoryAddress(36),  [...]
At /home/stan/code/repos/noir/test_programs/execution_succ [...]
 13    ...
 14
 15        let calculated_root = std::merkle::compute_merk [...]
 16        assert(new_root == calculated_root);
 17
 18 ->     let h = mimc::mimc_bn254(mimc_input);
 19        // Regression test for PR noir-lang#891
 20        std::println(h);
 21        assert(h == 18226366069841799622585958305961373 [...]
 22    }
>
```
@smanilov smanilov changed the title Add break <line-number> command feat: Add break <line-number> command May 13, 2024
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.

None yet

1 participant