How to trace macro'ed define to it's original location

If a define is introduced by a macro, how do I trace that back to it's original location? And I want is to do this in a tool analyzing a racket file where these macros exist. It won't be during compiling+running the file. I want to compile and analyze the file.

My overall goal is to use ctags with racket bc I use racket on smaller less powerful machines like old phones and small computers like SOC computers. They can barely handle a language server. I wanna make sure it captures defines introduced by macros.

I don't have anything so far, I haven't tried. I'm looking for an example of the tracing to help me start. And how would I read a file in as a syntax object? Is there like a read as syntax function?

I started playing around with ctags and while it was more robust than I thought, it misses definitions from structs.

I'd been meaning to write in about Universal Ctags, which I use personally. According to ctags --list-maps, it detects *.rkt files as Scheme.

The current parser just looks for (def and (set to create tags. Handling structs is harder because of all the introduced names; a quick test shows that this (which you can place in ~/.ctags.d somewhere) captures the struct name:

--regex-Scheme=/\([ \t]*struct[ \t]+([^[:space:]]+)/\1/f,function/

It probably doesn't handle |names with spaces|. With --mline-regex-<LANG> you might be able to write a clever pattern to capture the struct name and fields and construct struct-field tags.

Oh, but having just the struct name is OK if you don't mind doing :tag name instead of C-] on name-field; you can also Visually select name for C-].

Hm. Ykw, I goofed. This post ought to be titled "using ctags with racket", because ctags tricks are good answers too. However I feel like getting a list of all the names in sticking them in a ctags file is better. Like for structs I don't want to manually have to think about if function is derived and look up part of the name. And there's no automatic way to figure that out without a list of defines.

I also wonder if ctags handles define-values right.