Date: Fri, 15 Mar 2019 11:43:42 -0700 From: John Baldwin <jhb@FreeBSD.org> To: Gleb Smirnoff <glebius@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r345196 - head/sys/sys Message-ID: <5d6a44da-7980-e8a1-a41f-2d30e373b3a8@FreeBSD.org> In-Reply-To: <763f5e3c-38c1-2920-8138-6bae9482ad1f@FreeBSD.org> References: <201903151818.x2FII5Kv085552@repo.freebsd.org> <763f5e3c-38c1-2920-8138-6bae9482ad1f@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 3/15/19 11:28 AM, John Baldwin wrote: > On 3/15/19 11:18 AM, Gleb Smirnoff wrote: >> Author: glebius >> Date: Fri Mar 15 18:18:05 2019 >> New Revision: 345196 >> URL: https://svnweb.freebsd.org/changeset/base/345196 >> >> Log: >> Deanonymize thread and proc state enums, so that a userland app can >> use them without redefining the value names. New clang no longer >> allows to redefine a enum value name to the same value. >> >> Bump __FreeBSD_version, since ports depend on that. >> >> Discussed with: jhb > > Note that devel/mdb from before this commit will no longer work on > kernels built with this commit (so you can't use mdb on a 12.x box > to cross-debug a crash with this change anymore). Similarly, once > mdb is fixed to build with this change, a new mdb built with this > won't work with older kernels. For background, mdb makes "clever" use of CTF debug info. You declare a structure in the debugger (or one of the debugger modules) that contains a subset of the fields of the type from the thing you are debugging. mdb then compares the CTF of the two structures and figures out how to copy the needed fields from the target structure into the smaller one in the debugger module handling endian-ness swaps, integer size differences, etc. However, it requires the types of each field to be identical. The simplest way to do this is to make a copy of the field by literally copying the fields (in this case from sys/proc.h). This meant that mdb had structs like this: typedef struct { ... enum { TDS_INACTIVE = 0, ... } td_state; } mdb_thread_t; clang 8, in its infinite wisdom decided that the existing enum values in <sys/proc.h> conflicted with the ones in mdb_thread_t even though the numerical value of the enumerators was identical. Note that even with this change, the existing code can't be copied verbatim to mdb as using 'enum td_states { TDS_INACTIVE' once again triggers clang 8's hyper-sensitivity. Thus, with clang 8 it is now impossible to copy and paste enum fields from the target structure to the debugger version of the structure if you ever include the original header for some other reason. I consider this to be a compiler bug that it isn't able to understand that 0 == 0. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5d6a44da-7980-e8a1-a41f-2d30e373b3a8>