Analysis and Exploration for New Generation Debuggers Thomas Dupriez, Guillermo Polito, Stéphane Ducasse
Total Page:16
File Type:pdf, Size:1020Kb
Analysis and exploration for new generation debuggers Thomas Dupriez, Guillermo Polito, Stéphane Ducasse To cite this version: Thomas Dupriez, Guillermo Polito, Stéphane Ducasse. Analysis and exploration for new generation debuggers. International Workshop on Smalltalk Technology IWST’17, Sep 2017, Maribor, Slovenia. pp.5:1–5:6, 10.1145/3139903.3139910. hal-01585338 HAL Id: hal-01585338 https://hal.archives-ouvertes.fr/hal-01585338 Submitted on 11 Sep 2017 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Analysis and exploration for new generation debuggers Thomas Dupriez Guillermo Polito Stephane´ Ducasse ENS Paris-Saclay - RMoD, Inria RMoD - Univ. Lille, CNRS, Centrale RMoD, Inria Lille-Nord Europe Lille-Nord Europe Lille, Inria, UMR 9189 - CRIStAL - [email protected] [email protected] Centre de Recherche en Informatique Signal et Automatique de Lille, F-59000 Lille, France [email protected] Abstract offer a different perspective to this problem: it should be Locating and fixing bugs is a well-known time consuming possible to adapt a debugger to a given domain or task. task. Advanced approaches such as object-centric or back- In this position paper we motivate the need to mature and in-time debuggers have been proposed in the literature, still develop more advanced techniques by showing a complex in many scenarios developers are left alone with primitive debugging scenario obtained from a real use case. We then tools such as manual breakpoints and execution stepping. explore several promising advanced debugging techniques In this position paper we explore several advanced on-line and analyse the key challenges they pose: debugging techniques such as advanced breakpoints and on- Advanced Breakpoints. What if a developer had the poten- line execution comparison, that could help developers solve tial to create new smart breakpoints? What would be such complex debugging scenarios. We analyse the challenges breakpoints? What kind of runtime information should and underlying mechanisms required by these techniques. they have access to to be both useful and efficient? We present some early but promising prototypes we built on Execution Comparison. What if a developer could, after the Pharo programming language. We finally identify future modifying his codebase and breaking some tests, com- research paths by analysing existing research and connecting pare the executions of the program before the change and it to the techniques we presented before. after the change to find the cause of the bug? What would Keywords Debugger, Tool, Stack, Breakpoint, Watchpoint be the infrastructure required for this technique? What are the tools we could provide to a developer to perform 1. Introduction this task? Identifying and fixing bugs is an important task in soft- Accessing Execution History. Back-in-time debuggers are ware development. It is also well-known that this is a nowadays the referent debuggers to navigate history. time-consuming activities [Som01, Zel05]. Several works However, many questions remain still open. What would have been proposed to help developers with such compli- be a both a practical and efficient solution? What are the cated task. Automatic validation of conditions [LHS99] and alternatives to store both the execution and the objects in watchpoints [ADRC17] help developers to spot divergences the program’s state? How can we navigate the program from the expected program execution. Back-in-time debug- history to find a bug? gers offer the possibility to navigate the program execu- During our analysis, we also present some promising tion history with several promising research reults [LD03, ideas like the possibility of scripting the stack navigation. Hof06, PTP07, LGN08]. More recently, object-centric de- Finally we present some prototypes we implemented show- buggers presented advanced stepping mechanisms targetting ing the feasibility of some of them. individual objects [RBN12]. Moldable debuggers [CGN14] 2. Debugging Terminology Debugging is the process of finding and repairing defects in software. Informally, we refer to software defects as bugs, due to the difficulty they may present to be spotted and removed. The main challenge of debugging is to spot bugs i.e., to examine a program and understand what is the exact [Copyright notice will appear here once ’preprint’ option is removed.] cause of the misbehaviour or error. short description of paper 1 2017/6/22 In general, a developer performs such debugging process $ ./pharo Pharo.image test "Pillar.∗" with the aid of a debugger tool, or simply a debugger. [...] Debuggers allow developers to suspend a program execution 3182 run, 3182 passes, 0 failures, 0 errors. to inspect and explore the execution. This includes both observing the execution path and the state of objects existing However, as soon as we introduce the new accessors, 16 in the application. new errors appeared: Mainstream debuggers offer the possibility to suspend the program execution by placing breakpoints. When the pro- $ ./pharo Pharo.image test "Pillar.∗" gram execution arrives to a breakpoint, the execution is sus- [...] 3182 run, 3166 passes, 0 failures, 16 errors pended and the debugger shows to the developer the current state of the execution. This execution is generally shown as Checking the tests, we observe that the bug happens in an a stack trace. A stack trace is a sequence of methods exe- apparently unrelated piece of code, the cutions (usually called contexts or stack frames). In such a PREPubMenuJustHeaderTransformer>>actionOn: method. sequence, the context that precedes another context is called The symptom of the bug is that outputType is nil. However, its caller or sender. This sequence represents then a pro- this piece of failing code plus the fact that 3166 tests are still gram execution path from a first context until a context with working, give us no clue about the relation with the change a breakpoint. We call the first context of the program its en- and the bug. try point. In most programming languages, a program entry point is the first execution of the main function of a thread. In PREPubMenuJustHeaderTransformer>>actionOn: anInput Pharo, a program entry point is the first context of a Process, ^ (self class writers usually executing the Block>>#newProcess method. includes: anInput configuration outputType writerName) ifTrue: [ maxHeader := self maxHeaderOf: anInput input. The utility of the stack trace is twofold. On the one hand, super actionOn: anInput ] a developer can use it to navigate the execution path and ifFalse: [ anInput ] control flow that led to a problem. On the other hand, he can also use it to inspect previous states of the execution, by In the following sections of this paper, we explore several looking at the execution contexts . advanced debugging techniques that could help us finding the cause of this bug. 3. A Real Complex Debugging Scenario To illustrate why debugging is a complex task and motivate 4. Technique 1: Advanced Breakpoints the need of new debugging techniques, we isolated a real Breakpoints are a very common feature among debuggers. bug that appeared while refactoring the latest versions of They let developers specify a point in a program where the the Pillar markup language[ADCD16]. In this section we execution should be suspended. However, debuggers usually present the issue found and the way to reproduce it. We setup limit breakpoints to a limited set of pre-existing ones such as a repository explaining in details the steps to reproduce the breaking when the program arrives to a particular line. De- bug in https://github.com/guillep/pillar-bug, velopers are not usually capable of tailoring breakpoints to Pillar uses an object called PRPillarConfiguration to some more specific needs. This section presents some ideas manage all project settings e.g., what is the output format, that would increase the expressiveness of breakpoints and whether it needs to numerate sections or not, print a contents allow developers to specify more precise trigger conditions. table or not. PRPillarConfiguration semantics are compli- cated. First, it overrides doesNotUnderstand: [Duc99] to 4.1 Idea 1: Conditional Breakpoints dynamically interpret some message sends as configuration Scenario. The developer debugging Pillar is interested setters or getters. Second, it uses the Magritte [Ren06] meta- in looking at what happens to the problematic actionOn: description framework to control how a configuration values method only when it is called with a specific argument. If should behave by default, be serialized, deserialized, and he places a normal breakpoint in the method, the breakpoint validated. Finally, a PRConfiguration is organised in a hi- will trigger no matter the argument and he will have to check erarchy of configurations, and some operations may lookup himself whether the arguments are those he is interested in. settings in the hierarchy of the configuration while others do not. Idea. The developer could place a conditional breakpoint Given