envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.68k stars 4.75k forks source link

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

Closed coolg92003 closed 2 weeks ago

coolg92003 commented 1 month ago

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 tapfilter.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

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-0ubuntu1~20.04~1) 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

nezdolik commented 1 month ago

cc @phlax @htuch

coolg92003 commented 1 month ago

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 commented 1 month ago

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 '-DDATE="redacted"' '-DTIMESTAMP="redacted"' '-DTIME="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 commented 1 month ago

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:

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) + 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)", 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

coolg92003 commented 1 month ago

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

phlax commented 1 month ago

@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 commented 1 month ago

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

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

github-actions[bot] commented 3 weeks ago

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[bot] commented 2 weeks ago

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.