From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by sourceware.org (Postfix) with ESMTPS id F2A603858D33 for ; Mon, 2 May 2022 07:28:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F2A603858D33 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2057.outbound.protection.outlook.com [104.47.14.57]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-4-VEuT9K8TMCSgq4Vtva-rGg-1; Mon, 02 May 2022 09:28:09 +0200 X-MC-Unique: VEuT9K8TMCSgq4Vtva-rGg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NZgKf8QAxwrN9XsdJ3xO0rU12uRGLIwMinPEEyZknzqubDlrxhm98BD35MX2jXcdzbiX+OQvA4UXNp5kn77cM5g22XJ6S+jtUrWY9DZoLsM6H+N9TvsInwqmQnEmdoRlA9e8eW5CeU78LgB7QHzp2h2C0gV+soeWC8TKfhAEggN6A4F1XAXG+wCbq2Gx68W0pK5UW8+m7fIUhQght2bHln42rE6dLCplxP5L9ubwrEGbWb6XkXgns42/ViZBe8ka1YKynu+7tYhkt0ED8XXDMoaDIBerVaGva6CZJpjx0XOPkYlDYQ4/9BB3Z6FAXPnT+0jbZWN2E0Pvn/dcJKsO+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y4dhyouAL/AqRlxJwJxTK05sH0R81GVysmlMKPaQqvY=; b=Pc5VkW9rr+XbUztRNmgnZj/gk/BUHgusrdPn6S/sEwcWGjA58a3wmUIzNQRpf3oVF+N03/1ygUWECiwVf1RUikbOr0HwERprqraTRMIInM+KCOt/krNQyEKg8Qiem/eqYsFMoTCOQXaD5AXNm2R6gVKGGhb5pV6jQRkNwknSLdNa9mBTn81iVfncXB6kcAEl+ruAuR/5HAG8JlXjKdobC9BXTI7Mq0dWwXe80UvWri0bp0XhIEuE0MQtL449QhhhOrzeOs9IFJyEN94m9BOYBF+Q+f6gsgMQGUaDeMXvZjKzrcTJoq5x37Hb63ADBRNIYrjEyscbpqpIJDY3DAokGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from DU2PR04MB8616.eurprd04.prod.outlook.com (2603:10a6:10:2db::16) by DB7PR04MB5420.eurprd04.prod.outlook.com (2603:10a6:10:8e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.28; Mon, 2 May 2022 07:28:07 +0000 Received: from DU2PR04MB8616.eurprd04.prod.outlook.com ([fe80::5cb0:5195:4203:7c2f]) by DU2PR04MB8616.eurprd04.prod.outlook.com ([fe80::5cb0:5195:4203:7c2f%8]) with mapi id 15.20.5206.013; Mon, 2 May 2022 07:28:07 +0000 Message-ID: Date: Mon, 2 May 2022 09:28:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 2/2] libopcodes: extend the styling within the i386 disassembler Content-Language: en-US To: Andrew Burgess References: <388c1dd1235a3c95aefc7caee5726b869b6894e0.1651239378.git.aburgess@redhat.com> Cc: binutils@sourceware.org From: Jan Beulich In-Reply-To: <388c1dd1235a3c95aefc7caee5726b869b6894e0.1651239378.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AS9PR04CA0145.eurprd04.prod.outlook.com (2603:10a6:20b:48a::15) To DU2PR04MB8616.eurprd04.prod.outlook.com (2603:10a6:10:2db::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 039a2b2d-7f7a-44dd-5986-08da2c0d4dad X-MS-TrafficTypeDiagnostic: DB7PR04MB5420:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LMNSQy+3+BjvxaFIPbVMrzEGlVKbor+GPt6gtgp49RaJhGGs+X22/+aBZ9zts3piXAyQ2bQ92jCyeVSUsyVGOx9nuNgp/Bvwx9V8D717QaZn+04cCxFraP8M7HYBSP8kgMMIYJ7P0nTUekPW3vJaBt+nCwpgUAJ8z2aRsNAQSh9WAtYCJ7vXPEEcoyvOK3QJ2rpNHHuCAi5fpc6jdnqvpqzYnfSlzSZKLt4CsgvnoaBzAc5rN46DPJGoXceubxjdlnror8zwQ50jWNXqqkZdWjH7LRY43fgAwYFtVGZglsouHlxvaxut2/koWUf/Us20IWIAnIK+AT9xo6SPdhUMQZauNAqYkYhu3PEzE+GxP8rshDIv6O7m8rnGwSfIPpTAkuiZVlCrDJwAOdV2ALVaXfjVaKByhQ090Ie1voRnLy7oaf4c+JEXnC2xb5AaipLOyNIiFVD8kVmp+tIwpc8wQ+3dHrMDU+H3ShaoKdj+MZ7n84Pbowoi0E5Uh7oDiHllaMXJRpBbEg3dwzbr0FRyvBVT27GQs12qgxEVmNqyBGWwXEbbmnxtNUv6BlrLGqfpN+t2a8bmDSG5DKh+xHz/JQuK4qzg11TfO8abxo0Zsun/bO8u56ZvBAQY2y3Tzojg+rx3LJzZRxXg5tZOMLMsuFwr3nBO4vKAvTCq1Kjeg9/m1TfFNMaffnhqYxsbb1k8XT+4LUTag4AL3UcW0CuwtmkeUQ1qkIYp71YYoB7E67uvbFVZRlAK//qRuWKyBuDO X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8616.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(26005)(186003)(6512007)(508600001)(316002)(5660300002)(31696002)(2616005)(4326008)(66476007)(66946007)(66556008)(8676002)(6506007)(86362001)(6916009)(38100700002)(2906002)(53546011)(8936002)(31686004)(36756003)(6486002)(83380400001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NmJlQ1NBY1R5c1llWFpKN2NLV1VEaDdRb2oxazJQMUlpUER3TEt3RDB2cVVP?= =?utf-8?B?cTRtUjNMRWQ1QlJwaG5EN0h3NjBEVTg1Z2hxTFhyODNHUEpnOGtYTGdUQU4r?= =?utf-8?B?Y013bXNGeURNVTRiTE83N3JCTkxnV3lKcHhldi8vdWt4eUVmNFRvRU5tbnlk?= =?utf-8?B?SWdQQlMyUUl0akRkZ2JGZ1FDWFlBejEzWFBjT0VrSUVhSjU2Q2pkS2dXN1VN?= =?utf-8?B?TXc5N3ozcGZud2FDQ1NDL3EzeEVWRGRJSXBQQTNEQjA1WklBUFVDb1V6SlBj?= =?utf-8?B?UlBkc3JvMndkV3dQUiswellkeVdrR1JmbW5HTlp5VUtIZ1F2KzR1Zitaallh?= =?utf-8?B?VU1EVFhNOVFneGc3TmU1WTl2TGlwdkkvVXIzL1JBekJ1U0NIeWFHdHp1WFNX?= =?utf-8?B?c1NsYkp6TlE2eFBQR2FSQkh5Mm9rc2lRNGdGVUp0SDJ2TWJLaUIwZ3Rpd044?= =?utf-8?B?dDJWbGpXL1hLSU8va0Q1VUh1UStZSWJ5REI1RkZrV3M4ckFRRFFlc0JZMXdp?= =?utf-8?B?OFp3UTc3LzhQUmRTOUF2azdBOWlZa2hFUStkbmt1QkpCeW5xNjRUL1ptMmV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ant-Network-Message-Id: 039a2b2d-7f7a-44dd-5986-08da2c0d4dad X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8616.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2022 07:28:07.7000 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 27um6XLAsTdwuyEGtEB+nAplfXqozKCymB7rP9uWSwhMLWsOfm6PYvwUUHftjH9Et98MhnaaCkZHVn1hd6+Kjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5420 X-Spam-Status: No, score=-3032.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2022 07:28:12 -0000 On 29.04.2022 15:42, Andrew Burgess via Binutils wrote: > The i386 disassembler is pretty complex. Most disassembly is done > indirectly; operands are built into buffers within a struct instr_info > instance, before finally being printed later in the disassembly > process. > > Sometimes the operand buffers are built in a different order to the > order in which they will eventually be printed. > > Each operand can contain multiple components, e.g. multiple registers, > immediates, other textual elements (commas, brackets, etc). > > When looking for how to apply styling I guess the ideal solution would > be to move away from the operands being a single string that is built > up, and instead have each operand be a list of "parts", where each > part is some text and a style. Then, when we eventually print the > operand we would loop over the parts and print each part with the > correct style. > > But it feels like a huge amount of work to move from where we are > now to that potentially ideal solution. Plus, the above solution > would be pretty complex. > > So, instead I propose a .... different solution here, one that works > with the existing infrastructure. > > As each operand is built up, piece be piece, we pass through style > information. This style information is then encoded into the operand > buffer (see below for details). After this the code can continue to > operate as it does right now in order to manage the set of operand > buffers. > > Then, as each operand is printed we can split the operand buffer into > chunks at the style marker boundaries, with each chunk being printed > in the correct style. > > For encoding the style information I use the format "~%x~". As far as > I can tell the '~' is not otherwise used in the i386 disassembler, so > this should serve as a unique marker. To speed up writing and then > reading the style markers, I take advantage of the fact that there are > less than 16 styles so I know the '%x' will only ever be a single hex > character. Like H.J. I'd like to ask that you avoid ~ here (I actually have plans to use it to make at least some 64-bit constants better recognizable); I'm not sure about using non-ASCII though, as that may cause issues with compilers treating non-ASCII wrong. I'd soften this to non-alnum, non- operator characters (perhaps more generally non-printable). Otoh I guess about _any_ character could be used in symbol names, so I'm not convinced such an escaping model can be generally conflict free. Jan