This is an archive of the discontinued LLVM Phabricator instance.

Make TestStepNodebug more robust against codegen changes
AbandonedPublic

Authored by aprantl on Jun 9 2023, 10:04 AM.

Details

Summary

Depending on the compiler I've seen that for example the step-in command can do a column-step first before exiting out of the function:

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003d80 a.out`called_from_nodebug_actual(some_value=5) at with-debug.
c:10:10
   2    
   3    typedef int (*debug_callee) (int);
   4    
   5    extern int no_debug_caller (int, debug_callee);
   6    
   7    int called_from_nodebug_actual(int some_value) {
   8      int return_value = 0;
   9      return_value = printf("Length: %d.\n", some_value);
-> 10     return return_value; // Stop here and step out of me
                 ^
   11   }
   12   
   13   int called_from_nodebug(int some_value) {
   14     int intermediate_return_value = 0;
   15     intermediate_return_value = called_from_nodebug_actual(some_value);
   16     return intermediate_return_value;
   17   }
   18
Process 58672 launched: '/Volumes/Data/llvm-project/_build.ninja.release/lldb-test-build.noindex/functionalities/step-avoids-no-debug/TestStepNoDebug.test_step_out_with_python_dsym/a.out' (arm64)
(lldb) s
Process 58672 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x0000000100003d8c a.out`called_from_nodebug_actual(some_value=5) at with-debug.c:10:3
   2    
   3    typedef int (*debug_callee) (int);
   4    
   5    extern int no_debug_caller (int, debug_callee);
   6    
   7    int called_from_nodebug_actual(int some_value) {
   8      int return_value = 0;
   9      return_value = printf("Length: %d.\n", some_value);
-> 10     return return_value; // Stop here and step out of me
          ^
   11   }
   12

Diff Detail

Event Timeline

aprantl created this revision.Jun 9 2023, 10:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 10:04 AM
aprantl requested review of this revision.Jun 9 2023, 10:04 AM
lldb) image dump line-table with-debug.c
Line table for /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c in `a.out
0x0000000100003d4c: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:7
0x0000000100003d5c: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:8:7
0x0000000100003d60: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:9:42
0x0000000100003d68: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:9:18
0x0000000100003d7c: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:9:16
0x0000000100003d80: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:10:10
0x0000000100003d84: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:10:3
0x0000000100003d90: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:13
0x0000000100003da0: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:14:7
0x0000000100003da4: /Volumes/Data/llvm-project/lldb/test/API/functionalities/step-avoids-no-debug/with-debug.c:15:58
aprantl abandoned this revision.Jun 9 2023, 2:37 PM

According to an offline conversation with @jingham this is still not the expected behavior from the stepping engine.