Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepping through macro expansions #124

Open
deliciouslytyped opened this issue Aug 2, 2021 · 3 comments
Open

Stepping through macro expansions #124

deliciouslytyped opened this issue Aug 2, 2021 · 3 comments

Comments

@deliciouslytyped
Copy link

Related to #123 ,

I want to debug the following Makefile;
the make-dirs call expands to nothing:

define _make-dir
$1/.dum: $(not-dir $1)/.dum
        mkdir $(dir $@)
        touch $(dir $@)/.dum
endef

# we dont try to create/depend on /.dum
define make-dir
$(if $(not-dir $1),$(call _make-dir,$1),)
endef

$(call make-dir,test/)

I've skimmed through the manual earlier and looked through the in-REPL documentation, maybe I'm missing something but

  • I don't see any way to step through macro expansions
  • I don't see a way to dump the contents of the file after expansion
  • are there other techniques for debugging macros?
    Are there any existing solutions to these, or are there features that could be implemented?
@deliciouslytyped
Copy link
Author

I'm currently trying to find a workaround by trying to write a $(call trace,...) function that can be inserted in a nested expansion, similar to trace functions in functional programming languages; it prints the value it is passed and then returns it; but I'm not very good at make programming yet.

@deliciouslytyped
Copy link
Author

Another possibility might be to

  • use the gmake guile integration
  • use GDB with debug symbols enabled, if there is a function corresponding to "return the value of an expansion", and if I can find said function

@deliciouslytyped
Copy link
Author

deliciouslytyped commented Aug 2, 2021

#125 implements the fourth (not explicitly listed previously because I thought it would be a lot harder) option: implementing the trace builtin.

However, having the ability to step through expansions would still be helpful because it doesn't require modifying the Makefile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants