Merge "services/device/device: globify debug"
diff --git a/services/device/device/debug.go b/services/device/device/debug.go
index fcfab9e..1ba6fc4 100644
--- a/services/device/device/debug.go
+++ b/services/device/device/debug.go
@@ -6,32 +6,30 @@
 
 import (
 	"fmt"
+	"io"
+	"strings"
 
 	"v.io/v23/context"
 	"v.io/v23/services/device"
 	"v.io/x/lib/cmdline"
-	"v.io/x/ref/lib/v23cmd"
 )
 
 var cmdDebug = &cmdline.Command{
-	Runner:   v23cmd.RunnerFunc(runDebug),
+	Runner:   globRunner(runDebug),
 	Name:     "debug",
 	Short:    "Debug the device.",
-	Long:     "Debug the device.",
-	ArgsName: "<app name>",
+	Long:     "Get internal debug information about application installations and instances.",
+	ArgsName: "<app name patterns...>",
 	ArgsLong: `
-<app name> is the vanadium object name of an app installation or instance.`,
+<app name patterns...> are vanadium object names or glob name patterns corresponding to application installations and instances.`,
 }
 
-func runDebug(ctx *context.T, env *cmdline.Env, args []string) error {
-	if expected, got := 1, len(args); expected != got {
-		return env.UsageErrorf("debug: incorrect number of arguments, expected %d, got %d", expected, got)
-	}
-	appName := args[0]
-	if description, err := device.DeviceClient(appName).Debug(ctx); err != nil {
+func runDebug(entry globResult, ctx *context.T, stdout, _ io.Writer) error {
+	if description, err := device.DeviceClient(entry.name).Debug(ctx); err != nil {
 		return fmt.Errorf("Debug failed: %v", err)
 	} else {
-		fmt.Fprintf(env.Stdout, "%v\n", description)
+		line := strings.Repeat("*", len(entry.name)+4)
+		fmt.Fprintf(stdout, "%s\n* %s *\n%s\n%v\n", line, entry.name, line, description)
 	}
 	return nil
 }
diff --git a/services/device/device/debug_test.go b/services/device/device/debug_test.go
index f09af00..32a7678 100644
--- a/services/device/device/debug_test.go
+++ b/services/device/device/debug_test.go
@@ -6,6 +6,7 @@
 
 import (
 	"bytes"
+	"fmt"
 	"reflect"
 	"strings"
 	"testing"
@@ -27,22 +28,27 @@
 		return
 	}
 	defer stopServer(t, server)
-	// Setup the command-line.
+
 	cmd := cmd_device.CmdRoot
+	globName := naming.JoinAddressName(endpoint.String(), "glob")
+	appName := naming.JoinAddressName(endpoint.String(), "app")
+	rootTape, appTape := tapes.forSuffix(""), tapes.forSuffix("app")
+	rootTape.SetResponses(GlobResponse{[]string{"app"}})
+
 	var stdout, stderr bytes.Buffer
 	env := &cmdline.Env{Stdout: &stdout, Stderr: &stderr}
-	appName := naming.JoinAddressName(endpoint.String(), "")
 
 	debugMessage := "the secrets of the universe, revealed"
-	rootTape := tapes.forSuffix("")
-	rootTape.SetResponses(debugMessage)
-	if err := v23cmd.ParseAndRunForTest(cmd, ctx, env, []string{"debug", appName}); err != nil {
+	appTape.SetResponses(instanceRunning, debugMessage)
+	if err := v23cmd.ParseAndRunForTest(cmd, ctx, env, []string{"debug", globName}); err != nil {
 		t.Fatalf("%v", err)
 	}
-	if expected, got := debugMessage, strings.TrimSpace(stdout.String()); got != expected {
-		t.Fatalf("Unexpected output from debug. Got %q, expected %q", got, expected)
+	line := strings.Repeat("*", len(appName)+4)
+	expected := fmt.Sprintf("%s\n* %s *\n%s\n%s", line, appName, line, debugMessage)
+	if got := strings.TrimSpace(stdout.String()); got != expected {
+		t.Fatalf("Unexpected output from debug. Got:\n%v\nExpected:\n%v", got, expected)
 	}
-	if got, expected := rootTape.Play(), []interface{}{"Debug"}; !reflect.DeepEqual(expected, got) {
+	if got, expected := appTape.Play(), []interface{}{"Status", "Debug"}; !reflect.DeepEqual(expected, got) {
 		t.Errorf("invalid call sequence. Got %v, want %v", got, expected)
 	}
 }
diff --git a/services/device/device/doc.go b/services/device/device/doc.go
index 17eec24..881e621 100644
--- a/services/device/device/doc.go
+++ b/services/device/device/doc.go
@@ -314,12 +314,13 @@
 
 Device debug
 
-Debug the device.
+Get internal debug information about application installations and instances.
 
 Usage:
-   device debug <app name>
+   device debug <app name patterns...>
 
-<app name> is the vanadium object name of an app installation or instance.
+<app name patterns...> are vanadium object names or glob name patterns
+corresponding to application installations and instances.
 
 Device acl