Change Skylark's print() on a rule target to print the Skylark-exposed provider keys.

This change only affects printing a rule target directly -- it intentionally does not affect the behavior of str(target), as we want to avoid skylark code being able to parse potentially-private provider keys.

RELNOTES: In skylark, print(target) now shows the provider keys of a target, as debug information.
PiperOrigin-RevId: 186046226
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Printer.java b/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
index 69b16fe..b2248f8 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
@@ -73,6 +73,13 @@
   // These static methods proxy to the similar methods of BasePrinter
 
   /**
+   * Format an object with Skylark's {@code debugPrint}.
+   */
+  public static String debugPrint(Object x) {
+    return getPrinter().debugPrint(x).toString();
+  }
+
+  /**
    * Format an object with Skylark's {@code str}.
    */
   public static String str(Object x) {
@@ -283,6 +290,21 @@
     }
 
     /**
+     * Print an informal debug-only representation of object x.
+     *
+     * @param o the object
+     * @return the buffer, in fluent style
+     */
+    public BasePrinter debugPrint(Object o) {
+      if (o instanceof SkylarkValue) {
+        ((SkylarkValue) o).debugPrint(this);
+        return this;
+      }
+
+      return this.str(o);
+    }
+
+    /**
      * Print an informal representation of object x. Currently only differs from repr in the
      * behavior for strings and labels at top-level, that are returned as is rather than quoted.
      *