diff --git a/Secciones/background.tex b/Secciones/background.tex index 870e7a6..e3e65e5 100644 --- a/Secciones/background.tex +++ b/Secciones/background.tex @@ -41,7 +41,7 @@ The different variations are described later in this chapter, but there exist tw There also exists a middle-ground approach called \textit{chopping} \cite{JacR94}, which is used to find all the statements that affect some variables in the slicing criterion and at the same time they are affected by some other variables in the slicing criterion. \end{itemize} -Since the seminal definition of program slicing by Weiser \cite{Wei81}, the most studied variation of slicing has been \textit{static backward slicing}, which has been defined in previous sections of this thesis. +Since the seminal definition of program slicing by Weiser \cite{Wei81}, the most studied variation of slicing has been \textit{static backward slicing}, which has been informally defined at the beginning of this section and on Section~\ref{sec:motivation}. That definition can be split in two sub-types, \textit{strong} and \textit{weak} slices, with different levels of requirements and uses in different fields. First, though, we need to introduce and additional concept: the sequence of values. \begin{definition}[Sequence of values \cite{PerST19}] @@ -97,7 +97,6 @@ Along the thesis, we indicate which kind of slice is produced with each problem \begin{table} \centering - \label{tab:slice-weak} \begin{tabular}{r | r | r | r | r | r } % Evaluation Number & \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4} & \textbf{5} \\ \hline Original program & 1 & 2 & 6 & - & - \\ \hline @@ -106,6 +105,7 @@ Along the thesis, we indicate which kind of slice is produced with each problem Slice C & 1 & 1 & 1 & 1 & 1 \\ \end{tabular} \caption{Sequence of values obtained for a certain variable of the original program and three different slices A, B and C for a particular input.} + \label{tab:slice-weak} \end{table} \end{example} @@ -136,7 +136,7 @@ Once the second pass has finished, all the nodes visited form the slice. \begin{figure}[h] \begin{lstlisting} void main() { - multiply(3, 2); + multiply(2, 3); } int multiply(int x, int y) { diff --git a/Secciones/problem_solution.tex b/Secciones/problem_solution.tex index 661b467..0f6d340 100644 --- a/Secciones/problem_solution.tex +++ b/Secciones/problem_solution.tex @@ -86,7 +86,7 @@ public void f() { Now consider statement \texttt{C} (line 11) as the slicing criterion. Figure~\ref{fig:problem-break-sub-sdg} displays the SDG produced for the program, and the nodes selected by the slice. Figure~\ref{fig:problem-break-sub} displays the computed slice on the centre, and one of the minimal slices on the left. The inner \texttt{break} on line 6 and the \texttt{if} surrounding it have been unnecessarily included. Their inclusion would not be specially problematic, if it were not for the condition of the \texttt{if} statement, which may include extra data dependencies that are unnecessary in the slice and that may lead to include other unnecessary statements, making the slice even more imprecise. - Line 6 is not useful because regardless of whether it executes, the execution will continue on line 13 (after the \texttt{while}), as guaranteed by the other \texttt{break} statement on line 9, which is not guarded by any condition. Note that \texttt{B} is still control-dependent on line \josep{6\deleted{5}}, as it has a direct effect on it, but the dependence between both \texttt{break} statements introduces useless statements into the slice. + Line 6 is not useful because regardless of whether it executes, the execution will continue on line 13 (after the \texttt{while}). Once the execution flow has reached line 4, either \texttt{break} on line 6 or 9 will be executed, depending on the evaluation of \texttt{Z}. Note that \texttt{B} is still control-dependent on line \josep{6\deleted{5}}, as it has a direct effect on it, but the dependence between both \texttt{break} statements introduces useless statements into the slice. \begin{figure}[h] \centering @@ -124,7 +124,7 @@ In the context of weak slicing, as shown in chapter \ref{cha:incremental}, the s \begin{minipage}{0.33\linewidth} \begin{lstlisting} void g() { - int x = 0; + int x = 1; while (x > 0) { if (x > 10) break; @@ -137,7 +137,7 @@ void g() { \begin{minipage}{0.33\linewidth} \begin{lstlisting} void g() { - int x = 0; + int x = 1; while (x > 0) { if (x > 10) break; @@ -150,7 +150,7 @@ void g() { \begin{minipage}{0.33\linewidth} \begin{lstlisting} void g() { - int x = 0; + int x = 1; while (x > 0) { @@ -238,7 +238,7 @@ f(); \end{lstlisting} \end{minipage} \begin{minipage}{0.49\linewidth} - \begin{lstlisting} + \begin{lstlisting}[firstnumber=last] void f() throws Exception { if (x % 2 != 0) throw new Exception(); @@ -250,7 +250,7 @@ void f() throws Exception { \label{fig:incorrect-try-catch-code} \end{figure} - Figure~\ref{fig:incorrect-try-catch-graph} displays the program dependence graph for the snippet of code on the left side of Figure~\ref{fig:incorrect-try-catch-code}. The PDG of \texttt{f} is not shown for simplicity. The set of nodes filled in grey represent the slice with respect to the slicing criterion $\langle 4, x \rangle$ in \texttt{f}. In the slice, both calls to \texttt{f} and its input (\texttt{x\_in = x}) are included, but the \texttt{catch} block is not present. The execution of the slice may not be the same: if no exception is thrown, there is no change; but if \texttt{x} was odd before entering the snippet, an exception would be thrown and not caught, exiting the program prematurely. + Figure~\ref{fig:incorrect-try-catch-graph} displays the program dependence graph for the snippet of code on the left side of Figure~\ref{fig:incorrect-try-catch-code}. The PDG of \texttt{f} is not shown for simplicity. The set of nodes filled in grey represent the slice with respect to the slicing criterion $\langle 11, x \rangle$ in \texttt{f}. In the slice, both calls to \texttt{f} and its input (\texttt{x\_in = x}) are included, but the \texttt{catch} block is not present. The execution of the slice may not be the same: if no exception is thrown, there is no change; but if \texttt{x} was odd before entering the snippet, an exception would be thrown and not caught, exiting the program prematurely. \begin{figure}[h] \centering