Skip to content

Conversation

marxin
Copy link

@marxin marxin commented Apr 15, 2018

The patch is based on a blog post: http://kouk.surukle.me/2014/09/25/debugging-python-objects-and-fields-with-gdb/.
Adding him: @kouk

Purpose of the pull request is to support more complex expressions for py-print command.
Small example:

(gdb) py-print self
local 'self' = <OptimizationLevel(level='', options=[<MarchFlag(name='-mtune=', options={'x86_64': ('native', 'i386', 'i486', 'i586', 'pentium', 'lakemont', 'pentium-mmx', 'pentiumpro', 'i686', 'pentium2', 'pentium3', 'pentium3m', 'pentium-m', 'pentium4', 'pentium4m', 'prescott', 'nocona', 'core2', 'nehalem', 'westmere', 'sandybridge', 'ivybridge', 'haswell', 'broadwell', 'skylake', 'bonnell', 'silvermont', 'knl', 'skylake-avx512', 'k6', 'k6-2', 'k6-3', 'athlon', 'athlon-tbird', 'athlon-4', 'athlon-xp', 'athlon-mp', 'k8', 'opteron', 'athlon64', 'athlon-fx', 'k8-sse3', 'opteron-sse3', 'athlon64-sse3', 'amdfam10', 'barcelona', 'bdver1', 'bdver2', 'bdver3', 'bdver4', 'znver1', 'btver1', 'btver2', 'winchip-c6', 'winchip2', 'c3', 'c3-2', 'geode'), 'ppc64': ['401', '403', '405', '405fp', '440', '440fp', '464', '464fp', '476', '476fp', '505', '601', '602', '603', '603e', '604', '604e', '620', '630', '740', '7400', '7450', '750', '801', '821', '823', '860', '970', '8540', 'a2', 'e300c2', 'e300c3', 'e500mc', 'e500mc64', 'e5500', 'e6...(truncated)

(gdb) py-print self.options.0.options.x86_64.3
local 'self.options.0.options.x86_64.3' = 'i586'

I consider it very handy. For now I support objects, dictionary, tuple and list types of objects.
I guess a test-case and a documentation entry will be needed. But I would first like to get a feedback about the intention of the change.

Thanks

https://bugs.python.org/issue33294

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again to your contribution and we look forward to looking at it!

@marxin
Copy link
Author

marxin commented Apr 15, 2018

I've just signed CLA, please recheck it.

@pablogsal
Copy link
Member

@marxin Please, open an issue in http://bugs.python.org and reference that issue number in the pull request title. More info about the workflow:

https://devguide.python.org/pullrequest/#submitting

@marxin marxin force-pushed the gdb-py-print-improvement branch 2 times, most recently from bfcc0c3 to 5299070 Compare April 17, 2018 07:18
@marxin
Copy link
Author

marxin commented Apr 17, 2018

@pablogsal Thanks. Done that, looks issue-number check needs to be triggered again.

@pablogsal
Copy link
Member

@marxin Reference the issue number in the PR title. See other PRs for reference. Thanks

@marxin marxin changed the title Support complex expressions for py-print command. bpo-33294: Support complex expressions for py-print command. Apr 17, 2018
@marxin
Copy link
Author

marxin commented Apr 17, 2018

Thanks @pablogsal. Done that.

Copy link
Member

@davidmalcolm davidmalcolm left a comment

Choose a reason for hiding this comment

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

Thanks for this patch.

The patch is missing test coverage. Please see: Lib/test/test_gdb.py for examples of how to test py-print.

Copy link
Member

Choose a reason for hiding this comment

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

Is this missing some line breaks? (i.e. before the "local")

Copy link
Author

Choose a reason for hiding this comment

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

Yes, fixed in newer version.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a docstring i.e. within the function body?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, fixed in newer version.

Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit odd to be using dotted notation to access by index. Is it possible to support square-bracket syntax here, or does it conflict with gdb's usage of square-bracket syntax for C level lookup?

Copy link
Member

Choose a reason for hiding this comment

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

Similarly for dict objects; wouldn't square bracket notation be more Pythonic?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, fixed in newer version.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@classmethod
def tokenize_square_brackets(self, expr):
'''
Tokenize single expression of an array index of key of a dictionary
Copy link
Member

Choose a reason for hiding this comment

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

This docstring is confusing to read, could you elaborate a cleaner version of what this function does?

Copy link
Author

Choose a reason for hiding this comment

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

Should be better now ;)

@marxin marxin force-pushed the gdb-py-print-improvement branch from 0180f67 to 4b9980e Compare May 31, 2018 12:49
@marxin
Copy link
Author

marxin commented May 31, 2018

I also added a test-case.

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@davidmalcolm: please review the changes made to this pull request.

@marxin
Copy link
Author

marxin commented Jun 22, 2018

May I please ping review process?

Copy link
Member

Choose a reason for hiding this comment

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

The skills[defence] syntax seems weird to me; shouldn't this be skills["defence"] or skills['defence']?

Copy link
Member

Choose a reason for hiding this comment

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

Likewise here; shouldn't this be ['a'] rather than [a]?

Copy link
Member

Choose a reason for hiding this comment

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

Please add test coverage for this error

Copy link
Member

Choose a reason for hiding this comment

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

Please add test coverage for this error.

Copy link
Member

Choose a reason for hiding this comment

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

Please add test coverage of a tuple

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@marxin marxin force-pushed the gdb-py-print-improvement branch from 4b9980e to 41c700a Compare June 29, 2018 13:17
@marxin
Copy link
Author

marxin commented Jun 29, 2018

Thanks @davidmalcolm for review.
I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@davidmalcolm: please review the changes made to this pull request.

@marxin
Copy link
Author

marxin commented Jul 9, 2018

I would like to remind review @davidmalcolm. Thanks.

@marxin
Copy link
Author

marxin commented Sep 3, 2018

PING^2

@marxin
Copy link
Author

marxin commented Dec 31, 2018

PING^3

@csabella csabella requested a review from davidmalcolm June 1, 2019 01:16
@marxin
Copy link
Author

marxin commented Jun 30, 2019

@davidmalcolm: Hi. Can we please move forward with this pull request?

@marxin
Copy link
Author

marxin commented Dec 8, 2019

@davidmalcolm : ping

@csabella csabella requested review from davidmalcolm and removed request for davidmalcolm May 23, 2020 17:43
@marxin
Copy link
Author

marxin commented May 25, 2020

@csabella Can you please find somebody else from David who can make the patch review?
I've been waiting for quite some time..

@marxin
Copy link
Author

marxin commented Oct 12, 2021

Bailing out, apparently, there's nobody who would review my patch.

@marxin marxin closed this Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants