In some cases you can take shortcuts by using optimization to see which parameter affects what output:
http://omrelli.ug/g9/gallery/
Or, if you are only interested in the final line that drew an element, you could inject info about the code explicitly into the metadata of components that are drawn.
“Use-define chain” seems like a related concept based on the Wikipedia page, but I don’t know anything more about that:
https://en.wikipedia.org/wiki/Use-define_chain
I asked a possibly related question on Stackoverflow a year ago related to instrumenting JS, but didn’t get any useful replies there:
https://stackoverflow.com/questions/47871319/how-to-inspect-variable-data-flow-in-javascript
Somehow I get the feel that maybe LISP-like languages, where code and data are more similar, would be easier to debug and reason about. Then, instrumenting code wouldn’t be anything special or cause so much perf overhead. Probably also any architectures with mainly pure functions.