GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-106360: Support very basic superblock introspection by markshannon · Pull Request #106422 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Jul 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Adds indexing and len() support to uop superblocks, such that this:

def testfunc(x):
    i = 0
    while i < x:
        i += 1

testfunc(100)

for offset in range(0, 100, 2):
    try:
        ex = _testinternalcapi.get_executor(testfunc.__code__, offset)
        break
    except ValueError:
        pass

for uop in ex:
    print(uop)

produces this

('SAVE_IP', 7)
('LOAD_FAST', 1)
('SAVE_IP', 8)
('LOAD_CONST', 2)
('SAVE_IP', 9)
('_GUARD_BOTH_INT', 13)
('_BINARY_OP_ADD_INT', 13)
('SAVE_IP', 11)
('STORE_FAST', 1)
('SAVE_IP', 12)
('LOAD_FAST', 1)
('LOAD_FAST', 0)
('SAVE_IP', 13)
('COMPARE_OP_INT', 18)
('SAVE_IP', 15)
  • Issue: Add basic introspection, like str() for executors. #106360

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
markshannon added 6 commits July 3, 2023 12:30
@markshannon
Add very basic introspection capabilities to uop superblocks.
2cb3867
@markshannon
Add back accidental deletion.
2bed45a
@markshannon
Add len() and indexing support to uop superblocks.
46e99e6
@markshannon
Remove str() support from uop superblocks. Leave that to the client.
4f38063
@markshannon
Merge branch 'main' into superblock-introspection
f42f0cf
@markshannon
Use correct name of uop.
ed3b63a
@bedevere-bot bedevere-bot added the awaiting core review label Jul 4, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jul 4, 2023
Add basic introspection, like str() for executors. #106360
Closed
@markshannon markshannon added the skip news label Jul 4, 2023
@markshannon
markshannon requested a review from gvanrossum July 4, 2023 15:18
@markshannon

markshannon commented Jul 4, 2023

Copy link
Copy Markdown
Member Author

This PR also adds _PyOpcode_OpName and _PyOpcode_uop_name to non-debug builds because they are only a few Kbs of static data, and it is nice to be able to introspect things.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gvanrossum
gvanrossum approved these changes Jul 4, 2023
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This just needs a merge.

In the light of rising concerns over symbols starting with _Py still being public, maybe we should rename these or move the header file? These tables should be allowed to change on a whim.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_capi/test_misc.py Outdated
pass
if ex is None:
return
self.assertIn("SET_IP", str(ex))

@gvanrossum gvanrossum Jul 4, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think once you merge main you'll see that this is now called SAVE_IP.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

markshannon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jul 4, 2023
@markshannon

markshannon commented Jul 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

In the light of rising concerns over symbols starting with _Py still being public.

They aren't public though. We strip _Py symbols from the binary, unless they are marked with a PyAPI_FUNC or PyAPI_DATA macro.

gvanrossum reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon
markshannon merged commit 318ea2c into python:main Jul 4, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 4, 2023
carljm added a commit to carljm/cpython that referenced this pull request Jul 5, 2023
@carljm
Merge branch 'main' into modulelocals
4c59e51
* main: (39 commits)
  pythongh-102542 Remove unused bytes object and bytes slicing (python#106433)
  Clarify state of CancelledError in doc (python#106453)
  pythongh-64595: Fix regression in file write logic in Argument Clinic (python#106449)
  pythongh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (python#106443)
  tp_flags docs: fix indentation (python#106420)
  pythongh-104050: Partially annotate Argument Clinic CLanguage class (python#106437)
  pythongh-106368: Add tests for formatting helpers in Argument Clinic (python#106415)
  pythongh-104050: Annotate Argument Clinic parameter permutation helpers (python#106431)
  pythongh-104050: Annotate toplevel functions in clinic.py (python#106435)
  pythongh-106320: Fix specialize.c compilation by including pycore_pylifecycle.h (python#106434)
  Add some codeowners for `Tools/clinic/` (python#106430)
  pythongh-106217: Truncate the issue body size of `new-bugs-announce-notifier` (python#106423)
  pythongh-61215: Rename `wait_until_any_call` to `wait_until_any_call_with` (python#106414)
  pythongh-106162: array: suppress warning in test_array (python#106404)
  pythongh-106320: Remove _PyInterpreterState_HasFeature() (python#106425)
  pythonGH-106360: Support very basic superblock introspection (python#106422)
  pythongh-106406: Fix _Py_IsInterpreterFinalizing() in _winapi.c (python#106408)
  pythongh-106396: Special-case empty format spec to gen empty JoinedStr node (python#106401)
  pythongh-106368: Add tests for permutation helpers in Argument Clinic (python#106407)
  pythonGH-106008: Fix refleak when peepholing `None` comparisons (python#106367)
  ...
@markshannon
markshannon deleted the superblock-introspection branch August 6, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@markshannon @gvanrossum @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.