dbg:   debug applications remotely
1 Usage
1.1 Port Forwarding
2 Reference
2.1 Server
serve
2.2 Client
current-client
client?
connect
connected?
disconnect!
reconnect!
get-info
get-memory-use
get-object-counts
start-profile
stop-profile
get-profile
8.12

dbg: debug applications remotely🔗ℹ

Bogdan Popa <bogdan@defn.io>

This package provides a server, client and UI for remotely debugging Racket applications.

1 Usage🔗ℹ

Call serve before starting your app and use the returned function to stop the server when your app shuts down.

(require (prefix-in dbg: debugging/server))
(define dbg:stop (dbg:serve))

Then use the UI to interact with the server (raco dbg from the dbg-ui package). If you’re feeling particularly adventurous, you can use the programmatic API (Client) instead.

1.1 Port Forwarding🔗ℹ

The server listens on the loopback interface by default, so it’s not exposed to the internet. While you can tell it to listen on a different interface, that would likely be insecure. Instead, when you need to debug a remote server, you should use port forwarding. Here’s how you would forward port 9011 using the ssh command:

ssh -L 9011:127.0.0.1:9011 example.com

2 Reference🔗ℹ

The dbg package provides two top-level modules, representing the Server and Client APIs.

2.1 Server🔗ℹ

 (require debugging/server) package: dbg

procedure

(serve [#:host host #:port port])  (-> void?)

  host : string? = "127.0.0.1"
  port : (integer-in 0 65535) = 9011
Runs a debugging server bound to port on host in the background and returns a function that stops the server when called.

The server replaces the current-custodian in order to aid with profiling, so the earlier you start the server during your app’s boot process, the better.

2.2 Client🔗ℹ

 (require debugging/client) package: dbg

The client API may change between versions without warning.

parameter

(current-client)  client?

(current-client client)  void?
  client : client?
A parameter that holds the current client.

procedure

(client? v)  boolean?

  v : any/c
Returns #t when v is a client.

procedure

(connect [#:host host #:port port])  client?

  host : string? = "127.0.0.1"
  port : (integer-in 0 65535) = 9011
Connects to the debugging server at the given host and port.

procedure

(connected? [c])  boolean?

  c : client? = (current-client)
Returns #t when c is connected.

procedure

(disconnect! [c])  void?

  c : client? = (current-client)
Disconnects c from the server.

procedure

(reconnect! [c])  void?

  c : client? = (current-client)
Reconnects c to the server.

procedure

(get-info [c])  hash?

  c : client? = (current-client)
Gets metadata about the process being debugged.

procedure

(get-memory-use [c])  exact-positive-integer?

  c : client? = (current-client)
Gets the number of allocated bytes in use by the process being debugged.

procedure

(get-object-counts [c])

  (listof (cons/c string? (cons/c integer? integer?)))
  c : client? = (current-client)
Gets the current number and size (in bytes) of objects alloced by the process being debugged, grouped by type.

procedure

(start-profile [c delay-ms errortrace?])  void?

  c : client? = (current-client)
  delay-ms : exact-nonnegative-integer? = 1
  errortrace? : boolean? = #f
Starts a profiling the process being debugged, sampling every delay-ms milliseconds.

The errortrace? argument controls whether or not errortrace is used to construct call stacks. If errortrace was not enabled before starting the process, setting this value to #t will produce empty profiles.

procedure

(stop-profile [c])  any/c

  c : client? = (current-client)
Stops the current in-progress profile and returns the profile.

procedure

(get-profile [c])  any/c

  c : client? = (current-client)
Gets the last profile from the process being debugged.