We show that the degree of Gauss maps on abelian varieties is semicontinuous in families, and we study its jump loci. As an application we obtain that in the case of theta divisors this degree answers the Schottky problem. Our proof computes the degree of Gauss maps by specialization of Lagrangian cycles on the cotangent bundle. We also get similar results for the intersection cohomology of varieties with a finite morphism to an abelian variety; it follows that many components of Andreotti–Mayer loci, including the Schottky locus, are part of the stratification of the moduli space of ppav’s defined by the topological type of the theta divisor.