[SERVER-74240] Add gdb CodeFragment pretty printing of stackSize and fixups Created: 21/Feb/23  Updated: 01/Mar/23  Resolved: 01/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Kevin Cherkauer Assignee: Kevin Cherkauer
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Sprint: QE 2023-03-06
Participants:

 Description   

This is split out of SERVER-72752 for the Python pretty printer used by gdb to print CodeFragments.

 

Q: Where is the Python pretty printer?

A: Irina Yatsenko: buildscripts/gdb/mongo_printers.py SbeCodeFragmentPrinter

[Originally added by SERVER-62049 via commit
https://github.com/mongodb/mongo/commit/207e7d16e4a24d4a16c2ab594bf5122e50aa8c4e]

[It is a plugin for the GDB debugger.] the pretty printers should be loaded automatically if you are running GDB from the toolchain. however, after the recent toolchain updates there have been issues with pretty printers (not sure exactly about the extent of problems)

you'd need to attach GDB to mongod and get it to breakpoint in code that has a CodeFragment object sitting around. Then you do either "p obj_name" or "p *obj_name" depending on whether 'obj_name' is a value or a pointer

it should printout a nicely formatted sequence of opcodes

from the recent communications flying around, you might need to compile with GDB_INDEX=1 (add it to the scone's command line) to get any decent debugging experience in GDB. it does make the compile/link time longer, though, so you might not want to keep the setting permanently...

 

 



 Comments   
Comment by Kevin Cherkauer [ 01/Mar/23 ]

The external Python pretty printer has not been maintained and is broken in current master, so irina.yatsenko@mongodb.com, its creator, who moved to QI, was probably its only user. anna.wawrzyniak@mongodb.com, who opened the original ticket this was added to and then split off from later (SERVER-72752 Add C++ CodeFragment pretty printing of stackSize and fixups ), is fine not continuing the Python one. I also posted to the #sbe Slack channel asking if anyone is using the Python one and got no replies so far.

The C++ pretty printer I already enhanced in SERVER-72752 can be called from the llvm debugger:

?/nat code2.toString()
"[0x7fffbfa42ab0-0x7fffbfa42ac9] stackSize: 5, maxStackSize: 5\n0x7fffbfa42ab0: pushLocalVal(arg: -11);\n0x7fffbfa42ab1:   fixup: frameId: 10\n0x7fffbfa42ab5: pushLocalVal(arg: -20);\n0x7fffbfa42ab6:   fixup: frameId: 10\n0x7fffbfa42aba: pushLocalVal(arg: 1);\n0x7fffbfa42abb:   fixup: frameId: 10\n0x7fffbfa42abf: pushLocalVal(arg: 2);\n0x7fffbfa42ac0:   fixup: frameId: 10\n0x7fffbfa42ac4: pushLocalVal(arg: -97);\n0x7fffbfa42ac5:   fixup: frameId: 10\n"

and is also used by tests, so it is kept in sync.

There is no business case for maintaining a second external pretty printer, so I am closing this as "Won't Do."

Comment by Kevin Cherkauer [ 23/Feb/23 ]

david.storch@mongodb.com I split this out of existing already scheduled ticket SERVER-72752. It is in the state Jira put it into. I do not believe I have the authority to make scheduling decisions and have found some of my prior attempts were frowned upon, so I just left it in the state Jira put it into. If you can confirm I should just schedule this then I will click the "Schedule" button – or you can do it.

The original ticket seemed to add the gdb pretty pritner as an afterthought, and it is a Python tool external to the server codebase, so I thought it is better to do it as a separate ticket rather than hold the original ticket open after the C++ pretty printer is delivered.

Comment by David Storch [ 23/Feb/23 ]

kevin.cherkauer@mongodb.com is it incorrect that this ticket is in "Needs Scheduling" state? It looks like it's assigned to you and slotted into the current QE sprint.

Generated at Thu Feb 08 06:26:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.