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

addr2line: type checking, debugging #2434

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

travisdowns
Copy link
Contributor

@travisdowns travisdowns commented Sep 13, 2024

This series has two changes:

Add additional type hints and a few other type related changes to seastar-addr2line and addr2line.py. After this these scripts type check cleanly with pyright strict.

Add a --debug arg which actives additional explicit debug logging, quite useful for diagnosing what is going on.

./seastar-addr2line --test passes after these two changes.

@xemul xemul requested a review from bhalevy September 16, 2024 10:52
@travisdowns travisdowns changed the title addr2line: add type checking addr2line: type checking, debugging Sep 16, 2024
Copy link
Contributor

@tchaikov tchaikov left a comment

Choose a reason for hiding this comment

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

left some comments.

scripts/addr2line.py Show resolved Hide resolved
scripts/addr2line.py Outdated Show resolved Hide resolved
scripts/addr2line.py Show resolved Hide resolved
"""Returns the input stream for the process/pipe."""
return notNone(self._input_proc.stdin)


Copy link
Contributor

Choose a reason for hiding this comment

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

a single line would be better, IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, this is fixed by black too.

scripts/addr2line.py Outdated Show resolved Hide resolved
self._executable = executable
self._kallsyms = kallsyms
self._current_backtrace = []
self._current_backtrace : list[tuple[str, str]] = []
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, might want to put : next to self._current_backtrace , like:

self._current_backtrace: list[tuple[str, str]] = []

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good eye, fixed! (even more reason for black :))

@@ -51,13 +51,16 @@ def read_backtrace(stdin):
if char == '' or linefeeds > 1:
break

TestResult = dict[str, Any]
MaybeTestResult = Union[TestResult, None]
Copy link
Contributor

Choose a reason for hiding this comment

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

could use Optional[TestResult].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, done!

if self._missing:
return " ".join([self._binary, address, '\n'])
# We print a dummy 0x0 address after the address we are interested in
# which we can look for in _read_address
self._input.stdin.write(address + '\n0x0\n')
self._input.stdin.flush()
self._input().write(address + '\n0x0\n')
Copy link
Contributor

@tchaikov tchaikov Sep 22, 2024

Choose a reason for hiding this comment

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

if _input is a property, we don't need to call it for retrieving the value returned by it, am i right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, this is correctly without () after the 2nd commit in this series, but absorb assigned it to the wrong commit in this case, let me fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in db9e2ff.

@tchaikov
Copy link
Contributor

and you might want to rebase this changeset against master HEAD.

@travisdowns travisdowns force-pushed the td-addr2line-debugging branch 2 times, most recently from db9e2ff to e7b2866 Compare September 23, 2024 12:59
@travisdowns
Copy link
Contributor Author

and you might want to rebase this changeset against master HEAD.

Done in push e7b2866.

@avikivity
Copy link
Member

@bhalevy please review too

self._missing = res == ''

@property
Copy link
Contributor

Choose a reason for hiding this comment

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

the last nit: can we make similar changes to self._output, so they are symmetric ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, done in most recent push.

Add additional type hints and a few other type related changes to
seastar-addr2line and addr2line.py. After this these scripts type
check cleanly with pyright strict.

--test passes.
This adds the --debug argument to the seastar-addr2line script.

--debug will output additional logging/diagnostics to stderr (the
primary output goes to stdout), which can be helpful to diagnose what
is going on when addr2line does not decode things as expected.

Right now the debugging is targeted mostly at the specific flow of
decoding the addresses in the child process, but .debug(...) calls
can be added anywhere else if it is convenient.
@tchaikov
Copy link
Contributor

@scylladb/seastar-maint hello maintainers, could you help merge this change?

@travisdowns travisdowns force-pushed the td-addr2line-debugging branch from e7b2866 to 83fb226 Compare October 1, 2024 00:07
@tchaikov
Copy link
Contributor

tchaikov commented Oct 9, 2024

@scylladb/seastar-maint hello maintainers, could you help merge this change?

@avikivity avikivity closed this in d012297 Oct 9, 2024
@avikivity avikivity merged commit d012297 into scylladb:master Oct 9, 2024
15 checks passed
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.

5 participants