On Context Switching in Spectrum-Based Fault Localization

Roland Aszmann, Attila Péter Soha, Gergő Balogh, Árpád Beszédes and Tibor Gyimóthy
Spectrum-Based Fault Localization (SBFL) helps developers identify faulty code by ranking suspicious elements based on test outcomes and code coverage. In this paper, we examine the impact of context switching—when developers must shift their attention between different parts of the code, such as methods and classes—while traversing the ranked list of suspicious elements. Our study is motivated by the observation that investigating statements located close to each other often requires less effort than switching between distant code locations. To better capture this cost, we introduce a context-aware measure that estimates the effort of fault localization based on the number and frequency of method and class switches. Unlike traditional metrics that consider only the number of examined statements, our measure accounts for the additional burden introduced by context switches. We propose novel algorithms that reorder the ranked list to minimize context switching. Our approach includes context-aware tie-breaking and a carefully designed ordering of classes, methods, and statements for inspection. Experiments on the Defects4J benchmark demonstrate that our technique reduces method and class switches by up to 54%, and also lowers the number of statements investigated—by 15% using the traditional metric and up to 38% using the context-aware metric. Our technique is implemented in a publicly available experimentation framework, enabling configuration of algorithm parameters and exploration of alternative variants for adaptation to different subject systems and scenarios.

Keywords: Debugging, fault localization, spectrum-based fault localization, SBFL cost metrics, task switching, context switching.
Back