Explicit formula for the trace of an unramified principal series representation of $GL(n,K)$, $K$ $p$-adic. Let $K$ be a non-arch local field (I'm only interested in the char 0 case), let $\mathbb{G}$ be a connected reductive group over $K$ and let $G=\mathbb{G}(K)$. If $V$ is a smooth irreducible complex representation of $G$ and if $H$ is the Hecke algebra of locally constant complex-valued functions on $G$ with compact support (fix a Haar measure on $G$ to make $H$ an algebra under convolution), then $V$ is naturally an $H$-module, and every $h\in H$ acts on $V$ via a finite rank operator and hence has a trace.
It is my understanding that in this connected reductive situation, a theorem of Harish-Chandra says that this trace function $t:H\to\mathbb{C}$ can actually be expressed as
$$t(h)=\int_G tr(g)h(g) dg$$
for $tr:G\to\mathbb{C}$ an $L^1$ function, called the trace of $V$.
If $V$ is finite-dimensional then $tr$ is the usual trace. However I realised earlier this week that I do not know one single explicit example of this function if $V$ is infinite-dimensional. I just spent 20 minutes trying to fathom out what I guessed was probably the simplest non-trivial example: if $G=GL(2,K)$ and $V$ is, say, an unramified principal series representation. I failed :-( I could compute the trace of $h$ for various explicit $h$ (typically supported in $GL(2,R)$, $R$ the integers of $K$) but this didn't seem to get me any closer to an actual formula: in particular, although I could figure out $t$ on various functions I couldn't figure out $tr$ on any elements of $G$. On the other hand I imagine that this sort of stuff is completely standard, if you know where to look.
If $\mu_1$ and $\mu_2$ are unramified characters of $K^\times$ and $V$ is the associated principal series representation of $GL(2,K)$, then what is $tr(g)$ for $g$, say, a diagonal matrix? Or $g$ a unipotent matrix? 
[EDIT: Alexander Braverman points out that I have over-stated Harish-Chandra's result: $t$ is only locally $L^1$. Furthermore one has to be a little careful---more careful than I was at least---because $t$ is only defined via some integrals so one could change it on a set of measure zero---hence in some sense asking to evaluate $t$ at an explicit point makes no sense. However he, in his answer, shows how to make sense of my question anyway, as well as answering it.]
[EDIT: Loren Spice points out that my paranthetical char 0 comment is actually an assumption in Harish-Chandra's result, and that apparently local integrability is still open in char $p$. I didn't make a very good job of stating H-C's theorem at all!]
 A: Although you didn't mention them, it seems appropriate to bring up the so called ‘reducible principal series’—more precisely, the irreducible components of a full induced representation off a Borel.  These were computed for the case of $\operatorname{SL}_2$ by Paul Sally's student Stephen Franklin.  As far as I know, the thesis was never published; but the formula is announced in Sally–Shalika 3.  There must be other explicit calculations out there in this setting, but I don't know them.
A: The trace of a principal series representation can be easily computed from the main result of "Computation of Certain Induced Characters of p-Adic Groups" by van Dijk, Math. Ann. 199 229-240 (1972), doi: 10.1007/BF01429876, eudml. It gives you a formula to compute the character of a parabolically induced character based on that of the inducing character. It is of course supported on conjugates of Levi, and for $\gamma$ belonging to the Levi M, the character of the induced representation at gamma equals the weighted sum of characters of the inducing representation at W(G, M)-conjugates of $\gamma$, the weight being an appropriate discriminant factor. The formula also occurs somewhere in Kazhdan's "Cuspidal geometry of p-adic groups".
In particular, in the p-adic case if you induce $(\mu_1, \mu_2)$ to $GL_2(K)$, the character is supported on the conjugates of diagonals, and the value of the character at
$(\lambda_1, \lambda_2)$ is equal to something like (I might get some factor wrong) $\displaystyle\frac{\mu_1(\lambda_1) \mu_2(\lambda_2) + \mu_1(\lambda_2) \mu_2(\lambda_1)}{|\lambda_1 - \lambda_2|}$. Here the $|\lambda_1 - \lambda_2|^2$ factor is the reason why it does not extend nicely to $GL_2(K)$, and is also why it is not bounded. However, if you multiply it by $|\lambda_1 - \lambda_2|$, which is what is denoted $|D(g)|^{1/2}$ where $g = (\lambda_1, \lambda_2)$ then you do get a nice function on $GL_2(K)$ (it extends nicely to the non-regular set).
Note that the computation of characters of subquotients of principal series is a totally different ballgame. These guys are not supported on conjugates of the Levi. I doubt anyone has ventured seriously into that problem.
A: computing the trace of a smooth irreducible representation is a very difficult problem which is far from being totally solved.
For a nice overview, you may read :
Sally, Paul J., Jr.; Spice, Loren Character theory or reductive $p$-adic groups. Ottawa lectures on admissible representations of reductive $p$-adic groups, 103–111, Fields Inst. Monogr., 26, Amer. Math. Soc., Providence, RI, 2009.
For GL(2) you already have computations in Jacquet-Langlands LN 414 (at least for principal series, at certain elements). I think you may find similar things in Gelfand-Graev-Piateski-Shapiro as well.
Kutzko and Pantoja have  determined the Harish-Chandra characters of all smooth irreducible representations of GL(2)
P. C. Kutzko, Amer. J. Math. 109 (1987), no. 2, 201--221, doi: 10.2307/2374571.
Kutzko, Phil; Pantoja, José Character formulas for supercuspidal representations of the groups ${\rm GL}_2,\ {\rm SL}_2$. Comm. Algebra 26 (1998), no. 6, 1679–1697, doi: 10.1080/00927879808826232.
You have more general results by Sally, Corwin on GL(n) but in the tame case (see Math Sci Net). See also the computations by Bushnell and Henniart in their explicit version of the Jacquet-Langlands correspondence in the tame case.
Of course I must forget to cite a lot of contributors.
For supercuspidal representations, you may compute its character as soon as you get it  as a compactly induced representation. Indeed you may apply an adapted form of Mackey's formula. On that subject, I recommand the appendix of Bushnell-Henniart, Publication IHES.
All explicitely known supercuspidal representations are obtained as compactly induced representations.
You have more modern tools as well. Schneider and Stuhler have associated to any smooth irreducible representation $\pi$ of a $p$-adic reductive group $G$ a $G$-equivariant coefficient system $C(\pi )$ on the affine building $X$ of $G$ (see their IHES publication). They proved that if $\gamma$ is a regular elliptic element of $G$, then the the value of the Harish-Chandra character at $G$ is given by the trace of $\pi (\gamma )$ in the Euler-Poincaré module of the restriction of $C(\pi )$ to $X^{\gamma}$, the fixed point set of $\gamma$ in $X$.
Unfortunately this coefficient system as well as  the set of fixed points in $X$ are difficult to work out for explicit representations. In simple cases like that of level zero represenatations of $GL(m,D)$ and $\gamma$ minimal in the sense of Bushnell-Kutzko (those elements have  a single fixed point in the building) you may obtain a simple formula. For example, as an exercice you may compute this way the character of the Steinberg representation at regular elliptic elements (it is constant, equals to $\pm 1$.
A: I'm not sure about principal series representations, but I know that there is a Frobenius formula for supercuspidal representations of $p$-adic groups that helps in calculating these trace characters $tr$.  More precisely : 
$\mathbf{Theorem}$:
Let $G$ be a connected reductive $p$-adic group, and suppose (for simplicity) that $Z(G)$ is compact.  Let $K$ be an open compact subgroup of $G$ and let $(\sigma,W)$ be an irreducible representation of $K$ such that $$\pi := Ind_K^G \sigma$$ is a supercuspidal representation of $G$ (the induction is compact induction).  If $g \in G$ is regular and if $tr_{\pi}$ denotes the distribution character you described above for $\pi$, 
$$tr(g) = \displaystyle\sum_{x \in K \setminus G / K} \ \ \displaystyle\sum_{y \in K \setminus KxK} \dot{tr}_{\sigma}(ygy^{-1})$$
where $\dot{tr}_{\sigma}(h)$ is defined to be 
$tr_{\sigma}(h)$ if $h \in K$, and zero if $h \notin K$.  Here, $tr_{\sigma}$ is the distribution character of the representation $\sigma$.
This is Theorem 1.9 in Paul Sally's paper "Some remarks on discrete series characters for reductive p-adic groups".  Note: If $Z(G)$ is not compact, you get a similar formula but with a central character out front.
In principle, one starts with understanding $K \setminus G / K$.  Then, one knows that $KxK$ can be written as a finite union of right cosets. To see this, consider $K \cap x^{-1} Kx$.  Then $K / (K \cap x^{-1} Kx)$ is finite since $K$ is compact open.  Then, $$KxK = \displaystyle\bigcup_{z \in K / (K \cap x^{-1} K x)} Kxz$$ since $K \cap x^{-1} Kx$ is "all the stuff in $K$ that you can move to the left of $x$ in $KxK$". Therefore, the inner sum becomes $$\displaystyle\sum_{z \in K / (K \cap x^{-1} Kx)} \dot{tr}_{\sigma}(xzgz^{-1} x^{-1}),$$ a finite sum.  Then, one goes about calculating all these terms and simplifying and organizing the result.  
This is difficult in general.  I'm sure Loren Spice or Jeffrey Adler will answer/comment at some point, since they have computed these things in large generality, but here is a toy example :
One place to start is with depth zero supercuspidal representations.  Let $G$ be a split group and suppose that $Z(G)$ is compact.  If $K = G(\mathfrak{o})$, then we have the Cartan decomposition $G = KA^- K$, and the bijection $A^- / A(\mathfrak{o}) \leftrightarrow K \setminus G / K$, given by $a \mapsto KaK$, where $A$ is the maximal split torus of $G$, and where $A^-$ is the set of all $a \in A : |\alpha(a)| \leq 1 \ \forall \alpha \in \Delta$.  Here, $\Delta$ is a set of simple roots.  So we now have simplified the outer sum.  Then, one goes about calculating $K / (K \cap x^{-1} Kx)$, and then the elements $xzgz^{-1} x^{-1}$, and tallies everything together.  
You can try $SL(2,F)$ and fix some concrete $x \in A^-$.  Then literally calculate $K \cap x^{-1} K x$, and then $K / (K \cap x^{-1} K x)$, and see what happens, and you will have calculated the inner sum.  Then you can calculate $tr_{\pi}$ in terms of $tr_{\sigma}$.  Moreover, since we are in depth zero, $tr_{\sigma}$ will be given in terms of information over the finite field, which is known in principle.
I should mention Loren Spice and Jeffrey Adler's paper 
http://lanl.arxiv.org/abs/0707.3313
where they compute these distribution characters in large generality.  It is quite complicated in general, just by looking at their paper.
A: I am not sure, if you are still interested in this, but here is the general computation: 
Let $\phi \in C_c^\infty (GL_n(F))$, and let $\pi$ be a super-cuspidal representation of a Levi subgroup $M$ of a parabolic $P$ with unipotent radical $N$, and let $\pi_0 = Ind_{P}^{GL_n(F)} \pi$ be the normalized induced representation (assume unitary, irreducible for safety). Let $K$ be compact open subgroup with $GL_n(F) = P K$. 


*

*Define $ \phi^K (x) = \int\limits_K \phi(k^{-1}xk)  d k,$

*Define $ A\phi^K(m) = \Delta_P(m)^{1/2} \int\limits_{N} \phi^K(mn)d n$  for $m \in M$

*Then we have that $A\phi^K \in C_c^\infty(M)$ and the formula
$$ tr \pi_0(\phi) = tr \pi( A \phi^K).$$


The same formula is also useful, if the representation is not irreducible (unitarizability is not really an issue, and admissibility follows from the Iwasawa decomposition), but one has to normalize and decompose according to the $K$-isotypes.
So in your situation, you get a Fourier transform of $A \phi^K$. This in addition with Moshe Adrian answer computes all the irreducible, unitary principal series representation, at least in prinicple. 
A: First, let us formulate the theorem of Harish-Chandra in a little more precise manner:
it is a priori obvious that the character of $V$ is well-defined as a distribution. Now the theorem says that this distribution is given by a locally $L^1$-function which is well defined and is locally constant on an open dense subset of $G$ (but there is no good way to define
on the whole of $G$). For example for principal series the function will be well defined
on the open subset of regular semi-simple elements. What you can prove is that if such an element $g$ is not split, then the value of the character of an unramified principal series representation at $g$ is just equal to $0$.
If $g$ is split, then up to conjugacy it lies in the standard split torus and the character
is equal to the Weyl group average of the original character $\chi:T\to {\mathbb C}^*$ 
from which the principal series representation was induced (up to the standard
"$\rho$-shift").
