New functions to get kernel thread Id + serialisable task Id

On most platforms the userspace thread type (e.g. pthread_t) and kernel
thread id are different. Normally we don't care about kernel thread Ids,
but some system tools for tracing/profiling etc report kernel ids.
For example Solaris and OSX's DTrace and Linux's perf tool report kernel
thread ids. To be able to match these up with RTS's OSThread we need a
way to get at the kernel thread, so we add a new function for to do just
that (the implementation is system-dependent).

Additionally, strictly speaking the OSThreadId type, used as task ids,
is not a serialisable representation. On unix OSThreadId is a typedef for
pthread_t, but pthread_t is not guaranteed to be a numeric type.
Indeed on some systems pthread_t is a pointer and in principle it
could be a structure type. So we add another new function to get a
serialisable representation of an OSThreadId. This is only for use
in log files. We use the function to serialise an id of a task,
with the extra feature that it works in non-threaded builds
by always returning 1.
Define the task-tracking events

Based on initial patches by Mikolaj Konarski <mikolaj@well-typed.com>

These new eventlog events are to let profiling tools keep track of all
the OS threads that belong to an RTS capability at any moment in time.
In the RTS, OS threads correspond to the Task abstraction, so that is
what we track. There are events for tasks being created, migrated
between capabilities and deleted. In particular the task creation event
also records the kernel thread id which lets us match up the OS thread
with data collected by others tools (in the initial use case with
Linux's perf tool, but in principle also with DTrace).
Emit the task-tracking events

Based on initial patches by Mikolaj Konarski <mikolaj@well-typed.com>

Use the new task tracing functions traceTaskCreate/Migrate/Delete.
There are two key places. One is for worker tasks which have a
relatively simple life cycle. Worker tasks are created and deleted by
the RTS. The other case is bound tasks which are either created by the
RTS, or appear as foreign C threads making calls into the RTS. For bound
threads we do the tracing in rts_lock/unlock, which actually covers both
threads coming in from outside, and also bound threads made by the RTS.
Have a go at fixing the heap info DTrace build failue on OSX

This patch will need to be tested by someone on OSX.

Fixed a couple wrong names:
  CapsetID vs EventCapsetID
  gc__sync vs gc__global__sync
Spelling in comment
Merge branch 'master' of darcs.haskell.org:/home/darcs/ghc
Fix build with GHC 7.0
Don't use tracingDynFlags in assertPprPanic

It wasn't needed, but was left over as an oversight
Small tidy-up
When checking associated type instances, check that
the *type* indices match those of the class instance.
We don't need to track tke kind indices, and indeed
thay don't have the same careful name scoping.
See the notes in checkValidClass.

Fixes Trac #7073
Comments about associated type tyvar naming
Comments only
Comments only
Do not discard insoluble constraints in simplifyInfer

Before -fdefer-type-errors there we no insolubles
(because we'd have failed before then), but with -fdefer-type-errors
there can be.  The code is acutally a bit simpler: we just call
emitConstraints, and eliminate the bogus-looking emitWC from TcRnMonad.

There's a bit more tidying up to do, concerning the places we use
keepWanted, but I need to talk to Dimitrios about that.

Meanwhile this fixes Trac #7023
Merge remote branch 'mikolaj/dcoutts'
Merge branch 'master' of darcs.haskell.org:/srv/darcs//ghc
Fix typo
Add some casts to fix warnings
Whitespace only in Unique
Add a missing semi-colon