[Lldb-commits] [PATCH] D126013: Add [opt] suffix to optimized stack frame in lldb-vscode
jeffrey tan via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon May 23 10:03:42 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46c1f77e160a: Add [opt] suffix to optimized stack frame in lldb-vscode (authored by yinghuitan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126013/new/
https://reviews.llvm.org/D126013
Files:
lldb/test/API/tools/lldb-vscode/optimized/Makefile
lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py
lldb/test/API/tools/lldb-vscode/optimized/main.cpp
lldb/tools/lldb-vscode/JSONUtils.cpp
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -751,7 +751,19 @@
llvm::json::Object object;
int64_t frame_id = MakeVSCodeFrameID(frame);
object.try_emplace("id", frame_id);
- EmplaceSafeString(object, "name", frame.GetFunctionName());
+
+ std::string frame_name;
+ const char *func_name = frame.GetFunctionName();
+ if (func_name)
+ frame_name = func_name;
+ else
+ frame_name = "<unknown>";
+ bool is_optimized = frame.GetFunction().GetIsOptimized();
+ if (is_optimized)
+ frame_name += " [opt]";
+ EmplaceSafeString(object, "name", frame_name);
+ object.try_emplace("optimized", is_optimized);
+
int64_t disasm_line = 0;
object.try_emplace("source", CreateSource(frame, disasm_line));
Index: lldb/test/API/tools/lldb-vscode/optimized/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/optimized/main.cpp
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <string>
+
+int foo(int x, int y) {
+ printf("Got input %d, %d\n", x, y);
+ return x + y + 3; // breakpoint 1
+}
+
+int main(int argc, char const *argv[]) {
+ int optimized = argc > 1 ? std::stoi(argv[1]) : 0;
+
+ printf("argc: %d, optimized: %d\n", argc, optimized);
+ int result = foo(argc, 20);
+ printf("result: %d\n", result); // breakpoint 2
+ return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py
===================================================================
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py
@@ -0,0 +1,35 @@
+"""
+Test lldb-vscode variables/stackTrace request for optimized code
+"""
+
+from __future__ import print_function
+
+import unittest2
+import vscode
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbvscode_testcase
+
+
+class TestVSCode_optimized(lldbvscode_testcase.VSCodeTestCaseBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows
+ @skipIfRemote
+ def test_stack_frame_name(self):
+ ''' Test optimized frame has special name suffix.
+ '''
+ program = self.getBuildArtifact("a.out")
+ self.build_and_launch(program)
+ source = 'main.cpp'
+ breakpoint_line = line_number(source, '// breakpoint 1')
+ lines = [breakpoint_line]
+ breakpoint_ids = self.set_source_breakpoints(source, lines)
+ self.assertEqual(len(breakpoint_ids), len(lines),
+ "expect correct number of breakpoints")
+ self.continue_to_breakpoints(breakpoint_ids)
+ leaf_frame = self.vscode.get_stackFrame(frameIndex=0)
+ self.assertTrue(leaf_frame['name'].endswith(' [opt]'))
+ parent_frame = self.vscode.get_stackFrame(frameIndex=1)
+ self.assertTrue(parent_frame['name'].endswith(' [opt]'))
Index: lldb/test/API/tools/lldb-vscode/optimized/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/optimized/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -O3 -glldb
+include Makefile.rules
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126013.431418.patch
Type: text/x-patch
Size: 3309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220523/47f74b78/attachment.bin>
More information about the lldb-commits
mailing list