Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Conversation

@zanderso
Copy link
Member

@zanderso zanderso commented May 6, 2024

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to test this beforehand, but the idea that this fixes the linked issue is very credible.

@zanderso
Copy link
Member Author

zanderso commented May 6, 2024

@gaaclarke I'll probably land this either way so that we can be following the same best practices as in the Dart build, but since I'm not set up to fire up the vscode debugger, if you have time to patch this in and take it for a spin, that would be helpful.

@gaaclarke
Copy link
Member

Can do, give me a minute.

@gaaclarke
Copy link
Member

I was looking around how to verify the paths with commandline tools in macos. I was unable to find a way to reliably do it. Let me know if you know of a way.

@gaaclarke
Copy link
Member

This didn't work for me. I still get /b/f/w/...

Here's what I did:

git apply 852.patch
gclient sync -D
rm -rf out/host_debug_unopt_arm64
./flutter/tools/gn --runtime-mode=debug --unoptimized --mac-cpu=arm64 --no-lto --use-glfw-swiftshader
./flutter/bin/et build -c host_debug_unopt_arm64 //flutter/impeller:impeller_unittests

@gaaclarke
Copy link
Member

I figured out how one can verify if the paths are correct (or incorrect in this case, see /b/w/f/ paths below):

lldb out/host_debug_unopt_arm64/impeller_unittests
(lldb) image lookup -vn impeller::Canvas::Save
2 matches found in /Users/aaclarke/dev/engine/src/out/host_debug_unopt_arm64/impeller_unittests:
        Address: impeller_unittests[0x00000001034d74b0] (impeller_unittests.__TEXT.__text + 55402976)
        Summary: impeller_unittests`impeller::Canvas::Save(bool, unsigned int, impeller::BlendMode, std::_fl::shared_ptr<impeller::ImageFilter> const&) at canvas.cc:222
         Module: file = "/Users/aaclarke/dev/engine/src/out/host_debug_unopt_arm64/impeller_unittests", arch = "arm64"
    CompileUnit: id = {0x00000000}, file = "/b/f/w/flutter/impeller/aiks/canvas.cc", language = "<not loaded>"
       Function: id = {0x7fc000ee8a5}, name = "impeller::Canvas::Save(bool, unsigned int, impeller::BlendMode, std::_fl::shared_ptr<impeller::ImageFilter> const&)", mangled = "_ZN8impeller6Canvas4SaveEbjNS_9BlendModeERKNSt3_fl10shared_ptrINS_11ImageFilterEEE", range = [0x00000001034d74b0-0x00000001034d7780)
       FuncType: id = {0x7fc000ee8a5}, byte-size = 0, decl = canvas.h:213, compiler_type = "void (_Bool, uint32_t, enum impeller::BlendMode, const class std::shared_ptr<class impeller::ImageFilter> &)"
         Blocks: id = {0x7fc000ee8a5}, range = [0x1034d74b0-0x1034d7780)
      LineEntry: [0x00000001034d74b0-0x00000001034d74f4): /b/f/w/flutter/impeller/aiks/canvas.cc:222
         Symbol: id = {0x000acf25}, range = [0x00000001034d74b0-0x00000001034d7780), name="impeller::Canvas::Save(bool, unsigned int, impeller::BlendMode, std::_fl::shared_ptr<impeller::ImageFilter> const&)", mangled="_ZN8impeller6Canvas4SaveEbjNS_9BlendModeERKNSt3_fl10shared_ptrINS_11ImageFilterEEE"
       Variable: id = {0x7fc000ee922}, name = "this", type = "impeller::Canvas *", valid ranges = <block>, location = DW_OP_breg31 WSP+152, decl = 
       Variable: id = {0x7fc000ee930}, name = "create_subpass", type = "bool", valid ranges = <block>, location = DW_OP_breg31 WSP+151, decl = canvas.cc:219
       Variable: id = {0x7fc000ee93f}, name = "total_content_depth", type = "uint32_t", valid ranges = <block>, location = DW_OP_breg31 WSP+144, decl = canvas.cc:220
       Variable: id = {0x7fc000ee94e}, name = "blend_mode", type = "BlendMode", valid ranges = <block>, location = DW_OP_breg31 WSP+143, decl = canvas.cc:221
       Variable: id = {0x7fc000ee95d}, name = "backdrop_filter", type = "const std::_fl::shared_ptr<impeller::ImageFilter> &", valid ranges = <block>, location = DW_OP_breg31 WSP+128, decl = canvas.cc:222
       Variable: id = {0x7fc000ee96c}, name = "entry", type = "CanvasStackEntry", valid ranges = <block>, location = DW_OP_fbreg -136, decl = canvas.cc:223
        Address: impeller_unittests[0x00000001034d7414] (impeller_unittests.__TEXT.__text + 55402820)
        Summary: impeller_unittests`impeller::Canvas::Save(unsigned int) at canvas.cc:184
         Module: file = "/Users/aaclarke/dev/engine/src/out/host_debug_unopt_arm64/impeller_unittests", arch = "arm64"
    CompileUnit: id = {0x00000000}, file = "/b/f/w/flutter/impeller/aiks/canvas.cc", language = "c++14"
       Function: id = {0x7fc000efdbc}, name = "impeller::Canvas::Save(unsigned int)", mangled = "_ZN8impeller6Canvas4SaveEj", range = [0x00000001034d7414-0x00000001034d74b0)
       FuncType: id = {0x7fc000efdbc}, byte-size = 0, decl = canvas.h:79, compiler_type = "void (uint32_t)"
         Blocks: id = {0x7fc000efdbc}, range = [0x1034d7414-0x1034d74b0)
      LineEntry: [0x00000001034d7414-0x00000001034d7440): /b/f/w/flutter/impeller/aiks/canvas.cc:184
         Symbol: id = {0x000acec5}, range = [0x00000001034d7414-0x00000001034d74b0), name="impeller::Canvas::Save(unsigned int)", mangled="_ZN8impeller6Canvas4SaveEj"
       Variable: id = {0x7fc000efdd6}, name = "this", type = "impeller::Canvas *", valid ranges = <block>, location = DW_OP_breg31 WSP+32, decl = 
       Variable: id = {0x7fc000efde3}, name = "total_content_depth", type = "uint32_t", valid ranges = <block>, location = DW_OP_breg31 WSP+28, decl = canvas.cc:184

