From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: GDB and compiler-operations Date: Fri, 07 Sep 2018 13:59:41 -0600 Message-ID: <875zzhxemq.fsf@tromey.com> References: <5a2c709e-aa49-b5b6-3fbe-fb8bd33acb23@cs.ucla.edu> <06d01a4b-9d98-df5b-be8a-aeda449acad7@cs.ucla.edu> <83bm99vijd.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1536350356 22201 195.159.176.226 (7 Sep 2018 19:59:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 7 Sep 2018 19:59:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 07 21:59:12 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fyMuN-0005eH-PO for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2018 21:59:11 +0200 Original-Received: from localhost ([::1]:40095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyMwU-0007RW-0L for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2018 16:01:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyMvd-0007Kg-AN for emacs-devel@gnu.org; Fri, 07 Sep 2018 16:00:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fyMvY-00066B-HI for emacs-devel@gnu.org; Fri, 07 Sep 2018 16:00:29 -0400 Original-Received: from gateway24.websitewelcome.com ([192.185.51.253]:20777) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fyMvY-00061L-59 for emacs-devel@gnu.org; Fri, 07 Sep 2018 16:00:24 -0400 Original-Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 08FD7510A for ; Fri, 7 Sep 2018 15:00:22 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id yMurfswOibXuJyMvFfCjPB; Fri, 07 Sep 2018 15:00:21 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QoOprlJ7a75Di0qfTrpveEw8pjlpNVQmaqt0q33AlNU=; b=ps8cbIxMtn0Fl/AB7HpFxAWCk+ 6A2YUnWoElwTKmFwfI7cNpCsDuT82+dajnqaV8U+1JRt0KwamA/sI8vGzqd22uwFoTP+Cgd9+AsRQ vHpUb2MNOtvxS6zaHEGmvPqNf; Original-Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:50836 helo=pokyo) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fyMur-001Tz0-Om; Fri, 07 Sep 2018 14:59:41 -0500 X-Attribution: Tom In-Reply-To: (Stefan Monnier's message of "Fri, 07 Sep 2018 10:12:06 -0400") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.85.72 X-Source-L: No X-Exim-ID: 1fyMur-001Tz0-Om X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-85-72.hlrn.qwest.net (pokyo) [75.166.85.72]:50836 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.51.253 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:229448 Archived-At: >>>>> "Stefan" == Stefan Monnier writes: Stefan> Along the way I discovered that while `sizeof` works great, `offsetof` Stefan> gives me an error: Stefan> No symbol "offsetof" in current context. Stefan> any idea why this is (and how to fix it)? Other people answered the why. To fix it you have two options. One, define an offsetof macro: (gdb) macro define offsetof(type, field) ((int) (((type *) 0)->field)) The gdb C expression parser will automatically use macros you define interactively. Two, instead of using offsetof to inspect a type, upgrade to a newish (8.1 or better) gdb and use "ptype/o": (gdb) ptype/o struct Lisp_Vector /* offset | size */ type = struct Lisp_Vector { /* 0 | 8 */ union vectorlike_header { /* 8 */ ptrdiff_t size; /* 1 */ char gcaligned; /* total size (bytes): 8 */ } header; /* 8 | 0 */ Lisp_Object contents[]; /* total size (bytes): 8 */ } The output here is modeled on the pahole utility. If you can't upgrade gdb, there's a "pahole.py" script out there that adds a pahole command to gdb instead. I can email it if you really need it, but some distros installed it by default. So you could just try "(gdb) pahole struct Lisp_Vector". Tom