From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kJ3EHxr2gmGKVAAAWB0awg (envelope-from ) for ; Wed, 03 Nov 2021 16:50:34 -0400 Received: by simark.ca (Postfix, from userid 112) id 6E3C21F0C1; Wed, 3 Nov 2021 16:50:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CC13C1EDDB for ; Wed, 3 Nov 2021 16:50:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9E1A385800A for ; Wed, 3 Nov 2021 20:50:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9E1A385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635972633; bh=dgAAm7PHwuPNTjdy6dz9YLrnM5JAzdT/oyselopfx/g=; h=To:References:Subject:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=viFHj/jYSz+NeGCQ6AfE/Sc4eCCSn8Ko9XnRBQBBBSc3RPM2awt9aDZTRtaDIuxV8 aCTZfhK5rNBXBJUrALMJ6L6fcQ869bhakl6xze5/NCKN9DKl5dQJd0zXjZHKYDQmaN LDTTSlCCoRnnS0fYL4Vh56HgRbPiXW8COkxLps5M= Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 8B4893858D28 for ; Wed, 3 Nov 2021 20:50:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B4893858D28 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miNCw-0007Q0-KM for gdb@sourceware.org; Wed, 03 Nov 2021 16:50:06 -0400 Received: from ip5f5a8d68.dynamic.kabel-deutschland.de ([95.90.141.104]:61229 helo=[192.168.111.41]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miNCw-0005Vg-CG for gdb@sourceware.org; Wed, 03 Nov 2021 16:50:06 -0400 To: gdb@sourceware.org References: <60c53fa8bf160533a2eddf1da280eb50c7461a6a.camel@fit.cvut.cz> Subject: UnicodeDecodeError on gdb.execute Message-ID: <33ec492b-3689-80fd-ca78-a4e2e69b9180@gnu.org> Date: Wed, 3 Nov 2021 21:50:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <60c53fa8bf160533a2eddf1da280eb50c7461a6a.camel@fit.cvut.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit 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: , From: Simon Sobisch via Gdb Reply-To: Simon Sobisch Errors-To: gdb-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb" For some special file I need to look at the source code from within the GDB extension. I did this with the reasonable and obious output = gdb.execute("list *" + hex(sal.pc), False, True) (and get more lines with a follow-up "list" [not all are needed, otherwise the gdb.parameter("listsize") could be adjusted). I _think_ the problem I expect now is because of a system with Python3 which has default utf8 encoding, but it _may_ was also in before: There's a python exception UnicodeDecodeError in this line whenever it contains "extended" ascii. "list" in GDB shows the code correctly; also (gdb) py gdb.execute("list 14") shows the correct text, but as soon as python has to internally decode it to store a string: (gdb) py gdb.execute("list 14", False, True) Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 18: invalid start byte Error while executing Python code. is there any way I could adjust the encoding used for storing gdb.execute as string? Is there a reason that this isn't by default set to match gdb.target_charset() ? Thanks for insights to this issue, too, Simon