From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102518 invoked by alias); 7 Jun 2019 14:45:47 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 102230 invoked by uid 89); 7 Jun 2019 14:45:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.7 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=dear, tel, Tel, office X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Jun 2019 14:45:45 +0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2019 07:45:43 -0700 Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga005.jf.intel.com with ESMTP; 07 Jun 2019 07:45:42 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.112]) by IRSMSX102.ger.corp.intel.com ([169.254.2.238]) with mapi id 14.03.0415.000; Fri, 7 Jun 2019 15:45:41 +0100 From: "Aktemur, Tankut Baris" To: "gdb@sourceware.org" CC: "Metzger, Markus T" Subject: Infcall of a template function in a C++ program Date: Fri, 07 Jun 2019 14:45:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg00009.txt.bz2 Dear All, Suppose we have the following small C++ program: ~~~ #include template T foo (T t) { return t; } int main (void) { std::cout << foo (5) << std::endl; std::cout << foo ('a') << std::endl; return 0; } ~~~ The compiler is able to do the type inference, template function instantiation, and function invocation based on the expressions `foo (5)` and `foo ('a')`. When we start GDB and attempt to evaluate these expressions, the corresponding functions are not resolved, though. Here is a sample session: ~~~ (gdb) start ... (gdb) print foo(5) No symbol "foo" in current context. (gdb) print foo(5) $1 =3D 5 (gdb) print foo('a') $2 =3D 97 'a' ~~~ The DWARF info contains DIE's for the subprograms named "foo" and "foo": 0x00002849: DW_TAG_subprogram DW_AT_name ("foo") ... 0x00002882: DW_TAG_subprogram DW_AT_name ("foo") ... Is there any on-going or planned work to add type inference/resolution capability to GDB so that an expression such as `foo (5)` would be evaluated correctly? This might not be possible in general, but does GDB try any heur= istics to find the right template instance? Regards, -Tankut Baris Aktemur Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928