@gaaclarke
Copy link
Member

I tried from command line lldb too to make sure it isn't just a vscode thing. The symbolic breakpoints will hit, but when issuing 'l' commands the source isn't listed.

@zanderso
Copy link
Member Author

zanderso commented May 6, 2024

Hmm. With the patch, when I run that command in lldb (image lookup -vn impeller::Canvas::Save), the output no longer contains paths with the /b/f/w/, and instead are relative paths. Without the patch, I see the /b/f/w/ still. Not sure why it works on my machine and not yours, but since this patch is probably the right thing to do anyway, I'll go ahead and land it after a little more testing.

@gaaclarke
Copy link
Member

Wait, when I tried to test this, the gclient sync seems to have thrown away the change. With the change now I get

.debug_info contents:
0x00000000: Compile Unit: length = 0x0003c0eb, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0003c0ef)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("Fuchsia clang version 18.0.0 (https://llvm.googlesource.com/llvm-project 725656bdd885483c39f482a01ea25d67acf39c46)")
              DW_AT_language    (DW_LANG_C_plus_plus_14)
              DW_AT_name        ("../../flutter/impeller/base/base_unittests.cc")
              DW_AT_LLVM_sysroot        ("../../flutter/prebuilts/SDKs/MacOSX14.4.sdk")
              DW_AT_APPLE_sdk   ("MacOSX14.4.sdk")
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("set_by_reclient/a")
              DW_AT_low_pc      (0x00000001000012d0)
              DW_AT_ranges      (0x00000b70
                 [0x00000001000012d0, 0x0000000100030774))

So it worked in changing DW_AT_comp_dir, but I think we may need to use "/b/f/w/set_by_reclient/a"="".

@gaaclarke
Copy link
Member

@zanderso make sure you are using macOS too. Jason has reported that it seems to work fine on linux without this patch.

@gaaclarke
Copy link
Member

gaaclarke commented May 6, 2024

When using the following patch to this PR I get the following different results:

