From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by sourceware.org (Postfix) with ESMTPS id 3E5203844036 for ; Thu, 24 Jun 2021 00:34:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3E5203844036 Received: by mail-qv1-xf29.google.com with SMTP id j6so1827034qvp.3 for ; Wed, 23 Jun 2021 17:34:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=KMrS4oGn0GJJiqv59iW7345KFS9GfLrVW6e3/gWgIuA=; b=CnljfUwmFk0FPf/81+u/uPAx9EjlYUrmG23uGeaJAXog4OCZ89rxf3w8vAYSfOegoZ HqjIwvADwhofC/vY8pIyf22A1/jDjXUHGFEv9XsWpA6MtlFWwDq0IRfQJet6fmOWkf2o dqtFt/jP5to32pIAfwqhTdGqay7KEyIEk9NLh7d49fJArrsFIlEYQ/qOwg7RwEo0DgXg toNHLj/As1xD5rC/+MGgZDP4n9UonKzD3OFvsuRka7aA1G8TH1EVwLlBhYH3U9qMIW+J KxS8eKbAPi/osRrVcgDnEuTu+92iElVuzhO3IYZV8ZXRE+Y8yfuRqn4eztBSvN695iXk D+rQ== X-Gm-Message-State: AOAM533/QLUzmCJcCZg7OY+IxZSxjlbFQNE8BFTs7qB63ZaxqGfIy0Oe xmmIMMh++ogMZ1l9sJgPT7Zi/NNPCXT0Lj/NV47WpF/9T8kIww== X-Google-Smtp-Source: ABdhPJyix6YEcp8kofSEutVJqsyC57zXDh1rgiJlCCmQPucC4zTtLleX24FzNUpL1hxuKvlBpK0KnGJZ1TX7kdQ5vcg= X-Received: by 2002:a05:6214:42:: with SMTP id c2mr2756849qvr.20.1624494895523; Wed, 23 Jun 2021 17:34:55 -0700 (PDT) MIME-Version: 1.0 From: kamlesh kumar Date: Thu, 24 Jun 2021 06:04:19 +0530 Message-ID: Subject: gdb unable to print alias variable To: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 00:34:57 -0000 Hi Devs, Currently clang does not produce debug info for alias variables, I am working on this feature, by having DW_TAG_imported_declaration for alias variable but gdb does not work with this. below is demonstration consider this testcase, ----------- int oldname = 1; extern int newname attribute((alias("oldname"))); int main(){} --------------------- $clang test.c -g $gdb a.out (gdb) pt oldname type = int (gdb) pt newname type = (gdb) p newname 'newname' has unknown type; cast it to its declared type Here is debug info in ./a.out by clang dumped debug info (using llvm-dwarfdump) test.o: file format elf64-x86-64 .debug_info contents: 0x00000000: Compile Unit: length = 0x00000067, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000006b) 0x0000000b: DW_TAG_compile_unit DW_AT_producer ("clang version 13.0.0 (git@github.com:llvm/llvm-project.git 4cd7169f5517167ef456e82c6dcae669bde6c725)") DW_AT_language (DW_LANG_C99) DW_AT_name ("test.c") DW_AT_stmt_list (0x00000000) DW_AT_comp_dir ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin") DW_AT_low_pc (0x0000000000000000) DW_AT_high_pc (0x0000000000000008) 0x0000002a: DW_TAG_variable DW_AT_name ("oldname") DW_AT_type (0x0000003f "int") DW_AT_external (true) DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c") DW_AT_decl_line (1) DW_AT_location (DW_OP_addr 0x0) 0x0000003f: DW_TAG_base_type DW_AT_name ("int") DW_AT_encoding (DW_ATE_signed) DW_AT_byte_size (0x04) 0x00000046: DW_TAG_imported_declaration DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c") DW_AT_decl_line (2) DW_AT_import (0x0000002a) DW_AT_name ("newname") 0x00000051: DW_TAG_subprogram DW_AT_low_pc (0x0000000000000000) DW_AT_high_pc (0x0000000000000008) DW_AT_frame_base (DW_OP_reg6 RBP) DW_AT_name ("main") DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c") DW_AT_decl_line (3) DW_AT_type (0x0000003f "int") DW_AT_external (true) 0x0000006a: NULL Even though the newname has desired info, gdb is unable to print the value or type of the newname. I would like to know whether this is a bug in gdb, or debug info itself is wrong(because of DW_TAG_imported_declaration for newname)? Any other viable path to address alias variable debugging will be appreciated. ./kamlesh