79314414

Date: 2024-12-28 19:21:11
Score: 1
Natty:
Report link

Is there any simple and clear way to implement this?

No.

To implement this, you would need to have a detailed understanding of how the debug info is encoded, and how to interpret it.

I assume I need a parser of dwarf format, find AT_DW_location of arguments in .debug_info, maybe then refer to .debug_loc for location list ...

Yes, and more. You could compile your example program, and then study the output from readelf -wi a.out.

Look for DW_TAG_subprogram, followed by DW_TAG_formal_parameters. Each parameter will have DW_AT_type and DW_AT_location, which will tell you the type and location of the parameter.

I don't know if this is a feasible

It's feasible, but by the time you are done you will have implemented 30-50% of a real debugger. At which point a reasonable question is: why not use a real debugger which exists already?

Reasons:
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (1): Is there any
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): Is there any
  • High reputation (-2):
Posted by: Employed Russian