From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from GBR01-CWL-obe.outbound.protection.outlook.com (mail-eopbgr110088.outbound.protection.outlook.com [40.107.11.88]) by sourceware.org (Postfix) with ESMTPS id 3A13A3858D28 for ; Fri, 5 Nov 2021 12:22:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A13A3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codeplay.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=codeplay.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QTITn+U2e2/+AKS4RYfQIhFFF0deXAJCQVP0IveLRFuCACGDeBOfdtJk5GaOfHXtCWwdRWjcjEiNLwZ4PGwHcFbEt2oH58SP67Jjy+kBe4hsAuusin8cIA+8VQSinKm4ESeW+CvHBHk2xF92gsvFN+HCd1l93MYJII/WmmoQhTdPp3H+1McL2C8RYAhetNuTDIsEFzqFrzXtfEoW61apGrHow+YoOvDwhtiWbSxUGqhBev68MiutJHsZwXhWHLEz4g6G7BMU0gsEcgZqegmn7CtHP51IwhHojtrxlqPMcz8FdVjqlBQzxa/YCOxhiJLYwT6s5rWiQrsPWqgMI7sU8A== 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=09MeLVLhPS90MSn+vvWtwhtwPGGx+OCSPQRac15+Sgg=; b=VQtFNQ6JZWikse4z3KmPDFDO/9yN/OT+gIwZPzRsbU2A/Nf31fQ9hwmSjGhfOuodFZUrf4cY5CH3xtsTKiUB9580O9YUD41yGnoqy6+iV78GbMy6dESxNsIA5OCeti5ax/s4KpyNW82kckiqVzZ4NLOrlm1OvBijQFTJ1vGc4vGel5Sg3caoNJuo9fjUM1QN1QRATyK6lPSYmsojA2E3RHCUmSViq4SCtBUycX8NDbxs3J57Sh+CKH9cbgJ+jDkw0Od7wHdtBTgw69dZLxNEPCpxigG+e7CniDxSzQHFc2gnNnNjAjNgafK7FxkdW+/GAabh9UtLwh8cjafXWh8Kig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=codeplay.com; dmarc=pass action=none header.from=codeplay.com; dkim=pass header.d=codeplay.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeplay.onmicrosoft.com; s=selector2-codeplay-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=09MeLVLhPS90MSn+vvWtwhtwPGGx+OCSPQRac15+Sgg=; b=qTQTnqWkYp75MQ0RCU+v+dQ1NOn8JyBFKFaHOtLOGXi+e4eZfb9eQurDAXvcHFQX9aXLRTOXx28YbgBtiby2VTvkVqTr0iYjG2QF9k9bwuKFx9aNeU7YPXFeTtdkOeec0QFuZBZ97oRIBo6yw7hvWRKo8V9ocxpcZioYRC1oOhs= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=codeplay.com; Received: from CWXP265MB0551.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:b::17) by CWLP265MB3089.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:bb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Fri, 5 Nov 2021 12:22:46 +0000 Received: from CWXP265MB0551.GBRP265.PROD.OUTLOOK.COM ([fe80::3848:b5e3:6ca3:25b9]) by CWXP265MB0551.GBRP265.PROD.OUTLOOK.COM ([fe80::3848:b5e3:6ca3:25b9%2]) with mapi id 15.20.4649.021; Fri, 5 Nov 2021 12:22:46 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 05 Nov 2021 12:22:45 +0000 Message-Id: To: "David Blaikie" , "gdb" Subject: Re: Concatenating LazyStrings From: "Luke Drummond" References: In-Reply-To: X-ClientProxiedBy: DB6PR0802CA0045.eurprd08.prod.outlook.com (2603:10a6:4:a3::31) To CWXP265MB0551.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:b::17) MIME-Version: 1.0 Received: from localhost (185.34.9.74) by DB6PR0802CA0045.eurprd08.prod.outlook.com (2603:10a6:4:a3::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 12:22:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cffa226-5efb-4682-1870-08d9a056f928 X-MS-TrafficTypeDiagnostic: CWLP265MB3089: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d1NyHA7gGsoDinVlk/nVoycxq+Qxplex7iks7yFp94Uihu6k2Ehx9joSUUUgiZ6EO3m5sf6/OPJorA8GEVloYjvfDm3Z4wZs/UGre4WTJRP7qTp5qMT0n4FlaXPJ7COuwJHtThitaeXPged1fd7r0iz8J5GGOZjsQ+/O+Xt84ZsO1qSg24cQ4cOUKX7+FlY+Z4BdQxLJiiLSzTPJ3DIR8wAYEDwAOFDYF4osS3m0tgiZHrWtHb1XSn8nhRxOakgHCBUMpGtqGQBvV5P/lnA/YaPRv2Tc9whtFlWMM5iQilu+mwxf+uiCASsNWoJEiUNqFdlajwLrgwGSeiSQs3qa63LMm/axf9JSgaly3O8vEknbgudU/nLlr7cHfmAAu0Gs8Cg7Ijgx3rTPE33h8nP3H6DiY2zUv47wgFyNJA/tptxmMbhuTx6cdV/MUXphlMZbnX7wBShxEsy9OEzprIJr5E0/6ibea27jXxZiqmpuOyQom/lFghN7wCpdWprLwUWA/PGICTSHk2tWdF7Bo5GtbDi7NEvVBiPFuwFl53XbGLhlRx4KX06QVOMnNFw+xQLGY8sdy6aK0eHURozOiKZ2DNViO29X3RUk7i9xREUCAkJnerDCozwoKLlQab+C/ToFSjvmh0pn31aUOkrzHmZYVAR7faM2zVStFjxOpN74zPP3fiWqxBkcEvd0JonNXt1fK8o6zTiK0urc9oNz3IwHzu6q4qDNLt4KchVPGJnds8RWUnd4I1B688gF8DY+7S8OW8hmekVGSU0FcCXUwGeA6XNJERFV3vVSFlql5BXNhfMpzduWTtA+qk6fgGmFl9N0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CWXP265MB0551.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(7916004)(39830400003)(396003)(376002)(346002)(366004)(136003)(52116002)(3480700007)(316002)(508600001)(956004)(110136005)(9686003)(38350700002)(38100700002)(6496006)(26005)(83380400001)(2906002)(86362001)(33656002)(33716001)(966005)(66946007)(66476007)(66556008)(186003)(5660300002)(8936002)(7116003)(6486002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NUtxYUhyR0tJVW10R1FFR1Vzc0R2MTlKMTlqd0FVWmVnSEhVVnVaRkFMWEJZ?= =?utf-8?B?L1hsdXhUUFJpV1RRK3dWbXpMRGhCenNUMlJ3aEZ2cVVYaFkvV1F1SWt1V3c1?= =?utf-8?B?cXlqb2FMcUwvVkJjNGtNSUFRQ0JkZFlQbHhZUjIrdHhVVjI5Ky9oWGZRVm0z?= =?utf-8?B?d0hzMmhEQm1YMFNsWDM2ZzRzWTJNaEs0ZnNBWUloZ2ppT3NNcGErOE0rMFQ2?= =?utf-8?B?RmJKSWtFVWNHcEFRb1JLQTFoMllWODFQdE5v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bUV2Q2FOWldKMFlsK1BOVzF0WjdoUDI3RlB0?= =?utf-8?B?VTZSTURIZ1AzQ2hDTjFML2NCSnc4MTR6Mm1IdHNnaDEwUVRMWHdNNnJxazVJ?= =?utf-8?B?RHVjUG15Qmw5OGdMazQzMkk5NklrNTVsOEZCOVRrQWRxNDl2N1B2NEVaWnZE?= =?utf-8?B?YnoyWE84bTlwOWFRbWQ5WkEvZlRCZ1Y4KzVTdkd2dDJNUi90RlVHQ254dURE?= =?utf-8?B?YU9QcVU2c256eWRuTDBHTUdjUFFRPT0=?= X-OriginatorOrg: codeplay.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cffa226-5efb-4682-1870-08d9a056f928 X-MS-Exchange-CrossTenant-AuthSource: CWXP265MB0551.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 12:22:45.9690 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d2e4de91-8500-415e-a646-3a069a1921ca X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BBqyCrDjvrc4DetuiTEXOeiJG+GdFcxSMzDYMx2iYqGwD0xyp+xo7PuxmMMw6inlvolz3mvLB6AXnEcb5VWyoaRQYigbMyE9Sz3CYWuIkp0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP265MB3089 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 12:22:53 -0000 Hi David On Fri Nov 5, 2021 at 3:14 AM GMT, David Blaikie via Gdb wrote: > If I've got a pretty printer (for instance, for llvm's Twine type ( > https://github.com/llvm/llvm-project/blob/6d03227c16ee1950db0e1aa05fbc320= 1770248eb/llvm/utils/gdb-scripts/prettyprinters.py#L354 > + https://llvm.org/doxygen/classllvm_1_1Twine.html ) that wants to > pretty > print a string made up of other strings (from other pretty printers) - > how > would I do that? > > Specifically, I can't figure out how to correctly concatenate a gdb > LazyString value with another string. (even if I have to stringify the > LazyString (making it unlazy) in the process - calling ".value()" on the > LazyString doesn't seem to be enough - I can't seem to figure out how to > to-string-ify that resulting gdb Value (it doesn't have a pretty printer > that I can find - nor a to_string/str/string() function) to then > concatenate it with another string) `LazyString.value().format_string()` might be what you want. I've also foun= d the python builtin `str()` function to be usable in many places. https://sourceware.org/gdb/onlinedocs/gdb/Values-From-Inferior.html#Values-= From-Inferior has the documentation if you haven't already seen it. As an example, here's how I format an enumeration that's made up of bit-fla= gs: def fmt_flags_enum(enum_type, val): val =3D int(val) return ' | '.join( gdb.Value((1 << x) & val).cast(enum_type).format_string() for x in range(val.bit_length()) if (1 << x) & val ) The `format_string()` converts the individual enumerators into a string tha= t python can concatenate with `str.join`. Hope that helps. All the Best Luke --=20 Codeplay Software Ltd. Company registered in England and Wales, number: 04567874 Registered office: Regent House, 316 Beulah Hill, London, SE19 3HF