From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44902 invoked by alias); 2 Feb 2016 08:25:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 44887 invoked by uid 89); 2 Feb 2016 08:25:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=stretch, linux.git, UD:linux.git, linuxgit X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 02 Feb 2016 08:25:15 +0000 Received: by mail-wm0-f44.google.com with SMTP id l66so105022548wml.0 for ; Tue, 02 Feb 2016 00:25:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=UmHmlXLMky7eGmMgNbQPPzevUEJ7ebPtkiVbGbehkCo=; b=d0jTJ//3o+YRrwNkGpNZAWpFc24LDhaipPoFe6gEL7uzp3lpn2Jw2Ane0iKj+hoFhq RnTcZA3jXDBtbLVz3IN8vlF/WsATLAPpmKnpucZhXkuLo0J0Iz4x3YoiaGKT6X0uWeE5 7vCfdQNODP4J+nB0LWBHzK+QtjU6Js5LSB6YxgRLvu5uVRdD8pI66xRskEp2KrXv/R0c Hy5mehziB/ueA55oigGafbxyC4z81zuAchlY+WMcArfxLK2spQ+ecy4T6PTpEeT7uN3m mn8tqbH0p+6TGL5xmiMsq1MEs/hLVAqWYCuykAtMFeGvV4e8XyibLa+ax0A68r64Zhw3 qr5Q== X-Gm-Message-State: AG10YOTCcB6xmHQ0tsRWG/VZp9h/96F4KY4GRoyF/U3ZdUyNO9D4Wa2In7O4881J+7lqxQ== X-Received: by 10.28.97.135 with SMTP id v129mr16619908wmb.78.1454401511877; Tue, 02 Feb 2016 00:25:11 -0800 (PST) Received: from [192.168.0.31] (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net. [92.232.232.66]) by smtp.gmail.com with ESMTPSA id 75sm15287525wmo.22.2016.02.02.00.25.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Feb 2016 00:25:10 -0800 (PST) Subject: Re: [PATCH 2/4] Add Jeff Mahoney's py-crash patches. To: Jeff Mahoney , Doug Evans , Ales Novak References: <1454276692-7119-1-git-send-email-alnovak@suse.cz> <1454276692-7119-3-git-send-email-alnovak@suse.cz> <56B01AB9.90005@suse.com> Cc: gdb-patches , Peter Griffin , Lee Jones From: Kieran Bingham X-Enigmail-Draft-Status: N1110 Message-ID: <56B067E5.8070606@gmail.com> Date: Tue, 02 Feb 2016 08:25:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56B01AB9.90005@suse.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00041.txt.bz2 On 02/02/16 02:55, Jeff Mahoney wrote: > On 2/1/16 5:22 PM, Doug Evans wrote: >> On Sun, Jan 31, 2016 at 1:44 PM, Ales Novak >> wrote: >>> --- gdb/Makefile.in | 12 ++ >>> gdb/python/py-minsymbol.c | 353 >>> +++++++++++++++++++++++++++++++++++++ gdb/python/py-objfile.c >>> | 29 +++- gdb/python/py-section.c | 401 >>> +++++++++++++++++++++++++++++++++++++++++++ >>> gdb/python/py-symbol.c | 52 ++++-- >>> gdb/python/python-internal.h | 14 ++ gdb/python/python.c >>> | 7 +- 7 files changed, 853 insertions(+), 15 deletions(-) >>> create mode 100644 gdb/python/py-minsymbol.c create mode 100644 >>> gdb/python/py-section.c > > >> Hi. > > Hi Doug - > >> Part of what this patch is doing is exporting bfd to python. E.g., >> all the SEC_* constants. > >> As a rule we absolutely discourage people from using bfd outside >> of the the binutils+gdb source tree. Either this rule needs to >> change, or I don't think we can allow this patch. I'd be interested >> to hear what others in the community think. > > That's unfortunate. The Linux kernel uses ELF sections for a number > of purposes. Most notably is the definition of per-cpu variables. > Without the ELF section, we can't resolve the addresses for the > variables. So, from our perspective, it's a requirement. Jeff, I haven't yet looked into your code specifically to check your per-cpu implementation detail yet, so I'll just speculate for a moment: Have you seen that we can obtain per_cpu variable from linux.git/scripts/gdb/linux/cpus.py ? def per_cpu(var_ptr, cpu): if cpu == -1: cpu = get_current_cpu() if utils.is_target_arch("sparc:v9"): offset = gdb.parse_and_eval( "trap_block[{0}].__per_cpu_base".format(str(cpu))) else: try: offset = gdb.parse_and_eval( "__per_cpu_offset[{0}]".format(str(cpu))) except gdb.error: # !CONFIG_SMP case offset = 0 pointer = var_ptr.cast(utils.get_long_type()) + offset return pointer.cast(var_ptr.type).dereference() >> For myself, I would much rather export ELF separately (e.g., a >> separate python API one can use independent of any particular tool, >> including gdb), and then have gdb provide the necessary glue to use >> this API. [I can imagine some compromises being needed, at least >> for now; e.g., it'd be cumbersome to read in all ELF symbols >> twice. But fixing that is just an optimization.] > > Ok, that's doable. As it is, the section code mixes GDB and BFD > pretty heavily. It shouldn't be too difficult to separate the two out > and push the section stuff into a new BFD python interface and > associate the objfiles with it. Some of our further work (/stretch goals) on Linux Kernel Awareness, will also utilise this so I will be interested to see how it goes. > -Jeff > > >>> ... + if (PyModule_AddIntConstant (gdb_module, "SEC_NO_FLAGS", >>> SEC_NO_FLAGS) < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_ALLOC", SEC_ALLOC) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_LOAD", SEC_LOAD) < 0 + || >>> PyModule_AddIntConstant (gdb_module, "SEC_RELOC", SEC_RELOC) < 0 >>> + || PyModule_AddIntConstant (gdb_module, "SEC_READONLY", >>> SEC_READONLY) < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_CODE", SEC_CODE) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_DATA", SEC_DATA) < 0 + || >>> PyModule_AddIntConstant (gdb_module, "SEC_ROM", SEC_ROM) < 0 + >>> || PyModule_AddIntConstant (gdb_module, "SEC_CONSTRUCTOR", + >>> SEC_CONSTRUCTOR) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_HAS_CONTENTS", + >>> SEC_HAS_CONTENTS) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_NEVER_LOAD", + >>> SEC_NEVER_LOAD) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_THREAD_LOCAL", + >>> SEC_THREAD_LOCAL) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_HAS_GOT_REF", + >>> SEC_HAS_GOT_REF) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_IS_COMMON", + >>> SEC_IS_COMMON) < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_DEBUGGING", + SEC_DEBUGGING) >>> < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_IN_MEMORY", + SEC_IN_MEMORY) >>> < 0 + || PyModule_AddIntConstant (gdb_module, "SEC_EXCLUDE", >>> SEC_EXCLUDE) < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_SORT_ENTRIES", + >>> SEC_SORT_ENTRIES) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_LINK_ONCE", + >>> SEC_LINK_ONCE) < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_LINK_DUPLICATES", + >>> SEC_LINK_DUPLICATES) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_LINK_DUPLICATES_DISCARD", + >>> SEC_LINK_DUPLICATES_DISCARD) < 0 + || >>> PyModule_AddIntConstant (gdb_module, >>> "SEC_LINK_DUPLICATES_ONE_ONLY", + >>> SEC_LINK_DUPLICATES_ONE_ONLY) < 0 + || >>> PyModule_AddIntConstant (gdb_module, >>> "SEC_LINK_DUPLICATES_SAME_SIZE", + >>> SEC_LINK_DUPLICATES_SAME_SIZE) < 0 + || >>> PyModule_AddIntConstant (gdb_module, "SEC_LINKER_CREATED", + >>> SEC_LINKER_CREATED) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_KEEP", SEC_KEEP) < 0 + || >>> PyModule_AddIntConstant (gdb_module, "SEC_SMALL_DATA", + >>> SEC_SMALL_DATA) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_MERGE", SEC_MERGE) < 0 + || >>> PyModule_AddIntConstant (gdb_module, "SEC_STRNGS", SEC_STRINGS) < >>> 0 + || PyModule_AddIntConstant (gdb_module, "SEC_GROUP", >>> SEC_GROUP) < 0 + || PyModule_AddIntConstant (gdb_module, >>> "SEC_COFF_SHARED_LIBRARY", + >>> SEC_COFF_SHARED_LIBRARY) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_ELF_REVERSE_COPY", + >>> SEC_ELF_REVERSE_COPY) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_COFF_SHARED", + >>> SEC_COFF_SHARED) < 0 + || PyModule_AddIntConstant >>> (gdb_module, "SEC_COFF_NOREAD", + >>> SEC_COFF_NOREAD) < 0) + return -1; ... > > > >