Skip to content

Conversation

@jcpetruzza
Copy link
Contributor

The erl_debugger module currently exposes a BIF to toggle line-breakpoints, but there was no mechanism to query the status. We add BIFs that, for a give module or for a given MFA, will return all lines that allow breakpoints being set and what their status is.

The main motivation is to allow the edb debugger to implement stepping-over and stepping-out without requiring the module to be available on disk, and compiled with debug_info.

In several BIFs we were constructing tuples manually,
it is more clear with TUPLEX macros
These make it easier to use them in BIFs, especially those
that need to build maps of arbitrary sizes
@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2025

CT Test Results

    4 files    201 suites   1h 52m 48s ⏱️
3 118 tests 2 811 ✅ 306 💤 1 ❌
4 098 runs  3 712 ✅ 385 💤 1 ❌

For more details on these failures, see this check.

Results for commit e01435e.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@jhogberg jhogberg added the team:VM Assigned to OTP team VM label May 5, 2025
@bjorng bjorng force-pushed the list_line_breakpoints branch from 8e36e0c to 35fb56a Compare May 7, 2025 15:10
@bjorng bjorng self-assigned this May 7, 2025
@bjorng bjorng added the testing currently being tested, tag is used by OTP internal CI label May 7, 2025
@bjorng
Copy link
Contributor

bjorng commented May 7, 2025

Thanks for the pull request. I have cleaned up indentation in the last commit and force-pushed and the PR to our daily builds.

Comment on lines 603 to 605
default:
ASSERT(0);
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, all enum values are handled already and the compiler should know that:

Suggested change
default:
ASSERT(0);
continue;

Copy link
Contributor Author

@jcpetruzza jcpetruzza May 8, 2025

Choose a reason for hiding this comment

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

the compiler should know that

True but it currently emits a warning, not an error, if I comment out the default and an additional case. At least for me, I get lots of warnings when building the VM (mostly -Warray-bounds, I think because foo[1] is used throughout instead of foo[] for "flexible arrays"), so easy to miss. Maybe -Wswitch should be treated as error?

*hp++ = stack_frame_fun_info(c_p, catch_addr, NULL, 0);
hp = HAlloc(c_p, tup2_sz);
result = TUPLE2(hp,
ERTS_MAKE_AM("catch"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: 'catch' is already defined in the standard library, we may as well add it to atom.names :-)

} else {
*hp++ = ERTS_MAKE_AM("too_large");
*hp++ = make_small(val_size);
result = TUPLE2(hp, ERTS_MAKE_AM("too_large"), make_small(val_size));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: maybe am_system_limit? Users are already familiar with that terminology.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Notice that this is not a system limit: the limit is specified by the caller. The motivation is to give the caller some control on whether they will hit their heap limit by copying a gigantic term while peeking, or avoid the serialization overhead, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about size then -- you either return a {value, Value} or a {size, Size}?

Comment on lines 823 to 828
stack_frame_fun_info(BIF_P,
code_ptr,
rp,
is_return_addr),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: indentation looks a little off here.

Comment on lines +1309 to +1311
#define MAP0(hp) \
(MAP_HEADER(hp, 0, TUPLE0), \
make_flatmap(hp))
Copy link
Contributor

Choose a reason for hiding this comment

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

This ought to be a global literal just like TUPLE0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but iiuc this is not something I can do as part of this change, correct? The deduplication needs to happen somewhere, etc

Copy link
Contributor

Choose a reason for hiding this comment

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

It's actually a small change: since the key tuple of empty maps must be ERTS_GLOBAL_LIT_EMPTY_TUPLE we can identify all affected places just by searching for ERTS_GLOBAL_LIT_EMPTY_TUPLE and blindly returning ERTS_GLOBAL_LIT_EMPTY_MAP instead of constructing a fresh empty map.

That and expanding the two lines in copy.c saying if (obj == empty_tuple_literal || ...) to also include the empty map should be enough. All in all it's just a handful places.

jcpetruzza and others added 2 commits May 8, 2025 13:41
At the moment, the erl_debugger module allows to toggle line-breakpoints
on and off, but there is no way for the caller to know:

  1. What lines of a module/function admit breakpoints,
  2. What breakpoints are currently enabled

So we add two BIFs, `erl_debugger:breakpoints/1` and
`erl_debugger:breakpoints/3` that expose this information.
It is already defined in the standard library, so just adding
to atom.names
@jcpetruzza jcpetruzza force-pushed the list_line_breakpoints branch from 35fb56a to e01435e Compare May 8, 2025 12:46
@jcpetruzza
Copy link
Contributor Author

Pushed new version addressing feedback and fixing corner-case where the module has no line-table

@bjorng bjorng added testing currently being tested, tag is used by OTP internal CI and removed testing currently being tested, tag is used by OTP internal CI labels May 9, 2025
@bjorng bjorng merged commit 3064254 into erlang:master May 12, 2025
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants