Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"frame variable config" of lldb can't display any thing after build with "./ci/do_ci.sh debug.server_only" #35153

Closed
coolg92003 opened this issue Jul 11, 2024 · 9 comments
Labels
area/debugging stale stalebot believes this issue/PR has not been touched recently

Comments

@coolg92003
Copy link
Contributor

Title: frame variable config" of lldb can't display any thing

Description:
Recent, there are something confusion in envoy code. therefore, try to build a debug version of envoy to check stepbystep. however,
It can't display anything when doing test, no matter on trying "p config" or "var config" or "frame variable config", see below
lldb --version
lldb version 14.0.0

lldb /build/envoy/x64/source/exe/envoy/envoy
(lldb) target create "/build/envoy/x64/source/exe/envoy/envoy"
Current executable set to '/build/envoy/x64/source/exe/envoy/envoy' (x86_64).
(lldb) settings set target.source-map /proc/self/cwd /source
(lldb) b setDecoderFilterCallbacks
Breakpoint 1: 40 locations.
(lldb) settings set target.debug-file-search-paths /build/bazel_root/base/execroot/envoy
(lldb) r -l debug -c /tmp/test/fFtapenvoy.yaml --concurrency 1 --log-path /tmp/test/envoy.log
Process 881306 launched: '/build/envoy/x64/source/exe/envoy/envoy' (x86_64)
Process 881306 stopped
Process 881306 stopped
thread #9, name = 'wrk:worker_0', stop reason = step over
frame #0: 0x000055555bb2bab1 envoy`Envoy::Extensions::HttpFilters::TapFilter::Filter::setDecoderFilterCallbacks(Envoy::Http::StreamDecoderFilterCallbacks&) at tap_filter.h:102:16
99 Http::FilterTrailersStatus decodeTrailers(Http::RequestTrailerMap& trailers) override;
100 void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) override {
101 HttpTapConfigSharedPtr config = config_->currentConfig();
-> 102 if (config != nullptr) {
103 auto streamId = callbacks.streamId();
104 auto connection = callbacks.connection();
105 tapper_ = config->createPerRequestTapper(config_->getTapConfig(), streamId, connection);
(lldb) p config
error: expression failed to parse:
error: <user expression 0>:1:1: reference to 'config' is ambiguous
config
^
note: candidate found by name lookup is 'config'

note: candidate found by name lookup is 'config'

(lldb) var config
(lldb) frame variable config
(lldb)

In fact,

  1. I have read doc of below
    https://github.com/envoyproxy/envoy/blob/main/bazel/README.md#supported-compiler-versions
    add below
    --copt=-fno-limit-debug-info
    in my source code /source/.bazelrc as below
    build:clang-cl --copt="-fno-limit-debug-info"
    it also doesn't work,

  2. then we try to add debug path as below:
    settings set target.debug-file-search-paths /build/bazel_root/base/execroot/envoy
    because of *.dwo of debugged function as below:
    /build/bazel_root/base/execroot/envoy/bazel-out/k8-dbg/bin/source/extensions/filters/http/tap/_objs/tap_config_impl/tap_config_impl.pic.dwo

  3. then I try a test private code as below and all works fine
    envoybuild@cfx-build:/tmp/test$ ls cfx*
    cfx.cc
    envoybuild@cfx-build:/tmp/test$ clang++ -o a -gsplit-dwarf -ggdb3 cfx.cc
    envoybuild@cfx-build:/tmp/test$ ls cfx*
    cfx.cc cfx.dwo
    envoybuild@cfx-build:/tmp/test$ lldb ./a
    (lldb) target create "./a"
    Current executable set to '/tmp/test/a' (x86_64).
    (lldb) b testv
    Breakpoint 1: where = a`testv(int) + 11 at cfx.cc:6:12, address = 0x00000000004012cb
    (lldb) r
    Process 881362 launched: '/tmp/test/a' (x86_64)
    main: enter
    Process 881362 stopped

  • thread Initial import #1, name = 'a', stop reason = breakpoint 1.1
    frame #0: 0x00000000004012cb a`testv(i=2) at cfx.cc:6:12
    3 std::string str_g = "global string";
    4 void testv(int i)
    5 {
    -> 6 std::cout << "\ntestv: i:" << i << std::endl;
    7 return;
    8 }
    9 int main()
    (lldb) p i
    (int) $0 = 2
    (lldb) frame variable i
    (int) i = 2
    (lldb) var i
    (int) i = 2

4) from current see, the only difference, in envoy, the building output is(no dwo file, only one dwp file)
envoybuild@cfx-build:~/envoy/x64/source/exe/envoy$ ls -alt /build/envoy/x64/source/exe/envoy
total 2182184
-r-xr-xr-x. 1 envoybuild envoygroup 597614616 Jul 11 11:32 envoy.dwp
drwxr-xr-x. 2 envoybuild envoygroup 52 Jul 11 11:32 .
-r-xr-xr-x. 1 envoybuild envoygroup 1634070736 Jul 11 11:31 envoy
There is a dwp file there, there is no dwo. however, I have give the dwo file path as target.debug-file-search-paths
why still not work?
anything missed?

Also, I try gdb, it doesn't work because I can't set break-point as below:
gdb ./envoy
GNU gdb (Ubuntu 10.2-0ubuntu120.041) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./envoy...
Dwarf Error: bad DWP hash table, lookup didn't terminate [in module /build/envoy/x64/source/exe/envoy/envoy.dwp]
(gdb)

Thanks
CLiff

@coolg92003 coolg92003 added the triage Issue requires triage label Jul 11, 2024
@nezdolik nezdolik added area/debugging and removed triage Issue requires triage labels Jul 11, 2024
@nezdolik
Copy link
Member

nezdolik commented Jul 11, 2024

cc @phlax @htuch

@coolg92003
Copy link
Contributor Author

past build command
envoybuild@cfx-build:/source$ ./ci/do_ci.sh debug.server_only
ENVOY_SRCDIR=/source
ENVOY_BUILD_TARGET=//source/exe:envoy-static
ENVOY_BUILD_ARCH=x86_64
Setting test_tmpdir to /build/tmp.
Skip setting up Envoy Filter Example.
building using 6 CPUs
building for x86_64
clang toolchain with libc++ configured: clang-libc++
bazel debug build...
Building (type=debug target=//source/exe:envoy-static debug=//source/exe:envoy-static.dwp name=envoy)...
ENVOY_BIN=source/exe/envoy-static
INFO: Analyzed target //source/exe:envoy-static (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[6 / 7] Linking source/exe/envoy-static; 3s linux-sandbox

@coolg92003
Copy link
Contributor Author

coolg92003 commented Jul 12, 2024

When changing code error in purpose, got below output, it can see related debug flag is correct.
envoybuild@cfx-build:/source$ ./ci/do_ci.sh debug.server_only
ENVOY_SRCDIR=/source
ENVOY_BUILD_TARGET=//source/exe:envoy-static
ENVOY_BUILD_ARCH=x86_64
Setting test_tmpdir to /build/tmp.
Skip setting up Envoy Filter Example.
building using 6 CPUs
building for x86_64
clang toolchain with libc++ configured: clang-libc++
bazel debug build...
Building (type=debug target=//source/exe:envoy-static debug=//source/exe:envoy-static.dwp name=envoy)...
ENVOY_BIN=source/exe/envoy-static
Starting local Bazel server and connecting to it...
... still trying to connect to local Bazel server (881473) after 10 seconds ...
INFO: Analyzed target //source/exe:envoy-static (1064 packages loaded, 48699 targets configured).
INFO: Found 1 target...
ERROR: /source/source/extensions/filters/http/tap/BUILD:27:17: Compiling source/extensions/filters/http/tap/tap_config_impl.cc failed: (Exit 1): clang-14 failed: error executing command (from target //source/extensions/filters/http/tap:tap_config_impl)
(cd /build/bazel_root/base/sandbox/linux-sandbox/1/execroot/envoy &&
exec env -
BAZEL_COMPILER=clang
BAZEL_CXXOPTS='-stdlib=libc++'
BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
BAZEL_LINKOPTS=-lm:-pthread
CC=clang
CXX=clang++
CXXFLAGS='-stdlib=libc++'
LDFLAGS='-stdlib=libc++'
LLVM_CONFIG=/opt/llvm/bin/llvm-config
PATH=/opt/llvm/bin:/opt/llvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/proc/self/cwd
/opt/llvm/bin/clang-14 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g '-stdlib=libc++' -MD -MF bazel-out/k8-dbg/bin/source/extensions/filters/http/tap/_objs/tap_config_impl/tap_config_impl.pic.d '-frandom-seed=bazel-out/k8-dbg/bin/source/extensions/filters/http/tap/_objs/tap_config_impl/tap_config_impl.pic.o' -fPIC #-gsplit-dwarf -g -DENVOY_ADMIN_FUNCTIONALITY -DENVOY_ENABLE_QUIC -DENVOY_ENABLE_FULL_PROTOS -DENVOY_ENABLE_YAML -DENVOY_ENABLE_HTTP_DATAGRAMS -DENVOY_MOBILE_ENABLE_LISTENER -DENVOY_MOBILE_XDS -DENVOY_GOOGLE_GRPC -DFMT_HEADER_ONLY -DSPDLOG_FMT_EXTERNAL -DNGHTTP2_STATICLIB '-DBAZEL_CURRENT_REPOSITORY=""' -iquote . -iquote bazel-out/k8-dbg/bin -iquote external/com_google_absl -iquote bazel-out/k8-dbg/bin/external/com_google_absl -iquote external/com_github_gabime_spdlog -iquote bazel-out/k8-dbg/bin/external/com_github_gabime_spdlog -iquote external/com_github_fmtlib_fmt -iquote bazel-out/k8-dbg/bin/external/com_github_fmtlib_fmt -iquote external/com_google_protobuf -iquote bazel-out/k8-dbg/bin/external/com_google_protobuf -iquote external/utf8_range -iquote bazel-out/k8-dbg/bin/external/utf8_range -iquote external/com_github_cyan4973_xxhash -iquote bazel-out/k8-dbg/bin/external/com_github_cyan4973_xxhash -iquote external/envoy_api -iquote bazel-out/k8-dbg/bin/external/envoy_api -iquote external/com_github_cncf_xds -iquote bazel-out/k8-dbg/bin/external/com_github_cncf_xds -iquote external/com_google_googleapis -iquote bazel-out/k8-dbg/bin/external/com_google_googleapis -iquote external/com_envoyproxy_protoc_gen_validate -iquote bazel-out/k8-dbg/bin/external/com_envoyproxy_protoc_gen_validate -iquote external/com_googlesource_code_re2 -iquote bazel-out/k8-dbg/bin/external/com_googlesource_code_re2 -iquote external/dev_cel -iquote bazel-out/k8-dbg/bin/external/dev_cel -iquote external/opencensus_proto -iquote bazel-out/k8-dbg/bin/external/opencensus_proto -iquote external/com_github_jbeder_yaml_cpp -iquote bazel-out/k8-dbg/bin/external/com_github_jbeder_yaml_cpp -iquote external/boringssl -iquote bazel-out/k8-dbg/bin/external/boringssl -iquote external/com_github_google_quiche -iquote bazel-out/k8-dbg/bin/external/com_github_google_quiche -iquote external/envoy -iquote bazel-out/k8-dbg/bin/external/envoy -iquote external/com_googlesource_googleurl -iquote bazel-out/k8-dbg/bin/external/com_googlesource_googleurl -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_nowkt -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf_lite -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena_align -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/stubs/_virtual_includes/lite -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/port_def -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena_allocation_policy -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/arena_cleanup -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/string_block -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/internal_visibility -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/varint_shuffle -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/io -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/io_win32 -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/gzip_stream -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/stubs/_virtual_includes/stubs -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/printer -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/zero_copy_sink -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/io/_virtual_includes/tokenizer -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/any_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/descriptor_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/empty_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/struct_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/wrappers_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/_virtual_includes/protobuf -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/protobuf -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/wkt_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/api_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/source_context_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/type_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/duration_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/field_mask_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/timestamp_proto -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/compiler/_virtual_includes/importer -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/util/_virtual_includes/delimited_message_util -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/util/_virtual_includes/differencer -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/util/_virtual_includes/field_mask_util -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/util/_virtual_includes/json_util -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/json -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/parser -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/descriptor_traits -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/lexer -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/message_path -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/zero_copy_buffered_stream -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/untyped_message -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/util/_virtual_includes/type_resolver_util -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/descriptor_legacy -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/unparser -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/json/_virtual_includes/writer -Ibazel-out/k8-dbg/bin/external/com_google_protobuf/src/google/protobuf/util/_virtual_includes/time_util -Ibazel-out/k8-dbg/bin/source/common/common/_virtual_includes/logger_impl_lib_standard -Ibazel-out/k8-dbg/bin/external/dev_cel/proto/cel/expr/_virtual_includes/checked_proto -Ibazel-out/k8-dbg/bin/external/dev_cel/proto/cel/expr/_virtual_includes/syntax_proto -Ibazel-out/k8-dbg/bin/source/common/common/_virtual_includes/thread_impl_lib_posix -Ibazel-out/k8-dbg/bin/source/common/api/_virtual_includes/os_sys_calls_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/_virtual_includes/quiche_export_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/_virtual_includes/quiche_logging_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_server_stats_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/_virtual_includes/quiche_stack_trace_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/_virtual_includes/quiche_platform_iovec_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_prefetch_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_command_line_flags_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_flag_utils_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_reference_counted_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/virtual_includes/quiche_common_platform_default_quiche_platform_impl_testvalue_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/virtual_includes/quic_base_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/virtual_includes/quiche_flags_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/virtual_includes/quiche_mem_slice_impl_lib -Ibazel-out/k8-dbg/bin/source/common/quic/platform/virtual_includes/quiche_time_utils_impl_lib -Ibazel-out/k8-dbg/bin/external/com_github_google_quiche/virtual_includes/quiche_common_platform_default_quiche_platform_impl_client_stats_impl_lib -isystem external/com_github_gabime_spdlog/include -isystem bazel-out/k8-dbg/bin/external/com_github_gabime_spdlog/include -isystem external/com_github_fmtlib_fmt/include -isystem bazel-out/k8-dbg/bin/external/com_github_fmtlib_fmt/include -isystem bazel-out/k8-dbg/bin/external/envoy/bazel/foreign_cc/zlib/include -isystem bazel-out/k8-dbg/bin/external/envoy/bazel/foreign_cc/event/include -isystem external/com_github_jbeder_yaml_cpp/include -isystem bazel-out/k8-dbg/bin/external/com_github_jbeder_yaml_cpp/include -isystem external/boringssl/include -isystem bazel-out/k8-dbg/bin/external/boringssl/include -isystem bazel-out/k8-dbg/bin/external/envoy/bazel/foreign_cc/liburing/include -isystem external/envoy/bazel/external/http_parser -isystem bazel-out/k8-dbg/bin/external/envoy/bazel/external/http_parser -isystem bazel-out/k8-dbg/bin/external/envoy/bazel/foreign_cc/nghttp2/include '-DABSL_MIN_LOG_LEVEL=4' -fdebug-types-section -fPIC -Wno-deprecated-declarations '-std=c++2a' -fsized-deallocation -Wall -Wextra -Werror -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Wformat -Wformat-security -Wvla -Wno-deprecated-declarations -Wreturn-type #-ggdb3 -fno-limit-debug-info -Wgnu-conditional-omitted-operand -Wc++2a-extensions -Wrange-loop-analysis -DTCMALLOC -DENVOY_OBJECT_TRACE_ON_DUMP -DENVOY_HOT_RESTART -DENVOY_ADMIN_HTML -DENVOY_STATIC_EXTENSION_REGISTRATION -DENVOY_GOOGLE_GRPC -DENVOY_HANDLE_SIGNALS -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE="redacted"' '-D__TIMESTAMP="redacted"' '-D__TIME="redacted"' -c source/extensions/filters/http/tap/tap_config_impl.cc -o bazel-out/k8-dbg/bin/source/extensions/filters/http/tap/_objs/tap_config_impl/tap_config_impl.pic.o)
Configuration: ca24c212333f22be8913516a641f3578d2e31c459b7e7a4cbbd2609ba90ef7c7
Execution platform: @local_config_platform//:host

@coolg92003
Copy link
Contributor Author

After changing file /source/bazel/envoy_internal.bzl and add "-O0"
envoybuild@cfx-build:/source/bazel$ cat /source/bazel/envoy_internal.bzl | grep gdb3
repository + "//bazel:opt_build": [] if test else ["-ggdb3"],
repository + "//bazel:dbg_build": ["-O0 -ggdb3"],
Still doesn't work as before:

  • thread add x-envoy-upstream-rq-per-try-timeout-ms router header option #9, name = 'wrk:worker_0', stop reason = step over
    frame #0: 0x000055555bb21903 envoy`Envoy::Extensions::HttpFilters::TapFilter::HttpTapConfigImpl::createPerRequestTapper(envoy::extensions::filters::http::tap::v3::Tap const&, unsigned long, Envoy::OptRef<Envoy::Network::Connection const>) at tap_config_impl.cc:42:17
    39 const envoy::extensions::filters::http::tap::v3::Tap& tap_config, uint64_t stream_id,
    40 OptRef connection) {
    41 uint64_t i=1;
    -> 42 if (stream_id > 0) {
    43 i= i + stream_id;
    44 }
    45 ENVOY_LOG_MISC(info, "createPerRequestTapper: CFX num:<{}>", i);
    (lldb) p i
    error: expression failed to parse:
    error: <user expression 0>:1:1: use of undeclared identifier 'i'
    i
    ^
    (lldb) frame variable i
    (lldb) frame variable

From below address lookup, it still miss the variable information, don't know how it missed by clang++
image lookup --address 0x00000000065cd8fb --verbose
Address: envoy[0x00000000065cd8fb] (envoy.PT_LOAD[1]..text + 18737403)
Summary: envoy`Envoy::Extensions::HttpFilters::TapFilter::HttpTapConfigImpl::createPerRequestTapper(envoy::extensions::filters::http::tap::v3::Tap const&, unsigned long, Envoy::OptRef<Envoy::Network::Connection const>) + 59
Module: file = "/build/envoy/x64/source/exe/envoy/envoy", arch = "x86_64"
CompileUnit: id = {0x00000221}, file = "/proc/self/cwd/source/extensions/filters/http/tap/tap_config_impl.cc", language = ""
LineEntry: [0x00000000065cd8fb-0x00000000065cd903): /proc/self/cwd/source/extensions/filters/http/tap/tap_config_impl.cc:41:12
Symbol: id = {0x0011459e}, range = [0x00000000065cd8c0-0x00000000065cdb3b), name="Envoy::Extensions::HttpFilters::TapFilter::HttpTapConfigImpl::createPerRequestTapper(envoy::extensions::filters::http::tap::v3::Tap const&, unsigned long, Envoy::OptRef<Envoy::Network::Connection const>)", mangled="_ZN5Envoy10Extensions11HttpFilters9TapFilter17HttpTapConfigImpl22createPerRequestTapperERKN5envoy10extensions7filters4http3tap2v33TapEmNS_6OptRefIKNS_7Network10ConnectionEEE"

as you can see below in my test private build case, it has everything
clang++ -g -ggdb3 -gsplit-dwarf -O0 -o a cfx.cc
lldb ./a

rocess 948841 stopped

  • thread Initial import #1, name = 'a', stop reason = step over
    frame #0: 0x000000000040147e aEnvoy::Extensions::HttpFilters::TapFilter::An::displayValue(this=0x00007fffffffe8c0, j=2) at cfx.cc:25:13 22 std::cout << "\n\tdisplay: i=" << i << std::endl; 23 std::cout << "\n\tdisplay: end, this=" << this << std::endl; 24 int i=3; -> 25 std::cout << "\n\tdisplay: end, i+j=" << i+j << std::endl; 26 std::cout << "\n\tdisplay: end\n"; 27 } 28 private: (lldb) p i (int) $0 = 3 (lldb) frame variable (Envoy::Extensions::HttpFilters::TapFilter::An *) this = 0x00007fffffffe8c0 (int) j = 2 (int) i = 3 (lldb) image lookup --address 0x00007fffffffe8c0 --verbose (lldb) image lookup --address 0x0000000000401407 --verbose Address: a[0x0000000000401407] (a.PT_LOAD[1]..text + 759) Summary: aEnvoy::Extensions::HttpFilters::TapFilter::An::displayValue(int) + 23 at cfx.cc:22:13
    Module: file = "/tmp/test/a", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "/tmp/test/cfx.cc", language = "c++14"
    Function: id = {0x40000000000018a3}, name = "Envoy::Extensions::HttpFilters::TapFilter::An::displayValue(int)", mangled = "_ZN5Envoy10Extensions11HttpFilters9TapFilter2An12displayValueEi", range = [0x00000000004013f0-0x00000000004014d6)
    FuncType: id = {0x40000000000018a3}, byte-size = 0, decl = cfx.cc:21, compiler_type = "void (int)"
    Blocks: id = {0x40000000000018a3}, range = [0x004013f0-0x004014d6)
    LineEntry: [0x0000000000401407-0x0000000000401427): /tmp/test/cfx.cc:22:13
    Symbol: id = {0x00000051}, range = [0x00000000004013f0-0x00000000004014d6), name="Envoy::Extensions::HttpFilters::TapFilter::An::displayValue(int)", mangled="_ZN5Envoy10Extensions11HttpFilters9TapFilter2An12displayValueEi"
    Variable: id = {0x40000000000018b3}, name = "this", type = "Envoy::Extensions::HttpFilters::TapFilter::An *", location = DW_OP_fbreg -8, decl =
    Variable: id = {0x40000000000018bd}, name = "j", type = "int", location = DW_OP_fbreg -12, decl = cfx.cc:21
    Variable: id = {0x40000000000018c9}, name = "i", type = "int", location = DW_OP_fbreg -16, decl = cfx.cc:24

thanks
Cliff

@coolg92003
Copy link
Contributor Author

hi @htuch
Do you have any idea?
Appreciate your help!
Cliff

@phlax
Copy link
Member

phlax commented Jul 15, 2024

@coolg92003 please use markdown code fencing (with console) when pasting console lines, and use ` for literals

it would make it much easier to read your issue and more likely anyone can help

@coolg92003
Copy link
Contributor Author

Hi @phlax
Appreciated your comments.
From my observation, envoy built with clang missed Variable part and see below:

  • My private building
(lldb) image lookup --address 0x00000000004012db --verbose
      Address: a[0x00000000004012db] (a.PT_LOAD[1]..text + 459)
      Summary: a`Envoy::Extensions::HttpFilters::TapFilter::testv(int) + 11 at cfx.cc:12:12
       Module: file = "/tmp/test/a", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "/tmp/test/cfx.cc", language = "c++14"
     Function: id = {0x0000316a}, name = "Envoy::Extensions::HttpFilters::TapFilter::testv(int)", mangled = "_ZN5Envoy10Extensions11HttpFilters9TapFilter5testvEi", range = [0x00000000004012d0-0x0000000000401357)
     FuncType: id = {0x0000316a}, byte-size = 0, decl = cfx.cc:9, compiler_type = "void (int)"
       Blocks: id = {0x0000316a}, range = [0x004012d0-0x00401357)
    LineEntry: [0x00000000004012db-0x00000000004012f7): /tmp/test/cfx.cc:12:12
       Symbol: id = {0x0000004a}, range = [0x00000000004012d0-0x0000000000401357), name="Envoy::Extensions::HttpFilters::TapFilter::testv(int)", mangled="_ZN5Envoy10Extensions11HttpFilters9TapFilter5testvEi"
    ' Variable:id = {0x00003178}, name = "i", type = "int", location = DW_OP_fbreg -4, decl = cfx.cc:9
     Variable: id = {0x00003184}, name = "j", type = "int", location = DW_OP_fbreg -8, decl = cfx.cc:13
  • However, envoy built with debug without the content of language in CompileUnit, FunctionType, and Variable part
image lookup --verbose --address 0x00000000065cd8fb
      Address: envoy[0x00000000065cd8fb] (envoy.PT_LOAD[1]..text + 18737403)
      Summary: envoy`Envoy::Extensions::HttpFilters::TapFilter::HttpTapConfigImpl::createPerRequestTapper(envoy::extensions::filters::http::tap::v3::Tap const&, unsigned long, Envoy::OptRef<Envoy::Network::Connection const>) + 59
       Module: file = "/build/envoy/x64/source/exe/envoy/envoy", arch = "x86_64"
  CompileUnit: id = {0x00000221}, file = "/proc/self/cwd/source/extensions/filters/http/tap/tap_config_impl.cc", language = "<not loaded>"
    LineEntry: [0x00000000065cd8fb-0x00000000065cd903): /proc/self/cwd/source/extensions/filters/http/tap/tap_config_impl.cc:41:12
       Symbol: id = {0x0011459e}, range = [0x00000000065cd8c0-0x00000000065cdb3b), name="Envoy::Extensions::HttpFilters::TapFilter::HttpTapConfigImpl::createPerRequestTapper(envoy::extensions::filters::http::tap::v3::Tap const&, unsigned long, Envoy::OptRef<Envoy::Network::Connection const>)", mangled="_ZN5Envoy10Extensions11HttpFilters9TapFilter17HttpTapConfigImpl22createPerRequestTapperERKN5envoy10extensions7filters4http3tap2v33TapEmNS_6OptRefIKNS_7Network10ConnectionEEE"

Which Option create difference?
My private code is compiled by
clang++ -o a -g -O0 -ggdb3 cfx.cc

cat cfx.cc
#include <iostream>
#include <string>
std::string str_g = "global string";
namespace Envoy {
namespace Extensions {
namespace HttpFilters {
namespace TapFilter {

void testv(int i)
{
        // cfx
        std::cout << "\ntestv: i:" << i << std::endl;
        int j=9;
        std::cout << "\ntestv: j+i:" << j+9 << std::endl;

        return;
}
int i_g = 64;
class An {
public:
        void displayValue(int j) {
                std::cout << "\n\tdisplay: i=" << i << std::endl;
                std::cout << "\n\tdisplay: end, this=" << this << std::endl;
                int i=3;
                std::cout << "\n\tdisplay: end, i+j=" << i+j << std::endl;
                std::cout << "\n\tdisplay: end\n";
        }
private:
        int i =9;
};
}
}
}
}
int main()
{
        int j=2;
        std::cout << "main: enter\n";
        Envoy::Extensions::HttpFilters::TapFilter::testv(j);
        Envoy::Extensions::HttpFilters::TapFilter::An l_an;
        l_an.displayValue(j);
        std::cout << "main: exit\n";
        return 0;
}

I had changed below part

envoy_internal.bzl

--- a/bazel/envoy_internal.bzl
+++ b/bazel/envoy_internal.bzl
@@ -53,7 +53,7 @@ def envoy_copts(repository, test = False):
                # Bazel adds an implicit -DNDEBUG for opt targets.
                repository + "//bazel:opt_build": [] if test else ["-ggdb3"],
                repository + "//bazel:fastbuild_build": [],
-               repository + "//bazel:dbg_build": ["-ggdb3"],
+              repository + "//bazel:dbg_build": ["-O0 -ggdb3"],
                repository + "//bazel:windows_opt_build": [] if test else ["-Z7"],

but it still have no effect.

thanks
Cliff

Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Aug 15, 2024
Copy link

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/debugging stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

3 participants