--- a/build/config/gcc/BUILD.gn
+++ b/build/config/gcc/BUILD.gn
@@ -63,7 +63,7 @@ config("relative_paths") {
   # option to keep all source file name references uniformly relative to
   # a single root.
   if (use_rbe) {
-    absolute_path = "/b/f/w/"
+    absolute_path = "/b/f/w/set_by_reclient/a"
   } else {
     absolute_path = rebase_path("//")
   }
Screenshot 2024-05-06 at 4 25 06 PM
.debug_info contents:
0x00000000: Compile Unit: length = 0x0003c0e7, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0003c0eb)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("Fuchsia clang version 18.0.0 (https://llvm.googlesource.com/llvm-project 725656bdd885483c39f482a01ea25d67acf39c46)")
              DW_AT_language    (DW_LANG_C_plus_plus_14)
              DW_AT_name        ("../../flutter/impeller/base/base_unittests.cc")
              DW_AT_LLVM_sysroot        ("../../flutter/prebuilts/SDKs/MacOSX14.4.sdk")
              DW_AT_APPLE_sdk   ("MacOSX14.4.sdk")
              DW_AT_stmt_list   (0x00000000)
              DW_AT_low_pc      (0x00000001000012d0)
              DW_AT_ranges      (0x00000b70
                 [0x00000001000012d0, 0x0000000100030774))

@zanderso
Copy link
Member Author

zanderso commented May 6, 2024

Yeah, I'm on my arm64 mac.

@gaaclarke
Copy link
Member

gaaclarke commented May 6, 2024

Using "/b/f/w/set_by_reclient/a" for the prefix fixes using lldb from the commandline. It just doesn't work in VSCode.

