delve icon indicating copy to clipboard operation
delve copied to clipboard

Add support to trace defer function calls under trace follow option

Open archanaravindar opened this issue 9 months ago • 4 comments

Is an extension of the basic support added to mention depth upto which functions and their descendants need to be traced https://github.com/go-delve/delve/pull/3594 The same option can now trace defer functions and their descendants

Fixes #3743

archanaravindar avatar Apr 09 '25 10:04 archanaravindar

Hi @aarzilli Thank you for reviewing the patch in detail and also suggesting improvements to optimize the code This patch adds support for functions called from within defer {..} that cant be determined statically unlike other functions so that their execution can be traced more accurately. Defers are handled in this patch specifically because they are an explicit feature of Go and one of the most common dynamic dispatch types used within a Go program

archanaravindar avatar Apr 22 '25 11:04 archanaravindar

Defers are handled in this patch specifically because they are an explicit feature of Go and one of the most common dynamic dispatch types used within a Go program

Defers are an explicit feature of Go just like function variables and interfaces, I'm not even sure that they really are the most common type of dynamic dispatch compared to the others (or by how much if they are), but even if they were I'm not sure it's enough to single them out. Or even how you would explain that to users, i.e. this changes the behavior of follow-calls without updating its documentation, but how would you update it "defer calls are followed regardless of what they call but other other types of dynamic calls aren't"?

aarzilli avatar Apr 29 '25 13:04 aarzilli

Defers are handled in this patch specifically because they are an explicit feature of Go and one of the most common dynamic dispatch types used within a Go program

Defers are an explicit feature of Go just like function variables and interfaces, I'm not even sure that they really are the most common type of dynamic dispatch compared to the others (or by how much if they are), but even if they were I'm not sure it's enough to single them out. Or even how you would explain that to users, i.e. this changes the behavior of follow-calls without updating its documentation, but how would you update it "defer calls are followed regardless of what they call but other other types of dynamic calls aren't"?

Thank you for the detailed comment @aarzilli, it appears that with minimal modifications the code can trace functions that are dynamically passed as procedure parameters or returned from functions. Made changes to documentation and added couple of test cases for the same, kindly let us know your thoughts on this, Thanks again for your time on this!

archanaravindar avatar May 20 '25 09:05 archanaravindar

Sorry to not have reviewed this yet, but I have been busy this past month and I will continue to be busy for a while still.

aarzilli avatar Jun 16 '25 07:06 aarzilli