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

Added ability to trigger on addresses and line numbers #241

Closed
wants to merge 1 commit into from

Conversation

Lamoreauxaj
Copy link
Contributor

This feature adds triggers of the format addr:0xfffff or line:file.ml:99:15. All triggers can be prefixed with either symbol:, addr:, or line:, but if none is given, it will default to a symbol if possible and otherwise parse it as a line number or address.

There is no feature to allow our fuzzy finding to work with the new options, but it could be possible to implement fuzzy finding on files for example.

core/elf.ml Outdated
@@ -148,6 +167,72 @@ let find_symbol t name =
None)
;;

let find_selection t name : Selection.t option =
let find_line_selection name =
let split_name = String.split name ~on:':' in
Copy link
Member

Choose a reason for hiding this comment

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

Can we do a

match ... with
| [ desired_filename; desired_line; desired_col ] -> ...
| _ -> raise some error

here?

core/elf.ml Outdated
| Some desired_filename, Some desired_line, Some filename ->
if String.(desired_filename = filename) && desired_line = line
then cols := (col, state.address) :: !cols
| None, _, _ | _, None, _ | _, _, None -> ())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
| None, _, _ | _, None, _ | _, _, None -> ())
| _, _, _ -> ())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

core/elf.ml Outdated
then
Core.eprint_s
[%message
"Multiple snapshot symbols on same line. Selecting one."
Copy link
Member

@Xyene Xyene Jul 13, 2022

Choose a reason for hiding this comment

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

Let's switch this to a regular eprintf with non-sexp formatting because it's user-visible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

core/elf.ml Outdated
let find_symbol_selection name =
Option.map (find_symbol t name) ~f:(fun symbol -> Selection.Symbol symbol)
in
if String.is_prefix name ~prefix:"symbol:"
Copy link
Member

Choose a reason for hiding this comment

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

Let's extract this if/then branch into a short helper and use it here, that takes ~prefix and ~f, so that we can elide the hardcoding of the prefix lengths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

This feature adds triggers of the format `addr:0xfffff` or `line:file.ml:99:15`.
All triggers can be prefixed with either `symbol:`, `addr:`, or `line:`, but if
none is given, it will default to a symbol if possible and otherwise parse it as
a line number or address.

There is no feature to allow our fuzzy finding to work with the new options, but
it could be possible to implement fuzzy finding on files for example.

Signed-off-by: Aaron Lamoreaux <alamoreaux@janestreet.com>
@Xyene
Copy link
Member

Xyene commented Oct 27, 2023

Closing since this ended up being merged as part of another PR.

@Xyene Xyene closed this Oct 27, 2023
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

2 participants