1

I found that adding a print statement to my bazel macros and rule implementations result in console output added to the build such as

DEBUG: /home/$USER/repo/source.bzl:82:5: message XYZ

And I can even introspect a bit of objects with standard python techniques like...

def my_macro(my_list):
    print(my_list)
    print(type(my_list))
    print(dir(my_list))


DEBUG: /home/$USER/repo/source.bzl:83:5: ["//visibility:public"]
DEBUG: /home/$USER/repo/source.bzl:84:5: list
DEBUG: /home/$USER/repo/source.bzl:85:5: ["append", "extend", "index", "insert", "pop", "remove"]

Is there anyway to access things like in the traceback module to look at stack traces and what not? Maybe even something like importing pdb and setting a break point?

jxramos
  • 7,356
  • 6
  • 57
  • 105

1 Answers1

0

There's a lil section in the documentation dedicated to macro debugging

https://docs.bazel.build/versions/master/skylark/macros.html#debugging

You can also use print for debugging.

Where the print function is explicitly pointed out a handy link is given which redirects you to the globals functions.

https://docs.bazel.build/versions/master/skylark/lib/globals.html

There you can see the type and dir entries. Not seeing anything stack trace oriented just some techniques for probing the current call stack context.

jxramos
  • 7,356
  • 6
  • 57
  • 105