What you need is

\resetcounteronoverlays{lstlisting}


to prevent the counter from incrementing when using overlays. The complete code:

\documentclass{beamer}
\usetheme{Goettingen}
%\usecolortheme{whale}

\setbeamertemplate{frametitle continuation}[from second] % (cont.) from second slide
\setbeamertemplate{bibliography item}{[\theenumiv]} % numbers instead of silly pictures
\setbeamertemplate{footline}[frame number]
\beamertemplatenavigationsymbolsempty % remove navigationbar

\usepackage[font=bf,skip=\baselineskip]{caption}
\captionsetup[lstlisting]{font={footnotesize}}

\usepackage{color}
\definecolor{light-gray}{gray}{0.85}
\definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0} % for green colour in code
\usepackage{listings}
\usepackage[T1]{fontenc}
\lstset{
    basicstyle=\tiny,
    escapeinside={&lt;@}{@&gt;},
    numbers=left, 
    language=C, 
    morekeywords={throw, assert},
    frame=single,
    captionpos=b,
    commentstyle=\color{darkgreen}}

\resetcounteronoverlays{lstlisting}

\begin{document}
\begin{frame}[fragile,containsverbatim]{Example}
    \begin{lstlisting}[caption={Function}]
functionA(x){
  a = functionB(x)
  return a
}

functionB(x){
  b =  &lt;@\only&lt;1&gt;{GLOBAL\_VAR}\only&lt;2&gt;{\textcolor{darkgreen}{GLOBAL\_VAR}}@&gt;
  b++
  return b
}
    \end{lstlisting}
\end{frame}

\end{document}


The result:



beamer + lstlistings + overlay -> wrong numbering in caption
I want to extract all metadata information attached to a instruction.  I tried to extract this information using getAllMetadata. 

Can someone explain me why the following code doesn't print the name for the metadata nodes?

Note: I is an instruction 

.
.
.
I-&gt;getAllMetadata(MDForInst);

for(SmallVector&lt;std::pair&lt;unsigned, MDNode*&gt;, 4&gt;::iterator II = MDForInst.begin(),
                      EE = MDForInst.end(); II !=EE; ++II){

      outs()&lt;&lt;"name: "&lt;&lt; II-&gt;second-&gt;getName() &lt;&lt; "\n";

}
.
.
.

