Implement debug() using LinkedHashSet for determinism

In general, we should use LinkedHashSet/LinkedHashMap for collections
that we iterate over; this makes the behavior deterministic.  For
collections that are merely accessed but not iterated over, HashSet
etc. are fine.