Consider a real valued function g on an open interval $(a,b)$ which is the derivative of a function continuous on $[a,b]$ at each point of $(a,b)$. The function $g$ has the intermediate value property, so a monotone $g$ will have to be continuous, a general $g$ cannot have simple discontinuities, etc. With such constraints how badly can a derivative behave in terms of continuity, can it get much worse than the derivative of say, $x^2 \sin(1/x) $?

Talking about how bad may be the derivative of an everywhere derivable function on the interval [a,b], the natural example that occurs to my mind is: a Pompeiu derivative, that is, a derivative that vanishes in a dense set (these weird functions, however, constitue a closed linear space of $C^0[a,b]$, while it's not even obvious that they are closed wrto addition!). For an account on the subject you may refer e.g. to the above quoted book by Andrew M. Bruckner Differentiation of real functions: it's also in the CRM series now (here is a preview: http://books.google.it/books?id=fXfEGF2zJUC&printsec=frontcover&source=gbs_book_other_versions#v=onepage&q&f=false) For a quick reference, you may also have a look to the wiki article http://en.wikipedia.org/wiki/Pompeiu_derivative (it's me who wrote it ;) ) 


Of course every continuous function is a derivative, so your question seems like it could be reinterpreted as the characterization problem for derivatives: that is, give "nice" necessary and sufficient conditions on a function $f: [a,b] \rightarrow \mathbb{R}$ for it to be the derivative of some other function (onesided, at the endpoints). As others have pointed out, any derivative must be a Darboux function  i.e., satisfy the conclusion of the Intermediate Value Theorem  and also a Baire class one function  i.e., a pointwise limit of continuous functions. The latter implies that the set of discontinuities is meager. A lot of work has been done seeking to understand "how much bigger" the class of Darboux, Baire Class 1 functions is than the class of derivatives. Here are some references:
http://www.math.uga.edu/~pete/BrucknerLeonard66.pdf



Derivatives are like continuous functions in that both have the intermediate value property, but they need not have the extreme value property. Gelbaum and Olmstead, Counterexamples in Analysis, gives as example 3.7 the function $$ f(x) = \begin{cases} x^4 e^{\frac{1}{4}x^2}\sin\frac{8}{x^3}, & x \ne 0 \\ 0, & x=0 \end{cases} $$ for which $f'$ exists everywhere, but does not achieve its supremum on the compact interval $[1,1]$. On the other hand, a derivative cannot have too many discontinuities. Lars Olsen at http://mathforum.org/kb/message.jspa?messageID=281579&tstart=0 points out that a derivative is a pointwise limit of the continuous functions and hence of Baire class at most 1, and therefore its set of discontinuities is meager (in particular, has dense complement). 


I think it can. In particular, Wikipedia's antiderivative page seems to imply that, for any meagre $F_\sigma$ subset of an open interval, one can construct a function whose derivative is discontinuous on that subset. It also gives some examples. 


In Y. Katznelson and K. Stromberg’s paper “Everywhere differentiable, nowhere monotone, functions,” Amer. Math. Monthly 81 (1974), no. 4, 349–354, there is a construction, based on somewhat similar ideas to those described in Majer’s above mentioned article, whereby for any two disjoint countable sets $A, B \subset \mathbb{R}$ there exists a differentiable function whose derivative equals $1$ on $A$ and is less than $1$ on $B$. So if $A$ and $B$ are both dense in $\mathbb{R}$ then this derivative must be discontinuous at every point of $B$. 

