How to calculate $Ri^!$? Given a locally compact (Hausdorff) space $X$ and an open subset $U\subseteq X$ with complement $Z=X\setminus U$. Denote $i\colon Z\to X$ and $j\colon U\to X$ canonical inclusions. $j_*\colon\mathbf{Sh}(U)\to\mathbf{Sh}(X)$ is the direct image, and $i^!\colon\mathbf{Sh}(X)\to\mathbf{Sh}(Z)$ is the exceptional inverse image. Given a sheaf $\mathcal F$ on $X$, I want to know how to calculate $Ri^!(\mathcal F)$, where $Ri^!\colon\mathbf D(X)\to\mathbf D(Z)$ is the right derived functor of $i^!$. I'm most interested in the special case when $\mathcal F=M$ is a constant sheaf.
The higher direct image $Rj_*$ is more manageable: choose an injective resolution $\mathcal G\to\mathcal I^\bullet$ on $U$, we have $R^mj_*(\mathcal G)=H^m(j_*(\mathcal I^\bullet))$, which is associated to presheaf $$V\mapsto H^m\Gamma(V,j_*(\mathcal I^\bullet))=H^m\Gamma(j^{-1}(V),\mathcal I^\bullet)=H^m(j^{-1}(V),\mathcal G)$$
Moreover, the complex $Rj_*$ could be determined stalk-wise: for $x\in X$, denote $i_x\colon\{x\}\to X$ the inclusion,
$$i_x^{-1}Rj_*(\mathcal G)^\bullet=i_x^{-1}j_*(\mathcal I^\bullet)=\varinjlim_{V\ni x}\Gamma(V,j_*(\mathcal I^\bullet))=\varinjlim_{V\ni x}\Gamma(f^{-1}(V),\mathcal I^\bullet)=\varinjlim_{V\ni x}R\Gamma(f^{-1}(U),\mathcal G)^\bullet$$
The same trick will lead to a reduction of $R^mi^!(\mathcal F)$ to the sheaf associated to $V\mapsto\operatorname{Ext}^m(i_*(\mathbb Z_V),\mathcal F)$, but the later one doesn't seem computable.
Take the simplest case, if $X$ is a differentiable manifold of dimension $n$ and $Z$ is a point, $\mathcal F=\mathbb Z$ is a constant sheaf. I cannot see how the formula above leads to anything easier.
 A: The main tools at your disposal are duality and the localization triangles.
I come from algebraic geometry where everything is orientable and there is a factor 2 between dimension and cohomological degree, so I hope I will not make any mistakes.
The localization triangles are the following :
$$ i_*Ri^!\longrightarrow 1\longrightarrow Rj_*j^{-1}\overset{+1}\longrightarrow$$
The morphisms being the counit and the unit of adjunction. Moreover, the cone of $1\rightarrow Rj_*j^{-1}$ is unique up to unique isomorphism in this case (this is because it has support on $Z$ and there are no morphism from a complex with support on $Z$ and a complex of the form $Rj_*C$). Thus, the object $i_*Ri^!C$ is uniquely determined by $C\rightarrow Rj_*j^{-1}C$. Applying $i^{-1}$ on the left gives
$$ Ri^!\longrightarrow i^{-1}\longrightarrow i^{-1}Rj_*j^{-1}\overset{+1}\longrightarrow$$
These triangles give rise to long exact sequences which might give you some informations about $Ri^!$.
For example, if $X$ is a nice (paracompact and locally contractible) topological space and $Z=\{x\}$ a point, then the first triangle give rise to the long exact sequence in cohomology
$$H^n(X,X\setminus\{x\})\longrightarrow H^n(X)\longrightarrow H^n(X\setminus\{x\})\longrightarrow H^{n+1}$$
The first group is indeed $H^n(Ri^!\mathbb{Z})$. Of course, you can replace $X$ by any neighborhood of $x$. You can even go to the limit, this is essentially what gives the second distinguished triangle.
For example, if $X$ is a manifold of dimension $n$, replacing $X$ by an open ball around $x$, you get $Ri^!\mathbb{Z}=\mathbb{Z}[-n]$.
Another example : if $x$ is a singular point in a surface which look locally like the union of two planes in $\mathbb{R}^4$ having a single point of intersection, then $Ri^!\mathbb{Z}\simeq\mathbb{Z}[-1]\oplus\mathbb{Z}[-2]\oplus\mathbb{Z}[-2]$. 
The equality $Ri^!\mathbb{Z}=\mathbb{Z}[-n]$ (when $Z$ is a point in a manifold) also follows from Poincaré duality. More generally, if $Z$ is an orientable submanifold of codimension $c$ in a manifold $X$ of dimension $n$. Assume moreover that $Z$ has an orientable tubular neighborhood in $X$, then $Ri^!\mathbb{Z}=\mathbb{Z}[-c]$. Indeed, replace $X$ by the tubular neighborhood and let $p:X\rightarrow\{*\}$ be the projection. Then $Rp^!\mathbb{Z}=\mathbb{Z}[n]$ by Poincaré duality. Similarly, $Ri^!Rp^!\mathbb{Z}=\mathbb{Z}[n-c]$. So $Ri^!\mathbb{Z}[n]=\mathbb{Z}[n-c]$, hence the result.