(lldb) target create "impeller_unittests"
Current executable set to '/Users/aaclarke/dev/engine/src/out/host_debug_unopt_arm64/impeller_unittests' (arm64).
(lldb) b impeller::Canvas::Save
Breakpoint 1: 2 locations.
(lldb) run --gtest_filter="*CanRenderOffscreenCheckerboard*Metal" --enable_playground
Process 48104 launched: '/Users/aaclarke/dev/engine/src/out/host_debug_unopt_arm64/impeller_unittests' (arm64)
[INFO:flutter/testing/run_all_unittests.cc(64)] Debugger is attached. Suspending test timeouts.
Note: Google Test filter = *CanRenderOffscreenCheckerboard*Metal
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Play/AiksTest
[ RUN      ] Play/AiksTest.CanRenderOffscreenCheckerboard/Metal
Process 48104 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001034d74f4 impeller_unittests`impeller::Canvas::Save(this=0x000000016fdfe2b8, create_subpass=true, total_content_depth=16777216, blend_mode=kMultiply, backdrop_filter=0x000000016fdfe278) at canvas.cc:223:33
   220 	                  uint32_t total_content_depth,
   221 	                  BlendMode blend_mode,
   222 	                  const std::shared_ptr<ImageFilter>& backdrop_filter) {
-> 223 	  auto entry = CanvasStackEntry{};
   224 	  entry.transform = transform_stack_.back().transform;
   225 	  entry.cull_rect = transform_stack_.back().cull_rect;
   226 	  entry.clip_height = transform_stack_.back().clip_height;
Target 0: (impeller_unittests) stopped.

@gaaclarke
Copy link
Member

I think maybe we can get this working by doing something like --fdebug-prefix-map="/b/f/w/set_by_reclient/a"=$SRC_PATH/out/host_debug_unopt_arm64. Instead of relying on relative paths, remap it to the local absolute path. Would that mess up the caching mechanism of RBE though? VSCode doesn't seem to like relative paths. I would be curious to do a local build and look at the debugger symbols to see how those work.

@zanderso
Copy link
Member Author

zanderso commented May 6, 2024

Right, we can't put an absolute path on the command line because it will either mess with the dependency scanner or the caching, probably both.

@gaaclarke
Copy link
Member

gaaclarke commented May 6, 2024

@zanderso Can you verify that you are getting /b/f/w/ as your DW_AT_comp_dir, not /b/f/w/set_by_reclient/a? The proper test would be the breakpoint one I've shown in #852 (comment), the lookup test in #852 (comment) may look right but not behave correctly.

@gaaclarke
Copy link
Member

I created a local build to see what it's debugger symbols say, here are the results:

impeller_unittests.dSYM/Contents/Resources/DWARF/impeller_unittests:    file format Mach-O arm64

.debug_info contents:
0x00000000: Compile Unit: length = 0x0003c0eb, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0003c0ef)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("Fuchsia clang version 18.0.0 (https://llvm.googlesource.com/llvm-project 725656bdd885483c39f482a01ea25d67acf39c46)")
              DW_AT_language    (DW_LANG_C_plus_plus_14)
              DW_AT_name        ("../../flutter/impeller/base/base_unittests.cc")
              DW_AT_LLVM_sysroot        ("../../flutter/prebuilts/SDKs/MacOSX14.4.sdk")
              DW_AT_APPLE_sdk   ("MacOSX14.4.sdk")
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("out/host_debug_unopt_arm64")
              DW_AT_low_pc      (0x0000000100001300)
              DW_AT_ranges      (0x00000b70
                 [0x0000000100001300, 0x00000001000307a4))

I think that means we can do --fdebug-prefix-map="/b/f/w/set_by_reclient/a"=out/host_debug_unopt_arm64?

@gaaclarke
Copy link
Member

gaaclarke commented May 7, 2024

I ran with the following diff

diff --git a/build/config/gcc/BUILD.gn b/build/config/gcc/BUILD.gn
index f4c1aa3..6aa2e7a 100644
--- a/build/config/gcc/BUILD.gn
+++ b/build/config/gcc/BUILD.gn
@@ -63,11 +63,11 @@ config("relative_paths") {
   # option to keep all source file name references uniformly relative to
   # a single root.
   if (use_rbe) {
-    absolute_path = "/b/f/w/"
+    absolute_path = "/b/f/w/set_by_reclient/a"
   } else {
     absolute_path = rebase_path("//")
   }
-  relative_path = ""
+  relative_path = "out/host_debug_unopt_arm64"
   cflags = [
     # This makes sure that the DW_AT_comp_dir string (the current
     # directory while running the compiler, which is the basis for all

we get

impeller_unittests.dSYM/Contents/Resources/DWARF/impeller_unittests:    file format Mach-O arm64

.debug_info contents:
0x00000000: Compile Unit: length = 0x0003c0eb, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0003c0ef)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("Fuchsia clang version 18.0.0 (https://llvm.googlesource.com/llvm-project 725656bdd885483c39f482a01ea25d67acf39c46)")
              DW_AT_language    (DW_LANG_C_plus_plus_14)
              DW_AT_name        ("../../flutter/impeller/base/base_unittests.cc")
              DW_AT_LLVM_sysroot        ("../../flutter/prebuilts/SDKs/MacOSX14.4.sdk")
              DW_AT_APPLE_sdk   ("MacOSX14.4.sdk")
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("out/host_debug_unopt_arm64")
              DW_AT_low_pc      (0x00000001000012d0)
              DW_AT_ranges      (0x00000b70
                 [0x00000001000012d0, 0x0000000100030774))

This looks identical to the local build, but doesn't work the same. VSCode doesn't work with it. lldb works as long as I execute from the src directory. The VSCode error is Could not load source 'flutter/impeller/aiks/canvas.cc': 'SourceRequest' not supported..

@jason-simmons
Copy link
Member

I was able to get VSCode debugging to work with RBE-generated engine executables on macOS by using the CodeLLDB extension.

That extension supports a setting for remapping source paths (see https://github.com/vadimcn/codelldb/blob/master/MANUAL.md#source-path-remapping)

I used this .vscode/launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "TestLaunch",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/../out/host_debug_unopt_arm64/impeller_unittests",
            "cwd": "${workspaceFolder}/../out/host_debug_unopt_arm64",
            "sourceMap": { "/b/f/w/set_by_reclient/a/../../flutter": "${workspaceFolder}" }
        }
    ]
}

@zanderso zanderso force-pushed the debug-prefix-map branch from e381bc4 to 158dbfb Compare May 7, 2024 20:56
@zanderso zanderso merged commit b55755a into flutter:master May 8, 2024
@zanderso zanderso deleted the debug-prefix-map branch May 8, 2024 14:18
zanderso added a commit to flutter/engine that referenced this pull request May 8, 2024
For flutter/flutter#147750.

Depends on flutter/buildroot#852.

This PR rolls forward reclient, the buildroot, and our RBE configs. The
new RBE configs do a few things. First they default the exec strategy to
`racing`. Second, they add a local wrapper script that passes the
correct value for `-fdebug-prefix-map` in both the local and remote
cases. Finally, they remove the canonicalization of the build's working
directory, so that the remote working directory will have the same name
as the local working directory. This solves the issue where the build
working directory contained a mysterious `set_by_reclient/a` component.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants