From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15363 invoked by alias); 25 Sep 2015 04:24:45 -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 15351 invoked by uid 89); 25 Sep 2015 04:24:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f175.google.com Received: from mail-yk0-f175.google.com (HELO mail-yk0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 25 Sep 2015 04:24:44 +0000 Received: by ykdt18 with SMTP id t18so104897748ykd.3 for ; Thu, 24 Sep 2015 21:24:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=LyaYX9TmZSRXjLm0rOrj+U1pQ8fXjxnOodnkG7Gjkgk=; b=UYmO77af1RZZZseITWp17MzYR1fIqZQkyBXsNuBItbfYPFQ37BhEKKRBOGYglD5qxz H00+Bzwh8vd6eCtCM3SA93yUVUUlI9eG9idcf98xkBwxizZzaNPRUm3T3EKKvZ7jbwX2 otrbGk6f9Cb6dlt8/wStSKJ//NAQNhYnm0JQns6XErcPPe41selxEcDvxfn87vnSMkWd Q4DSsFLkbhZB/MdcRFZzSlqYXJrYhGcZNe7JBVTXTnglnWMpvurC661oOTglJVLmwGrb Z48VLy7smyqtUkAAdtjfucQcfXsnBZR5Ax+WHxZ5cp+lVvAPYnOFFhK4WDhVrByIsmJr dtww== X-Gm-Message-State: ALoCoQkrVIlIVCZH3c0SXzofb4xI+Jla/LR/LdQBMVUvCYEGT8oTVrJfn1tY2scbK4ixr+rufjNQmV7tZXgZ3/Bbm+UI/ozBfK6rbHFdCCjPlLsTYKCjOD8wgkqnZ11hd9aBXvHos9sWx3PzRA3ZjG4huynqYp9srbm0SP6oWM65DEHeq7jJe5M= X-Received: by 10.129.23.211 with SMTP id 202mr2807018ywx.102.1443155082384; Thu, 24 Sep 2015 21:24:42 -0700 (PDT) Received: from mail-yk0-f181.google.com (mail-yk0-f181.google.com. [209.85.160.181]) by smtp.gmail.com with ESMTPSA id v204sm1430133ywb.24.2015.09.24.21.24.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 21:24:41 -0700 (PDT) Received: by ykdz138 with SMTP id z138so104855205ykd.2 for ; Thu, 24 Sep 2015 21:24:40 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.13.211.135 with SMTP id v129mr3031117ywd.129.1443155080755; Thu, 24 Sep 2015 21:24:40 -0700 (PDT) Received: by 10.129.108.212 with HTTP; Thu, 24 Sep 2015 21:24:40 -0700 (PDT) Date: Fri, 25 Sep 2015 04:24:00 -0000 Message-ID: Subject: Python API: Type introspection of function arguments From: =?UTF-8?Q?Martin_=C3=9Cnsal?= To: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-09/txt/msg00021.txt.bz2 Hi all, GDB Python bindings are great. I have a question though. I'm trying to use a Python script to introspect the type of a function argument. The GDB documentation claims this is possible: https://sourceware.org/gdb/current/onlinedocs/gdb/Types-In-Python.html#Type= s-In-Python "=E2=80=94 Function: Type.fields () For structure and union types, this method returns the fields. Range types have two fields, the minimum and maximum values. Enum types have one field per enum constant. Function and method types have one field per parameter." However when I try this (in 7.8.1.20141128-cvs) I get the following error: >>> sym =3D gdb.lookup_global_symbol('my_function') >>> print sym.type.code =3D=3D gdb.TYPE_CODE_FUNC True >>> print sym.type.fields() Traceback (most recent call last): File "", line 1, in TypeError: Type is not a structure, union, or enum type. >>> I also looked in the code (gdb/python/py-type.c) and this seems to have the same behavior in 7.10. In light of this issue, can anyone suggest how to get function argument type information from Python API? Thanks, Martin